@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.
Files changed (136) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +77 -77
  3. package/dist/contact/ContactStore.d.ts.map +1 -1
  4. package/dist/digitalCredential/DigitalCredentialStore.d.ts.map +1 -1
  5. package/dist/eventLogger/EventLoggerStore.d.ts.map +1 -1
  6. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -1
  7. package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
  8. package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +33 -33
  9. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
  10. package/dist/migrations/postgres/1715761125001-CreateContacts.js +33 -33
  11. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +12 -12
  12. package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +32 -32
  13. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
  14. package/dist/migrations/sqlite/1710438363002-CreateContacts.js +13 -13
  15. package/dist/migrations/sqlite/1715761125002-CreateContacts.js +32 -32
  16. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +9 -9
  17. package/dist/presentationDefinition/PDStore.d.ts.map +1 -1
  18. package/dist/utils/SortingUtils.d.ts.map +1 -1
  19. package/dist/utils/contact/MappingUtils.d.ts.map +1 -1
  20. package/dist/utils/digitalCredential/MappingUtils.d.ts.map +1 -1
  21. package/dist/utils/digitalCredential/MappingUtils.js +4 -4
  22. package/dist/utils/digitalCredential/MappingUtils.js.map +1 -1
  23. package/dist/utils/presentationDefinition/MappingUtils.js +2 -2
  24. package/dist/utils/presentationDefinition/MappingUtils.js.map +1 -1
  25. package/package.json +8 -8
  26. package/src/__tests__/contact.entities.test.ts +2642 -2642
  27. package/src/__tests__/contact.store.test.ts +2649 -2649
  28. package/src/__tests__/digitalCredential.entities.test.ts +274 -274
  29. package/src/__tests__/digitalCredential.store.test.ts +330 -330
  30. package/src/__tests__/eventLogger.entities.test.ts +76 -76
  31. package/src/__tests__/eventLogger.store.test.ts +130 -130
  32. package/src/__tests__/issuanceBranding.entities.test.ts +846 -846
  33. package/src/__tests__/issuanceBranding.store.test.ts +1886 -1886
  34. package/src/__tests__/machineState.entities.test.ts +53 -53
  35. package/src/__tests__/machineState.store.test.ts +176 -176
  36. package/src/__tests__/pd-manager.entities.test.ts +73 -73
  37. package/src/__tests__/pd-manager.store.test.ts +193 -193
  38. package/src/contact/AbstractContactStore.ts +71 -71
  39. package/src/contact/ContactStore.ts +768 -768
  40. package/src/digitalCredential/AbstractDigitalCredentialStore.ts +21 -21
  41. package/src/digitalCredential/DigitalCredentialStore.ts +189 -189
  42. package/src/entities/contact/BaseContactEntity.ts +51 -51
  43. package/src/entities/contact/ConnectionEntity.ts +35 -35
  44. package/src/entities/contact/ContactMetadataItemEntity.ts +51 -51
  45. package/src/entities/contact/CorrelationIdentifierEntity.ts +43 -43
  46. package/src/entities/contact/DidAuthConfigEntity.ts +20 -20
  47. package/src/entities/contact/ElectronicAddressEntity.ts +70 -70
  48. package/src/entities/contact/IdentityEntity.ts +107 -107
  49. package/src/entities/contact/IdentityMetadataItemEntity.ts +48 -48
  50. package/src/entities/contact/NaturalPersonEntity.ts +44 -44
  51. package/src/entities/contact/OpenIdConfigEntity.ts +32 -32
  52. package/src/entities/contact/OrganizationEntity.ts +35 -35
  53. package/src/entities/contact/PartyEntity.ts +117 -117
  54. package/src/entities/contact/PartyRelationshipEntity.ts +68 -68
  55. package/src/entities/contact/PartyTypeEntity.ts +63 -63
  56. package/src/entities/contact/PhysicalAddressEntity.ts +95 -95
  57. package/src/entities/digitalCredential/DigitalCredentialEntity.ts +98 -98
  58. package/src/entities/eventLogger/AuditEventEntity.ts +92 -92
  59. package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +42 -42
  60. package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +87 -87
  61. package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +79 -79
  62. package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +33 -33
  63. package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
  64. package/src/entities/issuanceBranding/ImageDimensionsEntity.ts +22 -22
  65. package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +73 -73
  66. package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +33 -33
  67. package/src/entities/issuanceBranding/TextAttributesEntity.ts +31 -31
  68. package/src/entities/machineState/MachineStateInfoEntity.ts +59 -59
  69. package/src/entities/presentationDefinition/PresentationDefinitionItemEntity.ts +44 -44
  70. package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
  71. package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -29
  72. package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
  73. package/src/eventLogger/EventLoggerStore.ts +62 -62
  74. package/src/index.ts +160 -160
  75. package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
  76. package/src/machineState/IAbstractMachineStateStore.ts +65 -65
  77. package/src/machineState/MachineStateStore.ts +149 -149
  78. package/src/migrations/generic/1-CreateContacts.ts +66 -66
  79. package/src/migrations/generic/10-CreatePresentationDefinitions.ts +66 -66
  80. package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
  81. package/src/migrations/generic/3-CreateContacts.ts +66 -66
  82. package/src/migrations/generic/4-CreateStatusList.ts +54 -54
  83. package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
  84. package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
  85. package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
  86. package/src/migrations/generic/8-CreateContacts.ts +66 -66
  87. package/src/migrations/generic/9-CreateContacts.ts +66 -66
  88. package/src/migrations/generic/index.ts +43 -43
  89. package/src/migrations/index.ts +10 -10
  90. package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
  91. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
  92. package/src/migrations/postgres/1690925872592-CreateContacts.ts +158 -158
  93. package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
  94. package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
  95. package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +61 -61
  96. package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
  97. package/src/migrations/postgres/1710438363001-CreateContacts.ts +63 -63
  98. package/src/migrations/postgres/1715761125001-CreateContacts.ts +60 -60
  99. package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +25 -25
  100. package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
  101. package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
  102. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +228 -228
  103. package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
  104. package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
  105. package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +46 -46
  106. package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
  107. package/src/migrations/sqlite/1710438363002-CreateContacts.ts +83 -83
  108. package/src/migrations/sqlite/1715761125002-CreateContacts.ts +59 -59
  109. package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +24 -24
  110. package/src/presentationDefinition/AbstractPDStore.ts +20 -20
  111. package/src/presentationDefinition/PDStore.ts +185 -185
  112. package/src/statusList/IStatusListStore.ts +44 -44
  113. package/src/statusList/StatusListStore.ts +236 -236
  114. package/src/types/contact/IAbstractContactStore.ts +161 -161
  115. package/src/types/contact/contact.ts +295 -295
  116. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +42 -42
  117. package/src/types/digitalCredential/digitalCredential.ts +102 -102
  118. package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
  119. package/src/types/eventLogger/eventLogger.ts +3 -3
  120. package/src/types/index.ts +14 -14
  121. package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
  122. package/src/types/presentationDefinition/IAbstractPDStore.ts +25 -25
  123. package/src/types/presentationDefinition/presentationDefinition.ts +17 -17
  124. package/src/utils/SortingUtils.ts +16 -16
  125. package/src/utils/contact/MappingUtils.ts +506 -506
  126. package/src/utils/digitalCredential/MappingUtils.ts +160 -160
  127. package/src/utils/hasher.ts +19 -19
  128. package/src/utils/presentationDefinition/MappingUtils.ts +52 -52
  129. package/dist/entities/contact/IMetadataEntity.d.ts +0 -8
  130. package/dist/entities/contact/IMetadataEntity.d.ts.map +0 -1
  131. package/dist/entities/contact/IMetadataEntity.js +0 -2
  132. package/dist/entities/contact/IMetadataEntity.js.map +0 -1
  133. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
  134. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
  135. package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
  136. package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
@@ -1,68 +1,68 @@
1
- import {
2
- Entity,
3
- PrimaryGeneratedColumn,
4
- CreateDateColumn,
5
- UpdateDateColumn,
6
- ManyToOne,
7
- Column,
8
- Index,
9
- BeforeInsert,
10
- BeforeUpdate,
11
- JoinColumn,
12
- } from 'typeorm'
13
- import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
14
- import { PartyEntity } from './PartyEntity'
15
-
16
- @Entity('PartyRelationship')
17
- @Index('IDX_PartyRelationship_left_right', ['left', 'right'], { unique: true })
18
- export class PartyRelationshipEntity {
19
- @PrimaryGeneratedColumn('uuid')
20
- id!: string
21
-
22
- @ManyToOne(() => PartyEntity, {
23
- nullable: false,
24
- onDelete: 'CASCADE',
25
- })
26
- @JoinColumn({ name: 'left_id' })
27
- left!: PartyEntity
28
-
29
- @Column('text', { name: 'left_id', nullable: false })
30
- leftId!: string
31
-
32
- @ManyToOne(() => PartyEntity, {
33
- nullable: false,
34
- onDelete: 'CASCADE',
35
- })
36
- @JoinColumn({ name: 'right_id' })
37
- right!: PartyEntity
38
-
39
- @Column('text', { name: 'right_id', nullable: false })
40
- rightId!: string
41
-
42
- @Column('text', { name: 'owner_id', nullable: true })
43
- ownerId?: string
44
-
45
- @Column('text', { name: 'tenant_id', nullable: true })
46
- tenantId?: string
47
-
48
- @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
49
- createdAt!: Date
50
-
51
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
52
- lastUpdatedAt!: Date
53
-
54
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
55
- @BeforeInsert()
56
- @BeforeUpdate()
57
- updateUpdatedDate(): void {
58
- this.lastUpdatedAt = new Date()
59
- }
60
-
61
- @BeforeInsert()
62
- @BeforeUpdate()
63
- async checkRelationshipSides(): Promise<void> {
64
- if ((this.left?.id ?? this.leftId) === (this.right?.id ?? this.rightId)) {
65
- return Promise.reject(Error('Cannot use the same id for both sides of the relationship'))
66
- }
67
- }
68
- }
1
+ import {
2
+ Entity,
3
+ PrimaryGeneratedColumn,
4
+ CreateDateColumn,
5
+ UpdateDateColumn,
6
+ ManyToOne,
7
+ Column,
8
+ Index,
9
+ BeforeInsert,
10
+ BeforeUpdate,
11
+ JoinColumn,
12
+ } from 'typeorm'
13
+ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
14
+ import { PartyEntity } from './PartyEntity'
15
+
16
+ @Entity('PartyRelationship')
17
+ @Index('IDX_PartyRelationship_left_right', ['left', 'right'], { unique: true })
18
+ export class PartyRelationshipEntity {
19
+ @PrimaryGeneratedColumn('uuid')
20
+ id!: string
21
+
22
+ @ManyToOne(() => PartyEntity, {
23
+ nullable: false,
24
+ onDelete: 'CASCADE',
25
+ })
26
+ @JoinColumn({ name: 'left_id' })
27
+ left!: PartyEntity
28
+
29
+ @Column('text', { name: 'left_id', nullable: false })
30
+ leftId!: string
31
+
32
+ @ManyToOne(() => PartyEntity, {
33
+ nullable: false,
34
+ onDelete: 'CASCADE',
35
+ })
36
+ @JoinColumn({ name: 'right_id' })
37
+ right!: PartyEntity
38
+
39
+ @Column('text', { name: 'right_id', nullable: false })
40
+ rightId!: string
41
+
42
+ @Column('text', { name: 'owner_id', nullable: true })
43
+ ownerId?: string
44
+
45
+ @Column('text', { name: 'tenant_id', nullable: true })
46
+ tenantId?: string
47
+
48
+ @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
49
+ createdAt!: Date
50
+
51
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
52
+ lastUpdatedAt!: Date
53
+
54
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
55
+ @BeforeInsert()
56
+ @BeforeUpdate()
57
+ updateUpdatedDate(): void {
58
+ this.lastUpdatedAt = new Date()
59
+ }
60
+
61
+ @BeforeInsert()
62
+ @BeforeUpdate()
63
+ async checkRelationshipSides(): Promise<void> {
64
+ if ((this.left?.id ?? this.leftId) === (this.right?.id ?? this.rightId)) {
65
+ return Promise.reject(Error('Cannot use the same id for both sides of the relationship'))
66
+ }
67
+ }
68
+ }
@@ -1,63 +1,63 @@
1
- import { BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
- import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
3
- import { PartyEntity } from './PartyEntity'
4
- import { PartyOrigin, PartyTypeType, ValidationConstraint } from '../../types'
5
- import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
6
- import { IsNonEmptyStringConstraint } from '../validators'
7
- import { getConstraint } from '../../utils/ValidatorUtils'
8
-
9
- @Entity('PartyType')
10
- @Index('IDX_PartyType_type_tenant_id', ['type', 'tenantId'], { unique: true })
11
- export class PartyTypeEntity {
12
- @PrimaryGeneratedColumn('uuid')
13
- id!: string
14
-
15
- @Column('simple-enum', { name: 'type', enum: PartyTypeType, nullable: false })
16
- type!: PartyTypeType
17
-
18
- @Column('simple-enum', { name: 'origin', enum: PartyOrigin, nullable: false, unique: false })
19
- origin!: PartyOrigin
20
-
21
- @Column('varchar', { name: 'name', length: 255, nullable: false, unique: true })
22
- @IsNotEmpty({ message: 'Blank names are not allowed' })
23
- name!: string
24
-
25
- @Column('varchar', { name: 'description', length: 255, nullable: true })
26
- @Validate(IsNonEmptyStringConstraint, { message: 'Blank descriptions are not allowed' })
27
- description?: string
28
-
29
- @Column({ name: 'tenant_id', type: 'varchar', length: 255, nullable: true })
30
- @IsNotEmpty({ message: "Blank tenant id's are not allowed" })
31
- tenantId!: string
32
-
33
- @OneToMany(() => PartyEntity, (party: PartyEntity) => party.partyType, {
34
- nullable: false,
35
- })
36
- parties!: Array<PartyEntity>
37
-
38
- @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
39
- createdAt!: Date
40
-
41
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
42
- lastUpdatedAt!: Date
43
-
44
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
45
- @BeforeInsert()
46
- @BeforeUpdate()
47
- updateUpdatedDate(): void {
48
- this.lastUpdatedAt = new Date()
49
- }
50
-
51
- @BeforeInsert()
52
- @BeforeUpdate()
53
- async validate(): Promise<void> {
54
- const validation: Array<ValidationError> = await validate(this)
55
- if (validation.length > 0) {
56
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
57
- if (constraint) {
58
- const message: string = Object.values(constraint!)[0]
59
- return Promise.reject(Error(message))
60
- }
61
- }
62
- }
63
- }
1
+ import { BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
+ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
3
+ import { PartyEntity } from './PartyEntity'
4
+ import { PartyOrigin, PartyTypeType, ValidationConstraint } from '../../types'
5
+ import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
6
+ import { IsNonEmptyStringConstraint } from '../validators'
7
+ import { getConstraint } from '../../utils/ValidatorUtils'
8
+
9
+ @Entity('PartyType')
10
+ @Index('IDX_PartyType_type_tenant_id', ['type', 'tenantId'], { unique: true })
11
+ export class PartyTypeEntity {
12
+ @PrimaryGeneratedColumn('uuid')
13
+ id!: string
14
+
15
+ @Column('simple-enum', { name: 'type', enum: PartyTypeType, nullable: false })
16
+ type!: PartyTypeType
17
+
18
+ @Column('simple-enum', { name: 'origin', enum: PartyOrigin, nullable: false, unique: false })
19
+ origin!: PartyOrigin
20
+
21
+ @Column('varchar', { name: 'name', length: 255, nullable: false, unique: true })
22
+ @IsNotEmpty({ message: 'Blank names are not allowed' })
23
+ name!: string
24
+
25
+ @Column('varchar', { name: 'description', length: 255, nullable: true })
26
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank descriptions are not allowed' })
27
+ description?: string
28
+
29
+ @Column({ name: 'tenant_id', type: 'varchar', length: 255, nullable: true })
30
+ @IsNotEmpty({ message: "Blank tenant id's are not allowed" })
31
+ tenantId!: string
32
+
33
+ @OneToMany(() => PartyEntity, (party: PartyEntity) => party.partyType, {
34
+ nullable: false,
35
+ })
36
+ parties!: Array<PartyEntity>
37
+
38
+ @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
39
+ createdAt!: Date
40
+
41
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
42
+ lastUpdatedAt!: Date
43
+
44
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
45
+ @BeforeInsert()
46
+ @BeforeUpdate()
47
+ updateUpdatedDate(): void {
48
+ this.lastUpdatedAt = new Date()
49
+ }
50
+
51
+ @BeforeInsert()
52
+ @BeforeUpdate()
53
+ async validate(): Promise<void> {
54
+ const validation: Array<ValidationError> = await validate(this)
55
+ if (validation.length > 0) {
56
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
57
+ if (constraint) {
58
+ const message: string = Object.values(constraint!)[0]
59
+ return Promise.reject(Error(message))
60
+ }
61
+ }
62
+ }
63
+ }
@@ -1,95 +1,95 @@
1
- import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
2
- import {
3
- BaseEntity,
4
- BeforeInsert,
5
- BeforeUpdate,
6
- Column,
7
- CreateDateColumn,
8
- Entity,
9
- ManyToOne,
10
- PrimaryGeneratedColumn,
11
- UpdateDateColumn,
12
- } from 'typeorm'
13
- import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
14
- import { getConstraint } from '../../utils/ValidatorUtils'
15
- import { PhysicalAddressType, ValidationConstraint } from '../../types'
16
- import { PartyEntity } from './PartyEntity'
17
- import { IsNonEmptyStringConstraint } from '../validators'
18
-
19
- @Entity('PhysicalAddress')
20
- export class PhysicalAddressEntity extends BaseEntity {
21
- @PrimaryGeneratedColumn('uuid')
22
- id!: string
23
-
24
- @Column('varchar', { name: 'type', length: 255, nullable: false })
25
- @IsNotEmpty({ message: 'Blank physical address types are not allowed' })
26
- type!: PhysicalAddressType
27
-
28
- @Column('varchar', { name: 'street_name', length: 255, nullable: false })
29
- @IsNotEmpty({ message: 'Blank street names are not allowed' })
30
- streetName!: string
31
-
32
- @Column('varchar', { name: 'street_number', length: 255, nullable: false })
33
- @IsNotEmpty({ message: 'Blank street numbers are not allowed' })
34
- streetNumber!: string
35
-
36
- @Column('varchar', { name: 'postal_code', length: 255, nullable: false })
37
- @IsNotEmpty({ message: 'Blank postal codes are not allowed' })
38
- postalCode!: string
39
-
40
- @Column('varchar', { name: 'city_name', length: 255, nullable: false })
41
- @IsNotEmpty({ message: 'Blank city names are not allowed' })
42
- cityName!: string
43
-
44
- @Column('varchar', { name: 'province_name', length: 255, nullable: false })
45
- @IsNotEmpty({ message: 'Blank province names are not allowed' })
46
- provinceName!: string
47
-
48
- @Column('varchar', { name: 'country_code', length: 2, nullable: false })
49
- @IsNotEmpty({ message: 'Blank country codes are not allowed' })
50
- countryCode!: string
51
-
52
- @Column('varchar', { name: 'building_name', length: 255, nullable: true })
53
- @Validate(IsNonEmptyStringConstraint, { message: 'Blank building names are not allowed' })
54
- buildingName?: string
55
-
56
- @Column('text', { name: 'owner_id', nullable: true })
57
- ownerId?: string
58
-
59
- @Column('text', { name: 'tenant_id', nullable: true })
60
- tenantId?: string
61
-
62
- @ManyToOne(() => PartyEntity, (party: PartyEntity) => party.physicalAddresses, {
63
- onDelete: 'CASCADE',
64
- })
65
- party!: PartyEntity
66
-
67
- @Column('text', { name: 'partyId', nullable: true })
68
- partyId?: string
69
-
70
- @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
71
- createdAt!: Date
72
-
73
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
74
- lastUpdatedAt!: Date
75
-
76
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
77
- @BeforeInsert()
78
- @BeforeUpdate()
79
- updateUpdatedDate(): void {
80
- this.lastUpdatedAt = new Date()
81
- }
82
-
83
- @BeforeInsert()
84
- @BeforeUpdate()
85
- async validate(): Promise<void> {
86
- const validation: Array<ValidationError> = await validate(this)
87
- if (validation.length > 0) {
88
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
89
- if (constraint) {
90
- const message: string = Object.values(constraint!)[0]
91
- return Promise.reject(Error(message))
92
- }
93
- }
94
- }
95
- }
1
+ import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
2
+ import {
3
+ BaseEntity,
4
+ BeforeInsert,
5
+ BeforeUpdate,
6
+ Column,
7
+ CreateDateColumn,
8
+ Entity,
9
+ ManyToOne,
10
+ PrimaryGeneratedColumn,
11
+ UpdateDateColumn,
12
+ } from 'typeorm'
13
+ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
14
+ import { getConstraint } from '../../utils/ValidatorUtils'
15
+ import { PhysicalAddressType, ValidationConstraint } from '../../types'
16
+ import { PartyEntity } from './PartyEntity'
17
+ import { IsNonEmptyStringConstraint } from '../validators'
18
+
19
+ @Entity('PhysicalAddress')
20
+ export class PhysicalAddressEntity extends BaseEntity {
21
+ @PrimaryGeneratedColumn('uuid')
22
+ id!: string
23
+
24
+ @Column('varchar', { name: 'type', length: 255, nullable: false })
25
+ @IsNotEmpty({ message: 'Blank physical address types are not allowed' })
26
+ type!: PhysicalAddressType
27
+
28
+ @Column('varchar', { name: 'street_name', length: 255, nullable: false })
29
+ @IsNotEmpty({ message: 'Blank street names are not allowed' })
30
+ streetName!: string
31
+
32
+ @Column('varchar', { name: 'street_number', length: 255, nullable: false })
33
+ @IsNotEmpty({ message: 'Blank street numbers are not allowed' })
34
+ streetNumber!: string
35
+
36
+ @Column('varchar', { name: 'postal_code', length: 255, nullable: false })
37
+ @IsNotEmpty({ message: 'Blank postal codes are not allowed' })
38
+ postalCode!: string
39
+
40
+ @Column('varchar', { name: 'city_name', length: 255, nullable: false })
41
+ @IsNotEmpty({ message: 'Blank city names are not allowed' })
42
+ cityName!: string
43
+
44
+ @Column('varchar', { name: 'province_name', length: 255, nullable: false })
45
+ @IsNotEmpty({ message: 'Blank province names are not allowed' })
46
+ provinceName!: string
47
+
48
+ @Column('varchar', { name: 'country_code', length: 2, nullable: false })
49
+ @IsNotEmpty({ message: 'Blank country codes are not allowed' })
50
+ countryCode!: string
51
+
52
+ @Column('varchar', { name: 'building_name', length: 255, nullable: true })
53
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank building names are not allowed' })
54
+ buildingName?: string
55
+
56
+ @Column('text', { name: 'owner_id', nullable: true })
57
+ ownerId?: string
58
+
59
+ @Column('text', { name: 'tenant_id', nullable: true })
60
+ tenantId?: string
61
+
62
+ @ManyToOne(() => PartyEntity, (party: PartyEntity) => party.physicalAddresses, {
63
+ onDelete: 'CASCADE',
64
+ })
65
+ party!: PartyEntity
66
+
67
+ @Column('text', { name: 'partyId', nullable: true })
68
+ partyId?: string
69
+
70
+ @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
71
+ createdAt!: Date
72
+
73
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
74
+ lastUpdatedAt!: Date
75
+
76
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
77
+ @BeforeInsert()
78
+ @BeforeUpdate()
79
+ updateUpdatedDate(): void {
80
+ this.lastUpdatedAt = new Date()
81
+ }
82
+
83
+ @BeforeInsert()
84
+ @BeforeUpdate()
85
+ async validate(): Promise<void> {
86
+ const validation: Array<ValidationError> = await validate(this)
87
+ if (validation.length > 0) {
88
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
89
+ if (constraint) {
90
+ const message: string = Object.values(constraint!)[0]
91
+ return Promise.reject(Error(message))
92
+ }
93
+ }
94
+ }
95
+ }
@@ -1,98 +1,98 @@
1
- import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
- import {
3
- CredentialCorrelationType,
4
- CredentialDocumentFormat,
5
- CredentialRole,
6
- CredentialStateType,
7
- DigitalCredential,
8
- DocumentType,
9
- RegulationType,
10
- } from '../../types'
11
- import { typeormDate, typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
12
-
13
- @Entity('DigitalCredential')
14
- export class DigitalCredentialEntity extends BaseEntity implements DigitalCredential {
15
- @PrimaryGeneratedColumn('uuid')
16
- id!: string
17
-
18
- @Column('text', { name: 'parent_id', nullable: true })
19
- parentId?: string
20
-
21
- @Column('simple-enum', { name: 'document_type', enum: DocumentType, nullable: false })
22
- documentType!: DocumentType
23
-
24
- @Column('simple-enum', { name: 'regulation_type', enum: RegulationType, nullable: false })
25
- regulationType!: RegulationType
26
-
27
- @Column('simple-enum', { name: 'document_format', enum: CredentialDocumentFormat, nullable: false })
28
- documentFormat!: CredentialDocumentFormat
29
-
30
- @Column('simple-enum', { name: 'credential_role', enum: CredentialRole, nullable: false })
31
- credentialRole!: CredentialRole
32
-
33
- @Column('text', { name: 'raw_document', nullable: false })
34
- rawDocument!: string
35
-
36
- @Column('text', { name: 'uniform_document', nullable: false })
37
- uniformDocument!: string
38
-
39
- @Column('text', { name: 'credential_id', nullable: true, unique: false })
40
- credentialId!: string
41
-
42
- @Column('text', { name: 'hash', nullable: false, unique: true })
43
- hash!: string
44
-
45
- @Column('text', { name: 'kms_key_ref', nullable: true })
46
- kmsKeyRef!: string
47
-
48
- @Column('text', { name: 'identifier_method', nullable: true })
49
- identifierMethod!: string
50
-
51
- @Column('simple-enum', { name: 'issuer_correlation_type', enum: CredentialCorrelationType, nullable: false })
52
- issuerCorrelationType!: CredentialCorrelationType
53
-
54
- @Column('simple-enum', { name: 'subject_correlation_type', enum: CredentialCorrelationType, nullable: true })
55
- subjectCorrelationType?: CredentialCorrelationType
56
-
57
- @Column('simple-enum', { name: 'rp_correlation_type', enum: CredentialCorrelationType, nullable: true })
58
- rpCorrelationType?: CredentialCorrelationType
59
-
60
- @Column('boolean', { name: 'issuer_signed', nullable: true })
61
- isIssuerSigned?: boolean
62
-
63
- @Column('text', { name: 'issuer_correlation_id', nullable: false })
64
- issuerCorrelationId!: string
65
-
66
- @Column('text', { name: 'subject_correlation_id', nullable: true })
67
- subjectCorrelationId?: string
68
-
69
- @Column('text', { name: 'rp_correlation_id', nullable: true })
70
- rpCorrelationId?: string
71
-
72
- @Column('simple-enum', { name: 'verified_state', enum: CredentialStateType, nullable: true })
73
- verifiedState?: CredentialStateType
74
-
75
- @Column('text', { name: 'tenant_id', nullable: true })
76
- tenantId?: string
77
-
78
- @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
79
- createdAt!: Date
80
-
81
- @Column({ name: 'presented_at', nullable: true, type: typeormDate() })
82
- presentedAt?: Date
83
-
84
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
85
- lastUpdatedAt!: Date
86
-
87
- @Column({ name: 'valid_until', nullable: true, type: typeormDate() })
88
- validUntil?: Date
89
-
90
- @Column({ name: 'valid_from', nullable: true, type: typeormDate() })
91
- validFrom?: Date
92
-
93
- @Column({ name: 'verified_at', nullable: true, type: typeOrmDateTime() })
94
- verifiedAt?: Date
95
-
96
- @Column({ name: 'revoked_at', nullable: true, type: typeOrmDateTime() })
97
- revokedAt?: Date
98
- }
1
+ import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
2
+ import {
3
+ CredentialCorrelationType,
4
+ CredentialDocumentFormat,
5
+ CredentialRole,
6
+ CredentialStateType,
7
+ DigitalCredential,
8
+ DocumentType,
9
+ RegulationType,
10
+ } from '../../types'
11
+ import { typeormDate, typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
12
+
13
+ @Entity('DigitalCredential')
14
+ export class DigitalCredentialEntity extends BaseEntity implements DigitalCredential {
15
+ @PrimaryGeneratedColumn('uuid')
16
+ id!: string
17
+
18
+ @Column('text', { name: 'parent_id', nullable: true })
19
+ parentId?: string
20
+
21
+ @Column('simple-enum', { name: 'document_type', enum: DocumentType, nullable: false })
22
+ documentType!: DocumentType
23
+
24
+ @Column('simple-enum', { name: 'regulation_type', enum: RegulationType, nullable: false })
25
+ regulationType!: RegulationType
26
+
27
+ @Column('simple-enum', { name: 'document_format', enum: CredentialDocumentFormat, nullable: false })
28
+ documentFormat!: CredentialDocumentFormat
29
+
30
+ @Column('simple-enum', { name: 'credential_role', enum: CredentialRole, nullable: false })
31
+ credentialRole!: CredentialRole
32
+
33
+ @Column('text', { name: 'raw_document', nullable: false })
34
+ rawDocument!: string
35
+
36
+ @Column('text', { name: 'uniform_document', nullable: false })
37
+ uniformDocument!: string
38
+
39
+ @Column('text', { name: 'credential_id', nullable: true, unique: false })
40
+ credentialId!: string
41
+
42
+ @Column('text', { name: 'hash', nullable: false, unique: true })
43
+ hash!: string
44
+
45
+ @Column('text', { name: 'kms_key_ref', nullable: true })
46
+ kmsKeyRef!: string
47
+
48
+ @Column('text', { name: 'identifier_method', nullable: true })
49
+ identifierMethod!: string
50
+
51
+ @Column('simple-enum', { name: 'issuer_correlation_type', enum: CredentialCorrelationType, nullable: false })
52
+ issuerCorrelationType!: CredentialCorrelationType
53
+
54
+ @Column('simple-enum', { name: 'subject_correlation_type', enum: CredentialCorrelationType, nullable: true })
55
+ subjectCorrelationType?: CredentialCorrelationType
56
+
57
+ @Column('simple-enum', { name: 'rp_correlation_type', enum: CredentialCorrelationType, nullable: true })
58
+ rpCorrelationType?: CredentialCorrelationType
59
+
60
+ @Column('boolean', { name: 'issuer_signed', nullable: true })
61
+ isIssuerSigned?: boolean
62
+
63
+ @Column('text', { name: 'issuer_correlation_id', nullable: false })
64
+ issuerCorrelationId!: string
65
+
66
+ @Column('text', { name: 'subject_correlation_id', nullable: true })
67
+ subjectCorrelationId?: string
68
+
69
+ @Column('text', { name: 'rp_correlation_id', nullable: true })
70
+ rpCorrelationId?: string
71
+
72
+ @Column('simple-enum', { name: 'verified_state', enum: CredentialStateType, nullable: true })
73
+ verifiedState?: CredentialStateType
74
+
75
+ @Column('text', { name: 'tenant_id', nullable: true })
76
+ tenantId?: string
77
+
78
+ @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
79
+ createdAt!: Date
80
+
81
+ @Column({ name: 'presented_at', nullable: true, type: typeormDate() })
82
+ presentedAt?: Date
83
+
84
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
85
+ lastUpdatedAt!: Date
86
+
87
+ @Column({ name: 'valid_until', nullable: true, type: typeormDate() })
88
+ validUntil?: Date
89
+
90
+ @Column({ name: 'valid_from', nullable: true, type: typeormDate() })
91
+ validFrom?: Date
92
+
93
+ @Column({ name: 'verified_at', nullable: true, type: typeOrmDateTime() })
94
+ verifiedAt?: Date
95
+
96
+ @Column({ name: 'revoked_at', nullable: true, type: typeOrmDateTime() })
97
+ revokedAt?: Date
98
+ }