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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/contact/AbstractContactStore.d.ts +11 -1
  2. package/dist/contact/AbstractContactStore.d.ts.map +1 -1
  3. package/dist/contact/AbstractContactStore.js.map +1 -1
  4. package/dist/contact/ContactStore.d.ts +27 -15
  5. package/dist/contact/ContactStore.d.ts.map +1 -1
  6. package/dist/contact/ContactStore.js +199 -36
  7. package/dist/contact/ContactStore.js.map +1 -1
  8. package/dist/entities/contact/ElectronicAddressEntity.d.ts +1 -0
  9. package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
  10. package/dist/entities/contact/ElectronicAddressEntity.js +4 -0
  11. package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
  12. package/dist/entities/contact/IdentityEntity.d.ts +1 -1
  13. package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
  14. package/dist/entities/contact/PartyEntity.d.ts +2 -0
  15. package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
  16. package/dist/entities/contact/PartyEntity.js +12 -1
  17. package/dist/entities/contact/PartyEntity.js.map +1 -1
  18. package/dist/entities/contact/PhysicalAddressEntity.d.ts +21 -0
  19. package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -0
  20. package/dist/entities/contact/PhysicalAddressEntity.js +126 -0
  21. package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -0
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
  27. package/dist/issuanceBranding/IssuanceBrandingStore.js +76 -60
  28. package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -1
  29. package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
  30. package/dist/migrations/sqlite/1690925872693-CreateContacts.js +3 -6
  31. package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
  32. package/dist/types/contact/IAbstractContactStore.d.ts +36 -1
  33. package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
  34. package/dist/types/contact/contact.d.ts +27 -4
  35. package/dist/types/contact/contact.d.ts.map +1 -1
  36. package/dist/types/contact/contact.js.map +1 -1
  37. package/dist/utils/contact/MappingUtils.d.ts +4 -1
  38. package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
  39. package/dist/utils/contact/MappingUtils.js +37 -1
  40. package/dist/utils/contact/MappingUtils.js.map +1 -1
  41. package/package.json +4 -4
  42. package/src/__tests__/contact.entities.test.ts +323 -23
  43. package/src/__tests__/contact.store.test.ts +586 -10
  44. package/src/contact/AbstractContactStore.ts +38 -17
  45. package/src/contact/ContactStore.ts +276 -62
  46. package/src/entities/contact/ElectronicAddressEntity.ts +3 -0
  47. package/src/entities/contact/IdentityEntity.ts +1 -1
  48. package/src/entities/contact/PartyEntity.ts +11 -1
  49. package/src/entities/contact/PhysicalAddressEntity.ts +87 -0
  50. package/src/index.ts +3 -0
  51. package/src/issuanceBranding/IssuanceBrandingStore.ts +78 -62
  52. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +3 -8
  53. package/src/types/contact/IAbstractContactStore.ts +58 -8
  54. package/src/types/contact/contact.ts +29 -4
  55. package/src/utils/contact/MappingUtils.ts +39 -1
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ import { PartyTypeEntity } from './entities/contact/PartyTypeEntity'
24
24
  import { OrganizationEntity } from './entities/contact/OrganizationEntity'
25
25
  import { NaturalPersonEntity } from './entities/contact/NaturalPersonEntity'
26
26
  import { ElectronicAddressEntity } from './entities/contact/ElectronicAddressEntity'
27
+ import { PhysicalAddressEntity } from './entities/contact/PhysicalAddressEntity'
27
28
  export { ContactStore } from './contact/ContactStore'
28
29
  export { AbstractContactStore } from './contact/AbstractContactStore'
29
30
  export { AbstractIssuanceBrandingStore } from './issuanceBranding/AbstractIssuanceBrandingStore'
@@ -57,6 +58,7 @@ export const DataStoreContactEntities = [
57
58
  OrganizationEntity,
58
59
  NaturalPersonEntity,
59
60
  ElectronicAddressEntity,
61
+ PhysicalAddressEntity,
60
62
  ]
61
63
 
62
64
  export const DataStoreIssuanceBrandingEntities = [
@@ -102,6 +104,7 @@ export {
102
104
  CredentialLocaleBrandingEntity,
103
105
  IssuerLocaleBrandingEntity,
104
106
  ElectronicAddressEntity,
107
+ PhysicalAddressEntity,
105
108
  backgroundAttributesEntityFrom,
106
109
  credentialBrandingEntityFrom,
107
110
  imageAttributesEntityFrom,
@@ -53,16 +53,17 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
53
53
  }
54
54
 
55
55
  public addCredentialBranding = async (args: IAddCredentialBrandingArgs): Promise<ICredentialBranding> => {
56
+ const { localeBranding, vcHash } = args
56
57
  const repository: Repository<CredentialBrandingEntity> = (await this.dbConnection).getRepository(CredentialBrandingEntity)
57
58
  const result: CredentialBrandingEntity | null = await repository.findOne({
58
- where: [{ vcHash: args.vcHash }],
59
+ where: [{ vcHash }],
59
60
  })
60
61
 
61
62
  if (result) {
62
- return Promise.reject(Error(`Credential branding already present for vc with hash: ${args.vcHash}`))
63
+ return Promise.reject(Error(`Credential branding already present for vc with hash: ${vcHash}`))
63
64
  }
64
65
 
65
- if (await this.hasDuplicateLocales(args.localeBranding)) {
66
+ if (await this.hasDuplicateLocales(localeBranding)) {
66
67
  return Promise.reject(Error(`Credential branding contains duplicate locales`))
67
68
  }
68
69
 
@@ -74,8 +75,9 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
74
75
  }
75
76
 
76
77
  public getCredentialBranding = async (args?: IGetCredentialBrandingArgs): Promise<Array<ICredentialBranding>> => {
77
- if (args?.filter) {
78
- args?.filter.forEach((filter: IPartialCredentialBranding): void => {
78
+ const { filter } = args ?? {}
79
+ if (filter) {
80
+ filter.forEach((filter: IPartialCredentialBranding): void => {
79
81
  if (filter.localeBranding && 'locale' in filter.localeBranding && filter.localeBranding.locale === undefined) {
80
82
  filter.localeBranding.locale = ''
81
83
  }
@@ -84,16 +86,17 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
84
86
 
85
87
  debug('Getting credential branding', args)
86
88
  const result: Array<CredentialBrandingEntity> = await (await this.dbConnection).getRepository(CredentialBrandingEntity).find({
87
- ...(args?.filter && { where: args?.filter }),
89
+ ...(filter && { where: filter }),
88
90
  })
89
91
 
90
92
  return result.map((credentialBranding: CredentialBrandingEntity) => this.credentialBrandingFrom(credentialBranding))
91
93
  }
92
94
 
93
95
  public removeCredentialBranding = async (args: IRemoveCredentialBrandingArgs): Promise<void> => {
96
+ const { filter } = args
94
97
  const repository: Repository<CredentialBrandingEntity> = (await this.dbConnection).getRepository(CredentialBrandingEntity)
95
98
  const credentialBranding: Array<CredentialBrandingEntity> = await repository.find({
96
- where: args.filter,
99
+ where: filter,
97
100
  })
98
101
 
99
102
  debug('Removing credential locale branding', args)
@@ -105,49 +108,51 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
105
108
  await Promise.all(localeBrandingDeletions)
106
109
 
107
110
  debug('Removing credential branding', args)
108
- const credentialBrandingDeletions: Array<Promise<DeleteResult>> = args.filter.map(
111
+ const credentialBrandingDeletions: Array<Promise<DeleteResult>> = filter.map(
109
112
  async (filter: ICredentialBrandingFilter): Promise<DeleteResult> => await repository.delete(filter)
110
113
  )
111
114
  await Promise.all(credentialBrandingDeletions)
112
115
  }
113
116
 
114
117
  public updateCredentialBranding = async (args: IUpdateCredentialBrandingArgs): Promise<ICredentialBranding> => {
118
+ const { credentialBranding } = args
115
119
  const repository: Repository<CredentialBrandingEntity> = (await this.dbConnection).getRepository(CredentialBrandingEntity)
116
120
  const credentialBrandingEntity: CredentialBrandingEntity | null = await repository.findOne({
117
- where: { id: args.credentialBranding.id },
121
+ where: { id: credentialBranding.id },
118
122
  })
119
123
 
120
124
  if (!credentialBrandingEntity) {
121
- return Promise.reject(Error(`No credential branding found for id: ${args.credentialBranding.id}`))
125
+ return Promise.reject(Error(`No credential branding found for id: ${credentialBranding.id}`))
122
126
  }
123
127
 
124
- const credentialBranding: Omit<ICredentialBranding, 'createdAt' | 'lastUpdatedAt'> = {
125
- ...args.credentialBranding,
128
+ const branding: Omit<ICredentialBranding, 'createdAt' | 'lastUpdatedAt'> = {
129
+ ...credentialBranding,
126
130
  localeBranding: credentialBrandingEntity.localeBranding,
127
131
  }
128
132
 
129
- debug('Updating credential branding', credentialBranding)
130
- const result: CredentialBrandingEntity = await repository.save(credentialBranding, { transaction: true })
133
+ debug('Updating credential branding', branding)
134
+ const result: CredentialBrandingEntity = await repository.save(branding, { transaction: true })
131
135
 
132
136
  return this.credentialBrandingFrom(result)
133
137
  }
134
138
 
135
139
  public addCredentialLocaleBranding = async (args: IAddCredentialLocaleBrandingArgs): Promise<ICredentialBranding> => {
140
+ const { credentialBrandingId, localeBranding } = args
136
141
  const credentialBrandingRepository: Repository<CredentialBrandingEntity> = (await this.dbConnection).getRepository(CredentialBrandingEntity)
137
142
  const credentialBranding: CredentialBrandingEntity | null = await credentialBrandingRepository.findOne({
138
- where: { id: args.credentialBrandingId },
143
+ where: { id: credentialBrandingId },
139
144
  })
140
145
 
141
146
  if (!credentialBranding) {
142
- return Promise.reject(Error(`No credential branding found for id: ${args.credentialBrandingId}`))
147
+ return Promise.reject(Error(`No credential branding found for id: ${credentialBrandingId}`))
143
148
  }
144
149
 
145
150
  const locales: Array<CredentialLocaleBrandingEntity> | null = await (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity).find({
146
151
  where: {
147
152
  credentialBranding: {
148
- id: args.credentialBrandingId,
153
+ id: credentialBrandingId,
149
154
  },
150
- locale: In(args.localeBranding.map((localeBranding: IBasicCredentialLocaleBranding) => localeBranding.locale)),
155
+ locale: In(localeBranding.map((localeBranding: IBasicCredentialLocaleBranding) => localeBranding.locale)),
151
156
  },
152
157
  })
153
158
 
@@ -164,7 +169,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
164
169
  const credentialLocaleBrandingRepository: Repository<CredentialLocaleBrandingEntity> = (await this.dbConnection).getRepository(
165
170
  CredentialLocaleBrandingEntity
166
171
  )
167
- const addCredentialLocaleBranding: Array<Promise<void>> = args.localeBranding.map(
172
+ const addCredentialLocaleBranding: Array<Promise<void>> = localeBranding.map(
168
173
  async (localeBranding: IBasicCredentialLocaleBranding): Promise<void> => {
169
174
  const credentialLocaleBrandingEntity: CredentialLocaleBrandingEntity = credentialLocaleBrandingEntityFrom(localeBranding)
170
175
  debug('Adding credential locale branding', credentialLocaleBrandingEntity)
@@ -176,7 +181,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
176
181
  await Promise.all(addCredentialLocaleBranding)
177
182
 
178
183
  const result: CredentialBrandingEntity | null = await credentialBrandingRepository.findOne({
179
- where: { id: args.credentialBrandingId },
184
+ where: { id: credentialBrandingId },
180
185
  })
181
186
 
182
187
  if (!result) {
@@ -187,8 +192,9 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
187
192
  }
188
193
 
189
194
  public getCredentialLocaleBranding = async (args?: IGetCredentialLocaleBrandingArgs): Promise<Array<ICredentialLocaleBranding>> => {
190
- if (args?.filter) {
191
- args?.filter.forEach((filter: ICredentialLocaleBrandingFilter): void => {
195
+ const { filter } = args ?? {}
196
+ if (filter) {
197
+ filter.forEach((filter: ICredentialLocaleBrandingFilter): void => {
192
198
  if ('locale' in filter && filter.locale === undefined) {
193
199
  filter.locale = ''
194
200
  }
@@ -199,7 +205,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
199
205
  const credentialBrandingLocale: Array<CredentialLocaleBrandingEntity> | null = await (await this.dbConnection)
200
206
  .getRepository(CredentialLocaleBrandingEntity)
201
207
  .find({
202
- ...(args?.filter && { where: args?.filter }),
208
+ ...(filter && { where: filter }),
203
209
  })
204
210
 
205
211
  return credentialBrandingLocale
@@ -210,10 +216,11 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
210
216
  }
211
217
 
212
218
  public removeCredentialLocaleBranding = async (args: IRemoveCredentialLocaleBrandingArgs): Promise<void> => {
219
+ const { filter } = args
213
220
  const credentialLocaleBranding: Array<CredentialLocaleBrandingEntity> = await (await this.dbConnection)
214
221
  .getRepository(CredentialLocaleBrandingEntity)
215
222
  .find({
216
- where: args.filter,
223
+ where: filter,
217
224
  })
218
225
 
219
226
  debug('Removing credential locale branding', args)
@@ -224,13 +231,14 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
224
231
  }
225
232
 
226
233
  public updateCredentialLocaleBranding = async (args: IUpdateCredentialLocaleBrandingArgs): Promise<ICredentialLocaleBranding> => {
234
+ const { localeBranding } = args
227
235
  const repository: Repository<CredentialLocaleBrandingEntity> = (await this.dbConnection).getRepository(CredentialLocaleBrandingEntity)
228
236
  const result: CredentialLocaleBrandingEntity | null = await repository.findOne({
229
- where: { id: args.localeBranding.id },
237
+ where: { id: localeBranding.id },
230
238
  })
231
239
 
232
240
  if (!result) {
233
- return Promise.reject(Error(`No credential locale branding found for id: ${args.localeBranding.id}`))
241
+ return Promise.reject(Error(`No credential locale branding found for id: ${localeBranding.id}`))
234
242
  }
235
243
 
236
244
  const locales: Array<CredentialLocaleBrandingEntity> | null = await repository.find({
@@ -238,32 +246,33 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
238
246
  credentialBranding: {
239
247
  id: result.credentialBrandingId,
240
248
  },
241
- id: Not(In([args.localeBranding.id])),
242
- locale: args.localeBranding.locale,
249
+ id: Not(In([localeBranding.id])),
250
+ locale: localeBranding.locale,
243
251
  },
244
252
  })
245
253
 
246
254
  if (locales && locales.length > 0) {
247
- return Promise.reject(Error(`Credential branding: ${result.credentialBrandingId} already contains locale: ${args.localeBranding.locale}`))
255
+ return Promise.reject(Error(`Credential branding: ${result.credentialBrandingId} already contains locale: ${localeBranding.locale}`))
248
256
  }
249
257
 
250
- debug('Updating credential locale branding', args.localeBranding)
251
- const updatedResult: CredentialLocaleBrandingEntity = await repository.save(args.localeBranding, { transaction: true })
258
+ debug('Updating credential locale branding', localeBranding)
259
+ const updatedResult: CredentialLocaleBrandingEntity = await repository.save(localeBranding, { transaction: true })
252
260
 
253
261
  return this.localeBrandingFrom(updatedResult) as ICredentialLocaleBranding
254
262
  }
255
263
 
256
264
  public addIssuerBranding = async (args: IAddIssuerBrandingArgs): Promise<IIssuerBranding> => {
265
+ const { localeBranding, issuerCorrelationId } = args
257
266
  const repository: Repository<IssuerBrandingEntity> = (await this.dbConnection).getRepository(IssuerBrandingEntity)
258
267
  const result: IssuerBrandingEntity | null = await repository.findOne({
259
- where: [{ issuerCorrelationId: args.issuerCorrelationId }],
268
+ where: [{ issuerCorrelationId }],
260
269
  })
261
270
 
262
271
  if (result) {
263
- return Promise.reject(Error(`Issuer branding already present for issuer with correlation id: ${args.issuerCorrelationId}`))
272
+ return Promise.reject(Error(`Issuer branding already present for issuer with correlation id: ${issuerCorrelationId}`))
264
273
  }
265
274
 
266
- if (await this.hasDuplicateLocales(args.localeBranding)) {
275
+ if (await this.hasDuplicateLocales(localeBranding)) {
267
276
  return Promise.reject(Error(`Issuer branding contains duplicate locales`))
268
277
  }
269
278
 
@@ -275,8 +284,9 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
275
284
  }
276
285
 
277
286
  public getIssuerBranding = async (args?: IGetIssuerBrandingArgs): Promise<Array<IIssuerBranding>> => {
278
- if (args?.filter) {
279
- args?.filter.forEach((filter: IIssuerBrandingFilter): void => {
287
+ const { filter } = args ?? {}
288
+ if (filter) {
289
+ filter.forEach((filter: IIssuerBrandingFilter): void => {
280
290
  if (filter.localeBranding && 'locale' in filter.localeBranding && filter.localeBranding.locale === undefined) {
281
291
  filter.localeBranding.locale = ''
282
292
  }
@@ -285,16 +295,17 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
285
295
 
286
296
  debug('Getting issuer branding', args)
287
297
  const result: Array<IssuerBrandingEntity> = await (await this.dbConnection).getRepository(IssuerBrandingEntity).find({
288
- ...(args?.filter && { where: args?.filter }),
298
+ ...(filter && { where: filter }),
289
299
  })
290
300
 
291
301
  return result.map((issuerBranding: IssuerBrandingEntity) => this.issuerBrandingFrom(issuerBranding))
292
302
  }
293
303
 
294
304
  public removeIssuerBranding = async (args: IRemoveIssuerBrandingArgs): Promise<void> => {
305
+ const { filter } = args
295
306
  const repository: Repository<IssuerBrandingEntity> = (await this.dbConnection).getRepository(IssuerBrandingEntity)
296
307
  const issuerBranding: Array<IssuerBrandingEntity> = await repository.find({
297
- where: args.filter,
308
+ where: filter,
298
309
  })
299
310
 
300
311
  debug('Removing issuer locale branding', args)
@@ -306,49 +317,51 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
306
317
  await Promise.all(localeBrandingDeletions)
307
318
 
308
319
  debug('Removing issuer branding', args)
309
- const issuerBrandingDeletions: Array<Promise<DeleteResult>> = args.filter.map(
320
+ const issuerBrandingDeletions: Array<Promise<DeleteResult>> = filter.map(
310
321
  async (filter: IIssuerBrandingFilter): Promise<DeleteResult> => await repository.delete(filter)
311
322
  )
312
323
  await Promise.all(issuerBrandingDeletions)
313
324
  }
314
325
 
315
326
  public updateIssuerBranding = async (args: IUpdateIssuerBrandingArgs): Promise<IIssuerBranding> => {
327
+ const { issuerBranding } = args
316
328
  const repository: Repository<IssuerBrandingEntity> = (await this.dbConnection).getRepository(IssuerBrandingEntity)
317
329
  const issuerBrandingEntity: IssuerBrandingEntity | null = await repository.findOne({
318
- where: { id: args.issuerBranding.id },
330
+ where: { id: issuerBranding.id },
319
331
  })
320
332
 
321
333
  if (!issuerBrandingEntity) {
322
- return Promise.reject(Error(`No issuer branding found for id: ${args.issuerBranding.id}`))
334
+ return Promise.reject(Error(`No issuer branding found for id: ${issuerBranding.id}`))
323
335
  }
324
336
 
325
- const issuerBranding: Omit<IIssuerBranding, 'createdAt' | 'lastUpdatedAt'> = {
326
- ...args.issuerBranding,
337
+ const branding: Omit<IIssuerBranding, 'createdAt' | 'lastUpdatedAt'> = {
338
+ ...issuerBranding,
327
339
  localeBranding: issuerBrandingEntity.localeBranding,
328
340
  }
329
341
 
330
- debug('Updating issuer branding', issuerBranding)
331
- const result: IssuerBrandingEntity = await repository.save(issuerBranding, { transaction: true })
342
+ debug('Updating issuer branding', branding)
343
+ const result: IssuerBrandingEntity = await repository.save(branding, { transaction: true })
332
344
 
333
345
  return this.issuerBrandingFrom(result)
334
346
  }
335
347
 
336
348
  public addIssuerLocaleBranding = async (args: IAddIssuerLocaleBrandingArgs): Promise<IIssuerBranding> => {
349
+ const { localeBranding, issuerBrandingId } = args
337
350
  const issuerBrandingRepository: Repository<IssuerBrandingEntity> = (await this.dbConnection).getRepository(IssuerBrandingEntity)
338
351
  const issuerBranding: IssuerBrandingEntity | null = await issuerBrandingRepository.findOne({
339
- where: { id: args.issuerBrandingId },
352
+ where: { id: issuerBrandingId },
340
353
  })
341
354
 
342
355
  if (!issuerBranding) {
343
- return Promise.reject(Error(`No issuer branding found for id: ${args.issuerBrandingId}`))
356
+ return Promise.reject(Error(`No issuer branding found for id: ${issuerBrandingId}`))
344
357
  }
345
358
 
346
359
  const locales: Array<IssuerLocaleBrandingEntity> | null = await (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity).find({
347
360
  where: {
348
361
  issuerBranding: {
349
- id: args.issuerBrandingId,
362
+ id: issuerBrandingId,
350
363
  },
351
- locale: In(args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) => localeBranding.locale)),
364
+ locale: In(localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) => localeBranding.locale)),
352
365
  },
353
366
  })
354
367
 
@@ -363,7 +376,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
363
376
  }
364
377
 
365
378
  const issuerLocaleBrandingRepository: Repository<IssuerLocaleBrandingEntity> = (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity)
366
- const addIssuerLocaleBranding: Array<Promise<void>> = args.localeBranding.map(
379
+ const addIssuerLocaleBranding: Array<Promise<void>> = localeBranding.map(
367
380
  async (localeBranding: IBasicIssuerLocaleBranding): Promise<void> => {
368
381
  const issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity = issuerLocaleBrandingEntityFrom(localeBranding)
369
382
  debug('Adding issuer locale branding', issuerLocaleBrandingEntity)
@@ -375,7 +388,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
375
388
  await Promise.all(addIssuerLocaleBranding)
376
389
 
377
390
  const result: IssuerBrandingEntity | null = await issuerBrandingRepository.findOne({
378
- where: { id: args.issuerBrandingId },
391
+ where: { id: issuerBrandingId },
379
392
  })
380
393
 
381
394
  if (!result) {
@@ -386,8 +399,9 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
386
399
  }
387
400
 
388
401
  public getIssuerLocaleBranding = async (args?: IGetIssuerLocaleBrandingArgs): Promise<Array<IIssuerLocaleBranding>> => {
389
- if (args?.filter) {
390
- args?.filter.forEach((filter: IIssuerLocaleBrandingFilter): void => {
402
+ const { filter } = args ?? {}
403
+ if (filter) {
404
+ filter.forEach((filter: IIssuerLocaleBrandingFilter): void => {
391
405
  if ('locale' in filter && filter.locale === undefined) {
392
406
  filter.locale = ''
393
407
  }
@@ -398,7 +412,7 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
398
412
  const issuerLocaleBranding: Array<IssuerLocaleBrandingEntity> | null = await (await this.dbConnection)
399
413
  .getRepository(IssuerLocaleBrandingEntity)
400
414
  .find({
401
- ...(args?.filter && { where: args?.filter }),
415
+ ...(filter && { where: filter }),
402
416
  })
403
417
 
404
418
  return issuerLocaleBranding
@@ -409,8 +423,9 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
409
423
  }
410
424
 
411
425
  public removeIssuerLocaleBranding = async (args: IRemoveIssuerLocaleBrandingArgs): Promise<void> => {
426
+ const { filter } = args
412
427
  const issuerLocaleBranding: Array<IssuerLocaleBrandingEntity> = await (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity).find({
413
- where: args.filter,
428
+ where: filter,
414
429
  })
415
430
 
416
431
  debug('Removing credential locale branding', args)
@@ -421,13 +436,14 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
421
436
  }
422
437
 
423
438
  public updateIssuerLocaleBranding = async (args: IUpdateIssuerLocaleBrandingArgs): Promise<IIssuerLocaleBranding> => {
439
+ const { localeBranding } = args
424
440
  const repository: Repository<IssuerLocaleBrandingEntity> = (await this.dbConnection).getRepository(IssuerLocaleBrandingEntity)
425
441
  const result: IssuerLocaleBrandingEntity | null = await repository.findOne({
426
- where: { id: args.localeBranding.id },
442
+ where: { id: localeBranding.id },
427
443
  })
428
444
 
429
445
  if (!result) {
430
- return Promise.reject(Error(`No issuer locale branding found for id: ${args.localeBranding.id}`))
446
+ return Promise.reject(Error(`No issuer locale branding found for id: ${localeBranding.id}`))
431
447
  }
432
448
 
433
449
  const locales: Array<IssuerLocaleBrandingEntity> | null = await repository.find({
@@ -435,17 +451,17 @@ export class IssuanceBrandingStore extends AbstractIssuanceBrandingStore {
435
451
  issuerBranding: {
436
452
  id: result.issuerBrandingId,
437
453
  },
438
- id: Not(In([args.localeBranding.id])),
439
- locale: args.localeBranding.locale,
454
+ id: Not(In([localeBranding.id])),
455
+ locale: localeBranding.locale,
440
456
  },
441
457
  })
442
458
 
443
459
  if (locales && locales.length > 0) {
444
- return Promise.reject(Error(`Issuer branding: ${result.issuerBrandingId} already contains locale: ${args.localeBranding.locale}`))
460
+ return Promise.reject(Error(`Issuer branding: ${result.issuerBrandingId} already contains locale: ${localeBranding.locale}`))
445
461
  }
446
462
 
447
- debug('Updating issuer locale branding', args.localeBranding)
448
- const updatedResult: IssuerLocaleBrandingEntity = await repository.save(args.localeBranding, { transaction: true })
463
+ debug('Updating issuer locale branding', localeBranding)
464
+ const updatedResult: IssuerLocaleBrandingEntity = await repository.save(localeBranding, { transaction: true })
449
465
 
450
466
  return this.localeBrandingFrom(updatedResult) as IIssuerLocaleBranding
451
467
  }
@@ -60,9 +60,6 @@ export class CreateContacts1690925872693 implements MigrationInterface {
60
60
  `CREATE TABLE "PartyRelationship" ("id" varchar PRIMARY KEY NOT NULL, "left_id" varchar NOT NULL, "right_id" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`
61
61
  )
62
62
  await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
63
- await queryRunner.query(
64
- `CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar)`
65
- )
66
63
  await queryRunner.query(
67
64
  `CREATE TABLE "Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL)`
68
65
  )
@@ -99,15 +96,13 @@ export class CreateContacts1690925872693 implements MigrationInterface {
99
96
  await queryRunner.query(`ALTER TABLE "temporary_PartyRelationship" RENAME TO "PartyRelationship"`)
100
97
  await queryRunner.query(`CREATE UNIQUE INDEX "IDX_PartyRelationship_left_right" ON "PartyRelationship" ("left_id", "right_id")`)
101
98
  await queryRunner.query(
102
- `CREATE TABLE "temporary_ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
99
+ `CREATE TABLE "ElectronicAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "electronic_address" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "partyId" varchar, CONSTRAINT "FK_ElectronicAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
103
100
  )
104
101
  await queryRunner.query(
105
- `INSERT INTO "temporary_ElectronicAddress"("id", "type", "electronic_address", "created_at", "last_updated_at", "partyId") SELECT "id", "type", "electronic_address", "created_at", "last_updated_at", "partyId" FROM "ElectronicAddress"`
102
+ `CREATE TABLE "PhysicalAddress" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar(255) NOT NULL, "street_name" varchar(255) NOT NULL, "street_number" varchar(255) NOT NULL, "postal_code" varchar(255) NOT NULL, "city_name" varchar(255) NOT NULL, "province_name" varchar(255) NOT NULL, "country_code" varchar(2) NOT NULL, "building_name" varchar(255), "partyId" varchar, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
106
103
  )
107
- await queryRunner.query(`DROP TABLE "ElectronicAddress"`)
108
- await queryRunner.query(`ALTER TABLE "temporary_ElectronicAddress" RENAME TO "ElectronicAddress"`)
109
104
  await queryRunner.query(
110
- `CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`
105
+ `CREATE TABLE "temporary_Party" ("id" varchar PRIMARY KEY NOT NULL, "uri" varchar(255), "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "party_type_id" varchar NOT NULL, CONSTRAINT "FK_Party_party_type_id" FOREIGN KEY ("party_type_id") REFERENCES "PartyType" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`
111
106
  )
112
107
  await queryRunner.query(
113
108
  `INSERT INTO "temporary_Party"("id", "uri", "created_at", "last_updated_at", "party_type_id") SELECT "id", "uri", "created_at", "last_updated_at", "party_type_id" FROM "Party"`
@@ -1,23 +1,30 @@
1
1
  import {
2
- NonPersistedPartyType,
2
+ ElectronicAddress,
3
+ Identity,
3
4
  NonPersistedContact,
5
+ NonPersistedElectronicAddress,
4
6
  NonPersistedIdentity,
5
- Party,
6
- Identity,
7
- PartialParty,
7
+ NonPersistedPartyType,
8
+ NonPersistedPhysicalAddress,
9
+ PartialElectronicAddress,
8
10
  PartialIdentity,
9
- PartyTypeEnum,
10
- PartyType,
11
- PartyRelationship,
11
+ PartialParty,
12
12
  PartialPartyRelationship,
13
13
  PartialPartyType,
14
- NonPersistedElectronicAddress,
14
+ PartialPhysicalAddress,
15
+ Party,
16
+ PartyRelationship,
17
+ PartyType,
18
+ PartyTypeEnum,
19
+ PhysicalAddress
15
20
  } from './contact'
16
21
 
17
22
  export type FindPartyArgs = Array<PartialParty>
18
23
  export type FindIdentityArgs = Array<PartialIdentity>
19
24
  export type FindPartyTypeArgs = Array<PartialPartyType>
20
25
  export type FindRelationshipArgs = Array<PartialPartyRelationship>
26
+ export type FindElectronicAddressArgs = Array<PartialElectronicAddress>
27
+ export type FindPhysicalAddressArgs = Array<PartialPhysicalAddress>
21
28
 
22
29
  export type GetPartyArgs = {
23
30
  partyId: string
@@ -33,6 +40,7 @@ export type AddPartyArgs = {
33
40
  contact: NonPersistedContact
34
41
  identities?: Array<NonPersistedIdentity>
35
42
  electronicAddresses?: Array<NonPersistedElectronicAddress>
43
+ physicalAddresses?: Array<NonPersistedPhysicalAddress>
36
44
  }
37
45
 
38
46
  export type UpdatePartyArgs = {
@@ -107,3 +115,45 @@ export type UpdatePartyTypeArgs = {
107
115
  export type RemovePartyTypeArgs = {
108
116
  partyTypeId: string
109
117
  }
118
+
119
+ export type GetElectronicAddressArgs = {
120
+ electronicAddressId: string
121
+ }
122
+
123
+ export type GetElectronicAddressesArgs = {
124
+ filter?: FindElectronicAddressArgs
125
+ }
126
+
127
+ export type AddElectronicAddressArgs = {
128
+ partyId: string
129
+ electronicAddress: NonPersistedElectronicAddress
130
+ }
131
+
132
+ export type UpdateElectronicAddressArgs = {
133
+ electronicAddress: ElectronicAddress
134
+ }
135
+
136
+ export type RemoveElectronicAddressArgs = {
137
+ electronicAddressId: string
138
+ }
139
+
140
+ export type GetPhysicalAddressArgs = {
141
+ physicalAddressId: string
142
+ }
143
+
144
+ export type GetPhysicalAddressesArgs = {
145
+ filter?: FindPhysicalAddressArgs
146
+ }
147
+
148
+ export type AddPhysicalAddressArgs = {
149
+ partyId: string
150
+ physicalAddress: NonPersistedPhysicalAddress
151
+ }
152
+
153
+ export type UpdatePhysicalAddressArgs = {
154
+ physicalAddress: PhysicalAddress
155
+ }
156
+
157
+ export type RemovePhysicalAddressArgs = {
158
+ physicalAddressId: string
159
+ }
@@ -6,6 +6,7 @@ export type Party = {
6
6
  roles: Array<IdentityRoleEnum>
7
7
  identities: Array<Identity>
8
8
  electronicAddresses: Array<ElectronicAddress>
9
+ physicalAddresses: Array<PhysicalAddress>
9
10
  contact: Contact
10
11
  partyType: PartyType
11
12
  relationships: Array<PartyRelationship>
@@ -14,17 +15,19 @@ export type Party = {
14
15
  }
15
16
  export type NonPersistedParty = Omit<
16
17
  Party,
17
- 'id' | 'identities' | 'electronicAddresses' | 'contact' | 'roles' | 'partyType' | 'relationships' | 'createdAt' | 'lastUpdatedAt'
18
+ 'id' | 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'roles' | 'partyType' | 'relationships' | 'createdAt' | 'lastUpdatedAt'
18
19
  > & {
19
20
  identities?: Array<NonPersistedIdentity>
20
21
  electronicAddresses?: Array<NonPersistedElectronicAddress>
22
+ physicalAddresses?: Array<NonPersistedPhysicalAddress>
21
23
  contact: NonPersistedContact
22
24
  partyType: NonPersistedPartyType
23
25
  relationships?: Array<NonPersistedPartyRelationship>
24
26
  }
25
- export type PartialParty = Partial<Omit<Party, 'identities' | 'electronicAddresses' | 'contact' | 'partyType' | 'relationships'>> & {
27
+ export type PartialParty = Partial<Omit<Party, 'identities' | 'electronicAddresses' | 'physicalAddresses' | 'contact' | 'partyType' | 'relationships'>> & {
26
28
  identities?: PartialIdentity
27
29
  electronicAddresses?: PartialElectronicAddress
30
+ physicalAddresses?: PartialPhysicalAddress
28
31
  contact?: PartialContact
29
32
  partyType?: PartialPartyType
30
33
  relationships?: PartialPartyRelationship
@@ -168,9 +171,31 @@ export type ElectronicAddress = {
168
171
  lastUpdatedAt: Date
169
172
  }
170
173
  export type NonPersistedElectronicAddress = Omit<ElectronicAddress, 'id' | 'createdAt' | 'lastUpdatedAt'>
171
- export type PartialElectronicAddress = Partial<ElectronicAddress>
174
+ export type PartialElectronicAddress = Partial<ElectronicAddress> & {
175
+ partyId?: string
176
+ }
177
+
178
+ export type PhysicalAddress = {
179
+ id: string
180
+ type: PhysicalAddressType
181
+ streetName: string
182
+ streetNumber: string
183
+ postalCode: string
184
+ cityName: string
185
+ provinceName: string
186
+ countryCode: string
187
+ buildingName?: string
188
+ createdAt: Date
189
+ lastUpdatedAt: Date
190
+ }
191
+ export type NonPersistedPhysicalAddress = Omit<PhysicalAddress, 'id' | 'createdAt' | 'lastUpdatedAt'>
192
+ export type PartialPhysicalAddress = Partial<PhysicalAddress> & {
193
+ partyId?: string
194
+ }
195
+
196
+ export type ElectronicAddressType = 'email' | 'phone'
172
197
 
173
- export type ElectronicAddressType = 'email'
198
+ export type PhysicalAddressType = 'home' | 'visit' | 'postal'
174
199
 
175
200
  export enum IdentityRoleEnum {
176
201
  ISSUER = 'issuer',