@cofondateurauchomage/libs 1.1.150 → 1.1.152

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.
@@ -111,6 +111,7 @@ type ICrmProjectProfileSnapshot = Omit<IProject, "logo" | "description" | "partn
111
111
  export type TCrmPipelineBucket = "lead" | "inscrit" | "pro" | "ancien_pro";
112
112
  interface ICrmProfileBase {
113
113
  pipelineBucket: TCrmPipelineBucket;
114
+ searchText: string;
114
115
  lastTeamCallAt?: number;
115
116
  foundPartner?: boolean;
116
117
  }
@@ -0,0 +1,8 @@
1
+ import type { IContact, ICrmProfile } from "../db.model";
2
+ /**
3
+ * Rebuilds `crm_profiles.searchText` from denormalized profile (+ contact for user/project).
4
+ * Uses {@link foldSearchText}; apply the same folding to user queries.
5
+ */
6
+ export declare function buildCrmProfileSearchText(doc: Pick<ICrmProfile, "type" | "profile"> & {
7
+ contact?: IContact;
8
+ }): string;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCrmProfileSearchText = buildCrmProfileSearchText;
4
+ const stringUtils_1 = require("./stringUtils");
5
+ function pushPart(parts, value) {
6
+ const t = value?.trim();
7
+ if (t) {
8
+ parts.push(t);
9
+ }
10
+ }
11
+ /**
12
+ * Rebuilds `crm_profiles.searchText` from denormalized profile (+ contact for user/project).
13
+ * Uses {@link foldSearchText}; apply the same folding to user queries.
14
+ */
15
+ function buildCrmProfileSearchText(doc) {
16
+ const parts = [];
17
+ if (doc.type === "prospect") {
18
+ const profile = doc.profile;
19
+ pushPart(parts, profile.email);
20
+ pushPart(parts, profile.firstName);
21
+ pushPart(parts, profile.lastName);
22
+ pushPart(parts, profile.city);
23
+ pushPart(parts, profile.linkedin);
24
+ }
25
+ else if (doc.type === "user") {
26
+ const profile = doc.profile;
27
+ pushPart(parts, profile.firstName);
28
+ pushPart(parts, profile.lastName);
29
+ pushPart(parts, profile.city);
30
+ pushPart(parts, doc.contact?.email);
31
+ pushPart(parts, doc.contact?.linkedin);
32
+ }
33
+ else {
34
+ const profile = doc.profile;
35
+ pushPart(parts, profile.name);
36
+ pushPart(parts, profile.firstName);
37
+ pushPart(parts, profile.lastName);
38
+ pushPart(parts, profile.city);
39
+ pushPart(parts, doc.contact?.email);
40
+ pushPart(parts, doc.contact?.linkedin);
41
+ }
42
+ return (0, stringUtils_1.foldSearchText)(parts.join(" "));
43
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./arrayUtils";
2
+ export * from "./crmSearchText";
2
3
  export * from "./errorUtils";
3
4
  export * from "./objectUtils";
4
5
  export * from "./stringUtils";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./arrayUtils"), exports);
18
+ __exportStar(require("./crmSearchText"), exports);
18
19
  __exportStar(require("./errorUtils"), exports);
19
20
  __exportStar(require("./objectUtils"), exports);
20
21
  __exportStar(require("./stringUtils"), exports);
@@ -1,3 +1,5 @@
1
+ /** Lowercases and removes diacritics (e.g. `Éléonore` → `eleonore`). */
2
+ export declare function foldSearchText(raw: string): string;
1
3
  /**
2
4
  * Capitalize the first letter of each words separated by a space or a hyphen
3
5
  * and prevent double space
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.foldSearchText = foldSearchText;
3
4
  exports.capitalize = capitalize;
5
+ /** Lowercases and removes diacritics (e.g. `Éléonore` → `eleonore`). */
6
+ function foldSearchText(raw) {
7
+ return raw
8
+ .trim()
9
+ .toLowerCase()
10
+ .normalize("NFD")
11
+ .replace(/\p{M}/gu, "");
12
+ }
4
13
  /**
5
14
  * Capitalize the first letter of each words separated by a space or a hyphen
6
15
  * and prevent double space
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.1.150",
3
+ "version": "1.1.152",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {