@sphereon/ssi-sdk.data-store 0.34.1-next.3 → 0.34.1-next.323
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 +3377 -2924
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -1203
- package/dist/index.d.ts +357 -1203
- package/dist/index.js +3300 -2847
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- 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 +61 -4
- package/src/__tests__/statusList.store.test.ts +67 -4
- 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 +60 -0
- package/src/entities/statusList/StatusList2021EntryEntity.ts +4 -3
- package/src/entities/statusList/StatusListEntities.ts +55 -7
- package/src/eventLogger/EventLoggerStore.ts +2 -2
- package/src/index.ts +31 -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 +82 -0
- 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 -4
- 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/1737110469001-UpdateStatusList.ts +1 -1
- package/src/migrations/postgres/1741895823000-CreateBitstringStatusList.ts +67 -0
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +1 -1
- package/src/migrations/sqlite/1726617600000-CreateDcqlQueryItem.ts +24 -0
- package/src/migrations/sqlite/1741895823001-CreateBitstringStatusList.ts +145 -0
- package/src/presentationDefinition/PDStore.ts +45 -45
- package/src/statusList/IStatusListStore.ts +14 -11
- package/src/statusList/StatusListStore.ts +74 -36
- package/src/types/index.ts +0 -12
- package/src/types/statusList/IAbstractStatusListStore.ts +55 -5
- package/src/types/statusList/statusList.ts +50 -2
- 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 +71 -30
- 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
|
@@ -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
|
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateDcqlQueryItemSQlite1726617600000 implements MigrationInterface {
|
|
4
|
+
name = 'CreateDcqlQueryItemSQlite1726617600000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "DcqlQueryItem" (
|
|
9
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
10
|
+
"tenant_id" varchar,
|
|
11
|
+
"query_id" varchar NOT NULL,
|
|
12
|
+
"name" varchar,
|
|
13
|
+
"version" varchar NOT NULL,
|
|
14
|
+
"purpose" varchar,
|
|
15
|
+
"query" varchar NOT NULL,
|
|
16
|
+
"created_at" datetime NOT NULL DEFAULT (datetime('now')),
|
|
17
|
+
"last_updated_at" datetime NOT NULL DEFAULT (datetime('now')))`,
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
22
|
+
await queryRunner.query(`DROP TABLE "DcqlQueryItem"`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateBitstringStatusListSqlite1741895823001 implements MigrationInterface {
|
|
4
|
+
name = 'CreateBitstringStatusList1741895823000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
// Update StatusList table to include BitstringStatusList type and columns
|
|
8
|
+
await queryRunner.query(`
|
|
9
|
+
CREATE TABLE "temporary_StatusList" (
|
|
10
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
11
|
+
"correlationId" varchar NOT NULL,
|
|
12
|
+
"length" integer NOT NULL,
|
|
13
|
+
"issuer" text NOT NULL,
|
|
14
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList', 'BitstringStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
15
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
16
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
17
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
|
|
18
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
19
|
+
"statusPurpose" varchar,
|
|
20
|
+
"statusListCredential" text,
|
|
21
|
+
"expiresAt" datetime,
|
|
22
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
23
|
+
"ttl" integer,
|
|
24
|
+
"validFrom" datetime,
|
|
25
|
+
"validUntil" datetime,
|
|
26
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
27
|
+
)
|
|
28
|
+
`)
|
|
29
|
+
|
|
30
|
+
await queryRunner.query(`
|
|
31
|
+
INSERT INTO "temporary_StatusList"(
|
|
32
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
33
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
34
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
35
|
+
)
|
|
36
|
+
SELECT
|
|
37
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
38
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
39
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
40
|
+
FROM "StatusList"
|
|
41
|
+
`)
|
|
42
|
+
|
|
43
|
+
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
44
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
45
|
+
|
|
46
|
+
// Update StatusListEntry table with inheritance and bitstring columns
|
|
47
|
+
await queryRunner.query(`
|
|
48
|
+
CREATE TABLE "temporary_StatusListEntry" (
|
|
49
|
+
"statusListId" varchar NOT NULL,
|
|
50
|
+
"statusListIndex" integer NOT NULL,
|
|
51
|
+
"credentialId" text,
|
|
52
|
+
"credentialHash" varchar(128),
|
|
53
|
+
"correlationId" varchar(255),
|
|
54
|
+
"value" varchar(50),
|
|
55
|
+
"type" varchar CHECK( "type" IN ('StatusListEntryEntity', 'bitstring') ) NOT NULL DEFAULT ('StatusListEntryEntity'),
|
|
56
|
+
"statusPurpose" varchar,
|
|
57
|
+
"bitsPerStatus" integer DEFAULT (1),
|
|
58
|
+
"statusMessage" text,
|
|
59
|
+
"statusReference" text,
|
|
60
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
61
|
+
)
|
|
62
|
+
`)
|
|
63
|
+
|
|
64
|
+
await queryRunner.query(`
|
|
65
|
+
INSERT INTO "temporary_StatusListEntry"(
|
|
66
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
67
|
+
"correlationId", "value", "type"
|
|
68
|
+
)
|
|
69
|
+
SELECT
|
|
70
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
71
|
+
"correlationId", "value", 'StatusListEntryEntity'
|
|
72
|
+
FROM "StatusListEntry"
|
|
73
|
+
`)
|
|
74
|
+
|
|
75
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`)
|
|
76
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
80
|
+
// Revert StatusListEntry table changes
|
|
81
|
+
await queryRunner.query(`
|
|
82
|
+
CREATE TABLE "temporary_StatusListEntry" (
|
|
83
|
+
"statusListId" varchar NOT NULL,
|
|
84
|
+
"statusListIndex" integer NOT NULL,
|
|
85
|
+
"credentialId" text,
|
|
86
|
+
"credentialHash" varchar(128),
|
|
87
|
+
"correlationId" varchar(255),
|
|
88
|
+
"value" varchar(50),
|
|
89
|
+
PRIMARY KEY ("statusListId", "statusListIndex")
|
|
90
|
+
)
|
|
91
|
+
`)
|
|
92
|
+
|
|
93
|
+
await queryRunner.query(`
|
|
94
|
+
INSERT INTO "temporary_StatusListEntry"(
|
|
95
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
96
|
+
"correlationId", "value"
|
|
97
|
+
)
|
|
98
|
+
SELECT
|
|
99
|
+
"statusListId", "statusListIndex", "credentialId", "credentialHash",
|
|
100
|
+
"correlationId", "value"
|
|
101
|
+
FROM "StatusListEntry"
|
|
102
|
+
WHERE "type" = 'StatusListEntryEntity'
|
|
103
|
+
`)
|
|
104
|
+
|
|
105
|
+
await queryRunner.query(`DROP TABLE "StatusListEntry"`)
|
|
106
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusListEntry" RENAME TO "StatusListEntry"`)
|
|
107
|
+
|
|
108
|
+
// Revert StatusList table changes
|
|
109
|
+
await queryRunner.query(`
|
|
110
|
+
CREATE TABLE "temporary_StatusList" (
|
|
111
|
+
"id" varchar PRIMARY KEY NOT NULL,
|
|
112
|
+
"correlationId" varchar NOT NULL,
|
|
113
|
+
"length" integer NOT NULL,
|
|
114
|
+
"issuer" text NOT NULL,
|
|
115
|
+
"type" varchar CHECK( "type" IN ('StatusList2021', 'OAuthStatusList') ) NOT NULL DEFAULT ('StatusList2021'),
|
|
116
|
+
"driverType" varchar CHECK( "driverType" IN ('agent_typeorm','agent_kv_store','github','agent_filesystem') ) NOT NULL DEFAULT ('agent_typeorm'),
|
|
117
|
+
"credentialIdMode" varchar CHECK( "credentialIdMode" IN ('ISSUANCE','PERSISTENCE','NEVER') ) NOT NULL DEFAULT ('ISSUANCE'),
|
|
118
|
+
"proofFormat" varchar CHECK( "proofFormat" IN ('lds','jwt', 'vc+jwt') ) NOT NULL DEFAULT ('lds'),
|
|
119
|
+
"indexingDirection" varchar CHECK( "indexingDirection" IN ('rightToLeft') ),
|
|
120
|
+
"statusPurpose" varchar,
|
|
121
|
+
"statusListCredential" text,
|
|
122
|
+
"bitsPerStatus" integer,
|
|
123
|
+
"expiresAt" datetime,
|
|
124
|
+
CONSTRAINT "UQ_correlationId" UNIQUE ("correlationId")
|
|
125
|
+
)
|
|
126
|
+
`)
|
|
127
|
+
|
|
128
|
+
await queryRunner.query(`
|
|
129
|
+
INSERT INTO "temporary_StatusList"(
|
|
130
|
+
"id", "correlationId", "length", "issuer", "type", "driverType",
|
|
131
|
+
"credentialIdMode", "proofFormat", "indexingDirection", "statusPurpose",
|
|
132
|
+
"statusListCredential", "bitsPerStatus", "expiresAt"
|
|
133
|
+
)
|
|
134
|
+
SELECT
|
|
135
|
+
"id", "correlationId", "length", "issuer",
|
|
136
|
+
CASE WHEN "type" = 'BitstringStatusList' THEN 'StatusList2021' ELSE "type" END,
|
|
137
|
+
"driverType", "credentialIdMode", "proofFormat", "indexingDirection",
|
|
138
|
+
"statusPurpose", "statusListCredential", "bitsPerStatus", "expiresAt"
|
|
139
|
+
FROM "StatusList"
|
|
140
|
+
`)
|
|
141
|
+
|
|
142
|
+
await queryRunner.query(`DROP TABLE "StatusList"`)
|
|
143
|
+
await queryRunner.query(`ALTER TABLE "temporary_StatusList" RENAME TO "StatusList"`)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { type OrPromise } from '@sphereon/ssi-types'
|
|
2
|
-
import { DataSource, In, Repository } from 'typeorm'
|
|
3
|
-
import { AbstractPDStore } from './AbstractPDStore'
|
|
4
|
-
import Debug from 'debug'
|
|
5
1
|
import type {
|
|
2
|
+
DcqlQueryItem,
|
|
3
|
+
DcqlQueryItemFilter,
|
|
6
4
|
DeleteDefinitionArgs,
|
|
7
5
|
DeleteDefinitionsArgs,
|
|
8
6
|
GetDefinitionArgs,
|
|
9
7
|
GetDefinitionsArgs,
|
|
10
8
|
HasDefinitionArgs,
|
|
11
9
|
HasDefinitionsArgs,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
10
|
+
NonPersistedDcqlQueryItem,
|
|
11
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
12
|
+
import { AbstractPDStore } from '@sphereon/ssi-sdk.data-store-types'
|
|
13
|
+
import { type OrPromise } from '@sphereon/ssi-types'
|
|
14
|
+
import Debug from 'debug'
|
|
15
|
+
import { DataSource, In, Repository } from 'typeorm'
|
|
16
|
+
import { DcqlQueryItemEntity } from '../entities/presentationDefinition/DcqlQueryItemEntity'
|
|
17
|
+
import { dcqlQueryEntityItemFrom, dcqlQueryItemFrom } from '../utils/presentationDefinition/MappingUtils'
|
|
18
18
|
|
|
19
19
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:pd-store')
|
|
20
20
|
|
|
@@ -26,22 +26,22 @@ export class PDStore extends AbstractPDStore {
|
|
|
26
26
|
this.dbConnection = dbConnection
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
getDefinition = async (args: GetDefinitionArgs): Promise<
|
|
29
|
+
getDefinition = async (args: GetDefinitionArgs): Promise<DcqlQueryItem> => {
|
|
30
30
|
const { itemId } = args ?? {}
|
|
31
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
32
|
-
const result:
|
|
31
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
32
|
+
const result: DcqlQueryItemEntity | null = await pdRepository.findOne({
|
|
33
33
|
where: { id: itemId },
|
|
34
34
|
})
|
|
35
35
|
if (!result) {
|
|
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> => {
|
|
43
43
|
const { itemId } = args ?? {}
|
|
44
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
44
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
45
45
|
|
|
46
46
|
const resultCount: number = await pdRepository.count({
|
|
47
47
|
where: { id: itemId },
|
|
@@ -52,7 +52,7 @@ export class PDStore extends AbstractPDStore {
|
|
|
52
52
|
|
|
53
53
|
hasDefinitions = async (args: HasDefinitionsArgs): Promise<boolean> => {
|
|
54
54
|
const { filter } = args
|
|
55
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
55
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
56
56
|
|
|
57
57
|
const resultCount: number = await pdRepository.count({
|
|
58
58
|
...(filter && { where: cleanFilter(filter) }),
|
|
@@ -60,67 +60,67 @@ export class PDStore extends AbstractPDStore {
|
|
|
60
60
|
return resultCount > 0
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
getDefinitions = async (args: GetDefinitionsArgs): Promise<Array<
|
|
63
|
+
getDefinitions = async (args: GetDefinitionsArgs): Promise<Array<DcqlQueryItem>> => {
|
|
64
64
|
const { filter } = args
|
|
65
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
65
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
66
66
|
const initialResult = await this.findIds(pdRepository, filter)
|
|
67
|
-
const result: Array<
|
|
67
|
+
const result: Array<DcqlQueryItemEntity> = await pdRepository.find({
|
|
68
68
|
where: {
|
|
69
|
-
id: In(initialResult.map((entity:
|
|
69
|
+
id: In(initialResult.map((entity: DcqlQueryItemEntity) => entity.id)),
|
|
70
70
|
},
|
|
71
71
|
order: {
|
|
72
72
|
version: 'DESC',
|
|
73
73
|
},
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
-
return result.map((entity:
|
|
76
|
+
return result.map((entity: DcqlQueryItemEntity) => dcqlQueryItemFrom(entity))
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
addDefinition = async (item:
|
|
80
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
79
|
+
addDefinition = async (item: NonPersistedDcqlQueryItem): Promise<DcqlQueryItem> => {
|
|
80
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
81
81
|
|
|
82
|
-
const entity:
|
|
82
|
+
const entity: DcqlQueryItemEntity = dcqlQueryEntityItemFrom(item)
|
|
83
83
|
debug('Adding presentation definition entity', item)
|
|
84
|
-
const result:
|
|
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
|
-
updateDefinition = async (item:
|
|
92
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
91
|
+
updateDefinition = async (item: DcqlQueryItem): Promise<DcqlQueryItem> => {
|
|
92
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
93
93
|
|
|
94
|
-
const result:
|
|
94
|
+
const result: DcqlQueryItemEntity | null = await pdRepository.findOne({
|
|
95
95
|
where: { id: item.id },
|
|
96
96
|
})
|
|
97
97
|
if (!result) {
|
|
98
98
|
return Promise.reject(Error(`No presentation definition entity found for id: ${item.id}`))
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
const updatedEntity: Partial<
|
|
101
|
+
const updatedEntity: Partial<DcqlQueryItemEntity> = {
|
|
102
102
|
...result,
|
|
103
103
|
}
|
|
104
104
|
updatedEntity.tenantId = item.tenantId
|
|
105
|
-
updatedEntity.
|
|
105
|
+
updatedEntity.queryId = item.queryId!
|
|
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
|
-
const updateResult:
|
|
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> => {
|
|
120
120
|
const { itemId } = args
|
|
121
121
|
|
|
122
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
123
|
-
const entity:
|
|
122
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
123
|
+
const entity: DcqlQueryItemEntity | null = await pdRepository.findOne({
|
|
124
124
|
where: { id: itemId },
|
|
125
125
|
})
|
|
126
126
|
|
|
@@ -134,12 +134,12 @@ export class PDStore extends AbstractPDStore {
|
|
|
134
134
|
|
|
135
135
|
deleteDefinitions = async (args: DeleteDefinitionsArgs): Promise<number> => {
|
|
136
136
|
const { filter } = args
|
|
137
|
-
const pdRepository = (await this.dbConnection).getRepository(
|
|
137
|
+
const pdRepository = (await this.dbConnection).getRepository(DcqlQueryItemEntity)
|
|
138
138
|
const initialResult = await this.findIds(pdRepository, filter)
|
|
139
139
|
|
|
140
|
-
const result: Array<
|
|
140
|
+
const result: Array<DcqlQueryItemEntity> = await pdRepository.find({
|
|
141
141
|
where: {
|
|
142
|
-
id: In(initialResult.map((entity:
|
|
142
|
+
id: In(initialResult.map((entity: DcqlQueryItemEntity) => entity.id)),
|
|
143
143
|
},
|
|
144
144
|
})
|
|
145
145
|
|
|
@@ -151,9 +151,9 @@ export class PDStore extends AbstractPDStore {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
findIds = async (
|
|
154
|
-
pdRepository: Repository<
|
|
155
|
-
filter: Array<
|
|
156
|
-
): Promise<Array<
|
|
154
|
+
pdRepository: Repository<DcqlQueryItemEntity>,
|
|
155
|
+
filter: Array<DcqlQueryItemFilter> | undefined,
|
|
156
|
+
): Promise<Array<DcqlQueryItemEntity>> => {
|
|
157
157
|
const idFilters = filter?.map((f) => f.id).filter((id) => id !== undefined && id !== null)
|
|
158
158
|
if (idFilters && idFilters.length > 0 && idFilters.length === filter?.length) {
|
|
159
159
|
return await pdRepository.find({
|
|
@@ -167,15 +167,15 @@ export class PDStore extends AbstractPDStore {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
const cleanFilter = (filter: Array<
|
|
170
|
+
const cleanFilter = (filter: Array<DcqlQueryItemFilter> | undefined): Array<DcqlQueryItemFilter> | undefined => {
|
|
171
171
|
if (filter === undefined) {
|
|
172
172
|
return undefined
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
return filter.map((item) => {
|
|
176
|
-
const cleanedItem:
|
|
176
|
+
const cleanedItem: DcqlQueryItemFilter = {}
|
|
177
177
|
for (const key in item) {
|
|
178
|
-
const value = item[key as keyof
|
|
178
|
+
const value = item[key as keyof DcqlQueryItemFilter]
|
|
179
179
|
if (value !== undefined) {
|
|
180
180
|
;(cleanedItem as any)[key] = value
|
|
181
181
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
1
2
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
2
3
|
import type {
|
|
3
4
|
IAddStatusListArgs,
|
|
4
5
|
IAddStatusListEntryArgs,
|
|
6
|
+
IBitstringStatusListEntity,
|
|
7
|
+
IBitstringStatusListEntryEntity,
|
|
5
8
|
IGetStatusListArgs,
|
|
6
9
|
IGetStatusListEntriesArgs,
|
|
7
10
|
IGetStatusListEntryByCredentialIdArgs,
|
|
@@ -14,31 +17,31 @@ import type {
|
|
|
14
17
|
import { IStatusListEntity, IStatusListEntryEntity } from '../types'
|
|
15
18
|
|
|
16
19
|
export interface IStatusListStore {
|
|
17
|
-
getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity>
|
|
20
|
+
getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
|
|
18
21
|
|
|
19
|
-
getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity>>
|
|
22
|
+
getStatusLists(args: IGetStatusListsArgs): Promise<Array<IStatusListEntity | IBitstringStatusListEntity>>
|
|
20
23
|
|
|
21
24
|
removeStatusList(args: IRemoveStatusListArgs): Promise<boolean>
|
|
22
25
|
|
|
23
|
-
addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity>
|
|
26
|
+
addStatusList(args: IAddStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
|
|
24
27
|
|
|
25
|
-
updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity>
|
|
28
|
+
updateStatusList(args: IUpdateStatusListIndexArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
|
|
26
29
|
|
|
27
30
|
availableStatusListEntries(args: IStatusListEntryAvailableArgs): Promise<number[]>
|
|
28
31
|
|
|
29
|
-
addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity>
|
|
32
|
+
addStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
|
|
30
33
|
|
|
31
|
-
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity>
|
|
34
|
+
updateStatusListEntry(args: IAddStatusListEntryArgs): Promise<IStatusListEntryEntity | IBitstringStatusListEntryEntity>
|
|
32
35
|
|
|
33
|
-
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | undefined>
|
|
36
|
+
getStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined>
|
|
34
37
|
|
|
35
|
-
getStatusListEntryByCredentialId(
|
|
38
|
+
getStatusListEntryByCredentialId(
|
|
39
|
+
args: IGetStatusListEntryByCredentialIdArgs,
|
|
40
|
+
): Promise<StatusListEntryEntity | BitstringStatusListEntryEntity | undefined>
|
|
36
41
|
|
|
37
42
|
removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<boolean>
|
|
38
43
|
|
|
39
44
|
removeStatusListEntryByCredentialId(args: IGetStatusListEntryByCredentialIdArgs): Promise<boolean>
|
|
40
45
|
|
|
41
|
-
getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<IStatusListEntryEntity
|
|
42
|
-
|
|
43
|
-
getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity>
|
|
46
|
+
getStatusListEntries(args: IGetStatusListEntriesArgs): Promise<Array<IStatusListEntryEntity | IBitstringStatusListEntryEntity>>
|
|
44
47
|
}
|