@sphereon/ssi-sdk.data-store 0.34.1-next.91 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Debug from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { CreateDcqlQueryItemPG1726588800000 } from '../postgres/1726588800000-CreateDcqlQueryItem'
|
|
5
|
+
import { CreateDcqlQueryItemSQlite1726617600000 } from '../sqlite/1726617600000-CreateDcqlQueryItem'
|
|
6
|
+
|
|
7
|
+
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
8
|
+
|
|
9
|
+
export class CreateDcqlQueryItem1726617600000 implements MigrationInterface {
|
|
10
|
+
name = 'CreateDcqlQueryItem1726617600000'
|
|
11
|
+
|
|
12
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
debug('migration: updating presentation definition item nullable fields')
|
|
14
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
15
|
+
|
|
16
|
+
switch (dbType) {
|
|
17
|
+
case 'postgres': {
|
|
18
|
+
debug('using postgres migration file')
|
|
19
|
+
const mig: CreateDcqlQueryItemPG1726588800000 = new CreateDcqlQueryItemPG1726588800000()
|
|
20
|
+
await mig.up(queryRunner)
|
|
21
|
+
debug('Migration statements executed')
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
case 'sqlite':
|
|
25
|
+
case 'expo':
|
|
26
|
+
case 'react-native': {
|
|
27
|
+
debug('using sqlite/react-native migration file')
|
|
28
|
+
const mig: CreateDcqlQueryItemSQlite1726617600000 = new CreateDcqlQueryItemSQlite1726617600000()
|
|
29
|
+
await mig.up(queryRunner)
|
|
30
|
+
debug('Migration statements executed')
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return Promise.reject(
|
|
35
|
+
`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
41
|
+
debug('migration: reverting presentation definition item nullable fields')
|
|
42
|
+
const dbType: DatabaseType = queryRunner.connection.driver.options.type
|
|
43
|
+
|
|
44
|
+
switch (dbType) {
|
|
45
|
+
case 'postgres': {
|
|
46
|
+
debug('using postgres migration file')
|
|
47
|
+
const mig: CreateDcqlQueryItemPG1726588800000 = new CreateDcqlQueryItemPG1726588800000()
|
|
48
|
+
await mig.down(queryRunner)
|
|
49
|
+
debug('Migration statements executed')
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
case 'sqlite':
|
|
53
|
+
case 'expo':
|
|
54
|
+
case 'react-native': {
|
|
55
|
+
debug('using sqlite/react-native migration file')
|
|
56
|
+
const mig: CreateDcqlQueryItemSQlite1726617600000 = new CreateDcqlQueryItemSQlite1726617600000()
|
|
57
|
+
await mig.down(queryRunner)
|
|
58
|
+
debug('Migration statements executed')
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
return Promise.reject(
|
|
63
|
+
`Migrations are currently only supported for sqlite, react-native, expo and postgres. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateIssuanceBranding1685628974232 } from '../postgres/1685628974232-CreateIssuanceBranding'
|
|
4
4
|
import { CreateIssuanceBranding1685628973231 } from '../sqlite/1685628973231-CreateIssuanceBranding'
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug from 'debug'
|
|
3
|
-
import {
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
4
3
|
import { CreateContacts1690925872592 } from '../postgres/1690925872592-CreateContacts'
|
|
4
|
+
import { CreateContacts1690925872693 } from '../sqlite/1690925872693-CreateContacts'
|
|
5
5
|
|
|
6
6
|
const debug: Debug.Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Debug from 'debug'
|
|
2
2
|
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateStatusList1693866470001 } from '../postgres/1693866470001-CreateStatusList'
|
|
4
|
-
import { CreateStatusList1693866470002 } from '../sqlite/1693866470000-CreateStatusList'
|
|
5
4
|
import { UpdateStatusList1737110469001 } from '../postgres/1737110469001-UpdateStatusList'
|
|
5
|
+
import { CreateStatusList1693866470002 } from '../sqlite/1693866470000-CreateStatusList'
|
|
6
6
|
import { UpdateStatusList1737110469000 } from '../sqlite/1737110469000-UpdateStatusList'
|
|
7
7
|
|
|
8
8
|
const debug = Debug('sphereon:ssi-sdk:migrations')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug, { Debugger } from 'debug'
|
|
3
|
-
import {
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
4
3
|
import { CreateAuditEvents1701634812183 } from '../postgres/1701634812183-CreateAuditEvents'
|
|
4
|
+
import { CreateAuditEvents1701634819487 } from '../sqlite/1701634819487-CreateAuditEvents'
|
|
5
5
|
|
|
6
6
|
const debug: Debugger = Debug('sphereon:ssi-sdk:migrations')
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug, { Debugger } from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateDigitalCredential1708525189001 } from '../postgres/1708525189001-CreateDigitalCredential'
|
|
4
4
|
import { CreateDigitalCredential1708525189002 } from '../sqlite/1708525189002-CreateDigitalCredential'
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateMachineStateStore1708797018115 } from '../postgres/1708797018115-CreateMachineStateStore'
|
|
4
4
|
import { CreateMachineStateStore1708796002272 } from '../sqlite/1708796002272-CreateMachineStateStore'
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateContacts1710438363001 } from '../postgres/1710438363001-CreateContacts'
|
|
4
4
|
import { CreateContacts1710438363002 } from '../sqlite/1710438363002-CreateContacts'
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import Debug from 'debug'
|
|
2
|
+
import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
import { CreateContacts1715761125001 } from '../postgres/1715761125001-CreateContacts'
|
|
4
4
|
import { CreateContacts1715761125002 } from '../sqlite/1715761125002-CreateContacts'
|
|
5
5
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { CreateContacts1659463079429 } from './1-CreateContacts'
|
|
2
|
+
import { CreatePresentationDefinitions1716533767523 } from './10-CreatePresentationDefinitions'
|
|
3
|
+
import { FixCredentialClaimsReferencesUuid1741895822987 } from './11-FixCredentialClaimsReferenceUuid'
|
|
4
|
+
import { AddBitstringStatusListEnum1741895823000, CreateBitstringStatusList1741895823000 } from './12-CreateBitstringStatusList'
|
|
5
|
+
import { CreateDcqlQueryItem1726617600000 } from './13-CreateDcqlQueryItem'
|
|
2
6
|
import { CreateIssuanceBranding1659463079429 } from './2-CreateIssuanceBranding'
|
|
3
7
|
import { CreateContacts1690925872318 } from './3-CreateContacts'
|
|
4
8
|
import { CreateStatusList1693866470000 } from './4-CreateStatusList'
|
|
@@ -7,9 +11,6 @@ import { CreateDigitalCredential1708525189000 } from './6-CreateDigitalCredentia
|
|
|
7
11
|
import { CreateMachineStateStore1708098041262 } from './7-CreateMachineStateStore'
|
|
8
12
|
import { CreateContacts1708525189000 } from './8-CreateContacts'
|
|
9
13
|
import { CreateContacts1715761125000 } from './9-CreateContacts'
|
|
10
|
-
import { CreatePresentationDefinitions1716533767523 } from './10-CreatePresentationDefinitions'
|
|
11
|
-
import { FixCredentialClaimsReferencesUuid1741895822987 } from './11-FixCredentialClaimsReferenceUuid'
|
|
12
|
-
import { CreateBitstringStatusList1741895823000 } from './12-CreateBitstringStatusList'
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* The migrations array that SHOULD be used when initializing a TypeORM database connection.
|
|
@@ -27,11 +28,15 @@ export const DataStoreContactMigrations = [
|
|
|
27
28
|
CreateContacts1715761125000,
|
|
28
29
|
]
|
|
29
30
|
export const DataStoreIssuanceBrandingMigrations = [CreateIssuanceBranding1659463079429, FixCredentialClaimsReferencesUuid1741895822987]
|
|
30
|
-
export const DataStoreStatusListMigrations = [
|
|
31
|
+
export const DataStoreStatusListMigrations = [
|
|
32
|
+
CreateStatusList1693866470000,
|
|
33
|
+
AddBitstringStatusListEnum1741895823000,
|
|
34
|
+
CreateBitstringStatusList1741895823000,
|
|
35
|
+
]
|
|
31
36
|
export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
|
|
32
37
|
export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000]
|
|
33
38
|
export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
|
|
34
|
-
export const DataStorePresentationDefinitionMigrations = [CreatePresentationDefinitions1716533767523]
|
|
39
|
+
export const DataStorePresentationDefinitionMigrations = [CreatePresentationDefinitions1716533767523, CreateDcqlQueryItem1726617600000]
|
|
35
40
|
|
|
36
41
|
// All migrations together
|
|
37
42
|
export const DataStoreMigrations = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'
|
|
2
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
export class CreateContacts1659463079428 implements MigrationInterface {
|
|
5
5
|
name = 'CreateContacts1659463079428'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'
|
|
2
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
export class CreateIssuanceBranding1685628974232 implements MigrationInterface {
|
|
5
5
|
name = 'CreateIssuanceBranding1685628974232'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
1
|
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'
|
|
2
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
3
3
|
|
|
4
4
|
export class CreateContacts1690925872592 implements MigrationInterface {
|
|
5
5
|
name = 'CreateContacts1690925872592'
|
|
@@ -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"))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateDcqlQueryItemPG1726588800000 implements MigrationInterface {
|
|
4
|
+
name = 'CreateDcqlQueryItemPG1726588800000'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "DcqlQueryItem" (
|
|
9
|
+
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
|
10
|
+
"tenant_id" TEXT,
|
|
11
|
+
"query_id" TEXT NOT NULL,
|
|
12
|
+
"name" TEXT,
|
|
13
|
+
"version" TEXT NOT NULL,
|
|
14
|
+
"purpose" TEXT,
|
|
15
|
+
"query" TEXT NOT NULL,
|
|
16
|
+
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
17
|
+
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
|
18
|
+
CONSTRAINT "PK_DcqlQueryItem_id" PRIMARY KEY ("id"))
|
|
19
|
+
`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
23
|
+
await queryRunner.query(`DROP TABLE "DcqlQueryItem"`)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
2
|
|
|
3
|
-
export class
|
|
4
|
-
name = '
|
|
3
|
+
export class AddBitstringStatusListEnumPG1741895823000 implements MigrationInterface {
|
|
4
|
+
name = 'AddBitstringStatusListEnum1741895823000'
|
|
5
5
|
|
|
6
6
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
7
|
await queryRunner.startTransaction()
|
|
8
8
|
await queryRunner.query(`ALTER TYPE "StatusList_type_enum" ADD VALUE 'BitstringStatusList'`)
|
|
9
9
|
await queryRunner.commitTransaction()
|
|
10
|
+
}
|
|
10
11
|
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
14
|
+
// Note: Cannot remove enum value in Postgres without recreating the type
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class CreateBitstringStatusListPG1741895823000 implements MigrationInterface {
|
|
19
|
+
name = 'CreateBitstringStatusList1741895823000'
|
|
20
|
+
|
|
21
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
11
22
|
// Add BitstringStatusList columns to StatusList table
|
|
12
23
|
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "ttl" integer`)
|
|
13
24
|
await queryRunner.query(`ALTER TABLE "StatusList" ADD COLUMN "validFrom" TIMESTAMP`)
|
|
@@ -24,6 +35,7 @@ export class CreateBitstringStatusListPG1741895823000 implements MigrationInterf
|
|
|
24
35
|
|
|
25
36
|
// Add BitstringStatusListEntry specific columns to StatusListEntry table
|
|
26
37
|
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusPurpose" character varying`)
|
|
38
|
+
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "bitsPerStatus" integer DEFAULT 1`)
|
|
27
39
|
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusMessage" text`)
|
|
28
40
|
await queryRunner.query(`ALTER TABLE "StatusListEntry" ADD COLUMN "statusReference" text`)
|
|
29
41
|
|
|
@@ -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
|
+
}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
1
2
|
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
2
3
|
import type {
|
|
3
4
|
IAddStatusListArgs,
|
|
@@ -14,7 +15,6 @@ import type {
|
|
|
14
15
|
IUpdateStatusListIndexArgs,
|
|
15
16
|
} from '../types'
|
|
16
17
|
import { IStatusListEntity, IStatusListEntryEntity } from '../types'
|
|
17
|
-
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
18
18
|
|
|
19
19
|
export interface IStatusListStore {
|
|
20
20
|
getStatusList(args: IGetStatusListArgs): Promise<IStatusListEntity | IBitstringStatusListEntity>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type OrPromise, StatusListType } from '@sphereon/ssi-types'
|
|
2
2
|
import Debug from 'debug'
|
|
3
3
|
import { DataSource, In, type Repository } from 'typeorm'
|
|
4
|
-
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
5
|
-
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
4
|
import { BitstringStatusListEntryEntity } from '../entities/statusList/BitstringStatusListEntryEntity'
|
|
5
|
+
import { StatusListEntryEntity } from '../entities/statusList/StatusList2021EntryEntity'
|
|
6
|
+
import { BitstringStatusListEntity, OAuthStatusListEntity, StatusList2021Entity, StatusListEntity } from '../entities/statusList/StatusListEntities'
|
|
7
7
|
import {
|
|
8
8
|
IAddStatusListArgs,
|
|
9
9
|
IAddStatusListEntryArgs,
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
IStatusListEntryEntity,
|
|
21
21
|
IUpdateStatusListIndexArgs,
|
|
22
22
|
} from '../types'
|
|
23
|
-
import type { IStatusListStore } from './IStatusListStore'
|
|
24
23
|
import { statusListEntityFrom, statusListFrom } from '../utils/statusList/MappingUtils'
|
|
24
|
+
import type { IStatusListStore } from './IStatusListStore'
|
|
25
25
|
|
|
26
26
|
const debug = Debug('sphereon:ssi-sdk:data-store:status-list')
|
|
27
27
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
export * from './issuanceBranding/issuanceBranding'
|
|
2
|
-
export * from './issuanceBranding/IAbstractIssuanceBrandingStore'
|
|
3
|
-
export * from './contact/contact'
|
|
4
|
-
export * from './contact/IAbstractContactStore'
|
|
5
|
-
export * from './presentationDefinition/presentationDefinition'
|
|
6
|
-
export * from './presentationDefinition/IAbstractPDStore'
|
|
7
|
-
export * from './validation/validation'
|
|
8
1
|
export * from './statusList/statusList'
|
|
9
2
|
export * from './statusList/IAbstractStatusListStore'
|
|
10
|
-
export * from './eventLogger/IAbstractEventLoggerStore'
|
|
11
|
-
export * from './eventLogger/eventLogger'
|
|
12
|
-
export * from './machineState/IAbstractMachineStateStore'
|
|
13
|
-
export * from './digitalCredential'
|
|
14
|
-
export * from './digitalCredential/IAbstractDigitalCredentialStore'
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { FindOptionsWhere } from 'typeorm'
|
|
2
|
-
import {
|
|
3
|
-
BitstringStatusPurpose,
|
|
4
|
-
IBitstringStatusListEntryEntity,
|
|
5
|
-
IOAuthStatusListEntity,
|
|
6
|
-
IStatusList2021Entity,
|
|
7
|
-
IStatusListEntryEntity,
|
|
8
|
-
} from './statusList'
|
|
9
1
|
import {
|
|
10
2
|
CredentialProofFormat,
|
|
11
3
|
IIssuer,
|
|
@@ -16,8 +8,16 @@ import {
|
|
|
16
8
|
StatusListType,
|
|
17
9
|
StatusPurpose2021,
|
|
18
10
|
} from '@sphereon/ssi-types'
|
|
11
|
+
import { FindOptionsWhere } from 'typeorm'
|
|
12
|
+
import {
|
|
13
|
+
BitstringStatusPurpose,
|
|
14
|
+
IBitstringStatusListEntryEntity,
|
|
15
|
+
IOAuthStatusListEntity,
|
|
16
|
+
IStatusList2021Entity,
|
|
17
|
+
IStatusListEntryEntity,
|
|
18
|
+
} from './statusList'
|
|
19
19
|
|
|
20
|
-
export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[]
|
|
20
|
+
export type FindStatusListArgs = FindOptionsWhere<IStatusList2021Entity | IOAuthStatusListEntity>[] // TODO export our own FindOptionsWhere
|
|
21
21
|
export type FindStatusListEntryArgs = FindOptionsWhere<IStatusListEntryEntity>[] | FindOptionsWhere<IStatusListEntryEntity>
|
|
22
22
|
|
|
23
23
|
export interface IStatusListEntryAvailableArgs {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type ValidationConstraint } from '@sphereon/ssi-sdk.data-store-types'
|
|
1
2
|
import { ValidationError } from 'class-validator'
|
|
2
|
-
import { type ValidationConstraint } from '../types'
|
|
3
3
|
|
|
4
4
|
export const getConstraint = (validation: ValidationError): ValidationConstraint | undefined => {
|
|
5
5
|
if (validation.children && validation.children.length > 0) {
|