@sphereon/ssi-sdk.data-store 0.24.1-unstable.9 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/contact/ContactStore.d.ts +3 -0
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +84 -48
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/entities/contact/BaseContactEntity.d.ts +2 -0
- package/dist/entities/contact/BaseContactEntity.d.ts.map +1 -1
- package/dist/entities/contact/BaseContactEntity.js +12 -3
- package/dist/entities/contact/BaseContactEntity.js.map +1 -1
- package/dist/entities/contact/ConnectionEntity.d.ts +2 -0
- package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
- package/dist/entities/contact/ConnectionEntity.js +8 -0
- package/dist/entities/contact/ConnectionEntity.js.map +1 -1
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts +14 -0
- package/dist/entities/contact/ContactMetadataItemEntity.d.ts.map +1 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js +88 -0
- package/dist/entities/contact/ContactMetadataItemEntity.js.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.js +8 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +2 -0
- package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.js +8 -0
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +2 -0
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.js +8 -0
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -1
- package/dist/entities/contact/IMetadataEntity.d.ts +8 -0
- package/dist/entities/contact/IMetadataEntity.d.ts.map +1 -0
- package/dist/entities/contact/IMetadataEntity.js +2 -0
- package/dist/entities/contact/IMetadataEntity.js.map +1 -0
- package/dist/entities/contact/IdentityEntity.d.ts +5 -2
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +13 -0
- package/dist/entities/contact/IdentityEntity.js.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +6 -2
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.js +19 -3
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.d.ts +2 -0
- package/dist/entities/contact/NaturalPersonEntity.d.ts.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.js +8 -0
- package/dist/entities/contact/NaturalPersonEntity.js.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +2 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.js +8 -0
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
- package/dist/entities/contact/OrganizationEntity.d.ts +2 -0
- package/dist/entities/contact/OrganizationEntity.d.ts.map +1 -1
- package/dist/entities/contact/OrganizationEntity.js +8 -0
- package/dist/entities/contact/OrganizationEntity.js.map +1 -1
- package/dist/entities/contact/PartyEntity.d.ts +2 -0
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyEntity.js +8 -0
- package/dist/entities/contact/PartyEntity.js.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +2 -0
- package/dist/entities/contact/PartyRelationshipEntity.d.ts.map +1 -1
- package/dist/entities/contact/PartyRelationshipEntity.js +8 -0
- package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -1
- package/dist/entities/contact/PartyTypeEntity.js +4 -4
- package/dist/entities/contact/PartyTypeEntity.js.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.d.ts +2 -0
- package/dist/entities/contact/PhysicalAddressEntity.d.ts.map +1 -1
- package/dist/entities/contact/PhysicalAddressEntity.js +10 -1
- package/dist/entities/contact/PhysicalAddressEntity.js.map +1 -1
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts +14 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.d.ts.map +1 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js +74 -0
- package/dist/entities/presentationDefinition/PresentationDefinitionItemEntity.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js +78 -0
- package/dist/migrations/generic/10-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/8-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/8-CreateContacts.js +78 -0
- package/dist/migrations/generic/8-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/9-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/9-CreateContacts.js +78 -0
- package/dist/migrations/generic/9-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +2 -0
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +12 -2
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +40 -3
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js +63 -0
- package/dist/migrations/postgres/1710438363001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +74 -0
- package/dist/migrations/postgres/1715761125001-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +41 -0
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +1 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +40 -3
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -1
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +79 -0
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +73 -0
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +7 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +1 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +38 -0
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts +12 -0
- package/dist/presentationDefinition/AbstractPDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/AbstractPDStore.js +7 -0
- package/dist/presentationDefinition/AbstractPDStore.js.map +1 -0
- package/dist/presentationDefinition/PDStore.d.ts +19 -0
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -0
- package/dist/presentationDefinition/PDStore.js +152 -0
- package/dist/presentationDefinition/PDStore.js.map +1 -0
- package/dist/types/contact/contact.d.ts +51 -15
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +12 -7
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts +17 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.d.ts.map +1 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js +3 -0
- package/dist/types/presentationDefinition/IAbstractPDStore.js.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts +16 -0
- package/dist/types/presentationDefinition/presentationDefinition.d.ts.map +1 -0
- package/dist/types/presentationDefinition/presentationDefinition.js +3 -0
- package/dist/types/presentationDefinition/presentationDefinition.js.map +1 -0
- package/dist/utils/contact/MappingUtils.d.ts +6 -4
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.js +122 -18
- package/dist/utils/contact/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.d.ts +6 -0
- package/dist/utils/presentationDefinition/MappingUtils.d.ts.map +1 -0
- package/dist/utils/presentationDefinition/MappingUtils.js +48 -0
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -0
- package/package.json +7 -4
- package/src/__tests__/contact.entities.test.ts +129 -44
- package/src/__tests__/contact.store.test.ts +205 -29
- package/src/__tests__/eventLogger.entities.test.ts +2 -2
- package/src/__tests__/eventLogger.store.test.ts +2 -5
- package/src/__tests__/pd-manager.entities.test.ts +71 -0
- package/src/__tests__/pd-manager.store.test.ts +191 -0
- package/src/contact/ContactStore.ts +74 -30
- package/src/entities/contact/BaseContactEntity.ts +11 -0
- package/src/entities/contact/ConnectionEntity.ts +6 -0
- package/src/entities/contact/ContactMetadataItemEntity.ts +50 -0
- package/src/entities/contact/CorrelationIdentifierEntity.ts +6 -0
- package/src/entities/contact/DidAuthConfigEntity.ts +6 -0
- package/src/entities/contact/ElectronicAddressEntity.ts +6 -0
- package/src/entities/contact/IMetadataEntity.ts +8 -0
- package/src/entities/contact/IdentityEntity.ts +11 -2
- package/src/entities/contact/IdentityMetadataItemEntity.ts +16 -4
- package/src/entities/contact/NaturalPersonEntity.ts +6 -0
- package/src/entities/contact/OpenIdConfigEntity.ts +6 -0
- package/src/entities/contact/OrganizationEntity.ts +6 -0
- package/src/entities/contact/PartyEntity.ts +6 -0
- package/src/entities/contact/PartyRelationshipEntity.ts +6 -0
- package/src/entities/contact/PartyTypeEntity.ts +4 -4
- package/src/entities/contact/PhysicalAddressEntity.ts +9 -2
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +43 -0
- package/src/index.ts +13 -0
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -0
- package/src/migrations/generic/8-CreateContacts.ts +66 -0
- package/src/migrations/generic/9-CreateContacts.ts +66 -0
- package/src/migrations/generic/index.ts +11 -1
- package/src/migrations/index.ts +1 -0
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +57 -3
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -0
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -0
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +70 -3
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -0
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -0
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -0
- package/src/presentationDefinition/AbstractPDStore.ts +20 -0
- package/src/presentationDefinition/PDStore.ts +185 -0
- package/src/types/contact/contact.ts +56 -15
- package/src/types/index.ts +2 -0
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -0
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -0
- package/src/utils/contact/MappingUtils.ts +128 -18
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -0
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './issuanceBranding/issuanceBranding'
|
|
2
2
|
export * from './issuanceBranding/IAbstractIssuanceBrandingStore'
|
|
3
3
|
export * from './contact/contact'
|
|
4
|
+
export * from './presentationDefinition/presentationDefinition'
|
|
5
|
+
export * from './presentationDefinition/IAbstractPDStore'
|
|
4
6
|
export * from './contact/IAbstractContactStore'
|
|
5
7
|
export * from './validation/validation'
|
|
6
8
|
export * from './statusList/statusList'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NonPersistedPresentationDefinitionItem, PresentationDefinitionItem, PresentationDefinitionItemFilter } from './presentationDefinition'
|
|
2
|
+
|
|
3
|
+
export type FindDefinitionArgs = Array<PresentationDefinitionItemFilter>
|
|
4
|
+
|
|
5
|
+
export type GetDefinitionArgs = {
|
|
6
|
+
itemId: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type HasDefinitionArgs = GetDefinitionArgs
|
|
10
|
+
|
|
11
|
+
export type GetDefinitionsArgs = {
|
|
12
|
+
filter?: FindDefinitionArgs
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type HasDefinitionsArgs = GetDefinitionsArgs
|
|
16
|
+
|
|
17
|
+
export type AddDefinitionArgs = NonPersistedPresentationDefinitionItem
|
|
18
|
+
|
|
19
|
+
export type UpdateDefinitionArgs = PresentationDefinitionItem
|
|
20
|
+
|
|
21
|
+
export type DeleteDefinitionArgs = {
|
|
22
|
+
itemId: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type DeleteDefinitionsArgs = GetDefinitionsArgs
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IPresentationDefinition } from '@sphereon/pex'
|
|
2
|
+
|
|
3
|
+
export type PresentationDefinitionItem = {
|
|
4
|
+
id: string
|
|
5
|
+
definitionId: string
|
|
6
|
+
tenantId?: string
|
|
7
|
+
version: string
|
|
8
|
+
name?: string
|
|
9
|
+
purpose?: string
|
|
10
|
+
definitionPayload: IPresentationDefinition
|
|
11
|
+
createdAt: Date
|
|
12
|
+
lastUpdatedAt: Date
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type NonPersistedPresentationDefinitionItem = Omit<PresentationDefinitionItem, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
16
|
+
export type PartialPresentationDefinitionItem = Partial<PresentationDefinitionItem>
|
|
17
|
+
export type PresentationDefinitionItemFilter = Partial<Omit<PresentationDefinitionItem, 'definitionPayload'>> // TODO add logic to linearize & hash definitionPayload into a separate column so we can filter on it?
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MetadataTypes,
|
|
2
3
|
Connection,
|
|
3
4
|
ConnectionConfig,
|
|
4
5
|
Contact,
|
|
@@ -45,6 +46,7 @@ import { IdentityMetadataItemEntity } from '../../entities/contact/IdentityMetad
|
|
|
45
46
|
import { OpenIdConfigEntity } from '../../entities/contact/OpenIdConfigEntity'
|
|
46
47
|
import { PartyTypeEntity } from '../../entities/contact/PartyTypeEntity'
|
|
47
48
|
import { PhysicalAddressEntity } from '../../entities/contact/PhysicalAddressEntity'
|
|
49
|
+
import { ContactMetadataItemEntity } from '../../entities/contact/ContactMetadataItemEntity'
|
|
48
50
|
|
|
49
51
|
export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
50
52
|
const partyEntity: PartyEntity = new PartyEntity()
|
|
@@ -58,6 +60,8 @@ export const partyEntityFrom = (party: NonPersistedParty): PartyEntity => {
|
|
|
58
60
|
: []
|
|
59
61
|
partyEntity.partyType = partyTypeEntityFrom(party.partyType)
|
|
60
62
|
partyEntity.contact = contactEntityFrom(party.contact)
|
|
63
|
+
partyEntity.ownerId = party.ownerId
|
|
64
|
+
partyEntity.tenantId = party.tenantId
|
|
61
65
|
|
|
62
66
|
return partyEntity
|
|
63
67
|
}
|
|
@@ -77,6 +81,8 @@ export const partyFrom = (party: PartyEntity): Party => {
|
|
|
77
81
|
relationships: party.relationships ? party.relationships.map((relationship: PartyRelationshipEntity) => partyRelationshipFrom(relationship)) : [],
|
|
78
82
|
partyType: partyTypeFrom(party.partyType),
|
|
79
83
|
contact: contactFrom(party.contact),
|
|
84
|
+
ownerId: party.ownerId,
|
|
85
|
+
tenantId: party.tenantId,
|
|
80
86
|
createdAt: party.createdAt,
|
|
81
87
|
lastUpdatedAt: party.lastUpdatedAt,
|
|
82
88
|
}
|
|
@@ -112,6 +118,8 @@ export const connectionEntityFrom = (connection: NonPersistedConnection): Connec
|
|
|
112
118
|
const connectionEntity: ConnectionEntity = new ConnectionEntity()
|
|
113
119
|
connectionEntity.type = connection.type
|
|
114
120
|
connectionEntity.config = configEntityFrom(connection.config)
|
|
121
|
+
connectionEntity.ownerId = connection.ownerId
|
|
122
|
+
connectionEntity.tenantId = connection.tenantId
|
|
115
123
|
|
|
116
124
|
return connectionEntity
|
|
117
125
|
}
|
|
@@ -120,6 +128,8 @@ export const connectionFrom = (connection: ConnectionEntity): Connection => {
|
|
|
120
128
|
return {
|
|
121
129
|
id: connection.id,
|
|
122
130
|
type: connection.type,
|
|
131
|
+
ownerId: connection.ownerId,
|
|
132
|
+
tenantId: connection.tenantId,
|
|
123
133
|
config: configFrom(connection.config),
|
|
124
134
|
}
|
|
125
135
|
}
|
|
@@ -138,6 +148,8 @@ export const correlationIdentifierEntityFrom = (identifier: NonPersistedCorrelat
|
|
|
138
148
|
const identifierEntity: CorrelationIdentifierEntity = new CorrelationIdentifierEntity()
|
|
139
149
|
identifierEntity.type = identifier.type
|
|
140
150
|
identifierEntity.correlationId = identifier.correlationId
|
|
151
|
+
identifierEntity.ownerId = identifier.ownerId
|
|
152
|
+
identifierEntity.tenantId = identifier.tenantId
|
|
141
153
|
|
|
142
154
|
return identifierEntity
|
|
143
155
|
}
|
|
@@ -147,6 +159,8 @@ export const correlationIdentifierFrom = (identifier: CorrelationIdentifierEntit
|
|
|
147
159
|
id: identifier.id,
|
|
148
160
|
type: identifier.type,
|
|
149
161
|
correlationId: identifier.correlationId,
|
|
162
|
+
ownerId: identifier.ownerId,
|
|
163
|
+
tenantId: identifier.tenantId,
|
|
150
164
|
}
|
|
151
165
|
}
|
|
152
166
|
|
|
@@ -155,7 +169,8 @@ export const didAuthConfigEntityFrom = (config: NonPersistedDidAuthConfig): DidA
|
|
|
155
169
|
didAuthConfig.identifier = config.identifier.did
|
|
156
170
|
didAuthConfig.redirectUrl = config.redirectUrl
|
|
157
171
|
didAuthConfig.sessionId = config.sessionId
|
|
158
|
-
|
|
172
|
+
didAuthConfig.ownerId = config.ownerId
|
|
173
|
+
didAuthConfig.tenantId = config.tenantId
|
|
159
174
|
return didAuthConfig
|
|
160
175
|
}
|
|
161
176
|
|
|
@@ -163,6 +178,8 @@ export const electronicAddressEntityFrom = (electronicAddress: NonPersistedElect
|
|
|
163
178
|
const electronicAddressEntity: ElectronicAddressEntity = new ElectronicAddressEntity()
|
|
164
179
|
electronicAddressEntity.type = electronicAddress.type
|
|
165
180
|
electronicAddressEntity.electronicAddress = electronicAddress.electronicAddress
|
|
181
|
+
electronicAddressEntity.ownerId = electronicAddress.ownerId
|
|
182
|
+
electronicAddressEntity.tenantId = electronicAddress.tenantId
|
|
166
183
|
|
|
167
184
|
return electronicAddressEntity
|
|
168
185
|
}
|
|
@@ -172,6 +189,8 @@ export const electronicAddressFrom = (electronicAddress: ElectronicAddressEntity
|
|
|
172
189
|
id: electronicAddress.id,
|
|
173
190
|
type: electronicAddress.type,
|
|
174
191
|
electronicAddress: electronicAddress.electronicAddress,
|
|
192
|
+
ownerId: electronicAddress.ownerId,
|
|
193
|
+
tenantId: electronicAddress.tenantId,
|
|
175
194
|
createdAt: electronicAddress.createdAt,
|
|
176
195
|
lastUpdatedAt: electronicAddress.lastUpdatedAt,
|
|
177
196
|
}
|
|
@@ -187,6 +206,8 @@ export const physicalAddressEntityFrom = (physicalAddress: NonPersistedPhysicalA
|
|
|
187
206
|
physicalAddressEntity.provinceName = physicalAddress.provinceName
|
|
188
207
|
physicalAddressEntity.countryCode = physicalAddress.countryCode
|
|
189
208
|
physicalAddressEntity.buildingName = physicalAddress.buildingName
|
|
209
|
+
physicalAddressEntity.ownerId = physicalAddress.ownerId
|
|
210
|
+
physicalAddressEntity.tenantId = physicalAddress.tenantId
|
|
190
211
|
|
|
191
212
|
return physicalAddressEntity
|
|
192
213
|
}
|
|
@@ -202,19 +223,25 @@ export const physicalAddressFrom = (physicalAddress: PhysicalAddressEntity): Phy
|
|
|
202
223
|
provinceName: physicalAddress.provinceName,
|
|
203
224
|
countryCode: physicalAddress.countryCode,
|
|
204
225
|
buildingName: physicalAddress.buildingName,
|
|
226
|
+
ownerId: physicalAddress.ownerId,
|
|
227
|
+
tenantId: physicalAddress.tenantId,
|
|
205
228
|
createdAt: physicalAddress.createdAt,
|
|
206
229
|
lastUpdatedAt: physicalAddress.lastUpdatedAt,
|
|
207
230
|
}
|
|
208
231
|
}
|
|
209
232
|
|
|
210
|
-
export const identityEntityFrom = (
|
|
233
|
+
export const identityEntityFrom = (entity: NonPersistedIdentity): IdentityEntity => {
|
|
211
234
|
const identityEntity: IdentityEntity = new IdentityEntity()
|
|
212
|
-
identityEntity.alias =
|
|
213
|
-
identityEntity.
|
|
214
|
-
identityEntity.
|
|
215
|
-
identityEntity.
|
|
216
|
-
identityEntity.
|
|
217
|
-
|
|
235
|
+
identityEntity.alias = entity.alias
|
|
236
|
+
identityEntity.origin = entity.origin
|
|
237
|
+
identityEntity.ownerId = entity.ownerId
|
|
238
|
+
identityEntity.tenantId = entity.tenantId
|
|
239
|
+
identityEntity.roles = entity.roles
|
|
240
|
+
identityEntity.identifier = correlationIdentifierEntityFrom(entity.identifier)
|
|
241
|
+
identityEntity.connection = entity.connection ? connectionEntityFrom(entity.connection) : undefined
|
|
242
|
+
identityEntity.metadata = entity.metadata
|
|
243
|
+
? entity.metadata.map(identityMetadataItemEntityFrom).filter((entity): entity is IdentityMetadataItemEntity => entity !== undefined)
|
|
244
|
+
: []
|
|
218
245
|
return identityEntity
|
|
219
246
|
}
|
|
220
247
|
|
|
@@ -222,7 +249,10 @@ export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
|
222
249
|
return {
|
|
223
250
|
id: identity.id,
|
|
224
251
|
alias: identity.alias,
|
|
252
|
+
origin: identity.origin,
|
|
225
253
|
roles: identity.roles,
|
|
254
|
+
tenantId: identity.tenantId,
|
|
255
|
+
ownerId: identity.ownerId,
|
|
226
256
|
identifier: correlationIdentifierFrom(identity.identifier),
|
|
227
257
|
...(identity.connection && { connection: connectionFrom(identity.connection) }),
|
|
228
258
|
metadata: identity.metadata ? identity.metadata.map((item: IdentityMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
@@ -231,20 +261,75 @@ export const identityFrom = (identity: IdentityEntity): Identity => {
|
|
|
231
261
|
}
|
|
232
262
|
}
|
|
233
263
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
264
|
+
const metadataItemEntityFrom = <T extends MetadataTypes, U extends { new (): any }>(
|
|
265
|
+
item: NonPersistedMetadataItem<T>,
|
|
266
|
+
EntityClass: U,
|
|
267
|
+
): InstanceType<U> | undefined => {
|
|
268
|
+
const { label, value } = item
|
|
269
|
+
|
|
270
|
+
if (value === null || value === undefined) {
|
|
271
|
+
return undefined
|
|
272
|
+
}
|
|
238
273
|
|
|
274
|
+
const metadataItemEntity = new EntityClass()
|
|
275
|
+
metadataItemEntity.label = label
|
|
276
|
+
metadataItemEntity.valueType = typeof value
|
|
277
|
+
|
|
278
|
+
switch (typeof value) {
|
|
279
|
+
case 'undefined':
|
|
280
|
+
return undefined
|
|
281
|
+
case 'string':
|
|
282
|
+
metadataItemEntity.stringValue = value
|
|
283
|
+
break
|
|
284
|
+
case 'number':
|
|
285
|
+
metadataItemEntity.numberValue = value
|
|
286
|
+
break
|
|
287
|
+
case 'boolean':
|
|
288
|
+
metadataItemEntity.boolValue = value
|
|
289
|
+
break
|
|
290
|
+
case 'object':
|
|
291
|
+
metadataItemEntity.valueType = Object.prototype.toString.call(value).slice(8, -1)
|
|
292
|
+
if (value instanceof Date) {
|
|
293
|
+
metadataItemEntity.dateValue = value
|
|
294
|
+
} else {
|
|
295
|
+
// For now, we only support / implement not-primitive type Date in the entity
|
|
296
|
+
throw new Error(`Unsupported object type: ${metadataItemEntity.valueType} for value ${value}`)
|
|
297
|
+
}
|
|
298
|
+
break
|
|
299
|
+
}
|
|
239
300
|
return metadataItemEntity
|
|
240
301
|
}
|
|
241
302
|
|
|
242
|
-
export const
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
303
|
+
export const identityMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): IdentityMetadataItemEntity | undefined => {
|
|
304
|
+
return metadataItemEntityFrom(item, IdentityMetadataItemEntity)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export const contactMetadataItemEntityFrom = (item: NonPersistedMetadataItem<MetadataTypes>): ContactMetadataItemEntity | undefined => {
|
|
308
|
+
return metadataItemEntityFrom(item, ContactMetadataItemEntity)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export const metadataItemFrom = (entity: IdentityMetadataItemEntity | ContactMetadataItemEntity): MetadataItem<MetadataTypes> => {
|
|
312
|
+
const item: Partial<MetadataItem<MetadataTypes>> = {
|
|
313
|
+
id: entity.id,
|
|
314
|
+
label: entity.label,
|
|
315
|
+
}
|
|
316
|
+
switch (entity.valueType) {
|
|
317
|
+
case 'string':
|
|
318
|
+
item.value = entity.stringValue
|
|
319
|
+
break
|
|
320
|
+
case 'number':
|
|
321
|
+
item.value = entity.numberValue
|
|
322
|
+
break
|
|
323
|
+
case 'Date':
|
|
324
|
+
item.value = entity.dateValue
|
|
325
|
+
break
|
|
326
|
+
case 'boolean':
|
|
327
|
+
item.value = entity.boolValue
|
|
328
|
+
break
|
|
329
|
+
default:
|
|
330
|
+
throw new Error(`Unsupported valueType ${entity.valueType}`)
|
|
247
331
|
}
|
|
332
|
+
return item as MetadataItem<MetadataTypes>
|
|
248
333
|
}
|
|
249
334
|
|
|
250
335
|
export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson): NaturalPersonEntity => {
|
|
@@ -253,6 +338,11 @@ export const naturalPersonEntityFrom = (naturalPerson: NonPersistedNaturalPerson
|
|
|
253
338
|
naturalPersonEntity.middleName = naturalPerson.middleName
|
|
254
339
|
naturalPersonEntity.lastName = naturalPerson.lastName
|
|
255
340
|
naturalPersonEntity.displayName = naturalPerson.displayName
|
|
341
|
+
naturalPersonEntity.ownerId = naturalPerson.ownerId
|
|
342
|
+
naturalPersonEntity.tenantId = naturalPerson.tenantId
|
|
343
|
+
naturalPersonEntity.metadata = naturalPerson.metadata
|
|
344
|
+
? naturalPerson.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
345
|
+
: []
|
|
256
346
|
|
|
257
347
|
return naturalPersonEntity
|
|
258
348
|
}
|
|
@@ -264,6 +354,9 @@ export const naturalPersonFrom = (naturalPerson: NaturalPersonEntity): NaturalPe
|
|
|
264
354
|
middleName: naturalPerson.middleName,
|
|
265
355
|
lastName: naturalPerson.lastName,
|
|
266
356
|
displayName: naturalPerson.displayName,
|
|
357
|
+
metadata: naturalPerson.metadata ? naturalPerson.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
358
|
+
ownerId: naturalPerson.ownerId,
|
|
359
|
+
tenantId: naturalPerson.tenantId,
|
|
267
360
|
createdAt: naturalPerson.createdAt,
|
|
268
361
|
lastUpdatedAt: naturalPerson.lastUpdatedAt,
|
|
269
362
|
}
|
|
@@ -278,6 +371,8 @@ export const openIdConfigEntityFrom = (config: NonPersistedOpenIdConfig): OpenId
|
|
|
278
371
|
openIdConfig.redirectUrl = config.redirectUrl
|
|
279
372
|
openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
|
|
280
373
|
openIdConfig.clientAuthMethod = config.clientAuthMethod
|
|
374
|
+
openIdConfig.ownerId = config.ownerId
|
|
375
|
+
openIdConfig.tenantId = config.tenantId
|
|
281
376
|
|
|
282
377
|
return openIdConfig
|
|
283
378
|
}
|
|
@@ -286,6 +381,11 @@ export const organizationEntityFrom = (organization: NonPersistedOrganization):
|
|
|
286
381
|
const organizationEntity: OrganizationEntity = new OrganizationEntity()
|
|
287
382
|
organizationEntity.legalName = organization.legalName
|
|
288
383
|
organizationEntity.displayName = organization.displayName
|
|
384
|
+
organizationEntity.ownerId = organization.ownerId
|
|
385
|
+
organizationEntity.tenantId = organization.tenantId
|
|
386
|
+
organizationEntity.metadata = organization.metadata
|
|
387
|
+
? organization.metadata.map(contactMetadataItemEntityFrom).filter((entity): entity is ContactMetadataItemEntity => entity !== undefined)
|
|
388
|
+
: []
|
|
289
389
|
|
|
290
390
|
return organizationEntity
|
|
291
391
|
}
|
|
@@ -295,6 +395,9 @@ export const organizationFrom = (organization: OrganizationEntity): Organization
|
|
|
295
395
|
id: organization.id,
|
|
296
396
|
legalName: organization.legalName,
|
|
297
397
|
displayName: organization.displayName,
|
|
398
|
+
metadata: organization.metadata ? organization.metadata.map((item: ContactMetadataItemEntity) => metadataItemFrom(item)) : [],
|
|
399
|
+
ownerId: organization.ownerId,
|
|
400
|
+
tenantId: organization.tenantId,
|
|
298
401
|
createdAt: organization.createdAt,
|
|
299
402
|
lastUpdatedAt: organization.lastUpdatedAt,
|
|
300
403
|
}
|
|
@@ -304,7 +407,8 @@ export const partyRelationshipEntityFrom = (relationship: NonPersistedPartyRelat
|
|
|
304
407
|
const partyRelationshipEntity: PartyRelationshipEntity = new PartyRelationshipEntity()
|
|
305
408
|
partyRelationshipEntity.leftId = relationship.leftId
|
|
306
409
|
partyRelationshipEntity.rightId = relationship.rightId
|
|
307
|
-
|
|
410
|
+
partyRelationshipEntity.ownerId = relationship.ownerId
|
|
411
|
+
partyRelationshipEntity.tenantId = relationship.tenantId
|
|
308
412
|
return partyRelationshipEntity
|
|
309
413
|
}
|
|
310
414
|
|
|
@@ -313,6 +417,8 @@ export const partyRelationshipFrom = (relationship: PartyRelationshipEntity): Pa
|
|
|
313
417
|
id: relationship.id,
|
|
314
418
|
leftId: relationship.leftId,
|
|
315
419
|
rightId: relationship.rightId,
|
|
420
|
+
ownerId: relationship.ownerId,
|
|
421
|
+
tenantId: relationship.tenantId,
|
|
316
422
|
createdAt: relationship.createdAt,
|
|
317
423
|
lastUpdatedAt: relationship.lastUpdatedAt,
|
|
318
424
|
}
|
|
@@ -365,6 +471,8 @@ export const openIdConfigFrom = (config: OpenIdConfigEntity): OpenIdConfig => {
|
|
|
365
471
|
redirectUrl: config.redirectUrl,
|
|
366
472
|
dangerouslyAllowInsecureHttpRequests: config.dangerouslyAllowInsecureHttpRequests,
|
|
367
473
|
clientAuthMethod: config.clientAuthMethod,
|
|
474
|
+
ownerId: config.ownerId,
|
|
475
|
+
tenantId: config.tenantId,
|
|
368
476
|
}
|
|
369
477
|
}
|
|
370
478
|
|
|
@@ -375,6 +483,8 @@ export const didAuthConfigFrom = (config: DidAuthConfigEntity): DidAuthConfig =>
|
|
|
375
483
|
stateId: '', // FIXME
|
|
376
484
|
redirectUrl: config.redirectUrl,
|
|
377
485
|
sessionId: config.sessionId,
|
|
486
|
+
ownerId: config.ownerId,
|
|
487
|
+
tenantId: config.tenantId,
|
|
378
488
|
}
|
|
379
489
|
}
|
|
380
490
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { PresentationDefinitionItemEntity } from '../../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
2
|
+
import { IPresentationDefinition } from '@sphereon/pex'
|
|
3
|
+
import { NonPersistedPresentationDefinitionItem, PartialPresentationDefinitionItem, PresentationDefinitionItem } from '../../types'
|
|
4
|
+
import { blake2bHex } from 'blakejs'
|
|
5
|
+
|
|
6
|
+
export const presentationDefinitionItemFrom = (entity: PresentationDefinitionItemEntity): PresentationDefinitionItem => {
|
|
7
|
+
return {
|
|
8
|
+
id: entity.id,
|
|
9
|
+
tenantId: entity.tenantId,
|
|
10
|
+
definitionId: entity.definitionId,
|
|
11
|
+
version: entity.version,
|
|
12
|
+
name: entity.name,
|
|
13
|
+
purpose: entity.purpose,
|
|
14
|
+
definitionPayload: JSON.parse(entity.definitionPayload) as IPresentationDefinition,
|
|
15
|
+
createdAt: entity.createdAt,
|
|
16
|
+
lastUpdatedAt: entity.lastUpdatedAt,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const presentationDefinitionEntityItemFrom = (item: NonPersistedPresentationDefinitionItem): PresentationDefinitionItemEntity => {
|
|
21
|
+
const entity = new PresentationDefinitionItemEntity()
|
|
22
|
+
|
|
23
|
+
entity.tenantId = item.tenantId
|
|
24
|
+
entity.definitionId = item.definitionId!
|
|
25
|
+
entity.version = item.version
|
|
26
|
+
entity.name = item.name
|
|
27
|
+
entity.purpose = item.purpose
|
|
28
|
+
entity.definitionPayload = JSON.stringify(item.definitionPayload!)
|
|
29
|
+
return entity
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hashPayload(payload: IPresentationDefinition): string {
|
|
33
|
+
return blake2bHex(JSON.stringify(payload))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isPresentationDefinitionEqual(base: PartialPresentationDefinitionItem, compare: PartialPresentationDefinitionItem): boolean {
|
|
37
|
+
if (
|
|
38
|
+
base.definitionId !== compare.definitionId ||
|
|
39
|
+
base.tenantId != compare.tenantId ||
|
|
40
|
+
base.version !== compare.version ||
|
|
41
|
+
base.name != compare.name ||
|
|
42
|
+
base.purpose != compare.purpose
|
|
43
|
+
) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (base.definitionPayload && compare.definitionPayload) {
|
|
48
|
+
return hashPayload(base.definitionPayload) === hashPayload(compare.definitionPayload)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return false
|
|
52
|
+
}
|