@sphereon/ssi-sdk.data-store 0.34.1-feature.SSISDK.57.uni.client.169 → 0.34.1-feature.SSISDK.57.uni.client.203
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 +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/pd-manager.entities.test.ts +11 -11
- package/src/__tests__/pd-manager.store.test.ts +74 -23
- package/src/entities/presentationDefinition/DcqlQueryItemEntity.ts +2 -2
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/postgres/1726588800000-CreateDcqlQueryItem.ts +1 -1
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +1 -1
- package/src/presentationDefinition/PDStore.ts +7 -7
- package/src/types/presentationDefinition/presentationDefinition.ts +2 -2
- package/src/utils/presentationDefinition/MappingUtils.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.data-store",
|
|
3
|
-
"version": "0.34.1-feature.SSISDK.57.uni.client.
|
|
3
|
+
"version": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
30
30
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
31
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.57.uni.client.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.57.uni.client.
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.57.uni.client.
|
|
34
|
-
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.57.uni.client.
|
|
35
|
-
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.57.uni.client.
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
34
|
+
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
35
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.57.uni.client.203+70e8e76c",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/utils": "4.2.0",
|
|
38
38
|
"blakejs": "^1.2.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"PostgreSQL",
|
|
66
66
|
"Contact Store"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "70e8e76c1e91a68a49f9251002a11ad861c9f72f"
|
|
69
69
|
}
|
|
@@ -6,7 +6,7 @@ import { DataStorePresentationDefinitionEntities } from '../index'
|
|
|
6
6
|
import { DataStorePresentationDefinitionMigrations } from '../migrations'
|
|
7
7
|
import { SAMPLE_DCQL_QUERY_IMPORT } from './pd-manager.store.test'
|
|
8
8
|
|
|
9
|
-
describe('
|
|
9
|
+
describe('DcqlQueryItemEntity tests', (): void => {
|
|
10
10
|
let dbConnection: DataSource
|
|
11
11
|
|
|
12
12
|
beforeEach(async (): Promise<void> => {
|
|
@@ -26,34 +26,34 @@ describe('PresentationDefinitionItemEntity tests', (): void => {
|
|
|
26
26
|
await dbConnection.destroy()
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
it('should create and retrieve
|
|
29
|
+
it('should create and retrieve DcqlQueryItemEntity', async (): Promise<void> => {
|
|
30
30
|
const repository = dbConnection.getRepository(DcqlQueryItemEntity)
|
|
31
31
|
const entity = new DcqlQueryItemEntity()
|
|
32
32
|
entity.queryId = 'ajax-club'
|
|
33
33
|
entity.version = '1.0'
|
|
34
|
-
entity.
|
|
34
|
+
entity.query = JSON.stringify(SAMPLE_DCQL_QUERY_IMPORT.query)
|
|
35
35
|
|
|
36
36
|
const savedEntity = await repository.save(entity)
|
|
37
37
|
expect(savedEntity).toBeDefined()
|
|
38
38
|
expect(savedEntity.id).toBeDefined()
|
|
39
|
-
expect(savedEntity.
|
|
39
|
+
expect(savedEntity.query).toBeDefined()
|
|
40
40
|
|
|
41
41
|
const retrievedEntity = await repository.findOneBy({ id: savedEntity.id })
|
|
42
42
|
expect(retrievedEntity).toBeDefined()
|
|
43
|
-
expect(retrievedEntity!.
|
|
44
|
-
const parsedDcql = JSON.parse(retrievedEntity!.
|
|
43
|
+
expect(retrievedEntity!.query).toBeDefined()
|
|
44
|
+
const parsedDcql = JSON.parse(retrievedEntity!.query)
|
|
45
45
|
expect(parsedDcql.credentials[0].id).toEqual('clubcard-v1')
|
|
46
46
|
expect(parsedDcql.credentials[0].format).toEqual('dc+sd-jwt')
|
|
47
47
|
expect(parsedDcql.credentials[0].meta.vct_values).toContain('clubcard-v1')
|
|
48
48
|
expect(parsedDcql.credentials[0].claims).toHaveLength(4)
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('should update
|
|
51
|
+
it('should update DcqlQueryItemEntity dcql query', async (): Promise<void> => {
|
|
52
52
|
const repository = dbConnection.getRepository(DcqlQueryItemEntity)
|
|
53
53
|
const entity = new DcqlQueryItemEntity()
|
|
54
54
|
entity.queryId = 'ajax-club'
|
|
55
55
|
entity.version = '1.0'
|
|
56
|
-
entity.
|
|
56
|
+
entity.query = JSON.stringify(SAMPLE_DCQL_QUERY_IMPORT.query)
|
|
57
57
|
|
|
58
58
|
const savedEntity = await repository.save(entity)
|
|
59
59
|
expect(savedEntity).toBeDefined()
|
|
@@ -71,10 +71,10 @@ describe('PresentationDefinitionItemEntity tests', (): void => {
|
|
|
71
71
|
},
|
|
72
72
|
],
|
|
73
73
|
}
|
|
74
|
-
savedEntity.
|
|
74
|
+
savedEntity.query = JSON.stringify(updatedDcql)
|
|
75
75
|
const updatedEntity = await repository.save(savedEntity)
|
|
76
76
|
expect(updatedEntity).toBeDefined()
|
|
77
|
-
expect(JSON.parse(updatedEntity.
|
|
78
|
-
expect(JSON.parse(updatedEntity.
|
|
77
|
+
expect(JSON.parse(updatedEntity.query).credentials[0].id).toEqual('updated-clubcard')
|
|
78
|
+
expect(JSON.parse(updatedEntity.query).credentials[0].format).toEqual('jwt_vc')
|
|
79
79
|
})
|
|
80
80
|
})
|
|
@@ -13,7 +13,7 @@ import { DcqlQueryItem, GetDefinitionsArgs, NonPersistedDcqlQueryItem } from '..
|
|
|
13
13
|
|
|
14
14
|
export const SAMPLE_DCQL_QUERY_IMPORT: ImportDcqlQueryItem = {
|
|
15
15
|
queryId: 'ajax-club',
|
|
16
|
-
|
|
16
|
+
query: {
|
|
17
17
|
credentials: [
|
|
18
18
|
{
|
|
19
19
|
id: 'clubcard-v1',
|
|
@@ -66,17 +66,68 @@ describe('PDStore tests', (): void => {
|
|
|
66
66
|
await dbConnection.destroy()
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
it('should throw error when getting
|
|
69
|
+
it('should throw error when getting query with unknown id', async (): Promise<void> => {
|
|
70
70
|
const itemId = 'unknownDefinitionId'
|
|
71
71
|
|
|
72
72
|
await expect(pdStore.getDefinition({ itemId })).rejects.toThrow(`No presentation definition item found for id: ${itemId}`)
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
it('should
|
|
75
|
+
it('should get all queries', async (): Promise<void> => {
|
|
76
|
+
const definition1: NonPersistedDcqlQueryItem = {
|
|
77
|
+
queryId: 'definition1',
|
|
78
|
+
version: '1.0',
|
|
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
|
+
},
|
|
94
|
+
}
|
|
95
|
+
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
96
|
+
expect(savedDefinition1).toBeDefined()
|
|
97
|
+
|
|
98
|
+
const definition2: NonPersistedDcqlQueryItem = {
|
|
99
|
+
queryId: 'definition2',
|
|
100
|
+
version: '1.0',
|
|
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
|
+
},
|
|
116
|
+
}
|
|
117
|
+
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
118
|
+
expect(savedDefinition2).toBeDefined()
|
|
119
|
+
|
|
120
|
+
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions({})
|
|
121
|
+
|
|
122
|
+
expect(result).toBeDefined()
|
|
123
|
+
expect(result.length).toEqual(2)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('should update dcql query', async (): Promise<void> => {
|
|
76
127
|
const definition: NonPersistedDcqlQueryItem = {
|
|
77
128
|
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
78
129
|
version: '1.0',
|
|
79
|
-
|
|
130
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
80
131
|
}
|
|
81
132
|
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
82
133
|
expect(savedDefinition).toBeDefined()
|
|
@@ -98,7 +149,7 @@ describe('PDStore tests', (): void => {
|
|
|
98
149
|
const updatedDefinition: DcqlQueryItem = {
|
|
99
150
|
...savedDefinition,
|
|
100
151
|
version: '1.1',
|
|
101
|
-
|
|
152
|
+
query: updatedDcqlQuery,
|
|
102
153
|
}
|
|
103
154
|
|
|
104
155
|
await pdStore.updateDefinition(updatedDefinition)
|
|
@@ -106,15 +157,15 @@ describe('PDStore tests', (): void => {
|
|
|
106
157
|
|
|
107
158
|
expect(result).toBeDefined()
|
|
108
159
|
expect(result.version).toEqual('1.1')
|
|
109
|
-
expect(result.
|
|
110
|
-
expect(result.
|
|
160
|
+
expect(result.query?.credentials[0].id).toEqual('updated-clubcard')
|
|
161
|
+
expect(result.query?.credentials[0].format).toEqual('dc+sd-jwt')
|
|
111
162
|
})
|
|
112
163
|
|
|
113
|
-
it('should get
|
|
164
|
+
it('should get dcql queries by id', async (): Promise<void> => {
|
|
114
165
|
const definition: NonPersistedDcqlQueryItem = {
|
|
115
166
|
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
116
167
|
version: '1.0',
|
|
117
|
-
|
|
168
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
118
169
|
}
|
|
119
170
|
|
|
120
171
|
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
@@ -123,19 +174,19 @@ describe('PDStore tests', (): void => {
|
|
|
123
174
|
const result: DcqlQueryItem = await pdStore.getDefinition({ itemId: savedDefinition.id })
|
|
124
175
|
|
|
125
176
|
expect(result).toBeDefined()
|
|
126
|
-
expect(result.
|
|
127
|
-
expect(result.
|
|
128
|
-
if (result.
|
|
129
|
-
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')
|
|
130
181
|
}
|
|
131
|
-
expect(result.
|
|
182
|
+
expect(result.query.credentials[0].claims).toHaveLength(4)
|
|
132
183
|
})
|
|
133
184
|
|
|
134
|
-
it('should get
|
|
185
|
+
it('should get dcql queries by filter', async (): Promise<void> => {
|
|
135
186
|
const definition: NonPersistedDcqlQueryItem = {
|
|
136
187
|
queryId: SAMPLE_DCQL_QUERY_IMPORT.queryId,
|
|
137
188
|
version: '1.0',
|
|
138
|
-
|
|
189
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
139
190
|
}
|
|
140
191
|
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
141
192
|
expect(savedDefinition).toBeDefined()
|
|
@@ -146,15 +197,15 @@ describe('PDStore tests', (): void => {
|
|
|
146
197
|
const result: Array<DcqlQueryItem> = await pdStore.getDefinitions(args)
|
|
147
198
|
|
|
148
199
|
expect(result.length).toEqual(1)
|
|
149
|
-
expect(result[0].
|
|
150
|
-
expect(result[0].
|
|
200
|
+
expect(result[0].query).toBeDefined()
|
|
201
|
+
expect(result[0].query.credentials[0].id).toEqual('clubcard-v1')
|
|
151
202
|
})
|
|
152
203
|
|
|
153
|
-
it('should delete query', async (): Promise<void> => {
|
|
204
|
+
it('should delete dcql query', async (): Promise<void> => {
|
|
154
205
|
const definition: NonPersistedDcqlQueryItem = {
|
|
155
206
|
queryId: 'definition1',
|
|
156
207
|
version: '1.0',
|
|
157
|
-
|
|
208
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
158
209
|
}
|
|
159
210
|
const savedDefinition: DcqlQueryItem = await pdStore.addDefinition(definition)
|
|
160
211
|
expect(savedDefinition).toBeDefined()
|
|
@@ -166,11 +217,11 @@ describe('PDStore tests', (): void => {
|
|
|
166
217
|
)
|
|
167
218
|
})
|
|
168
219
|
|
|
169
|
-
it('should delete queries by filter', async (): Promise<void> => {
|
|
220
|
+
it('should delete dcql queries by filter', async (): Promise<void> => {
|
|
170
221
|
const definition1: NonPersistedDcqlQueryItem = {
|
|
171
222
|
queryId: 'definition1',
|
|
172
223
|
version: '1.0',
|
|
173
|
-
|
|
224
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
174
225
|
}
|
|
175
226
|
const savedDefinition1: DcqlQueryItem = await pdStore.addDefinition(definition1)
|
|
176
227
|
expect(savedDefinition1).toBeDefined()
|
|
@@ -178,7 +229,7 @@ describe('PDStore tests', (): void => {
|
|
|
178
229
|
const definition2: NonPersistedDcqlQueryItem = {
|
|
179
230
|
queryId: 'definition2',
|
|
180
231
|
version: '1.0',
|
|
181
|
-
|
|
232
|
+
query: SAMPLE_DCQL_QUERY_IMPORT.query,
|
|
182
233
|
}
|
|
183
234
|
const savedDefinition2: DcqlQueryItem = await pdStore.addDefinition(definition2)
|
|
184
235
|
expect(savedDefinition2).toBeDefined()
|
|
@@ -25,9 +25,9 @@ export class DcqlQueryItemEntity extends BaseEntity {
|
|
|
25
25
|
@Column({ name: 'name', length: 255, type: 'varchar', nullable: true, unique: false })
|
|
26
26
|
name?: string
|
|
27
27
|
|
|
28
|
-
@Column({ name: '
|
|
28
|
+
@Column({ name: 'query', type: 'text', nullable: false, unique: false })
|
|
29
29
|
@IsNotEmpty({ message: 'A blank dcql query payload field is not allowed' })
|
|
30
|
-
|
|
30
|
+
query!: string
|
|
31
31
|
|
|
32
32
|
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
33
33
|
createdAt!: Date
|
|
@@ -13,7 +13,7 @@ CREATE TABLE "PresentationDefinitionItem" (
|
|
|
13
13
|
"version" TEXT NOT NULL,
|
|
14
14
|
"purpose" TEXT,
|
|
15
15
|
"definition_payload" TEXT NOT NULL,
|
|
16
|
-
"
|
|
16
|
+
"query" TEXT,
|
|
17
17
|
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
18
18
|
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
19
19
|
CONSTRAINT "PK_PresentationDefinitionItem_id" PRIMARY KEY ("id"))
|
|
@@ -12,7 +12,7 @@ export class CreateDcqlQueryItemPG1726588800000 implements MigrationInterface {
|
|
|
12
12
|
"name" TEXT,
|
|
13
13
|
"version" TEXT NOT NULL,
|
|
14
14
|
"purpose" TEXT,
|
|
15
|
-
"
|
|
15
|
+
"query" TEXT NOT NULL,
|
|
16
16
|
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
17
17
|
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
18
18
|
CONSTRAINT "PK_DcqlQueryItem_id" PRIMARY KEY ("id"))
|
|
@@ -13,7 +13,7 @@ export class CreatePresentationDefinitions1716475165344 implements MigrationInte
|
|
|
13
13
|
"version" varchar NOT NULL,
|
|
14
14
|
"purpose" varchar,
|
|
15
15
|
"definition_payload" varchar NOT NULL,
|
|
16
|
-
"
|
|
16
|
+
"query" varchar,
|
|
17
17
|
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
18
18
|
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
19
19
|
)
|
|
@@ -12,7 +12,7 @@ export class CreateDcqlQueryItemSQlite1726617600000 implements MigrationInterfac
|
|
|
12
12
|
"name" varchar,
|
|
13
13
|
"version" varchar NOT NULL,
|
|
14
14
|
"purpose" varchar,
|
|
15
|
-
"
|
|
15
|
+
"query" varchar NOT NULL,
|
|
16
16
|
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
17
17
|
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
18
18
|
)
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
DcqlQueryItemFilter,
|
|
15
15
|
} from '../types'
|
|
16
16
|
import { DcqlQueryItemEntity } from '../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
17
|
-
import {
|
|
17
|
+
import { dcqlQueryEntityItemFrom, dcqlQueryItemFrom } from '../utils/presentationDefinition/MappingUtils'
|
|
18
18
|
|
|
19
19
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:pd-store')
|
|
20
20
|
|
|
@@ -36,7 +36,7 @@ export class PDStore extends AbstractPDStore {
|
|
|
36
36
|
return Promise.reject(Error(`No presentation definition item found for id: ${itemId}`))
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return
|
|
39
|
+
return dcqlQueryItemFrom(result)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
hasDefinition = async (args: HasDefinitionArgs): Promise<boolean> => {
|
|
@@ -73,19 +73,19 @@ export class PDStore extends AbstractPDStore {
|
|
|
73
73
|
},
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
-
return result.map((entity: DcqlQueryItemEntity) =>
|
|
76
|
+
return result.map((entity: DcqlQueryItemEntity) => dcqlQueryItemFrom(entity))
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
addDefinition = async (item: NonPersistedDcqlQueryItem): Promise<DcqlQueryItem> => {
|
|
80
80
|
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
81
81
|
|
|
82
|
-
const entity: DcqlQueryItemEntity =
|
|
82
|
+
const entity: DcqlQueryItemEntity = dcqlQueryEntityItemFrom(item)
|
|
83
83
|
debug('Adding presentation definition entity', item)
|
|
84
84
|
const result: DcqlQueryItemEntity = await pdRepository.save(entity, {
|
|
85
85
|
transaction: true,
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
return
|
|
88
|
+
return dcqlQueryItemFrom(result)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
updateDefinition = async (item: DcqlQueryItem): Promise<DcqlQueryItem> => {
|
|
@@ -106,14 +106,14 @@ export class PDStore extends AbstractPDStore {
|
|
|
106
106
|
updatedEntity.version = item.version
|
|
107
107
|
updatedEntity.name = item.name
|
|
108
108
|
updatedEntity.purpose = item.purpose
|
|
109
|
-
updatedEntity.
|
|
109
|
+
updatedEntity.query = JSON.stringify(item.query)
|
|
110
110
|
|
|
111
111
|
debug('Updating presentation definition entity', updatedEntity)
|
|
112
112
|
const updateResult: DcqlQueryItemEntity = await pdRepository.save(updatedEntity, {
|
|
113
113
|
transaction: true,
|
|
114
114
|
})
|
|
115
115
|
|
|
116
|
-
return
|
|
116
|
+
return dcqlQueryItemFrom(updateResult)
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
deleteDefinition = async (args: DeleteDefinitionArgs): Promise<void> => {
|
|
@@ -7,7 +7,7 @@ export type DcqlQueryItem = {
|
|
|
7
7
|
version: string
|
|
8
8
|
name?: string
|
|
9
9
|
purpose?: string
|
|
10
|
-
|
|
10
|
+
query: DcqlQuery
|
|
11
11
|
createdAt: Date
|
|
12
12
|
lastUpdatedAt: Date
|
|
13
13
|
}
|
|
@@ -15,4 +15,4 @@ export type DcqlQueryItem = {
|
|
|
15
15
|
export type ImportDcqlQueryItem = Omit<DcqlQueryItem, 'id' | 'tenantId' | 'version' | 'createdAt' | 'lastUpdatedAt'>
|
|
16
16
|
export type NonPersistedDcqlQueryItem = Omit<DcqlQueryItem, 'id' | 'createdAt' | 'lastUpdatedAt'>
|
|
17
17
|
export type PartialDcqlQueryItem = Partial<DcqlQueryItem>
|
|
18
|
-
export type DcqlQueryItemFilter = Partial<Omit<DcqlQueryItem, '
|
|
18
|
+
export type DcqlQueryItemFilter = Partial<Omit<DcqlQueryItem, 'query'>>
|
|
@@ -5,7 +5,7 @@ import { DcqlQueryItemEntity } from '../../entities/presentationDefinition/DcqlQ
|
|
|
5
5
|
import type { NonPersistedDcqlQueryItem, PartialDcqlQueryItem, DcqlQueryItem } from '../../types'
|
|
6
6
|
import { replaceNullWithUndefined } from '../FormattingUtils'
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const dcqlQueryItemFrom = (entity: DcqlQueryItemEntity): DcqlQueryItem => {
|
|
9
9
|
const result: DcqlQueryItem = {
|
|
10
10
|
id: entity.id,
|
|
11
11
|
tenantId: entity.tenantId,
|
|
@@ -13,18 +13,18 @@ export const presentationDefinitionItemFrom = (entity: DcqlQueryItemEntity): Dcq
|
|
|
13
13
|
version: entity.version,
|
|
14
14
|
name: entity.name,
|
|
15
15
|
purpose: entity.purpose,
|
|
16
|
-
|
|
16
|
+
query: DcqlQuery.parse(JSON.parse(entity.query)),
|
|
17
17
|
createdAt: entity.createdAt,
|
|
18
18
|
lastUpdatedAt: entity.lastUpdatedAt,
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
if (result.
|
|
22
|
-
DcqlQuery.validate(result.
|
|
21
|
+
if (result.query) {
|
|
22
|
+
DcqlQuery.validate(result.query)
|
|
23
23
|
}
|
|
24
24
|
return replaceNullWithUndefined(result)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const dcqlQueryEntityItemFrom = (item: NonPersistedDcqlQueryItem): DcqlQueryItemEntity => {
|
|
28
28
|
const entity = new DcqlQueryItemEntity()
|
|
29
29
|
|
|
30
30
|
entity.tenantId = item.tenantId
|
|
@@ -32,10 +32,10 @@ export const presentationDefinitionEntityItemFrom = (item: NonPersistedDcqlQuery
|
|
|
32
32
|
entity.version = item.version
|
|
33
33
|
entity.name = item.name
|
|
34
34
|
entity.purpose = item.purpose
|
|
35
|
-
if (item.
|
|
36
|
-
const dcqlQuery = DcqlQuery.parse(item.
|
|
35
|
+
if (item.query) {
|
|
36
|
+
const dcqlQuery = DcqlQuery.parse(item.query)
|
|
37
37
|
DcqlQuery.validate(dcqlQuery)
|
|
38
|
-
entity.
|
|
38
|
+
entity.query = JSON.stringify(item.query)
|
|
39
39
|
}
|
|
40
40
|
return entity
|
|
41
41
|
}
|
|
@@ -55,11 +55,11 @@ export function isPresentationDefinitionEqual(base: PartialDcqlQueryItem, compar
|
|
|
55
55
|
return false
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
if (base.
|
|
59
|
-
if (hashPayload(base.
|
|
58
|
+
if (base.query && compare.query) {
|
|
59
|
+
if (hashPayload(base.query) !== hashPayload(compare.query)) {
|
|
60
60
|
return false
|
|
61
61
|
}
|
|
62
|
-
} else if (base.
|
|
62
|
+
} else if (base.query || compare.query) {
|
|
63
63
|
return false
|
|
64
64
|
}
|
|
65
65
|
|