@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,48 +1,48 @@
1
- import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
2
- import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
3
- import { IMetadataEntity, ValidationConstraint } from '../../types'
4
- import { IdentityEntity } from './IdentityEntity'
5
- import { IsNotEmpty, validate, ValidationError } from 'class-validator'
6
- import { getConstraint } from '../../utils/ValidatorUtils'
7
-
8
- @Entity('IdentityMetadata')
9
- export class IdentityMetadataItemEntity 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(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
34
- identity!: IdentityEntity
35
-
36
- @BeforeInsert()
37
- @BeforeUpdate()
38
- async validate(): Promise<void> {
39
- const validation: Array<ValidationError> = await validate(this)
40
- if (validation.length > 0) {
41
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
42
- if (constraint) {
43
- const message: string = Object.values(constraint!)[0]
44
- return Promise.reject(Error(message))
45
- }
46
- }
47
- }
48
- }
1
+ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
2
+ import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
3
+ import { IMetadataEntity, ValidationConstraint } from '../../types'
4
+ import { IdentityEntity } from './IdentityEntity'
5
+ import { IsNotEmpty, validate, ValidationError } from 'class-validator'
6
+ import { getConstraint } from '../../utils/ValidatorUtils'
7
+
8
+ @Entity('IdentityMetadata')
9
+ export class IdentityMetadataItemEntity 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(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
34
+ identity!: IdentityEntity
35
+
36
+ @BeforeInsert()
37
+ @BeforeUpdate()
38
+ async validate(): Promise<void> {
39
+ const validation: Array<ValidationError> = await validate(this)
40
+ if (validation.length > 0) {
41
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
42
+ if (constraint) {
43
+ const message: string = Object.values(constraint!)[0]
44
+ return Promise.reject(Error(message))
45
+ }
46
+ }
47
+ }
48
+ }
@@ -1,44 +1,44 @@
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('varchar', { name: 'first_name', length: 255, nullable: false, unique: false })
11
- @IsNotEmpty({ message: 'Blank first names are not allowed' })
12
- firstName!: string
13
-
14
- @Column('varchar', { 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('varchar', { name: 'last_name', length: 255, nullable: false, unique: false })
19
- @IsNotEmpty({ message: 'Blank last names are not allowed' })
20
- lastName!: string
21
-
22
- @Column('varchar', { name: 'display_name', length: 255, nullable: false, unique: false })
23
- @IsNotEmpty({ message: 'Blank display names are not allowed' })
24
- displayName!: string
25
-
26
- @Column('text', { name: 'owner_id', nullable: true })
27
- ownerId?: string
28
-
29
- @Column('text', { name: 'tenant_id', nullable: true })
30
- tenantId?: string
31
-
32
- @BeforeInsert()
33
- @BeforeUpdate()
34
- async validate(): Promise<void> {
35
- const validation: Array<ValidationError> = await validate(this)
36
- if (validation.length > 0) {
37
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
38
- if (constraint) {
39
- const message: string = Object.values(constraint!)[0]
40
- return Promise.reject(Error(message))
41
- }
42
- }
43
- }
44
- }
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('varchar', { name: 'first_name', length: 255, nullable: false, unique: false })
11
+ @IsNotEmpty({ message: 'Blank first names are not allowed' })
12
+ firstName!: string
13
+
14
+ @Column('varchar', { 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('varchar', { name: 'last_name', length: 255, nullable: false, unique: false })
19
+ @IsNotEmpty({ message: 'Blank last names are not allowed' })
20
+ lastName!: string
21
+
22
+ @Column('varchar', { name: 'display_name', length: 255, nullable: false, unique: false })
23
+ @IsNotEmpty({ message: 'Blank display names are not allowed' })
24
+ displayName!: string
25
+
26
+ @Column('text', { name: 'owner_id', nullable: true })
27
+ ownerId?: string
28
+
29
+ @Column('text', { name: 'tenant_id', nullable: true })
30
+ tenantId?: string
31
+
32
+ @BeforeInsert()
33
+ @BeforeUpdate()
34
+ async validate(): Promise<void> {
35
+ const validation: Array<ValidationError> = await validate(this)
36
+ if (validation.length > 0) {
37
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
38
+ if (constraint) {
39
+ const message: string = Object.values(constraint!)[0]
40
+ return Promise.reject(Error(message))
41
+ }
42
+ }
43
+ }
44
+ }
@@ -1,32 +1,32 @@
1
- import { ChildEntity, Column } from 'typeorm'
2
- import { BaseConfigEntity } from './BaseConfigEntity'
3
-
4
- @ChildEntity('OpenIdConfig')
5
- export class OpenIdConfigEntity extends BaseConfigEntity {
6
- @Column('varchar', { name: 'client_id', length: 255, nullable: false })
7
- clientId!: string
8
-
9
- @Column('varchar', { 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('varchar', { 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
-
27
- @Column('text', { name: 'owner_id', nullable: true })
28
- ownerId?: string
29
-
30
- @Column('text', { name: 'tenant_id', nullable: true })
31
- tenantId?: string
32
- }
1
+ import { ChildEntity, Column } from 'typeorm'
2
+ import { BaseConfigEntity } from './BaseConfigEntity'
3
+
4
+ @ChildEntity('OpenIdConfig')
5
+ export class OpenIdConfigEntity extends BaseConfigEntity {
6
+ @Column('varchar', { name: 'client_id', length: 255, nullable: false })
7
+ clientId!: string
8
+
9
+ @Column('varchar', { 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('varchar', { 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
+
27
+ @Column('text', { name: 'owner_id', nullable: true })
28
+ ownerId?: string
29
+
30
+ @Column('text', { name: 'tenant_id', nullable: true })
31
+ tenantId?: string
32
+ }
@@ -1,35 +1,35 @@
1
- import { IsNotEmpty, validate, ValidationError } from 'class-validator'
2
- import { BeforeInsert, BeforeUpdate, ChildEntity, Column } from 'typeorm'
3
- import { ValidationConstraint } from '../../types'
4
- import { getConstraint } from '../../utils/ValidatorUtils'
5
- import { BaseContactEntity } from './BaseContactEntity'
6
-
7
- @ChildEntity('Organization')
8
- export class OrganizationEntity extends BaseContactEntity {
9
- @Column('varchar', { name: 'legal_name', length: 255, nullable: false, unique: true })
10
- @IsNotEmpty({ message: 'Blank legal names are not allowed' })
11
- legalName!: string
12
-
13
- @Column('varchar', { name: 'display_name', length: 255, nullable: false, unique: false })
14
- @IsNotEmpty({ message: 'Blank display names are not allowed' })
15
- displayName!: string
16
-
17
- @Column('text', { name: 'owner_id', nullable: true })
18
- ownerId?: string
19
-
20
- @Column('text', { name: 'tenant_id', nullable: true })
21
- tenantId?: string
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 { IsNotEmpty, validate, ValidationError } from 'class-validator'
2
+ import { BeforeInsert, BeforeUpdate, ChildEntity, Column } from 'typeorm'
3
+ import { ValidationConstraint } from '../../types'
4
+ import { getConstraint } from '../../utils/ValidatorUtils'
5
+ import { BaseContactEntity } from './BaseContactEntity'
6
+
7
+ @ChildEntity('Organization')
8
+ export class OrganizationEntity extends BaseContactEntity {
9
+ @Column('varchar', { name: 'legal_name', length: 255, nullable: false, unique: true })
10
+ @IsNotEmpty({ message: 'Blank legal names are not allowed' })
11
+ legalName!: string
12
+
13
+ @Column('varchar', { name: 'display_name', length: 255, nullable: false, unique: false })
14
+ @IsNotEmpty({ message: 'Blank display names are not allowed' })
15
+ displayName!: string
16
+
17
+ @Column('text', { name: 'owner_id', nullable: true })
18
+ ownerId?: string
19
+
20
+ @Column('text', { name: 'tenant_id', nullable: true })
21
+ tenantId?: string
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,117 +1,117 @@
1
- import {
2
- BaseEntity,
3
- BeforeInsert,
4
- BeforeUpdate,
5
- Column,
6
- CreateDateColumn,
7
- Entity,
8
- JoinColumn,
9
- ManyToOne,
10
- OneToMany,
11
- OneToOne,
12
- PrimaryGeneratedColumn,
13
- UpdateDateColumn,
14
- } from 'typeorm'
15
- import { ValidationConstraint } from '../../types'
16
- import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
17
- import { IdentityEntity } from './IdentityEntity'
18
- import { validate, ValidationError } from 'class-validator'
19
- import { PartyTypeEntity } from './PartyTypeEntity'
20
- import { BaseContactEntity } from './BaseContactEntity'
21
- import { PartyRelationshipEntity } from './PartyRelationshipEntity'
22
- import { getConstraint } from '../../utils/ValidatorUtils'
23
- import { ElectronicAddressEntity } from './ElectronicAddressEntity'
24
- import { PhysicalAddressEntity } from './PhysicalAddressEntity'
25
-
26
- @Entity('Party')
27
- export class PartyEntity extends BaseEntity {
28
- @PrimaryGeneratedColumn('uuid')
29
- id!: string
30
-
31
- @Column('varchar', { name: 'uri', length: 255, nullable: true })
32
- uri?: string
33
-
34
- @Column('text', { name: 'owner_id', nullable: true })
35
- ownerId?: string
36
-
37
- @Column('text', { name: 'tenant_id', nullable: true })
38
- tenantId?: string
39
-
40
- @OneToMany(() => IdentityEntity, (identity: IdentityEntity) => identity.party, {
41
- cascade: true,
42
- onDelete: 'CASCADE',
43
- eager: true,
44
- nullable: false,
45
- })
46
- @JoinColumn({ name: 'identity_id' })
47
- identities!: Array<IdentityEntity>
48
-
49
- @OneToMany(() => ElectronicAddressEntity, (electronicAddress: ElectronicAddressEntity) => electronicAddress.party, {
50
- cascade: true,
51
- onDelete: 'CASCADE',
52
- eager: true,
53
- nullable: false,
54
- })
55
- @JoinColumn({ name: 'electronic_address_id' })
56
- electronicAddresses!: Array<ElectronicAddressEntity>
57
-
58
- @OneToMany(() => PhysicalAddressEntity, (physicalAddress: PhysicalAddressEntity) => physicalAddress.party, {
59
- cascade: true,
60
- onDelete: 'CASCADE',
61
- eager: true,
62
- nullable: false,
63
- })
64
- @JoinColumn({ name: 'physical_address_id' })
65
- physicalAddresses!: Array<PhysicalAddressEntity>
66
-
67
- @ManyToOne(() => PartyTypeEntity, (contactType: PartyTypeEntity) => contactType.parties, {
68
- cascade: true,
69
- nullable: false,
70
- eager: true,
71
- })
72
- @JoinColumn({ name: 'party_type_id' })
73
- partyType!: PartyTypeEntity
74
-
75
- @OneToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.party, {
76
- cascade: true,
77
- onDelete: 'CASCADE',
78
- eager: true,
79
- nullable: false,
80
- })
81
- contact!: BaseContactEntity
82
-
83
- @OneToMany(() => PartyRelationshipEntity, (relationship: PartyRelationshipEntity) => relationship.left, {
84
- cascade: true,
85
- onDelete: 'CASCADE',
86
- eager: true,
87
- nullable: false,
88
- })
89
- @JoinColumn({ name: 'relationship_id' })
90
- relationships!: Array<PartyRelationshipEntity>
91
-
92
- @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
93
- createdAt!: Date
94
-
95
- @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
96
- lastUpdatedAt!: Date
97
-
98
- // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
99
- @BeforeInsert()
100
- @BeforeUpdate()
101
- updateUpdatedDate(): void {
102
- this.lastUpdatedAt = new Date()
103
- }
104
-
105
- @BeforeInsert()
106
- @BeforeUpdate()
107
- async validate(): Promise<void> {
108
- const validation: Array<ValidationError> = await validate(this)
109
- if (validation.length > 0) {
110
- const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
111
- if (constraint) {
112
- const message: string = Object.values(constraint!)[0]
113
- return Promise.reject(Error(message))
114
- }
115
- }
116
- }
117
- }
1
+ import {
2
+ BaseEntity,
3
+ BeforeInsert,
4
+ BeforeUpdate,
5
+ Column,
6
+ CreateDateColumn,
7
+ Entity,
8
+ JoinColumn,
9
+ ManyToOne,
10
+ OneToMany,
11
+ OneToOne,
12
+ PrimaryGeneratedColumn,
13
+ UpdateDateColumn,
14
+ } from 'typeorm'
15
+ import { ValidationConstraint } from '../../types'
16
+ import { typeOrmDateTime } from '@sphereon/ssi-sdk.agent-config'
17
+ import { IdentityEntity } from './IdentityEntity'
18
+ import { validate, ValidationError } from 'class-validator'
19
+ import { PartyTypeEntity } from './PartyTypeEntity'
20
+ import { BaseContactEntity } from './BaseContactEntity'
21
+ import { PartyRelationshipEntity } from './PartyRelationshipEntity'
22
+ import { getConstraint } from '../../utils/ValidatorUtils'
23
+ import { ElectronicAddressEntity } from './ElectronicAddressEntity'
24
+ import { PhysicalAddressEntity } from './PhysicalAddressEntity'
25
+
26
+ @Entity('Party')
27
+ export class PartyEntity extends BaseEntity {
28
+ @PrimaryGeneratedColumn('uuid')
29
+ id!: string
30
+
31
+ @Column('varchar', { name: 'uri', length: 255, nullable: true })
32
+ uri?: string
33
+
34
+ @Column('text', { name: 'owner_id', nullable: true })
35
+ ownerId?: string
36
+
37
+ @Column('text', { name: 'tenant_id', nullable: true })
38
+ tenantId?: string
39
+
40
+ @OneToMany(() => IdentityEntity, (identity: IdentityEntity) => identity.party, {
41
+ cascade: true,
42
+ onDelete: 'CASCADE',
43
+ eager: true,
44
+ nullable: false,
45
+ })
46
+ @JoinColumn({ name: 'identity_id' })
47
+ identities!: Array<IdentityEntity>
48
+
49
+ @OneToMany(() => ElectronicAddressEntity, (electronicAddress: ElectronicAddressEntity) => electronicAddress.party, {
50
+ cascade: true,
51
+ onDelete: 'CASCADE',
52
+ eager: true,
53
+ nullable: false,
54
+ })
55
+ @JoinColumn({ name: 'electronic_address_id' })
56
+ electronicAddresses!: Array<ElectronicAddressEntity>
57
+
58
+ @OneToMany(() => PhysicalAddressEntity, (physicalAddress: PhysicalAddressEntity) => physicalAddress.party, {
59
+ cascade: true,
60
+ onDelete: 'CASCADE',
61
+ eager: true,
62
+ nullable: false,
63
+ })
64
+ @JoinColumn({ name: 'physical_address_id' })
65
+ physicalAddresses!: Array<PhysicalAddressEntity>
66
+
67
+ @ManyToOne(() => PartyTypeEntity, (contactType: PartyTypeEntity) => contactType.parties, {
68
+ cascade: true,
69
+ nullable: false,
70
+ eager: true,
71
+ })
72
+ @JoinColumn({ name: 'party_type_id' })
73
+ partyType!: PartyTypeEntity
74
+
75
+ @OneToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.party, {
76
+ cascade: true,
77
+ onDelete: 'CASCADE',
78
+ eager: true,
79
+ nullable: false,
80
+ })
81
+ contact!: BaseContactEntity
82
+
83
+ @OneToMany(() => PartyRelationshipEntity, (relationship: PartyRelationshipEntity) => relationship.left, {
84
+ cascade: true,
85
+ onDelete: 'CASCADE',
86
+ eager: true,
87
+ nullable: false,
88
+ })
89
+ @JoinColumn({ name: 'relationship_id' })
90
+ relationships!: Array<PartyRelationshipEntity>
91
+
92
+ @CreateDateColumn({ name: 'created_at', nullable: false, type: typeOrmDateTime() })
93
+ createdAt!: Date
94
+
95
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false, type: typeOrmDateTime() })
96
+ lastUpdatedAt!: Date
97
+
98
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
99
+ @BeforeInsert()
100
+ @BeforeUpdate()
101
+ updateUpdatedDate(): void {
102
+ this.lastUpdatedAt = new Date()
103
+ }
104
+
105
+ @BeforeInsert()
106
+ @BeforeUpdate()
107
+ async validate(): Promise<void> {
108
+ const validation: Array<ValidationError> = await validate(this)
109
+ if (validation.length > 0) {
110
+ const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
111
+ if (constraint) {
112
+ const message: string = Object.values(constraint!)[0]
113
+ return Promise.reject(Error(message))
114
+ }
115
+ }
116
+ }
117
+ }