@sphereon/ssi-sdk.contact-manager 0.15.2-next.6 → 0.15.2-next.77
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/agent/ContactManager.d.ts +21 -0
- package/dist/agent/ContactManager.d.ts.map +1 -1
- package/dist/agent/ContactManager.js +94 -8
- package/dist/agent/ContactManager.js.map +1 -1
- package/dist/types/IContactManager.d.ts +80 -39
- package/dist/types/IContactManager.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/agent/ContactManager.ts +125 -29
- package/src/types/IContactManager.ts +104 -32
|
@@ -31,5 +31,26 @@ export declare class ContactManager implements IAgentPlugin {
|
|
|
31
31
|
private cmUpdateIdentity;
|
|
32
32
|
/** {@inheritDoc IContactManager.cmRemoveIdentity} */
|
|
33
33
|
private cmRemoveIdentity;
|
|
34
|
+
/** {@inheritDoc IContactManager.cmAddRelationship} */
|
|
35
|
+
private cmAddRelationship;
|
|
36
|
+
/** {@inheritDoc IContactManager.cmRemoveRelationship} */
|
|
37
|
+
private cmRemoveRelationship;
|
|
38
|
+
/** {@inheritDoc IContactManager.cmGetRelationship} */
|
|
39
|
+
private cmGetRelationship;
|
|
40
|
+
/** {@inheritDoc IContactManager.cmGetRelationships} */
|
|
41
|
+
private cmGetRelationships;
|
|
42
|
+
/** {@inheritDoc IContactManager.cmUpdateRelationship} */
|
|
43
|
+
private cmUpdateRelationship;
|
|
44
|
+
/** {@inheritDoc IContactManager.cmGetContactType} */
|
|
45
|
+
private cmGetContactType;
|
|
46
|
+
/** {@inheritDoc IContactManager.cmGetContactTypes} */
|
|
47
|
+
private cmGetContactTypes;
|
|
48
|
+
/** {@inheritDoc IContactManager.cmAddContactType} */
|
|
49
|
+
private cmAddContactType;
|
|
50
|
+
/** {@inheritDoc IContactManager.cmUpdateContactType} */
|
|
51
|
+
private cmUpdateContactType;
|
|
52
|
+
/** {@inheritDoc IContactManager.cmRemoveContactType} */
|
|
53
|
+
private cmRemoveContactType;
|
|
54
|
+
private getContactInformationFrom;
|
|
34
55
|
}
|
|
35
56
|
//# sourceMappingURL=ContactManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactManager.d.ts","sourceRoot":"","sources":["../../src/agent/ContactManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAML,eAAe,
|
|
1
|
+
{"version":3,"file":"ContactManager.d.ts","sourceRoot":"","sources":["../../src/agent/ContactManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAML,eAAe,EAiBhB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,oBAAoB,EAQrB,MAAM,8BAA8B,CAAA;AAErC;;GAEG;AACH,qBAAa,cAAe,YAAW,YAAY;IACjD,QAAQ,CAAC,MAAM,MAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAqBhC;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBAEhC,OAAO,EAAE;QAAE,KAAK,EAAE,oBAAoB,CAAA;KAAE;IAIpD,iDAAiD;YACnC,YAAY;IAI1B,kDAAkD;YACpC,aAAa;IAI3B,iDAAiD;YACnC,YAAY;IAU1B,oDAAoD;YACtC,eAAe;IAI7B,oDAAoD;YACtC,eAAe;IAI7B,kDAAkD;YACpC,aAAa;IAI3B,oDAAoD;YACtC,eAAe;IAI7B,kDAAkD;YACpC,aAAa;IAI3B,qDAAqD;YACvC,gBAAgB;IAI9B,qDAAqD;YACvC,gBAAgB;IAI9B,sDAAsD;YACxC,iBAAiB;IAI/B,yDAAyD;YAC3C,oBAAoB;IAIlC,sDAAsD;YACxC,iBAAiB;IAI/B,uDAAuD;YACzC,kBAAkB;IAIhC,yDAAyD;YAC3C,oBAAoB;IAIlC,qDAAqD;YACvC,gBAAgB;IAI9B,sDAAsD;YACxC,iBAAiB;IAI/B,qDAAqD;YACvC,gBAAgB;IAI9B,wDAAwD;YAC1C,mBAAmB;IAIjC,wDAAwD;YAC1C,mBAAmB;IAIjC,OAAO,CAAC,yBAAyB;CAUlC"}
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ContactManager = void 0;
|
|
13
13
|
const index_1 = require("../index");
|
|
14
|
+
const ssi_sdk_data_store_1 = require("@sphereon/ssi-sdk.data-store");
|
|
14
15
|
/**
|
|
15
16
|
* {@inheritDoc IContactManager}
|
|
16
17
|
*/
|
|
@@ -28,37 +29,53 @@ class ContactManager {
|
|
|
28
29
|
cmAddIdentity: this.cmAddIdentity.bind(this),
|
|
29
30
|
cmUpdateIdentity: this.cmUpdateIdentity.bind(this),
|
|
30
31
|
cmRemoveIdentity: this.cmRemoveIdentity.bind(this),
|
|
32
|
+
cmAddRelationship: this.cmAddRelationship.bind(this),
|
|
33
|
+
cmRemoveRelationship: this.cmRemoveRelationship.bind(this),
|
|
34
|
+
cmGetRelationship: this.cmGetRelationship.bind(this),
|
|
35
|
+
cmGetRelationships: this.cmGetRelationships.bind(this),
|
|
36
|
+
cmUpdateRelationship: this.cmUpdateRelationship.bind(this),
|
|
37
|
+
cmGetContactType: this.cmGetContactType.bind(this),
|
|
38
|
+
cmGetContactTypes: this.cmGetContactTypes.bind(this),
|
|
39
|
+
cmAddContactType: this.cmAddContactType.bind(this),
|
|
40
|
+
cmUpdateContactType: this.cmUpdateContactType.bind(this),
|
|
41
|
+
cmRemoveContactType: this.cmRemoveContactType.bind(this),
|
|
31
42
|
};
|
|
32
43
|
this.store = options.store;
|
|
33
44
|
}
|
|
34
45
|
/** {@inheritDoc IContactManager.cmGetContact} */
|
|
35
46
|
cmGetContact(args, context) {
|
|
36
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return this.store.
|
|
48
|
+
return this.store.getParty({ partyId: args.contactId });
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
/** {@inheritDoc IContactManager.cmGetContacts} */
|
|
41
52
|
cmGetContacts(args) {
|
|
42
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return this.store.
|
|
54
|
+
return this.store.getParties(args);
|
|
44
55
|
});
|
|
45
56
|
}
|
|
46
57
|
/** {@inheritDoc IContactManager.cmAddContact} */
|
|
47
58
|
cmAddContact(args, context) {
|
|
48
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return this.store.
|
|
60
|
+
return this.store.addParty({
|
|
61
|
+
uri: args.uri,
|
|
62
|
+
partyType: args.contactType,
|
|
63
|
+
contact: this.getContactInformationFrom(args),
|
|
64
|
+
identities: args.identities,
|
|
65
|
+
electronicAddresses: args.electronicAddresses,
|
|
66
|
+
});
|
|
50
67
|
});
|
|
51
68
|
}
|
|
52
69
|
/** {@inheritDoc IContactManager.cmUpdateContact} */
|
|
53
70
|
cmUpdateContact(args, context) {
|
|
54
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return this.store.
|
|
72
|
+
return this.store.updateParty({ party: args.contact });
|
|
56
73
|
});
|
|
57
74
|
}
|
|
58
75
|
/** {@inheritDoc IContactManager.cmRemoveContact} */
|
|
59
76
|
cmRemoveContact(args, context) {
|
|
60
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
return this.store.
|
|
78
|
+
return this.store.removeParty({ partyId: args.contactId }).then(() => true);
|
|
62
79
|
});
|
|
63
80
|
}
|
|
64
81
|
/** {@inheritDoc IContactManager.cmGetIdentity} */
|
|
@@ -68,7 +85,7 @@ class ContactManager {
|
|
|
68
85
|
});
|
|
69
86
|
}
|
|
70
87
|
/** {@inheritDoc IContactManager.cmGetIdentities} */
|
|
71
|
-
cmGetIdentities(args
|
|
88
|
+
cmGetIdentities(args) {
|
|
72
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
90
|
return this.store.getIdentities(args);
|
|
74
91
|
});
|
|
@@ -76,7 +93,7 @@ class ContactManager {
|
|
|
76
93
|
/** {@inheritDoc IContactManager.cmAddIdentity} */
|
|
77
94
|
cmAddIdentity(args, context) {
|
|
78
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
return this.store.addIdentity(args);
|
|
96
|
+
return this.store.addIdentity({ partyId: args.contactId, identity: args.identity });
|
|
80
97
|
});
|
|
81
98
|
}
|
|
82
99
|
/** {@inheritDoc IContactManager.cmUpdateIdentity} */
|
|
@@ -88,9 +105,78 @@ class ContactManager {
|
|
|
88
105
|
/** {@inheritDoc IContactManager.cmRemoveIdentity} */
|
|
89
106
|
cmRemoveIdentity(args, context) {
|
|
90
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
return this.store.removeIdentity(args).then(() => true);
|
|
108
|
+
return this.store.removeIdentity(args).then(() => true);
|
|
92
109
|
});
|
|
93
110
|
}
|
|
111
|
+
/** {@inheritDoc IContactManager.cmAddRelationship} */
|
|
112
|
+
cmAddRelationship(args, context) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return this.store.addRelationship(args);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** {@inheritDoc IContactManager.cmRemoveRelationship} */
|
|
118
|
+
cmRemoveRelationship(args, context) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return this.store.removeRelationship(args).then(() => true);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** {@inheritDoc IContactManager.cmGetRelationship} */
|
|
124
|
+
cmGetRelationship(args, context) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
return this.store.getRelationship(args);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** {@inheritDoc IContactManager.cmGetRelationships} */
|
|
130
|
+
cmGetRelationships(args) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
return this.store.getRelationships(args);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** {@inheritDoc IContactManager.cmUpdateRelationship} */
|
|
136
|
+
cmUpdateRelationship(args, context) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
return this.store.updateRelationship(args);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** {@inheritDoc IContactManager.cmGetContactType} */
|
|
142
|
+
cmGetContactType(args, context) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
return this.store.getPartyType({ partyTypeId: args.contactTypeId });
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** {@inheritDoc IContactManager.cmGetContactTypes} */
|
|
148
|
+
cmGetContactTypes(args) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
return this.store.getPartyTypes(args);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** {@inheritDoc IContactManager.cmAddContactType} */
|
|
154
|
+
cmAddContactType(args, context) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return this.store.addPartyType(args);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** {@inheritDoc IContactManager.cmUpdateContactType} */
|
|
160
|
+
cmUpdateContactType(args, context) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
return this.store.updatePartyType({ partyType: args.contactType });
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** {@inheritDoc IContactManager.cmRemoveContactType} */
|
|
166
|
+
cmRemoveContactType(args, context) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
return this.store.removePartyType({ partyTypeId: args.contactTypeId }).then(() => true);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
getContactInformationFrom(contact) {
|
|
172
|
+
if ((0, ssi_sdk_data_store_1.isNaturalPerson)(contact)) {
|
|
173
|
+
return { firstName: contact.firstName, middleName: contact.middleName, lastName: contact.lastName, displayName: contact.displayName };
|
|
174
|
+
}
|
|
175
|
+
else if ((0, ssi_sdk_data_store_1.isOrganization)(contact)) {
|
|
176
|
+
return { legalName: contact.legalName, displayName: contact.displayName };
|
|
177
|
+
}
|
|
178
|
+
throw new Error('Contact not supported');
|
|
179
|
+
}
|
|
94
180
|
}
|
|
95
181
|
exports.ContactManager = ContactManager;
|
|
96
182
|
//# sourceMappingURL=ContactManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactManager.js","sourceRoot":"","sources":["../../src/agent/ContactManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAiC;
|
|
1
|
+
{"version":3,"file":"ContactManager.js","sourceRoot":"","sources":["../../src/agent/ContactManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAAiC;AAyBjC,qEASqC;AAErC;;GAEG;AACH,MAAa,cAAc;IA2BzB,YAAY,OAAwC;QA1B3C,WAAM,GAAG,cAAM,CAAC,eAAe,CAAA;QAC/B,YAAO,GAAoB;YAClC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1C,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1C,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAChD,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAChD,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAChD,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,gBAAgB,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/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Identity, NonPersistedIdentity, FindRelationshipArgs, FindIdentityArgs, NonPersistedContact, PartyTypeEnum as ContactTypeEnum, NonPersistedPartyType as NonPersistedContactType, FindPartyTypeArgs as FindContactTypeArgs, FindPartyArgs as FindContactArgs, PartyRelationship as ContactRelationship, PartyType as ContactType, Party as Contact, NonPersistedParty } from '@sphereon/ssi-sdk.data-store';
|
|
3
3
|
export interface IContactManager extends IPluginMethodMap {
|
|
4
|
-
cmGetContact(args:
|
|
5
|
-
cmGetContacts(args?:
|
|
6
|
-
cmAddContact(args:
|
|
7
|
-
cmUpdateContact(args:
|
|
8
|
-
cmRemoveContact(args:
|
|
9
|
-
cmGetIdentity(args:
|
|
10
|
-
cmGetIdentities(args
|
|
11
|
-
cmAddIdentity(args:
|
|
12
|
-
cmUpdateIdentity(args:
|
|
13
|
-
cmRemoveIdentity(args:
|
|
4
|
+
cmGetContact(args: GetContactArgs, context: RequiredContext): Promise<Contact>;
|
|
5
|
+
cmGetContacts(args?: GetContactsArgs): Promise<Array<Contact>>;
|
|
6
|
+
cmAddContact(args: AddContactArgs, context: RequiredContext): Promise<Contact>;
|
|
7
|
+
cmUpdateContact(args: UpdateContactArgs, context: RequiredContext): Promise<Contact>;
|
|
8
|
+
cmRemoveContact(args: RemoveContactArgs, context: RequiredContext): Promise<boolean>;
|
|
9
|
+
cmGetIdentity(args: GetIdentityArgs, context: RequiredContext): Promise<Identity>;
|
|
10
|
+
cmGetIdentities(args?: GetIdentitiesArgs): Promise<Array<Identity>>;
|
|
11
|
+
cmAddIdentity(args: AddIdentityArgs, context: RequiredContext): Promise<Identity>;
|
|
12
|
+
cmUpdateIdentity(args: UpdateIdentityArgs, context: RequiredContext): Promise<Identity>;
|
|
13
|
+
cmRemoveIdentity(args: RemoveIdentityArgs, context: RequiredContext): Promise<boolean>;
|
|
14
|
+
cmGetRelationship(args: GetRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>;
|
|
15
|
+
cmGetRelationships(args?: GetRelationshipsArgs): Promise<Array<ContactRelationship>>;
|
|
16
|
+
cmUpdateRelationship(args: UpdateRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>;
|
|
17
|
+
cmAddRelationship(args: AddRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>;
|
|
18
|
+
cmRemoveRelationship(args: RemoveRelationshipArgs, context: RequiredContext): Promise<boolean>;
|
|
19
|
+
cmGetContactType(args: GetContactTypeArgs, context: RequiredContext): Promise<ContactType>;
|
|
20
|
+
cmGetContactTypes(args?: GetContactTypesArgs): Promise<Array<ContactType>>;
|
|
21
|
+
cmAddContactType(args: AddContactTypeArgs, context: RequiredContext): Promise<ContactType>;
|
|
22
|
+
cmUpdateContactType(args: UpdateContactTypeArgs, context: RequiredContext): Promise<ContactType>;
|
|
23
|
+
cmRemoveContactType(args: RemoveContactTypeArgs, context: RequiredContext): Promise<boolean>;
|
|
14
24
|
}
|
|
15
|
-
export
|
|
25
|
+
export type GetContactArgs = {
|
|
16
26
|
contactId: string;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
27
|
+
};
|
|
28
|
+
export type GetContactsArgs = {
|
|
19
29
|
filter?: FindContactArgs;
|
|
20
|
-
}
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
contact: IContact;
|
|
29
|
-
}
|
|
30
|
-
export interface IRemoveContactArgs {
|
|
30
|
+
};
|
|
31
|
+
export type AddContactArgs = Omit<NonPersistedParty, 'contact' | 'partyType'> & NonPersistedContact & {
|
|
32
|
+
contactType: NonPersistedContactType;
|
|
33
|
+
};
|
|
34
|
+
export type UpdateContactArgs = {
|
|
35
|
+
contact: Contact;
|
|
36
|
+
};
|
|
37
|
+
export type RemoveContactArgs = {
|
|
31
38
|
contactId: string;
|
|
32
|
-
}
|
|
33
|
-
export
|
|
39
|
+
};
|
|
40
|
+
export type GetIdentityArgs = {
|
|
34
41
|
identityId: string;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
42
|
+
};
|
|
43
|
+
export type GetIdentitiesArgs = {
|
|
37
44
|
filter?: FindIdentityArgs;
|
|
38
|
-
}
|
|
39
|
-
export
|
|
45
|
+
};
|
|
46
|
+
export type AddIdentityArgs = {
|
|
40
47
|
contactId: string;
|
|
41
|
-
identity:
|
|
42
|
-
}
|
|
43
|
-
export
|
|
44
|
-
identity:
|
|
45
|
-
}
|
|
46
|
-
export
|
|
48
|
+
identity: NonPersistedIdentity;
|
|
49
|
+
};
|
|
50
|
+
export type UpdateIdentityArgs = {
|
|
51
|
+
identity: Identity;
|
|
52
|
+
};
|
|
53
|
+
export type RemoveIdentityArgs = {
|
|
47
54
|
identityId: string;
|
|
48
|
-
}
|
|
49
|
-
export type
|
|
55
|
+
};
|
|
56
|
+
export type AddRelationshipArgs = {
|
|
57
|
+
leftId: string;
|
|
58
|
+
rightId: string;
|
|
59
|
+
};
|
|
60
|
+
export type RemoveRelationshipArgs = {
|
|
61
|
+
relationshipId: string;
|
|
62
|
+
};
|
|
63
|
+
export type GetRelationshipArgs = {
|
|
64
|
+
relationshipId: string;
|
|
65
|
+
};
|
|
66
|
+
export type GetRelationshipsArgs = {
|
|
67
|
+
filter: FindRelationshipArgs;
|
|
68
|
+
};
|
|
69
|
+
export type UpdateRelationshipArgs = {
|
|
70
|
+
relationship: Omit<ContactRelationship, 'createdAt' | 'lastUpdatedAt'>;
|
|
71
|
+
};
|
|
72
|
+
export type AddContactTypeArgs = {
|
|
73
|
+
type: ContactTypeEnum;
|
|
74
|
+
name: string;
|
|
75
|
+
tenantId: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
};
|
|
78
|
+
export type GetContactTypeArgs = {
|
|
79
|
+
contactTypeId: string;
|
|
80
|
+
};
|
|
81
|
+
export type GetContactTypesArgs = {
|
|
82
|
+
filter?: FindContactTypeArgs;
|
|
83
|
+
};
|
|
84
|
+
export type UpdateContactTypeArgs = {
|
|
85
|
+
contactType: Omit<ContactType, 'createdAt' | 'lastUpdatedAt'>;
|
|
86
|
+
};
|
|
87
|
+
export type RemoveContactTypeArgs = {
|
|
88
|
+
contactTypeId: string;
|
|
89
|
+
};
|
|
90
|
+
export type RequiredContext = IAgentContext<never>;
|
|
50
91
|
//# sourceMappingURL=IContactManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IContactManager.d.ts","sourceRoot":"","sources":["../../src/types/IContactManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"IContactManager.d.ts","sourceRoot":"","sources":["../../src/types/IContactManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,IAAI,eAAe,EAChC,qBAAqB,IAAI,uBAAuB,EAChD,iBAAiB,IAAI,mBAAmB,EACxC,aAAa,IAAI,eAAe,EAChC,iBAAiB,IAAI,mBAAmB,EACxC,SAAS,IAAI,WAAW,EACxB,KAAK,IAAI,OAAO,EAChB,iBAAiB,EAClB,MAAM,8BAA8B,CAAA;AAErC,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9E,aAAa,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9D,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9E,eAAe,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAA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|
3
|
+
"version": "0.15.2-next.77+79913478",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/ssi-sdk.data-store": "
|
|
17
|
+
"@sphereon/ssi-sdk.data-store": "0.15.2-next.77+79913478",
|
|
18
18
|
"cross-fetch": "^3.1.8",
|
|
19
19
|
"typeorm": "^0.3.12"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@sphereon/ssi-sdk.agent-config": "
|
|
23
|
-
"@sphereon/ssi-sdk.data-store": "workspace
|
|
22
|
+
"@sphereon/ssi-sdk.agent-config": "0.15.2-next.77+79913478",
|
|
23
|
+
"@sphereon/ssi-sdk.data-store": "workspace:*",
|
|
24
24
|
"@veramo/remote-client": "4.2.0",
|
|
25
25
|
"@veramo/remote-server": "4.2.0"
|
|
26
26
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"OpenID",
|
|
46
46
|
"Contact Manager"
|
|
47
47
|
],
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "799134780eecc541cfe5e8b961cf3d0d0a212a4d"
|
|
49
49
|
}
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { IAgentPlugin } from '@veramo/core'
|
|
2
2
|
import { schema } from '../index'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
AddContactArgs,
|
|
5
|
+
UpdateContactArgs,
|
|
6
|
+
GetIdentitiesArgs,
|
|
7
|
+
RemoveContactArgs,
|
|
8
|
+
AddIdentityArgs,
|
|
9
9
|
IContactManager,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
GetIdentityArgs,
|
|
11
|
+
RemoveIdentityArgs,
|
|
12
|
+
RequiredContext,
|
|
13
|
+
UpdateIdentityArgs,
|
|
14
|
+
GetContactsArgs,
|
|
15
|
+
GetContactArgs,
|
|
16
|
+
AddRelationshipArgs,
|
|
17
|
+
RemoveRelationshipArgs,
|
|
18
|
+
GetRelationshipArgs,
|
|
19
|
+
GetRelationshipsArgs,
|
|
20
|
+
UpdateRelationshipArgs,
|
|
21
|
+
AddContactTypeArgs,
|
|
22
|
+
GetContactTypeArgs,
|
|
23
|
+
GetContactTypesArgs,
|
|
24
|
+
RemoveContactTypeArgs,
|
|
25
|
+
UpdateContactTypeArgs,
|
|
16
26
|
} from '../types/IContactManager'
|
|
17
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
AbstractContactStore,
|
|
29
|
+
Party as Contact,
|
|
30
|
+
Identity,
|
|
31
|
+
PartyRelationship as ContactRelationship,
|
|
32
|
+
PartyType as ContactType,
|
|
33
|
+
NonPersistedContact,
|
|
34
|
+
isNaturalPerson,
|
|
35
|
+
isOrganization,
|
|
36
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
18
37
|
|
|
19
38
|
/**
|
|
20
39
|
* {@inheritDoc IContactManager}
|
|
@@ -32,6 +51,16 @@ export class ContactManager implements IAgentPlugin {
|
|
|
32
51
|
cmAddIdentity: this.cmAddIdentity.bind(this),
|
|
33
52
|
cmUpdateIdentity: this.cmUpdateIdentity.bind(this),
|
|
34
53
|
cmRemoveIdentity: this.cmRemoveIdentity.bind(this),
|
|
54
|
+
cmAddRelationship: this.cmAddRelationship.bind(this),
|
|
55
|
+
cmRemoveRelationship: this.cmRemoveRelationship.bind(this),
|
|
56
|
+
cmGetRelationship: this.cmGetRelationship.bind(this),
|
|
57
|
+
cmGetRelationships: this.cmGetRelationships.bind(this),
|
|
58
|
+
cmUpdateRelationship: this.cmUpdateRelationship.bind(this),
|
|
59
|
+
cmGetContactType: this.cmGetContactType.bind(this),
|
|
60
|
+
cmGetContactTypes: this.cmGetContactTypes.bind(this),
|
|
61
|
+
cmAddContactType: this.cmAddContactType.bind(this),
|
|
62
|
+
cmUpdateContactType: this.cmUpdateContactType.bind(this),
|
|
63
|
+
cmRemoveContactType: this.cmRemoveContactType.bind(this),
|
|
35
64
|
}
|
|
36
65
|
|
|
37
66
|
private readonly store: AbstractContactStore
|
|
@@ -41,52 +70,119 @@ export class ContactManager implements IAgentPlugin {
|
|
|
41
70
|
}
|
|
42
71
|
|
|
43
72
|
/** {@inheritDoc IContactManager.cmGetContact} */
|
|
44
|
-
private async cmGetContact(args:
|
|
45
|
-
return this.store.
|
|
73
|
+
private async cmGetContact(args: GetContactArgs, context: RequiredContext): Promise<Contact> {
|
|
74
|
+
return this.store.getParty({ partyId: args.contactId })
|
|
46
75
|
}
|
|
47
76
|
|
|
48
77
|
/** {@inheritDoc IContactManager.cmGetContacts} */
|
|
49
|
-
private async cmGetContacts(args?:
|
|
50
|
-
return this.store.
|
|
78
|
+
private async cmGetContacts(args?: GetContactsArgs): Promise<Array<Contact>> {
|
|
79
|
+
return this.store.getParties(args)
|
|
51
80
|
}
|
|
52
81
|
|
|
53
82
|
/** {@inheritDoc IContactManager.cmAddContact} */
|
|
54
|
-
private async cmAddContact(args:
|
|
55
|
-
return this.store.
|
|
83
|
+
private async cmAddContact(args: AddContactArgs, context: RequiredContext): Promise<Contact> {
|
|
84
|
+
return this.store.addParty({
|
|
85
|
+
uri: args.uri,
|
|
86
|
+
partyType: args.contactType,
|
|
87
|
+
contact: this.getContactInformationFrom(args),
|
|
88
|
+
identities: args.identities,
|
|
89
|
+
electronicAddresses: args.electronicAddresses,
|
|
90
|
+
})
|
|
56
91
|
}
|
|
57
92
|
|
|
58
93
|
/** {@inheritDoc IContactManager.cmUpdateContact} */
|
|
59
|
-
private async cmUpdateContact(args:
|
|
60
|
-
return this.store.
|
|
94
|
+
private async cmUpdateContact(args: UpdateContactArgs, context: RequiredContext): Promise<Contact> {
|
|
95
|
+
return this.store.updateParty({ party: args.contact })
|
|
61
96
|
}
|
|
62
97
|
|
|
63
98
|
/** {@inheritDoc IContactManager.cmRemoveContact} */
|
|
64
|
-
private async cmRemoveContact(args:
|
|
65
|
-
return this.store.
|
|
99
|
+
private async cmRemoveContact(args: RemoveContactArgs, context: RequiredContext): Promise<boolean> {
|
|
100
|
+
return this.store.removeParty({ partyId: args.contactId }).then(() => true)
|
|
66
101
|
}
|
|
67
102
|
|
|
68
103
|
/** {@inheritDoc IContactManager.cmGetIdentity} */
|
|
69
|
-
private async cmGetIdentity(args:
|
|
104
|
+
private async cmGetIdentity(args: GetIdentityArgs, context: RequiredContext): Promise<Identity> {
|
|
70
105
|
return this.store.getIdentity(args)
|
|
71
106
|
}
|
|
72
107
|
|
|
73
108
|
/** {@inheritDoc IContactManager.cmGetIdentities} */
|
|
74
|
-
private async cmGetIdentities(args
|
|
109
|
+
private async cmGetIdentities(args?: GetIdentitiesArgs): Promise<Array<Identity>> {
|
|
75
110
|
return this.store.getIdentities(args)
|
|
76
111
|
}
|
|
77
112
|
|
|
78
113
|
/** {@inheritDoc IContactManager.cmAddIdentity} */
|
|
79
|
-
private async cmAddIdentity(args:
|
|
80
|
-
return this.store.addIdentity(args)
|
|
114
|
+
private async cmAddIdentity(args: AddIdentityArgs, context: RequiredContext): Promise<Identity> {
|
|
115
|
+
return this.store.addIdentity({ partyId: args.contactId, identity: args.identity })
|
|
81
116
|
}
|
|
82
117
|
|
|
83
118
|
/** {@inheritDoc IContactManager.cmUpdateIdentity} */
|
|
84
|
-
private async cmUpdateIdentity(args:
|
|
119
|
+
private async cmUpdateIdentity(args: UpdateIdentityArgs, context: RequiredContext): Promise<Identity> {
|
|
85
120
|
return this.store.updateIdentity(args)
|
|
86
121
|
}
|
|
87
122
|
|
|
88
123
|
/** {@inheritDoc IContactManager.cmRemoveIdentity} */
|
|
89
|
-
private async cmRemoveIdentity(args:
|
|
90
|
-
return this.store.removeIdentity(args).then(() => true)
|
|
124
|
+
private async cmRemoveIdentity(args: RemoveIdentityArgs, context: RequiredContext): Promise<boolean> {
|
|
125
|
+
return this.store.removeIdentity(args).then(() => true)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** {@inheritDoc IContactManager.cmAddRelationship} */
|
|
129
|
+
private async cmAddRelationship(args: AddRelationshipArgs, context: RequiredContext): Promise<ContactRelationship> {
|
|
130
|
+
return this.store.addRelationship(args)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** {@inheritDoc IContactManager.cmRemoveRelationship} */
|
|
134
|
+
private async cmRemoveRelationship(args: RemoveRelationshipArgs, context: RequiredContext): Promise<boolean> {
|
|
135
|
+
return this.store.removeRelationship(args).then(() => true)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** {@inheritDoc IContactManager.cmGetRelationship} */
|
|
139
|
+
private async cmGetRelationship(args: GetRelationshipArgs, context: RequiredContext): Promise<ContactRelationship> {
|
|
140
|
+
return this.store.getRelationship(args)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** {@inheritDoc IContactManager.cmGetRelationships} */
|
|
144
|
+
private async cmGetRelationships(args?: GetRelationshipsArgs): Promise<Array<ContactRelationship>> {
|
|
145
|
+
return this.store.getRelationships(args)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** {@inheritDoc IContactManager.cmUpdateRelationship} */
|
|
149
|
+
private async cmUpdateRelationship(args: UpdateRelationshipArgs, context: RequiredContext): Promise<ContactRelationship> {
|
|
150
|
+
return this.store.updateRelationship(args)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** {@inheritDoc IContactManager.cmGetContactType} */
|
|
154
|
+
private async cmGetContactType(args: GetContactTypeArgs, context: RequiredContext): Promise<ContactType> {
|
|
155
|
+
return this.store.getPartyType({ partyTypeId: args.contactTypeId })
|
|
91
156
|
}
|
|
157
|
+
|
|
158
|
+
/** {@inheritDoc IContactManager.cmGetContactTypes} */
|
|
159
|
+
private async cmGetContactTypes(args?: GetContactTypesArgs): Promise<Array<ContactType>> {
|
|
160
|
+
return this.store.getPartyTypes(args)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** {@inheritDoc IContactManager.cmAddContactType} */
|
|
164
|
+
private async cmAddContactType(args: AddContactTypeArgs, context: RequiredContext): Promise<ContactType> {
|
|
165
|
+
return this.store.addPartyType(args)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** {@inheritDoc IContactManager.cmUpdateContactType} */
|
|
169
|
+
private async cmUpdateContactType(args: UpdateContactTypeArgs, context: RequiredContext): Promise<ContactType> {
|
|
170
|
+
return this.store.updatePartyType({ partyType: args.contactType })
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** {@inheritDoc IContactManager.cmRemoveContactType} */
|
|
174
|
+
private async cmRemoveContactType(args: RemoveContactTypeArgs, context: RequiredContext): Promise<boolean> {
|
|
175
|
+
return this.store.removePartyType({ partyTypeId: args.contactTypeId }).then(() => true)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private getContactInformationFrom(contact: any): NonPersistedContact {
|
|
179
|
+
if (isNaturalPerson(contact)) {
|
|
180
|
+
return { firstName: contact.firstName, middleName: contact.middleName, lastName: contact.lastName, displayName: contact.displayName }
|
|
181
|
+
} else if (isOrganization(contact)) {
|
|
182
|
+
return { legalName: contact.legalName, displayName: contact.displayName }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
throw new Error('Contact not supported')
|
|
186
|
+
}
|
|
187
|
+
|
|
92
188
|
}
|
|
@@ -1,61 +1,133 @@
|
|
|
1
1
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Identity,
|
|
4
|
+
NonPersistedIdentity,
|
|
5
|
+
FindRelationshipArgs,
|
|
6
|
+
FindIdentityArgs,
|
|
7
|
+
NonPersistedContact,
|
|
8
|
+
PartyTypeEnum as ContactTypeEnum,
|
|
9
|
+
NonPersistedPartyType as NonPersistedContactType,
|
|
10
|
+
FindPartyTypeArgs as FindContactTypeArgs,
|
|
11
|
+
FindPartyArgs as FindContactArgs,
|
|
12
|
+
PartyRelationship as ContactRelationship,
|
|
13
|
+
PartyType as ContactType,
|
|
14
|
+
Party as Contact,
|
|
15
|
+
NonPersistedParty,
|
|
16
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
3
17
|
|
|
4
18
|
export interface IContactManager extends IPluginMethodMap {
|
|
5
|
-
cmGetContact(args:
|
|
6
|
-
cmGetContacts(args?:
|
|
7
|
-
cmAddContact(args:
|
|
8
|
-
cmUpdateContact(args:
|
|
9
|
-
cmRemoveContact(args:
|
|
10
|
-
cmGetIdentity(args:
|
|
11
|
-
cmGetIdentities(args
|
|
12
|
-
cmAddIdentity(args:
|
|
13
|
-
cmUpdateIdentity(args:
|
|
14
|
-
cmRemoveIdentity(args:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
cmGetContact(args: GetContactArgs, context: RequiredContext): Promise<Contact>
|
|
20
|
+
cmGetContacts(args?: GetContactsArgs): Promise<Array<Contact>>
|
|
21
|
+
cmAddContact(args: AddContactArgs, context: RequiredContext): Promise<Contact>
|
|
22
|
+
cmUpdateContact(args: UpdateContactArgs, context: RequiredContext): Promise<Contact>
|
|
23
|
+
cmRemoveContact(args: RemoveContactArgs, context: RequiredContext): Promise<boolean>
|
|
24
|
+
cmGetIdentity(args: GetIdentityArgs, context: RequiredContext): Promise<Identity>
|
|
25
|
+
cmGetIdentities(args?: GetIdentitiesArgs): Promise<Array<Identity>>
|
|
26
|
+
cmAddIdentity(args: AddIdentityArgs, context: RequiredContext): Promise<Identity>
|
|
27
|
+
cmUpdateIdentity(args: UpdateIdentityArgs, context: RequiredContext): Promise<Identity>
|
|
28
|
+
cmRemoveIdentity(args: RemoveIdentityArgs, context: RequiredContext): Promise<boolean>
|
|
29
|
+
cmGetRelationship(args: GetRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>
|
|
30
|
+
cmGetRelationships(args?: GetRelationshipsArgs): Promise<Array<ContactRelationship>>
|
|
31
|
+
cmUpdateRelationship(args: UpdateRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>
|
|
32
|
+
cmAddRelationship(args: AddRelationshipArgs, context: RequiredContext): Promise<ContactRelationship>
|
|
33
|
+
cmRemoveRelationship(args: RemoveRelationshipArgs, context: RequiredContext): Promise<boolean>
|
|
34
|
+
cmGetContactType(args: GetContactTypeArgs, context: RequiredContext): Promise<ContactType>
|
|
35
|
+
cmGetContactTypes(args?: GetContactTypesArgs): Promise<Array<ContactType>>
|
|
36
|
+
cmAddContactType(args: AddContactTypeArgs, context: RequiredContext): Promise<ContactType>
|
|
37
|
+
cmUpdateContactType(args: UpdateContactTypeArgs, context: RequiredContext): Promise<ContactType>
|
|
38
|
+
cmRemoveContactType(args: RemoveContactTypeArgs, context: RequiredContext): Promise<boolean>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type GetContactArgs = {
|
|
18
42
|
contactId: string
|
|
19
43
|
}
|
|
20
44
|
|
|
21
|
-
export
|
|
45
|
+
export type GetContactsArgs = {
|
|
22
46
|
filter?: FindContactArgs
|
|
23
47
|
}
|
|
24
48
|
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
49
|
+
// export type AddContactArgs = {
|
|
50
|
+
// uri?: string
|
|
51
|
+
// contactType: NonPersistedContactType
|
|
52
|
+
// identities?: Array<NonPersistedIdentity>
|
|
53
|
+
// } & NonPersistedNaturalPerson | NonPersistedOrganization
|
|
31
54
|
|
|
32
|
-
export
|
|
33
|
-
|
|
55
|
+
export type AddContactArgs = Omit<NonPersistedParty, 'contact' | 'partyType'> &
|
|
56
|
+
NonPersistedContact & {
|
|
57
|
+
contactType: NonPersistedContactType
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type UpdateContactArgs = {
|
|
61
|
+
contact: Contact
|
|
34
62
|
}
|
|
35
63
|
|
|
36
|
-
export
|
|
64
|
+
export type RemoveContactArgs = {
|
|
37
65
|
contactId: string
|
|
38
66
|
}
|
|
39
67
|
|
|
40
|
-
export
|
|
68
|
+
export type GetIdentityArgs = {
|
|
41
69
|
identityId: string
|
|
42
70
|
}
|
|
43
71
|
|
|
44
|
-
export
|
|
72
|
+
export type GetIdentitiesArgs = {
|
|
45
73
|
filter?: FindIdentityArgs
|
|
46
74
|
}
|
|
47
75
|
|
|
48
|
-
export
|
|
76
|
+
export type AddIdentityArgs = {
|
|
49
77
|
contactId: string
|
|
50
|
-
identity:
|
|
78
|
+
identity: NonPersistedIdentity
|
|
51
79
|
}
|
|
52
80
|
|
|
53
|
-
export
|
|
54
|
-
identity:
|
|
81
|
+
export type UpdateIdentityArgs = {
|
|
82
|
+
identity: Identity
|
|
55
83
|
}
|
|
56
84
|
|
|
57
|
-
export
|
|
85
|
+
export type RemoveIdentityArgs = {
|
|
58
86
|
identityId: string
|
|
59
87
|
}
|
|
60
88
|
|
|
61
|
-
export type
|
|
89
|
+
export type AddRelationshipArgs = {
|
|
90
|
+
leftId: string
|
|
91
|
+
rightId: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type RemoveRelationshipArgs = {
|
|
95
|
+
relationshipId: string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type GetRelationshipArgs = {
|
|
99
|
+
relationshipId: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type GetRelationshipsArgs = {
|
|
103
|
+
filter: FindRelationshipArgs
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type UpdateRelationshipArgs = {
|
|
107
|
+
relationship: Omit<ContactRelationship, 'createdAt' | 'lastUpdatedAt'>
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type AddContactTypeArgs = {
|
|
111
|
+
type: ContactTypeEnum
|
|
112
|
+
name: string
|
|
113
|
+
tenantId: string
|
|
114
|
+
description?: string
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type GetContactTypeArgs = {
|
|
118
|
+
contactTypeId: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type GetContactTypesArgs = {
|
|
122
|
+
filter?: FindContactTypeArgs
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type UpdateContactTypeArgs = {
|
|
126
|
+
contactType: Omit<ContactType, 'createdAt' | 'lastUpdatedAt'>
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type RemoveContactTypeArgs = {
|
|
130
|
+
contactTypeId: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type RequiredContext = IAgentContext<never>
|