@sphereon/ssi-sdk.data-store 0.23.5-unstable.88 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +77 -77
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -15
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/index.d.ts +0 -2
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +1 -4
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -2
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1708525189001-CreateDigitalCredential.js +22 -22
- package/dist/migrations/postgres/1708797018115-CreateMachineStateStore.js +16 -16
- package/dist/migrations/sqlite/1708525189002-CreateDigitalCredential.js +21 -21
- package/dist/migrations/sqlite/1708796002272-CreateMachineStateStore.js +15 -15
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -5
- package/src/__tests__/contact.entities.test.ts +2542 -2542
- package/src/__tests__/contact.store.test.ts +2471 -2471
- package/src/__tests__/digitalCredential.entities.test.ts +254 -254
- package/src/__tests__/digitalCredential.store.test.ts +294 -294
- package/src/__tests__/eventLogger.entities.test.ts +73 -73
- package/src/__tests__/eventLogger.store.test.ts +136 -136
- package/src/__tests__/issuanceBranding.entities.test.ts +844 -844
- package/src/__tests__/issuanceBranding.store.test.ts +1884 -1884
- package/src/__tests__/machineState.entities.test.ts +51 -51
- package/src/__tests__/machineState.store.test.ts +174 -174
- package/src/contact/AbstractContactStore.ts +71 -71
- package/src/contact/ContactStore.ts +723 -723
- package/src/digitalCredential/AbstractDigitalCredentialStore.ts +17 -17
- package/src/digitalCredential/DigitalCredentialStore.ts +127 -127
- package/src/entities/contact/BaseContactEntity.ts +39 -39
- package/src/entities/contact/ConnectionEntity.ts +29 -29
- package/src/entities/contact/CorrelationIdentifierEntity.ts +37 -37
- package/src/entities/contact/DidAuthConfigEntity.ts +14 -14
- package/src/entities/contact/ElectronicAddressEntity.ts +63 -63
- package/src/entities/contact/IdentityEntity.ts +97 -97
- package/src/entities/contact/IdentityMetadataItemEntity.ts +35 -35
- package/src/entities/contact/NaturalPersonEntity.ts +38 -38
- package/src/entities/contact/OpenIdConfigEntity.ts +26 -26
- package/src/entities/contact/OrganizationEntity.ts +34 -34
- package/src/entities/contact/PartyEntity.ts +110 -110
- package/src/entities/contact/PartyRelationshipEntity.ts +61 -61
- package/src/entities/contact/PartyTypeEntity.ts +62 -62
- package/src/entities/contact/PhysicalAddressEntity.ts +87 -87
- package/src/entities/digitalCredential/DigitalCredentialEntity.ts +64 -64
- package/src/entities/eventLogger/AuditEventEntity.ts +99 -99
- package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -78
- package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -57
- package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -72
- package/src/entities/machineState/MachineStateInfoEntity.ts +58 -58
- package/src/entities/statusList2021/StatusList2021Entity.ts +96 -96
- package/src/eventLogger/AbstractEventLoggerStore.ts +7 -7
- package/src/eventLogger/EventLoggerStore.ts +62 -62
- package/src/index.ts +141 -154
- package/src/issuanceBranding/IssuanceBrandingStore.ts +559 -559
- package/src/machineState/IAbstractMachineStateStore.ts +65 -65
- package/src/machineState/MachineStateStore.ts +149 -149
- package/src/migrations/generic/1-CreateContacts.ts +66 -66
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +64 -64
- package/src/migrations/generic/3-CreateContacts.ts +66 -66
- package/src/migrations/generic/4-CreateStatusList.ts +54 -54
- package/src/migrations/generic/5-CreateAuditEvents.ts +66 -66
- package/src/migrations/generic/6-CreateDigitalCredential.ts +66 -66
- package/src/migrations/generic/7-CreateMachineStateStore.ts +66 -66
- package/src/migrations/generic/index.ts +33 -36
- package/src/migrations/index.ts +9 -10
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +63 -63
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +85 -85
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +104 -104
- package/src/migrations/postgres/1693866470001-CreateStatusList.ts +24 -24
- package/src/migrations/postgres/1701634812183-CreateAuditEvents.ts +33 -33
- package/src/migrations/postgres/1708525189001-CreateDigitalCredential.ts +44 -44
- package/src/migrations/postgres/1708797018115-CreateMachineStateStore.ts +29 -29
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -110
- package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -119
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +161 -161
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -24
- package/src/migrations/sqlite/1701634819487-CreateAuditEvents.ts +15 -15
- package/src/migrations/sqlite/1708525189002-CreateDigitalCredential.ts +34 -34
- package/src/migrations/sqlite/1708796002272-CreateMachineStateStore.ts +28 -28
- package/src/statusList/StatusListStore.ts +237 -237
- package/src/types/contact/IAbstractContactStore.ts +161 -161
- package/src/types/contact/contact.ts +237 -237
- package/src/types/digitalCredential/IAbstractDigitalCredentialStore.ts +37 -37
- package/src/types/digitalCredential/digitalCredential.ts +46 -46
- package/src/types/eventLogger/IAbstractEventLoggerStore.ts +12 -12
- package/src/types/eventLogger/eventLogger.ts +3 -3
- package/src/types/index.ts +10 -12
- package/src/types/machineState/IAbstractMachineStateStore.ts +68 -68
- package/src/utils/SortingUtils.ts +16 -16
- package/src/utils/contact/MappingUtils.ts +385 -385
- package/src/utils/digitalCredential/MappingUtils.ts +122 -122
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts +0 -13
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.d.ts.map +0 -1
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js +0 -71
- package/dist/entities/presentationDefinitions/PresentationDefinitionItemEntity.js.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/generic/8-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js +0 -78
- package/dist/migrations/generic/8-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js +0 -40
- package/dist/migrations/postgres/1716475165345-CreatePresentationDefinitions.js.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts +0 -7
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.d.ts.map +0 -1
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js +0 -37
- package/dist/migrations/sqlite/1716475165344-CreatePresentationDefinitions.js.map +0 -1
- package/dist/pd/AbstractPDStore.d.ts +0 -10
- package/dist/pd/AbstractPDStore.d.ts.map +0 -1
- package/dist/pd/AbstractPDStore.js +0 -7
- package/dist/pd/AbstractPDStore.js.map +0 -1
- package/dist/pd/PDStore.d.ts +0 -14
- package/dist/pd/PDStore.d.ts.map +0 -1
- package/dist/pd/PDStore.js +0 -90
- package/dist/pd/PDStore.js.map +0 -1
- package/dist/types/pd/IAbstractPDStore.d.ts +0 -14
- package/dist/types/pd/IAbstractPDStore.d.ts.map +0 -1
- package/dist/types/pd/IAbstractPDStore.js +0 -3
- package/dist/types/pd/IAbstractPDStore.js.map +0 -1
- package/dist/types/pd/pd.d.ts +0 -15
- package/dist/types/pd/pd.d.ts.map +0 -1
- package/dist/types/pd/pd.js +0 -3
- package/dist/types/pd/pd.js.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts +0 -6
- package/dist/utils/presentationDefinitions/MappingUtils.d.ts.map +0 -1
- package/dist/utils/presentationDefinitions/MappingUtils.js +0 -50
- package/dist/utils/presentationDefinitions/MappingUtils.js.map +0 -1
- package/src/entities/presentationDefinitions/PresentationDefinitionItemEntity.ts +0 -41
- package/src/migrations/generic/8-CreatePresentationDefinitions.ts +0 -66
- package/src/migrations/postgres/1716475165345-CreatePresentationDefinitions.ts +0 -24
- package/src/migrations/sqlite/1716475165344-CreatePresentationDefinitions.ts +0 -23
- package/src/pd/AbstractPDStore.ts +0 -10
- package/src/pd/PDStore.ts +0 -103
- package/src/types/pd/IAbstractPDStore.ts +0 -19
- package/src/types/pd/pd.ts +0 -16
- package/src/utils/presentationDefinitions/MappingUtils.ts +0 -54
|
@@ -1,110 +1,110 @@
|
|
|
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 { IdentityEntity } from './IdentityEntity'
|
|
17
|
-
import { validate, ValidationError } from 'class-validator'
|
|
18
|
-
import { PartyTypeEntity } from './PartyTypeEntity'
|
|
19
|
-
import { BaseContactEntity } from './BaseContactEntity'
|
|
20
|
-
import { PartyRelationshipEntity } from './PartyRelationshipEntity'
|
|
21
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
22
|
-
import { ElectronicAddressEntity } from './ElectronicAddressEntity'
|
|
23
|
-
import { PhysicalAddressEntity } from './PhysicalAddressEntity'
|
|
24
|
-
|
|
25
|
-
@Entity('Party')
|
|
26
|
-
export class PartyEntity extends BaseEntity {
|
|
27
|
-
@PrimaryGeneratedColumn('uuid')
|
|
28
|
-
id!: string
|
|
29
|
-
|
|
30
|
-
@Column({ name: 'uri', length: 255, nullable: true })
|
|
31
|
-
uri?: string
|
|
32
|
-
|
|
33
|
-
@OneToMany(() => IdentityEntity, (identity: IdentityEntity) => identity.party, {
|
|
34
|
-
cascade: true,
|
|
35
|
-
onDelete: 'CASCADE',
|
|
36
|
-
eager: true,
|
|
37
|
-
nullable: false,
|
|
38
|
-
})
|
|
39
|
-
@JoinColumn({ name: 'identity_id' })
|
|
40
|
-
identities!: Array<IdentityEntity>
|
|
41
|
-
|
|
42
|
-
@OneToMany(() => ElectronicAddressEntity, (electronicAddress: ElectronicAddressEntity) => electronicAddress.party, {
|
|
43
|
-
cascade: true,
|
|
44
|
-
onDelete: 'CASCADE',
|
|
45
|
-
eager: true,
|
|
46
|
-
nullable: false,
|
|
47
|
-
})
|
|
48
|
-
@JoinColumn({ name: 'electronic_address_id' })
|
|
49
|
-
electronicAddresses!: Array<ElectronicAddressEntity>
|
|
50
|
-
|
|
51
|
-
@OneToMany(() => PhysicalAddressEntity, (physicalAddress: PhysicalAddressEntity) => physicalAddress.party, {
|
|
52
|
-
cascade: true,
|
|
53
|
-
onDelete: 'CASCADE',
|
|
54
|
-
eager: true,
|
|
55
|
-
nullable: false,
|
|
56
|
-
})
|
|
57
|
-
@JoinColumn({ name: 'physical_address_id' })
|
|
58
|
-
physicalAddresses!: Array<PhysicalAddressEntity>
|
|
59
|
-
|
|
60
|
-
@ManyToOne(() => PartyTypeEntity, (contactType: PartyTypeEntity) => contactType.parties, {
|
|
61
|
-
cascade: true,
|
|
62
|
-
nullable: false,
|
|
63
|
-
eager: true,
|
|
64
|
-
})
|
|
65
|
-
@JoinColumn({ name: 'party_type_id' })
|
|
66
|
-
partyType!: PartyTypeEntity
|
|
67
|
-
|
|
68
|
-
@OneToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.party, {
|
|
69
|
-
cascade: true,
|
|
70
|
-
onDelete: 'CASCADE',
|
|
71
|
-
eager: true,
|
|
72
|
-
nullable: false,
|
|
73
|
-
})
|
|
74
|
-
contact!: BaseContactEntity
|
|
75
|
-
|
|
76
|
-
@OneToMany(() => PartyRelationshipEntity, (relationship: PartyRelationshipEntity) => relationship.left, {
|
|
77
|
-
cascade: true,
|
|
78
|
-
onDelete: 'CASCADE',
|
|
79
|
-
eager: true,
|
|
80
|
-
nullable: false,
|
|
81
|
-
})
|
|
82
|
-
@JoinColumn({ name: 'relationship_id' })
|
|
83
|
-
relationships!: Array<PartyRelationshipEntity>
|
|
84
|
-
|
|
85
|
-
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
86
|
-
createdAt!: Date
|
|
87
|
-
|
|
88
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
89
|
-
lastUpdatedAt!: Date
|
|
90
|
-
|
|
91
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
92
|
-
@BeforeInsert()
|
|
93
|
-
@BeforeUpdate()
|
|
94
|
-
updateUpdatedDate(): void {
|
|
95
|
-
this.lastUpdatedAt = new Date()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@BeforeInsert()
|
|
99
|
-
@BeforeUpdate()
|
|
100
|
-
async validate(): Promise<void> {
|
|
101
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
102
|
-
if (validation.length > 0) {
|
|
103
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
104
|
-
if (constraint) {
|
|
105
|
-
const message: string = Object.values(constraint!)[0]
|
|
106
|
-
return Promise.reject(Error(message))
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
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 { IdentityEntity } from './IdentityEntity'
|
|
17
|
+
import { validate, ValidationError } from 'class-validator'
|
|
18
|
+
import { PartyTypeEntity } from './PartyTypeEntity'
|
|
19
|
+
import { BaseContactEntity } from './BaseContactEntity'
|
|
20
|
+
import { PartyRelationshipEntity } from './PartyRelationshipEntity'
|
|
21
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
22
|
+
import { ElectronicAddressEntity } from './ElectronicAddressEntity'
|
|
23
|
+
import { PhysicalAddressEntity } from './PhysicalAddressEntity'
|
|
24
|
+
|
|
25
|
+
@Entity('Party')
|
|
26
|
+
export class PartyEntity extends BaseEntity {
|
|
27
|
+
@PrimaryGeneratedColumn('uuid')
|
|
28
|
+
id!: string
|
|
29
|
+
|
|
30
|
+
@Column({ name: 'uri', length: 255, nullable: true })
|
|
31
|
+
uri?: string
|
|
32
|
+
|
|
33
|
+
@OneToMany(() => IdentityEntity, (identity: IdentityEntity) => identity.party, {
|
|
34
|
+
cascade: true,
|
|
35
|
+
onDelete: 'CASCADE',
|
|
36
|
+
eager: true,
|
|
37
|
+
nullable: false,
|
|
38
|
+
})
|
|
39
|
+
@JoinColumn({ name: 'identity_id' })
|
|
40
|
+
identities!: Array<IdentityEntity>
|
|
41
|
+
|
|
42
|
+
@OneToMany(() => ElectronicAddressEntity, (electronicAddress: ElectronicAddressEntity) => electronicAddress.party, {
|
|
43
|
+
cascade: true,
|
|
44
|
+
onDelete: 'CASCADE',
|
|
45
|
+
eager: true,
|
|
46
|
+
nullable: false,
|
|
47
|
+
})
|
|
48
|
+
@JoinColumn({ name: 'electronic_address_id' })
|
|
49
|
+
electronicAddresses!: Array<ElectronicAddressEntity>
|
|
50
|
+
|
|
51
|
+
@OneToMany(() => PhysicalAddressEntity, (physicalAddress: PhysicalAddressEntity) => physicalAddress.party, {
|
|
52
|
+
cascade: true,
|
|
53
|
+
onDelete: 'CASCADE',
|
|
54
|
+
eager: true,
|
|
55
|
+
nullable: false,
|
|
56
|
+
})
|
|
57
|
+
@JoinColumn({ name: 'physical_address_id' })
|
|
58
|
+
physicalAddresses!: Array<PhysicalAddressEntity>
|
|
59
|
+
|
|
60
|
+
@ManyToOne(() => PartyTypeEntity, (contactType: PartyTypeEntity) => contactType.parties, {
|
|
61
|
+
cascade: true,
|
|
62
|
+
nullable: false,
|
|
63
|
+
eager: true,
|
|
64
|
+
})
|
|
65
|
+
@JoinColumn({ name: 'party_type_id' })
|
|
66
|
+
partyType!: PartyTypeEntity
|
|
67
|
+
|
|
68
|
+
@OneToOne(() => BaseContactEntity, (contact: BaseContactEntity) => contact.party, {
|
|
69
|
+
cascade: true,
|
|
70
|
+
onDelete: 'CASCADE',
|
|
71
|
+
eager: true,
|
|
72
|
+
nullable: false,
|
|
73
|
+
})
|
|
74
|
+
contact!: BaseContactEntity
|
|
75
|
+
|
|
76
|
+
@OneToMany(() => PartyRelationshipEntity, (relationship: PartyRelationshipEntity) => relationship.left, {
|
|
77
|
+
cascade: true,
|
|
78
|
+
onDelete: 'CASCADE',
|
|
79
|
+
eager: true,
|
|
80
|
+
nullable: false,
|
|
81
|
+
})
|
|
82
|
+
@JoinColumn({ name: 'relationship_id' })
|
|
83
|
+
relationships!: Array<PartyRelationshipEntity>
|
|
84
|
+
|
|
85
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
86
|
+
createdAt!: Date
|
|
87
|
+
|
|
88
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
89
|
+
lastUpdatedAt!: Date
|
|
90
|
+
|
|
91
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
92
|
+
@BeforeInsert()
|
|
93
|
+
@BeforeUpdate()
|
|
94
|
+
updateUpdatedDate(): void {
|
|
95
|
+
this.lastUpdatedAt = new Date()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@BeforeInsert()
|
|
99
|
+
@BeforeUpdate()
|
|
100
|
+
async validate(): Promise<void> {
|
|
101
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
102
|
+
if (validation.length > 0) {
|
|
103
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
104
|
+
if (constraint) {
|
|
105
|
+
const message: string = Object.values(constraint!)[0]
|
|
106
|
+
return Promise.reject(Error(message))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
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 { PartyEntity } from './PartyEntity'
|
|
14
|
-
|
|
15
|
-
@Entity('PartyRelationship')
|
|
16
|
-
@Index('IDX_PartyRelationship_left_right', ['left', 'right'], { unique: true })
|
|
17
|
-
export class PartyRelationshipEntity {
|
|
18
|
-
@PrimaryGeneratedColumn('uuid')
|
|
19
|
-
id!: string
|
|
20
|
-
|
|
21
|
-
@ManyToOne(() => PartyEntity, {
|
|
22
|
-
nullable: false,
|
|
23
|
-
onDelete: 'CASCADE',
|
|
24
|
-
})
|
|
25
|
-
@JoinColumn({ name: 'left_id' })
|
|
26
|
-
left!: PartyEntity
|
|
27
|
-
|
|
28
|
-
@Column({ name: 'left_id', nullable: false })
|
|
29
|
-
leftId!: string
|
|
30
|
-
|
|
31
|
-
@ManyToOne(() => PartyEntity, {
|
|
32
|
-
nullable: false,
|
|
33
|
-
onDelete: 'CASCADE',
|
|
34
|
-
})
|
|
35
|
-
@JoinColumn({ name: 'right_id' })
|
|
36
|
-
right!: PartyEntity
|
|
37
|
-
|
|
38
|
-
@Column({ name: 'right_id', nullable: false })
|
|
39
|
-
rightId!: string
|
|
40
|
-
|
|
41
|
-
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
42
|
-
createdAt!: Date
|
|
43
|
-
|
|
44
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
45
|
-
lastUpdatedAt!: Date
|
|
46
|
-
|
|
47
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
48
|
-
@BeforeInsert()
|
|
49
|
-
@BeforeUpdate()
|
|
50
|
-
updateUpdatedDate(): void {
|
|
51
|
-
this.lastUpdatedAt = new Date()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@BeforeInsert()
|
|
55
|
-
@BeforeUpdate()
|
|
56
|
-
async checkRelationshipSides(): Promise<void> {
|
|
57
|
-
if ((this.left?.id ?? this.leftId) === (this.right?.id ?? this.rightId)) {
|
|
58
|
-
return Promise.reject(Error('Cannot use the same id for both sides of the relationship'))
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
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 { PartyEntity } from './PartyEntity'
|
|
14
|
+
|
|
15
|
+
@Entity('PartyRelationship')
|
|
16
|
+
@Index('IDX_PartyRelationship_left_right', ['left', 'right'], { unique: true })
|
|
17
|
+
export class PartyRelationshipEntity {
|
|
18
|
+
@PrimaryGeneratedColumn('uuid')
|
|
19
|
+
id!: string
|
|
20
|
+
|
|
21
|
+
@ManyToOne(() => PartyEntity, {
|
|
22
|
+
nullable: false,
|
|
23
|
+
onDelete: 'CASCADE',
|
|
24
|
+
})
|
|
25
|
+
@JoinColumn({ name: 'left_id' })
|
|
26
|
+
left!: PartyEntity
|
|
27
|
+
|
|
28
|
+
@Column({ name: 'left_id', nullable: false })
|
|
29
|
+
leftId!: string
|
|
30
|
+
|
|
31
|
+
@ManyToOne(() => PartyEntity, {
|
|
32
|
+
nullable: false,
|
|
33
|
+
onDelete: 'CASCADE',
|
|
34
|
+
})
|
|
35
|
+
@JoinColumn({ name: 'right_id' })
|
|
36
|
+
right!: PartyEntity
|
|
37
|
+
|
|
38
|
+
@Column({ name: 'right_id', nullable: false })
|
|
39
|
+
rightId!: string
|
|
40
|
+
|
|
41
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
42
|
+
createdAt!: Date
|
|
43
|
+
|
|
44
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
45
|
+
lastUpdatedAt!: Date
|
|
46
|
+
|
|
47
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
48
|
+
@BeforeInsert()
|
|
49
|
+
@BeforeUpdate()
|
|
50
|
+
updateUpdatedDate(): void {
|
|
51
|
+
this.lastUpdatedAt = new Date()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@BeforeInsert()
|
|
55
|
+
@BeforeUpdate()
|
|
56
|
+
async checkRelationshipSides(): Promise<void> {
|
|
57
|
+
if ((this.left?.id ?? this.leftId) === (this.right?.id ?? this.rightId)) {
|
|
58
|
+
return Promise.reject(Error('Cannot use the same id for both sides of the relationship'))
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
-
import { PartyEntity } from './PartyEntity'
|
|
3
|
-
import { PartyOrigin, PartyTypeType, ValidationConstraint } from '../../types'
|
|
4
|
-
import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
|
|
5
|
-
import { IsNonEmptyStringConstraint } from '../validators'
|
|
6
|
-
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
7
|
-
|
|
8
|
-
@Entity('PartyType')
|
|
9
|
-
@Index('IDX_PartyType_type_tenant_id', ['type', 'tenantId'], { unique: true })
|
|
10
|
-
export class PartyTypeEntity {
|
|
11
|
-
@PrimaryGeneratedColumn('uuid')
|
|
12
|
-
id!: string
|
|
13
|
-
|
|
14
|
-
@Column('simple-enum', { name: 'type', enum: PartyTypeType, nullable: false, unique: false })
|
|
15
|
-
type!: PartyTypeType
|
|
16
|
-
|
|
17
|
-
@Column('simple-enum', { name: 'origin', enum: PartyOrigin, default: 'EXTERNAL', nullable: false, unique: false })
|
|
18
|
-
origin!: PartyOrigin
|
|
19
|
-
|
|
20
|
-
@Column({ name: 'name', length: 255, nullable: false, unique: true })
|
|
21
|
-
@IsNotEmpty({ message: 'Blank names are not allowed' })
|
|
22
|
-
name!: string
|
|
23
|
-
|
|
24
|
-
@Column({ name: 'description', length: 255, nullable: true, unique: false })
|
|
25
|
-
@Validate(IsNonEmptyStringConstraint, { message: 'Blank descriptions are not allowed' })
|
|
26
|
-
description?: string
|
|
27
|
-
|
|
28
|
-
@Column({ name: 'tenant_id', length: 255, nullable: false, unique: false })
|
|
29
|
-
@IsNotEmpty({ message: "Blank tenant id's are not allowed" })
|
|
30
|
-
tenantId!: string
|
|
31
|
-
|
|
32
|
-
@OneToMany(() => PartyEntity, (party: PartyEntity) => party.partyType, {
|
|
33
|
-
nullable: false,
|
|
34
|
-
})
|
|
35
|
-
parties!: Array<PartyEntity>
|
|
36
|
-
|
|
37
|
-
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
38
|
-
createdAt!: Date
|
|
39
|
-
|
|
40
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
41
|
-
lastUpdatedAt!: Date
|
|
42
|
-
|
|
43
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
44
|
-
@BeforeInsert()
|
|
45
|
-
@BeforeUpdate()
|
|
46
|
-
updateUpdatedDate(): void {
|
|
47
|
-
this.lastUpdatedAt = new Date()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@BeforeInsert()
|
|
51
|
-
@BeforeUpdate()
|
|
52
|
-
async validate(): Promise<void> {
|
|
53
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
54
|
-
if (validation.length > 0) {
|
|
55
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
56
|
-
if (constraint) {
|
|
57
|
-
const message: string = Object.values(constraint!)[0]
|
|
58
|
-
return Promise.reject(Error(message))
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
import { BeforeInsert, BeforeUpdate, Column, CreateDateColumn, Entity, Index, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
|
|
2
|
+
import { PartyEntity } from './PartyEntity'
|
|
3
|
+
import { PartyOrigin, PartyTypeType, ValidationConstraint } from '../../types'
|
|
4
|
+
import { IsNotEmpty, Validate, validate, ValidationError } from 'class-validator'
|
|
5
|
+
import { IsNonEmptyStringConstraint } from '../validators'
|
|
6
|
+
import { getConstraint } from '../../utils/ValidatorUtils'
|
|
7
|
+
|
|
8
|
+
@Entity('PartyType')
|
|
9
|
+
@Index('IDX_PartyType_type_tenant_id', ['type', 'tenantId'], { unique: true })
|
|
10
|
+
export class PartyTypeEntity {
|
|
11
|
+
@PrimaryGeneratedColumn('uuid')
|
|
12
|
+
id!: string
|
|
13
|
+
|
|
14
|
+
@Column('simple-enum', { name: 'type', enum: PartyTypeType, nullable: false, unique: false })
|
|
15
|
+
type!: PartyTypeType
|
|
16
|
+
|
|
17
|
+
@Column('simple-enum', { name: 'origin', enum: PartyOrigin, default: 'EXTERNAL', nullable: false, unique: false })
|
|
18
|
+
origin!: PartyOrigin
|
|
19
|
+
|
|
20
|
+
@Column({ name: 'name', length: 255, nullable: false, unique: true })
|
|
21
|
+
@IsNotEmpty({ message: 'Blank names are not allowed' })
|
|
22
|
+
name!: string
|
|
23
|
+
|
|
24
|
+
@Column({ name: 'description', length: 255, nullable: true, unique: false })
|
|
25
|
+
@Validate(IsNonEmptyStringConstraint, { message: 'Blank descriptions are not allowed' })
|
|
26
|
+
description?: string
|
|
27
|
+
|
|
28
|
+
@Column({ name: 'tenant_id', length: 255, nullable: false, unique: false })
|
|
29
|
+
@IsNotEmpty({ message: "Blank tenant id's are not allowed" })
|
|
30
|
+
tenantId!: string
|
|
31
|
+
|
|
32
|
+
@OneToMany(() => PartyEntity, (party: PartyEntity) => party.partyType, {
|
|
33
|
+
nullable: false,
|
|
34
|
+
})
|
|
35
|
+
parties!: Array<PartyEntity>
|
|
36
|
+
|
|
37
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
38
|
+
createdAt!: Date
|
|
39
|
+
|
|
40
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
41
|
+
lastUpdatedAt!: Date
|
|
42
|
+
|
|
43
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
44
|
+
@BeforeInsert()
|
|
45
|
+
@BeforeUpdate()
|
|
46
|
+
updateUpdatedDate(): void {
|
|
47
|
+
this.lastUpdatedAt = new Date()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@BeforeInsert()
|
|
51
|
+
@BeforeUpdate()
|
|
52
|
+
async validate(): Promise<void> {
|
|
53
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
54
|
+
if (validation.length > 0) {
|
|
55
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
56
|
+
if (constraint) {
|
|
57
|
+
const message: string = Object.values(constraint!)[0]
|
|
58
|
+
return Promise.reject(Error(message))
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { IsNotEmpty, 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 { getConstraint } from '../../utils/ValidatorUtils'
|
|
14
|
-
import { PhysicalAddressType, ValidationConstraint } from '../../types'
|
|
15
|
-
import { PartyEntity } from './PartyEntity'
|
|
16
|
-
|
|
17
|
-
@Entity('PhysicalAddress')
|
|
18
|
-
export class PhysicalAddressEntity extends BaseEntity {
|
|
19
|
-
@PrimaryGeneratedColumn('uuid')
|
|
20
|
-
id!: string
|
|
21
|
-
|
|
22
|
-
@Column({ name: 'type', length: 255, nullable: false })
|
|
23
|
-
@IsNotEmpty({ message: 'Blank physical address types are not allowed' })
|
|
24
|
-
type!: PhysicalAddressType
|
|
25
|
-
|
|
26
|
-
@Column({ name: 'street_name', length: 255, nullable: false })
|
|
27
|
-
@IsNotEmpty({ message: 'Blank street names are not allowed' })
|
|
28
|
-
streetName!: string
|
|
29
|
-
|
|
30
|
-
@Column({ name: 'street_number', length: 255, nullable: false })
|
|
31
|
-
@IsNotEmpty({ message: 'Blank street numbers are not allowed' })
|
|
32
|
-
streetNumber!: string
|
|
33
|
-
|
|
34
|
-
@Column({ name: 'postal_code', length: 255, nullable: false })
|
|
35
|
-
@IsNotEmpty({ message: 'Blank postal codes are not allowed' })
|
|
36
|
-
postalCode!: string
|
|
37
|
-
|
|
38
|
-
@Column({ name: 'city_name', length: 255, nullable: false })
|
|
39
|
-
@IsNotEmpty({ message: 'Blank city names are not allowed' })
|
|
40
|
-
cityName!: string
|
|
41
|
-
|
|
42
|
-
@Column({ name: 'province_name', length: 255, nullable: false })
|
|
43
|
-
@IsNotEmpty({ message: 'Blank province names are not allowed' })
|
|
44
|
-
provinceName!: string
|
|
45
|
-
|
|
46
|
-
@Column({ name: 'country_code', length: 2, nullable: false })
|
|
47
|
-
@IsNotEmpty({ message: 'Blank country codes are not allowed' })
|
|
48
|
-
countryCode!: string
|
|
49
|
-
|
|
50
|
-
@Column({ name: 'building_name', length: 255, nullable: true })
|
|
51
|
-
@IsNotEmpty({ message: 'Blank building names are not allowed' })
|
|
52
|
-
buildingName?: string
|
|
53
|
-
|
|
54
|
-
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.physicalAddresses, {
|
|
55
|
-
onDelete: 'CASCADE',
|
|
56
|
-
})
|
|
57
|
-
party!: PartyEntity
|
|
58
|
-
|
|
59
|
-
@Column({ name: 'partyId', nullable: true })
|
|
60
|
-
partyId?: string
|
|
61
|
-
|
|
62
|
-
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
63
|
-
createdAt!: Date
|
|
64
|
-
|
|
65
|
-
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
66
|
-
lastUpdatedAt!: Date
|
|
67
|
-
|
|
68
|
-
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
69
|
-
@BeforeInsert()
|
|
70
|
-
@BeforeUpdate()
|
|
71
|
-
updateUpdatedDate(): void {
|
|
72
|
-
this.lastUpdatedAt = new Date()
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@BeforeInsert()
|
|
76
|
-
@BeforeUpdate()
|
|
77
|
-
async validate(): Promise<void> {
|
|
78
|
-
const validation: Array<ValidationError> = await validate(this)
|
|
79
|
-
if (validation.length > 0) {
|
|
80
|
-
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
81
|
-
if (constraint) {
|
|
82
|
-
const message: string = Object.values(constraint!)[0]
|
|
83
|
-
return Promise.reject(Error(message))
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
import { IsNotEmpty, 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 { getConstraint } from '../../utils/ValidatorUtils'
|
|
14
|
+
import { PhysicalAddressType, ValidationConstraint } from '../../types'
|
|
15
|
+
import { PartyEntity } from './PartyEntity'
|
|
16
|
+
|
|
17
|
+
@Entity('PhysicalAddress')
|
|
18
|
+
export class PhysicalAddressEntity extends BaseEntity {
|
|
19
|
+
@PrimaryGeneratedColumn('uuid')
|
|
20
|
+
id!: string
|
|
21
|
+
|
|
22
|
+
@Column({ name: 'type', length: 255, nullable: false })
|
|
23
|
+
@IsNotEmpty({ message: 'Blank physical address types are not allowed' })
|
|
24
|
+
type!: PhysicalAddressType
|
|
25
|
+
|
|
26
|
+
@Column({ name: 'street_name', length: 255, nullable: false })
|
|
27
|
+
@IsNotEmpty({ message: 'Blank street names are not allowed' })
|
|
28
|
+
streetName!: string
|
|
29
|
+
|
|
30
|
+
@Column({ name: 'street_number', length: 255, nullable: false })
|
|
31
|
+
@IsNotEmpty({ message: 'Blank street numbers are not allowed' })
|
|
32
|
+
streetNumber!: string
|
|
33
|
+
|
|
34
|
+
@Column({ name: 'postal_code', length: 255, nullable: false })
|
|
35
|
+
@IsNotEmpty({ message: 'Blank postal codes are not allowed' })
|
|
36
|
+
postalCode!: string
|
|
37
|
+
|
|
38
|
+
@Column({ name: 'city_name', length: 255, nullable: false })
|
|
39
|
+
@IsNotEmpty({ message: 'Blank city names are not allowed' })
|
|
40
|
+
cityName!: string
|
|
41
|
+
|
|
42
|
+
@Column({ name: 'province_name', length: 255, nullable: false })
|
|
43
|
+
@IsNotEmpty({ message: 'Blank province names are not allowed' })
|
|
44
|
+
provinceName!: string
|
|
45
|
+
|
|
46
|
+
@Column({ name: 'country_code', length: 2, nullable: false })
|
|
47
|
+
@IsNotEmpty({ message: 'Blank country codes are not allowed' })
|
|
48
|
+
countryCode!: string
|
|
49
|
+
|
|
50
|
+
@Column({ name: 'building_name', length: 255, nullable: true })
|
|
51
|
+
@IsNotEmpty({ message: 'Blank building names are not allowed' })
|
|
52
|
+
buildingName?: string
|
|
53
|
+
|
|
54
|
+
@ManyToOne(() => PartyEntity, (party: PartyEntity) => party.physicalAddresses, {
|
|
55
|
+
onDelete: 'CASCADE',
|
|
56
|
+
})
|
|
57
|
+
party!: PartyEntity
|
|
58
|
+
|
|
59
|
+
@Column({ name: 'partyId', nullable: true })
|
|
60
|
+
partyId?: string
|
|
61
|
+
|
|
62
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
63
|
+
createdAt!: Date
|
|
64
|
+
|
|
65
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
66
|
+
lastUpdatedAt!: Date
|
|
67
|
+
|
|
68
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
69
|
+
@BeforeInsert()
|
|
70
|
+
@BeforeUpdate()
|
|
71
|
+
updateUpdatedDate(): void {
|
|
72
|
+
this.lastUpdatedAt = new Date()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@BeforeInsert()
|
|
76
|
+
@BeforeUpdate()
|
|
77
|
+
async validate(): Promise<void> {
|
|
78
|
+
const validation: Array<ValidationError> = await validate(this)
|
|
79
|
+
if (validation.length > 0) {
|
|
80
|
+
const constraint: ValidationConstraint | undefined = getConstraint(validation[0])
|
|
81
|
+
if (constraint) {
|
|
82
|
+
const message: string = Object.values(constraint!)[0]
|
|
83
|
+
return Promise.reject(Error(message))
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|