@sphereon/ssi-sdk.data-store 0.11.1-unstable.64
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 -0
- package/README.md +67 -0
- package/dist/contact/AbstractContactStore.d.ts +15 -0
- package/dist/contact/AbstractContactStore.d.ts.map +1 -0
- package/dist/contact/AbstractContactStore.js +7 -0
- package/dist/contact/AbstractContactStore.js.map +1 -0
- package/dist/contact/ContactStore.d.ts +30 -0
- package/dist/contact/ContactStore.d.ts.map +1 -0
- package/dist/contact/ContactStore.js +281 -0
- package/dist/contact/ContactStore.js.map +1 -0
- package/dist/entities/contact/BaseConfigEntity.d.ts +5 -0
- package/dist/entities/contact/BaseConfigEntity.d.ts.map +1 -0
- package/dist/entities/contact/BaseConfigEntity.js +26 -0
- package/dist/entities/contact/BaseConfigEntity.js.map +1 -0
- package/dist/entities/contact/ConnectionEntity.d.ts +12 -0
- package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -0
- package/dist/entities/contact/ConnectionEntity.js +66 -0
- package/dist/entities/contact/ConnectionEntity.js.map +1 -0
- package/dist/entities/contact/ContactEntity.d.ts +16 -0
- package/dist/entities/contact/ContactEntity.d.ts.map +1 -0
- package/dist/entities/contact/ContactEntity.js +108 -0
- package/dist/entities/contact/ContactEntity.js.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +12 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.js +76 -0
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -0
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +11 -0
- package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -0
- package/dist/entities/contact/DidAuthConfigEntity.js +49 -0
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -0
- package/dist/entities/contact/IdentityEntity.d.ts +22 -0
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -0
- package/dist/entities/contact/IdentityEntity.js +137 -0
- package/dist/entities/contact/IdentityEntity.js.map +1 -0
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +12 -0
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -0
- package/dist/entities/contact/IdentityMetadataItemEntity.js +73 -0
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +15 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -0
- package/dist/entities/contact/OpenIdConfigEntity.js +70 -0
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/generic/1-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/1-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/1-CreateContacts.js +72 -0
- package/dist/migrations/generic/1-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +10 -0
- package/dist/migrations/generic/index.d.ts.map +1 -0
- package/dist/migrations/generic/index.js +13 -0
- package/dist/migrations/generic/index.js.map +1 -0
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +6 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/internal-migrations-ormconfig.d.ts +6 -0
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -0
- package/dist/migrations/internal-migrations-ormconfig.js +29 -0
- package/dist/migrations/internal-migrations-ormconfig.js.map +1 -0
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +55 -0
- package/dist/migrations/postgres/1659463079428-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js +79 -0
- package/dist/migrations/sqlite/1659463069549-CreateContacts.js.map +1 -0
- package/dist/types/IAbstractContactStore.d.ts +41 -0
- package/dist/types/IAbstractContactStore.d.ts.map +1 -0
- package/dist/types/IAbstractContactStore.js +3 -0
- package/dist/types/IAbstractContactStore.js.map +1 -0
- package/dist/types/contact.d.ts +91 -0
- package/dist/types/contact.d.ts.map +1 -0
- package/dist/types/contact.js +21 -0
- package/dist/types/contact.js.map +1 -0
- package/package.json +45 -0
- package/src/__tests__/contact.entities.test.ts +911 -0
- package/src/__tests__/contact.store.test.ts +743 -0
- package/src/contact/AbstractContactStore.ts +26 -0
- package/src/contact/ContactStore.ts +373 -0
- package/src/entities/contact/BaseConfigEntity.ts +8 -0
- package/src/entities/contact/ConnectionEntity.ts +48 -0
- package/src/entities/contact/ContactEntity.ts +76 -0
- package/src/entities/contact/CorrelationIdentifierEntity.ts +41 -0
- package/src/entities/contact/DidAuthConfigEntity.ts +31 -0
- package/src/entities/contact/IdentityEntity.ts +106 -0
- package/src/entities/contact/IdentityMetadataItemEntity.ts +39 -0
- package/src/entities/contact/OpenIdConfigEntity.ts +48 -0
- package/src/index.ts +45 -0
- package/src/migrations/generic/1-CreateContacts.ts +54 -0
- package/src/migrations/generic/index.ts +10 -0
- package/src/migrations/index.ts +1 -0
- package/src/migrations/internal-migrations-ormconfig.ts +28 -0
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +61 -0
- package/src/migrations/sqlite/1659463069549-CreateContacts.ts +111 -0
- package/src/types/IAbstractContactStore.ts +51 -0
- package/src/types/contact.ts +101 -0
|
@@ -0,0 +1,106 @@
|
|
|
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 { correlationIdentifierEntityFrom, CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
|
|
16
|
+
import { ConnectionEntity, connectionEntityFrom } from './ConnectionEntity'
|
|
17
|
+
import { BasicMetadataItem, IBasicIdentity, IdentityRoleEnum } from '../../types/contact'
|
|
18
|
+
import { ContactEntity } from './ContactEntity'
|
|
19
|
+
import { IdentityMetadataItemEntity, metadataItemEntityFrom } from './IdentityMetadataItemEntity'
|
|
20
|
+
import { IsNotEmpty, validate } from 'class-validator'
|
|
21
|
+
|
|
22
|
+
@Entity('Identity')
|
|
23
|
+
export class IdentityEntity extends BaseEntity {
|
|
24
|
+
@PrimaryGeneratedColumn('uuid')
|
|
25
|
+
id!: string
|
|
26
|
+
|
|
27
|
+
@Column({
|
|
28
|
+
name: 'alias',
|
|
29
|
+
length: 255,
|
|
30
|
+
nullable: false,
|
|
31
|
+
unique: true,
|
|
32
|
+
})
|
|
33
|
+
@IsNotEmpty({ message: 'Blank aliases are not allowed' })
|
|
34
|
+
alias!: string
|
|
35
|
+
|
|
36
|
+
@Column('simple-array', { name: 'roles', nullable: false })
|
|
37
|
+
roles!: Array<IdentityRoleEnum>
|
|
38
|
+
|
|
39
|
+
@OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
|
|
40
|
+
cascade: true,
|
|
41
|
+
onDelete: 'CASCADE',
|
|
42
|
+
eager: true,
|
|
43
|
+
nullable: false,
|
|
44
|
+
})
|
|
45
|
+
identifier!: CorrelationIdentifierEntity
|
|
46
|
+
|
|
47
|
+
@OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
|
|
48
|
+
cascade: true,
|
|
49
|
+
onDelete: 'CASCADE',
|
|
50
|
+
eager: true,
|
|
51
|
+
})
|
|
52
|
+
connection?: ConnectionEntity
|
|
53
|
+
|
|
54
|
+
@OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
|
|
55
|
+
cascade: true,
|
|
56
|
+
onDelete: 'CASCADE',
|
|
57
|
+
eager: true,
|
|
58
|
+
nullable: false,
|
|
59
|
+
})
|
|
60
|
+
@JoinColumn({ name: 'metadataId' })
|
|
61
|
+
metadata!: Array<IdentityMetadataItemEntity>
|
|
62
|
+
|
|
63
|
+
@CreateDateColumn({ name: 'created_at', nullable: false })
|
|
64
|
+
createdAt!: Date
|
|
65
|
+
|
|
66
|
+
@UpdateDateColumn({ name: 'last_updated_at', nullable: false })
|
|
67
|
+
lastUpdatedAt!: Date
|
|
68
|
+
|
|
69
|
+
@ManyToOne(() => ContactEntity, (contact: ContactEntity) => contact.identities, {
|
|
70
|
+
onDelete: 'CASCADE',
|
|
71
|
+
})
|
|
72
|
+
contact!: ContactEntity
|
|
73
|
+
|
|
74
|
+
@Column({ name: 'contactId', nullable: true })
|
|
75
|
+
contactId!: string
|
|
76
|
+
|
|
77
|
+
// By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
|
|
78
|
+
@BeforeInsert()
|
|
79
|
+
@BeforeUpdate()
|
|
80
|
+
updateUpdatedDate() {
|
|
81
|
+
this.lastUpdatedAt = new Date()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@BeforeInsert()
|
|
85
|
+
@BeforeUpdate()
|
|
86
|
+
async validate() {
|
|
87
|
+
const validation = await validate(this)
|
|
88
|
+
if (validation.length > 0) {
|
|
89
|
+
return Promise.reject(Error(validation[0].constraints?.isNotEmpty))
|
|
90
|
+
}
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const identityEntityFrom = (args: IBasicIdentity): IdentityEntity => {
|
|
96
|
+
const identityEntity = new IdentityEntity()
|
|
97
|
+
identityEntity.alias = args.alias
|
|
98
|
+
identityEntity.roles = args.roles
|
|
99
|
+
identityEntity.identifier = correlationIdentifierEntityFrom(args.identifier)
|
|
100
|
+
if (args.connection) {
|
|
101
|
+
identityEntity.connection = connectionEntityFrom(args.connection)
|
|
102
|
+
}
|
|
103
|
+
identityEntity.metadata = args.metadata ? args.metadata.map((item: BasicMetadataItem) => metadataItemEntityFrom(item)) : []
|
|
104
|
+
|
|
105
|
+
return identityEntity
|
|
106
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
|
|
2
|
+
import { BasicMetadataItem } from '../../types/contact'
|
|
3
|
+
import { IdentityEntity } from './IdentityEntity'
|
|
4
|
+
import { IsNotEmpty, validate } from 'class-validator'
|
|
5
|
+
|
|
6
|
+
@Entity('IdentityMetadata')
|
|
7
|
+
export class IdentityMetadataItemEntity extends BaseEntity {
|
|
8
|
+
@PrimaryGeneratedColumn('uuid')
|
|
9
|
+
id!: string
|
|
10
|
+
|
|
11
|
+
@Column({ name: 'label', length: 255, nullable: false })
|
|
12
|
+
@IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
|
|
13
|
+
label!: string
|
|
14
|
+
|
|
15
|
+
@Column({ name: 'value', length: 255, nullable: false })
|
|
16
|
+
@IsNotEmpty({ message: 'Blank metadata values are not allowed' })
|
|
17
|
+
value!: string
|
|
18
|
+
|
|
19
|
+
@ManyToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
|
|
20
|
+
identity!: IdentityEntity
|
|
21
|
+
|
|
22
|
+
@BeforeInsert()
|
|
23
|
+
@BeforeUpdate()
|
|
24
|
+
async validate() {
|
|
25
|
+
const validation = await validate(this)
|
|
26
|
+
if (validation.length > 0) {
|
|
27
|
+
return Promise.reject(Error(validation[0].constraints?.isNotEmpty))
|
|
28
|
+
}
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const metadataItemEntityFrom = (item: BasicMetadataItem): IdentityMetadataItemEntity => {
|
|
34
|
+
const metadataItem = new IdentityMetadataItemEntity()
|
|
35
|
+
metadataItem.label = item.label
|
|
36
|
+
metadataItem.value = item.value
|
|
37
|
+
|
|
38
|
+
return metadataItem
|
|
39
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ChildEntity, Column, JoinColumn, OneToOne } from 'typeorm'
|
|
2
|
+
import { BaseConfigEntity } from './BaseConfigEntity'
|
|
3
|
+
import { BasicOpenIdConfig } from '../../types/contact'
|
|
4
|
+
import { ConnectionEntity } from './ConnectionEntity'
|
|
5
|
+
|
|
6
|
+
@ChildEntity('OpenIdConfig')
|
|
7
|
+
export class OpenIdConfigEntity extends BaseConfigEntity {
|
|
8
|
+
@Column({ name: 'client_id', length: 255, nullable: false })
|
|
9
|
+
clientId!: string
|
|
10
|
+
|
|
11
|
+
@Column({ name: 'client_secret', length: 255, nullable: false })
|
|
12
|
+
clientSecret!: string
|
|
13
|
+
|
|
14
|
+
@Column('simple-array', { name: 'scopes', nullable: false })
|
|
15
|
+
scopes!: Array<string>
|
|
16
|
+
|
|
17
|
+
@Column({ name: 'issuer', length: 255, nullable: false })
|
|
18
|
+
issuer!: string
|
|
19
|
+
|
|
20
|
+
@Column('text', { name: 'redirect_url', nullable: false })
|
|
21
|
+
redirectUrl!: string
|
|
22
|
+
|
|
23
|
+
@Column('boolean', { name: 'dangerously_allow_insecure_http_requests', nullable: false })
|
|
24
|
+
dangerouslyAllowInsecureHttpRequests!: boolean
|
|
25
|
+
|
|
26
|
+
@Column('text', { name: 'client_auth_method', nullable: false })
|
|
27
|
+
clientAuthMethod!: 'basic' | 'post' | undefined
|
|
28
|
+
|
|
29
|
+
@OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.config, {
|
|
30
|
+
cascade: ['insert', 'update'],
|
|
31
|
+
onDelete: 'CASCADE',
|
|
32
|
+
})
|
|
33
|
+
@JoinColumn({ name: 'connectionId' })
|
|
34
|
+
connection?: ConnectionEntity
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const openIdConfigEntityFrom = (config: BasicOpenIdConfig): OpenIdConfigEntity => {
|
|
38
|
+
const openIdConfig = new OpenIdConfigEntity()
|
|
39
|
+
openIdConfig.clientId = config.clientId
|
|
40
|
+
openIdConfig.clientSecret = config.clientSecret
|
|
41
|
+
openIdConfig.scopes = config.scopes
|
|
42
|
+
openIdConfig.issuer = config.issuer
|
|
43
|
+
openIdConfig.redirectUrl = config.redirectUrl
|
|
44
|
+
openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
|
|
45
|
+
openIdConfig.clientAuthMethod = config.clientAuthMethod
|
|
46
|
+
|
|
47
|
+
return openIdConfig
|
|
48
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseConfigEntity } from './entities/contact/BaseConfigEntity'
|
|
2
|
+
import { ConnectionEntity, connectionEntityFrom } from './entities/contact/ConnectionEntity'
|
|
3
|
+
import { ContactEntity, contactEntityFrom } from './entities/contact/ContactEntity'
|
|
4
|
+
import { CorrelationIdentifierEntity, correlationIdentifierEntityFrom } from './entities/contact/CorrelationIdentifierEntity'
|
|
5
|
+
import { DidAuthConfigEntity, didAuthConfigEntityFrom } from './entities/contact/DidAuthConfigEntity'
|
|
6
|
+
import { IdentityEntity, identityEntityFrom } from './entities/contact/IdentityEntity'
|
|
7
|
+
import { IdentityMetadataItemEntity, metadataItemEntityFrom } from './entities/contact/IdentityMetadataItemEntity'
|
|
8
|
+
import { OpenIdConfigEntity, openIdConfigEntityFrom } from './entities/contact/OpenIdConfigEntity'
|
|
9
|
+
|
|
10
|
+
export { ContactStore } from './contact/ContactStore'
|
|
11
|
+
export { AbstractContactStore } from './contact/AbstractContactStore'
|
|
12
|
+
|
|
13
|
+
export const DataStoreContactEntities = [
|
|
14
|
+
BaseConfigEntity,
|
|
15
|
+
ConnectionEntity,
|
|
16
|
+
ContactEntity,
|
|
17
|
+
IdentityEntity,
|
|
18
|
+
IdentityMetadataItemEntity,
|
|
19
|
+
CorrelationIdentifierEntity,
|
|
20
|
+
DidAuthConfigEntity,
|
|
21
|
+
OpenIdConfigEntity,
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
BaseConfigEntity,
|
|
26
|
+
ConnectionEntity,
|
|
27
|
+
ContactEntity,
|
|
28
|
+
CorrelationIdentifierEntity,
|
|
29
|
+
DidAuthConfigEntity,
|
|
30
|
+
IdentityEntity,
|
|
31
|
+
IdentityMetadataItemEntity,
|
|
32
|
+
OpenIdConfigEntity,
|
|
33
|
+
metadataItemEntityFrom,
|
|
34
|
+
connectionEntityFrom,
|
|
35
|
+
contactEntityFrom,
|
|
36
|
+
correlationIdentifierEntityFrom,
|
|
37
|
+
identityEntityFrom,
|
|
38
|
+
didAuthConfigEntityFrom,
|
|
39
|
+
openIdConfigEntityFrom,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export * from './types/contact'
|
|
43
|
+
export * from './types/IAbstractContactStore'
|
|
44
|
+
|
|
45
|
+
export { DataStoreMigrations } from './migrations'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
import Debug from 'debug'
|
|
3
|
+
import { CreateContacts1659463079428 } from '../postgres/1659463079428-CreateContacts'
|
|
4
|
+
import { CreateContacts1659463069549 } from '../sqlite/1659463069549-CreateContacts'
|
|
5
|
+
|
|
6
|
+
const debug = Debug('sphereon:ssi-sdk:migrations')
|
|
7
|
+
|
|
8
|
+
export class CreateContacts1659463079429 implements MigrationInterface {
|
|
9
|
+
name = 'CreateContacts1659463079429'
|
|
10
|
+
|
|
11
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
12
|
+
debug('migration: creating contacts tables')
|
|
13
|
+
const dbType = queryRunner.connection.driver.options.type
|
|
14
|
+
if (dbType === 'postgres') {
|
|
15
|
+
debug('using postgres migration file')
|
|
16
|
+
const mig = new CreateContacts1659463079428()
|
|
17
|
+
const up = await mig.up(queryRunner)
|
|
18
|
+
debug('Migration statements executed')
|
|
19
|
+
return up
|
|
20
|
+
} else if (dbType === 'sqlite' || 'react-native') {
|
|
21
|
+
debug('using sqlite/react-native migration file')
|
|
22
|
+
const mig = new CreateContacts1659463069549()
|
|
23
|
+
const up = await mig.up(queryRunner)
|
|
24
|
+
debug('Migration statements executed')
|
|
25
|
+
return up
|
|
26
|
+
} else {
|
|
27
|
+
return Promise.reject(
|
|
28
|
+
"Migrations are currently only supported for sqlite, react-native and postgres. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now"
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
34
|
+
debug('reverting contacts tables')
|
|
35
|
+
const dbType = queryRunner.connection.driver.options.type
|
|
36
|
+
if (dbType === 'postgres') {
|
|
37
|
+
debug('using postgres migration file')
|
|
38
|
+
const mig = new CreateContacts1659463079428()
|
|
39
|
+
const down = await mig.down(queryRunner)
|
|
40
|
+
debug('Migration statements executed')
|
|
41
|
+
return down
|
|
42
|
+
} else if (dbType === 'sqlite' || 'react-native') {
|
|
43
|
+
debug('using sqlite/react-native migration file')
|
|
44
|
+
const mig = new CreateContacts1659463069549()
|
|
45
|
+
const down = await mig.down(queryRunner)
|
|
46
|
+
debug('Migration statements executed')
|
|
47
|
+
return down
|
|
48
|
+
} else {
|
|
49
|
+
return Promise.reject(
|
|
50
|
+
"Migrations are currently only supported for sqlite, react-native and postgres. Please run your database without migrations and with 'migrationsRun: false' and 'synchronize: true' for now"
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CreateContacts1659463079429 } from './1-CreateContacts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The migrations array that SHOULD be used when initializing a TypeORM database connection.
|
|
5
|
+
*
|
|
6
|
+
* These ensure the correct creation of tables and the proper migrations of data when tables change between versions.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const DataStoreMigrations = [CreateContacts1659463079429]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataStoreMigrations } from './generic'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConnectionOptions } from 'typeorm'
|
|
2
|
+
import { DataStoreContactEntities, DataStoreMigrations } from '../index'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Do Not use these connections in production!. They are only here to create/test migration files!
|
|
6
|
+
*/
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
type: 'sqlite',
|
|
10
|
+
name: 'migration-sqlite',
|
|
11
|
+
database: 'migration.sqlite',
|
|
12
|
+
migrationsRun: false,
|
|
13
|
+
synchronize: false,
|
|
14
|
+
logging: ['error', 'info', 'warn', 'log'],
|
|
15
|
+
entities: [...DataStoreContactEntities],
|
|
16
|
+
migrations: [...DataStoreMigrations],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'postgres',
|
|
20
|
+
name: 'migration-postgres',
|
|
21
|
+
database: 'migration-postgres',
|
|
22
|
+
migrationsRun: false,
|
|
23
|
+
synchronize: false,
|
|
24
|
+
logging: ['error', 'info', 'warn', 'log'],
|
|
25
|
+
entities: [...DataStoreContactEntities],
|
|
26
|
+
migrations: [...DataStoreMigrations],
|
|
27
|
+
},
|
|
28
|
+
] as ConnectionOptions[]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateContacts1659463079428 implements MigrationInterface {
|
|
4
|
+
name = 'CreateContacts1659463079428'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "BaseConfigEntity" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "redirect_url" text, "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "identifier" character varying(255), "session_id" character varying(255), "type" character varying NOT NULL, "connectionId" uuid, CONSTRAINT "REL_BaseConfig_connectionId" UNIQUE ("connectionId"), CONSTRAINT "PK_BaseConfigEntity_id" PRIMARY KEY ("id"))`
|
|
9
|
+
)
|
|
10
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfigEntity_type" ON "BaseConfigEntity" ("type")`)
|
|
11
|
+
await queryRunner.query(`CREATE TYPE "public"."CorrelationIdentifier_type_enum" AS ENUM('did', 'url')`)
|
|
12
|
+
await queryRunner.query(
|
|
13
|
+
`CREATE TABLE "CorrelationIdentifier" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."CorrelationIdentifier_type_enum" NOT NULL, "correlation_id" text NOT NULL, "identityId" uuid, CONSTRAINT "UQ_Correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"), CONSTRAINT "PK_CorrelationIdentifier_id" PRIMARY KEY ("id"))`
|
|
14
|
+
)
|
|
15
|
+
await queryRunner.query(
|
|
16
|
+
`CREATE TABLE "Contact" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(255) NOT NULL, "alias" character varying(255) NOT NULL, "uri" character varying(255) NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_Name" UNIQUE ("name"), CONSTRAINT "UQ_Alias" UNIQUE ("alias"), CONSTRAINT "PK_Contact_id" PRIMARY KEY ("id"))`
|
|
17
|
+
)
|
|
18
|
+
await queryRunner.query(
|
|
19
|
+
`CREATE TABLE "IdentityMetadata" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "label" character varying(255) NOT NULL, "value" character varying(255) NOT NULL, "identityId" uuid, CONSTRAINT "PK_IdentityMetadata_id" PRIMARY KEY ("id"))`
|
|
20
|
+
)
|
|
21
|
+
await queryRunner.query(
|
|
22
|
+
`CREATE TABLE "Identity" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "alias" character varying(255) NOT NULL, "roles" text, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "last_updated_at" TIMESTAMP NOT NULL DEFAULT now(), "contactId" uuid, CONSTRAINT "UQ_Alias" UNIQUE ("alias"), CONSTRAINT "PK_Identity_id" PRIMARY KEY ("id"))`
|
|
23
|
+
)
|
|
24
|
+
await queryRunner.query(`CREATE TYPE "public"."Connection_type_enum" AS ENUM('OIDC', 'SIOPv2', 'SIOPv2+OpenID4VP')`)
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`CREATE TABLE "Connection" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."Connection_type_enum" NOT NULL, "identityId" uuid, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"), CONSTRAINT "PK_Connection_id" PRIMARY KEY ("id"))`
|
|
27
|
+
)
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "BaseConfigEntity" ADD CONSTRAINT "FK_BaseConfig_connectionId" FOREIGN KEY ("connectionId") REFERENCES "Connection"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
|
30
|
+
)
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "CorrelationIdentifier" ADD CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
|
33
|
+
)
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "IdentityMetadata" ADD CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
|
36
|
+
)
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "Identity" ADD CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
|
39
|
+
)
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "Connection" ADD CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
46
|
+
await queryRunner.query(`ALTER TABLE "Connection" DROP CONSTRAINT "FK_Connection_identityId"`)
|
|
47
|
+
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`)
|
|
48
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`)
|
|
49
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`)
|
|
50
|
+
await queryRunner.query(`ALTER TABLE "BaseConfigEntity" DROP CONSTRAINT "FK_BaseConfig_connectionId"`)
|
|
51
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
52
|
+
await queryRunner.query(`DROP TYPE "public"."Connection_type_enum"`)
|
|
53
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
54
|
+
await queryRunner.query(`DROP TABLE "IdentityMetadata"`)
|
|
55
|
+
await queryRunner.query(`DROP TABLE "Contact"`)
|
|
56
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
57
|
+
await queryRunner.query(`DROP TYPE "public"."CorrelationIdentifier_type_enum"`)
|
|
58
|
+
await queryRunner.query(`DROP INDEX "public"."IDX_BaseConfigEntity_type"`)
|
|
59
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
export class CreateContacts1659463069549 implements MigrationInterface {
|
|
4
|
+
name = 'CreateContacts1659463069549'
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "redirect_url" text, "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "identifier" varchar(255), "session_id" varchar(255), "type" varchar NOT NULL, "connectionId" varchar, CONSTRAINT "REL_BaseConfig_connectionId" UNIQUE ("connectionId"))`
|
|
9
|
+
)
|
|
10
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfigEntity_type" ON "BaseConfigEntity" ("type")`)
|
|
11
|
+
await queryRunner.query(
|
|
12
|
+
`CREATE TABLE "CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "UQ_Correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"))`
|
|
13
|
+
)
|
|
14
|
+
await queryRunner.query(
|
|
15
|
+
`CREATE TABLE "Contact" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar(255) NOT NULL, "alias" varchar(255) NOT NULL, "uri" varchar(255) NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_Name" UNIQUE ("name"), CONSTRAINT "UQ_Alias" UNIQUE ("alias"))`
|
|
16
|
+
)
|
|
17
|
+
await queryRunner.query(
|
|
18
|
+
`CREATE TABLE "IdentityMetadata" ("id" varchar PRIMARY KEY NOT NULL, "label" varchar(255) NOT NULL, "value" varchar(255) NOT NULL, "identityId" varchar)`
|
|
19
|
+
)
|
|
20
|
+
await queryRunner.query(
|
|
21
|
+
`CREATE TABLE "Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Alias" UNIQUE ("alias"))`
|
|
22
|
+
)
|
|
23
|
+
await queryRunner.query(
|
|
24
|
+
`CREATE TABLE "Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`
|
|
25
|
+
)
|
|
26
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfigEntity_type"`)
|
|
27
|
+
await queryRunner.query(
|
|
28
|
+
`CREATE TABLE "temporary_BaseConfigEntity" ("id" varchar PRIMARY KEY NOT NULL, "client_id" varchar(255), "client_secret" varchar(255), "scopes" text, "issuer" varchar(255), "redirect_url" text, "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "identifier" varchar(255), "session_id" varchar(255), "type" varchar NOT NULL, "connectionId" varchar, CONSTRAINT "REL_BaseConfig_connectionId" UNIQUE ("connectionId"), CONSTRAINT "FK_BaseConfig_connectionId" FOREIGN KEY ("connectionId") REFERENCES "Connection" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
29
|
+
)
|
|
30
|
+
await queryRunner.query(
|
|
31
|
+
`INSERT INTO "temporary_BaseConfigEntity"("id", "client_id", "client_secret", "scopes", "issuer", "redirect_url", "dangerously_allow_insecure_http_requests", "client_auth_method", "identifier", "session_id", "type", "connectionId") SELECT "id", "client_id", "client_secret", "scopes", "issuer", "redirect_url", "dangerously_allow_insecure_http_requests", "client_auth_method", "identifier", "session_id", "type", "connectionId" FROM "BaseConfigEntity"`
|
|
32
|
+
)
|
|
33
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`)
|
|
34
|
+
await queryRunner.query(`ALTER TABLE "temporary_BaseConfigEntity" RENAME TO "BaseConfigEntity"`)
|
|
35
|
+
await queryRunner.query(`CREATE INDEX "IDX_BaseConfigEntity_type" ON "BaseConfigEntity" ("type")`)
|
|
36
|
+
await queryRunner.query(
|
|
37
|
+
`CREATE TABLE "temporary_CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "UQ_Correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"), CONSTRAINT "FK_CorrelationIdentifier_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
38
|
+
)
|
|
39
|
+
await queryRunner.query(
|
|
40
|
+
`INSERT INTO "temporary_CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`
|
|
41
|
+
)
|
|
42
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
43
|
+
await queryRunner.query(`ALTER TABLE "temporary_CorrelationIdentifier" RENAME TO "CorrelationIdentifier"`)
|
|
44
|
+
await queryRunner.query(
|
|
45
|
+
`CREATE TABLE "temporary_IdentityMetadata" ("id" varchar PRIMARY KEY NOT NULL, "label" varchar(255) NOT NULL, "value" varchar(255) NOT NULL, "identityId" varchar, CONSTRAINT "FK_IdentityMetadata_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
46
|
+
)
|
|
47
|
+
await queryRunner.query(
|
|
48
|
+
`INSERT INTO "temporary_IdentityMetadata"("id", "label", "value", "identityId") SELECT "id", "label", "value", "identityId" FROM "IdentityMetadata"`
|
|
49
|
+
)
|
|
50
|
+
await queryRunner.query(`DROP TABLE "IdentityMetadata"`)
|
|
51
|
+
await queryRunner.query(`ALTER TABLE "temporary_IdentityMetadata" RENAME TO "IdentityMetadata"`)
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`CREATE TABLE "temporary_Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Alias" UNIQUE ("alias"), CONSTRAINT "FK_Identity_contactId" FOREIGN KEY ("contactId") REFERENCES "Contact" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
54
|
+
)
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`INSERT INTO "temporary_Identity"("id", "alias", "roles", "created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles", "created_at", "last_updated_at", "contactId" FROM "Identity"`
|
|
57
|
+
)
|
|
58
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
59
|
+
await queryRunner.query(`ALTER TABLE "temporary_Identity" RENAME TO "Identity"`)
|
|
60
|
+
await queryRunner.query(
|
|
61
|
+
`CREATE TABLE "temporary_Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"), CONSTRAINT "FK_Connection_identityId" FOREIGN KEY ("identityId") REFERENCES "Identity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
|
62
|
+
)
|
|
63
|
+
await queryRunner.query(`INSERT INTO "temporary_Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
64
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
65
|
+
await queryRunner.query(`ALTER TABLE "temporary_Connection" RENAME TO "Connection"`)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
69
|
+
await queryRunner.query(`ALTER TABLE "Connection" RENAME TO "temporary_Connection"`)
|
|
70
|
+
await queryRunner.query(
|
|
71
|
+
`CREATE TABLE "Connection" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('OIDC','SIOPv2','SIOPv2+OpenID4VP') ) NOT NULL, "identityId" varchar, CONSTRAINT "REL_Connection_identityId" UNIQUE ("identityId"))`
|
|
72
|
+
)
|
|
73
|
+
await queryRunner.query(`INSERT INTO "Connection"("id", "type", "identityId") SELECT "id", "type", "identityId" FROM "Connection"`)
|
|
74
|
+
await queryRunner.query(`DROP TABLE "temporary_Connection"`)
|
|
75
|
+
|
|
76
|
+
await queryRunner.query(`ALTER TABLE "Identity" RENAME TO "temporary_Identity"`)
|
|
77
|
+
await queryRunner.query(
|
|
78
|
+
`CREATE TABLE "Identity" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar(255) NOT NULL, "roles" text, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "last_updated_at" datetime NOT NULL DEFAULT (datetime('now')), "contactId" varchar, CONSTRAINT "UQ_Alias" UNIQUE ("alias"))`
|
|
79
|
+
)
|
|
80
|
+
await queryRunner.query(
|
|
81
|
+
`INSERT INTO "Identity"("id", "alias", "roles","created_at", "last_updated_at", "contactId") SELECT "id", "alias", "roles","created_at", "last_updated_at", "contactId" FROM "Identity"`
|
|
82
|
+
)
|
|
83
|
+
await queryRunner.query(`DROP TABLE "temporary_Identity"`)
|
|
84
|
+
|
|
85
|
+
await queryRunner.query(`ALTER TABLE "IdentityMetadata" RENAME TO "temporary_IdentityMetadata"`)
|
|
86
|
+
await queryRunner.query(
|
|
87
|
+
`CREATE TABLE "IdentityMetadata" ("id" varchar PRIMARY KEY NOT NULL, "label" varchar(255) NOT NULL, "value" varchar(255) NOT NULL, "identityId" varchar)`
|
|
88
|
+
)
|
|
89
|
+
await queryRunner.query(
|
|
90
|
+
`INSERT INTO "IdentityMetadata"("id", "label", "value", "identityId") SELECT "id", "label", "value", "identityId" FROM "IdentityMetadata"`
|
|
91
|
+
)
|
|
92
|
+
await queryRunner.query(`DROP TABLE "temporary_IdentityMetadata"`)
|
|
93
|
+
|
|
94
|
+
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" RENAME TO "temporary_CorrelationIdentifier"`)
|
|
95
|
+
await queryRunner.query(
|
|
96
|
+
`CREATE TABLE "CorrelationIdentifier" ("id" varchar PRIMARY KEY NOT NULL, "type" varchar CHECK( "type" IN ('did','url') ) NOT NULL, "correlation_id" text NOT NULL, "identityId" varchar, CONSTRAINT "UQ_Correlation_id" UNIQUE ("correlation_id"), CONSTRAINT "REL_CorrelationIdentifier_identityId" UNIQUE ("identityId"))`
|
|
97
|
+
)
|
|
98
|
+
await queryRunner.query(
|
|
99
|
+
`INSERT INTO "CorrelationIdentifier"("id", "type", "correlation_id", "identityId") SELECT "id", "type", "correlation_id", "identityId" FROM "CorrelationIdentifier"`
|
|
100
|
+
)
|
|
101
|
+
await queryRunner.query(`DROP TABLE "temporary_CorrelationIdentifier"`)
|
|
102
|
+
|
|
103
|
+
await queryRunner.query(`DROP TABLE "Connection"`)
|
|
104
|
+
await queryRunner.query(`DROP TABLE "Identity"`)
|
|
105
|
+
await queryRunner.query(`DROP TABLE "IdentityMetadata"`)
|
|
106
|
+
await queryRunner.query(`DROP TABLE "Contact"`)
|
|
107
|
+
await queryRunner.query(`DROP TABLE "CorrelationIdentifier"`)
|
|
108
|
+
await queryRunner.query(`DROP INDEX "IDX_BaseConfigEntity_type"`)
|
|
109
|
+
await queryRunner.query(`DROP TABLE "BaseConfigEntity"`)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FindOptionsWhere } from 'typeorm'
|
|
2
|
+
import { ContactEntity } from '../entities/contact/ContactEntity'
|
|
3
|
+
import { IdentityEntity } from '../entities/contact/IdentityEntity'
|
|
4
|
+
import { IBasicIdentity, IContact, IIdentity } from './contact'
|
|
5
|
+
|
|
6
|
+
export type FindContactArgs = FindOptionsWhere<ContactEntity>[]
|
|
7
|
+
export type FindIdentityArgs = FindOptionsWhere<IdentityEntity>[]
|
|
8
|
+
|
|
9
|
+
export interface IGetContactArgs {
|
|
10
|
+
contactId: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IGetContactsArgs {
|
|
14
|
+
filter?: FindContactArgs
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IAddContactArgs {
|
|
18
|
+
name: string
|
|
19
|
+
alias: string
|
|
20
|
+
uri?: string
|
|
21
|
+
identities?: Array<IBasicIdentity>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IUpdateContactArgs {
|
|
25
|
+
contact: Omit<IContact, 'identities' | 'createdAt' | 'lastUpdatedAt'>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IRemoveContactArgs {
|
|
29
|
+
contactId: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IGetIdentityArgs {
|
|
33
|
+
identityId: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IGetIdentitiesArgs {
|
|
37
|
+
filter?: FindIdentityArgs
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IAddIdentityArgs {
|
|
41
|
+
contactId: string
|
|
42
|
+
identity: IBasicIdentity
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IUpdateIdentityArgs {
|
|
46
|
+
identity: IIdentity
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IRemoveIdentityArgs {
|
|
50
|
+
identityId: string
|
|
51
|
+
}
|