@sphereon/ssi-sdk.data-store 0.15.2-next.6 → 0.15.2-next.95

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 (213) hide show
  1. package/dist/contact/AbstractContactStore.d.ts +21 -11
  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 +25 -21
  5. package/dist/contact/ContactStore.d.ts.map +1 -1
  6. package/dist/contact/ContactStore.js +216 -136
  7. package/dist/contact/ContactStore.js.map +1 -1
  8. package/dist/entities/contact/BaseConfigEntity.d.ts +2 -0
  9. package/dist/entities/contact/BaseConfigEntity.d.ts.map +1 -1
  10. package/dist/entities/contact/BaseConfigEntity.js +10 -2
  11. package/dist/entities/contact/BaseConfigEntity.js.map +1 -1
  12. package/dist/entities/contact/BaseContactEntity.d.ts +10 -0
  13. package/dist/entities/contact/BaseContactEntity.d.ts.map +1 -0
  14. package/dist/entities/contact/BaseContactEntity.js +54 -0
  15. package/dist/entities/contact/BaseContactEntity.js.map +1 -0
  16. package/dist/entities/contact/ConnectionEntity.d.ts +1 -2
  17. package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
  18. package/dist/entities/contact/ConnectionEntity.js +2 -21
  19. package/dist/entities/contact/ConnectionEntity.js.map +1 -1
  20. package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -3
  21. package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -1
  22. package/dist/entities/contact/CorrelationIdentifierEntity.js +8 -11
  23. package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
  24. package/dist/entities/contact/DidAuthConfigEntity.d.ts +0 -4
  25. package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -1
  26. package/dist/entities/contact/DidAuthConfigEntity.js +1 -17
  27. package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
  28. package/dist/entities/contact/ElectronicAddressEntity.d.ts +14 -0
  29. package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -0
  30. package/dist/entities/contact/ElectronicAddressEntity.js +92 -0
  31. package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -0
  32. package/dist/entities/contact/IdentityEntity.d.ts +5 -6
  33. package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
  34. package/dist/entities/contact/IdentityEntity.js +15 -20
  35. package/dist/entities/contact/IdentityEntity.js.map +1 -1
  36. package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +1 -3
  37. package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -1
  38. package/dist/entities/contact/IdentityMetadataItemEntity.js +7 -10
  39. package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
  40. package/dist/entities/contact/NaturalPersonEntity.d.ts +9 -0
  41. package/dist/entities/contact/NaturalPersonEntity.d.ts.map +1 -0
  42. package/dist/entities/contact/NaturalPersonEntity.js +72 -0
  43. package/dist/entities/contact/NaturalPersonEntity.js.map +1 -0
  44. package/dist/entities/contact/OpenIdConfigEntity.d.ts +0 -4
  45. package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -1
  46. package/dist/entities/contact/OpenIdConfigEntity.js +1 -22
  47. package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
  48. package/dist/entities/contact/OrganizationEntity.d.ts +9 -0
  49. package/dist/entities/contact/OrganizationEntity.d.ts.map +1 -0
  50. package/dist/entities/contact/OrganizationEntity.js +67 -0
  51. package/dist/entities/contact/OrganizationEntity.js.map +1 -0
  52. package/dist/entities/contact/PartyEntity.d.ts +21 -0
  53. package/dist/entities/contact/PartyEntity.d.ts.map +1 -0
  54. package/dist/entities/contact/PartyEntity.js +155 -0
  55. package/dist/entities/contact/PartyEntity.js.map +1 -0
  56. package/dist/entities/contact/PartyRelationshipEntity.d.ts +13 -0
  57. package/dist/entities/contact/PartyRelationshipEntity.d.ts.map +1 -0
  58. package/dist/entities/contact/PartyRelationshipEntity.js +95 -0
  59. package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -0
  60. package/dist/entities/contact/PartyTypeEntity.d.ts +15 -0
  61. package/dist/entities/contact/PartyTypeEntity.d.ts.map +1 -0
  62. package/dist/entities/contact/{ContactEntity.js → PartyTypeEntity.js} +35 -36
  63. package/dist/entities/contact/PartyTypeEntity.js.map +1 -0
  64. package/dist/entities/statusList2021/StatusList2021Entity.d.ts +19 -0
  65. package/dist/entities/statusList2021/StatusList2021Entity.d.ts.map +1 -0
  66. package/dist/entities/statusList2021/StatusList2021Entity.js +115 -0
  67. package/dist/entities/statusList2021/StatusList2021Entity.js.map +1 -0
  68. package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts +11 -0
  69. package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts.map +1 -0
  70. package/dist/entities/statusList2021/StatusList2021EntryEntity.js +51 -0
  71. package/dist/entities/statusList2021/StatusList2021EntryEntity.js.map +1 -0
  72. package/dist/index.d.ts +20 -9
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +27 -11
  75. package/dist/index.js.map +1 -1
  76. package/dist/migrations/generic/1-CreateContacts.d.ts.map +1 -1
  77. package/dist/migrations/generic/1-CreateContacts.js +36 -32
  78. package/dist/migrations/generic/1-CreateContacts.js.map +1 -1
  79. package/dist/migrations/generic/2-CreateContacts.d.ts +7 -0
  80. package/dist/migrations/generic/2-CreateContacts.d.ts.map +1 -0
  81. package/dist/migrations/generic/2-CreateContacts.js +76 -0
  82. package/dist/migrations/generic/2-CreateContacts.js.map +1 -0
  83. package/dist/migrations/generic/{1-CreateIssuanceBranding.d.ts → 2-CreateIssuanceBranding.d.ts} +1 -1
  84. package/dist/migrations/generic/2-CreateIssuanceBranding.d.ts.map +1 -0
  85. package/dist/migrations/generic/2-CreateIssuanceBranding.js +76 -0
  86. package/dist/migrations/generic/2-CreateIssuanceBranding.js.map +1 -0
  87. package/dist/migrations/generic/3-CreateStatusList.d.ts +7 -0
  88. package/dist/migrations/generic/3-CreateStatusList.d.ts.map +1 -0
  89. package/dist/migrations/generic/{1-CreateIssuanceBranding.js → 3-CreateStatusList.js} +11 -11
  90. package/dist/migrations/generic/3-CreateStatusList.js.map +1 -0
  91. package/dist/migrations/generic/index.d.ts +5 -0
  92. package/dist/migrations/generic/index.d.ts.map +1 -1
  93. package/dist/migrations/generic/index.js +10 -3
  94. package/dist/migrations/generic/index.js.map +1 -1
  95. package/dist/migrations/internal-migrations-ormconfig.d.ts +2 -1
  96. package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
  97. package/dist/migrations/internal-migrations-ormconfig.js +0 -2
  98. package/dist/migrations/internal-migrations-ormconfig.js.map +1 -1
  99. package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts.map +1 -1
  100. package/dist/migrations/postgres/1659463079428-CreateContacts.js +4 -2
  101. package/dist/migrations/postgres/1659463079428-CreateContacts.js.map +1 -1
  102. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts.map +1 -1
  103. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +2 -0
  104. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js.map +1 -1
  105. package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts +7 -0
  106. package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts.map +1 -0
  107. package/dist/migrations/postgres/1690925872592-CreateContacts.js +69 -0
  108. package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -0
  109. package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts +7 -0
  110. package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts.map +1 -0
  111. package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js +32 -0
  112. package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js.map +1 -0
  113. package/dist/migrations/postgres/uuid.d.ts +3 -0
  114. package/dist/migrations/postgres/uuid.d.ts.map +1 -0
  115. package/dist/migrations/postgres/uuid.js +25 -0
  116. package/dist/migrations/postgres/uuid.js.map +1 -0
  117. package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts +7 -0
  118. package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -0
  119. package/dist/migrations/sqlite/1690925872693-CreateContacts.js +108 -0
  120. package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -0
  121. package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts +7 -0
  122. package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts.map +1 -0
  123. package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +32 -0
  124. package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -0
  125. package/dist/statusList/IStatusListStore.d.ts +20 -0
  126. package/dist/statusList/IStatusListStore.d.ts.map +1 -0
  127. package/dist/statusList/IStatusListStore.js +3 -0
  128. package/dist/statusList/IStatusListStore.js.map +1 -0
  129. package/dist/statusList/StatusListStore.d.ts +36 -0
  130. package/dist/statusList/StatusListStore.d.ts.map +1 -0
  131. package/dist/statusList/StatusListStore.js +213 -0
  132. package/dist/statusList/StatusListStore.js.map +1 -0
  133. package/dist/types/contact/IAbstractContactStore.d.ts +70 -36
  134. package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
  135. package/dist/types/contact/contact.d.ts +139 -56
  136. package/dist/types/contact/contact.d.ts.map +1 -1
  137. package/dist/types/contact/contact.js +6 -1
  138. package/dist/types/contact/contact.js.map +1 -1
  139. package/dist/types/index.d.ts +3 -0
  140. package/dist/types/index.d.ts.map +1 -1
  141. package/dist/types/index.js +3 -0
  142. package/dist/types/index.js.map +1 -1
  143. package/dist/types/statusList/IAbstractStatusListStore.d.ts +38 -0
  144. package/dist/types/statusList/IAbstractStatusListStore.d.ts.map +1 -0
  145. package/dist/types/statusList/IAbstractStatusListStore.js +3 -0
  146. package/dist/types/statusList/IAbstractStatusListStore.js.map +1 -0
  147. package/dist/types/statusList/statusList.d.ts +25 -0
  148. package/dist/types/statusList/statusList.d.ts.map +1 -0
  149. package/dist/types/statusList/statusList.js +3 -0
  150. package/dist/types/statusList/statusList.js.map +1 -0
  151. package/dist/types/validation/validation.d.ts +4 -0
  152. package/dist/types/validation/validation.d.ts.map +1 -0
  153. package/dist/types/validation/validation.js +3 -0
  154. package/dist/types/validation/validation.js.map +1 -0
  155. package/dist/utils/ValidatorUtils.d.ts +4 -0
  156. package/dist/utils/ValidatorUtils.d.ts.map +1 -0
  157. package/dist/utils/ValidatorUtils.js +13 -0
  158. package/dist/utils/ValidatorUtils.js.map +1 -0
  159. package/dist/utils/contact/MappingUtils.d.ts +47 -0
  160. package/dist/utils/contact/MappingUtils.d.ts.map +1 -0
  161. package/dist/utils/contact/MappingUtils.js +291 -0
  162. package/dist/utils/contact/MappingUtils.js.map +1 -0
  163. package/package.json +5 -4
  164. package/src/__tests__/contact.entities.test.ts +1457 -195
  165. package/src/__tests__/contact.store.test.ts +1302 -266
  166. package/src/contact/AbstractContactStore.ts +44 -22
  167. package/src/contact/ContactStore.ts +328 -204
  168. package/src/entities/contact/BaseConfigEntity.ts +10 -2
  169. package/src/entities/contact/BaseContactEntity.ts +30 -0
  170. package/src/entities/contact/ConnectionEntity.ts +4 -23
  171. package/src/entities/contact/CorrelationIdentifierEntity.ts +9 -13
  172. package/src/entities/contact/DidAuthConfigEntity.ts +1 -18
  173. package/src/entities/contact/ElectronicAddressEntity.ts +60 -0
  174. package/src/entities/contact/IdentityEntity.ts +18 -25
  175. package/src/entities/contact/IdentityMetadataItemEntity.ts +8 -12
  176. package/src/entities/contact/NaturalPersonEntity.ts +38 -0
  177. package/src/entities/contact/OpenIdConfigEntity.ts +1 -23
  178. package/src/entities/contact/OrganizationEntity.ts +34 -0
  179. package/src/entities/contact/PartyEntity.ts +118 -0
  180. package/src/entities/contact/PartyRelationshipEntity.ts +61 -0
  181. package/src/entities/contact/PartyTypeEntity.ts +59 -0
  182. package/src/entities/statusList2021/StatusList2021Entity.ts +95 -0
  183. package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -0
  184. package/src/index.ts +36 -17
  185. package/src/migrations/generic/1-CreateContacts.ts +46 -36
  186. package/src/migrations/generic/2-CreateContacts.ts +64 -0
  187. package/src/migrations/generic/2-CreateIssuanceBranding.ts +62 -0
  188. package/src/migrations/generic/{1-CreateIssuanceBranding.ts → 3-CreateStatusList.ts} +9 -9
  189. package/src/migrations/generic/index.ts +11 -2
  190. package/src/migrations/internal-migrations-ormconfig.ts +2 -4
  191. package/src/migrations/postgres/1659463079428-CreateContacts.ts +4 -2
  192. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +2 -0
  193. package/src/migrations/postgres/1690925872592-CreateContacts.ts +94 -0
  194. package/src/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.ts +24 -0
  195. package/src/migrations/postgres/uuid.ts +12 -0
  196. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +163 -0
  197. package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -0
  198. package/src/statusList/IStatusListStore.ts +44 -0
  199. package/src/statusList/StatusListStore.ts +237 -0
  200. package/src/types/contact/IAbstractContactStore.ts +84 -27
  201. package/src/types/contact/contact.ts +144 -50
  202. package/src/types/index.ts +4 -0
  203. package/src/types/statusList/IAbstractStatusListStore.ts +47 -0
  204. package/src/types/statusList/statusList.ts +39 -0
  205. package/src/types/validation/validation.ts +3 -0
  206. package/src/utils/ValidatorUtils.ts +10 -0
  207. package/src/utils/contact/MappingUtils.ts +344 -0
  208. package/dist/entities/contact/ContactEntity.d.ts +0 -16
  209. package/dist/entities/contact/ContactEntity.d.ts.map +0 -1
  210. package/dist/entities/contact/ContactEntity.js.map +0 -1
  211. package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +0 -1
  212. package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +0 -1
  213. package/src/entities/contact/ContactEntity.ts +0 -74
@@ -1,7 +1,24 @@
1
1
  import { DataSource } from 'typeorm'
2
-
2
+ import { DataStoreMigrations, DataStoreContactEntities } from '../index'
3
3
  import { ContactStore } from '../contact/ContactStore'
4
- import { CorrelationIdentifierEnum, DataStoreContactEntities, DataStoreMigrations, IdentityRoleEnum } from '../index'
4
+ import {
5
+ IdentityRoleEnum,
6
+ PartyTypeEnum,
7
+ NonPersistedParty,
8
+ Party,
9
+ CorrelationIdentifierEnum,
10
+ Identity,
11
+ NaturalPerson,
12
+ NonPersistedNaturalPerson,
13
+ NonPersistedIdentity,
14
+ GetIdentitiesArgs,
15
+ GetPartiesArgs,
16
+ NonPersistedPartyRelationship,
17
+ PartyRelationship,
18
+ PartyType,
19
+ GetRelationshipsArgs,
20
+ NonPersistedPartyType,
21
+ } from '../types'
5
22
 
6
23
  describe('Contact store tests', (): void => {
7
24
  let dbConnection: DataSource
@@ -11,7 +28,7 @@ describe('Contact store tests', (): void => {
11
28
  dbConnection = await new DataSource({
12
29
  type: 'sqlite',
13
30
  database: ':memory:',
14
- //logging: 'all',
31
+ logging: 'all',
15
32
  migrationsRun: false,
16
33
  migrations: DataStoreMigrations,
17
34
  synchronize: false,
@@ -26,70 +43,138 @@ describe('Contact store tests', (): void => {
26
43
  await (await dbConnection).destroy()
27
44
  })
28
45
 
29
- it('should get contact by id', async (): Promise<void> => {
30
- const contact = {
31
- name: 'test_name',
32
- alias: 'test_alias',
46
+ it('should get party by id', async (): Promise<void> => {
47
+ const party: NonPersistedParty = {
33
48
  uri: 'example.com',
49
+ partyType: {
50
+ type: PartyTypeEnum.NATURAL_PERSON,
51
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
52
+ name: 'example_name',
53
+ },
54
+ contact: {
55
+ firstName: 'example_first_name',
56
+ middleName: 'example_middle_name',
57
+ lastName: 'example_last_name',
58
+ displayName: 'example_display_name',
59
+ },
34
60
  }
35
- const savedContact = await contactStore.addContact(contact)
36
- expect(savedContact).toBeDefined()
37
61
 
38
- const result = await contactStore.getContact({ contactId: savedContact.id })
62
+ const savedParty: Party = await contactStore.addParty(party)
63
+ expect(savedParty).toBeDefined()
64
+
65
+ const result: Party = await contactStore.getParty({ partyId: savedParty.id })
39
66
 
40
67
  expect(result).toBeDefined()
41
68
  })
42
69
 
43
- it('should throw error when getting contact with unknown id', async (): Promise<void> => {
44
- const contactId = 'unknownContactId'
70
+ it('should throw error when getting party with unknown id', async (): Promise<void> => {
71
+ const partyId = 'unknownPartyId'
45
72
 
46
- await expect(contactStore.getContact({ contactId })).rejects.toThrow(`No contact found for id: ${contactId}`)
73
+ await expect(contactStore.getParty({ partyId })).rejects.toThrow(`No party found for id: ${partyId}`)
47
74
  })
48
75
 
49
- it('should get all contacts', async (): Promise<void> => {
50
- const contact1 = {
51
- name: 'test_name1',
52
- alias: 'test_alias1',
53
- uri: 'example.com1',
76
+ it('should get all parties', async (): Promise<void> => {
77
+ const party1: NonPersistedParty = {
78
+ uri: 'example.com',
79
+ partyType: {
80
+ type: PartyTypeEnum.NATURAL_PERSON,
81
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
82
+ name: 'example_name1',
83
+ },
84
+ contact: {
85
+ firstName: 'example_first_name1',
86
+ middleName: 'example_middle_name1',
87
+ lastName: 'example_last_name1',
88
+ displayName: 'example_display_name1',
89
+ },
54
90
  }
55
- const savedContact1 = await contactStore.addContact(contact1)
56
- expect(savedContact1).toBeDefined()
91
+ const savedParty1: Party = await contactStore.addParty(party1)
92
+ expect(savedParty1).toBeDefined()
57
93
 
58
- const contact2 = {
59
- name: 'test_name2',
60
- alias: 'test_alias2',
61
- uri: 'example.com2',
94
+ const party2: NonPersistedParty = {
95
+ uri: 'example.com',
96
+ partyType: {
97
+ type: PartyTypeEnum.NATURAL_PERSON,
98
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
99
+ name: 'example_name2',
100
+ },
101
+ contact: {
102
+ firstName: 'example_first_name2',
103
+ middleName: 'example_middle_name2',
104
+ lastName: 'example_last_name2',
105
+ displayName: 'example_display_name2',
106
+ },
62
107
  }
63
- const savedContact2 = await contactStore.addContact(contact2)
64
- expect(savedContact2).toBeDefined()
108
+ const savedParty2: Party = await contactStore.addParty(party2)
109
+ expect(savedParty2).toBeDefined()
65
110
 
66
- const result = await contactStore.getContacts()
111
+ const result: Array<Party> = await contactStore.getParties()
67
112
 
113
+ expect(result).toBeDefined()
68
114
  expect(result.length).toEqual(2)
69
115
  })
70
116
 
71
- it('should get contacts by filter', async (): Promise<void> => {
72
- const contact = {
73
- name: 'test_name',
74
- alias: 'test_alias',
117
+ it('should get parties by filter', async (): Promise<void> => {
118
+ const party: NonPersistedParty = {
75
119
  uri: 'example.com',
120
+ partyType: {
121
+ type: PartyTypeEnum.NATURAL_PERSON,
122
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
123
+ name: 'example_name',
124
+ },
125
+ contact: {
126
+ firstName: 'example_first_name',
127
+ middleName: 'example_middle_name',
128
+ lastName: 'example_last_name',
129
+ displayName: 'example_display_name',
130
+ },
76
131
  }
77
- const savedContact = await contactStore.addContact(contact)
78
- expect(savedContact).toBeDefined()
132
+ const savedParty: Party = await contactStore.addParty(party)
133
+ expect(savedParty).toBeDefined()
79
134
 
80
- const args = {
81
- filter: [{ name: 'test_name' }, { alias: 'test_alias' }, { uri: 'example.com' }],
135
+ const args: GetPartiesArgs = {
136
+ filter: [
137
+ {
138
+ contact: {
139
+ firstName: (<NonPersistedNaturalPerson>party.contact).firstName,
140
+ },
141
+ },
142
+ {
143
+ contact: {
144
+ middleName: (<NonPersistedNaturalPerson>party.contact).middleName,
145
+ },
146
+ },
147
+ {
148
+ contact: {
149
+ lastName: (<NonPersistedNaturalPerson>party.contact).lastName,
150
+ },
151
+ },
152
+ {
153
+ contact: {
154
+ displayName: (<NonPersistedNaturalPerson>party.contact).displayName,
155
+ },
156
+ },
157
+ ],
82
158
  }
83
- const result = await contactStore.getContacts(args)
159
+ const result: Array<Party> = await contactStore.getParties(args)
84
160
 
85
161
  expect(result.length).toEqual(1)
86
162
  })
87
163
 
88
- it('should get whole contacts by filter', async (): Promise<void> => {
89
- const contact = {
90
- name: 'test_name',
91
- alias: 'test_alias',
164
+ it('should get whole parties by filter', async (): Promise<void> => {
165
+ const party: NonPersistedParty = {
92
166
  uri: 'example.com',
167
+ partyType: {
168
+ type: PartyTypeEnum.NATURAL_PERSON,
169
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
170
+ name: 'example_name',
171
+ },
172
+ contact: {
173
+ firstName: 'example_first_name',
174
+ middleName: 'example_middle_name',
175
+ lastName: 'example_last_name',
176
+ displayName: 'example_display_name',
177
+ },
93
178
  identities: [
94
179
  {
95
180
  alias: 'test_alias1',
@@ -116,11 +201,17 @@ describe('Contact store tests', (): void => {
116
201
  },
117
202
  },
118
203
  ],
204
+ electronicAddresses: [
205
+ {
206
+ type: 'email',
207
+ electronicAddress: 'sphereon@sphereon.com',
208
+ },
209
+ ],
119
210
  }
120
- const savedContact = await contactStore.addContact(contact)
121
- expect(savedContact).toBeDefined()
211
+ const savedParty: Party = await contactStore.addParty(party)
212
+ expect(savedParty).toBeDefined()
122
213
 
123
- const args = {
214
+ const args: GetPartiesArgs = {
124
215
  filter: [
125
216
  {
126
217
  identities: {
@@ -131,90 +222,178 @@ describe('Contact store tests', (): void => {
131
222
  },
132
223
  ],
133
224
  }
134
- const result = await contactStore.getContacts(args)
225
+ const result: Array<Party> = await contactStore.getParties(args)
135
226
 
136
227
  expect(result[0].identities.length).toEqual(3)
228
+ expect(result[0].electronicAddresses.length).toEqual(1)
137
229
  })
138
230
 
139
- it('should get contacts by name', async (): Promise<void> => {
140
- const contact = {
141
- name: 'test_name',
142
- alias: 'test_alias',
231
+ it('should get parties by name', async (): Promise<void> => {
232
+ const party: NonPersistedParty = {
143
233
  uri: 'example.com',
234
+ partyType: {
235
+ type: PartyTypeEnum.NATURAL_PERSON,
236
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
237
+ name: 'something',
238
+ },
239
+ contact: {
240
+ firstName: 'example_first_name',
241
+ middleName: 'example_middle_name',
242
+ lastName: 'example_last_name',
243
+ displayName: 'example_display_name',
244
+ },
144
245
  }
145
- const savedContact = await contactStore.addContact(contact)
146
- expect(savedContact).toBeDefined()
147
246
 
148
- const args = {
149
- filter: [{ name: 'test_name' }],
247
+ const savedParty: Party = await contactStore.addParty(party)
248
+ expect(savedParty).toBeDefined()
249
+
250
+ const args: GetPartiesArgs = {
251
+ filter: [
252
+ {
253
+ contact: {
254
+ firstName: (<NonPersistedNaturalPerson>party.contact).firstName,
255
+ },
256
+ },
257
+ {
258
+ contact: {
259
+ middleName: (<NonPersistedNaturalPerson>party.contact).middleName,
260
+ },
261
+ },
262
+ {
263
+ contact: {
264
+ lastName: (<NonPersistedNaturalPerson>party.contact).lastName,
265
+ },
266
+ },
267
+ ],
150
268
  }
151
- const result = await contactStore.getContacts(args)
269
+ const result: Array<Party> = await contactStore.getParties(args)
152
270
 
153
271
  expect(result.length).toEqual(1)
154
272
  })
155
273
 
156
- it('should get contacts by alias', async (): Promise<void> => {
157
- const contact = {
158
- name: 'test_name',
159
- alias: 'test_alias',
274
+ it('should get parties by display name', async (): Promise<void> => {
275
+ const party: NonPersistedParty = {
160
276
  uri: 'example.com',
277
+ partyType: {
278
+ type: PartyTypeEnum.NATURAL_PERSON,
279
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
280
+ name: 'example_name',
281
+ },
282
+ contact: {
283
+ firstName: 'example_first_name',
284
+ middleName: 'example_middle_name',
285
+ lastName: 'example_last_name',
286
+ displayName: 'example_display_name',
287
+ },
161
288
  }
162
- const savedContact = await contactStore.addContact(contact)
163
- expect(savedContact).toBeDefined()
164
289
 
165
- const args = {
166
- filter: [{ alias: 'test_alias' }],
290
+ const savedParty: Party = await contactStore.addParty(party)
291
+ expect(savedParty).toBeDefined()
292
+
293
+ const args: GetPartiesArgs = {
294
+ filter: [
295
+ {
296
+ contact: {
297
+ displayName: (<NonPersistedNaturalPerson>party.contact).displayName,
298
+ },
299
+ },
300
+ ],
167
301
  }
168
- const result = await contactStore.getContacts(args)
302
+ const result: Array<Party> = await contactStore.getParties(args)
169
303
 
170
304
  expect(result.length).toEqual(1)
171
305
  })
172
306
 
173
- it('should get contacts by uri', async (): Promise<void> => {
174
- const contact = {
175
- name: 'test_name',
176
- alias: 'test_alias',
307
+ it('should get parties by uri', async (): Promise<void> => {
308
+ const party: NonPersistedParty = {
177
309
  uri: 'example.com',
310
+ partyType: {
311
+ type: PartyTypeEnum.NATURAL_PERSON,
312
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
313
+ name: 'example_name',
314
+ },
315
+ contact: {
316
+ firstName: 'example_first_name',
317
+ middleName: 'example_middle_name',
318
+ lastName: 'example_last_name',
319
+ displayName: 'example_display_name',
320
+ },
178
321
  }
179
- const savedContact = await contactStore.addContact(contact)
180
- expect(savedContact).toBeDefined()
322
+ const savedParty: Party = await contactStore.addParty(party)
323
+ expect(savedParty).toBeDefined()
181
324
 
182
- const args = {
325
+ const args: GetPartiesArgs = {
183
326
  filter: [{ uri: 'example.com' }],
184
327
  }
185
- const result = await contactStore.getContacts(args)
328
+ const result: Array<Party> = await contactStore.getParties(args)
186
329
 
187
330
  expect(result.length).toEqual(1)
188
331
  })
189
332
 
190
- it('should return no contacts if filter does not match', async (): Promise<void> => {
191
- const args = {
192
- filter: [{ name: 'no_match_contact' }, { alias: 'no_match_contact_alias' }, { uri: 'no_match_example.com' }],
333
+ it('should return no parties if filter does not match', async (): Promise<void> => {
334
+ const args: GetPartiesArgs = {
335
+ filter: [
336
+ {
337
+ contact: {
338
+ firstName: 'no_match_firstName',
339
+ },
340
+ },
341
+ {
342
+ contact: {
343
+ middleName: 'no_match_middleName',
344
+ },
345
+ },
346
+ {
347
+ contact: {
348
+ lastName: 'no_match_lastName',
349
+ },
350
+ },
351
+ ],
193
352
  }
194
- const result = await contactStore.getContacts(args)
353
+ const result: Array<Party> = await contactStore.getParties(args)
195
354
 
196
355
  expect(result.length).toEqual(0)
197
356
  })
198
357
 
199
- it('should add contact without identities', async (): Promise<void> => {
200
- const contact = {
201
- name: 'test_name',
202
- alias: 'test_alias',
358
+ it('should add party without identities', async (): Promise<void> => {
359
+ const party: NonPersistedParty = {
203
360
  uri: 'example.com',
361
+ partyType: {
362
+ type: PartyTypeEnum.NATURAL_PERSON,
363
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
364
+ name: 'example_name',
365
+ },
366
+ contact: {
367
+ firstName: 'example_first_name',
368
+ middleName: 'example_middle_name',
369
+ lastName: 'example_last_name',
370
+ displayName: 'example_display_name',
371
+ },
204
372
  }
205
373
 
206
- const result = await contactStore.addContact(contact)
374
+ const result: Party = await contactStore.addParty(party)
207
375
 
208
- expect(result.name).toEqual(contact.name)
209
- expect(result.alias).toEqual(contact.alias)
210
- expect(result.uri).toEqual(contact.uri)
376
+ expect(result).toBeDefined()
377
+ expect((<NaturalPerson>result.contact).firstName).toEqual((<NonPersistedNaturalPerson>party.contact).firstName)
378
+ expect((<NaturalPerson>result.contact).middleName).toEqual((<NonPersistedNaturalPerson>party.contact).middleName)
379
+ expect((<NaturalPerson>result.contact).lastName).toEqual((<NonPersistedNaturalPerson>party.contact).lastName)
380
+ expect(result.identities.length).toEqual(0)
211
381
  })
212
382
 
213
- it('should add contact with identities', async (): Promise<void> => {
214
- const contact = {
215
- name: 'test_name',
216
- alias: 'test_alias',
383
+ it('should add party with identities', async (): Promise<void> => {
384
+ const party: NonPersistedParty = {
217
385
  uri: 'example.com',
386
+ partyType: {
387
+ type: PartyTypeEnum.NATURAL_PERSON,
388
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
389
+ name: 'example_name',
390
+ },
391
+ contact: {
392
+ firstName: 'example_first_name',
393
+ middleName: 'example_middle_name',
394
+ lastName: 'example_last_name',
395
+ displayName: 'example_display_name',
396
+ },
218
397
  identities: [
219
398
  {
220
399
  alias: 'test_alias1',
@@ -235,25 +414,35 @@ describe('Contact store tests', (): void => {
235
414
  ],
236
415
  }
237
416
 
238
- const result = await contactStore.addContact(contact)
417
+ const result: Party = await contactStore.addParty(party)
239
418
 
240
- expect(result.name).toEqual(contact.name)
241
- expect(result.alias).toEqual(contact.alias)
242
- expect(result.uri).toEqual(contact.uri)
419
+ expect(result).toBeDefined()
420
+ expect((<NaturalPerson>result.contact).firstName).toEqual((<NonPersistedNaturalPerson>party.contact).firstName)
421
+ expect((<NaturalPerson>result.contact).middleName).toEqual((<NonPersistedNaturalPerson>party.contact).middleName)
422
+ expect((<NaturalPerson>result.contact).lastName).toEqual((<NonPersistedNaturalPerson>party.contact).lastName)
243
423
  expect(result.identities.length).toEqual(2)
244
424
  })
245
425
 
246
- it('should throw error when adding contact with invalid identity', async (): Promise<void> => {
247
- const contact = {
248
- name: 'test_name',
249
- alias: 'test_alias',
426
+ it('should throw error when adding party with invalid identity', async (): Promise<void> => {
427
+ const party: NonPersistedParty = {
250
428
  uri: 'example.com',
429
+ partyType: {
430
+ type: PartyTypeEnum.NATURAL_PERSON,
431
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
432
+ name: 'something',
433
+ },
434
+ contact: {
435
+ firstName: 'example_first_name',
436
+ middleName: 'example_middle_name',
437
+ lastName: 'example_last_name',
438
+ displayName: 'example_display_name',
439
+ },
251
440
  identities: [
252
441
  {
253
442
  alias: 'test_alias1',
254
443
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
255
444
  identifier: {
256
- type: CorrelationIdentifierEnum.DID,
445
+ type: CorrelationIdentifierEnum.URL,
257
446
  correlationId: 'example_did1',
258
447
  },
259
448
  },
@@ -268,64 +457,28 @@ describe('Contact store tests', (): void => {
268
457
  ],
269
458
  }
270
459
 
271
- const result = await contactStore.addContact(contact)
272
-
273
- expect(result.name).toEqual(contact.name)
274
- expect(result.alias).toEqual(contact.alias)
275
- expect(result.uri).toEqual(contact.uri)
276
- expect(result.identities.length).toEqual(2)
277
- })
278
-
279
- it('should throw error when adding contact with duplicate name', async (): Promise<void> => {
280
- const name = 'test_name'
281
- const contact1 = {
282
- name,
283
- alias: 'test_alias',
284
- uri: 'example.com',
285
- }
286
- const savedContact1 = await contactStore.addContact(contact1)
287
- expect(savedContact1).toBeDefined()
288
-
289
- const alias = 'test_alias2'
290
- const contact2 = {
291
- name,
292
- alias,
293
- uri: 'example.com',
294
- }
295
-
296
- await expect(contactStore.addContact(contact2)).rejects.toThrow(`Duplicate names or aliases are not allowed. Name: ${name}, Alias: ${alias}`)
460
+ await expect(contactStore.addParty(party)).rejects.toThrow(`Identity with correlation type url should contain a connection`)
297
461
  })
298
462
 
299
- it('should throw error when adding contact with duplicate alias', async (): Promise<void> => {
300
- const alias = 'test_alias'
301
- const contact1 = {
302
- name: 'test_name',
303
- alias,
304
- uri: 'example.com',
305
- }
306
- const savedContact1 = await contactStore.addContact(contact1)
307
- expect(savedContact1).toBeDefined()
308
-
309
- const name = 'test_name2'
310
- const contact2 = {
311
- name,
312
- alias,
313
- uri: 'example.com',
314
- }
315
-
316
- await expect(contactStore.addContact(contact2)).rejects.toThrow(`Duplicate names or aliases are not allowed. Name: ${name}, Alias: ${alias}`)
317
- })
318
-
319
- it('should update contact by id', async (): Promise<void> => {
320
- const contact = {
321
- name: 'test_name',
322
- alias: 'test_alias',
463
+ it('should update party by id', async (): Promise<void> => {
464
+ const party: NonPersistedParty = {
323
465
  uri: 'example.com',
466
+ partyType: {
467
+ type: PartyTypeEnum.NATURAL_PERSON,
468
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
469
+ name: 'example_name',
470
+ },
471
+ contact: {
472
+ firstName: 'example_first_name',
473
+ middleName: 'example_middle_name',
474
+ lastName: 'example_last_name',
475
+ displayName: 'example_display_name',
476
+ },
324
477
  }
325
- const savedContact = await contactStore.addContact(contact)
326
- expect(savedContact).toBeDefined()
478
+ const savedParty: Party = await contactStore.addParty(party)
479
+ expect(savedParty).toBeDefined()
327
480
 
328
- const identity1 = {
481
+ const identity1: NonPersistedIdentity = {
329
482
  alias: 'test_alias1',
330
483
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
331
484
  identifier: {
@@ -333,10 +486,10 @@ describe('Contact store tests', (): void => {
333
486
  correlationId: 'example_did1',
334
487
  },
335
488
  }
336
- const savedIdentity1 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity1 })
489
+ const savedIdentity1: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity1 })
337
490
  expect(savedIdentity1).toBeDefined()
338
491
 
339
- const identity2 = {
492
+ const identity2: NonPersistedIdentity = {
340
493
  alias: 'test_alias2',
341
494
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
342
495
  identifier: {
@@ -344,50 +497,77 @@ describe('Contact store tests', (): void => {
344
497
  correlationId: 'example_did2',
345
498
  },
346
499
  }
347
- const savedIdentity2 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity2 })
500
+ const savedIdentity2: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity2 })
348
501
  expect(savedIdentity2).toBeDefined()
349
502
 
350
- const contactName = 'updated_name'
351
- const updatedContact = {
352
- ...savedContact,
353
- name: contactName,
503
+ const contactFirstName = 'updated_first_name'
504
+ const updatedParty: Party = {
505
+ ...savedParty,
506
+ contact: {
507
+ ...savedParty.contact,
508
+ firstName: contactFirstName,
509
+ },
354
510
  }
355
511
 
356
- await contactStore.updateContact({ contact: updatedContact })
357
- const result = await contactStore.getContact({ contactId: savedContact.id })
512
+ await contactStore.updateParty({ party: updatedParty })
513
+ const result: Party = await contactStore.getParty({ partyId: savedParty.id })
358
514
 
359
- expect(result.name).toEqual(contactName)
515
+ expect(result).toBeDefined()
516
+ expect((<NaturalPerson>result.contact).firstName).toEqual(contactFirstName)
360
517
  expect(result.identities.length).toEqual(2)
361
518
  })
362
519
 
363
- it('should throw error when updating contact with unknown id', async (): Promise<void> => {
364
- const contact = {
365
- name: 'test_name',
366
- alias: 'test_alias',
520
+ it('should throw error when updating party with unknown id', async (): Promise<void> => {
521
+ const party: NonPersistedParty = {
367
522
  uri: 'example.com',
523
+ partyType: {
524
+ type: PartyTypeEnum.NATURAL_PERSON,
525
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
526
+ name: 'example_name',
527
+ },
528
+ contact: {
529
+ firstName: 'example_first_name',
530
+ middleName: 'example_middle_name',
531
+ lastName: 'example_last_name',
532
+ displayName: 'example_display_name',
533
+ },
368
534
  }
369
- const savedContact = await contactStore.addContact(contact)
370
- expect(savedContact).toBeDefined()
371
-
372
- const contactId = 'unknownContactId'
373
- const updatedContact = {
374
- ...savedContact,
375
- id: contactId,
376
- name: 'new_name',
535
+ const savedParty: Party = await contactStore.addParty(party)
536
+ expect(savedParty).toBeDefined()
537
+
538
+ const partyId = 'unknownPartyId'
539
+ const contactFirstName = 'updated_first_name'
540
+ const updatedParty: Party = {
541
+ ...savedParty,
542
+ id: partyId,
543
+ contact: {
544
+ ...savedParty.contact,
545
+ firstName: contactFirstName,
546
+ },
377
547
  }
378
- await expect(contactStore.updateContact({ contact: updatedContact })).rejects.toThrow(`No contact found for id: ${contactId}`)
548
+
549
+ await expect(contactStore.updateParty({ party: updatedParty })).rejects.toThrow(`No party found for id: ${partyId}`)
379
550
  })
380
551
 
381
552
  it('should get identity by id', async (): Promise<void> => {
382
- const contact = {
383
- name: 'test_name',
384
- alias: 'test_alias',
553
+ const party: NonPersistedParty = {
385
554
  uri: 'example.com',
555
+ partyType: {
556
+ type: PartyTypeEnum.NATURAL_PERSON,
557
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
558
+ name: 'example_name',
559
+ },
560
+ contact: {
561
+ firstName: 'example_first_name',
562
+ middleName: 'example_middle_name',
563
+ lastName: 'example_last_name',
564
+ displayName: 'example_display_name',
565
+ },
386
566
  }
387
- const savedContact = await contactStore.addContact(contact)
388
- expect(savedContact).toBeDefined()
567
+ const savedParty: Party = await contactStore.addParty(party)
568
+ expect(savedParty).toBeDefined()
389
569
 
390
- const identity = {
570
+ const identity: NonPersistedIdentity = {
391
571
  alias: 'test_alias',
392
572
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
393
573
  identifier: {
@@ -395,24 +575,33 @@ describe('Contact store tests', (): void => {
395
575
  correlationId: 'example_did',
396
576
  },
397
577
  }
398
- const savedIdentity = await contactStore.addIdentity({ contactId: savedContact.id, identity })
578
+ const savedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity })
399
579
  expect(savedIdentity).toBeDefined()
400
580
 
401
- const result = await contactStore.getIdentity({ identityId: savedIdentity.id })
581
+ const result: Identity = await contactStore.getIdentity({ identityId: savedIdentity.id })
402
582
 
403
583
  expect(result).toBeDefined()
404
584
  })
405
585
 
406
586
  it('should get holderDID identity by id', async (): Promise<void> => {
407
- const contact = {
408
- name: 'test_name',
409
- alias: 'test_alias',
587
+ const party: NonPersistedParty = {
410
588
  uri: 'example.com',
589
+ partyType: {
590
+ type: PartyTypeEnum.NATURAL_PERSON,
591
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
592
+ name: 'example_name',
593
+ },
594
+ contact: {
595
+ firstName: 'example_first_name',
596
+ middleName: 'example_middle_name',
597
+ lastName: 'example_last_name',
598
+ displayName: 'example_display_name',
599
+ },
411
600
  }
412
- const savedContact = await contactStore.addContact(contact)
413
- expect(savedContact).toBeDefined()
601
+ const savedParty: Party = await contactStore.addParty(party)
602
+ expect(savedParty).toBeDefined()
414
603
 
415
- const identity = {
604
+ const identity: NonPersistedIdentity = {
416
605
  alias: 'test_alias',
417
606
  roles: [IdentityRoleEnum.HOLDER],
418
607
  identifier: {
@@ -420,10 +609,10 @@ describe('Contact store tests', (): void => {
420
609
  correlationId: 'example_did',
421
610
  },
422
611
  }
423
- const savedIdentity = await contactStore.addIdentity({ contactId: savedContact.id, identity })
612
+ const savedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity })
424
613
  expect(savedIdentity).toBeDefined()
425
614
 
426
- const result = await contactStore.getIdentity({ identityId: savedIdentity.id })
615
+ const result: Identity = await contactStore.getIdentity({ identityId: savedIdentity.id })
427
616
 
428
617
  expect(result).toBeDefined()
429
618
  })
@@ -435,15 +624,24 @@ describe('Contact store tests', (): void => {
435
624
  })
436
625
 
437
626
  it('should get all identities for contact', async (): Promise<void> => {
438
- const contact = {
439
- name: 'test_name',
440
- alias: 'test_alias',
627
+ const party: NonPersistedParty = {
441
628
  uri: 'example.com',
629
+ partyType: {
630
+ type: PartyTypeEnum.NATURAL_PERSON,
631
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
632
+ name: 'example_name',
633
+ },
634
+ contact: {
635
+ firstName: 'example_first_name',
636
+ middleName: 'example_middle_name',
637
+ lastName: 'example_last_name',
638
+ displayName: 'example_display_name',
639
+ },
442
640
  }
443
- const savedContact = await contactStore.addContact(contact)
444
- expect(savedContact).toBeDefined()
641
+ const savedParty: Party = await contactStore.addParty(party)
642
+ expect(savedParty).toBeDefined()
445
643
 
446
- const identity1 = {
644
+ const identity1: NonPersistedIdentity = {
447
645
  alias: 'test_alias1',
448
646
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
449
647
  identifier: {
@@ -451,10 +649,10 @@ describe('Contact store tests', (): void => {
451
649
  correlationId: 'example_did1',
452
650
  },
453
651
  }
454
- const savedIdentity1 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity1 })
652
+ const savedIdentity1: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity1 })
455
653
  expect(savedIdentity1).toBeDefined()
456
654
 
457
- const identity2 = {
655
+ const identity2: NonPersistedIdentity = {
458
656
  alias: 'test_alias2',
459
657
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
460
658
  identifier: {
@@ -462,28 +660,37 @@ describe('Contact store tests', (): void => {
462
660
  correlationId: 'example_did2',
463
661
  },
464
662
  }
465
- const savedIdentity2 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity2 })
663
+ const savedIdentity2: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity2 })
466
664
  expect(savedIdentity2).toBeDefined()
467
665
 
468
- const args = {
469
- filter: [{ contactId: savedContact.id }],
666
+ const args: GetIdentitiesArgs = {
667
+ filter: [{ partyId: savedParty.id }],
470
668
  }
471
669
 
472
- const result = await contactStore.getIdentities(args)
670
+ const result: Array<Identity> = await contactStore.getIdentities(args)
473
671
 
474
672
  expect(result.length).toEqual(2)
475
673
  })
476
674
 
477
675
  it('should get all identities', async (): Promise<void> => {
478
- const contact = {
479
- name: 'test_name',
480
- alias: 'test_alias',
676
+ const party: NonPersistedParty = {
481
677
  uri: 'example.com',
678
+ partyType: {
679
+ type: PartyTypeEnum.NATURAL_PERSON,
680
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
681
+ name: 'example_name',
682
+ },
683
+ contact: {
684
+ firstName: 'example_first_name',
685
+ middleName: 'example_middle_name',
686
+ lastName: 'example_last_name',
687
+ displayName: 'example_display_name',
688
+ },
482
689
  }
483
- const savedContact = await contactStore.addContact(contact)
484
- expect(savedContact).toBeDefined()
690
+ const savedParty: Party = await contactStore.addParty(party)
691
+ expect(savedParty).toBeDefined()
485
692
 
486
- const identity1 = {
693
+ const identity1: NonPersistedIdentity = {
487
694
  alias: 'test_alias1',
488
695
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
489
696
  identifier: {
@@ -491,10 +698,10 @@ describe('Contact store tests', (): void => {
491
698
  correlationId: 'example_did1',
492
699
  },
493
700
  }
494
- const savedIdentity1 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity1 })
701
+ const savedIdentity1: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity1 })
495
702
  expect(savedIdentity1).toBeDefined()
496
703
 
497
- const identity2 = {
704
+ const identity2: NonPersistedIdentity = {
498
705
  alias: 'test_alias2',
499
706
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
500
707
  identifier: {
@@ -502,25 +709,34 @@ describe('Contact store tests', (): void => {
502
709
  correlationId: 'example_did2',
503
710
  },
504
711
  }
505
- const savedIdentity2 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity2 })
712
+ const savedIdentity2: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity2 })
506
713
  expect(savedIdentity2).toBeDefined()
507
714
 
508
- const result = await contactStore.getIdentities()
715
+ const result: Array<Identity> = await contactStore.getIdentities()
509
716
 
510
717
  expect(result.length).toEqual(2)
511
718
  })
512
719
 
513
720
  it('should get identities by filter', async (): Promise<void> => {
514
- const contact = {
515
- name: 'test_name',
516
- alias: 'test_alias',
721
+ const party: NonPersistedParty = {
517
722
  uri: 'example.com',
723
+ partyType: {
724
+ type: PartyTypeEnum.NATURAL_PERSON,
725
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
726
+ name: 'example_name',
727
+ },
728
+ contact: {
729
+ firstName: 'example_first_name',
730
+ middleName: 'example_middle_name',
731
+ lastName: 'example_last_name',
732
+ displayName: 'example_display_name',
733
+ },
518
734
  }
519
- const savedContact = await contactStore.addContact(contact)
520
- expect(savedContact).toBeDefined()
735
+ const savedParty: Party = await contactStore.addParty(party)
736
+ expect(savedParty).toBeDefined()
521
737
 
522
738
  const alias = 'test_alias1'
523
- const identity1 = {
739
+ const identity1: NonPersistedIdentity = {
524
740
  alias,
525
741
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
526
742
  identifier: {
@@ -528,10 +744,10 @@ describe('Contact store tests', (): void => {
528
744
  correlationId: 'example_did1',
529
745
  },
530
746
  }
531
- const savedIdentity1 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity1 })
747
+ const savedIdentity1: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity1 })
532
748
  expect(savedIdentity1).toBeDefined()
533
749
 
534
- const identity2 = {
750
+ const identity2: NonPersistedIdentity = {
535
751
  alias: 'test_alias2',
536
752
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
537
753
  identifier: {
@@ -539,29 +755,38 @@ describe('Contact store tests', (): void => {
539
755
  correlationId: 'example_did2',
540
756
  },
541
757
  }
542
- const savedIdentity2 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity2 })
758
+ const savedIdentity2: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity2 })
543
759
  expect(savedIdentity2).toBeDefined()
544
760
 
545
- const args = {
761
+ const args: GetIdentitiesArgs = {
546
762
  filter: [{ alias }],
547
763
  }
548
764
 
549
- const result = await contactStore.getIdentities(args)
765
+ const result: Array<Identity> = await contactStore.getIdentities(args)
550
766
 
551
767
  expect(result.length).toEqual(1)
552
768
  })
553
769
 
554
770
  it('should get whole identities by filter', async (): Promise<void> => {
555
- const contact = {
556
- name: 'test_name',
557
- alias: 'test_alias',
771
+ const party: NonPersistedParty = {
558
772
  uri: 'example.com',
773
+ partyType: {
774
+ type: PartyTypeEnum.NATURAL_PERSON,
775
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
776
+ name: 'example_name',
777
+ },
778
+ contact: {
779
+ firstName: 'example_first_name',
780
+ middleName: 'example_middle_name',
781
+ lastName: 'example_last_name',
782
+ displayName: 'example_display_name',
783
+ },
559
784
  }
560
- const savedContact = await contactStore.addContact(contact)
561
- expect(savedContact).toBeDefined()
785
+ const savedParty: Party = await contactStore.addParty(party)
786
+ expect(savedParty).toBeDefined()
562
787
 
563
788
  const alias = 'test_alias1'
564
- const identity1 = {
789
+ const identity1: NonPersistedIdentity = {
565
790
  alias,
566
791
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
567
792
  identifier: {
@@ -579,29 +804,38 @@ describe('Contact store tests', (): void => {
579
804
  },
580
805
  ],
581
806
  }
582
- const savedIdentity1 = await contactStore.addIdentity({ contactId: savedContact.id, identity: identity1 })
807
+ const savedIdentity1: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity: identity1 })
583
808
  expect(savedIdentity1).toBeDefined()
584
809
 
585
- const args = {
810
+ const args: GetIdentitiesArgs = {
586
811
  filter: [{ metadata: { label: 'label1' } }],
587
812
  }
588
813
 
589
- const result = await contactStore.getIdentities(args)
814
+ const result: Array<Identity> = await contactStore.getIdentities(args)
590
815
 
591
816
  expect(result[0]).toBeDefined()
592
817
  expect(result[0].metadata!.length).toEqual(2)
593
818
  })
594
819
 
595
820
  it('should add identity to contact', async (): Promise<void> => {
596
- const contact = {
597
- name: 'test_name',
598
- alias: 'test_alias',
821
+ const party: NonPersistedParty = {
599
822
  uri: 'example.com',
823
+ partyType: {
824
+ type: PartyTypeEnum.NATURAL_PERSON,
825
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
826
+ name: 'example_name',
827
+ },
828
+ contact: {
829
+ firstName: 'example_first_name',
830
+ middleName: 'example_middle_name',
831
+ lastName: 'example_last_name',
832
+ displayName: 'example_display_name',
833
+ },
600
834
  }
601
- const savedContact = await contactStore.addContact(contact)
602
- expect(savedContact).toBeDefined()
835
+ const savedParty: Party = await contactStore.addParty(party)
836
+ expect(savedParty).toBeDefined()
603
837
 
604
- const identity = {
838
+ const identity: NonPersistedIdentity = {
605
839
  alias: 'test_alias',
606
840
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
607
841
  identifier: {
@@ -609,10 +843,10 @@ describe('Contact store tests', (): void => {
609
843
  correlationId: 'example_did',
610
844
  },
611
845
  }
612
- const savedIdentity = await contactStore.addIdentity({ contactId: savedContact.id, identity })
846
+ const savedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity })
613
847
  expect(savedIdentity).toBeDefined()
614
848
 
615
- const result = await contactStore.getContact({ contactId: savedContact.id })
849
+ const result: Party = await contactStore.getParty({ partyId: savedParty.id })
616
850
  expect(result.identities.length).toEqual(1)
617
851
  })
618
852
 
@@ -623,16 +857,25 @@ describe('Contact store tests', (): void => {
623
857
  })
624
858
 
625
859
  it('should throw error when adding identity with invalid identifier', async (): Promise<void> => {
626
- const contact = {
627
- name: 'test_name',
628
- alias: 'test_alias',
860
+ const party: NonPersistedParty = {
629
861
  uri: 'example.com',
862
+ partyType: {
863
+ type: PartyTypeEnum.NATURAL_PERSON,
864
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
865
+ name: 'example_name',
866
+ },
867
+ contact: {
868
+ firstName: 'example_first_name',
869
+ middleName: 'example_middle_name',
870
+ lastName: 'example_last_name',
871
+ displayName: 'example_display_name',
872
+ },
630
873
  }
631
- const savedContact = await contactStore.addContact(contact)
632
- expect(savedContact).toBeDefined()
874
+ const savedParty: Party = await contactStore.addParty(party)
875
+ expect(savedParty).toBeDefined()
633
876
 
634
877
  const correlationId = 'missing_connection_example'
635
- const identity = {
878
+ const identity: NonPersistedIdentity = {
636
879
  alias: correlationId,
637
880
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
638
881
  identifier: {
@@ -641,22 +884,31 @@ describe('Contact store tests', (): void => {
641
884
  },
642
885
  }
643
886
 
644
- await expect(contactStore.addIdentity({ contactId: savedContact.id, identity })).rejects.toThrow(
887
+ await expect(contactStore.addIdentity({ partyId: savedParty.id, identity })).rejects.toThrow(
645
888
  `Identity with correlation type url should contain a connection`
646
889
  )
647
890
  })
648
891
 
649
892
  it('should throw error when updating identity with invalid identifier', async (): Promise<void> => {
650
- const contact = {
651
- name: 'test_name',
652
- alias: 'test_alias',
893
+ const party: NonPersistedParty = {
653
894
  uri: 'example.com',
895
+ partyType: {
896
+ type: PartyTypeEnum.NATURAL_PERSON,
897
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
898
+ name: 'example_name',
899
+ },
900
+ contact: {
901
+ firstName: 'example_first_name',
902
+ middleName: 'example_middle_name',
903
+ lastName: 'example_last_name',
904
+ displayName: 'example_display_name',
905
+ },
654
906
  }
655
- const savedContact = await contactStore.addContact(contact)
656
- expect(savedContact).toBeDefined()
907
+ const savedParty: Party = await contactStore.addParty(party)
908
+ expect(savedParty).toBeDefined()
657
909
 
658
910
  const correlationId = 'missing_connection_example'
659
- const identity = {
911
+ const identity: NonPersistedIdentity = {
660
912
  alias: correlationId,
661
913
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER, IdentityRoleEnum.HOLDER],
662
914
  identifier: {
@@ -664,7 +916,7 @@ describe('Contact store tests', (): void => {
664
916
  correlationId,
665
917
  },
666
918
  }
667
- const storedIdentity = await contactStore.addIdentity({ contactId: savedContact.id, identity })
919
+ const storedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity })
668
920
  storedIdentity.identifier = { ...storedIdentity.identifier, type: CorrelationIdentifierEnum.URL }
669
921
 
670
922
  await expect(contactStore.updateIdentity({ identity: storedIdentity })).rejects.toThrow(
@@ -673,15 +925,24 @@ describe('Contact store tests', (): void => {
673
925
  })
674
926
 
675
927
  it('should update identity by id', async (): Promise<void> => {
676
- const contact = {
677
- name: 'test_name',
678
- alias: 'test_alias',
928
+ const party: NonPersistedParty = {
679
929
  uri: 'example.com',
930
+ partyType: {
931
+ type: PartyTypeEnum.NATURAL_PERSON,
932
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
933
+ name: 'example_name',
934
+ },
935
+ contact: {
936
+ firstName: 'example_first_name',
937
+ middleName: 'example_middle_name',
938
+ lastName: 'example_last_name',
939
+ displayName: 'example_display_name',
940
+ },
680
941
  }
681
- const savedContact = await contactStore.addContact(contact)
682
- expect(savedContact).toBeDefined()
942
+ const savedParty: Party = await contactStore.addParty(party)
943
+ expect(savedParty).toBeDefined()
683
944
 
684
- const identity = {
945
+ const identity: NonPersistedIdentity = {
685
946
  alias: 'example_did',
686
947
  roles: [IdentityRoleEnum.ISSUER, IdentityRoleEnum.VERIFIER],
687
948
  identifier: {
@@ -689,22 +950,31 @@ describe('Contact store tests', (): void => {
689
950
  correlationId: 'example_did',
690
951
  },
691
952
  }
692
- const storedIdentity = await contactStore.addIdentity({ contactId: savedContact.id, identity })
953
+ const storedIdentity: Identity = await contactStore.addIdentity({ partyId: savedParty.id, identity })
693
954
  const correlationId = 'new_update_example_did'
694
955
  storedIdentity.identifier = { ...storedIdentity.identifier, correlationId }
695
956
 
696
957
  await contactStore.updateIdentity({ identity: storedIdentity })
697
- const result = await contactStore.getIdentity({ identityId: storedIdentity.id })
958
+ const result: Identity = await contactStore.getIdentity({ identityId: storedIdentity.id })
698
959
 
699
- expect(result).not.toBeNull()
960
+ expect(result).toBeDefined()
700
961
  expect(result.identifier.correlationId).toEqual(correlationId)
701
962
  })
702
963
 
703
- it('should get aggregate of identity roles on contact', async (): Promise<void> => {
704
- const contact = {
705
- name: 'test_name',
706
- alias: 'test_alias',
964
+ it('should get aggregate of identity roles on party', async (): Promise<void> => {
965
+ const party: NonPersistedParty = {
707
966
  uri: 'example.com',
967
+ partyType: {
968
+ type: PartyTypeEnum.NATURAL_PERSON,
969
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
970
+ name: 'example_name',
971
+ },
972
+ contact: {
973
+ firstName: 'example_first_name',
974
+ middleName: 'example_middle_name',
975
+ lastName: 'example_last_name',
976
+ displayName: 'example_display_name',
977
+ },
708
978
  identities: [
709
979
  {
710
980
  alias: 'test_alias1',
@@ -733,11 +1003,777 @@ describe('Contact store tests', (): void => {
733
1003
  ],
734
1004
  }
735
1005
 
736
- const savedContact = await contactStore.addContact(contact)
737
- const result = await contactStore.getContact({ contactId: savedContact.id })
1006
+ const savedParty: Party = await contactStore.addParty(party)
1007
+ const result: Party = await contactStore.getParty({ partyId: savedParty.id })
738
1008
 
739
1009
  expect(result.roles).toBeDefined()
740
1010
  expect(result.roles.length).toEqual(3)
741
1011
  expect(result.roles).toEqual([IdentityRoleEnum.VERIFIER, IdentityRoleEnum.ISSUER, IdentityRoleEnum.HOLDER])
742
1012
  })
1013
+
1014
+ it('should add relationship', async (): Promise<void> => {
1015
+ const party1: NonPersistedParty = {
1016
+ uri: 'example1.com',
1017
+ partyType: {
1018
+ type: PartyTypeEnum.NATURAL_PERSON,
1019
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1020
+ name: 'example_name1',
1021
+ },
1022
+ contact: {
1023
+ firstName: 'example_first_name1',
1024
+ middleName: 'example_middle_name1',
1025
+ lastName: 'example_last_name1',
1026
+ displayName: 'example_display_name1',
1027
+ },
1028
+ }
1029
+ const savedParty1: Party = await contactStore.addParty(party1)
1030
+ expect(savedParty1).toBeDefined()
1031
+
1032
+ const party2: NonPersistedParty = {
1033
+ uri: 'example2.com',
1034
+ partyType: {
1035
+ type: PartyTypeEnum.NATURAL_PERSON,
1036
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1037
+ name: 'example_name2',
1038
+ },
1039
+ contact: {
1040
+ firstName: 'example_first_name2',
1041
+ middleName: 'example_middle_name2',
1042
+ lastName: 'example_last_name2',
1043
+ displayName: 'example_display_name2',
1044
+ },
1045
+ }
1046
+ const savedParty2: Party = await contactStore.addParty(party2)
1047
+ expect(savedParty2).toBeDefined()
1048
+
1049
+ const relationship: NonPersistedPartyRelationship = {
1050
+ leftId: savedParty1.id,
1051
+ rightId: savedParty2.id,
1052
+ }
1053
+ await contactStore.addRelationship(relationship)
1054
+
1055
+ const result: Party = await contactStore.getParty({ partyId: savedParty1.id })
1056
+
1057
+ expect(result).toBeDefined()
1058
+ expect(result.relationships.length).toEqual(1)
1059
+ expect(result.relationships[0].leftId).toEqual(savedParty1.id)
1060
+ expect(result.relationships[0].rightId).toEqual(savedParty2.id)
1061
+ })
1062
+
1063
+ it('should get relationship', async (): Promise<void> => {
1064
+ const party1: NonPersistedParty = {
1065
+ uri: 'example1.com',
1066
+ partyType: {
1067
+ type: PartyTypeEnum.NATURAL_PERSON,
1068
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1069
+ name: 'example_name1',
1070
+ },
1071
+ contact: {
1072
+ firstName: 'example_first_name1',
1073
+ middleName: 'example_middle_name1',
1074
+ lastName: 'example_last_name1',
1075
+ displayName: 'example_display_name1',
1076
+ },
1077
+ }
1078
+ const savedParty1: Party = await contactStore.addParty(party1)
1079
+ expect(savedParty1).toBeDefined()
1080
+
1081
+ const party2: NonPersistedParty = {
1082
+ uri: 'example2.com',
1083
+ partyType: {
1084
+ type: PartyTypeEnum.NATURAL_PERSON,
1085
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1086
+ name: 'example_name2',
1087
+ },
1088
+ contact: {
1089
+ firstName: 'example_first_name2',
1090
+ middleName: 'example_middle_name2',
1091
+ lastName: 'example_last_name2',
1092
+ displayName: 'example_display_name2',
1093
+ },
1094
+ }
1095
+ const savedParty2: Party = await contactStore.addParty(party2)
1096
+ expect(savedParty2).toBeDefined()
1097
+
1098
+ const relationship: NonPersistedPartyRelationship = {
1099
+ leftId: savedParty1.id,
1100
+ rightId: savedParty2.id,
1101
+ }
1102
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1103
+
1104
+ const result: PartyRelationship = await contactStore.getRelationship({ relationshipId: savedRelationship.id })
1105
+
1106
+ expect(result).toBeDefined()
1107
+ expect(result.leftId).toEqual(savedParty1.id)
1108
+ expect(result.rightId).toEqual(savedParty2.id)
1109
+ })
1110
+
1111
+ it('should throw error when getting relationship with unknown id', async (): Promise<void> => {
1112
+ const relationshipId = 'unknownRelationshipId'
1113
+
1114
+ await expect(contactStore.getRelationship({ relationshipId })).rejects.toThrow(`No relationship found for id: ${relationshipId}`)
1115
+ })
1116
+
1117
+ it('should get all relationships', async (): Promise<void> => {
1118
+ const party1: NonPersistedParty = {
1119
+ uri: 'example1.com',
1120
+ partyType: {
1121
+ type: PartyTypeEnum.NATURAL_PERSON,
1122
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1123
+ name: 'example_name1',
1124
+ },
1125
+ contact: {
1126
+ firstName: 'example_first_name1',
1127
+ middleName: 'example_middle_name1',
1128
+ lastName: 'example_last_name1',
1129
+ displayName: 'example_display_name1',
1130
+ },
1131
+ }
1132
+ const savedParty1: Party = await contactStore.addParty(party1)
1133
+ expect(savedParty1).toBeDefined()
1134
+
1135
+ const party2: NonPersistedParty = {
1136
+ uri: 'example2.com',
1137
+ partyType: {
1138
+ type: PartyTypeEnum.NATURAL_PERSON,
1139
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1140
+ name: 'example_name2',
1141
+ },
1142
+ contact: {
1143
+ firstName: 'example_first_name2',
1144
+ middleName: 'example_middle_name2',
1145
+ lastName: 'example_last_name2',
1146
+ displayName: 'example_display_name2',
1147
+ },
1148
+ }
1149
+ const savedParty2: Party = await contactStore.addParty(party2)
1150
+ expect(savedParty2).toBeDefined()
1151
+
1152
+ const relationship1: NonPersistedPartyRelationship = {
1153
+ leftId: savedParty1.id,
1154
+ rightId: savedParty2.id,
1155
+ }
1156
+ await contactStore.addRelationship(relationship1)
1157
+
1158
+ const relationship2: NonPersistedPartyRelationship = {
1159
+ leftId: savedParty2.id,
1160
+ rightId: savedParty1.id,
1161
+ }
1162
+ await contactStore.addRelationship(relationship2)
1163
+
1164
+ const result: Array<PartyRelationship> = await contactStore.getRelationships()
1165
+
1166
+ expect(result).toBeDefined()
1167
+ expect(result.length).toEqual(2)
1168
+ })
1169
+
1170
+ it('should get relationships by filter', async (): Promise<void> => {
1171
+ const party1: NonPersistedParty = {
1172
+ uri: 'example1.com',
1173
+ partyType: {
1174
+ type: PartyTypeEnum.NATURAL_PERSON,
1175
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1176
+ name: 'example_name1',
1177
+ },
1178
+ contact: {
1179
+ firstName: 'example_first_name1',
1180
+ middleName: 'example_middle_name1',
1181
+ lastName: 'example_last_name1',
1182
+ displayName: 'example_display_name1',
1183
+ },
1184
+ }
1185
+ const savedParty1: Party = await contactStore.addParty(party1)
1186
+ expect(savedParty1).toBeDefined()
1187
+
1188
+ const party2: NonPersistedParty = {
1189
+ uri: 'example2.com',
1190
+ partyType: {
1191
+ type: PartyTypeEnum.NATURAL_PERSON,
1192
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1193
+ name: 'example_name2',
1194
+ },
1195
+ contact: {
1196
+ firstName: 'example_first_name2',
1197
+ middleName: 'example_middle_name2',
1198
+ lastName: 'example_last_name2',
1199
+ displayName: 'example_display_name2',
1200
+ },
1201
+ }
1202
+ const savedParty2: Party = await contactStore.addParty(party2)
1203
+ expect(savedParty2).toBeDefined()
1204
+
1205
+ const relationship1: NonPersistedPartyRelationship = {
1206
+ leftId: savedParty1.id,
1207
+ rightId: savedParty2.id,
1208
+ }
1209
+ await contactStore.addRelationship(relationship1)
1210
+
1211
+ const relationship2: NonPersistedPartyRelationship = {
1212
+ leftId: savedParty2.id,
1213
+ rightId: savedParty1.id,
1214
+ }
1215
+ await contactStore.addRelationship(relationship2)
1216
+
1217
+ const args: GetRelationshipsArgs = {
1218
+ filter: [
1219
+ {
1220
+ leftId: savedParty1.id,
1221
+ rightId: savedParty2.id,
1222
+ },
1223
+ ],
1224
+ }
1225
+
1226
+ const result: Array<PartyRelationship> = await contactStore.getRelationships(args)
1227
+
1228
+ expect(result).toBeDefined()
1229
+ expect(result.length).toEqual(1)
1230
+ })
1231
+
1232
+ it('should remove relationship', async (): Promise<void> => {
1233
+ const party1: NonPersistedParty = {
1234
+ uri: 'example1.com',
1235
+ partyType: {
1236
+ type: PartyTypeEnum.NATURAL_PERSON,
1237
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1238
+ name: 'example_name1',
1239
+ },
1240
+ contact: {
1241
+ firstName: 'example_first_name1',
1242
+ middleName: 'example_middle_name1',
1243
+ lastName: 'example_last_name1',
1244
+ displayName: 'example_display_name1',
1245
+ },
1246
+ }
1247
+ const savedParty1: Party = await contactStore.addParty(party1)
1248
+ expect(savedParty1).toBeDefined()
1249
+
1250
+ const party2: NonPersistedParty = {
1251
+ uri: 'example2.com',
1252
+ partyType: {
1253
+ type: PartyTypeEnum.NATURAL_PERSON,
1254
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1255
+ name: 'example_name2',
1256
+ },
1257
+ contact: {
1258
+ firstName: 'example_first_name2',
1259
+ middleName: 'example_middle_name2',
1260
+ lastName: 'example_last_name2',
1261
+ displayName: 'example_display_name2',
1262
+ },
1263
+ }
1264
+ const savedParty2: Party = await contactStore.addParty(party2)
1265
+ expect(savedParty2).toBeDefined()
1266
+
1267
+ const relationship: NonPersistedPartyRelationship = {
1268
+ leftId: savedParty1.id,
1269
+ rightId: savedParty2.id,
1270
+ }
1271
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1272
+ expect(savedRelationship).toBeDefined()
1273
+
1274
+ await contactStore.removeRelationship({ relationshipId: savedRelationship.id })
1275
+
1276
+ const result: Party = await contactStore.getParty({ partyId: savedParty1.id })
1277
+
1278
+ expect(result).toBeDefined()
1279
+ expect(result?.relationships?.length).toEqual(0)
1280
+ })
1281
+
1282
+ it('should throw error when removing relationship with unknown id', async (): Promise<void> => {
1283
+ const relationshipId = 'unknownRelationshipId'
1284
+
1285
+ await expect(contactStore.removeRelationship({ relationshipId })).rejects.toThrow(`No relationship found for id: ${relationshipId}`)
1286
+ })
1287
+
1288
+ it('should return no relationships if filter does not match', async (): Promise<void> => {
1289
+ const args: GetRelationshipsArgs = {
1290
+ filter: [
1291
+ {
1292
+ leftId: 'unknown_id',
1293
+ },
1294
+ ],
1295
+ }
1296
+ const result: Array<PartyRelationship> = await contactStore.getRelationships(args)
1297
+
1298
+ expect(result.length).toEqual(0)
1299
+ })
1300
+
1301
+ it('should update relationship by id', async (): Promise<void> => {
1302
+ const party1: NonPersistedParty = {
1303
+ uri: 'example1.com',
1304
+ partyType: {
1305
+ type: PartyTypeEnum.NATURAL_PERSON,
1306
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1307
+ name: 'example_name1',
1308
+ },
1309
+ contact: {
1310
+ firstName: 'example_first_name1',
1311
+ middleName: 'example_middle_name1',
1312
+ lastName: 'example_last_name1',
1313
+ displayName: 'example_display_name1',
1314
+ },
1315
+ }
1316
+ const savedParty1: Party = await contactStore.addParty(party1)
1317
+ expect(savedParty1).toBeDefined()
1318
+
1319
+ const party2: NonPersistedParty = {
1320
+ uri: 'example2.com',
1321
+ partyType: {
1322
+ type: PartyTypeEnum.NATURAL_PERSON,
1323
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1324
+ name: 'example_name2',
1325
+ },
1326
+ contact: {
1327
+ firstName: 'example_first_name2',
1328
+ middleName: 'example_middle_name2',
1329
+ lastName: 'example_last_name2',
1330
+ displayName: 'example_display_name2',
1331
+ },
1332
+ }
1333
+ const savedParty2: Party = await contactStore.addParty(party2)
1334
+ expect(savedParty2).toBeDefined()
1335
+
1336
+ const party3: NonPersistedParty = {
1337
+ uri: 'example3.com',
1338
+ partyType: {
1339
+ type: PartyTypeEnum.NATURAL_PERSON,
1340
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d287',
1341
+ name: 'example_name3',
1342
+ },
1343
+ contact: {
1344
+ firstName: 'example_first_name3',
1345
+ middleName: 'example_middle_name3',
1346
+ lastName: 'example_last_name3',
1347
+ displayName: 'example_display_name3',
1348
+ },
1349
+ }
1350
+ const savedParty3: Party = await contactStore.addParty(party3)
1351
+ expect(savedParty3).toBeDefined()
1352
+
1353
+ const relationship: NonPersistedPartyRelationship = {
1354
+ leftId: savedParty1.id,
1355
+ rightId: savedParty2.id,
1356
+ }
1357
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1358
+
1359
+ const updatedRelationship: PartyRelationship = {
1360
+ ...savedRelationship,
1361
+ rightId: savedParty3.id,
1362
+ }
1363
+
1364
+ await contactStore.updateRelationship({ relationship: updatedRelationship })
1365
+
1366
+ const result: Party = await contactStore.getParty({ partyId: savedParty1.id })
1367
+
1368
+ expect(result).toBeDefined()
1369
+ expect(result.relationships.length).toEqual(1)
1370
+ expect(result.relationships[0].leftId).toEqual(savedParty1.id)
1371
+ expect(result.relationships[0].rightId).toEqual(savedParty3.id)
1372
+ })
1373
+
1374
+ it('should throw error when updating relationship with unknown id', async (): Promise<void> => {
1375
+ const party1: NonPersistedParty = {
1376
+ uri: 'example1.com',
1377
+ partyType: {
1378
+ type: PartyTypeEnum.NATURAL_PERSON,
1379
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1380
+ name: 'example_name1',
1381
+ },
1382
+ contact: {
1383
+ firstName: 'example_first_name1',
1384
+ middleName: 'example_middle_name1',
1385
+ lastName: 'example_last_name1',
1386
+ displayName: 'example_display_name1',
1387
+ },
1388
+ }
1389
+ const savedParty1: Party = await contactStore.addParty(party1)
1390
+ expect(savedParty1).toBeDefined()
1391
+
1392
+ const party2: NonPersistedParty = {
1393
+ uri: 'example2.com',
1394
+ partyType: {
1395
+ type: PartyTypeEnum.NATURAL_PERSON,
1396
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1397
+ name: 'example_name2',
1398
+ },
1399
+ contact: {
1400
+ firstName: 'example_first_name2',
1401
+ middleName: 'example_middle_name2',
1402
+ lastName: 'example_last_name2',
1403
+ displayName: 'example_display_name2',
1404
+ },
1405
+ }
1406
+ const savedParty2: Party = await contactStore.addParty(party2)
1407
+ expect(savedParty2).toBeDefined()
1408
+
1409
+ const relationship: NonPersistedPartyRelationship = {
1410
+ leftId: savedParty1.id,
1411
+ rightId: savedParty2.id,
1412
+ }
1413
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1414
+
1415
+ const relationshipId = 'unknownRelationshipId'
1416
+ const updatedRelationship: PartyRelationship = {
1417
+ ...savedRelationship,
1418
+ id: relationshipId,
1419
+ rightId: savedParty2.id,
1420
+ }
1421
+
1422
+ await expect(contactStore.updateRelationship({ relationship: updatedRelationship })).rejects.toThrow(
1423
+ `No party relationship found for id: ${relationshipId}`
1424
+ )
1425
+ })
1426
+
1427
+ it('should throw error when updating relationship with unknown right side id', async (): Promise<void> => {
1428
+ const party1: NonPersistedParty = {
1429
+ uri: 'example1.com',
1430
+ partyType: {
1431
+ type: PartyTypeEnum.NATURAL_PERSON,
1432
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1433
+ name: 'example_name1',
1434
+ },
1435
+ contact: {
1436
+ firstName: 'example_first_name1',
1437
+ middleName: 'example_middle_name1',
1438
+ lastName: 'example_last_name1',
1439
+ displayName: 'example_display_name1',
1440
+ },
1441
+ }
1442
+ const savedParty1: Party = await contactStore.addParty(party1)
1443
+ expect(savedParty1).toBeDefined()
1444
+
1445
+ const party2: NonPersistedParty = {
1446
+ uri: 'example2.com',
1447
+ partyType: {
1448
+ type: PartyTypeEnum.NATURAL_PERSON,
1449
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1450
+ name: 'example_name2',
1451
+ },
1452
+ contact: {
1453
+ firstName: 'example_first_name2',
1454
+ middleName: 'example_middle_name2',
1455
+ lastName: 'example_last_name2',
1456
+ displayName: 'example_display_name2',
1457
+ },
1458
+ }
1459
+ const savedParty2: Party = await contactStore.addParty(party2)
1460
+ expect(savedParty2).toBeDefined()
1461
+
1462
+ const relationship: NonPersistedPartyRelationship = {
1463
+ leftId: savedParty1.id,
1464
+ rightId: savedParty2.id,
1465
+ }
1466
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1467
+
1468
+ const partyId = 'unknownPartyId'
1469
+ const updatedRelationship: PartyRelationship = {
1470
+ ...savedRelationship,
1471
+ rightId: partyId,
1472
+ }
1473
+
1474
+ await expect(contactStore.updateRelationship({ relationship: updatedRelationship })).rejects.toThrow(
1475
+ `No party found for right side of the relationship, party id: ${partyId}`
1476
+ )
1477
+ })
1478
+
1479
+ it('should throw error when updating relationship with unknown left side id', async (): Promise<void> => {
1480
+ const party1: NonPersistedParty = {
1481
+ uri: 'example1.com',
1482
+ partyType: {
1483
+ type: PartyTypeEnum.NATURAL_PERSON,
1484
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1485
+ name: 'example_name1',
1486
+ },
1487
+ contact: {
1488
+ firstName: 'example_first_name1',
1489
+ middleName: 'example_middle_name1',
1490
+ lastName: 'example_last_name1',
1491
+ displayName: 'example_display_name1',
1492
+ },
1493
+ }
1494
+ const savedParty1: Party = await contactStore.addParty(party1)
1495
+ expect(savedParty1).toBeDefined()
1496
+
1497
+ const party2: NonPersistedParty = {
1498
+ uri: 'example2.com',
1499
+ partyType: {
1500
+ type: PartyTypeEnum.NATURAL_PERSON,
1501
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1502
+ name: 'example_name2',
1503
+ },
1504
+ contact: {
1505
+ firstName: 'example_first_name2',
1506
+ middleName: 'example_middle_name2',
1507
+ lastName: 'example_last_name2',
1508
+ displayName: 'example_display_name2',
1509
+ },
1510
+ }
1511
+ const savedParty2: Party = await contactStore.addParty(party2)
1512
+ expect(savedParty2).toBeDefined()
1513
+
1514
+ const relationship: NonPersistedPartyRelationship = {
1515
+ leftId: savedParty1.id,
1516
+ rightId: savedParty2.id,
1517
+ }
1518
+ const savedRelationship: PartyRelationship = await contactStore.addRelationship(relationship)
1519
+
1520
+ const partyId = 'unknownPartyId'
1521
+ const updatedRelationship: PartyRelationship = {
1522
+ ...savedRelationship,
1523
+ leftId: partyId,
1524
+ }
1525
+
1526
+ await expect(contactStore.updateRelationship({ relationship: updatedRelationship })).rejects.toThrow(
1527
+ `No party found for left side of the relationship, party id: ${partyId}`
1528
+ )
1529
+ })
1530
+
1531
+ it('should add party type', async (): Promise<void> => {
1532
+ const partyType: NonPersistedPartyType = {
1533
+ type: PartyTypeEnum.NATURAL_PERSON,
1534
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1535
+ name: 'example_name',
1536
+ description: 'example_description',
1537
+ }
1538
+
1539
+ const savedPartyType: PartyType = await contactStore.addPartyType(partyType)
1540
+ const result: PartyType = await contactStore.getPartyType({ partyTypeId: savedPartyType.id })
1541
+
1542
+ expect(result).toBeDefined()
1543
+ expect(result.name).toEqual(partyType.name)
1544
+ expect(result.type).toEqual(partyType.type)
1545
+ expect(result.tenantId).toEqual(partyType.tenantId)
1546
+ expect(result.description).toEqual(partyType.description)
1547
+ expect(result.lastUpdatedAt).toBeDefined()
1548
+ expect(result.createdAt).toBeDefined()
1549
+ })
1550
+
1551
+ it('should get party types by filter', async (): Promise<void> => {
1552
+ const partyType1: NonPersistedPartyType = {
1553
+ type: PartyTypeEnum.NATURAL_PERSON,
1554
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1555
+ name: 'example_name1',
1556
+ description: 'example_description1',
1557
+ }
1558
+ const savedPartyType1: PartyType = await contactStore.addPartyType(partyType1)
1559
+ expect(savedPartyType1).toBeDefined()
1560
+
1561
+ const partyType2: NonPersistedPartyType = {
1562
+ type: PartyTypeEnum.NATURAL_PERSON,
1563
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d287',
1564
+ name: 'example_name2',
1565
+ description: 'example_description2',
1566
+ }
1567
+ const savedPartyType2: PartyType = await contactStore.addPartyType(partyType2)
1568
+ expect(savedPartyType2).toBeDefined()
1569
+
1570
+ const result: Array<PartyType> = await contactStore.getPartyTypes({
1571
+ filter: [
1572
+ {
1573
+ type: PartyTypeEnum.NATURAL_PERSON,
1574
+ name: 'example_name1',
1575
+ description: 'example_description1',
1576
+ },
1577
+ ],
1578
+ })
1579
+
1580
+ expect(result).toBeDefined()
1581
+ expect(result.length).toEqual(1)
1582
+ })
1583
+
1584
+ it('should return no party types if filter does not match', async (): Promise<void> => {
1585
+ const partyType1: NonPersistedPartyType = {
1586
+ type: PartyTypeEnum.NATURAL_PERSON,
1587
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1588
+ name: 'example_name1',
1589
+ description: 'example_description1',
1590
+ }
1591
+ const savedPartyType1: PartyType = await contactStore.addPartyType(partyType1)
1592
+ expect(savedPartyType1).toBeDefined()
1593
+
1594
+ const partyType2: NonPersistedPartyType = {
1595
+ type: PartyTypeEnum.NATURAL_PERSON,
1596
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d287',
1597
+ name: 'example_name2',
1598
+ description: 'example_description2',
1599
+ }
1600
+ const savedPartyType2: PartyType = await contactStore.addPartyType(partyType2)
1601
+ expect(savedPartyType2).toBeDefined()
1602
+
1603
+ const result: Array<PartyType> = await contactStore.getPartyTypes({
1604
+ filter: [
1605
+ {
1606
+ type: PartyTypeEnum.NATURAL_PERSON,
1607
+ name: 'unknown_name',
1608
+ description: 'unknown_description',
1609
+ },
1610
+ ],
1611
+ })
1612
+
1613
+ expect(result).toBeDefined()
1614
+ expect(result.length).toEqual(0)
1615
+ })
1616
+
1617
+ it('should throw error when updating party type with unknown id', async (): Promise<void> => {
1618
+ const partyType: NonPersistedPartyType = {
1619
+ type: PartyTypeEnum.NATURAL_PERSON,
1620
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1621
+ name: 'example_name',
1622
+ description: 'example_description',
1623
+ }
1624
+ const savedPartyType: PartyType = await contactStore.addPartyType(partyType)
1625
+ expect(savedPartyType).toBeDefined()
1626
+
1627
+ const partyTypeId = 'unknownPartyTypeId'
1628
+ const updatedPartyType: PartyType = {
1629
+ ...savedPartyType,
1630
+ id: partyTypeId,
1631
+ description: 'new_example_description',
1632
+ }
1633
+
1634
+ await expect(contactStore.updatePartyType({ partyType: updatedPartyType })).rejects.toThrow(`No party type found for id: ${partyTypeId}`)
1635
+ })
1636
+
1637
+ it('should update party type by id', async (): Promise<void> => {
1638
+ const partyType: NonPersistedPartyType = {
1639
+ type: PartyTypeEnum.NATURAL_PERSON,
1640
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1641
+ name: 'example_name',
1642
+ description: 'example_description',
1643
+ }
1644
+ const savedPartyType: PartyType = await contactStore.addPartyType(partyType)
1645
+ expect(savedPartyType).toBeDefined()
1646
+
1647
+ const newDescription = 'new_example_description'
1648
+ const updatedPartyType: PartyType = {
1649
+ ...savedPartyType,
1650
+ description: newDescription,
1651
+ }
1652
+
1653
+ const result: PartyType = await contactStore.updatePartyType({ partyType: updatedPartyType })
1654
+
1655
+ expect(result).toBeDefined()
1656
+ expect(result.description).toEqual(newDescription)
1657
+ })
1658
+
1659
+ it('should throw error when removing party type with unknown id', async (): Promise<void> => {
1660
+ const partyTypeId = 'unknownPartyTypeId'
1661
+
1662
+ await expect(contactStore.removePartyType({ partyTypeId })).rejects.toThrow(`No party type found for id: ${partyTypeId}`)
1663
+ })
1664
+
1665
+ it('should remove party type', async (): Promise<void> => {
1666
+ const partyType: NonPersistedPartyType = {
1667
+ type: PartyTypeEnum.NATURAL_PERSON,
1668
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d288',
1669
+ name: 'example_name',
1670
+ description: 'example_description',
1671
+ }
1672
+ const savedPartyType: PartyType = await contactStore.addPartyType(partyType)
1673
+ expect(savedPartyType).toBeDefined()
1674
+
1675
+ const resultPartyType: PartyType = await contactStore.getPartyType({ partyTypeId: savedPartyType.id })
1676
+ expect(resultPartyType).toBeDefined()
1677
+
1678
+ const includingMigrationPartyTypes: Array<PartyType> = await contactStore.getPartyTypes()
1679
+ expect(includingMigrationPartyTypes.length).toEqual(2)
1680
+
1681
+ await contactStore.removePartyType({ partyTypeId: savedPartyType.id })
1682
+
1683
+ const result: Array<PartyType> = await contactStore.getPartyTypes()
1684
+
1685
+ expect(result).toBeDefined()
1686
+ expect(result.length).toEqual(1)
1687
+ })
1688
+
1689
+ it('should throw error when removing party type attached to contact', async (): Promise<void> => {
1690
+ const party: NonPersistedParty = {
1691
+ uri: 'example.com',
1692
+ partyType: {
1693
+ type: PartyTypeEnum.NATURAL_PERSON,
1694
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1695
+ name: 'example_name',
1696
+ },
1697
+ contact: {
1698
+ firstName: 'example_first_name',
1699
+ middleName: 'example_middle_name',
1700
+ lastName: 'example_last_name',
1701
+ displayName: 'example_display_name',
1702
+ },
1703
+ }
1704
+ const savedParty: Party = await contactStore.addParty(party)
1705
+ expect(savedParty).toBeDefined()
1706
+
1707
+ await expect(contactStore.removePartyType({ partyTypeId: savedParty.partyType.id })).rejects.toThrow(
1708
+ `Unable to remove party type with id: ${savedParty.partyType.id}. Party type is in use`
1709
+ )
1710
+ })
1711
+
1712
+ it('Should save party with existing party type', async (): Promise<void> => {
1713
+ const partyType: NonPersistedPartyType = {
1714
+ type: PartyTypeEnum.NATURAL_PERSON,
1715
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1716
+ name: 'example_name',
1717
+ }
1718
+ const savedPartyType: PartyType = await contactStore.addPartyType(partyType)
1719
+ expect(savedPartyType).toBeDefined()
1720
+
1721
+ const party: NonPersistedParty = {
1722
+ uri: 'example.com',
1723
+ partyType: savedPartyType,
1724
+ contact: {
1725
+ firstName: 'example_first_name',
1726
+ middleName: 'example_middle_name',
1727
+ lastName: 'example_last_name',
1728
+ displayName: 'example_display_name',
1729
+ },
1730
+ }
1731
+
1732
+ const result: Party = await contactStore.addParty(party)
1733
+
1734
+ expect(result).toBeDefined()
1735
+ expect(result?.partyType).toBeDefined()
1736
+ expect(result?.partyType.id).toEqual(savedPartyType.id)
1737
+ expect(result?.partyType.type).toEqual(savedPartyType.type)
1738
+ expect(result?.partyType.tenantId).toEqual(savedPartyType.tenantId)
1739
+ expect(result?.partyType.name).toEqual(savedPartyType.name)
1740
+ })
1741
+
1742
+ it('should throw error when adding person party with wrong contact type', async (): Promise<void> => {
1743
+ const partyType = PartyTypeEnum.ORGANIZATION
1744
+ const party: NonPersistedParty = {
1745
+ uri: 'example.com',
1746
+ partyType: {
1747
+ type: partyType,
1748
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1749
+ name: 'example_name',
1750
+ },
1751
+ contact: {
1752
+ firstName: 'example_first_name',
1753
+ middleName: 'example_middle_name',
1754
+ lastName: 'example_last_name',
1755
+ displayName: 'example_display_name',
1756
+ },
1757
+ }
1758
+
1759
+ await expect(contactStore.addParty(party)).rejects.toThrow(`Party type ${partyType}, does not match for provided contact`)
1760
+ })
1761
+
1762
+ it('should throw error when adding organization party with wrong contact type', async (): Promise<void> => {
1763
+ const partyType = PartyTypeEnum.NATURAL_PERSON
1764
+ const party: NonPersistedParty = {
1765
+ uri: 'example.com',
1766
+ partyType: {
1767
+ type: partyType,
1768
+ tenantId: '0605761c-4113-4ce5-a6b2-9cbae2f9d289',
1769
+ name: 'example_name',
1770
+ },
1771
+ contact: {
1772
+ legalName: 'example_legal_name',
1773
+ displayName: 'example_display_name',
1774
+ },
1775
+ }
1776
+
1777
+ await expect(contactStore.addParty(party)).rejects.toThrow(`Party type ${partyType}, does not match for provided contact`)
1778
+ })
743
1779
  })