@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.
Files changed (146) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +77 -77
  3. package/dist/index.d.ts +3 -9
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -15
  6. package/dist/index.js.map +1 -1
  7. package/dist/migrations/generic/index.d.ts +0 -2
  8. package/dist/migrations/generic/index.d.ts.map +1 -1
  9. package/dist/migrations/generic/index.js +1 -4
  10. package/dist/migrations/generic/index.js.map +1 -1
  11. package/dist/migrations/index.d.ts +1 -1
  12. package/dist/migrations/index.d.ts.map +1 -1
  13. package/dist/migrations/index.js +1 -2
  14. package/dist/migrations/index.js.map +1 -1
  15. package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
  16. package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
  17. package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
  18. package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
  19. package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
  20. package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
  21. package/dist/types/index.d.ts +0 -2
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/dist/types/index.js +0 -2
  24. package/dist/types/index.js.map +1 -1
  25. package/package.json +4 -5
  26. package/src/__tests__/contact.entities.test.ts +2542 -2542
  27. package/src/__tests__/contact.store.test.ts +2471 -2471
  28. package/src/__tests__/digitalCredential.entities.test.ts +254 -254
  29. package/src/__tests__/digitalCredential.store.test.ts +294 -294
  30. package/src/__tests__/eventLogger.entities.test.ts +73 -73
  31. package/src/__tests__/eventLogger.store.test.ts +136 -136
  32. package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
  33. package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
  34. package/src/__tests__/machineState.entities.test.ts +51 -51
  35. package/src/__tests__/machineState.store.test.ts +174 -174
  36. package/src/contact/AbstractContactStore.ts +71 -71
  37. package/src/contact/ContactStore.ts +723 -723
  38. package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
  39. package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
  40. package/src/entities/contact/BaseContactEntity.ts +39 -39
  41. package/src/entities/contact/ConnectionEntity.ts +29 -29
  42. package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
  43. package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
  44. package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
  45. package/src/entities/contact/IdentityEntity.ts +97 -97
  46. package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
  47. package/src/entities/contact/NaturalPersonEntity.ts +38 -38
  48. package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
  49. package/src/entities/contact/OrganizationEntity.ts +34 -34
  50. package/src/entities/contact/PartyEntity.ts +110 -110
  51. package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
  52. package/src/entities/contact/PartyTypeEntity.ts +62 -62
  53. package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
  54. package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
  55. package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
  56. package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
  57. package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
  58. package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
  59. package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
  60. package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
  61. package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
  62. package/src/eventLogger/EventLoggerStore.ts +62 -62
  63. package/src/index.ts +141 -154
  64. package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
  65. package/src/machineState/IAbstractMachineStateStore.ts +65 -65
  66. package/src/machineState/MachineStateStore.ts +149 -149
  67. package/src/migrations/generic/1-CreateContacts.ts +66 -66
  68. package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
  69. package/src/migrations/generic/3-CreateContacts.ts +66 -66
  70. package/src/migrations/generic/4-CreateStatusList.ts +54 -54
  71. package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
  72. package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
  73. package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
  74. package/src/migrations/generic/index.ts +33 -36
  75. package/src/migrations/index.ts +9 -10
  76. package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
  77. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
  78. package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
  79. package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
  80. package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
  81. package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
  82. package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
  83. package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
  84. package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
  85. package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
  86. package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
  87. package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
  88. package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
  89. package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
  90. package/src/statusList/StatusListStore.ts +237 -237
  91. package/src/types/contact/IAbstractContactStore.ts +161 -161
  92. package/src/types/contact/contact.ts +237 -237
  93. package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
  94. package/src/types/digitalCredential/digitalCredential.ts +46 -46
  95. package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
  96. package/src/types/eventLogger/eventLogger.ts +3 -3
  97. package/src/types/index.ts +10 -12
  98. package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
  99. package/src/utils/SortingUtils.ts +16 -16
  100. package/src/utils/contact/MappingUtils.ts +385 -385
  101. package/src/utils/digitalCredential/MappingUtils.ts +122 -122
  102. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
  103. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
  104. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
  105. package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
  106. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
  107. package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
  108. package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
  109. package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
  110. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
  111. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
  112. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
  113. package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
  114. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
  115. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
  116. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
  117. package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
  118. package/dist/pd/AbstractPDStore.d.ts +0 -10
  119. package/dist/pd/AbstractPDStore.d.ts.map +0 -1
  120. package/dist/pd/AbstractPDStore.js +0 -7
  121. package/dist/pd/AbstractPDStore.js.map +0 -1
  122. package/dist/pd/PDStore.d.ts +0 -14
  123. package/dist/pd/PDStore.d.ts.map +0 -1
  124. package/dist/pd/PDStore.js +0 -90
  125. package/dist/pd/PDStore.js.map +0 -1
  126. package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
  127. package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
  128. package/dist/types/pd/IAbstractPDStore.js +0 -3
  129. package/dist/types/pd/IAbstractPDStore.js.map +0 -1
  130. package/dist/types/pd/pd.d.ts +0 -15
  131. package/dist/types/pd/pd.d.ts.map +0 -1
  132. package/dist/types/pd/pd.js +0 -3
  133. package/dist/types/pd/pd.js.map +0 -1
  134. package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
  135. package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
  136. package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
  137. package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
  138. package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
  139. package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
  140. package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
  141. package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
  142. package/src/pd/AbstractPDStore.ts +0 -10
  143. package/src/pd/PDStore.ts +0 -103
  144. package/src/types/pd/IAbstractPDStore.ts +0 -19
  145. package/src/types/pd/pd.ts +0 -16
  146. package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
@@ -1,97 +1,97 @@
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 { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
17
- import { ConnectionEntity } from './ConnectionEntity'
18
- import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
19
- import { IdentityRole, ValidationConstraint } from '../../types'
20
- import { PartyEntity } from './PartyEntity'
21
- import { getConstraint } from '../../utils/ValidatorUtils'
22
-
23
- @Entity('Identity')
24
- export class IdentityEntity extends BaseEntity {
25
- @PrimaryGeneratedColumn('uuid')
26
- id!: string
27
-
28
- @Column({
29
- name: 'alias',
30
- length: 255,
31
- nullable: false,
32
- unique: true,
33
- })
34
- @IsNotEmpty({ message: 'Blank aliases are not allowed' })
35
- alias!: string
36
-
37
- @Column('simple-array', { name: 'roles', nullable: false })
38
- roles!: Array<IdentityRole>
39
-
40
- @OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
41
- cascade: true,
42
- onDelete: 'CASCADE',
43
- eager: true,
44
- nullable: false,
45
- })
46
- identifier!: CorrelationIdentifierEntity
47
-
48
- @OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
49
- cascade: true,
50
- onDelete: 'CASCADE',
51
- eager: true,
52
- })
53
- connection?: ConnectionEntity
54
-
55
- @OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
56
- cascade: true,
57
- onDelete: 'CASCADE',
58
- eager: true,
59
- nullable: false,
60
- })
61
- @JoinColumn({ name: 'metadata_id' }) // TODO check in db file
62
- metadata!: Array<IdentityMetadataItemEntity>
63
-
64
- @CreateDateColumn({ name: 'created_at', nullable: false })
65
- createdAt!: Date
66
-
67
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
68
- lastUpdatedAt!: Date
69
-
70
- @ManyToOne(() => PartyEntity, (party: PartyEntity) => party.identities, {
71
- onDelete: 'CASCADE',
72
- })
73
- party!: PartyEntity
74
-
75
- @Column({ name: 'partyId', nullable: true })
76
- partyId?: string
77
-
78
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
79
- @BeforeInsert()
80
- @BeforeUpdate()
81
- updateUpdatedDate(): void {
82
- this.lastUpdatedAt = new Date()
83
- }
84
-
85
- @BeforeInsert()
86
- @BeforeUpdate()
87
- async validate(): Promise<void> {
88
- const validation: Array<ValidationError> = await validate(this)
89
- if (validation.length > 0) {
90
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
91
- if (constraint) {
92
- const message: string = Object.values(constraint!)[0]
93
- return Promise.reject(Error(message))
94
- }
95
- }
96
- }
97
- }
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 { CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
17
+ import { ConnectionEntity } from './ConnectionEntity'
18
+ import { IdentityMetadataItemEntity } from './IdentityMetadataItemEntity'
19
+ import { IdentityRole, ValidationConstraint } from '../../types'
20
+ import { PartyEntity } from './PartyEntity'
21
+ import { getConstraint } from '../../utils/ValidatorUtils'
22
+
23
+ @Entity('Identity')
24
+ export class IdentityEntity extends BaseEntity {
25
+ @PrimaryGeneratedColumn('uuid')
26
+ id!: string
27
+
28
+ @Column({
29
+ name: 'alias',
30
+ length: 255,
31
+ nullable: false,
32
+ unique: true,
33
+ })
34
+ @IsNotEmpty({ message: 'Blank aliases are not allowed' })
35
+ alias!: string
36
+
37
+ @Column('simple-array', { name: 'roles', nullable: false })
38
+ roles!: Array<IdentityRole>
39
+
40
+ @OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
41
+ cascade: true,
42
+ onDelete: 'CASCADE',
43
+ eager: true,
44
+ nullable: false,
45
+ })
46
+ identifier!: CorrelationIdentifierEntity
47
+
48
+ @OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
49
+ cascade: true,
50
+ onDelete: 'CASCADE',
51
+ eager: true,
52
+ })
53
+ connection?: ConnectionEntity
54
+
55
+ @OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
56
+ cascade: true,
57
+ onDelete: 'CASCADE',
58
+ eager: true,
59
+ nullable: false,
60
+ })
61
+ @JoinColumn({ name: 'metadata_id' }) // TODO check in db file
62
+ metadata!: Array<IdentityMetadataItemEntity>
63
+
64
+ @CreateDateColumn({ name: 'created_at', nullable: false })
65
+ createdAt!: Date
66
+
67
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
68
+ lastUpdatedAt!: Date
69
+
70
+ @ManyToOne(() => PartyEntity, (party: PartyEntity) => party.identities, {
71
+ onDelete: 'CASCADE',
72
+ })
73
+ party!: PartyEntity
74
+
75
+ @Column({ name: 'partyId', nullable: true })
76
+ partyId?: string
77
+
78
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
79
+ @BeforeInsert()
80
+ @BeforeUpdate()
81
+ updateUpdatedDate(): void {
82
+ this.lastUpdatedAt = new Date()
83
+ }
84
+
85
+ @BeforeInsert()
86
+ @BeforeUpdate()
87
+ async validate(): Promise<void> {
88
+ const validation: Array<ValidationError> = await validate(this)
89
+ if (validation.length > 0) {
90
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
91
+ if (constraint) {
92
+ const message: string = Object.values(constraint!)[0]
93
+ return Promise.reject(Error(message))
94
+ }
95
+ }
96
+ }
97
+ }
@@ -1,35 +1,35 @@
1
- import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
2
- import { 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('IdentityMetadata')
8
- export class IdentityMetadataItemEntity extends BaseEntity {
9
- @PrimaryGeneratedColumn('uuid')
10
- id!: string
11
-
12
- @Column({ name: 'label', length: 255, nullable: false })
13
- @IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
14
- label!: string
15
-
16
- @Column({ name: 'value', length: 255, nullable: false })
17
- @IsNotEmpty({ message: 'Blank metadata values are not allowed' })
18
- value!: string
19
-
20
- @ManyToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
21
- identity!: IdentityEntity
22
-
23
- @BeforeInsert()
24
- @BeforeUpdate()
25
- async validate(): Promise<void> {
26
- const validation: Array<ValidationError> = await validate(this)
27
- if (validation.length > 0) {
28
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
29
- if (constraint) {
30
- const message: string = Object.values(constraint!)[0]
31
- return Promise.reject(Error(message))
32
- }
33
- }
34
- }
35
- }
1
+ import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
2
+ import { 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('IdentityMetadata')
8
+ export class IdentityMetadataItemEntity extends BaseEntity {
9
+ @PrimaryGeneratedColumn('uuid')
10
+ id!: string
11
+
12
+ @Column({ name: 'label', length: 255, nullable: false })
13
+ @IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
14
+ label!: string
15
+
16
+ @Column({ name: 'value', length: 255, nullable: false })
17
+ @IsNotEmpty({ message: 'Blank metadata values are not allowed' })
18
+ value!: string
19
+
20
+ @ManyToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
21
+ identity!: IdentityEntity
22
+
23
+ @BeforeInsert()
24
+ @BeforeUpdate()
25
+ async validate(): Promise<void> {
26
+ const validation: Array<ValidationError> = await validate(this)
27
+ if (validation.length > 0) {
28
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
29
+ if (constraint) {
30
+ const message: string = Object.values(constraint!)[0]
31
+ return Promise.reject(Error(message))
32
+ }
33
+ }
34
+ }
35
+ }
@@ -1,38 +1,38 @@
1
- import { Column, ChildEntity, BeforeInsert, BeforeUpdate } from 'typeorm'
2
- import { BaseContactEntity } from './BaseContactEntity'
3
- import { ValidationConstraint } from '../../types'
4
- import { validate, IsNotEmpty, ValidationError, Validate } from 'class-validator'
5
- import { IsNonEmptyStringConstraint } from '../validators'
6
- import { getConstraint } from '../../utils/ValidatorUtils'
7
-
8
- @ChildEntity('NaturalPerson')
9
- export class NaturalPersonEntity extends BaseContactEntity {
10
- @Column({ name: 'first_name', length: 255, nullable: false, unique: false })
11
- @IsNotEmpty({ message: 'Blank first names are not allowed' })
12
- firstName!: string
13
-
14
- @Column({ name: 'middle_name', length: 255, nullable: true, unique: false })
15
- @Validate(IsNonEmptyStringConstraint, { message: 'Blank middle names are not allowed' })
16
- middleName?: string
17
-
18
- @Column({ name: 'last_name', length: 255, nullable: false, unique: false })
19
- @IsNotEmpty({ message: 'Blank last names are not allowed' })
20
- lastName!: string
21
-
22
- @Column({ name: 'display_name', length: 255, nullable: false, unique: false })
23
- @IsNotEmpty({ message: 'Blank display names are not allowed' })
24
- displayName!: string
25
-
26
- @BeforeInsert()
27
- @BeforeUpdate()
28
- async validate(): Promise<void> {
29
- const validation: Array<ValidationError> = await validate(this)
30
- if (validation.length > 0) {
31
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
32
- if (constraint) {
33
- const message: string = Object.values(constraint!)[0]
34
- return Promise.reject(Error(message))
35
- }
36
- }
37
- }
38
- }
1
+ import { Column, ChildEntity, BeforeInsert, BeforeUpdate } from 'typeorm'
2
+ import { BaseContactEntity } from './BaseContactEntity'
3
+ import { ValidationConstraint } from '../../types'
4
+ import { validate, IsNotEmpty, ValidationError, Validate } from 'class-validator'
5
+ import { IsNonEmptyStringConstraint } from '../validators'
6
+ import { getConstraint } from '../../utils/ValidatorUtils'
7
+
8
+ @ChildEntity('NaturalPerson')
9
+ export class NaturalPersonEntity extends BaseContactEntity {
10
+ @Column({ name: 'first_name', length: 255, nullable: false, unique: false })
11
+ @IsNotEmpty({ message: 'Blank first names are not allowed' })
12
+ firstName!: string
13
+
14
+ @Column({ name: 'middle_name', length: 255, nullable: true, unique: false })
15
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank middle names are not allowed' })
16
+ middleName?: string
17
+
18
+ @Column({ name: 'last_name', length: 255, nullable: false, unique: false })
19
+ @IsNotEmpty({ message: 'Blank last names are not allowed' })
20
+ lastName!: string
21
+
22
+ @Column({ name: 'display_name', length: 255, nullable: false, unique: false })
23
+ @IsNotEmpty({ message: 'Blank display names are not allowed' })
24
+ displayName!: string
25
+
26
+ @BeforeInsert()
27
+ @BeforeUpdate()
28
+ async validate(): Promise<void> {
29
+ const validation: Array<ValidationError> = await validate(this)
30
+ if (validation.length > 0) {
31
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
32
+ if (constraint) {
33
+ const message: string = Object.values(constraint!)[0]
34
+ return Promise.reject(Error(message))
35
+ }
36
+ }
37
+ }
38
+ }
@@ -1,26 +1,26 @@
1
- import { ChildEntity, Column } from 'typeorm'
2
- import { BaseConfigEntity } from './BaseConfigEntity'
3
-
4
- @ChildEntity('OpenIdConfig')
5
- export class OpenIdConfigEntity extends BaseConfigEntity {
6
- @Column({ name: 'client_id', length: 255, nullable: false })
7
- clientId!: string
8
-
9
- @Column({ name: 'client_secret', length: 255, nullable: false })
10
- clientSecret!: string
11
-
12
- @Column('simple-array', { name: 'scopes', nullable: false })
13
- scopes!: Array<string>
14
-
15
- @Column({ name: 'issuer', length: 255, nullable: false })
16
- issuer!: string
17
-
18
- @Column('text', { name: 'redirect_url', nullable: false })
19
- redirectUrl!: string
20
-
21
- @Column('boolean', { name: 'dangerously_allow_insecure_http_requests', nullable: false })
22
- dangerouslyAllowInsecureHttpRequests!: boolean
23
-
24
- @Column('text', { name: 'client_auth_method', nullable: false })
25
- clientAuthMethod!: 'basic' | 'post' | undefined
26
- }
1
+ import { ChildEntity, Column } from 'typeorm'
2
+ import { BaseConfigEntity } from './BaseConfigEntity'
3
+
4
+ @ChildEntity('OpenIdConfig')
5
+ export class OpenIdConfigEntity extends BaseConfigEntity {
6
+ @Column({ name: 'client_id', length: 255, nullable: false })
7
+ clientId!: string
8
+
9
+ @Column({ name: 'client_secret', length: 255, nullable: false })
10
+ clientSecret!: string
11
+
12
+ @Column('simple-array', { name: 'scopes', nullable: false })
13
+ scopes!: Array<string>
14
+
15
+ @Column({ name: 'issuer', length: 255, nullable: false })
16
+ issuer!: string
17
+
18
+ @Column('text', { name: 'redirect_url', nullable: false })
19
+ redirectUrl!: string
20
+
21
+ @Column('boolean', { name: 'dangerously_allow_insecure_http_requests', nullable: false })
22
+ dangerouslyAllowInsecureHttpRequests!: boolean
23
+
24
+ @Column('text', { name: 'client_auth_method', nullable: false })
25
+ clientAuthMethod!: 'basic' | 'post' | undefined
26
+ }
@@ -1,34 +1,34 @@
1
- import { JoinColumn, OneToOne, Column, ChildEntity, BeforeInsert, BeforeUpdate } from 'typeorm'
2
- import { PartyEntity } from './PartyEntity'
3
- import { BaseContactEntity } from './BaseContactEntity'
4
- import { ValidationConstraint } from '../../types'
5
- import { validate, IsNotEmpty, ValidationError } from 'class-validator'
6
- import { getConstraint } from '../../utils/ValidatorUtils'
7
-
8
- @ChildEntity('Organization')
9
- export class OrganizationEntity extends BaseContactEntity {
10
- @Column({ name: 'legal_name', length: 255, nullable: false, unique: true })
11
- @IsNotEmpty({ message: 'Blank legal names are not allowed' })
12
- legalName!: string
13
-
14
- @Column({ name: 'display_name', length: 255, nullable: false, unique: false })
15
- @IsNotEmpty({ message: 'Blank display names are not allowed' })
16
- displayName!: string
17
-
18
- @OneToOne(() => PartyEntity)
19
- @JoinColumn({ name: 'party_id' })
20
- party!: PartyEntity
21
-
22
- @BeforeInsert()
23
- @BeforeUpdate()
24
- async validate(): Promise<void> {
25
- const validation: Array<ValidationError> = await validate(this)
26
- if (validation.length > 0) {
27
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
28
- if (constraint) {
29
- const message: string = Object.values(constraint!)[0]
30
- return Promise.reject(Error(message))
31
- }
32
- }
33
- }
34
- }
1
+ import { JoinColumn, OneToOne, Column, ChildEntity, BeforeInsert, BeforeUpdate } from 'typeorm'
2
+ import { PartyEntity } from './PartyEntity'
3
+ import { BaseContactEntity } from './BaseContactEntity'
4
+ import { ValidationConstraint } from '../../types'
5
+ import { validate, IsNotEmpty, ValidationError } from 'class-validator'
6
+ import { getConstraint } from '../../utils/ValidatorUtils'
7
+
8
+ @ChildEntity('Organization')
9
+ export class OrganizationEntity extends BaseContactEntity {
10
+ @Column({ name: 'legal_name', length: 255, nullable: false, unique: true })
11
+ @IsNotEmpty({ message: 'Blank legal names are not allowed' })
12
+ legalName!: string
13
+
14
+ @Column({ name: 'display_name', length: 255, nullable: false, unique: false })
15
+ @IsNotEmpty({ message: 'Blank display names are not allowed' })
16
+ displayName!: string
17
+
18
+ @OneToOne(() => PartyEntity)
19
+ @JoinColumn({ name: 'party_id' })
20
+ party!: PartyEntity
21
+
22
+ @BeforeInsert()
23
+ @BeforeUpdate()
24
+ async validate(): Promise<void> {
25
+ const validation: Array<ValidationError> = await validate(this)
26
+ if (validation.length > 0) {
27
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
28
+ if (constraint) {
29
+ const message: string = Object.values(constraint!)[0]
30
+ return Promise.reject(Error(message))
31
+ }
32
+ }
33
+ }
34
+ }