@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189
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 +1616 -1477
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -194
- package/dist/index.d.ts +187 -194
- package/dist/index.js +1582 -1443
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2 -2
- package/src/__tests__/contact.store.test.ts +1 -1
- package/src/__tests__/digitalCredential.entities.test.ts +2 -1
- package/src/__tests__/digitalCredential.store.test.ts +5 -5
- package/src/__tests__/pd-manager.entities.test.ts +27 -98
- package/src/__tests__/pd-manager.store.test.ts +151 -101
- package/src/digitalCredential/DigitalCredentialStore.ts +9 -9
- package/src/entities/contact/IdentityEntity.ts +2 -1
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +2 -1
- package/src/entities/presentationDefinition/{PresentationDefinitionItemEntity.ts → DcqlQueryItemEntity.ts} +8 -12
- package/src/index.ts +3 -3
- package/src/migrations/generic/12-CreateBitstringStatusList.ts +32 -2
- package/src/migrations/generic/13-CreateDcqlQueryItem.ts +67 -0
- package/src/migrations/generic/index.ts +10 -5
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +25 -0
- package/src/migrations/postgres/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +15 -2
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
- package/src/presentationDefinition/AbstractPDStore.ts +5 -5
- package/src/presentationDefinition/PDStore.ts +40 -40
- package/src/types/contact/contact.ts +1 -1
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +2 -1
- package/src/types/digitalCredential/enums.ts +0 -7
- package/src/types/digitalCredential/types.ts +2 -1
- package/src/types/presentationDefinition/IAbstractPDStore.ts +5 -5
- package/src/types/presentationDefinition/presentationDefinition.ts +8 -9
- package/src/utils/presentationDefinition/MappingUtils.ts +31 -22
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DcqlQueryREST } from '@sphereon/ssi-types'
|
|
1
|
+
import { DcqlQuery } from 'dcql'
|
|
3
2
|
|
|
4
|
-
export type
|
|
3
|
+
export type DcqlQueryItem = {
|
|
5
4
|
id: string
|
|
6
|
-
|
|
5
|
+
queryId: string
|
|
7
6
|
tenantId?: string
|
|
8
7
|
version: string
|
|
9
8
|
name?: string
|
|
10
9
|
purpose?: string
|
|
11
|
-
|
|
12
|
-
dcqlPayload?: DcqlQueryREST
|
|
10
|
+
query: DcqlQuery
|
|
13
11
|
createdAt: Date
|
|
14
12
|
lastUpdatedAt: Date
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
export type
|
|
15
|
+
export type ImportDcqlQueryItem = Omit<DcqlQueryItem, 'id' | 'tenantId' | 'version' | 'createdAt' | 'lastUpdatedAt'>
|
|
16
|
+
export type NonPersistedDcqlQueryItem = Omit<DcqlQueryItem, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
17
|
+
export type PartialDcqlQueryItem = Partial<DcqlQueryItem>
|
|
18
|
+
export type DcqlQueryItemFilter = Partial<Omit<DcqlQueryItem, 'query'>>
|
|
@@ -1,58 +1,67 @@
|
|
|
1
|
-
import { PresentationDefinitionItemEntity } from '../../entities/presentationDefinition/PresentationDefinitionItemEntity'
|
|
2
1
|
import type { IPresentationDefinition } from '@sphereon/pex'
|
|
3
|
-
import type { NonPersistedPresentationDefinitionItem, PartialPresentationDefinitionItem, PresentationDefinitionItem } from '../../types'
|
|
4
2
|
import * as blakepkg from 'blakejs'
|
|
3
|
+
import { DcqlQuery } from 'dcql'
|
|
4
|
+
import { DcqlQueryItemEntity } from '../../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
5
|
+
import type { NonPersistedDcqlQueryItem, PartialDcqlQueryItem, DcqlQueryItem } from '../../types'
|
|
5
6
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
6
|
-
import type { DcqlQueryREST } from '@sphereon/ssi-types'
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
const result:
|
|
8
|
+
export const dcqlQueryItemFrom = (entity: DcqlQueryItemEntity): DcqlQueryItem => {
|
|
9
|
+
const result: DcqlQueryItem = {
|
|
10
10
|
id: entity.id,
|
|
11
11
|
tenantId: entity.tenantId,
|
|
12
|
-
|
|
12
|
+
queryId: entity.queryId,
|
|
13
13
|
version: entity.version,
|
|
14
14
|
name: entity.name,
|
|
15
15
|
purpose: entity.purpose,
|
|
16
|
-
|
|
17
|
-
dcqlPayload: JSON.parse(entity.dcqlPayload) as DcqlQueryREST,
|
|
16
|
+
query: DcqlQuery.parse(JSON.parse(entity.query)),
|
|
18
17
|
createdAt: entity.createdAt,
|
|
19
18
|
lastUpdatedAt: entity.lastUpdatedAt,
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
if (result.query) {
|
|
22
|
+
DcqlQuery.validate(result.query)
|
|
23
|
+
}
|
|
22
24
|
return replaceNullWithUndefined(result)
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export const
|
|
26
|
-
const entity = new
|
|
27
|
+
export const dcqlQueryEntityItemFrom = (item: NonPersistedDcqlQueryItem): DcqlQueryItemEntity => {
|
|
28
|
+
const entity = new DcqlQueryItemEntity()
|
|
27
29
|
|
|
28
30
|
entity.tenantId = item.tenantId
|
|
29
|
-
entity.
|
|
31
|
+
entity.queryId = item.queryId!
|
|
30
32
|
entity.version = item.version
|
|
31
33
|
entity.name = item.name
|
|
32
34
|
entity.purpose = item.purpose
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
if (item.query) {
|
|
36
|
+
const dcqlQuery = DcqlQuery.parse(item.query)
|
|
37
|
+
DcqlQuery.validate(dcqlQuery)
|
|
38
|
+
entity.query = JSON.stringify(item.query)
|
|
39
|
+
}
|
|
35
40
|
return entity
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
function hashPayload(payload: IPresentationDefinition): string {
|
|
43
|
+
function hashPayload(payload: IPresentationDefinition | DcqlQuery): string {
|
|
39
44
|
return blakepkg.blake2bHex(JSON.stringify(payload))
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
export function isPresentationDefinitionEqual(base:
|
|
47
|
+
export function isPresentationDefinitionEqual(base: PartialDcqlQueryItem, compare: PartialDcqlQueryItem): boolean {
|
|
43
48
|
if (
|
|
44
|
-
base.
|
|
45
|
-
base.tenantId
|
|
49
|
+
base.queryId !== compare.queryId ||
|
|
50
|
+
base.tenantId !== compare.tenantId ||
|
|
46
51
|
base.version !== compare.version ||
|
|
47
|
-
base.name
|
|
48
|
-
base.purpose
|
|
52
|
+
base.name !== compare.name ||
|
|
53
|
+
base.purpose !== compare.purpose
|
|
49
54
|
) {
|
|
50
55
|
return false
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
if (base.
|
|
54
|
-
|
|
58
|
+
if (base.query && compare.query) {
|
|
59
|
+
if (hashPayload(base.query) !== hashPayload(compare.query)) {
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
} else if (base.query || compare.query) {
|
|
63
|
+
return false
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
return
|
|
66
|
+
return true
|
|
58
67
|
}
|