@sphereon/ssi-sdk.data-store 0.30.1-unstable.4 → 0.30.1
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/contact/ContactStore.d.ts.map +1 -1
- package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -1
- package/dist/eventLogger/EventLoggerStore.d.ts.map +1 -1
- package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +33 -33
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/postgres/1715761125001-CreateContacts.js +33 -33
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +12 -12
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +32 -32
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/migrations/sqlite/1710438363002-CreateContacts.js +13 -13
- package/dist/migrations/sqlite/1715761125002-CreateContacts.js +32 -32
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +9 -9
- package/dist/presentationDefinition/PDStore.d.ts.map +1 -1
- package/dist/utils/SortingUtils.d.ts.map +1 -1
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
- package/dist/utils/digitalCredential/MappingUtils.js +4 -4
- package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
- package/dist/utils/presentationDefinition/MappingUtils.js +2 -2
- package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/contact.entities.test.ts +2642 -2642
- package/src/__tests__/contact.store.test.ts +2649 -2649
- package/src/__tests__/digitalCredential.entities.test.ts +274 -274
- package/src/__tests__/digitalCredential.store.test.ts +330 -330
- package/src/__tests__/eventLogger.entities.test.ts +76 -76
- package/src/__tests__/eventLogger.store.test.ts +130 -130
- package/src/__tests__/issuanceBranding.entities.test.ts +846 -846
- package/src/__tests__/issuanceBranding.store.test.ts +1886 -1886
- package/src/__tests__/machineState.entities.test.ts +53 -53
- package/src/__tests__/machineState.store.test.ts +176 -176
- package/src/__tests__/pd-manager.entities.test.ts +73 -73
- package/src/__tests__/pd-manager.store.test.ts +193 -193
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +768 -768
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +21 -21
- package/src/digitalCredential/DigitalCredentialStore.ts +189 -189
- package/src/entities/contact/BaseContactEntity.ts +51 -51
- package/src/entities/contact/ConnectionEntity.ts +35 -35
- package/src/entities/contact/ContactMetadataItemEntity.ts +51 -51
- package/src/entities/contact/CorrelationIdentifierEntity.ts +43 -43
- package/src/entities/contact/DidAuthConfigEntity.ts +20 -20
- package/src/entities/contact/ElectronicAddressEntity.ts +70 -70
- package/src/entities/contact/IdentityEntity.ts +107 -107
- package/src/entities/contact/IdentityMetadataItemEntity.ts +48 -48
- package/src/entities/contact/NaturalPersonEntity.ts +44 -44
- package/src/entities/contact/OpenIdConfigEntity.ts +32 -32
- package/src/entities/contact/OrganizationEntity.ts +35 -35
- package/src/entities/contact/PartyEntity.ts +117 -117
- package/src/entities/contact/PartyRelationshipEntity.ts +68 -68
- package/src/entities/contact/PartyTypeEntity.ts +63 -63
- package/src/entities/contact/PhysicalAddressEntity.ts +95 -95
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +98 -98
- package/src/entities/eventLogger/AuditEventEntity.ts +92 -92
- package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +42 -42
- package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +87 -87
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +79 -79
- package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/ImageDimensionsEntity.ts +22 -22
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +73 -73
- package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +33 -33
- package/src/entities/issuanceBranding/TextAttributesEntity.ts +31 -31
- package/src/entities/machineState/MachineStateInfoEntity.ts +59 -59
- package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +44 -44
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -29
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +160 -160
- 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/10-CreatePresentationDefinitions.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/8-CreateContacts.ts +66 -66
- package/src/migrations/generic/9-CreateContacts.ts +66 -66
- package/src/migrations/generic/index.ts +43 -43
- package/src/migrations/index.ts +10 -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 +158 -158
- 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 +61 -61
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -60
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -25
- 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 +228 -228
- 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 +46 -46
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -83
- package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -59
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -24
- package/src/presentationDefinition/AbstractPDStore.ts +20 -20
- package/src/presentationDefinition/PDStore.ts +185 -185
- package/src/statusList/IStatusListStore.ts +44 -44
- package/src/statusList/StatusListStore.ts +236 -236
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +295 -295
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +42 -42
- package/src/types/digitalCredential/digitalCredential.ts +102 -102
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +14 -14
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -25
- package/src/types/presentationDefinition/presentationDefinition.ts +17 -17
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +506 -506
- package/src/utils/digitalCredential/MappingUtils.ts +160 -160
- package/src/utils/hasher.ts +19 -19
- package/src/utils/presentationDefinition/MappingUtils.ts +52 -52
- package/dist/entities/contact/IMetadataEntity.d.ts +0 -8
- package/dist/entities/contact/IMetadataEntity.d.ts.map +0 -1
- package/dist/entities/contact/IMetadataEntity.js +0 -2
- package/dist/entities/contact/IMetadataEntity.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
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
|
|
2
|
-
import { IMetadataEntity, ValidationConstraint } from '../../types'
|
|
3
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
4
|
-
import { BaseContactEntity } from './BaseContactEntity'
|
|
5
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
6
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
7
|
-
|
|
8
|
-
@Entity('ContactMetadata')
|
|
9
|
-
export class ContactMetadataItemEntity extends BaseEntity implements IMetadataEntity {
|
|
10
|
-
@PrimaryGeneratedColumn('uuid')
|
|
11
|
-
id!: string
|
|
12
|
-
|
|
13
|
-
@Column('varchar', { name: 'label', length: 255, nullable: false })
|
|
14
|
-
@IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
|
|
15
|
-
label!: string
|
|
16
|
-
|
|
17
|
-
@Column('varchar', { name: 'valueType', nullable: false })
|
|
18
|
-
@IsNotEmpty({ message: 'valueType must not be empty' })
|
|
19
|
-
valueType!: string
|
|
20
|
-
|
|
21
|
-
@Column('varchar', { name: 'stringValue', length: 255, nullable: true })
|
|
22
|
-
stringValue?: string
|
|
23
|
-
|
|
24
|
-
@Column('numeric', { name: 'numberValue', nullable: true })
|
|
25
|
-
numberValue?: number
|
|
26
|
-
|
|
27
|
-
@Column({ name: 'dateValue', nullable: true, type: typeOrmDateTime() })
|
|
28
|
-
dateValue?: Date
|
|
29
|
-
|
|
30
|
-
@Column('boolean', { name: 'boolValue', nullable: true })
|
|
31
|
-
boolValue?: boolean
|
|
32
|
-
|
|
33
|
-
@ManyToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.metadata, {
|
|
34
|
-
cascade: ['insert', 'update'],
|
|
35
|
-
onDelete: 'CASCADE',
|
|
36
|
-
})
|
|
37
|
-
contact!: BaseContactEntity
|
|
38
|
-
|
|
39
|
-
@BeforeInsert()
|
|
40
|
-
@BeforeUpdate()
|
|
41
|
-
async validate(): Promise<void> {
|
|
42
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
43
|
-
if (validation.length > 0) {
|
|
44
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
45
|
-
if (constraint) {
|
|
46
|
-
const message: string = Object.values(constraint!)[0]
|
|
47
|
-
return Promise.reject(Error(message))
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
|
|
2
|
+
import { IMetadataEntity, ValidationConstraint } from '../../types'
|
|
3
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
4
|
+
import { BaseContactEntity } from './BaseContactEntity'
|
|
5
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
6
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
7
|
+
|
|
8
|
+
@Entity('ContactMetadata')
|
|
9
|
+
export class ContactMetadataItemEntity extends BaseEntity implements IMetadataEntity {
|
|
10
|
+
@PrimaryGeneratedColumn('uuid')
|
|
11
|
+
id!: string
|
|
12
|
+
|
|
13
|
+
@Column('varchar', { name: 'label', length: 255, nullable: false })
|
|
14
|
+
@IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
|
|
15
|
+
label!: string
|
|
16
|
+
|
|
17
|
+
@Column('varchar', { name: 'valueType', nullable: false })
|
|
18
|
+
@IsNotEmpty({ message: 'valueType must not be empty' })
|
|
19
|
+
valueType!: string
|
|
20
|
+
|
|
21
|
+
@Column('varchar', { name: 'stringValue', length: 255, nullable: true })
|
|
22
|
+
stringValue?: string
|
|
23
|
+
|
|
24
|
+
@Column('numeric', { name: 'numberValue', nullable: true })
|
|
25
|
+
numberValue?: number
|
|
26
|
+
|
|
27
|
+
@Column({ name: 'dateValue', nullable: true, type: typeOrmDateTime() })
|
|
28
|
+
dateValue?: Date
|
|
29
|
+
|
|
30
|
+
@Column('boolean', { name: 'boolValue', nullable: true })
|
|
31
|
+
boolValue?: boolean
|
|
32
|
+
|
|
33
|
+
@ManyToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.metadata, {
|
|
34
|
+
cascade: ['insert', 'update'],
|
|
35
|
+
onDelete: 'CASCADE',
|
|
36
|
+
})
|
|
37
|
+
contact!: BaseContactEntity
|
|
38
|
+
|
|
39
|
+
@BeforeInsert()
|
|
40
|
+
@BeforeUpdate()
|
|
41
|
+
async validate(): Promise<void> {
|
|
42
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
43
|
+
if (validation.length > 0) {
|
|
44
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
45
|
+
if (constraint) {
|
|
46
|
+
const message: string = Object.values(constraint!)[0]
|
|
47
|
+
return Promise.reject(Error(message))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } from 'typeorm'
|
|
2
|
-
import { CorrelationIdentifierType, ValidationConstraint } from '../../types'
|
|
3
|
-
import { IdentityEntity } from './IdentityEntity'
|
|
4
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
5
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
6
|
-
|
|
7
|
-
@Entity('CorrelationIdentifier')
|
|
8
|
-
export class CorrelationIdentifierEntity extends BaseEntity {
|
|
9
|
-
@PrimaryGeneratedColumn('uuid')
|
|
10
|
-
id!: string
|
|
11
|
-
|
|
12
|
-
@Column('simple-enum', { name: 'type', enum: CorrelationIdentifierType, nullable: false })
|
|
13
|
-
type!: CorrelationIdentifierType
|
|
14
|
-
|
|
15
|
-
@Column('text', { name: 'correlation_id', nullable: false, unique: true })
|
|
16
|
-
@IsNotEmpty({ message: 'Blank correlation ids are not allowed' })
|
|
17
|
-
correlationId!: string
|
|
18
|
-
|
|
19
|
-
@Column('text', { name: 'owner_id', nullable: true })
|
|
20
|
-
ownerId?: string
|
|
21
|
-
|
|
22
|
-
@Column('text', { name: 'tenant_id', nullable: true })
|
|
23
|
-
tenantId?: string
|
|
24
|
-
|
|
25
|
-
@OneToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.identifier, {
|
|
26
|
-
onDelete: 'CASCADE',
|
|
27
|
-
})
|
|
28
|
-
@JoinColumn({ name: 'identity_id' })
|
|
29
|
-
identity!: IdentityEntity
|
|
30
|
-
|
|
31
|
-
@BeforeInsert()
|
|
32
|
-
@BeforeUpdate()
|
|
33
|
-
async validate(): Promise<void> {
|
|
34
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
35
|
-
if (validation.length > 0) {
|
|
36
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
37
|
-
if (constraint) {
|
|
38
|
-
const message: string = Object.values(constraint!)[0]
|
|
39
|
-
return Promise.reject(Error(message))
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, OneToOne, JoinColumn, BeforeInsert, BeforeUpdate } from 'typeorm'
|
|
2
|
+
import { CorrelationIdentifierType, ValidationConstraint } from '../../types'
|
|
3
|
+
import { IdentityEntity } from './IdentityEntity'
|
|
4
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
5
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
6
|
+
|
|
7
|
+
@Entity('CorrelationIdentifier')
|
|
8
|
+
export class CorrelationIdentifierEntity extends BaseEntity {
|
|
9
|
+
@PrimaryGeneratedColumn('uuid')
|
|
10
|
+
id!: string
|
|
11
|
+
|
|
12
|
+
@Column('simple-enum', { name: 'type', enum: CorrelationIdentifierType, nullable: false })
|
|
13
|
+
type!: CorrelationIdentifierType
|
|
14
|
+
|
|
15
|
+
@Column('text', { name: 'correlation_id', nullable: false, unique: true })
|
|
16
|
+
@IsNotEmpty({ message: 'Blank correlation ids are not allowed' })
|
|
17
|
+
correlationId!: string
|
|
18
|
+
|
|
19
|
+
@Column('text', { name: 'owner_id', nullable: true })
|
|
20
|
+
ownerId?: string
|
|
21
|
+
|
|
22
|
+
@Column('text', { name: 'tenant_id', nullable: true })
|
|
23
|
+
tenantId?: string
|
|
24
|
+
|
|
25
|
+
@OneToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.identifier, {
|
|
26
|
+
onDelete: 'CASCADE',
|
|
27
|
+
})
|
|
28
|
+
@JoinColumn({ name: 'identity_id' })
|
|
29
|
+
identity!: IdentityEntity
|
|
30
|
+
|
|
31
|
+
@BeforeInsert()
|
|
32
|
+
@BeforeUpdate()
|
|
33
|
+
async validate(): Promise<void> {
|
|
34
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
35
|
+
if (validation.length > 0) {
|
|
36
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
37
|
+
if (constraint) {
|
|
38
|
+
const message: string = Object.values(constraint!)[0]
|
|
39
|
+
return Promise.reject(Error(message))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ChildEntity, Column } from 'typeorm'
|
|
2
|
-
import { BaseConfigEntity } from './BaseConfigEntity'
|
|
3
|
-
|
|
4
|
-
@ChildEntity('DidAuthConfig')
|
|
5
|
-
export class DidAuthConfigEntity extends BaseConfigEntity {
|
|
6
|
-
@Column('varchar', { name: 'identifier', length: 255, nullable: false })
|
|
7
|
-
identifier!: string
|
|
8
|
-
|
|
9
|
-
@Column('varchar', { name: 'redirect_url', length: 255, nullable: false })
|
|
10
|
-
redirectUrl!: string
|
|
11
|
-
|
|
12
|
-
@Column('varchar', { name: 'session_id', length: 255, nullable: false })
|
|
13
|
-
sessionId!: string
|
|
14
|
-
|
|
15
|
-
@Column('text', { name: 'owner_id', nullable: true })
|
|
16
|
-
ownerId?: string
|
|
17
|
-
|
|
18
|
-
@Column('text', { name: 'tenant_id', nullable: true })
|
|
19
|
-
tenantId?: string
|
|
20
|
-
}
|
|
1
|
+
import { ChildEntity, Column } from 'typeorm'
|
|
2
|
+
import { BaseConfigEntity } from './BaseConfigEntity'
|
|
3
|
+
|
|
4
|
+
@ChildEntity('DidAuthConfig')
|
|
5
|
+
export class DidAuthConfigEntity extends BaseConfigEntity {
|
|
6
|
+
@Column('varchar', { name: 'identifier', length: 255, nullable: false })
|
|
7
|
+
identifier!: string
|
|
8
|
+
|
|
9
|
+
@Column('varchar', { name: 'redirect_url', length: 255, nullable: false })
|
|
10
|
+
redirectUrl!: string
|
|
11
|
+
|
|
12
|
+
@Column('varchar', { name: 'session_id', length: 255, nullable: false })
|
|
13
|
+
sessionId!: string
|
|
14
|
+
|
|
15
|
+
@Column('text', { name: 'owner_id', nullable: true })
|
|
16
|
+
ownerId?: string
|
|
17
|
+
|
|
18
|
+
@Column('text', { name: 'tenant_id', nullable: true })
|
|
19
|
+
tenantId?: string
|
|
20
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
2
|
-
import {
|
|
3
|
-
Entity,
|
|
4
|
-
Column,
|
|
5
|
-
PrimaryGeneratedColumn,
|
|
6
|
-
BaseEntity,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
BeforeInsert,
|
|
9
|
-
BeforeUpdate,
|
|
10
|
-
CreateDateColumn,
|
|
11
|
-
UpdateDateColumn,
|
|
12
|
-
} from 'typeorm'
|
|
13
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
14
|
-
import { PartyEntity } from './PartyEntity'
|
|
15
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
16
|
-
import { ElectronicAddressType, ValidationConstraint } from '../../types'
|
|
17
|
-
|
|
18
|
-
@Entity('ElectronicAddress')
|
|
19
|
-
export class ElectronicAddressEntity extends BaseEntity {
|
|
20
|
-
@PrimaryGeneratedColumn('uuid')
|
|
21
|
-
id!: string
|
|
22
|
-
|
|
23
|
-
@Column('varchar', { name: 'type', length: 255, nullable: false })
|
|
24
|
-
@IsNotEmpty({ message: 'Blank electronic address types are not allowed' })
|
|
25
|
-
type!: ElectronicAddressType
|
|
26
|
-
|
|
27
|
-
@Column('varchar', { name: 'electronic_address', length: 255, nullable: false })
|
|
28
|
-
@IsNotEmpty({ message: 'Blank electronic addresses are not allowed' })
|
|
29
|
-
electronicAddress!: string
|
|
30
|
-
|
|
31
|
-
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.electronicAddresses, {
|
|
32
|
-
onDelete: 'CASCADE',
|
|
33
|
-
})
|
|
34
|
-
party!: PartyEntity
|
|
35
|
-
|
|
36
|
-
@Column('text', { name: 'partyId', nullable: true })
|
|
37
|
-
partyId?: string
|
|
38
|
-
|
|
39
|
-
@Column('text', { name: 'owner_id', nullable: true })
|
|
40
|
-
ownerId?: string
|
|
41
|
-
|
|
42
|
-
@Column('text', { name: 'tenant_id', nullable: true })
|
|
43
|
-
tenantId?: string
|
|
44
|
-
|
|
45
|
-
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
46
|
-
createdAt!: Date
|
|
47
|
-
|
|
48
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
49
|
-
lastUpdatedAt!: Date
|
|
50
|
-
|
|
51
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
52
|
-
@BeforeInsert()
|
|
53
|
-
@BeforeUpdate()
|
|
54
|
-
updateUpdatedDate(): void {
|
|
55
|
-
this.lastUpdatedAt = new Date()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@BeforeInsert()
|
|
59
|
-
@BeforeUpdate()
|
|
60
|
-
async validate(): Promise<void> {
|
|
61
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
62
|
-
if (validation.length > 0) {
|
|
63
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
64
|
-
if (constraint) {
|
|
65
|
-
const message: string = Object.values(constraint!)[0]
|
|
66
|
-
return Promise.reject(Error(message))
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
2
|
+
import {
|
|
3
|
+
Entity,
|
|
4
|
+
Column,
|
|
5
|
+
PrimaryGeneratedColumn,
|
|
6
|
+
BaseEntity,
|
|
7
|
+
ManyToOne,
|
|
8
|
+
BeforeInsert,
|
|
9
|
+
BeforeUpdate,
|
|
10
|
+
CreateDateColumn,
|
|
11
|
+
UpdateDateColumn,
|
|
12
|
+
} from 'typeorm'
|
|
13
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
14
|
+
import { PartyEntity } from './PartyEntity'
|
|
15
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
16
|
+
import { ElectronicAddressType, ValidationConstraint } from '../../types'
|
|
17
|
+
|
|
18
|
+
@Entity('ElectronicAddress')
|
|
19
|
+
export class ElectronicAddressEntity extends BaseEntity {
|
|
20
|
+
@PrimaryGeneratedColumn('uuid')
|
|
21
|
+
id!: string
|
|
22
|
+
|
|
23
|
+
@Column('varchar', { name: 'type', length: 255, nullable: false })
|
|
24
|
+
@IsNotEmpty({ message: 'Blank electronic address types are not allowed' })
|
|
25
|
+
type!: ElectronicAddressType
|
|
26
|
+
|
|
27
|
+
@Column('varchar', { name: 'electronic_address', length: 255, nullable: false })
|
|
28
|
+
@IsNotEmpty({ message: 'Blank electronic addresses are not allowed' })
|
|
29
|
+
electronicAddress!: string
|
|
30
|
+
|
|
31
|
+
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.electronicAddresses, {
|
|
32
|
+
onDelete: 'CASCADE',
|
|
33
|
+
})
|
|
34
|
+
party!: PartyEntity
|
|
35
|
+
|
|
36
|
+
@Column('text', { name: 'partyId', nullable: true })
|
|
37
|
+
partyId?: string
|
|
38
|
+
|
|
39
|
+
@Column('text', { name: 'owner_id', nullable: true })
|
|
40
|
+
ownerId?: string
|
|
41
|
+
|
|
42
|
+
@Column('text', { name: 'tenant_id', nullable: true })
|
|
43
|
+
tenantId?: string
|
|
44
|
+
|
|
45
|
+
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
46
|
+
createdAt!: Date
|
|
47
|
+
|
|
48
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
49
|
+
lastUpdatedAt!: Date
|
|
50
|
+
|
|
51
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
52
|
+
@BeforeInsert()
|
|
53
|
+
@BeforeUpdate()
|
|
54
|
+
updateUpdatedDate(): void {
|
|
55
|
+
this.lastUpdatedAt = new Date()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@BeforeInsert()
|
|
59
|
+
@BeforeUpdate()
|
|
60
|
+
async validate(): Promise<void> {
|
|
61
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
62
|
+
if (validation.length > 0) {
|
|
63
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
64
|
+
if (constraint) {
|
|
65
|
+
const message: string = Object.values(constraint!)[0]
|
|
66
|
+
return Promise.reject(Error(message))
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseEntity,
|
|
3
|
-
CreateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
PrimaryGeneratedColumn,
|
|
6
|
-
UpdateDateColumn,
|
|
7
|
-
OneToOne,
|
|
8
|
-
JoinColumn,
|
|
9
|
-
ManyToOne,
|
|
10
|
-
Column,
|
|
11
|
-
OneToMany,
|
|
12
|
-
BeforeInsert,
|
|
13
|
-
BeforeUpdate,
|
|
14
|
-
} from 'typeorm'
|
|
15
|
-
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
16
|
-
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
17
|
-
import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
18
|
-
import { ConnectionEntity } from './ConnectionEntity'
|
|
19
|
-
import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
|
|
20
|
-
import { CredentialRole, IdentityOrigin, ValidationConstraint } from '../../types'
|
|
21
|
-
import { PartyEntity } from './PartyEntity'
|
|
22
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
23
|
-
|
|
24
|
-
@Entity('Identity')
|
|
25
|
-
export class IdentityEntity extends BaseEntity {
|
|
26
|
-
@PrimaryGeneratedColumn('uuid')
|
|
27
|
-
id!: string
|
|
28
|
-
|
|
29
|
-
@Column('varchar', {
|
|
30
|
-
name: 'alias',
|
|
31
|
-
length: 255,
|
|
32
|
-
nullable: false,
|
|
33
|
-
unique: true,
|
|
34
|
-
})
|
|
35
|
-
@IsNotEmpty({ message: 'Blank aliases are not allowed' })
|
|
36
|
-
alias!: string
|
|
37
|
-
|
|
38
|
-
@Column('simple-enum', { name: 'origin', enum: IdentityOrigin, nullable: false })
|
|
39
|
-
origin!: IdentityOrigin
|
|
40
|
-
|
|
41
|
-
@Column('text', { name: 'owner_id', nullable: true })
|
|
42
|
-
ownerId?: string
|
|
43
|
-
|
|
44
|
-
@Column('text', { name: 'tenant_id', nullable: true })
|
|
45
|
-
tenantId?: string
|
|
46
|
-
|
|
47
|
-
@Column('simple-array', { name: 'roles', nullable: false })
|
|
48
|
-
roles!: Array<CredentialRole>
|
|
49
|
-
|
|
50
|
-
@OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
|
|
51
|
-
cascade: true,
|
|
52
|
-
onDelete: 'CASCADE',
|
|
53
|
-
eager: true,
|
|
54
|
-
nullable: false,
|
|
55
|
-
})
|
|
56
|
-
identifier!: CorrelationIdentifierEntity
|
|
57
|
-
|
|
58
|
-
@OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
|
|
59
|
-
cascade: true,
|
|
60
|
-
onDelete: 'CASCADE',
|
|
61
|
-
eager: true,
|
|
62
|
-
})
|
|
63
|
-
connection?: ConnectionEntity
|
|
64
|
-
|
|
65
|
-
@OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
|
|
66
|
-
cascade: true,
|
|
67
|
-
onDelete: 'CASCADE',
|
|
68
|
-
eager: true,
|
|
69
|
-
nullable: false,
|
|
70
|
-
})
|
|
71
|
-
@JoinColumn({ name: 'metadata_id' }) // TODO check in db file
|
|
72
|
-
metadata!: Array<IdentityMetadataItemEntity>
|
|
73
|
-
|
|
74
|
-
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
75
|
-
createdAt!: Date
|
|
76
|
-
|
|
77
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
78
|
-
lastUpdatedAt!: Date
|
|
79
|
-
|
|
80
|
-
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.identities, {
|
|
81
|
-
onDelete: 'CASCADE',
|
|
82
|
-
})
|
|
83
|
-
party!: PartyEntity
|
|
84
|
-
|
|
85
|
-
@Column('text', { name: 'partyId', nullable: true })
|
|
86
|
-
partyId?: string
|
|
87
|
-
|
|
88
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
89
|
-
@BeforeInsert()
|
|
90
|
-
@BeforeUpdate()
|
|
91
|
-
updateUpdatedDate(): void {
|
|
92
|
-
this.lastUpdatedAt = new Date()
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@BeforeInsert()
|
|
96
|
-
@BeforeUpdate()
|
|
97
|
-
async validate(): Promise<void> {
|
|
98
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
99
|
-
if (validation.length > 0) {
|
|
100
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
101
|
-
if (constraint) {
|
|
102
|
-
const message: string = Object.values(constraint!)[0]
|
|
103
|
-
return Promise.reject(Error(message))
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
BaseEntity,
|
|
3
|
+
CreateDateColumn,
|
|
4
|
+
Entity,
|
|
5
|
+
PrimaryGeneratedColumn,
|
|
6
|
+
UpdateDateColumn,
|
|
7
|
+
OneToOne,
|
|
8
|
+
JoinColumn,
|
|
9
|
+
ManyToOne,
|
|
10
|
+
Column,
|
|
11
|
+
OneToMany,
|
|
12
|
+
BeforeInsert,
|
|
13
|
+
BeforeUpdate,
|
|
14
|
+
} from 'typeorm'
|
|
15
|
+
import { IsNotEmpty, validate, ValidationError } from 'class-validator'
|
|
16
|
+
import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
|
|
17
|
+
import { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
18
|
+
import { ConnectionEntity } from './ConnectionEntity'
|
|
19
|
+
import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
|
|
20
|
+
import { CredentialRole, IdentityOrigin, ValidationConstraint } from '../../types'
|
|
21
|
+
import { PartyEntity } from './PartyEntity'
|
|
22
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
23
|
+
|
|
24
|
+
@Entity('Identity')
|
|
25
|
+
export class IdentityEntity extends BaseEntity {
|
|
26
|
+
@PrimaryGeneratedColumn('uuid')
|
|
27
|
+
id!: string
|
|
28
|
+
|
|
29
|
+
@Column('varchar', {
|
|
30
|
+
name: 'alias',
|
|
31
|
+
length: 255,
|
|
32
|
+
nullable: false,
|
|
33
|
+
unique: true,
|
|
34
|
+
})
|
|
35
|
+
@IsNotEmpty({ message: 'Blank aliases are not allowed' })
|
|
36
|
+
alias!: string
|
|
37
|
+
|
|
38
|
+
@Column('simple-enum', { name: 'origin', enum: IdentityOrigin, nullable: false })
|
|
39
|
+
origin!: IdentityOrigin
|
|
40
|
+
|
|
41
|
+
@Column('text', { name: 'owner_id', nullable: true })
|
|
42
|
+
ownerId?: string
|
|
43
|
+
|
|
44
|
+
@Column('text', { name: 'tenant_id', nullable: true })
|
|
45
|
+
tenantId?: string
|
|
46
|
+
|
|
47
|
+
@Column('simple-array', { name: 'roles', nullable: false })
|
|
48
|
+
roles!: Array<CredentialRole>
|
|
49
|
+
|
|
50
|
+
@OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
|
|
51
|
+
cascade: true,
|
|
52
|
+
onDelete: 'CASCADE',
|
|
53
|
+
eager: true,
|
|
54
|
+
nullable: false,
|
|
55
|
+
})
|
|
56
|
+
identifier!: CorrelationIdentifierEntity
|
|
57
|
+
|
|
58
|
+
@OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
|
|
59
|
+
cascade: true,
|
|
60
|
+
onDelete: 'CASCADE',
|
|
61
|
+
eager: true,
|
|
62
|
+
})
|
|
63
|
+
connection?: ConnectionEntity
|
|
64
|
+
|
|
65
|
+
@OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
|
|
66
|
+
cascade: true,
|
|
67
|
+
onDelete: 'CASCADE',
|
|
68
|
+
eager: true,
|
|
69
|
+
nullable: false,
|
|
70
|
+
})
|
|
71
|
+
@JoinColumn({ name: 'metadata_id' }) // TODO check in db file
|
|
72
|
+
metadata!: Array<IdentityMetadataItemEntity>
|
|
73
|
+
|
|
74
|
+
@CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
|
|
75
|
+
createdAt!: Date
|
|
76
|
+
|
|
77
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
|
|
78
|
+
lastUpdatedAt!: Date
|
|
79
|
+
|
|
80
|
+
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.identities, {
|
|
81
|
+
onDelete: 'CASCADE',
|
|
82
|
+
})
|
|
83
|
+
party!: PartyEntity
|
|
84
|
+
|
|
85
|
+
@Column('text', { name: 'partyId', nullable: true })
|
|
86
|
+
partyId?: string
|
|
87
|
+
|
|
88
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
89
|
+
@BeforeInsert()
|
|
90
|
+
@BeforeUpdate()
|
|
91
|
+
updateUpdatedDate(): void {
|
|
92
|
+
this.lastUpdatedAt = new Date()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@BeforeInsert()
|
|
96
|
+
@BeforeUpdate()
|
|
97
|
+
async validate(): Promise<void> {
|
|
98
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
99
|
+
if (validation.length > 0) {
|
|
100
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
101
|
+
if (constraint) {
|
|
102
|
+
const message: string = Object.values(constraint!)[0]
|
|
103
|
+
return Promise.reject(Error(message))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|