@things-factory/contact 10.1.254 → 10.1.256
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-server/service/contact/contacts-by-email.d.ts +8 -0
- package/dist-server/service/contact/contacts-by-email.js +21 -0
- package/dist-server/service/contact/contacts-by-email.js.map +1 -0
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { Contact } from './contact';
|
|
3
|
+
/** The addresses of a contact, lower-cased. */
|
|
4
|
+
export declare const emailsOf: (contact: Pick<Contact, "items">) => string[];
|
|
5
|
+
/** The domain's contacts reached at any of the addresses. */
|
|
6
|
+
export declare function contactsByEmail(tx: EntityManager, domain: {
|
|
7
|
+
id: string;
|
|
8
|
+
}, addresses: readonly string[]): Promise<Contact[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emailsOf = void 0;
|
|
4
|
+
exports.contactsByEmail = contactsByEmail;
|
|
5
|
+
const contact_1 = require("./contact");
|
|
6
|
+
/*
|
|
7
|
+
* The contacts reached at some email addresses - a contact's addresses are its email items, so another module that
|
|
8
|
+
* knows only an address (a mail's sender, its recipients) finds the people and their counterparties here.
|
|
9
|
+
*/
|
|
10
|
+
/** The addresses of a contact, lower-cased. */
|
|
11
|
+
const emailsOf = (contact) => (contact.items ?? []).filter(item => item.type === contact_1.ContactField.Email && item.value).map(item => String(item.value).trim().toLowerCase());
|
|
12
|
+
exports.emailsOf = emailsOf;
|
|
13
|
+
/** The domain's contacts reached at any of the addresses. */
|
|
14
|
+
async function contactsByEmail(tx, domain, addresses) {
|
|
15
|
+
const wanted = new Set(addresses.map(one => String(one ?? '').trim().toLowerCase()).filter(Boolean));
|
|
16
|
+
if (!wanted.size)
|
|
17
|
+
return [];
|
|
18
|
+
const contacts = await tx.getRepository(contact_1.Contact).find({ where: { domain: { id: domain.id } } });
|
|
19
|
+
return contacts.filter(contact => (0, exports.emailsOf)(contact).some(address => wanted.has(address)));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=contacts-by-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts-by-email.js","sourceRoot":"","sources":["../../../server/service/contact/contacts-by-email.ts"],"names":[],"mappings":";;;AAcA,0CAKC;AAjBD,uCAAiD;AAEjD;;;GAGG;AAEH,+CAA+C;AACxC,MAAM,QAAQ,GAAG,CAAC,OAA+B,EAAE,EAAE,CAC1D,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAY,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;AAD9H,QAAA,QAAQ,YACsH;AAE3I,6DAA6D;AACtD,KAAK,UAAU,eAAe,CAAC,EAAiB,EAAE,MAAsB,EAAE,SAA4B;IAC3G,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IACpG,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IAC3B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,iBAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAS,EAAE,CAAC,CAAA;IACtG,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAA,gBAAQ,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { Contact, ContactField } from './contact'\n\n/*\n * The contacts reached at some email addresses - a contact's addresses are its email items, so another module that\n * knows only an address (a mail's sender, its recipients) finds the people and their counterparties here.\n */\n\n/** The addresses of a contact, lower-cased. */\nexport const emailsOf = (contact: Pick<Contact, 'items'>) =>\n (contact.items ?? []).filter(item => item.type === ContactField.Email && item.value).map(item => String(item.value).trim().toLowerCase())\n\n/** The domain's contacts reached at any of the addresses. */\nexport async function contactsByEmail(tx: EntityManager, domain: { id: string }, addresses: readonly string[]): Promise<Contact[]> {\n const wanted = new Set(addresses.map(one => String(one ?? '').trim().toLowerCase()).filter(Boolean))\n if (!wanted.size) return []\n const contacts = await tx.getRepository(Contact).find({ where: { domain: { id: domain.id } } as any })\n return contacts.filter(contact => emailsOf(contact).some(address => wanted.has(address)))\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './contact/profile';
|
|
2
2
|
export * from './contact/contact-item';
|
|
3
3
|
export * from './contact/contact';
|
|
4
|
+
export * from './contact/contacts-by-email';
|
|
4
5
|
export declare const entities: (typeof import("./contact/profile").Profile | typeof import("./contact/contact").Contact)[];
|
|
5
6
|
export declare const subscribers: any[];
|
|
6
7
|
export declare const schema: {
|
|
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
tslib_1.__exportStar(require("./contact/profile"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./contact/contact-item"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./contact/contact"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./contact/contacts-by-email"), exports);
|
|
9
10
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
10
11
|
const contact_1 = require("./contact");
|
|
11
12
|
exports.entities = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,4DAAiC;AACjC,iEAAsC;AACtC,4DAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,4DAAiC;AACjC,iEAAsC;AACtC,4DAAiC;AACjC,sEAA2C;AAE3C,mCAAmC;AACnC,uCAAsF;AAEzE,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,kBAAe;CACnB,CAAA;AAEY,QAAA,WAAW,GAAG;AACzB,iBAAiB;CAClB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,mBAAgB;KACpB;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './contact/profile'\nexport * from './contact/contact-item'\nexport * from './contact/contact'\nexport * from './contact/contacts-by-email'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as ContactEntities, resolvers as ContactResolvers } from './contact'\n\nexport const entities = [\n /* ENTITIES */\n ...ContactEntities\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...ContactResolvers\n ]\n}\n"]}
|