@sphereon/ssi-sdk.data-store 0.36.1-feature.integration.fides.88 → 0.36.1-feature.vdx24.einvoice.endpoints.122

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.data-store",
3
- "version": "0.36.1-feature.integration.fides.88+5eba8a30",
3
+ "version": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
4
4
  "source": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,13 +28,14 @@
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.36.1-feature.integration.fides.88+5eba8a30",
32
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.36.1-feature.integration.fides.88+5eba8a30",
33
- "@sphereon/ssi-sdk.agent-config": "0.36.1-feature.integration.fides.88+5eba8a30",
34
- "@sphereon/ssi-sdk.core": "0.36.1-feature.integration.fides.88+5eba8a30",
35
- "@sphereon/ssi-sdk.data-store-types": "0.36.1-feature.integration.fides.88+5eba8a30",
36
- "@sphereon/ssi-types": "0.36.1-feature.integration.fides.88+5eba8a30",
31
+ "@sphereon/ssi-sdk-ext.did-utils": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
32
+ "@sphereon/ssi-sdk-ext.identifier-resolution": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
33
+ "@sphereon/ssi-sdk.agent-config": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
34
+ "@sphereon/ssi-sdk.core": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
35
+ "@sphereon/ssi-sdk.data-store-types": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
36
+ "@sphereon/ssi-types": "0.36.1-feature.vdx24.einvoice.endpoints.122+88b3421b",
37
37
  "@veramo/core": "4.2.0",
38
+ "@veramo/data-store": "4.2.0",
38
39
  "@veramo/utils": "4.2.0",
39
40
  "blakejs": "^1.2.1",
40
41
  "class-validator": "0.14.1",
@@ -66,5 +67,5 @@
66
67
  "PostgreSQL",
67
68
  "Contact Store"
68
69
  ],
69
- "gitHead": "5eba8a30455af768df2d4129f6934bf5c1246715"
70
+ "gitHead": "88b3421b6e5bc5f630bf5f877c8db095c5850444"
70
71
  }
@@ -18,7 +18,7 @@ import { PartyEntity } from '../entities/contact/PartyEntity'
18
18
  import { PartyRelationshipEntity } from '../entities/contact/PartyRelationshipEntity'
19
19
  import { PartyTypeEntity } from '../entities/contact/PartyTypeEntity'
20
20
  import { PhysicalAddressEntity } from '../entities/contact/PhysicalAddressEntity'
21
- import { contactMetadataItemEntityFrom, DataStoreContactEntities, DataStoreMigrations, identityMetadataItemEntityFrom, partyTypeFrom } from '../index'
21
+ import { contactMetadataItemEntityFrom, DataStoreContactEntities, DataStoreEntitiesWithVeramo, DataStoreMigrationsWithVeramo, identityMetadataItemEntityFrom, partyTypeFrom } from '../index'
22
22
  import {
23
23
  IdentityOrigin,
24
24
  MetadataTypes,
@@ -64,9 +64,9 @@ describe('Database entities tests', (): void => {
64
64
  database: ':memory:',
65
65
  logging: ['info'],
66
66
  migrationsRun: false,
67
- migrations: DataStoreMigrations,
67
+ migrations: DataStoreMigrationsWithVeramo,
68
68
  synchronize: false,
69
- entities: DataStoreContactEntities,
69
+ entities: DataStoreEntitiesWithVeramo,
70
70
  }).initialize()
71
71
  await dbConnection.runMigrations()
72
72
  expect(await dbConnection.showMigrations()).toBeFalsy()
@@ -31,7 +31,7 @@ import { CredentialRole } from '@sphereon/ssi-types'
31
31
  import { DataSource } from 'typeorm'
32
32
  import { afterEach, beforeEach, describe, expect, it } from 'vitest'
33
33
  import { ContactStore } from '../contact/ContactStore'
34
- import { DataStoreContactEntities, DataStoreMigrations } from '../index'
34
+ import { DataStoreContactEntities, DataStoreEntitiesWithVeramo, DataStoreMigrationsWithVeramo } from '../index'
35
35
 
36
36
  describe('Contact store tests', (): void => {
37
37
  let dbConnection: DataSource
@@ -44,9 +44,9 @@ describe('Contact store tests', (): void => {
44
44
  database: ':memory:',
45
45
  logging: ['info'],
46
46
  migrationsRun: false,
47
- migrations: DataStoreMigrations,
47
+ migrations: DataStoreMigrationsWithVeramo,
48
48
  synchronize: false,
49
- entities: DataStoreContactEntities,
49
+ entities: DataStoreEntitiesWithVeramo,
50
50
  }).initialize()
51
51
  await dbConnection.runMigrations()
52
52
  expect(await dbConnection.showMigrations()).toBeFalsy()
@@ -6,7 +6,7 @@ import {
6
6
  credentialBrandingEntityFrom,
7
7
  CredentialLocaleBrandingEntity,
8
8
  credentialLocaleBrandingEntityFrom,
9
- DataStoreIssuanceBrandingEntities,
9
+ DataStoreIssuanceBrandingEntities, DataStoreEntitiesWithVeramo,
10
10
  IBasicCredentialBranding,
11
11
  IBasicCredentialLocaleBranding,
12
12
  IBasicIssuerBranding,
@@ -16,7 +16,7 @@ import {
16
16
  IssuerLocaleBrandingEntity,
17
17
  issuerLocaleBrandingEntityFrom,
18
18
  } from '../index'
19
- import { DataStoreMigrations } from '../migrations'
19
+ import { DataStoreMigrationsWithVeramo } from '../migrations'
20
20
 
21
21
  describe('Database entities tests', (): void => {
22
22
  let dbConnection: DataSource
@@ -28,9 +28,9 @@ describe('Database entities tests', (): void => {
28
28
  database: ':memory:',
29
29
  //logging: ['info'],
30
30
  migrationsRun: false,
31
- migrations: DataStoreMigrations,
31
+ migrations: DataStoreMigrationsWithVeramo,
32
32
  synchronize: false,
33
- entities: DataStoreIssuanceBrandingEntities,
33
+ entities: DataStoreEntitiesWithVeramo,
34
34
  }).initialize()
35
35
  await dbConnection.runMigrations()
36
36
  expect(await dbConnection.showMigrations()).toBeFalsy()
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
4
4
  import {
5
5
  BackgroundAttributesEntity,
6
6
  CredentialLocaleBrandingEntity,
7
- DataStoreIssuanceBrandingEntities,
7
+ DataStoreIssuanceBrandingEntities, DataStoreEntitiesWithVeramo,
8
8
  IAddCredentialLocaleBrandingArgs,
9
9
  IAddIssuerLocaleBrandingArgs,
10
10
  IBasicCredentialBranding,
@@ -26,7 +26,7 @@ import {
26
26
  TextAttributesEntity,
27
27
  } from '../index'
28
28
  import { IssuanceBrandingStore } from '../issuanceBranding/IssuanceBrandingStore'
29
- import { DataStoreMigrations } from '../migrations'
29
+ import { DataStoreMigrationsWithVeramo } from '../migrations'
30
30
 
31
31
  describe('Issuance branding store tests', (): void => {
32
32
  let dbConnection: DataSource
@@ -39,9 +39,9 @@ describe('Issuance branding store tests', (): void => {
39
39
  database: ':memory:',
40
40
  //logging: ['info'],
41
41
  migrationsRun: false,
42
- migrations: DataStoreMigrations,
42
+ migrations: DataStoreMigrationsWithVeramo,
43
43
  synchronize: false,
44
- entities: DataStoreIssuanceBrandingEntities,
44
+ entities: DataStoreEntitiesWithVeramo,
45
45
  }).initialize()
46
46
  await dbConnection.runMigrations()
47
47
  expect(await dbConnection.showMigrations()).toBeFalsy()
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Entities as VeramoDataStoreEntities } from '@veramo/data-store'
1
2
  import { BaseConfigEntity } from './entities/contact/BaseConfigEntity'
2
3
  import { BaseContactEntity } from './entities/contact/BaseContactEntity'
3
4
  import { ConnectionEntity } from './entities/contact/ConnectionEntity'
@@ -46,6 +47,7 @@ export { MachineStateStore } from './machineState/MachineStateStore'
46
47
  export { PDStore } from './presentationDefinition/PDStore'
47
48
  export {
48
49
  DataStoreMigrations,
50
+ DataStoreMigrationsWithVeramo,
49
51
  DataStoreEventLoggerMigrations,
50
52
  DataStoreContactMigrations,
51
53
  DataStoreDigitalCredentialMigrations,
@@ -53,6 +55,9 @@ export {
53
55
  DataStoreStatusListMigrations,
54
56
  DataStoreMachineStateMigrations,
55
57
  DataStorePresentationDefinitionMigrations,
58
+ DataStoreServiceMigrations,
59
+ VeramoDataStoreMigrations,
60
+ VeramoDataStoreEntities,
56
61
  } from './migrations'
57
62
  export * from './types'
58
63
  export * from './utils/contact/MappingUtils'
@@ -123,6 +128,12 @@ export const DataStoreEntities = [
123
128
  // ...DataStoreOid4vcStateEntities,
124
129
  ]
125
130
 
131
+ // All entities combined with Veramo entities if a party wants to enable them all at once
132
+ export const DataStoreEntitiesWithVeramo = [
133
+ ...VeramoDataStoreEntities,
134
+ ...DataStoreEntities,
135
+ ]
136
+
126
137
  export {
127
138
  BaseConfigEntity,
128
139
  ConnectionEntity,
@@ -0,0 +1,66 @@
1
+ import Debug, { Debugger } from 'debug'
2
+ import { DatabaseType, MigrationInterface, QueryRunner } from 'typeorm'
3
+ import { AddServiceMetadata1764000000001 } from '../postgres/1764000000001-AddServiceMetadata'
4
+ import { AddServiceMetadata1764000000002 } from '../sqlite/1764000000002-AddServiceMetadata'
5
+
6
+ const debug: Debugger = Debug('sphereon:ssi-sdk:migrations')
7
+
8
+ export class AddServiceMetadata1764000000000 implements MigrationInterface {
9
+ name: string = 'AddServiceMetadata1764000000000'
10
+
11
+ public async up(queryRunner: QueryRunner): Promise<void> {
12
+ debug('migration: adding metadata column to service table')
13
+ const dbType: DatabaseType = queryRunner.connection.driver.options.type
14
+
15
+ switch (dbType) {
16
+ case 'postgres': {
17
+ debug('using postgres migration file for AddServiceMetadata')
18
+ const mig: AddServiceMetadata1764000000001 = new AddServiceMetadata1764000000001()
19
+ await mig.up(queryRunner)
20
+ debug('Postgres migration statements for AddServiceMetadata executed')
21
+ return
22
+ }
23
+ case 'sqlite':
24
+ case 'expo':
25
+ case 'react-native': {
26
+ debug('using sqlite/react-native migration file for AddServiceMetadata')
27
+ const mig: AddServiceMetadata1764000000002 = new AddServiceMetadata1764000000002()
28
+ await mig.up(queryRunner)
29
+ debug('SQLite migration statements for AddServiceMetadata executed')
30
+ return
31
+ }
32
+ default:
33
+ return Promise.reject(
34
+ `Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddServiceMetadata. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,
35
+ )
36
+ }
37
+ }
38
+
39
+ public async down(queryRunner: QueryRunner): Promise<void> {
40
+ debug('migration: reverting metadata column from service table')
41
+ const dbType: DatabaseType = queryRunner.connection.driver.options.type
42
+
43
+ switch (dbType) {
44
+ case 'postgres': {
45
+ debug('using postgres migration file for AddServiceMetadata')
46
+ const mig: AddServiceMetadata1764000000001 = new AddServiceMetadata1764000000001()
47
+ await mig.down(queryRunner)
48
+ debug('Postgres migration statements for AddServiceMetadata reverted')
49
+ return
50
+ }
51
+ case 'sqlite':
52
+ case 'expo':
53
+ case 'react-native': {
54
+ debug('using sqlite/react-native migration file for AddServiceMetadata')
55
+ const mig: AddServiceMetadata1764000000002 = new AddServiceMetadata1764000000002()
56
+ await mig.down(queryRunner)
57
+ debug('SQLite migration statements for AddServiceMetadata reverted')
58
+ return
59
+ }
60
+ default:
61
+ return Promise.reject(
62
+ `Migrations are currently only supported for sqlite, react-native, expo, and postgres for AddServiceMetadata. Was ${dbType}. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now`,
63
+ )
64
+ }
65
+ }
66
+ }
@@ -1,9 +1,11 @@
1
+ import { migrations as VeramoDataStoreMigrations, Entities as VeramoDataStoreEntities } from '@veramo/data-store'
1
2
  import { CreateContacts1659463079429 } from './1-CreateContacts'
2
3
  import { CreatePresentationDefinitions1716533767523 } from './10-CreatePresentationDefinitions'
3
4
  import { FixCredentialClaimsReferencesUuid1741895822987 } from './11-FixCredentialClaimsReferenceUuid'
4
5
  import { AddBitstringStatusListEnum1741895823000, CreateBitstringStatusList1741895823000 } from './12-CreateBitstringStatusList'
5
6
  import { CreateDcqlQueryItem1726617600000 } from './13-CreateDcqlQueryItem'
6
7
  import { AddLinkedVpFields1763387280000 } from './14-AddLinkedVpFields'
8
+ import { AddServiceMetadata1764000000000 } from './15-AddServiceMetadata'
7
9
  import { CreateIssuanceBranding1659463079429 } from './2-CreateIssuanceBranding'
8
10
  import { CreateContacts1690925872318 } from './3-CreateContacts'
9
11
  import { CreateStatusList1693866470000 } from './4-CreateStatusList'
@@ -38,6 +40,7 @@ export const DataStoreEventLoggerMigrations = [CreateAuditEvents1701635835330]
38
40
  export const DataStoreDigitalCredentialMigrations = [CreateDigitalCredential1708525189000, AddLinkedVpFields1763387280000]
39
41
  export const DataStoreMachineStateMigrations = [CreateMachineStateStore1708098041262]
40
42
  export const DataStorePresentationDefinitionMigrations = [CreatePresentationDefinitions1716533767523, CreateDcqlQueryItem1726617600000]
43
+ export const DataStoreServiceMigrations = [AddServiceMetadata1764000000000]
41
44
 
42
45
  // All migrations together
43
46
  export const DataStoreMigrations = [
@@ -48,4 +51,14 @@ export const DataStoreMigrations = [
48
51
  ...DataStoreDigitalCredentialMigrations,
49
52
  ...DataStoreMachineStateMigrations,
50
53
  ...DataStorePresentationDefinitionMigrations,
54
+ ...DataStoreServiceMigrations,
51
55
  ]
56
+
57
+ // All migrations combined with Veramo migrations first - use this when you need both
58
+ export const DataStoreMigrationsWithVeramo = [
59
+ ...VeramoDataStoreMigrations,
60
+ ...DataStoreMigrations,
61
+ ]
62
+
63
+ // Re-export Veramo migrations and entities for convenience
64
+ export { VeramoDataStoreMigrations, VeramoDataStoreEntities }
@@ -1,5 +1,6 @@
1
1
  export {
2
2
  DataStoreMigrations,
3
+ DataStoreMigrationsWithVeramo,
3
4
  DataStoreEventLoggerMigrations,
4
5
  DataStoreContactMigrations,
5
6
  DataStoreIssuanceBrandingMigrations,
@@ -7,4 +8,7 @@ export {
7
8
  DataStoreDigitalCredentialMigrations,
8
9
  DataStoreMachineStateMigrations,
9
10
  DataStorePresentationDefinitionMigrations,
11
+ DataStoreServiceMigrations,
12
+ VeramoDataStoreMigrations,
13
+ VeramoDataStoreEntities,
10
14
  } from './generic'
@@ -0,0 +1,44 @@
1
+ import Debug, { Debugger } from 'debug'
2
+ import { MigrationInterface, QueryRunner } from 'typeorm'
3
+
4
+ const debug: Debugger = Debug('sphereon:ssi-sdk:migrations')
5
+
6
+ export class AddServiceMetadata1764000000001 implements MigrationInterface {
7
+ name = 'AddServiceMetadata1764000000001'
8
+
9
+ public async up(queryRunner: QueryRunner): Promise<void> {
10
+ // Check if the service table exists (created by Veramo migrations)
11
+ const table = await queryRunner.getTable('service')
12
+ if (!table) {
13
+ // Service table doesn't exist - Veramo DID Manager is not in use
14
+ // Skip this migration as there's no service table to modify
15
+ debug(
16
+ 'AddServiceMetadata: Skipping migration - service table does not exist. ' +
17
+ 'This is expected if Veramo DID Manager is not being used. ' +
18
+ 'If you need service metadata support, ensure Veramo migrations run before SSI-SDK migrations.'
19
+ )
20
+ console.warn(
21
+ '[SSI-SDK Migration] AddServiceMetadata: Skipping - service table does not exist (Veramo DID Manager not in use)'
22
+ )
23
+ return
24
+ }
25
+
26
+ await queryRunner.query(`
27
+ ALTER TABLE "service"
28
+ ADD COLUMN IF NOT EXISTS "metadata" jsonb
29
+ `)
30
+ debug('AddServiceMetadata: Added metadata column to service table')
31
+ }
32
+
33
+ public async down(queryRunner: QueryRunner): Promise<void> {
34
+ const table = await queryRunner.getTable('service')
35
+ if (!table) {
36
+ return
37
+ }
38
+
39
+ await queryRunner.query(`
40
+ ALTER TABLE "service"
41
+ DROP COLUMN IF EXISTS "metadata"
42
+ `)
43
+ }
44
+ }
@@ -0,0 +1,41 @@
1
+ import Debug, { Debugger } from 'debug'
2
+ import { MigrationInterface, QueryRunner } from 'typeorm'
3
+
4
+ const debug: Debugger = Debug('sphereon:ssi-sdk:migrations')
5
+
6
+ export class AddServiceMetadata1764000000002 implements MigrationInterface {
7
+ name = 'AddServiceMetadata1764000000002'
8
+
9
+ public async up(queryRunner: QueryRunner): Promise<void> {
10
+ // Check if the service table exists (created by Veramo migrations)
11
+ const table = await queryRunner.getTable('service')
12
+ if (!table) {
13
+ // Service table doesn't exist - Veramo DID Manager is not in use
14
+ // Skip this migration as there's no service table to modify
15
+ debug(
16
+ 'AddServiceMetadata: Skipping migration - service table does not exist. ' +
17
+ 'This is expected if Veramo DID Manager is not being used. ' +
18
+ 'If you need service metadata support, ensure Veramo migrations run before SSI-SDK migrations.'
19
+ )
20
+ console.warn(
21
+ '[SSI-SDK Migration] AddServiceMetadata: Skipping - service table does not exist (Veramo DID Manager not in use)'
22
+ )
23
+ return
24
+ }
25
+
26
+ // Check if metadata column already exists
27
+ const hasMetadataColumn = table.columns.some((col) => col.name === 'metadata')
28
+ if (!hasMetadataColumn) {
29
+ await queryRunner.query(`
30
+ ALTER TABLE "service"
31
+ ADD COLUMN "metadata" text
32
+ `)
33
+ debug('AddServiceMetadata: Added metadata column to service table')
34
+ }
35
+ }
36
+
37
+ public async down(queryRunner: QueryRunner): Promise<void> {
38
+ // SQLite doesn't support DROP COLUMN directly
39
+ // Also, if the service table doesn't exist, nothing to do
40
+ }
41
+ }