@sphereon/ssi-sdk.data-store 0.23.5-unstable.88 → 0.24.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/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/index.d.ts +0 -2
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +1 -4
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/contact.entities.test.ts +2542 -2542
- package/src/__tests__/contact.store.test.ts +2471 -2471
- package/src/__tests__/digitalCredential.entities.test.ts +254 -254
- package/src/__tests__/digitalCredential.store.test.ts +294 -294
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
- package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
- package/src/__tests__/machineState.entities.test.ts +51 -51
- package/src/__tests__/machineState.store.test.ts +174 -174
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +723 -723
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
- package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
- package/src/entities/contact/BaseContactEntity.ts +39 -39
- package/src/entities/contact/ConnectionEntity.ts +29 -29
- package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
- package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
- package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
- package/src/entities/contact/IdentityEntity.ts +97 -97
- package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
- package/src/entities/contact/NaturalPersonEntity.ts +38 -38
- package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
- package/src/entities/contact/OrganizationEntity.ts +34 -34
- package/src/entities/contact/PartyEntity.ts +110 -110
- package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
- package/src/entities/contact/PartyTypeEntity.ts +62 -62
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
- package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +141 -154
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/index.ts +33 -36
- package/src/migrations/index.ts +9 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/statusList/StatusListStore.ts +237 -237
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +237 -237
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
- package/src/types/digitalCredential/digitalCredential.ts +46 -46
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +10 -12
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +385 -385
- package/src/utils/digitalCredential/MappingUtils.ts +122 -122
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
- package/dist/pd/AbstractPDStore.d.ts +0 -10
- package/dist/pd/AbstractPDStore.d.ts.map +0 -1
- package/dist/pd/AbstractPDStore.js +0 -7
- package/dist/pd/AbstractPDStore.js.map +0 -1
- package/dist/pd/PDStore.d.ts +0 -14
- package/dist/pd/PDStore.d.ts.map +0 -1
- package/dist/pd/PDStore.js +0 -90
- package/dist/pd/PDStore.js.map +0 -1
- package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
- package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
- package/dist/types/pd/IAbstractPDStore.js +0 -3
- package/dist/types/pd/IAbstractPDStore.js.map +0 -1
- package/dist/types/pd/pd.d.ts +0 -15
- package/dist/types/pd/pd.d.ts.map +0 -1
- package/dist/types/pd/pd.js +0 -3
- package/dist/types/pd/pd.js.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
- package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
- package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
- package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
- package/src/pd/AbstractPDStore.ts +0 -10
- package/src/pd/PDStore.ts +0 -103
- package/src/types/pd/IAbstractPDStore.ts +0 -19
- package/src/types/pd/pd.ts +0 -16
- package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseEntity,
|
|
3
|
-
BeforeInsert,
|
|
4
|
-
BeforeUpdate,
|
|
5
|
-
Column,
|
|
6
|
-
CreateDateColumn,
|
|
7
|
-
Entity,
|
|
8
|
-
Index,
|
|
9
|
-
OneToMany,
|
|
10
|
-
PrimaryGeneratedColumn,
|
|
11
|
-
UpdateDateColumn,
|
|
12
|
-
} from 'typeorm'
|
|
13
|
-
import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
14
|
-
import { IssuerLocaleBrandingEntity, issuerLocaleBrandingEntityFrom } from './IssuerLocaleBrandingEntity'
|
|
15
|
-
import { IBasicIssuerBranding, IBasicIssuerLocaleBranding } from '../../types'
|
|
16
|
-
|
|
17
|
-
@Entity('IssuerBranding')
|
|
18
|
-
@Index('IDX_IssuerBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
|
|
19
|
-
export class IssuerBrandingEntity extends BaseEntity {
|
|
20
|
-
@PrimaryGeneratedColumn('uuid')
|
|
21
|
-
id!: string
|
|
22
|
-
|
|
23
|
-
@Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: true })
|
|
24
|
-
@IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
|
|
25
|
-
issuerCorrelationId!: string
|
|
26
|
-
|
|
27
|
-
@OneToMany(
|
|
28
|
-
() => IssuerLocaleBrandingEntity,
|
|
29
|
-
(issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.issuerBranding,
|
|
30
|
-
{
|
|
31
|
-
cascade: true,
|
|
32
|
-
onDelete: 'CASCADE',
|
|
33
|
-
eager: true,
|
|
34
|
-
nullable: false,
|
|
35
|
-
},
|
|
36
|
-
)
|
|
37
|
-
@ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
|
|
38
|
-
localeBranding!: Array<IssuerLocaleBrandingEntity>
|
|
39
|
-
|
|
40
|
-
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
41
|
-
createdAt!: Date
|
|
42
|
-
|
|
43
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
44
|
-
lastUpdatedAt!: Date
|
|
45
|
-
|
|
46
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
47
|
-
@BeforeInsert()
|
|
48
|
-
@BeforeUpdate()
|
|
49
|
-
updateUpdatedDate(): void {
|
|
50
|
-
this.lastUpdatedAt = new Date()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@BeforeInsert()
|
|
54
|
-
@BeforeUpdate()
|
|
55
|
-
async validate(): Promise<undefined> {
|
|
56
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
57
|
-
if (validation.length > 0) {
|
|
58
|
-
return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
|
|
59
|
-
}
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const issuerBrandingEntityFrom = (args: IBasicIssuerBranding): IssuerBrandingEntity => {
|
|
65
|
-
const issuerBrandingEntity: IssuerBrandingEntity = new IssuerBrandingEntity()
|
|
66
|
-
issuerBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
|
|
67
|
-
issuerBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) =>
|
|
68
|
-
issuerLocaleBrandingEntityFrom(localeBranding),
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
return issuerBrandingEntity
|
|
72
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
BaseEntity,
|
|
3
|
+
BeforeInsert,
|
|
4
|
+
BeforeUpdate,
|
|
5
|
+
Column,
|
|
6
|
+
CreateDateColumn,
|
|
7
|
+
Entity,
|
|
8
|
+
Index,
|
|
9
|
+
OneToMany,
|
|
10
|
+
PrimaryGeneratedColumn,
|
|
11
|
+
UpdateDateColumn,
|
|
12
|
+
} from 'typeorm'
|
|
13
|
+
import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
14
|
+
import { IssuerLocaleBrandingEntity, issuerLocaleBrandingEntityFrom } from './IssuerLocaleBrandingEntity'
|
|
15
|
+
import { IBasicIssuerBranding, IBasicIssuerLocaleBranding } from '../../types'
|
|
16
|
+
|
|
17
|
+
@Entity('IssuerBranding')
|
|
18
|
+
@Index('IDX_IssuerBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
|
|
19
|
+
export class IssuerBrandingEntity extends BaseEntity {
|
|
20
|
+
@PrimaryGeneratedColumn('uuid')
|
|
21
|
+
id!: string
|
|
22
|
+
|
|
23
|
+
@Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: true })
|
|
24
|
+
@IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
|
|
25
|
+
issuerCorrelationId!: string
|
|
26
|
+
|
|
27
|
+
@OneToMany(
|
|
28
|
+
() => IssuerLocaleBrandingEntity,
|
|
29
|
+
(issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.issuerBranding,
|
|
30
|
+
{
|
|
31
|
+
cascade: true,
|
|
32
|
+
onDelete: 'CASCADE',
|
|
33
|
+
eager: true,
|
|
34
|
+
nullable: false,
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
@ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
|
|
38
|
+
localeBranding!: Array<IssuerLocaleBrandingEntity>
|
|
39
|
+
|
|
40
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
41
|
+
createdAt!: Date
|
|
42
|
+
|
|
43
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
44
|
+
lastUpdatedAt!: Date
|
|
45
|
+
|
|
46
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
47
|
+
@BeforeInsert()
|
|
48
|
+
@BeforeUpdate()
|
|
49
|
+
updateUpdatedDate(): void {
|
|
50
|
+
this.lastUpdatedAt = new Date()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@BeforeInsert()
|
|
54
|
+
@BeforeUpdate()
|
|
55
|
+
async validate(): Promise<undefined> {
|
|
56
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
57
|
+
if (validation.length > 0) {
|
|
58
|
+
return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
|
|
59
|
+
}
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const issuerBrandingEntityFrom = (args: IBasicIssuerBranding): IssuerBrandingEntity => {
|
|
65
|
+
const issuerBrandingEntity: IssuerBrandingEntity = new IssuerBrandingEntity()
|
|
66
|
+
issuerBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
|
|
67
|
+
issuerBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) =>
|
|
68
|
+
issuerLocaleBrandingEntityFrom(localeBranding),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return issuerBrandingEntity
|
|
72
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @class MachineStateInfoEntity
|
|
5
|
-
* Represents a machine state. It allows to continue a machine at a later point in time at the point it was left of
|
|
6
|
-
*
|
|
7
|
-
* @param {string} instanceId - The instance ID of the machine state.
|
|
8
|
-
* @param {string} [sessionId] - The session ID of the machine state. (optional)
|
|
9
|
-
* @param {string} machineName - The name of the machine.
|
|
10
|
-
* @param {string} [latestStateName] - The name of the latest state. (optional)
|
|
11
|
-
* @param {string} latestEventType - The type of the latest event.
|
|
12
|
-
* @param {string} state - The current state of the machine.
|
|
13
|
-
* @param {Date} createdAt - The date and time when the machine state was created.
|
|
14
|
-
* @param {Date} updatedAt - The date and time when the machine state was last updated.
|
|
15
|
-
* @param {number} updatedCount - The number of times the machine state has been updated.
|
|
16
|
-
* @param {Date} [expiresAt] - The date and time when the machine state expires. (optional)
|
|
17
|
-
* @param {Date} [completedAt] - The date and time when the machine state was completed. (optional)
|
|
18
|
-
* @param {string} [tenantId] - The ID of the tenant associated with the machine state. (optional)
|
|
19
|
-
*/
|
|
20
|
-
@Entity('MachineStateInfoEntity')
|
|
21
|
-
export class MachineStateInfoEntity extends BaseEntity {
|
|
22
|
-
@PrimaryColumn({ name: 'instance_id', type: 'varchar', nullable: false })
|
|
23
|
-
instanceId!: string
|
|
24
|
-
|
|
25
|
-
@Column({ name: 'session_id', type: 'varchar', nullable: true })
|
|
26
|
-
sessionId?: string
|
|
27
|
-
|
|
28
|
-
// Xstate moved to name instead of instanceId for V5. Also makes more sense
|
|
29
|
-
@Column({ name: 'machine_name', type: 'varchar', nullable: false })
|
|
30
|
-
machineName!: string
|
|
31
|
-
|
|
32
|
-
@Column({ name: 'latest_state_name', type: 'varchar', nullable: true })
|
|
33
|
-
latestStateName?: string
|
|
34
|
-
|
|
35
|
-
@Column({ name: 'latest_event_type', type: 'varchar', nullable: false })
|
|
36
|
-
latestEventType!: string
|
|
37
|
-
|
|
38
|
-
@Column({ name: 'state', type: 'text', nullable: false })
|
|
39
|
-
state!: string
|
|
40
|
-
|
|
41
|
-
@CreateDateColumn({ name: 'created_at', type: 'datetime', nullable: false })
|
|
42
|
-
createdAt!: Date
|
|
43
|
-
|
|
44
|
-
@UpdateDateColumn({ name: 'updated_at', type: 'datetime', nullable: false })
|
|
45
|
-
updatedAt!: Date
|
|
46
|
-
|
|
47
|
-
@Column({ name: 'updated_count', type: 'integer', nullable: false })
|
|
48
|
-
updatedCount!: number
|
|
49
|
-
|
|
50
|
-
@Column({ name: 'expires_at', type: 'datetime', nullable: true })
|
|
51
|
-
expiresAt?: Date
|
|
52
|
-
|
|
53
|
-
@Column({ name: 'completed_at', type: 'datetime', nullable: true })
|
|
54
|
-
completedAt?: Date
|
|
55
|
-
|
|
56
|
-
@Column({ name: 'tenant_id', type: 'varchar', nullable: true })
|
|
57
|
-
tenantId?: string
|
|
58
|
-
}
|
|
1
|
+
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class MachineStateInfoEntity
|
|
5
|
+
* Represents a machine state. It allows to continue a machine at a later point in time at the point it was left of
|
|
6
|
+
*
|
|
7
|
+
* @param {string} instanceId - The instance ID of the machine state.
|
|
8
|
+
* @param {string} [sessionId] - The session ID of the machine state. (optional)
|
|
9
|
+
* @param {string} machineName - The name of the machine.
|
|
10
|
+
* @param {string} [latestStateName] - The name of the latest state. (optional)
|
|
11
|
+
* @param {string} latestEventType - The type of the latest event.
|
|
12
|
+
* @param {string} state - The current state of the machine.
|
|
13
|
+
* @param {Date} createdAt - The date and time when the machine state was created.
|
|
14
|
+
* @param {Date} updatedAt - The date and time when the machine state was last updated.
|
|
15
|
+
* @param {number} updatedCount - The number of times the machine state has been updated.
|
|
16
|
+
* @param {Date} [expiresAt] - The date and time when the machine state expires. (optional)
|
|
17
|
+
* @param {Date} [completedAt] - The date and time when the machine state was completed. (optional)
|
|
18
|
+
* @param {string} [tenantId] - The ID of the tenant associated with the machine state. (optional)
|
|
19
|
+
*/
|
|
20
|
+
@Entity('MachineStateInfoEntity')
|
|
21
|
+
export class MachineStateInfoEntity extends BaseEntity {
|
|
22
|
+
@PrimaryColumn({ name: 'instance_id', type: 'varchar', nullable: false })
|
|
23
|
+
instanceId!: string
|
|
24
|
+
|
|
25
|
+
@Column({ name: 'session_id', type: 'varchar', nullable: true })
|
|
26
|
+
sessionId?: string
|
|
27
|
+
|
|
28
|
+
// Xstate moved to name instead of instanceId for V5. Also makes more sense
|
|
29
|
+
@Column({ name: 'machine_name', type: 'varchar', nullable: false })
|
|
30
|
+
machineName!: string
|
|
31
|
+
|
|
32
|
+
@Column({ name: 'latest_state_name', type: 'varchar', nullable: true })
|
|
33
|
+
latestStateName?: string
|
|
34
|
+
|
|
35
|
+
@Column({ name: 'latest_event_type', type: 'varchar', nullable: false })
|
|
36
|
+
latestEventType!: string
|
|
37
|
+
|
|
38
|
+
@Column({ name: 'state', type: 'text', nullable: false })
|
|
39
|
+
state!: string
|
|
40
|
+
|
|
41
|
+
@CreateDateColumn({ name: 'created_at', type: 'datetime', nullable: false })
|
|
42
|
+
createdAt!: Date
|
|
43
|
+
|
|
44
|
+
@UpdateDateColumn({ name: 'updated_at', type: 'datetime', nullable: false })
|
|
45
|
+
updatedAt!: Date
|
|
46
|
+
|
|
47
|
+
@Column({ name: 'updated_count', type: 'integer', nullable: false })
|
|
48
|
+
updatedCount!: number
|
|
49
|
+
|
|
50
|
+
@Column({ name: 'expires_at', type: 'datetime', nullable: true })
|
|
51
|
+
expiresAt?: Date
|
|
52
|
+
|
|
53
|
+
@Column({ name: 'completed_at', type: 'datetime', nullable: true })
|
|
54
|
+
completedAt?: Date
|
|
55
|
+
|
|
56
|
+
@Column({ name: 'tenant_id', type: 'varchar', nullable: true })
|
|
57
|
+
tenantId?: string
|
|
58
|
+
}
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IIssuer,
|
|
3
|
-
JwtDecodedVerifiableCredential,
|
|
4
|
-
StatusListCredentialIdMode,
|
|
5
|
-
StatusListDriverType,
|
|
6
|
-
StatusListIndexingDirection,
|
|
7
|
-
StatusListType,
|
|
8
|
-
StatusPurpose2021,
|
|
9
|
-
W3CVerifiableCredential,
|
|
10
|
-
} from '@sphereon/ssi-types'
|
|
11
|
-
import { ProofFormat } from '@veramo/core'
|
|
12
|
-
import { BaseEntity, Column, Entity, OneToMany, PrimaryColumn, Unique } from 'typeorm'
|
|
13
|
-
import { StatusListEntryEntity } from './StatusList2021EntryEntity'
|
|
14
|
-
|
|
15
|
-
@Entity('StatusList')
|
|
16
|
-
@Unique('UQ_correlationId', ['correlationId'])
|
|
17
|
-
export class StatusListEntity extends BaseEntity {
|
|
18
|
-
@PrimaryColumn({ name: 'id', type: 'varchar' })
|
|
19
|
-
id!: string
|
|
20
|
-
|
|
21
|
-
@Column({ name: 'correlationId', type: 'varchar', nullable: false })
|
|
22
|
-
correlationId!: string
|
|
23
|
-
|
|
24
|
-
@Column({ name: 'length', nullable: false, unique: false })
|
|
25
|
-
length!: number
|
|
26
|
-
|
|
27
|
-
@Column({
|
|
28
|
-
name: 'issuer',
|
|
29
|
-
type: 'text',
|
|
30
|
-
nullable: false,
|
|
31
|
-
unique: false,
|
|
32
|
-
transformer: {
|
|
33
|
-
from(value: string): string | IIssuer {
|
|
34
|
-
if (value?.trim()?.startsWith('{')) {
|
|
35
|
-
return JSON.parse(value)
|
|
36
|
-
}
|
|
37
|
-
return value
|
|
38
|
-
},
|
|
39
|
-
to(value: string | IIssuer): string {
|
|
40
|
-
if (typeof value === 'string') {
|
|
41
|
-
return value
|
|
42
|
-
}
|
|
43
|
-
return JSON.stringify(value)
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
issuer!: string | IIssuer
|
|
48
|
-
|
|
49
|
-
@Column('simple-enum', { name: 'type', enum: StatusListType, nullable: false, default: StatusListType.StatusList2021 })
|
|
50
|
-
type!: StatusListType
|
|
51
|
-
|
|
52
|
-
@Column('simple-enum', { name: 'driverType', enum: StatusListDriverType, nullable: false, default: StatusListDriverType.AGENT_TYPEORM })
|
|
53
|
-
driverType!: StatusListDriverType
|
|
54
|
-
|
|
55
|
-
@Column('simple-enum', {
|
|
56
|
-
name: 'credentialIdMode',
|
|
57
|
-
enum: StatusListCredentialIdMode,
|
|
58
|
-
nullable: false,
|
|
59
|
-
default: StatusListCredentialIdMode.ISSUANCE,
|
|
60
|
-
})
|
|
61
|
-
credentialIdMode!: StatusListCredentialIdMode
|
|
62
|
-
|
|
63
|
-
@Column({ type: 'varchar', name: 'proofFormat', enum: ['lds', 'jwt'], nullable: false, default: 'lds' })
|
|
64
|
-
proofFormat!: ProofFormat
|
|
65
|
-
|
|
66
|
-
@Column({ type: 'varchar', name: 'indexingDirection', enum: ['rightToLeft'], nullable: false, default: 'rightToLeft' })
|
|
67
|
-
indexingDirection!: StatusListIndexingDirection
|
|
68
|
-
|
|
69
|
-
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
|
|
70
|
-
statusPurpose!: StatusPurpose2021
|
|
71
|
-
|
|
72
|
-
@Column({
|
|
73
|
-
name: 'statusListCredential',
|
|
74
|
-
type: 'text',
|
|
75
|
-
nullable: true,
|
|
76
|
-
unique: false,
|
|
77
|
-
transformer: {
|
|
78
|
-
from(value: string): W3CVerifiableCredential | JwtDecodedVerifiableCredential {
|
|
79
|
-
if (value?.startsWith('ey')) {
|
|
80
|
-
return value
|
|
81
|
-
}
|
|
82
|
-
return JSON.parse(value)
|
|
83
|
-
},
|
|
84
|
-
to(value: W3CVerifiableCredential | JwtDecodedVerifiableCredential): string {
|
|
85
|
-
if (typeof value === 'string') {
|
|
86
|
-
return value
|
|
87
|
-
}
|
|
88
|
-
return JSON.stringify(value)
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
statusListCredential?: W3CVerifiableCredential | JwtDecodedVerifiableCredential
|
|
93
|
-
|
|
94
|
-
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
95
|
-
statusListEntries!: StatusListEntryEntity[]
|
|
96
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
IIssuer,
|
|
3
|
+
JwtDecodedVerifiableCredential,
|
|
4
|
+
StatusListCredentialIdMode,
|
|
5
|
+
StatusListDriverType,
|
|
6
|
+
StatusListIndexingDirection,
|
|
7
|
+
StatusListType,
|
|
8
|
+
StatusPurpose2021,
|
|
9
|
+
W3CVerifiableCredential,
|
|
10
|
+
} from '@sphereon/ssi-types'
|
|
11
|
+
import { ProofFormat } from '@veramo/core'
|
|
12
|
+
import { BaseEntity, Column, Entity, OneToMany, PrimaryColumn, Unique } from 'typeorm'
|
|
13
|
+
import { StatusListEntryEntity } from './StatusList2021EntryEntity'
|
|
14
|
+
|
|
15
|
+
@Entity('StatusList')
|
|
16
|
+
@Unique('UQ_correlationId', ['correlationId'])
|
|
17
|
+
export class StatusListEntity extends BaseEntity {
|
|
18
|
+
@PrimaryColumn({ name: 'id', type: 'varchar' })
|
|
19
|
+
id!: string
|
|
20
|
+
|
|
21
|
+
@Column({ name: 'correlationId', type: 'varchar', nullable: false })
|
|
22
|
+
correlationId!: string
|
|
23
|
+
|
|
24
|
+
@Column({ name: 'length', nullable: false, unique: false })
|
|
25
|
+
length!: number
|
|
26
|
+
|
|
27
|
+
@Column({
|
|
28
|
+
name: 'issuer',
|
|
29
|
+
type: 'text',
|
|
30
|
+
nullable: false,
|
|
31
|
+
unique: false,
|
|
32
|
+
transformer: {
|
|
33
|
+
from(value: string): string | IIssuer {
|
|
34
|
+
if (value?.trim()?.startsWith('{')) {
|
|
35
|
+
return JSON.parse(value)
|
|
36
|
+
}
|
|
37
|
+
return value
|
|
38
|
+
},
|
|
39
|
+
to(value: string | IIssuer): string {
|
|
40
|
+
if (typeof value === 'string') {
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
return JSON.stringify(value)
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
issuer!: string | IIssuer
|
|
48
|
+
|
|
49
|
+
@Column('simple-enum', { name: 'type', enum: StatusListType, nullable: false, default: StatusListType.StatusList2021 })
|
|
50
|
+
type!: StatusListType
|
|
51
|
+
|
|
52
|
+
@Column('simple-enum', { name: 'driverType', enum: StatusListDriverType, nullable: false, default: StatusListDriverType.AGENT_TYPEORM })
|
|
53
|
+
driverType!: StatusListDriverType
|
|
54
|
+
|
|
55
|
+
@Column('simple-enum', {
|
|
56
|
+
name: 'credentialIdMode',
|
|
57
|
+
enum: StatusListCredentialIdMode,
|
|
58
|
+
nullable: false,
|
|
59
|
+
default: StatusListCredentialIdMode.ISSUANCE,
|
|
60
|
+
})
|
|
61
|
+
credentialIdMode!: StatusListCredentialIdMode
|
|
62
|
+
|
|
63
|
+
@Column({ type: 'varchar', name: 'proofFormat', enum: ['lds', 'jwt'], nullable: false, default: 'lds' })
|
|
64
|
+
proofFormat!: ProofFormat
|
|
65
|
+
|
|
66
|
+
@Column({ type: 'varchar', name: 'indexingDirection', enum: ['rightToLeft'], nullable: false, default: 'rightToLeft' })
|
|
67
|
+
indexingDirection!: StatusListIndexingDirection
|
|
68
|
+
|
|
69
|
+
@Column({ type: 'varchar', name: 'statusPurpose', nullable: false, default: 'revocation' })
|
|
70
|
+
statusPurpose!: StatusPurpose2021
|
|
71
|
+
|
|
72
|
+
@Column({
|
|
73
|
+
name: 'statusListCredential',
|
|
74
|
+
type: 'text',
|
|
75
|
+
nullable: true,
|
|
76
|
+
unique: false,
|
|
77
|
+
transformer: {
|
|
78
|
+
from(value: string): W3CVerifiableCredential | JwtDecodedVerifiableCredential {
|
|
79
|
+
if (value?.startsWith('ey')) {
|
|
80
|
+
return value
|
|
81
|
+
}
|
|
82
|
+
return JSON.parse(value)
|
|
83
|
+
},
|
|
84
|
+
to(value: W3CVerifiableCredential | JwtDecodedVerifiableCredential): string {
|
|
85
|
+
if (typeof value === 'string') {
|
|
86
|
+
return value
|
|
87
|
+
}
|
|
88
|
+
return JSON.stringify(value)
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
statusListCredential?: W3CVerifiableCredential | JwtDecodedVerifiableCredential
|
|
93
|
+
|
|
94
|
+
@OneToMany((type) => StatusListEntryEntity, (entry) => entry.statusList)
|
|
95
|
+
statusListEntries!: StatusListEntryEntity[]
|
|
96
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
|
|
2
|
-
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
3
|
-
|
|
4
|
-
export abstract class AbstractEventLoggerStore {
|
|
5
|
-
abstract getAuditEvents(args: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
|
|
6
|
-
abstract storeAuditEvent(args: StoreAuditEventArgs): Promise<AuditLoggingEvent>
|
|
7
|
-
}
|
|
1
|
+
import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
|
|
2
|
+
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
3
|
+
|
|
4
|
+
export abstract class AbstractEventLoggerStore {
|
|
5
|
+
abstract getAuditEvents(args: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
|
|
6
|
+
abstract storeAuditEvent(args: StoreAuditEventArgs): Promise<AuditLoggingEvent>
|
|
7
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import Debug, { Debugger } from 'debug'
|
|
2
|
-
import { DataSource } from 'typeorm'
|
|
3
|
-
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
4
|
-
import { OrPromise } from '@sphereon/ssi-types'
|
|
5
|
-
import { AbstractEventLoggerStore } from './AbstractEventLoggerStore'
|
|
6
|
-
import { AuditEventEntity, auditEventEntityFrom } from '../entities/eventLogger/AuditEventEntity'
|
|
7
|
-
import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
|
|
8
|
-
|
|
9
|
-
const debug: Debugger = Debug('sphereon:ssi-sdk:event-store')
|
|
10
|
-
|
|
11
|
-
export class EventLoggerStore extends AbstractEventLoggerStore {
|
|
12
|
-
private readonly dbConnection: OrPromise<DataSource>
|
|
13
|
-
|
|
14
|
-
constructor(dbConnection: OrPromise<DataSource>) {
|
|
15
|
-
super()
|
|
16
|
-
this.dbConnection = dbConnection
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getAuditEvents = async (args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>> => {
|
|
20
|
-
const connection: DataSource = await this.dbConnection // TODO apply everywhere
|
|
21
|
-
debug('Getting audit events', args)
|
|
22
|
-
const result: Array<AuditEventEntity> = await connection.getRepository(AuditEventEntity).find({
|
|
23
|
-
...(args?.filter && { where: args?.filter }),
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
return result.map((event: AuditEventEntity) => this.auditEventFrom(event))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
storeAuditEvent = async (args: StoreAuditEventArgs): Promise<AuditLoggingEvent> => {
|
|
30
|
-
const { event } = args
|
|
31
|
-
|
|
32
|
-
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(event)
|
|
33
|
-
const connection: DataSource = await this.dbConnection
|
|
34
|
-
debug('Storing audit event', auditEventEntity)
|
|
35
|
-
const createdResult: AuditEventEntity = await connection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
36
|
-
|
|
37
|
-
return this.auditEventFrom(createdResult)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private auditEventFrom = (event: AuditEventEntity): AuditLoggingEvent => {
|
|
41
|
-
return {
|
|
42
|
-
id: event.id,
|
|
43
|
-
description: event.description,
|
|
44
|
-
timestamp: event.timestamp,
|
|
45
|
-
level: event.level,
|
|
46
|
-
correlationId: event.correlationId,
|
|
47
|
-
actionType: event.actionType,
|
|
48
|
-
actionSubType: event.actionSubType,
|
|
49
|
-
initiatorType: event.initiatorType,
|
|
50
|
-
partyAlias: event.partyAlias,
|
|
51
|
-
partyCorrelationId: event.partyCorrelationId,
|
|
52
|
-
partyCorrelationType: event.partyCorrelationType,
|
|
53
|
-
subSystemType: event.subSystemType,
|
|
54
|
-
system: event.system,
|
|
55
|
-
systemAlias: event.systemAlias,
|
|
56
|
-
systemCorrelationId: event.systemCorrelationId,
|
|
57
|
-
systemCorrelationIdType: event.systemCorrelationIdType,
|
|
58
|
-
...(event.data && { data: JSON.parse(event.data) }),
|
|
59
|
-
...(event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }),
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
import Debug, { Debugger } from 'debug'
|
|
2
|
+
import { DataSource } from 'typeorm'
|
|
3
|
+
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
4
|
+
import { OrPromise } from '@sphereon/ssi-types'
|
|
5
|
+
import { AbstractEventLoggerStore } from './AbstractEventLoggerStore'
|
|
6
|
+
import { AuditEventEntity, auditEventEntityFrom } from '../entities/eventLogger/AuditEventEntity'
|
|
7
|
+
import { GetAuditEventsArgs, StoreAuditEventArgs } from '../types'
|
|
8
|
+
|
|
9
|
+
const debug: Debugger = Debug('sphereon:ssi-sdk:event-store')
|
|
10
|
+
|
|
11
|
+
export class EventLoggerStore extends AbstractEventLoggerStore {
|
|
12
|
+
private readonly dbConnection: OrPromise<DataSource>
|
|
13
|
+
|
|
14
|
+
constructor(dbConnection: OrPromise<DataSource>) {
|
|
15
|
+
super()
|
|
16
|
+
this.dbConnection = dbConnection
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getAuditEvents = async (args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>> => {
|
|
20
|
+
const connection: DataSource = await this.dbConnection // TODO apply everywhere
|
|
21
|
+
debug('Getting audit events', args)
|
|
22
|
+
const result: Array<AuditEventEntity> = await connection.getRepository(AuditEventEntity).find({
|
|
23
|
+
...(args?.filter && { where: args?.filter }),
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return result.map((event: AuditEventEntity) => this.auditEventFrom(event))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
storeAuditEvent = async (args: StoreAuditEventArgs): Promise<AuditLoggingEvent> => {
|
|
30
|
+
const { event } = args
|
|
31
|
+
|
|
32
|
+
const auditEventEntity: AuditEventEntity = auditEventEntityFrom(event)
|
|
33
|
+
const connection: DataSource = await this.dbConnection
|
|
34
|
+
debug('Storing audit event', auditEventEntity)
|
|
35
|
+
const createdResult: AuditEventEntity = await connection.getRepository(AuditEventEntity).save(auditEventEntity)
|
|
36
|
+
|
|
37
|
+
return this.auditEventFrom(createdResult)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private auditEventFrom = (event: AuditEventEntity): AuditLoggingEvent => {
|
|
41
|
+
return {
|
|
42
|
+
id: event.id,
|
|
43
|
+
description: event.description,
|
|
44
|
+
timestamp: event.timestamp,
|
|
45
|
+
level: event.level,
|
|
46
|
+
correlationId: event.correlationId,
|
|
47
|
+
actionType: event.actionType,
|
|
48
|
+
actionSubType: event.actionSubType,
|
|
49
|
+
initiatorType: event.initiatorType,
|
|
50
|
+
partyAlias: event.partyAlias,
|
|
51
|
+
partyCorrelationId: event.partyCorrelationId,
|
|
52
|
+
partyCorrelationType: event.partyCorrelationType,
|
|
53
|
+
subSystemType: event.subSystemType,
|
|
54
|
+
system: event.system,
|
|
55
|
+
systemAlias: event.systemAlias,
|
|
56
|
+
systemCorrelationId: event.systemCorrelationId,
|
|
57
|
+
systemCorrelationIdType: event.systemCorrelationIdType,
|
|
58
|
+
...(event.data && { data: JSON.parse(event.data) }),
|
|
59
|
+
...(event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|