@sphereon/ssi-sdk.data-store 0.15.2-next.6 → 0.15.2-next.95
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/dist/contact/AbstractContactStore.d.ts +21 -11
- package/dist/contact/AbstractContactStore.d.ts.map +1 -1
- package/dist/contact/AbstractContactStore.js.map +1 -1
- package/dist/contact/ContactStore.d.ts +25 -21
- package/dist/contact/ContactStore.d.ts.map +1 -1
- package/dist/contact/ContactStore.js +216 -136
- package/dist/contact/ContactStore.js.map +1 -1
- package/dist/entities/contact/BaseConfigEntity.d.ts +2 -0
- package/dist/entities/contact/BaseConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/BaseConfigEntity.js +10 -2
- package/dist/entities/contact/BaseConfigEntity.js.map +1 -1
- package/dist/entities/contact/BaseContactEntity.d.ts +10 -0
- package/dist/entities/contact/BaseContactEntity.d.ts.map +1 -0
- package/dist/entities/contact/BaseContactEntity.js +54 -0
- package/dist/entities/contact/BaseContactEntity.js.map +1 -0
- package/dist/entities/contact/ConnectionEntity.d.ts +1 -2
- package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -1
- package/dist/entities/contact/ConnectionEntity.js +2 -21
- package/dist/entities/contact/ConnectionEntity.js.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +2 -3
- package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -1
- package/dist/entities/contact/CorrelationIdentifierEntity.js +8 -11
- package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.d.ts +0 -4
- package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/DidAuthConfigEntity.js +1 -17
- package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -1
- package/dist/entities/contact/ElectronicAddressEntity.d.ts +14 -0
- package/dist/entities/contact/ElectronicAddressEntity.d.ts.map +1 -0
- package/dist/entities/contact/ElectronicAddressEntity.js +92 -0
- package/dist/entities/contact/ElectronicAddressEntity.js.map +1 -0
- package/dist/entities/contact/IdentityEntity.d.ts +5 -6
- package/dist/entities/contact/IdentityEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityEntity.js +15 -20
- package/dist/entities/contact/IdentityEntity.js.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +1 -3
- package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -1
- package/dist/entities/contact/IdentityMetadataItemEntity.js +7 -10
- package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -1
- package/dist/entities/contact/NaturalPersonEntity.d.ts +9 -0
- package/dist/entities/contact/NaturalPersonEntity.d.ts.map +1 -0
- package/dist/entities/contact/NaturalPersonEntity.js +72 -0
- package/dist/entities/contact/NaturalPersonEntity.js.map +1 -0
- package/dist/entities/contact/OpenIdConfigEntity.d.ts +0 -4
- package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -1
- package/dist/entities/contact/OpenIdConfigEntity.js +1 -22
- package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -1
- package/dist/entities/contact/OrganizationEntity.d.ts +9 -0
- package/dist/entities/contact/OrganizationEntity.d.ts.map +1 -0
- package/dist/entities/contact/OrganizationEntity.js +67 -0
- package/dist/entities/contact/OrganizationEntity.js.map +1 -0
- package/dist/entities/contact/PartyEntity.d.ts +21 -0
- package/dist/entities/contact/PartyEntity.d.ts.map +1 -0
- package/dist/entities/contact/PartyEntity.js +155 -0
- package/dist/entities/contact/PartyEntity.js.map +1 -0
- package/dist/entities/contact/PartyRelationshipEntity.d.ts +13 -0
- package/dist/entities/contact/PartyRelationshipEntity.d.ts.map +1 -0
- package/dist/entities/contact/PartyRelationshipEntity.js +95 -0
- package/dist/entities/contact/PartyRelationshipEntity.js.map +1 -0
- package/dist/entities/contact/PartyTypeEntity.d.ts +15 -0
- package/dist/entities/contact/PartyTypeEntity.d.ts.map +1 -0
- package/dist/entities/contact/{ContactEntity.js → PartyTypeEntity.js} +35 -36
- package/dist/entities/contact/PartyTypeEntity.js.map +1 -0
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts +19 -0
- package/dist/entities/statusList2021/StatusList2021Entity.d.ts.map +1 -0
- package/dist/entities/statusList2021/StatusList2021Entity.js +115 -0
- package/dist/entities/statusList2021/StatusList2021Entity.js.map +1 -0
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts +11 -0
- package/dist/entities/statusList2021/StatusList2021EntryEntity.d.ts.map +1 -0
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js +51 -0
- package/dist/entities/statusList2021/StatusList2021EntryEntity.js.map +1 -0
- package/dist/index.d.ts +20 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/migrations/generic/1-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/generic/1-CreateContacts.js +36 -32
- package/dist/migrations/generic/1-CreateContacts.js.map +1 -1
- package/dist/migrations/generic/2-CreateContacts.d.ts +7 -0
- package/dist/migrations/generic/2-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/generic/2-CreateContacts.js +76 -0
- package/dist/migrations/generic/2-CreateContacts.js.map +1 -0
- package/dist/migrations/generic/{1-CreateIssuanceBranding.d.ts → 2-CreateIssuanceBranding.d.ts} +1 -1
- package/dist/migrations/generic/2-CreateIssuanceBranding.d.ts.map +1 -0
- package/dist/migrations/generic/2-CreateIssuanceBranding.js +76 -0
- package/dist/migrations/generic/2-CreateIssuanceBranding.js.map +1 -0
- package/dist/migrations/generic/3-CreateStatusList.d.ts +7 -0
- package/dist/migrations/generic/3-CreateStatusList.d.ts.map +1 -0
- package/dist/migrations/generic/{1-CreateIssuanceBranding.js → 3-CreateStatusList.js} +11 -11
- package/dist/migrations/generic/3-CreateStatusList.js.map +1 -0
- package/dist/migrations/generic/index.d.ts +5 -0
- package/dist/migrations/generic/index.d.ts.map +1 -1
- package/dist/migrations/generic/index.js +10 -3
- package/dist/migrations/generic/index.js.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts +2 -1
- package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -1
- package/dist/migrations/internal-migrations-ormconfig.js +0 -2
- package/dist/migrations/internal-migrations-ormconfig.js.map +1 -1
- package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts.map +1 -1
- package/dist/migrations/postgres/1659463079428-CreateContacts.js +4 -2
- package/dist/migrations/postgres/1659463079428-CreateContacts.js.map +1 -1
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts.map +1 -1
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +2 -0
- package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js.map +1 -1
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts +7 -0
- package/dist/migrations/postgres/1690925872592-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/postgres/1690925872592-CreateContacts.js +69 -0
- package/dist/migrations/postgres/1690925872592-CreateContacts.js.map +1 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts +7 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.d.ts.map +1 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js +32 -0
- package/dist/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.js.map +1 -0
- package/dist/migrations/postgres/uuid.d.ts +3 -0
- package/dist/migrations/postgres/uuid.d.ts.map +1 -0
- package/dist/migrations/postgres/uuid.js +25 -0
- package/dist/migrations/postgres/uuid.js.map +1 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts +7 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.d.ts.map +1 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js +108 -0
- package/dist/migrations/sqlite/1690925872693-CreateContacts.js.map +1 -0
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts +7 -0
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.d.ts.map +1 -0
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js +32 -0
- package/dist/migrations/sqlite/1693866470000-CreateStatusList.js.map +1 -0
- package/dist/statusList/IStatusListStore.d.ts +20 -0
- package/dist/statusList/IStatusListStore.d.ts.map +1 -0
- package/dist/statusList/IStatusListStore.js +3 -0
- package/dist/statusList/IStatusListStore.js.map +1 -0
- package/dist/statusList/StatusListStore.d.ts +36 -0
- package/dist/statusList/StatusListStore.d.ts.map +1 -0
- package/dist/statusList/StatusListStore.js +213 -0
- package/dist/statusList/StatusListStore.js.map +1 -0
- package/dist/types/contact/IAbstractContactStore.d.ts +70 -36
- package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -1
- package/dist/types/contact/contact.d.ts +139 -56
- package/dist/types/contact/contact.d.ts.map +1 -1
- package/dist/types/contact/contact.js +6 -1
- package/dist/types/contact/contact.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/statusList/IAbstractStatusListStore.d.ts +38 -0
- package/dist/types/statusList/IAbstractStatusListStore.d.ts.map +1 -0
- package/dist/types/statusList/IAbstractStatusListStore.js +3 -0
- package/dist/types/statusList/IAbstractStatusListStore.js.map +1 -0
- package/dist/types/statusList/statusList.d.ts +25 -0
- package/dist/types/statusList/statusList.d.ts.map +1 -0
- package/dist/types/statusList/statusList.js +3 -0
- package/dist/types/statusList/statusList.js.map +1 -0
- package/dist/types/validation/validation.d.ts +4 -0
- package/dist/types/validation/validation.d.ts.map +1 -0
- package/dist/types/validation/validation.js +3 -0
- package/dist/types/validation/validation.js.map +1 -0
- package/dist/utils/ValidatorUtils.d.ts +4 -0
- package/dist/utils/ValidatorUtils.d.ts.map +1 -0
- package/dist/utils/ValidatorUtils.js +13 -0
- package/dist/utils/ValidatorUtils.js.map +1 -0
- package/dist/utils/contact/MappingUtils.d.ts +47 -0
- package/dist/utils/contact/MappingUtils.d.ts.map +1 -0
- package/dist/utils/contact/MappingUtils.js +291 -0
- package/dist/utils/contact/MappingUtils.js.map +1 -0
- package/package.json +5 -4
- package/src/__tests__/contact.entities.test.ts +1457 -195
- package/src/__tests__/contact.store.test.ts +1302 -266
- package/src/contact/AbstractContactStore.ts +44 -22
- package/src/contact/ContactStore.ts +328 -204
- package/src/entities/contact/BaseConfigEntity.ts +10 -2
- package/src/entities/contact/BaseContactEntity.ts +30 -0
- package/src/entities/contact/ConnectionEntity.ts +4 -23
- package/src/entities/contact/CorrelationIdentifierEntity.ts +9 -13
- package/src/entities/contact/DidAuthConfigEntity.ts +1 -18
- package/src/entities/contact/ElectronicAddressEntity.ts +60 -0
- package/src/entities/contact/IdentityEntity.ts +18 -25
- package/src/entities/contact/IdentityMetadataItemEntity.ts +8 -12
- package/src/entities/contact/NaturalPersonEntity.ts +38 -0
- package/src/entities/contact/OpenIdConfigEntity.ts +1 -23
- package/src/entities/contact/OrganizationEntity.ts +34 -0
- package/src/entities/contact/PartyEntity.ts +118 -0
- package/src/entities/contact/PartyRelationshipEntity.ts +61 -0
- package/src/entities/contact/PartyTypeEntity.ts +59 -0
- package/src/entities/statusList2021/StatusList2021Entity.ts +95 -0
- package/src/entities/statusList2021/StatusList2021EntryEntity.ts +29 -0
- package/src/index.ts +36 -17
- package/src/migrations/generic/1-CreateContacts.ts +46 -36
- package/src/migrations/generic/2-CreateContacts.ts +64 -0
- package/src/migrations/generic/2-CreateIssuanceBranding.ts +62 -0
- package/src/migrations/generic/{1-CreateIssuanceBranding.ts → 3-CreateStatusList.ts} +9 -9
- package/src/migrations/generic/index.ts +11 -2
- package/src/migrations/internal-migrations-ormconfig.ts +2 -4
- package/src/migrations/postgres/1659463079428-CreateContacts.ts +4 -2
- package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +2 -0
- package/src/migrations/postgres/1690925872592-CreateContacts.ts +94 -0
- package/src/migrations/postgres/CreateStatusList1693866470001-CreateStatusList.ts +24 -0
- package/src/migrations/postgres/uuid.ts +12 -0
- package/src/migrations/sqlite/1690925872693-CreateContacts.ts +163 -0
- package/src/migrations/sqlite/1693866470000-CreateStatusList.ts +24 -0
- package/src/statusList/IStatusListStore.ts +44 -0
- package/src/statusList/StatusListStore.ts +237 -0
- package/src/types/contact/IAbstractContactStore.ts +84 -27
- package/src/types/contact/contact.ts +144 -50
- package/src/types/index.ts +4 -0
- package/src/types/statusList/IAbstractStatusListStore.ts +47 -0
- package/src/types/statusList/statusList.ts +39 -0
- package/src/types/validation/validation.ts +3 -0
- package/src/utils/ValidatorUtils.ts +10 -0
- package/src/utils/contact/MappingUtils.ts +344 -0
- package/dist/entities/contact/ContactEntity.d.ts +0 -16
- package/dist/entities/contact/ContactEntity.d.ts.map +0 -1
- package/dist/entities/contact/ContactEntity.js.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +0 -1
- package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +0 -1
- package/src/entities/contact/ContactEntity.ts +0 -74
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Party, Identity, AddIdentityArgs, GetIdentityArgs, GetIdentitiesArgs, GetPartyArgs, RemoveIdentityArgs, UpdateIdentityArgs, AddPartyArgs, GetPartiesArgs, RemovePartyArgs, UpdatePartyArgs, AddRelationshipArgs, PartyRelationship, RemoveRelationshipArgs, AddPartyTypeArgs, PartyType, GetPartyTypeArgs, UpdatePartyTypeArgs, GetPartyTypesArgs, RemovePartyTypeArgs, GetRelationshipsArgs, GetRelationshipArgs, UpdateRelationshipArgs } from '../types';
|
|
2
2
|
export declare abstract class AbstractContactStore {
|
|
3
|
-
abstract
|
|
4
|
-
abstract
|
|
5
|
-
abstract
|
|
6
|
-
abstract
|
|
7
|
-
abstract
|
|
8
|
-
abstract getIdentity(args:
|
|
9
|
-
abstract getIdentities(args
|
|
10
|
-
abstract addIdentity(args:
|
|
11
|
-
abstract updateIdentity(args:
|
|
12
|
-
abstract removeIdentity(args:
|
|
3
|
+
abstract getParty(args: GetPartyArgs): Promise<Party>;
|
|
4
|
+
abstract getParties(args?: GetPartiesArgs): Promise<Array<Party>>;
|
|
5
|
+
abstract addParty(args: AddPartyArgs): Promise<Party>;
|
|
6
|
+
abstract updateParty(args: UpdatePartyArgs): Promise<Party>;
|
|
7
|
+
abstract removeParty(args: RemovePartyArgs): Promise<void>;
|
|
8
|
+
abstract getIdentity(args: GetIdentityArgs): Promise<Identity>;
|
|
9
|
+
abstract getIdentities(args?: GetIdentitiesArgs): Promise<Array<Identity>>;
|
|
10
|
+
abstract addIdentity(args: AddIdentityArgs): Promise<Identity>;
|
|
11
|
+
abstract updateIdentity(args: UpdateIdentityArgs): Promise<Identity>;
|
|
12
|
+
abstract removeIdentity(args: RemoveIdentityArgs): Promise<void>;
|
|
13
|
+
abstract getRelationship(args: GetRelationshipArgs): Promise<PartyRelationship>;
|
|
14
|
+
abstract getRelationships(args?: GetRelationshipsArgs): Promise<Array<PartyRelationship>>;
|
|
15
|
+
abstract addRelationship(args: AddRelationshipArgs): Promise<PartyRelationship>;
|
|
16
|
+
abstract updateRelationship(args: UpdateRelationshipArgs): Promise<PartyRelationship>;
|
|
17
|
+
abstract removeRelationship(args: RemoveRelationshipArgs): Promise<void>;
|
|
18
|
+
abstract getPartyType(args: GetPartyTypeArgs): Promise<PartyType>;
|
|
19
|
+
abstract getPartyTypes(args?: GetPartyTypesArgs): Promise<Array<PartyType>>;
|
|
20
|
+
abstract addPartyType(args: AddPartyTypeArgs): Promise<PartyType>;
|
|
21
|
+
abstract updatePartyType(args: UpdatePartyTypeArgs): Promise<PartyType>;
|
|
22
|
+
abstract removePartyType(args: RemovePartyTypeArgs): Promise<void>;
|
|
13
23
|
}
|
|
14
24
|
//# sourceMappingURL=AbstractContactStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractContactStore.d.ts","sourceRoot":"","sources":["../../src/contact/AbstractContactStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"AbstractContactStore.d.ts","sourceRoot":"","sources":["../../src/contact/AbstractContactStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,QAAQ,EACR,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,UAAU,CAAA;AAEjB,8BAAsB,oBAAoB;IACxC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;IACrD,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;IACrD,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC;IAC3D,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1D,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC9D,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1E,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC9D,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC;IACpE,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAChE,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC/E,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACzF,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC/E,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IACrF,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IACxE,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IACjE,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC3E,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IACjE,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IACvE,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractContactStore.js","sourceRoot":"","sources":["../../src/contact/AbstractContactStore.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AbstractContactStore.js","sourceRoot":"","sources":["../../src/contact/AbstractContactStore.ts"],"names":[],"mappings":";;;AA2BA,MAAsB,oBAAoB;CAqBzC;AArBD,oDAqBC"}
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { OrPromise } from '@sphereon/ssi-types';
|
|
2
|
-
import { AbstractContactStore } from './AbstractContactStore';
|
|
3
|
-
import { IAddIdentityArgs, IGetIdentityArgs, IGetIdentitiesArgs, IGetContactArgs, IRemoveIdentityArgs, IUpdateIdentityArgs, IGetContactsArgs, IAddContactArgs, IUpdateContactArgs, IRemoveContactArgs, IContact, IIdentity } from '../types';
|
|
4
2
|
import { DataSource } from 'typeorm';
|
|
3
|
+
import { AbstractContactStore } from './AbstractContactStore';
|
|
4
|
+
import { AddIdentityArgs, GetIdentityArgs, GetIdentitiesArgs, GetPartyArgs, RemoveIdentityArgs, UpdateIdentityArgs, GetPartiesArgs, AddPartyArgs, UpdatePartyArgs, RemovePartyArgs, Party, Identity, RemoveRelationshipArgs, PartyRelationship, AddRelationshipArgs, GetRelationshipArgs, AddPartyTypeArgs, PartyType, GetPartyTypeArgs, GetPartyTypesArgs, UpdatePartyTypeArgs, RemovePartyTypeArgs, GetRelationshipsArgs, UpdateRelationshipArgs } from '../types';
|
|
5
5
|
export declare class ContactStore extends AbstractContactStore {
|
|
6
6
|
private readonly dbConnection;
|
|
7
7
|
constructor(dbConnection: OrPromise<DataSource>);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
getParty: ({ partyId }: GetPartyArgs) => Promise<Party>;
|
|
9
|
+
getParties: (args?: GetPartiesArgs) => Promise<Array<Party>>;
|
|
10
|
+
addParty: (args: AddPartyArgs) => Promise<Party>;
|
|
11
|
+
updateParty: ({ party }: UpdatePartyArgs) => Promise<Party>;
|
|
12
|
+
removeParty: ({ partyId }: RemovePartyArgs) => Promise<void>;
|
|
13
|
+
getIdentity: ({ identityId }: GetIdentityArgs) => Promise<Identity>;
|
|
14
|
+
getIdentities: (args?: GetIdentitiesArgs) => Promise<Array<Identity>>;
|
|
15
|
+
addIdentity: ({ identity, partyId }: AddIdentityArgs) => Promise<Identity>;
|
|
16
|
+
updateIdentity: ({ identity }: UpdateIdentityArgs) => Promise<Identity>;
|
|
17
|
+
removeIdentity: ({ identityId }: RemoveIdentityArgs) => Promise<void>;
|
|
18
|
+
addRelationship: ({ leftId, rightId }: AddRelationshipArgs) => Promise<PartyRelationship>;
|
|
19
|
+
getRelationship: ({ relationshipId }: GetRelationshipArgs) => Promise<PartyRelationship>;
|
|
20
|
+
getRelationships: (args?: GetRelationshipsArgs) => Promise<Array<PartyRelationship>>;
|
|
21
|
+
updateRelationship: ({ relationship }: UpdateRelationshipArgs) => Promise<PartyRelationship>;
|
|
22
|
+
removeRelationship: ({ relationshipId }: RemoveRelationshipArgs) => Promise<void>;
|
|
23
|
+
addPartyType: (args: AddPartyTypeArgs) => Promise<PartyType>;
|
|
24
|
+
getPartyType: ({ partyTypeId }: GetPartyTypeArgs) => Promise<PartyType>;
|
|
25
|
+
getPartyTypes: (args?: GetPartyTypesArgs) => Promise<Array<PartyType>>;
|
|
26
|
+
updatePartyType: ({ partyType }: UpdatePartyTypeArgs) => Promise<PartyType>;
|
|
27
|
+
removePartyType: ({ partyTypeId }: RemovePartyTypeArgs) => Promise<void>;
|
|
28
|
+
private hasCorrectConnectionConfig;
|
|
29
|
+
private hasCorrectPartyType;
|
|
13
30
|
private deleteIdentities;
|
|
14
|
-
|
|
15
|
-
getIdentities: (args?: IGetIdentitiesArgs) => Promise<Array<IIdentity>>;
|
|
16
|
-
addIdentity: ({ identity, contactId }: IAddIdentityArgs) => Promise<IIdentity>;
|
|
17
|
-
updateIdentity: ({ identity }: IUpdateIdentityArgs) => Promise<IIdentity>;
|
|
18
|
-
removeIdentity: ({ identityId }: IRemoveIdentityArgs) => Promise<void>;
|
|
19
|
-
private contactFrom;
|
|
20
|
-
private identityFrom;
|
|
21
|
-
private correlationIdentifierFrom;
|
|
22
|
-
private metadataItemFrom;
|
|
23
|
-
private connectionFrom;
|
|
24
|
-
private configFrom;
|
|
25
|
-
private hasCorrectConfig;
|
|
26
|
-
private isOpenIdConfig;
|
|
27
|
-
private isDidAuthConfig;
|
|
31
|
+
private assertRelationshipSides;
|
|
28
32
|
}
|
|
29
33
|
//# sourceMappingURL=ContactStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactStore.d.ts","sourceRoot":"","sources":["../../src/contact/ContactStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContactStore.d.ts","sourceRoot":"","sources":["../../src/contact/ContactStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAA;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAuB7D,OAAO,EACL,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EAIf,KAAK,EACL,QAAQ,EACR,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EAGvB,MAAM,UAAU,CAAA;AAIjB,qBAAa,YAAa,SAAQ,oBAAoB;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;gBAExC,YAAY,EAAE,SAAS,CAAC,UAAU,CAAC;IAK/C,QAAQ,gBAAuB,YAAY,KAAG,QAAQ,KAAK,CAAC,CAU3D;IAED,UAAU,UAAiB,cAAc,KAAG,QAAQ,MAAM,KAAK,CAAC,CAAC,CAahE;IAED,QAAQ,SAAgB,YAAY,KAAG,QAAQ,KAAK,CAAC,CA0BpD;IAED,WAAW,cAAqB,eAAe,KAAG,QAAQ,KAAK,CAAC,CAsB/D;IAED,WAAW,gBAAuB,eAAe,KAAG,QAAQ,IAAI,CAAC,CAiBhE;IAED,WAAW,mBAA0B,eAAe,KAAG,QAAQ,QAAQ,CAAC,CAUvE;IAED,aAAa,UAAiB,iBAAiB,KAAG,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAazE;IAED,WAAW,0BAAiC,eAAe,KAAG,QAAQ,QAAQ,CAAC,CA2B9E;IAED,cAAc,iBAAwB,kBAAkB,KAAG,QAAQ,QAAQ,CAAC,CAwB3E;IAED,cAAc,mBAA0B,kBAAkB,KAAG,QAAQ,IAAI,CAAC,CAYzE;IAED,eAAe,wBAA+B,mBAAmB,KAAG,QAAQ,iBAAiB,CAAC,CAY7F;IAED,eAAe,uBAA8B,mBAAmB,KAAG,QAAQ,iBAAiB,CAAC,CAU5F;IAED,gBAAgB,UAAiB,oBAAoB,KAAG,QAAQ,MAAM,iBAAiB,CAAC,CAAC,CAaxF;IAED,kBAAkB,qBAA4B,sBAAsB,KAAG,QAAQ,iBAAiB,CAAC,CAgBhG;IAED,kBAAkB,uBAA8B,sBAAsB,KAAG,QAAQ,IAAI,CAAC,CAarF;IAED,YAAY,SAAgB,gBAAgB,KAAG,QAAQ,SAAS,CAAC,CAMhE;IAED,YAAY,oBAA2B,gBAAgB,KAAG,QAAQ,SAAS,CAAC,CAU3E;IAED,aAAa,UAAiB,iBAAiB,KAAG,QAAQ,MAAM,SAAS,CAAC,CAAC,CAa1E;IAED,eAAe,kBAAyB,mBAAmB,KAAG,QAAQ,SAAS,CAAC,CAc/E;IAED,eAAe,oBAA2B,mBAAmB,KAAG,QAAQ,IAAI,CAAC,CAyB5E;IAED,OAAO,CAAC,0BAA0B;IAWlC,OAAO,CAAC,mBAAmB;YAWb,gBAAgB;YAwChB,uBAAuB;CAkBtC"}
|
|
@@ -13,91 +13,93 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ContactStore = void 0;
|
|
16
|
+
const typeorm_1 = require("typeorm");
|
|
16
17
|
const debug_1 = __importDefault(require("debug"));
|
|
17
18
|
const AbstractContactStore_1 = require("./AbstractContactStore");
|
|
18
|
-
const
|
|
19
|
-
const ContactEntity_1 = require("../entities/contact/ContactEntity");
|
|
19
|
+
const PartyEntity_1 = require("../entities/contact/PartyEntity");
|
|
20
20
|
const IdentityEntity_1 = require("../entities/contact/IdentityEntity");
|
|
21
21
|
const IdentityMetadataItemEntity_1 = require("../entities/contact/IdentityMetadataItemEntity");
|
|
22
22
|
const CorrelationIdentifierEntity_1 = require("../entities/contact/CorrelationIdentifierEntity");
|
|
23
23
|
const ConnectionEntity_1 = require("../entities/contact/ConnectionEntity");
|
|
24
24
|
const BaseConfigEntity_1 = require("../entities/contact/BaseConfigEntity");
|
|
25
|
-
const
|
|
25
|
+
const PartyRelationshipEntity_1 = require("../entities/contact/PartyRelationshipEntity");
|
|
26
|
+
const PartyTypeEntity_1 = require("../entities/contact/PartyTypeEntity");
|
|
27
|
+
const MappingUtils_1 = require("../utils/contact/MappingUtils");
|
|
28
|
+
const types_1 = require("../types");
|
|
26
29
|
const debug = (0, debug_1.default)('sphereon:ssi-sdk:contact-store');
|
|
27
30
|
class ContactStore extends AbstractContactStore_1.AbstractContactStore {
|
|
28
31
|
constructor(dbConnection) {
|
|
29
32
|
super();
|
|
30
|
-
this.
|
|
31
|
-
const result = yield (yield this.dbConnection).getRepository(
|
|
32
|
-
where: { id:
|
|
33
|
+
this.getParty = ({ partyId }) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const result = yield (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity).findOne({
|
|
35
|
+
where: { id: partyId },
|
|
33
36
|
});
|
|
34
37
|
if (!result) {
|
|
35
|
-
return Promise.reject(Error(`No
|
|
38
|
+
return Promise.reject(Error(`No party found for id: ${partyId}`));
|
|
36
39
|
}
|
|
37
|
-
return
|
|
40
|
+
return (0, MappingUtils_1.partyFrom)(result);
|
|
38
41
|
});
|
|
39
|
-
this.
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
+
this.getParties = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const partyRepository = (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity);
|
|
44
|
+
const initialResult = yield partyRepository.find(Object.assign({}, ((args === null || args === void 0 ? void 0 : args.filter) && { where: args === null || args === void 0 ? void 0 : args.filter })));
|
|
45
|
+
const result = yield partyRepository.find({
|
|
42
46
|
where: {
|
|
43
|
-
id: (0, typeorm_1.In)(initialResult.map((
|
|
47
|
+
id: (0, typeorm_1.In)(initialResult.map((party) => party.id)),
|
|
44
48
|
},
|
|
45
49
|
});
|
|
46
|
-
return result.map((
|
|
50
|
+
return result.map((party) => (0, MappingUtils_1.partyFrom)(party));
|
|
47
51
|
});
|
|
48
|
-
this.
|
|
49
|
-
const {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (result) {
|
|
54
|
-
return Promise.reject(Error(`Duplicate names or aliases are not allowed. Name: ${name}, Alias: ${alias}`));
|
|
52
|
+
this.addParty = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const { identities, contact, partyType } = args;
|
|
54
|
+
const partyRepository = (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity);
|
|
55
|
+
if (!this.hasCorrectPartyType(partyType.type, contact)) {
|
|
56
|
+
return Promise.reject(Error(`Party type ${partyType.type}, does not match for provided contact`));
|
|
55
57
|
}
|
|
56
58
|
for (const identity of identities !== null && identities !== void 0 ? identities : []) {
|
|
57
59
|
if (identity.identifier.type === types_1.CorrelationIdentifierEnum.URL) {
|
|
58
60
|
if (!identity.connection) {
|
|
59
61
|
return Promise.reject(Error(`Identity with correlation type ${types_1.CorrelationIdentifierEnum.URL} should contain a connection`));
|
|
60
62
|
}
|
|
61
|
-
if (!this.
|
|
63
|
+
if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
|
|
62
64
|
return Promise.reject(Error(`Connection type ${identity.connection.type}, does not match for provided config`));
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
const
|
|
67
|
-
debug('Adding
|
|
68
|
-
const createdResult = yield
|
|
69
|
-
return
|
|
68
|
+
const partyEntity = (0, MappingUtils_1.partyEntityFrom)(args);
|
|
69
|
+
debug('Adding party', args);
|
|
70
|
+
const createdResult = yield partyRepository.save(partyEntity);
|
|
71
|
+
return (0, MappingUtils_1.partyFrom)(createdResult);
|
|
70
72
|
});
|
|
71
|
-
this.
|
|
72
|
-
const
|
|
73
|
-
|
|
73
|
+
this.updateParty = ({ party }) => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const partyRepository = (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity);
|
|
75
|
+
const result = yield partyRepository.findOne({
|
|
76
|
+
where: { id: party.id },
|
|
74
77
|
});
|
|
75
78
|
if (!result) {
|
|
76
|
-
return Promise.reject(Error(`No
|
|
79
|
+
return Promise.reject(Error(`No party found for id: ${party.id}`));
|
|
77
80
|
}
|
|
78
|
-
const
|
|
79
|
-
debug('Updating
|
|
80
|
-
const updatedResult = yield
|
|
81
|
-
return
|
|
81
|
+
const updatedParty = Object.assign(Object.assign({}, party), { identities: result.identities, type: result.partyType, relationships: result.relationships, electronicAddresses: result.electronicAddresses });
|
|
82
|
+
debug('Updating party', party);
|
|
83
|
+
const updatedResult = yield partyRepository.save(updatedParty, { transaction: true });
|
|
84
|
+
return (0, MappingUtils_1.partyFrom)(updatedResult);
|
|
82
85
|
});
|
|
83
|
-
this.
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
.findOneById(
|
|
88
|
-
.then((
|
|
89
|
-
if (!
|
|
90
|
-
yield Promise.reject(Error(`Unable to find the
|
|
86
|
+
this.removeParty = ({ partyId }) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const partyRepository = (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity);
|
|
88
|
+
debug('Removing party', partyId);
|
|
89
|
+
partyRepository
|
|
90
|
+
.findOneById(partyId)
|
|
91
|
+
.then((party) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
if (!party) {
|
|
93
|
+
yield Promise.reject(Error(`Unable to find the party with id to remove: ${partyId}`));
|
|
91
94
|
}
|
|
92
95
|
else {
|
|
93
|
-
yield this.deleteIdentities(
|
|
94
|
-
yield
|
|
95
|
-
.
|
|
96
|
-
.
|
|
97
|
-
.catch((error) => Promise.reject(Error(`Unable to remove contact with id: ${contactId}. ${error}`)));
|
|
96
|
+
yield this.deleteIdentities(party.identities);
|
|
97
|
+
yield partyRepository
|
|
98
|
+
.delete({ id: partyId })
|
|
99
|
+
.catch((error) => Promise.reject(Error(`Unable to remove party with id: ${partyId}. ${error}`)));
|
|
98
100
|
}
|
|
99
101
|
}))
|
|
100
|
-
.catch((error) => Promise.reject(Error(`Unable to remove
|
|
102
|
+
.catch((error) => Promise.reject(Error(`Unable to remove party with id: ${partyId}. ${error}`)));
|
|
101
103
|
});
|
|
102
104
|
this.getIdentity = ({ identityId }) => __awaiter(this, void 0, void 0, function* () {
|
|
103
105
|
const result = yield (yield this.dbConnection).getRepository(IdentityEntity_1.IdentityEntity).findOne({
|
|
@@ -106,42 +108,44 @@ class ContactStore extends AbstractContactStore_1.AbstractContactStore {
|
|
|
106
108
|
if (!result) {
|
|
107
109
|
return Promise.reject(Error(`No identity found for id: ${identityId}`));
|
|
108
110
|
}
|
|
109
|
-
return
|
|
111
|
+
return (0, MappingUtils_1.identityFrom)(result);
|
|
110
112
|
});
|
|
111
113
|
this.getIdentities = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
+
const identityRepository = (yield this.dbConnection).getRepository(IdentityEntity_1.IdentityEntity);
|
|
115
|
+
const initialResult = yield identityRepository.find(Object.assign({}, ((args === null || args === void 0 ? void 0 : args.filter) && { where: args === null || args === void 0 ? void 0 : args.filter })));
|
|
116
|
+
const result = yield identityRepository.find({
|
|
114
117
|
where: {
|
|
115
118
|
id: (0, typeorm_1.In)(initialResult.map((identity) => identity.id)),
|
|
116
119
|
},
|
|
117
120
|
});
|
|
118
|
-
return result.map((identity) =>
|
|
121
|
+
return result.map((identity) => (0, MappingUtils_1.identityFrom)(identity));
|
|
119
122
|
});
|
|
120
|
-
this.addIdentity = ({ identity,
|
|
121
|
-
const
|
|
122
|
-
where: { id:
|
|
123
|
+
this.addIdentity = ({ identity, partyId }) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const party = yield (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity).findOne({
|
|
125
|
+
where: { id: partyId },
|
|
123
126
|
});
|
|
124
|
-
if (!
|
|
125
|
-
return Promise.reject(Error(`No
|
|
127
|
+
if (!party) {
|
|
128
|
+
return Promise.reject(Error(`No party found for id: ${partyId}`));
|
|
126
129
|
}
|
|
127
130
|
if (identity.identifier.type === types_1.CorrelationIdentifierEnum.URL) {
|
|
128
131
|
if (!identity.connection) {
|
|
129
132
|
return Promise.reject(Error(`Identity with correlation type ${types_1.CorrelationIdentifierEnum.URL} should contain a connection`));
|
|
130
133
|
}
|
|
131
|
-
if (!this.
|
|
134
|
+
if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
|
|
132
135
|
return Promise.reject(Error(`Connection type ${identity.connection.type}, does not match for provided config`));
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
|
-
const identityEntity = (0,
|
|
136
|
-
identityEntity.
|
|
138
|
+
const identityEntity = (0, MappingUtils_1.identityEntityFrom)(identity);
|
|
139
|
+
identityEntity.party = party;
|
|
137
140
|
debug('Adding identity', identity);
|
|
138
141
|
const result = yield (yield this.dbConnection).getRepository(IdentityEntity_1.IdentityEntity).save(identityEntity, {
|
|
139
142
|
transaction: true,
|
|
140
143
|
});
|
|
141
|
-
return
|
|
144
|
+
return (0, MappingUtils_1.identityFrom)(result);
|
|
142
145
|
});
|
|
143
146
|
this.updateIdentity = ({ identity }) => __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
const
|
|
147
|
+
const identityRepository = (yield this.dbConnection).getRepository(IdentityEntity_1.IdentityEntity);
|
|
148
|
+
const result = yield identityRepository.findOne({
|
|
145
149
|
where: { id: identity.id },
|
|
146
150
|
});
|
|
147
151
|
if (!result) {
|
|
@@ -151,13 +155,13 @@ class ContactStore extends AbstractContactStore_1.AbstractContactStore {
|
|
|
151
155
|
if (!identity.connection) {
|
|
152
156
|
return Promise.reject(Error(`Identity with correlation type ${types_1.CorrelationIdentifierEnum.URL} should contain a connection`));
|
|
153
157
|
}
|
|
154
|
-
if (!this.
|
|
158
|
+
if (!this.hasCorrectConnectionConfig(identity.connection.type, identity.connection.config)) {
|
|
155
159
|
return Promise.reject(Error(`Connection type ${identity.connection.type}, does not match for provided config`));
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
debug('Updating identity', identity);
|
|
159
|
-
const updatedResult = yield
|
|
160
|
-
return
|
|
163
|
+
const updatedResult = yield identityRepository.save(identity, { transaction: true });
|
|
164
|
+
return (0, MappingUtils_1.identityFrom)(updatedResult);
|
|
161
165
|
});
|
|
162
166
|
this.removeIdentity = ({ identityId }) => __awaiter(this, void 0, void 0, function* () {
|
|
163
167
|
const identity = yield (yield this.dbConnection).getRepository(IdentityEntity_1.IdentityEntity).findOne({
|
|
@@ -169,72 +173,141 @@ class ContactStore extends AbstractContactStore_1.AbstractContactStore {
|
|
|
169
173
|
debug('Removing identity', identityId);
|
|
170
174
|
yield this.deleteIdentities([identity]);
|
|
171
175
|
});
|
|
172
|
-
this.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.configFrom = (type, config) => {
|
|
210
|
-
switch (type) {
|
|
211
|
-
case types_1.ConnectionTypeEnum.OPENID_CONNECT:
|
|
212
|
-
return {
|
|
213
|
-
id: config.id,
|
|
214
|
-
clientId: config.clientId,
|
|
215
|
-
clientSecret: config.clientSecret,
|
|
216
|
-
scopes: config.scopes,
|
|
217
|
-
issuer: config.issuer,
|
|
218
|
-
redirectUrl: config.redirectUrl,
|
|
219
|
-
dangerouslyAllowInsecureHttpRequests: config.dangerouslyAllowInsecureHttpRequests,
|
|
220
|
-
clientAuthMethod: config.clientAuthMethod,
|
|
221
|
-
};
|
|
222
|
-
case types_1.ConnectionTypeEnum.SIOPv2:
|
|
223
|
-
return {
|
|
224
|
-
id: config.id,
|
|
225
|
-
identifier: { did: config.identifier, provider: '', keys: [], services: [] },
|
|
226
|
-
stateId: '',
|
|
227
|
-
redirectUrl: config.redirectUrl,
|
|
228
|
-
sessionId: config.sessionId,
|
|
229
|
-
};
|
|
230
|
-
default:
|
|
231
|
-
throw new Error('Connection type not supported');
|
|
176
|
+
this.addRelationship = ({ leftId, rightId }) => __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
return this.assertRelationshipSides(leftId, rightId).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const relationship = (0, MappingUtils_1.partyRelationshipEntityFrom)({
|
|
179
|
+
leftId,
|
|
180
|
+
rightId,
|
|
181
|
+
});
|
|
182
|
+
debug('Adding party relationship', relationship);
|
|
183
|
+
const createdResult = yield (yield this.dbConnection).getRepository(PartyRelationshipEntity_1.PartyRelationshipEntity).save(relationship);
|
|
184
|
+
return (0, MappingUtils_1.partyRelationshipFrom)(createdResult);
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
this.getRelationship = ({ relationshipId }) => __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const result = yield (yield this.dbConnection).getRepository(PartyRelationshipEntity_1.PartyRelationshipEntity).findOne({
|
|
189
|
+
where: { id: relationshipId },
|
|
190
|
+
});
|
|
191
|
+
if (!result) {
|
|
192
|
+
return Promise.reject(Error(`No relationship found for id: ${relationshipId}`));
|
|
193
|
+
}
|
|
194
|
+
return (0, MappingUtils_1.partyRelationshipFrom)(result);
|
|
195
|
+
});
|
|
196
|
+
this.getRelationships = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
const partyRelationshipRepository = (yield this.dbConnection).getRepository(PartyRelationshipEntity_1.PartyRelationshipEntity);
|
|
198
|
+
const initialResult = yield partyRelationshipRepository.find(Object.assign({}, ((args === null || args === void 0 ? void 0 : args.filter) && { where: args === null || args === void 0 ? void 0 : args.filter })));
|
|
199
|
+
const result = yield partyRelationshipRepository.find({
|
|
200
|
+
where: {
|
|
201
|
+
id: (0, typeorm_1.In)(initialResult.map((partyRelationship) => partyRelationship.id)),
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
return result.map((partyRelationship) => (0, MappingUtils_1.partyRelationshipFrom)(partyRelationship));
|
|
205
|
+
});
|
|
206
|
+
this.updateRelationship = ({ relationship }) => __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const partyRelationshipRepository = (yield this.dbConnection).getRepository(PartyRelationshipEntity_1.PartyRelationshipEntity);
|
|
208
|
+
const result = yield partyRelationshipRepository.findOne({
|
|
209
|
+
where: { id: relationship.id },
|
|
210
|
+
});
|
|
211
|
+
if (!result) {
|
|
212
|
+
return Promise.reject(Error(`No party relationship found for id: ${relationship.id}`));
|
|
232
213
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
214
|
+
return this.assertRelationshipSides(relationship.leftId, relationship.rightId).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
debug('Updating party relationship', relationship);
|
|
216
|
+
const updatedResult = yield partyRelationshipRepository.save(relationship, { transaction: true });
|
|
217
|
+
return (0, MappingUtils_1.partyRelationshipFrom)(updatedResult);
|
|
218
|
+
}));
|
|
219
|
+
});
|
|
220
|
+
this.removeRelationship = ({ relationshipId }) => __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const partyRelationshipRepository = (yield this.dbConnection).getRepository(PartyRelationshipEntity_1.PartyRelationshipEntity);
|
|
222
|
+
const relationship = yield partyRelationshipRepository.findOne({
|
|
223
|
+
where: { id: relationshipId },
|
|
224
|
+
});
|
|
225
|
+
if (!relationship) {
|
|
226
|
+
return Promise.reject(Error(`No relationship found for id: ${relationshipId}`));
|
|
227
|
+
}
|
|
228
|
+
debug('Removing relationship', relationshipId);
|
|
229
|
+
yield partyRelationshipRepository.delete(relationshipId);
|
|
230
|
+
});
|
|
231
|
+
this.addPartyType = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
const partyEntity = (0, MappingUtils_1.partyTypeEntityFrom)(args);
|
|
233
|
+
debug('Adding party type', args);
|
|
234
|
+
const createdResult = yield (yield this.dbConnection).getRepository(PartyTypeEntity_1.PartyTypeEntity).save(partyEntity);
|
|
235
|
+
return (0, MappingUtils_1.partyTypeFrom)(createdResult);
|
|
236
|
+
});
|
|
237
|
+
this.getPartyType = ({ partyTypeId }) => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
const result = yield (yield this.dbConnection).getRepository(PartyTypeEntity_1.PartyTypeEntity).findOne({
|
|
239
|
+
where: { id: partyTypeId },
|
|
240
|
+
});
|
|
241
|
+
if (!result) {
|
|
242
|
+
return Promise.reject(Error(`No party type found for id: ${partyTypeId}`));
|
|
243
|
+
}
|
|
244
|
+
return (0, MappingUtils_1.partyTypeFrom)(result);
|
|
245
|
+
});
|
|
246
|
+
this.getPartyTypes = (args) => __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
const partyTypeRepository = (yield this.dbConnection).getRepository(PartyTypeEntity_1.PartyTypeEntity);
|
|
248
|
+
const initialResult = yield partyTypeRepository.find(Object.assign({}, ((args === null || args === void 0 ? void 0 : args.filter) && { where: args === null || args === void 0 ? void 0 : args.filter })));
|
|
249
|
+
const result = yield partyTypeRepository.find({
|
|
250
|
+
where: {
|
|
251
|
+
id: (0, typeorm_1.In)(initialResult.map((partyType) => partyType.id)),
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return result.map((partyType) => (0, MappingUtils_1.partyTypeFrom)(partyType));
|
|
255
|
+
});
|
|
256
|
+
this.updatePartyType = ({ partyType }) => __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
const partyTypeRepository = (yield this.dbConnection).getRepository(PartyTypeEntity_1.PartyTypeEntity);
|
|
258
|
+
const result = yield partyTypeRepository.findOne({
|
|
259
|
+
where: { id: partyType.id },
|
|
260
|
+
});
|
|
261
|
+
if (!result) {
|
|
262
|
+
return Promise.reject(Error(`No party type found for id: ${partyType.id}`));
|
|
263
|
+
}
|
|
264
|
+
debug('Updating party type', partyType);
|
|
265
|
+
const updatedResult = yield partyTypeRepository.save(partyType, { transaction: true });
|
|
266
|
+
return (0, MappingUtils_1.partyTypeFrom)(updatedResult);
|
|
267
|
+
});
|
|
268
|
+
this.removePartyType = ({ partyTypeId }) => __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
const parties = yield (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity).find({
|
|
270
|
+
where: {
|
|
271
|
+
partyType: {
|
|
272
|
+
id: partyTypeId,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
if (parties.length > 0) {
|
|
277
|
+
return Promise.reject(Error(`Unable to remove party type with id: ${partyTypeId}. Party type is in use`));
|
|
278
|
+
}
|
|
279
|
+
const partyTypeRepository = (yield this.dbConnection).getRepository(PartyTypeEntity_1.PartyTypeEntity);
|
|
280
|
+
const partyType = yield partyTypeRepository.findOne({
|
|
281
|
+
where: { id: partyTypeId },
|
|
282
|
+
});
|
|
283
|
+
if (!partyType) {
|
|
284
|
+
return Promise.reject(Error(`No party type found for id: ${partyTypeId}`));
|
|
285
|
+
}
|
|
286
|
+
debug('Removing party type', partyTypeId);
|
|
287
|
+
yield partyTypeRepository.delete(partyTypeId);
|
|
288
|
+
});
|
|
236
289
|
this.dbConnection = dbConnection;
|
|
237
290
|
}
|
|
291
|
+
hasCorrectConnectionConfig(type, config) {
|
|
292
|
+
switch (type) {
|
|
293
|
+
case types_1.ConnectionTypeEnum.OPENID_CONNECT:
|
|
294
|
+
return (0, MappingUtils_1.isOpenIdConfig)(config);
|
|
295
|
+
case types_1.ConnectionTypeEnum.SIOPv2:
|
|
296
|
+
return (0, MappingUtils_1.isDidAuthConfig)(config);
|
|
297
|
+
default:
|
|
298
|
+
throw new Error('Connection type not supported');
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
hasCorrectPartyType(type, contact) {
|
|
302
|
+
switch (type) {
|
|
303
|
+
case types_1.PartyTypeEnum.NATURAL_PERSON:
|
|
304
|
+
return (0, MappingUtils_1.isNaturalPerson)(contact);
|
|
305
|
+
case types_1.PartyTypeEnum.ORGANIZATION:
|
|
306
|
+
return (0, MappingUtils_1.isOrganization)(contact);
|
|
307
|
+
default:
|
|
308
|
+
throw new Error('Party type not supported');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
238
311
|
deleteIdentities(identities) {
|
|
239
312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
240
313
|
debug('Removing identities', identities);
|
|
@@ -266,15 +339,22 @@ class ContactStore extends AbstractContactStore_1.AbstractContactStore {
|
|
|
266
339
|
}));
|
|
267
340
|
});
|
|
268
341
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
342
|
+
assertRelationshipSides(leftId, rightId) {
|
|
343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
344
|
+
const partyRepository = (yield this.dbConnection).getRepository(PartyEntity_1.PartyEntity);
|
|
345
|
+
const leftParty = yield partyRepository.findOne({
|
|
346
|
+
where: { id: leftId },
|
|
347
|
+
});
|
|
348
|
+
if (!leftParty) {
|
|
349
|
+
return Promise.reject(Error(`No party found for left side of the relationship, party id: ${leftId}`));
|
|
350
|
+
}
|
|
351
|
+
const rightParty = yield partyRepository.findOne({
|
|
352
|
+
where: { id: rightId },
|
|
353
|
+
});
|
|
354
|
+
if (!rightParty) {
|
|
355
|
+
return Promise.reject(Error(`No party found for right side of the relationship, party id: ${rightId}`));
|
|
356
|
+
}
|
|
357
|
+
});
|
|
278
358
|
}
|
|
279
359
|
}
|
|
280
360
|
exports.ContactStore = ContactStore;
|