@cofondateurauchomage/libs 1.1.165 → 1.1.169

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/build/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IBlogHtmlArticle, IContact, INewsletter, IProject, IProspect, IReactionStatus, IUser, TPlan, TPlanOption, TVisibility } from "./db.model";
2
- export type CloudFunctionNames = "createProject" | "updateProject" | "deleteProject" | "createUser" | "updateUser" | "deleteUser" | "updateVisibility" | "addStripeId" | "updatePlan" | "updateMetaStripe" | "addStatsAssociation" | "updateNewsletter" | "createProspect" | "getProspect" | "updateProspect" | "createReaction" | "deleteReaction" | "createBlogHtmlArticle" | "syncCrmProfiles";
2
+ export type CloudFunctionNames = "createProject" | "updateProject" | "deleteProject" | "createUser" | "updateUser" | "deleteUser" | "updateVisibility" | "addStripeId" | "updatePlan" | "updateMetaStripe" | "addStatsAssociation" | "updateNewsletter" | "createProspect" | "getProspect" | "updateProspect" | "createReaction" | "deleteReaction" | "createBlogHtmlArticle" | "syncCrmProfiles" | "migrateCrmNotes";
3
3
  export type RouteNames = "checkout_session" | "delete_customer" | "portal_session" | "webhook";
4
4
  export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
5
5
  createProject: Omit<IProject, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer" | "postedOnLinkedInAt"> & IContact & {
@@ -58,6 +58,8 @@ export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
58
58
  };
59
59
  /** Admin-only: rebuild all `crm_profiles` from source collections. */
60
60
  syncCrmProfiles: Record<string, never>;
61
+ /** Admin-only: lift `notes` subcollections onto parent `crm_profiles` docs. */
62
+ migrateCrmNotes: Record<string, never>;
61
63
  checkout_session: {
62
64
  customer: {
63
65
  email: string;
@@ -112,6 +114,12 @@ export type ResponseForO<O extends CloudFunctionNames | RouteNames> = {
112
114
  synced: number;
113
115
  failed: number;
114
116
  };
117
+ migrateCrmNotes: {
118
+ migrated: number;
119
+ skipped: number;
120
+ deletedSubdocs: number;
121
+ failed: number;
122
+ };
115
123
  checkout_session: {
116
124
  sessionId: string;
117
125
  };
@@ -237,6 +237,7 @@ const schemasForAllRoutes = {
237
237
  toc: zod_1.z.string().optional(),
238
238
  }),
239
239
  syncCrmProfiles: zod_1.z.object({}),
240
+ migrateCrmNotes: zod_1.z.object({}),
240
241
  checkout_session: zod_1.z.object({
241
242
  customer: zod_1.z.object({
242
243
  email: zod_1.z.string(),
@@ -0,0 +1,2 @@
1
+ export * from "./notes";
2
+ export * from "./searchText";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./notes"), exports);
18
+ __exportStar(require("./searchText"), exports);
@@ -0,0 +1,5 @@
1
+ import type { ICrmNote } from "../db.model";
2
+ export declare const MAX_CRM_NOTES = 20;
3
+ export declare function hasCrmNotes(notes: ICrmNote[] | undefined): boolean;
4
+ export declare function sortCrmNotesDesc(notes: ICrmNote[]): ICrmNote[];
5
+ export declare function appendCrmNote(existing: ICrmNote[] | undefined, note: ICrmNote): ICrmNote[];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_CRM_NOTES = void 0;
4
+ exports.hasCrmNotes = hasCrmNotes;
5
+ exports.sortCrmNotesDesc = sortCrmNotesDesc;
6
+ exports.appendCrmNote = appendCrmNote;
7
+ exports.MAX_CRM_NOTES = 20;
8
+ function hasCrmNotes(notes) {
9
+ return (notes?.length ?? 0) > 0;
10
+ }
11
+ function sortCrmNotesDesc(notes) {
12
+ return [...notes].sort((a, b) => (b.createdAt ?? 0) - (a.createdAt ?? 0));
13
+ }
14
+ function appendCrmNote(existing, note) {
15
+ return sortCrmNotesDesc([note, ...(existing ?? [])]).slice(0, exports.MAX_CRM_NOTES);
16
+ }
@@ -0,0 +1,5 @@
1
+ import type { IContact, ICrmNote, ICrmProfile } from "../db.model";
2
+ export declare function buildCrmProfileSearchText(doc: Pick<ICrmProfile, "type" | "profile"> & {
3
+ contact?: IContact;
4
+ notes?: ICrmNote[];
5
+ }): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCrmProfileSearchText = buildCrmProfileSearchText;
4
+ const stringUtils_1 = require("../utils/stringUtils");
5
+ function pushPart(parts, value) {
6
+ const t = value?.trim();
7
+ if (t) {
8
+ parts.push(t);
9
+ }
10
+ }
11
+ function buildCrmProfileSearchText(doc) {
12
+ const parts = [];
13
+ if (doc.type === "prospect") {
14
+ const profile = doc.profile;
15
+ pushPart(parts, profile.email);
16
+ pushPart(parts, profile.firstName);
17
+ pushPart(parts, profile.lastName);
18
+ pushPart(parts, profile.city);
19
+ pushPart(parts, profile.linkedin);
20
+ }
21
+ else if (doc.type === "user") {
22
+ const profile = doc.profile;
23
+ pushPart(parts, profile.firstName);
24
+ pushPart(parts, profile.lastName);
25
+ pushPart(parts, profile.city);
26
+ pushPart(parts, doc.contact?.email);
27
+ pushPart(parts, doc.contact?.linkedin);
28
+ }
29
+ else {
30
+ const profile = doc.profile;
31
+ pushPart(parts, profile.name);
32
+ pushPart(parts, profile.firstName);
33
+ pushPart(parts, profile.lastName);
34
+ pushPart(parts, profile.city);
35
+ pushPart(parts, doc.contact?.email);
36
+ pushPart(parts, doc.contact?.linkedin);
37
+ }
38
+ for (const note of doc.notes ?? []) {
39
+ pushPart(parts, note.text);
40
+ }
41
+ return (0, stringUtils_1.foldSearchText)(parts.join(" "));
42
+ }
@@ -9,7 +9,9 @@ export declare enum Collections {
9
9
  reactions = "reactions",
10
10
  visits = "visits",
11
11
  blogHtmlArticles = "blog_html_articles",
12
- crm_profiles = "crm_profiles"
12
+ crm_profiles = "crm_profiles",
13
+ admins = "admins",
14
+ crm_team_call_events = "crm_team_call_events"
13
15
  }
14
16
  export type TSkill = "Sales" | "Operation" | "Design" | "Marketing" | "Produit" | "Tech" | "Growth" | "Finance";
15
17
  export type TPlan = "free" | "pro" | "premium";
@@ -121,6 +123,8 @@ interface ICrmProfileBase {
121
123
  hasStripe: boolean;
122
124
  hasTel: boolean;
123
125
  hasLinkedin: boolean;
126
+ hasNotes: boolean;
127
+ notes?: ICrmNote[];
124
128
  }
125
129
  export interface ICrmProfileProspect extends ICrmProfileBase {
126
130
  type: "prospect";
@@ -152,6 +156,18 @@ export interface ICrmNote {
152
156
  createdAt: number;
153
157
  author: string;
154
158
  }
159
+ /** CRM operator identity (document id = Firebase Auth uid). */
160
+ export interface IAdmin {
161
+ uid: string;
162
+ displayName: string;
163
+ email: string;
164
+ }
165
+ /** One logged team call (append-only; filter by `createdAt` for date ranges). */
166
+ export interface ICrmTeamCallEvent {
167
+ uid: string;
168
+ crmId: string;
169
+ createdAt: number;
170
+ }
155
171
  export interface IContact {
156
172
  email: string;
157
173
  linkedin?: string;
package/build/db.model.js CHANGED
@@ -14,4 +14,6 @@ var Collections;
14
14
  Collections["visits"] = "visits";
15
15
  Collections["blogHtmlArticles"] = "blog_html_articles";
16
16
  Collections["crm_profiles"] = "crm_profiles";
17
+ Collections["admins"] = "admins";
18
+ Collections["crm_team_call_events"] = "crm_team_call_events";
17
19
  })(Collections || (exports.Collections = Collections = {}));
package/build/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./api";
2
2
  export * from "./api.validate";
3
3
  export * from "./const";
4
+ export * from "./crm";
4
5
  export * from "./db.model";
5
6
  export * from "./regex";
6
7
  export * from "./utils";
package/build/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api"), exports);
18
18
  __exportStar(require("./api.validate"), exports);
19
19
  __exportStar(require("./const"), exports);
20
+ __exportStar(require("./crm"), exports);
20
21
  __exportStar(require("./db.model"), exports);
21
22
  __exportStar(require("./regex"), exports);
22
23
  __exportStar(require("./utils"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.1.165",
3
+ "version": "1.1.169",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {