@things-factory/contact 7.0.71 → 7.0.72
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/client/components/contact-selector.ts +2 -1
- package/client/pages/contact-list-page.ts +3 -5
- package/dist-client/components/contact-selector.js +2 -1
- package/dist-client/components/contact-selector.js.map +1 -1
- package/dist-client/pages/contact-list-page.js +3 -5
- package/dist-client/pages/contact-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/index.d.ts +1 -0
- package/dist-server/controllers/index.js +4 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/register-contact-as-system-user.d.ts +5 -0
- package/dist-server/controllers/register-contact-as-system-user.js +74 -0
- package/dist-server/controllers/register-contact-as-system-user.js.map +1 -0
- package/dist-server/index.d.ts +1 -3
- package/dist-server/index.js +1 -3
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.d.ts +0 -1
- package/dist-server/routes.js +0 -24
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/contact/contact-query.js +5 -5
- package/dist-server/service/contact/contact-query.js.map +1 -1
- package/dist-server/service/contact/contact.d.ts +1 -4
- package/dist-server/service/contact/contact.js +4 -17
- package/dist-server/service/contact/contact.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/controllers/index.ts +1 -0
- package/server/controllers/register-contact-as-system-user.ts +88 -0
- package/server/index.ts +1 -4
- package/server/routes.ts +0 -28
- package/server/service/contact/contact-query.ts +5 -5
- package/server/service/contact/contact.ts +12 -8
- package/translations/en.json +5 -1
- package/translations/ja.json +5 -1
- package/translations/ko.json +5 -1
- package/translations/ms.json +5 -1
- package/translations/zh.json +5 -1
- package/dist-server/middlewares/index.d.ts +0 -1
- package/dist-server/middlewares/index.js +0 -7
- package/dist-server/middlewares/index.js.map +0 -1
- package/dist-server/migrations/index.d.ts +0 -1
- package/dist-server/migrations/index.js +0 -12
- package/dist-server/migrations/index.js.map +0 -1
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;AAAA,4EAAiD","sourcesContent":["export * from './register-contact-as-system-user'\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerContactAsSystemUser = registerContactAsSystemUser;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
7
|
+
const env_1 = require("@things-factory/env");
|
|
8
|
+
const contact_1 = require("../service/contact/contact");
|
|
9
|
+
const { defaultPassword } = env_1.config.get('password');
|
|
10
|
+
async function registerContactAsSystemUser({ contactId, roleName }, context) {
|
|
11
|
+
const { domain, user, tx } = context.state;
|
|
12
|
+
const contactRepository = (0, shell_1.getRepository)(contact_1.Contact, tx);
|
|
13
|
+
const contact = await contactRepository.findOne({
|
|
14
|
+
where: {
|
|
15
|
+
id: contactId,
|
|
16
|
+
domain: { id: domain.id }
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (!contact) {
|
|
20
|
+
throw new Error(context.t('error.contact-not-found', { contactId }));
|
|
21
|
+
}
|
|
22
|
+
const email = contact.getContactItem(contact_1.ContactField.Email, 'work');
|
|
23
|
+
if (!email) {
|
|
24
|
+
throw new Error(context.t('error.contact-email-not-set', { contactId }));
|
|
25
|
+
}
|
|
26
|
+
const userRepository = (0, shell_1.getRepository)(auth_base_1.User, tx);
|
|
27
|
+
const existingUser = await userRepository.findOne({
|
|
28
|
+
where: { email: (0, typeorm_1.ILike)(email) },
|
|
29
|
+
relations: ['domains', 'roles']
|
|
30
|
+
});
|
|
31
|
+
if (existingUser && !existingUser.domains.find(d => d.id === domain.id)) {
|
|
32
|
+
existingUser.domains = [...existingUser.domains, domain];
|
|
33
|
+
}
|
|
34
|
+
if (!existingUser && !defaultPassword) {
|
|
35
|
+
throw new Error(context.t('error.contact-initial-password-required'));
|
|
36
|
+
}
|
|
37
|
+
const salt = !existingUser && auth_base_1.User.generateSalt();
|
|
38
|
+
const newUser = existingUser
|
|
39
|
+
? existingUser
|
|
40
|
+
: {
|
|
41
|
+
name: contact.name,
|
|
42
|
+
email,
|
|
43
|
+
userType: 'user',
|
|
44
|
+
domains: [domain],
|
|
45
|
+
status: auth_base_1.UserStatus.ACTIVATED,
|
|
46
|
+
salt,
|
|
47
|
+
passwordUpdatedAt: new Date(),
|
|
48
|
+
password: auth_base_1.User.encode(defaultPassword, salt),
|
|
49
|
+
updater: user,
|
|
50
|
+
creator: user
|
|
51
|
+
};
|
|
52
|
+
if (roleName) {
|
|
53
|
+
const roleRepository = (0, shell_1.getRepository)(auth_base_1.Role, tx);
|
|
54
|
+
const role = await roleRepository.findOne({
|
|
55
|
+
where: {
|
|
56
|
+
name: roleName,
|
|
57
|
+
domain: { id: domain.id }
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (!role) {
|
|
61
|
+
throw new Error(context.t('error.contact-role-not-found', { roleName }));
|
|
62
|
+
}
|
|
63
|
+
if (newUser.roles) {
|
|
64
|
+
if (!newUser.roles.find(role => role.name == roleName)) {
|
|
65
|
+
newUser.roles = [...newUser.roles, role];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
newUser.roles = [role];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return await userRepository.save(newUser);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=register-contact-as-system-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-cont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ACF,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;QAC1E,CAAC;QAED,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,EAAE,CAAC;gBACvD,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAC1C,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { ILike } from 'typeorm'\nimport { Role, User, UserStatus } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\nimport { config } from '@things-factory/env'\nimport { Contact, ContactField } from '../service/contact/contact'\n\nconst { defaultPassword } = config.get('password')\n\nexport async function registerContactAsSystemUser(\n { contactId, roleName }: { contactId: string; roleName?: string },\n context: ResolverContext\n) {\n const { domain, user, tx } = context.state\n\n const contactRepository = getRepository(Contact, tx)\n\n const contact = await contactRepository.findOne({\n where: {\n id: contactId,\n domain: { id: domain.id }\n }\n })\n\n if (!contact) {\n throw new Error(context.t('error.contact-not-found', { contactId }))\n }\n\n const email = contact.getContactItem(ContactField.Email, 'work')\n\n if (!email) {\n throw new Error(context.t('error.contact-email-not-set', { contactId }))\n }\n\n const userRepository = getRepository(User, tx)\n const existingUser = await userRepository.findOne({\n where: { email: ILike(email) },\n relations: ['domains', 'roles']\n })\n\n if (existingUser && !existingUser.domains.find(d => d.id === domain.id)) {\n existingUser.domains = [...existingUser.domains, domain]\n }\n\n if (!existingUser && !defaultPassword) {\n throw new Error(context.t('error.contact-initial-password-required'))\n }\n\n const salt = !existingUser && User.generateSalt()\n\n const newUser: Partial<User> = existingUser\n ? existingUser\n : {\n name: contact.name,\n email,\n userType: 'user',\n domains: [domain],\n status: UserStatus.ACTIVATED,\n salt,\n passwordUpdatedAt: new Date(),\n password: User.encode(defaultPassword, salt),\n updater: user,\n creator: user\n }\n\n if (roleName) {\n const roleRepository = getRepository(Role, tx)\n const role = await roleRepository.findOne({\n where: {\n name: roleName,\n domain: { id: domain.id }\n }\n })\n\n if (!role) {\n throw new Error(context.t('error.contact-role-not-found', { roleName }))\n }\n\n if (newUser.roles) {\n if (!newUser.roles.find(role => role.name == roleName)) {\n newUser.roles = [...newUser.roles, role]\n }\n } else {\n newUser.roles = [role]\n }\n }\n\n return await userRepository.save(newUser)\n}\n"]}
|
package/dist-server/index.d.ts
CHANGED
package/dist-server/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./
|
|
5
|
-
tslib_1.__exportStar(require("./middlewares"), exports);
|
|
4
|
+
tslib_1.__exportStar(require("./controllers"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./service"), exports);
|
|
7
|
-
require("./routes");
|
|
8
6
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,oDAAyB","sourcesContent":["export * from './controllers'\nexport * from './service'\n"]}
|
package/dist-server/routes.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const debug: any;
|
package/dist-server/routes.js
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
const debug = require('debug')('things-factory:contact:routes');
|
|
2
|
-
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
|
3
|
-
/*
|
|
4
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
5
|
-
*
|
|
6
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
7
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
8
|
-
*/
|
|
9
|
-
});
|
|
10
|
-
process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
|
|
11
|
-
/*
|
|
12
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
13
|
-
*/
|
|
14
|
-
});
|
|
15
|
-
process.on('bootstrap-module-domain-public-route', (app, domainPublicRouter) => {
|
|
16
|
-
/*
|
|
17
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
18
|
-
*/
|
|
19
|
-
});
|
|
20
|
-
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
|
21
|
-
/*
|
|
22
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
23
|
-
*/
|
|
24
|
-
});
|
|
25
1
|
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -20,7 +20,7 @@ function getContactItems(contact) {
|
|
|
20
20
|
function getContactItem(contact, type, label) {
|
|
21
21
|
var _a;
|
|
22
22
|
const { items } = contact;
|
|
23
|
-
return (
|
|
23
|
+
return (_a = items === null || items === void 0 ? void 0 : items.find(item => item.type === type && item.label === label)) === null || _a === void 0 ? void 0 : _a.value;
|
|
24
24
|
}
|
|
25
25
|
let ContactQuery = class ContactQuery {
|
|
26
26
|
async contact(id, context) {
|
|
@@ -104,28 +104,28 @@ tslib_1.__decorate([
|
|
|
104
104
|
tslib_1.__metadata("design:returntype", Promise)
|
|
105
105
|
], ContactQuery.prototype, "profile", null);
|
|
106
106
|
tslib_1.__decorate([
|
|
107
|
-
(0, type_graphql_1.FieldResolver)(type => String),
|
|
107
|
+
(0, type_graphql_1.FieldResolver)(type => String, { nullable: true }),
|
|
108
108
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
109
109
|
tslib_1.__metadata("design:type", Function),
|
|
110
110
|
tslib_1.__metadata("design:paramtypes", [contact_1.Contact]),
|
|
111
111
|
tslib_1.__metadata("design:returntype", Promise)
|
|
112
112
|
], ContactQuery.prototype, "phone", null);
|
|
113
113
|
tslib_1.__decorate([
|
|
114
|
-
(0, type_graphql_1.FieldResolver)(type => String),
|
|
114
|
+
(0, type_graphql_1.FieldResolver)(type => String, { nullable: true }),
|
|
115
115
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
116
116
|
tslib_1.__metadata("design:type", Function),
|
|
117
117
|
tslib_1.__metadata("design:paramtypes", [contact_1.Contact]),
|
|
118
118
|
tslib_1.__metadata("design:returntype", Promise)
|
|
119
119
|
], ContactQuery.prototype, "email", null);
|
|
120
120
|
tslib_1.__decorate([
|
|
121
|
-
(0, type_graphql_1.FieldResolver)(type => String),
|
|
121
|
+
(0, type_graphql_1.FieldResolver)(type => String, { nullable: true }),
|
|
122
122
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
123
123
|
tslib_1.__metadata("design:type", Function),
|
|
124
124
|
tslib_1.__metadata("design:paramtypes", [contact_1.Contact]),
|
|
125
125
|
tslib_1.__metadata("design:returntype", Promise)
|
|
126
126
|
], ContactQuery.prototype, "address", null);
|
|
127
127
|
tslib_1.__decorate([
|
|
128
|
-
(0, type_graphql_1.FieldResolver)(type => String),
|
|
128
|
+
(0, type_graphql_1.FieldResolver)(type => String, { nullable: true }),
|
|
129
129
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
130
130
|
tslib_1.__metadata("design:type", Function),
|
|
131
131
|
tslib_1.__metadata("design:paramtypes", [contact_1.Contact]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact-query.js","sourceRoot":"","sources":["../../../server/service/contact/contact-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,iDAAuG;AACvG,yDAAgD;AAChD,qEAA4D;AAC5D,uCAAiD;AACjD,iDAA4C;AAC5C,uCAAmC;AACnC,iDAA4C;AAE5C,SAAS,eAAe,CAAC,OAAgB;IACvC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAEzB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB,EAAE,IAAY,EAAE,KAAa;;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAEzB,OAAO,
|
|
1
|
+
{"version":3,"file":"contact-query.js","sourceRoot":"","sources":["../../../server/service/contact/contact-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,iDAAuG;AACvG,yDAAgD;AAChD,qEAA4D;AAC5D,uCAAiD;AACjD,iDAA4C;AAC5C,uCAAmC;AACnC,iDAA4C;AAE5C,SAAS,eAAe,CAAC,OAAgB;IACvC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAEzB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB,EAAE,IAAY,EAAE,KAAa;;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAEzB,OAAO,MAAA,K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EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;yCAEnC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACnC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;8CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,0BAAW,CAAC,CAAC;IACxB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;yCAEnC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;uBAnFU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CAoFxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Contact, ContactField } from './contact'\nimport { ContactItem } from './contact-item'\nimport { Profile } from './profile'\nimport { ContactList } from './contact-type'\n\nfunction getContactItems(contact: Contact) {\n const { items } = contact\n\n if (!items || !(items instanceof Array)) {\n return []\n }\n\n return items\n}\n\nfunction getContactItem(contact: Contact, type: String, label: String) {\n const { items } = contact\n\n return items?.find(item => item.type === type && item.label === label)?.value\n}\n\n@Resolver(Contact)\nexport class ContactQuery {\n @Query(returns => Contact!, { nullable: true, description: 'To fetch a Contact' })\n async contact(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Contact> {\n const { domain } = context.state\n\n return await getRepository(Contact).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ContactList, { description: 'To fetch multiple Contacts' })\n async contacts(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ContactList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Contact),\n searchables: ['name', 'company', 'email', 'phone']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Profile)\n async profile(@Root() contact: Contact): Promise<Profile> {\n var { left, top, zoom } = contact.profile || {}\n\n if (left === undefined || top === undefined || zoom === undefined) {\n return\n }\n\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: contact.domainId },\n refType: Contact.name,\n refBy: contact.id\n }\n })\n\n return { left, top, zoom, picture: attachment?.fullpath }\n }\n\n @FieldResolver(type => String, { nullable: true })\n async phone(@Root() contact: Contact): Promise<string> {\n return getContactItem(contact, ContactField.Phone, 'work')\n }\n\n @FieldResolver(type => String, { nullable: true })\n async email(@Root() contact: Contact): Promise<string> {\n return getContactItem(contact, ContactField.Email, 'work')\n }\n\n @FieldResolver(type => String, { nullable: true })\n async address(@Root() contact: Contact): Promise<string> {\n return getContactItem(contact, ContactField.Address, 'work')\n }\n\n @FieldResolver(type => String, { nullable: true })\n async department(@Root() contact: Contact): Promise<string> {\n return getContactItem(contact, ContactField.Department, 'work')\n }\n\n @FieldResolver(type => [ContactItem])\n async items(@Root() contact: Contact): Promise<ContactItem[]> {\n return getContactItems(contact)\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() contact: Contact): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: contact.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() contact: Contact): Promise<User> {\n return await getRepository(User).findOneBy({ id: contact.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() contact: Contact): Promise<User> {\n return await getRepository(User).findOneBy({ id: contact.creatorId })\n }\n}\n"]}
|
|
@@ -21,10 +21,6 @@ export declare class Contact {
|
|
|
21
21
|
domainId?: string;
|
|
22
22
|
name?: string;
|
|
23
23
|
company?: string;
|
|
24
|
-
email?: string;
|
|
25
|
-
phone?: string;
|
|
26
|
-
address?: string;
|
|
27
|
-
department?: string;
|
|
28
24
|
note?: string;
|
|
29
25
|
profile: Profile;
|
|
30
26
|
items?: ContactItem[];
|
|
@@ -35,4 +31,5 @@ export declare class Contact {
|
|
|
35
31
|
creatorId?: string;
|
|
36
32
|
updater?: User;
|
|
37
33
|
updaterId?: string;
|
|
34
|
+
getContactItem(type: ContactField, label?: string): string;
|
|
38
35
|
}
|
|
@@ -4,7 +4,6 @@ exports.Contact = exports.ContactField = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
-
const graphql_scalars_1 = require("graphql-scalars");
|
|
8
7
|
const shell_1 = require("@things-factory/shell");
|
|
9
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
9
|
const contact_item_1 = require("./contact-item");
|
|
@@ -28,6 +27,10 @@ var ContactField;
|
|
|
28
27
|
description: 'field enumeration of a contact'
|
|
29
28
|
});
|
|
30
29
|
let Contact = class Contact {
|
|
30
|
+
getContactItem(type, label) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = (this.items || []).find(item => item.type === type && (!item.label || item.label === label))) === null || _a === void 0 ? void 0 : _a.value;
|
|
33
|
+
}
|
|
31
34
|
};
|
|
32
35
|
exports.Contact = Contact;
|
|
33
36
|
tslib_1.__decorate([
|
|
@@ -54,22 +57,6 @@ tslib_1.__decorate([
|
|
|
54
57
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
55
58
|
tslib_1.__metadata("design:type", String)
|
|
56
59
|
], Contact.prototype, "company", void 0);
|
|
57
|
-
tslib_1.__decorate([
|
|
58
|
-
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { nullable: true }),
|
|
59
|
-
tslib_1.__metadata("design:type", String)
|
|
60
|
-
], Contact.prototype, "email", void 0);
|
|
61
|
-
tslib_1.__decorate([
|
|
62
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
63
|
-
tslib_1.__metadata("design:type", String)
|
|
64
|
-
], Contact.prototype, "phone", void 0);
|
|
65
|
-
tslib_1.__decorate([
|
|
66
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
67
|
-
tslib_1.__metadata("design:type", String)
|
|
68
|
-
], Contact.prototype, "address", void 0);
|
|
69
|
-
tslib_1.__decorate([
|
|
70
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
71
|
-
tslib_1.__metadata("design:type", String)
|
|
72
|
-
], Contact.prototype, "department", void 0);
|
|
73
60
|
tslib_1.__decorate([
|
|
74
61
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
75
62
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact.js","sourceRoot":"","sources":["../../../server/service/contact/contact.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;
|
|
1
|
+
{"version":3,"file":"contact.js","sourceRoot":"","sources":["../../../server/service/contact/contact.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAG3E,iDA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AAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;kBApEP,OAAO;IAHnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;GACrC,OAAO,CAyEnB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { Domain, ScalarObject } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { ContactItem } from './contact-item'\nimport { Profile } from './profile'\n\nexport enum ContactField {\n Name = 'name',\n JobTitle = 'job-title',\n Phone = 'phone',\n Address = 'address',\n Email = 'email',\n Birthday = 'birthday',\n Profile = 'profile',\n Picture = 'picture',\n Department = 'department',\n Company = 'company',\n Homepage = 'homepage'\n}\n\nregisterEnumType(ContactField, {\n name: 'ContactField',\n description: 'field enumeration of a contact'\n})\n\n@Entity()\n@Index('ix_contact_0', (contact: Contact) => [contact.domain, contact.name])\n@ObjectType({ description: 'Entity for Contact' })\nexport class Contact {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((contact: Contact) => contact.domain)\n domainId?: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n company?: string\n\n // @Field(type => GraphQLEmailAddress, { nullable: true })\n // email?: string\n\n // @Field({ nullable: true })\n // phone?: string\n\n // @Field({ nullable: true })\n // address?: string\n\n // @Field({ nullable: true })\n // department?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n @Column('simple-json', { nullable: true })\n @Field(type => Profile, { nullable: true })\n profile: Profile\n\n @Column('simple-json', { nullable: true })\n @Field(type => [ContactItem], { nullable: true })\n items?: ContactItem[]\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((contact: Contact) => contact.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((contact: Contact) => contact.updater)\n updaterId?: string\n\n getContactItem(type: ContactField, label?: string) {\n return (this.items || []).find(item => item.type === type && (!item.label || item.label === label))?.value\n }\n}\n"]}
|