@sphereon/ssi-sdk.data-store 0.34.1-next.91 → 0.36.1-feat.SSISDK.83.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3776 -3801
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +339 -1270
- package/dist/index.d.ts +339 -1270
- package/dist/index.js +3707 -3732
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/__tests__/contact.entities.test.ts +4 -10
- package/src/__tests__/contact.store.test.ts +11 -6
- package/src/__tests__/digitalCredential.entities.test.ts +13 -6
- package/src/__tests__/digitalCredential.store.test.ts +6 -6
- package/src/__tests__/eventLogger.entities.test.ts +3 -3
- package/src/__tests__/eventLogger.store.test.ts +9 -4
- package/src/__tests__/issuanceBranding.entities.test.ts +2 -2
- package/src/__tests__/issuanceBranding.store.test.ts +3 -3
- package/src/__tests__/machineState.entities.test.ts +1 -1
- package/src/__tests__/machineState.store.test.ts +1 -1
- package/src/__tests__/pd-manager.entities.test.ts +27 -98
- package/src/__tests__/pd-manager.store.test.ts +151 -101
- package/src/__tests__/statusList.entities.test.ts +4 -4
- package/src/__tests__/statusList.store.test.ts +3 -3
- package/src/contact/ContactStore.ts +35 -35
- package/src/digitalCredential/DigitalCredentialStore.ts +6 -7
- package/src/entities/contact/BaseConfigEntity.ts +2 -2
- package/src/entities/contact/BaseContactEntity.ts +4 -5
- package/src/entities/contact/ConnectionEntity.ts +4 -4
- package/src/entities/contact/ContactMetadataItemEntity.ts +3 -4
- package/src/entities/contact/CorrelationIdentifierEntity.ts +3 -4
- package/src/entities/contact/DidAuthConfigEntity.ts +1 -2
- package/src/entities/contact/ElectronicAddressEntity.ts +15 -5
- package/src/entities/contact/IdentityEntity.ts +12 -11
- package/src/entities/contact/IdentityMetadataItemEntity.ts +3 -3
- package/src/entities/contact/NaturalPersonEntity.ts +5 -5
- package/src/entities/contact/OrganizationEntity.ts +1 -1
- package/src/entities/contact/PartyEntity.ts +7 -7
- package/src/entities/contact/PartyRelationshipEntity.ts +8 -8
- package/src/entities/contact/PartyTypeEntity.ts +4 -4
- package/src/entities/contact/PhysicalAddressEntity.ts +3 -3
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +4 -3
- package/src/entities/eventLogger/AuditEventEntity.ts +2 -2
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +2 -2
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +6 -7
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/CredentialClaimsEntity.ts +2 -2
- package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +2 -2
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +2 -2
- package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +3 -3
- package/src/entities/issuanceBranding/TextAttributesEntity.ts +1 -1
- package/src/entities/machineState/MachineStateInfoEntity.ts +1 -1
- package/src/entities/presentationDefinition/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +10 -14
- package/src/entities/statusList/BitstringStatusListEntryEntity.ts +1 -1
- package/src/entities/statusList/StatusListEntities.ts +3 -4
- package/src/eventLogger/EventLoggerStore.ts +2 -2
- package/src/index.ts +21 -26
- package/src/issuanceBranding/IssuanceBrandingStore.ts +25 -25
- package/src/machineState/MachineStateStore.ts +7 -7
- package/src/migrations/generic/1-CreateContacts.ts +1 -1
- package/src/migrations/generic/10-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/generic/11-FixCredentialClaimsReferenceUuid.ts +2 -2
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
- package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +1 -1
- package/src/migrations/generic/3-CreateContacts.ts +2 -2
- package/src/migrations/generic/4-CreateStatusList.ts +1 -1
- package/src/migrations/generic/5-CreateAuditEvents.ts +2 -2
- package/src/migrations/generic/6-CreateDigitalCredential.ts +1 -1
- package/src/migrations/generic/7-CreateMachineStateStore.ts +1 -1
- package/src/migrations/generic/8-CreateContacts.ts +1 -1
- package/src/migrations/generic/9-CreateContacts.ts +1 -1
- package/src/migrations/generic/index.ts +10 -5
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +1 -1
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +1 -1
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +1 -1
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +25 -0
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +14 -2
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
- package/src/presentationDefinition/PDStore.ts +45 -45
- package/src/statusList/IStatusListStore.ts +1 -1
- package/src/statusList/StatusListStore.ts +3 -3
- package/src/types/index.ts +0 -12
- package/src/types/statusList/IAbstractStatusListStore.ts +9 -9
- package/src/utils/ValidatorUtils.ts +1 -1
- package/src/utils/contact/MappingUtils.ts +10 -10
- package/src/utils/digitalCredential/MappingUtils.ts +3 -21
- package/src/utils/eventLogger/MappingUtils.ts +2 -2
- package/src/utils/issuanceBranding/MappingUtils.ts +13 -13
- package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
- package/src/utils/statusList/MappingUtils.ts +1 -1
- package/src/contact/AbstractContactStore.ts +0 -71
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +0 -21
- package/src/eventLogger/AbstractEventLoggerStore.ts +0 -9
- package/src/issuanceBranding/AbstractIssuanceBrandingStore.ts +0 -41
- package/src/machineState/IAbstractMachineStateStore.ts +0 -65
- package/src/presentationDefinition/AbstractPDStore.ts +0 -20
- package/src/types/contact/IAbstractContactStore.ts +0 -161
- package/src/types/contact/contact.ts +0 -295
- package/src/types/contact/index.ts +0 -2
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +0 -43
- package/src/types/digitalCredential/enums.ts +0 -70
- package/src/types/digitalCredential/index.ts +0 -3
- package/src/types/digitalCredential/types.ts +0 -39
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +0 -22
- package/src/types/eventLogger/eventLogger.ts +0 -4
- package/src/types/issuanceBranding/IAbstractIssuanceBrandingStore.ts +0 -85
- package/src/types/issuanceBranding/issuanceBranding.ts +0 -138
- package/src/types/machineState/IAbstractMachineStateStore.ts +0 -68
- package/src/types/presentationDefinition/IAbstractPDStore.ts +0 -25
- package/src/types/presentationDefinition/presentationDefinition.ts +0 -19
- package/src/types/validation/validation.ts +0 -3
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { DcqlQuery } from 'dcql'
|
|
2
3
|
import { DataSource } from 'typeorm'
|
|
3
|
-
import { DataStorePresentationDefinitionEntities, DataStorePresentationDefinitionMigrations, PDStore } from '../index'
|
|
4
|
-
import { GetDefinitionsArgs, NonPersistedPresentationDefinitionItem, PresentationDefinitionItem } from '../types'
|
|
5
4
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import {
|
|
6
|
+
DataStorePresentationDefinitionEntities,
|
|
7
|
+
DataStorePresentationDefinitionMigrations,
|
|
8
|
+
type DeleteDefinitionsArgs,
|
|
9
|
+
ImportDcqlQueryItem,
|
|
10
|
+
PDStore,
|
|
11
|
+
} from '../index'
|
|
12
|
+
import { DcqlQueryItem, GetDefinitionsArgs, NonPersistedDcqlQueryItem } from '@sphereon/ssi-sdk.data-store-types'
|
|
13
|
+
|
|
14
|
+
export const SAMPLE_DCQL_QUERY_IMPORT: ImportDcqlQueryItem = {
|
|
15
|
+
queryId: 'ajax-club',
|
|
16
|
+
query: {
|
|
17
|
+
credentials: [
|
|
18
|
+
{
|
|
19
|
+
id: 'clubcard-v1',
|
|
20
|
+
format: 'dc+sd-jwt',
|
|
21
|
+
require_cryptographic_holder_binding: true,
|
|
22
|
+
multiple: false,
|
|
23
|
+
meta: {
|
|
24
|
+
vct_values: ['clubcard-v1'],
|
|
25
|
+
},
|
|
26
|
+
claims: [
|
|
27
|
+
{
|
|
28
|
+
path: ['personData', 'name'],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
path: ['personData', 'birthDate'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
path: ['membershipData', 'membershipId'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: ['membershipData', 'season'],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
}
|
|
6
44
|
|
|
7
45
|
describe('PDStore tests', (): void => {
|
|
8
46
|
let dbConnection: DataSource
|
|
@@ -28,136 +66,148 @@ describe('PDStore tests', (): void => {
|
|
|
28
66
|
await dbConnection.destroy()
|
|
29
67
|
})
|
|
30
68
|
|
|
31
|
-
it('should
|
|
32
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
33
|
-
definitionId: 'definition1',
|
|
34
|
-
version: '1.0',
|
|
35
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
36
|
-
}
|
|
37
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
38
|
-
expect(savedDefinition).toBeDefined()
|
|
39
|
-
|
|
40
|
-
const exists: boolean = await pdStore.hasDefinition({ itemId: savedDefinition.id })
|
|
41
|
-
|
|
42
|
-
expect(exists).toBeTruthy()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('should check if definitions exist by filter', async (): Promise<void> => {
|
|
46
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
47
|
-
definitionId: 'definition1',
|
|
48
|
-
version: '1.0',
|
|
49
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
50
|
-
}
|
|
51
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
52
|
-
expect(savedDefinition).toBeDefined()
|
|
53
|
-
|
|
54
|
-
const exists: boolean = await pdStore.hasDefinitions({ filter: [{ definitionId: 'definition1' }] })
|
|
55
|
-
|
|
56
|
-
expect(exists).toBeTruthy()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should get definition by id', async (): Promise<void> => {
|
|
60
|
-
const definition: NonPersistedPresentationDefinitionItem = {
|
|
61
|
-
definitionId: 'definition1',
|
|
62
|
-
version: '1.0',
|
|
63
|
-
definitionPayload: { id: 'definition1', input_descriptors: [] },
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const savedDefinition: PresentationDefinitionItem = await pdStore.addDefinition(definition)
|
|
67
|
-
expect(savedDefinition).toBeDefined()
|
|
68
|
-
|
|
69
|
-
const result: PresentationDefinitionItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
70
|
-
|
|
71
|
-
expect(result).toBeDefined()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should throw error when getting definition with unknown id', async (): Promise<void> => {
|
|
69
|
+
it('should throw error when getting query with unknown id', async (): Promise<void> => {
|
|
75
70
|
const itemId = 'unknownDefinitionId'
|
|
76
71
|
|
|
77
72
|
await expect(pdStore.getDefinition({ itemId })).rejects.toThrow(`No presentation definition item found for id: ${itemId}`)
|
|
78
73
|
})
|
|
79
74
|
|
|
80
|
-
it('should get all
|
|
81
|
-
const definition1:
|
|
82
|
-
|
|
75
|
+
it('should get all queries', async (): Promise<void> => {
|
|
76
|
+
const definition1: NonPersistedDcqlQueryItem = {
|
|
77
|
+
queryId: 'definition1',
|
|
83
78
|
version: '1.0',
|
|
84
|
-
|
|
79
|
+
query: {
|
|
80
|
+
credentials: [
|
|
81
|
+
{
|
|
82
|
+
id: 'id-card-v1',
|
|
83
|
+
format: 'dc+sd-jwt',
|
|
84
|
+
require_cryptographic_holder_binding: true,
|
|
85
|
+
multiple: false,
|
|
86
|
+
claims: [
|
|
87
|
+
{
|
|
88
|
+
path: ['name'],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
85
94
|
}
|
|
86
|
-
const savedDefinition1:
|
|
95
|
+
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
87
96
|
expect(savedDefinition1).toBeDefined()
|
|
88
97
|
|
|
89
|
-
const definition2:
|
|
90
|
-
|
|
98
|
+
const definition2: NonPersistedDcqlQueryItem = {
|
|
99
|
+
queryId: 'definition2',
|
|
91
100
|
version: '1.0',
|
|
92
|
-
|
|
101
|
+
query: {
|
|
102
|
+
credentials: [
|
|
103
|
+
{
|
|
104
|
+
id: 'driver-license-v1',
|
|
105
|
+
format: 'dc+sd-jwt',
|
|
106
|
+
require_cryptographic_holder_binding: true,
|
|
107
|
+
multiple: false,
|
|
108
|
+
claims: [
|
|
109
|
+
{
|
|
110
|
+
path: ['dateOfBirth'],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
93
116
|
}
|
|
94
|
-
const savedDefinition2:
|
|
117
|
+
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
95
118
|
expect(savedDefinition2).toBeDefined()
|
|
96
119
|
|
|
97
|
-
const result: Array<
|
|
120
|
+
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions({})
|
|
98
121
|
|
|
99
122
|
expect(result).toBeDefined()
|
|
100
123
|
expect(result.length).toEqual(2)
|
|
101
124
|
})
|
|
102
125
|
|
|
103
|
-
it('should
|
|
104
|
-
const definition:
|
|
105
|
-
|
|
126
|
+
it('should update dcql query', async (): Promise<void> => {
|
|
127
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
128
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
106
129
|
version: '1.0',
|
|
107
|
-
|
|
130
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
108
131
|
}
|
|
109
|
-
const savedDefinition:
|
|
132
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
110
133
|
expect(savedDefinition).toBeDefined()
|
|
111
134
|
|
|
112
|
-
const
|
|
113
|
-
|
|
135
|
+
const updatedDcqlQuery = DcqlQuery.parse({
|
|
136
|
+
credentials: [
|
|
137
|
+
{
|
|
138
|
+
id: 'updated-clubcard',
|
|
139
|
+
format: 'dc+sd-jwt',
|
|
140
|
+
claims: [
|
|
141
|
+
{
|
|
142
|
+
path: ['name'],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const updatedDefinition: DcqlQueryItem = {
|
|
150
|
+
...savedDefinition,
|
|
151
|
+
version: '1.1',
|
|
152
|
+
query: updatedDcqlQuery,
|
|
114
153
|
}
|
|
115
|
-
const result: Array<PresentationDefinitionItem> = await pdStore.getDefinitions(args)
|
|
116
154
|
|
|
117
|
-
|
|
155
|
+
await pdStore.updateDefinition(updatedDefinition)
|
|
156
|
+
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
157
|
+
|
|
158
|
+
expect(result).toBeDefined()
|
|
159
|
+
expect(result.version).toEqual('1.1')
|
|
160
|
+
expect(result.query?.credentials[0].id).toEqual('updated-clubcard')
|
|
161
|
+
expect(result.query?.credentials[0].format).toEqual('dc+sd-jwt')
|
|
118
162
|
})
|
|
119
163
|
|
|
120
|
-
it('should
|
|
121
|
-
const definition:
|
|
122
|
-
|
|
164
|
+
it('should get dcql queries by id', async (): Promise<void> => {
|
|
165
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
166
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
123
167
|
version: '1.0',
|
|
124
|
-
|
|
168
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
125
169
|
}
|
|
126
170
|
|
|
127
|
-
const
|
|
171
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
172
|
+
expect(savedDefinition).toBeDefined()
|
|
173
|
+
|
|
174
|
+
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
128
175
|
|
|
129
176
|
expect(result).toBeDefined()
|
|
130
|
-
expect(result.
|
|
177
|
+
expect(result.query).toBeDefined()
|
|
178
|
+
expect(result.query.credentials[0].format).toBe('dc+sd-jwt')
|
|
179
|
+
if (result.query.credentials[0].format === 'dc+sd-jwt') {
|
|
180
|
+
expect(result.query.credentials[0].meta?.vct_values).toContain('clubcard-v1')
|
|
181
|
+
}
|
|
182
|
+
expect(result.query.credentials[0].claims).toHaveLength(4)
|
|
131
183
|
})
|
|
132
184
|
|
|
133
|
-
it('should
|
|
134
|
-
const definition:
|
|
135
|
-
|
|
185
|
+
it('should get dcql queries by filter', async (): Promise<void> => {
|
|
186
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
187
|
+
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
136
188
|
version: '1.0',
|
|
137
|
-
|
|
189
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
138
190
|
}
|
|
139
|
-
const savedDefinition:
|
|
191
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
140
192
|
expect(savedDefinition).toBeDefined()
|
|
141
193
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
version: '1.1',
|
|
194
|
+
const args: GetDefinitionsArgs = {
|
|
195
|
+
filter: [{ queryId: 'ajax-club' }],
|
|
145
196
|
}
|
|
197
|
+
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions(args)
|
|
146
198
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
expect(result).toBeDefined()
|
|
151
|
-
expect(result.version).toEqual('1.1')
|
|
199
|
+
expect(result.length).toEqual(1)
|
|
200
|
+
expect(result[0].query).toBeDefined()
|
|
201
|
+
expect(result[0].query.credentials[0].id).toEqual('clubcard-v1')
|
|
152
202
|
})
|
|
153
203
|
|
|
154
|
-
it('should delete
|
|
155
|
-
const definition:
|
|
156
|
-
|
|
204
|
+
it('should delete dcql query', async (): Promise<void> => {
|
|
205
|
+
const definition: NonPersistedDcqlQueryItem = {
|
|
206
|
+
queryId: 'definition1',
|
|
157
207
|
version: '1.0',
|
|
158
|
-
|
|
208
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
159
209
|
}
|
|
160
|
-
const savedDefinition:
|
|
210
|
+
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
161
211
|
expect(savedDefinition).toBeDefined()
|
|
162
212
|
|
|
163
213
|
await pdStore.deleteDefinition({ itemId: savedDefinition.id })
|
|
@@ -167,28 +217,28 @@ describe('PDStore tests', (): void => {
|
|
|
167
217
|
)
|
|
168
218
|
})
|
|
169
219
|
|
|
170
|
-
it('should delete
|
|
171
|
-
const definition1:
|
|
172
|
-
|
|
220
|
+
it('should delete dcql queries by filter', async (): Promise<void> => {
|
|
221
|
+
const definition1: NonPersistedDcqlQueryItem = {
|
|
222
|
+
queryId: 'definition1',
|
|
173
223
|
version: '1.0',
|
|
174
|
-
|
|
224
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
175
225
|
}
|
|
176
|
-
const savedDefinition1:
|
|
226
|
+
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
177
227
|
expect(savedDefinition1).toBeDefined()
|
|
178
228
|
|
|
179
|
-
const definition2:
|
|
180
|
-
|
|
229
|
+
const definition2: NonPersistedDcqlQueryItem = {
|
|
230
|
+
queryId: 'definition2',
|
|
181
231
|
version: '1.0',
|
|
182
|
-
|
|
232
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
183
233
|
}
|
|
184
|
-
const savedDefinition2:
|
|
234
|
+
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
185
235
|
expect(savedDefinition2).toBeDefined()
|
|
186
236
|
|
|
187
|
-
const filter = { filter: [{
|
|
237
|
+
const filter = { filter: [{ queryId: 'definition1' }] } satisfies DeleteDefinitionsArgs
|
|
188
238
|
await pdStore.deleteDefinitions(filter)
|
|
189
239
|
|
|
190
|
-
const remainingDefinitions: Array<
|
|
240
|
+
const remainingDefinitions: Array<DcqlQueryItem> = await pdStore.getDefinitions({})
|
|
191
241
|
expect(remainingDefinitions.length).toEqual(1)
|
|
192
|
-
expect(remainingDefinitions[0].
|
|
242
|
+
expect(remainingDefinitions[0].queryId).toEqual('definition2')
|
|
193
243
|
})
|
|
194
244
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
3
|
-
import { BitstringStatusListEntity, BitstringStatusListEntryEntity, DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
4
|
-
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
|
-
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
2
|
import { IIssuer, StatusListCredentialIdMode, StatusListDriverType } from '@sphereon/ssi-types'
|
|
3
|
+
import { DataSource } from 'typeorm'
|
|
7
4
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import { OAuthStatusListEntity, StatusList2021Entity } from '../entities/statusList/StatusListEntities'
|
|
6
|
+
import { BitstringStatusListEntity, BitstringStatusListEntryEntity, DataStoreStatusListEntities, StatusListEntryEntity } from '../index'
|
|
7
|
+
import { DataStoreStatusListMigrations } from '../migrations'
|
|
8
8
|
|
|
9
9
|
describe('Status list entities tests', () => {
|
|
10
10
|
let dbConnection: DataSource
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm'
|
|
2
1
|
import { DataSources } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
3
|
+
import { DataSource } from 'typeorm'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
3
5
|
import { DataStoreStatusListEntities, IBitstringStatusListEntity } from '../index'
|
|
4
6
|
import { DataStoreStatusListMigrations } from '../migrations'
|
|
5
7
|
import { StatusListStore } from '../statusList/StatusListStore'
|
|
6
8
|
import { IOAuthStatusListEntity, IStatusList2021Entity, IStatusListEntryEntity } from '../types'
|
|
7
|
-
import { StatusListCredentialIdMode, StatusListDriverType, StatusListType } from '@sphereon/ssi-types'
|
|
8
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
9
9
|
|
|
10
10
|
describe('Status list store tests', () => {
|
|
11
11
|
let dbConnection: DataSource
|
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
import { OrPromise } from '@sphereon/ssi-types'
|
|
2
|
-
import { BaseEntity, DataSource, type FindOptionsWhere, In, type Repository } from 'typeorm'
|
|
3
|
-
import Debug from 'debug'
|
|
4
|
-
import { AbstractContactStore } from './AbstractContactStore'
|
|
5
|
-
import { PartyEntity } from '../entities/contact/PartyEntity'
|
|
6
|
-
import { IdentityEntity } from '../entities/contact/IdentityEntity'
|
|
7
|
-
import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
|
|
8
|
-
import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
|
|
9
|
-
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
10
|
-
import { BaseConfigEntity } from '../entities/contact/BaseConfigEntity'
|
|
11
|
-
import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
|
|
12
|
-
import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
|
|
13
|
-
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
14
|
-
import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
|
|
15
|
-
import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
|
|
16
|
-
import {
|
|
17
|
-
electronicAddressEntityFrom,
|
|
18
|
-
electronicAddressFrom,
|
|
19
|
-
identityEntityFrom,
|
|
20
|
-
identityFrom,
|
|
21
|
-
isDidAuthConfig,
|
|
22
|
-
isNaturalPerson,
|
|
23
|
-
isOpenIdConfig,
|
|
24
|
-
isOrganization,
|
|
25
|
-
partyEntityFrom,
|
|
26
|
-
partyFrom,
|
|
27
|
-
partyRelationshipEntityFrom,
|
|
28
|
-
partyRelationshipFrom,
|
|
29
|
-
partyTypeEntityFrom,
|
|
30
|
-
partyTypeFrom,
|
|
31
|
-
physicalAddressEntityFrom,
|
|
32
|
-
physicalAddressFrom,
|
|
33
|
-
} from '../utils/contact/MappingUtils'
|
|
34
1
|
import {
|
|
2
|
+
AbstractContactStore,
|
|
35
3
|
AddElectronicAddressArgs,
|
|
36
4
|
AddIdentityArgs,
|
|
37
5
|
AddPartyArgs,
|
|
@@ -53,8 +21,8 @@ import {
|
|
|
53
21
|
GetPhysicalAddressesArgs,
|
|
54
22
|
GetRelationshipArgs,
|
|
55
23
|
GetRelationshipsArgs,
|
|
56
|
-
IMetadataEntity,
|
|
57
24
|
Identity,
|
|
25
|
+
IMetadataEntity,
|
|
58
26
|
MetadataItem,
|
|
59
27
|
MetadataTypes,
|
|
60
28
|
NonPersistedConnectionConfig,
|
|
@@ -76,7 +44,39 @@ import {
|
|
|
76
44
|
UpdatePartyTypeArgs,
|
|
77
45
|
UpdatePhysicalAddressArgs,
|
|
78
46
|
UpdateRelationshipArgs,
|
|
79
|
-
} from '
|
|
47
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
48
|
+
import { OrPromise } from '@sphereon/ssi-types'
|
|
49
|
+
import Debug from 'debug'
|
|
50
|
+
import { BaseEntity, DataSource, type FindOptionsWhere, In, type Repository } from 'typeorm'
|
|
51
|
+
import { BaseConfigEntity } from '../entities/contact/BaseConfigEntity'
|
|
52
|
+
import { BaseContactEntity } from '../entities/contact/BaseContactEntity'
|
|
53
|
+
import { ConnectionEntity } from '../entities/contact/ConnectionEntity'
|
|
54
|
+
import { CorrelationIdentifierEntity } from '../entities/contact/CorrelationIdentifierEntity'
|
|
55
|
+
import { ElectronicAddressEntity } from '../entities/contact/ElectronicAddressEntity'
|
|
56
|
+
import { IdentityEntity } from '../entities/contact/IdentityEntity'
|
|
57
|
+
import { IdentityMetadataItemEntity } from '../entities/contact/IdentityMetadataItemEntity'
|
|
58
|
+
import { PartyEntity } from '../entities/contact/PartyEntity'
|
|
59
|
+
import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
|
|
60
|
+
import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
|
|
61
|
+
import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
|
|
62
|
+
import {
|
|
63
|
+
electronicAddressEntityFrom,
|
|
64
|
+
electronicAddressFrom,
|
|
65
|
+
identityEntityFrom,
|
|
66
|
+
identityFrom,
|
|
67
|
+
isDidAuthConfig,
|
|
68
|
+
isNaturalPerson,
|
|
69
|
+
isOpenIdConfig,
|
|
70
|
+
isOrganization,
|
|
71
|
+
partyEntityFrom,
|
|
72
|
+
partyFrom,
|
|
73
|
+
partyRelationshipEntityFrom,
|
|
74
|
+
partyRelationshipFrom,
|
|
75
|
+
partyTypeEntityFrom,
|
|
76
|
+
partyTypeFrom,
|
|
77
|
+
physicalAddressEntityFrom,
|
|
78
|
+
physicalAddressFrom,
|
|
79
|
+
} from '../utils/contact/MappingUtils'
|
|
80
80
|
|
|
81
81
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:contact-store')
|
|
82
82
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AbstractDigitalCredentialStore } from './AbstractDigitalCredentialStore'
|
|
2
1
|
import {
|
|
2
|
+
AbstractDigitalCredentialStore,
|
|
3
3
|
AddCredentialArgs,
|
|
4
|
-
CredentialRole,
|
|
5
4
|
CredentialStateType,
|
|
6
5
|
DigitalCredential,
|
|
7
6
|
GetCredentialArgs,
|
|
@@ -10,13 +9,13 @@ import {
|
|
|
10
9
|
NonPersistedDigitalCredential,
|
|
11
10
|
RemoveCredentialArgs,
|
|
12
11
|
UpdateCredentialStateArgs,
|
|
13
|
-
} from '
|
|
14
|
-
import { OrPromise } from '@sphereon/ssi-types'
|
|
15
|
-
import { DataSource, type FindOptionsOrder, type FindOptionsWhere, Repository } from 'typeorm'
|
|
12
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
13
|
+
import { CredentialRole, OrPromise } from '@sphereon/ssi-types'
|
|
16
14
|
import Debug from 'debug'
|
|
17
|
-
import {
|
|
15
|
+
import { DataSource, type FindOptionsOrder, type FindOptionsWhere, Repository } from 'typeorm'
|
|
18
16
|
|
|
19
17
|
import { digitalCredentialFrom, digitalCredentialsFrom, nonPersistedDigitalCredentialEntityFromAddArgs } from '../../src'
|
|
18
|
+
import { DigitalCredentialEntity } from '../entities/digitalCredential/DigitalCredentialEntity'
|
|
20
19
|
import { parseAndValidateOrderOptions } from '../utils/SortingUtils'
|
|
21
20
|
|
|
22
21
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:credential-store')
|
|
@@ -78,7 +77,7 @@ export class DigitalCredentialStore extends AbstractDigitalCredentialStore {
|
|
|
78
77
|
return false
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
const query: FindOptionsWhere<DigitalCredentialEntity> = {}
|
|
82
81
|
|
|
83
82
|
if ('id' in args) {
|
|
84
83
|
query.id = args.id
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { BaseEntity, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, TableInheritance } from 'typeorm'
|
|
2
|
+
|
|
3
3
|
import { ConnectionEntity } from './ConnectionEntity'
|
|
4
4
|
|
|
5
5
|
@Entity('BaseConfig')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import {
|
|
3
3
|
BaseEntity,
|
|
4
4
|
BeforeInsert,
|
|
5
5
|
BeforeUpdate,
|
|
@@ -11,10 +11,9 @@ const {
|
|
|
11
11
|
PrimaryGeneratedColumn,
|
|
12
12
|
TableInheritance,
|
|
13
13
|
UpdateDateColumn,
|
|
14
|
-
}
|
|
15
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
16
|
-
import { PartyEntity } from './PartyEntity'
|
|
14
|
+
} from 'typeorm'
|
|
17
15
|
import { ContactMetadataItemEntity } from './ContactMetadataItemEntity'
|
|
16
|
+
import { PartyEntity } from './PartyEntity'
|
|
18
17
|
|
|
19
18
|
@Entity('BaseContact')
|
|
20
19
|
@TableInheritance({ column: { type: 'varchar', name: 'type' } })
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ConnectionType } from '@sphereon/ssi-sdk.data-store-types'
|
|
2
|
+
import { BaseEntity, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
3
|
+
|
|
3
4
|
import { BaseConfigEntity } from './BaseConfigEntity'
|
|
4
|
-
import {
|
|
5
|
+
import { DidAuthConfigEntity } from './DidAuthConfigEntity'
|
|
5
6
|
import { IdentityEntity } from './IdentityEntity'
|
|
6
7
|
import { OpenIdConfigEntity } from './OpenIdConfigEntity'
|
|
7
|
-
import { DidAuthConfigEntity } from './DidAuthConfigEntity'
|
|
8
8
|
|
|
9
9
|
@Entity('Connection')
|
|
10
10
|
export class ConnectionEntity extends BaseEntity {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import typeorm from 'typeorm'
|
|
2
|
-
const { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } = typeorm
|
|
3
|
-
import { IMetadataEntity, ValidationConstraint } from '../../types'
|
|
4
1
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import {
|
|
2
|
+
import { IMetadataEntity, ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
6
3
|
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
4
|
+
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
7
5
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
6
|
+
import { BaseContactEntity } from './BaseContactEntity'
|
|
8
7
|
|
|
9
8
|
@Entity('ContactMetadata')
|
|
10
9
|
export class ContactMetadataItemEntity extends BaseEntity implements IMetadataEntity {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } = typeorm
|
|
3
|
-
import { CorrelationIdentifierType, ValidationConstraint } from '../../types'
|
|
4
|
-
import { IdentityEntity } from './IdentityEntity'
|
|
1
|
+
import { CorrelationIdentifierType, ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
5
2
|
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
3
|
+
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
6
4
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
5
|
+
import { IdentityEntity } from './IdentityEntity'
|
|
7
6
|
|
|
8
7
|
@Entity('CorrelationIdentifier')
|
|
9
8
|
export class CorrelationIdentifierEntity extends BaseEntity {
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
2
|
-
import typeorm from 'typeorm'
|
|
3
|
-
const { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate, CreateDateColumn, UpdateDateColumn } = typeorm
|
|
4
1
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import type { ElectronicAddressType, ValidationConstraint } from '
|
|
6
|
-
import {
|
|
2
|
+
import type { ElectronicAddressType, ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
3
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
BaseEntity,
|
|
7
|
+
BeforeInsert,
|
|
8
|
+
BeforeUpdate,
|
|
9
|
+
Column,
|
|
10
|
+
CreateDateColumn,
|
|
11
|
+
Entity,
|
|
12
|
+
ManyToOne,
|
|
13
|
+
PrimaryGeneratedColumn,
|
|
14
|
+
UpdateDateColumn,
|
|
15
|
+
} from 'typeorm'
|
|
7
16
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
17
|
+
import { PartyEntity } from './PartyEntity'
|
|
8
18
|
|
|
9
19
|
@Entity('ElectronicAddress')
|
|
10
20
|
export class ElectronicAddressEntity extends BaseEntity {
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
+
import { IdentityOrigin, ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
3
|
+
import { CredentialRole } from '@sphereon/ssi-types'
|
|
4
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
1
5
|
import {
|
|
2
6
|
BaseEntity,
|
|
7
|
+
BeforeInsert,
|
|
8
|
+
BeforeUpdate,
|
|
9
|
+
Column,
|
|
3
10
|
CreateDateColumn,
|
|
4
11
|
Entity,
|
|
5
|
-
PrimaryGeneratedColumn,
|
|
6
|
-
UpdateDateColumn,
|
|
7
|
-
OneToOne,
|
|
8
12
|
JoinColumn,
|
|
9
13
|
ManyToOne,
|
|
10
|
-
Column,
|
|
11
14
|
OneToMany,
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
OneToOne,
|
|
16
|
+
PrimaryGeneratedColumn,
|
|
17
|
+
UpdateDateColumn,
|
|
14
18
|
} from 'typeorm'
|
|
15
|
-
import {
|
|
16
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
17
|
-
import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
19
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
18
20
|
import { ConnectionEntity } from './ConnectionEntity'
|
|
21
|
+
import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
19
22
|
import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
|
|
20
|
-
import { CredentialRole, IdentityOrigin, ValidationConstraint } from '../../types'
|
|
21
23
|
import { PartyEntity } from './PartyEntity'
|
|
22
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
23
24
|
|
|
24
25
|
@Entity('Identity')
|
|
25
26
|
export class IdentityEntity extends BaseEntity {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
2
|
-
import {
|
|
3
|
-
import { IMetadataEntity, ValidationConstraint } from '../../types'
|
|
4
|
-
import { IdentityEntity } from './IdentityEntity'
|
|
2
|
+
import { IMetadataEntity, ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
5
3
|
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
4
|
+
import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
|
|
6
5
|
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
6
|
+
import { IdentityEntity } from './IdentityEntity'
|
|
7
7
|
|
|
8
8
|
@Entity('IdentityMetadata')
|
|
9
9
|
export class IdentityMetadataItemEntity extends BaseEntity implements IMetadataEntity {
|