@cofondateurauchomage/libs 1.1.136 → 1.1.139

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" | "addStatsAssociation" | "updateNewsletter" | "createProspect" | "getProspect" | "updateProspect" | "createReaction" | "deleteReaction" | "createBlogHtmlArticle";
2
+ export type CloudFunctionNames = "createProject" | "updateProject" | "deleteProject" | "createUser" | "updateUser" | "deleteUser" | "updateVisibility" | "addStripeId" | "updatePlan" | "updateMetaStripe" | "addStatsAssociation" | "updateNewsletter" | "createProspect" | "getProspect" | "updateProspect" | "createReaction" | "deleteReaction" | "createBlogHtmlArticle";
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 & {
@@ -28,6 +28,16 @@ export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
28
28
  email: string;
29
29
  plan: TPlan;
30
30
  };
31
+ updateMetaStripe: {
32
+ stripeId: string;
33
+ stripeFirstPaidAt?: number;
34
+ stripeLastPaymentAt?: number;
35
+ stripeSubscriptionEndedAt?: number | null;
36
+ stripeCurrentPeriodEnd?: number | null;
37
+ stripeNetSpendDeltaCents?: number;
38
+ subscriptionCancellationFeedback?: string | null;
39
+ subscriptionCancellationComment?: string | null;
40
+ };
31
41
  addStatsAssociation: {};
32
42
  updateNewsletter: Omit<INewsletter, "new_profil_last_sent_date">;
33
43
  createProspect: Pick<IProspect, "email" | "referrer">;
@@ -79,6 +89,7 @@ export type ResponseForO<O extends CloudFunctionNames | RouteNames> = {
79
89
  updateVisibility: WriteResult;
80
90
  addStripeId: WriteResult;
81
91
  updatePlan: WriteResult;
92
+ updateMetaStripe: WriteResult;
82
93
  addStatsAssociation: WriteResult;
83
94
  updateNewsletter: WriteResult;
84
95
  createProspect: {
@@ -165,6 +165,14 @@ const schemasForAllRoutes = {
165
165
  email: zod_1.z.string(),
166
166
  plan: zod_1.z.enum(["free", "pro", "premium"]),
167
167
  }),
168
+ updateMetaStripe: zod_1.z.object({
169
+ stripeId: zStrMax50,
170
+ stripeFirstPaidAt: zod_1.z.number().optional(),
171
+ stripeLastPaymentAt: zod_1.z.number().optional(),
172
+ stripeSubscriptionEndedAt: zod_1.z.union([zod_1.z.number(), zod_1.z.null()]).optional(),
173
+ stripeCurrentPeriodEnd: zod_1.z.union([zod_1.z.number(), zod_1.z.null()]).optional(),
174
+ stripeNetSpendDeltaCents: zod_1.z.number().int().optional(),
175
+ }),
168
176
  addStatsAssociation: zod_1.z.object({}),
169
177
  updateNewsletter: zod_1.z.object({
170
178
  match: zod_1.z.boolean().optional(),
@@ -260,7 +268,7 @@ function validateBodyForO(route, body) {
260
268
  const input = body;
261
269
  const data = parsed.data;
262
270
  const result = {};
263
- for (const key of Object.keys(schema.shape)) {
271
+ for (const key of Object.keys(data)) {
264
272
  if (input[key] !== undefined) {
265
273
  result[key] = data[key];
266
274
  }
@@ -8,7 +8,8 @@ export declare enum Collections {
8
8
  prospects = "prospects",
9
9
  reactions = "reactions",
10
10
  visits = "visits",
11
- blogHtmlArticles = "blog_html_articles"
11
+ blogHtmlArticles = "blog_html_articles",
12
+ crm_profiles = "crm_profiles"
12
13
  }
13
14
  export type TSkill = "Sales" | "Operation" | "Design" | "Marketing" | "Produit" | "Tech" | "Growth" | "Finance";
14
15
  export type TPlan = "free" | "pro" | "premium";
@@ -82,6 +83,36 @@ export interface IProject {
82
83
  partner_swanbase?: boolean;
83
84
  partner_iii?: boolean;
84
85
  }
86
+ /**
87
+ * CRM-side state: team actions, Stripe sync, billing overlay.
88
+ * Document id = canonicalId: `user:{uid}` | `project:{uid}` | `prospect:{docId}` under collection `crm_profiles`.
89
+ */
90
+ export interface ICrmProfile {
91
+ lastTeamCallAt?: number;
92
+ foundPartner?: boolean;
93
+ /** Stripe infos */
94
+ /** First successful invoice payment tied to subscriptions (unix ms). */
95
+ stripeFirstPaidAt?: number;
96
+ /** Last successful invoice payment (unix ms). */
97
+ stripeLastPaymentAt?: number;
98
+ /** When the subscription last ended/churned (unix ms); cleared when a new subscription starts. */
99
+ stripeSubscriptionEndedAt?: number;
100
+ /** Stripe `current_period_end` for the active subscription (unix ms); cleared when no active sub. */
101
+ stripeCurrentPeriodEnd?: number;
102
+ /** Lifetime net cents (invoice payments − refunds handled via deltas from webhooks). */
103
+ stripeNetSpendCents?: number;
104
+ /** Stripe `cancellation_details.feedback`. */
105
+ subscriptionCancellationFeedback?: string;
106
+ subscriptionCancellationComment?: string;
107
+ /** Team-granted Pro (unix ms); orthogonal to Stripe. */
108
+ complimentaryProGrantedAt?: number;
109
+ complimentaryProRevokedAt?: number;
110
+ }
111
+ export interface ICrmNote {
112
+ text: string;
113
+ createdAt: number;
114
+ author: string;
115
+ }
85
116
  export interface IContact {
86
117
  email: string;
87
118
  linkedin?: string;
package/build/db.model.js CHANGED
@@ -13,4 +13,5 @@ var Collections;
13
13
  Collections["reactions"] = "reactions";
14
14
  Collections["visits"] = "visits";
15
15
  Collections["blogHtmlArticles"] = "blog_html_articles";
16
+ Collections["crm_profiles"] = "crm_profiles";
16
17
  })(Collections || (exports.Collections = Collections = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.1.136",
3
+ "version": "1.1.139",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {