@cofondateurauchomage/libs 1.1.120 → 1.1.123
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 +7 -3
- package/build/api.validate.js +9 -4
- package/build/utils/errorUtils.js +8 -4
- package/package.json +1 -1
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" | "getProfileCompletionRate" | "deleteProject" | "createUser" | "updateUser" | "deleteUser" | "updateVisibility" | "addStripeId" | "updatePlan" | "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 & {
|
|
@@ -7,13 +7,14 @@ export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
|
|
|
7
7
|
emailProspect: string;
|
|
8
8
|
};
|
|
9
9
|
deleteProject: {};
|
|
10
|
-
updateProject: Omit<IProject, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer" | "postedOnLinkedInAt" | "partner_swanbase" | "partner_iii"> & Omit<IContact, "email"
|
|
10
|
+
updateProject: Partial<Omit<IProject, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer" | "postedOnLinkedInAt" | "partner_swanbase" | "partner_iii"> & Omit<IContact, "email">>;
|
|
11
|
+
getProfileCompletionRate: {};
|
|
11
12
|
createUser: Omit<IUser, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer"> & IContact & {
|
|
12
13
|
newsletterMarketing?: boolean;
|
|
13
14
|
emailProspect: string;
|
|
14
15
|
};
|
|
15
16
|
deleteUser: {};
|
|
16
|
-
updateUser: Omit<IUser, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer"> & Omit<IContact, "email"
|
|
17
|
+
updateUser: Partial<Omit<IUser, "id" | "plan" | "visibility" | "clicks" | "creationDate" | "lastConnection" | "stripeId" | "referrer"> & Omit<IContact, "email">>;
|
|
17
18
|
updateVisibility: {
|
|
18
19
|
visibility: TVisibility;
|
|
19
20
|
};
|
|
@@ -73,6 +74,9 @@ export type ResponseForO<O extends CloudFunctionNames | RouteNames> = {
|
|
|
73
74
|
createProject: WriteResult;
|
|
74
75
|
deleteProject: WriteResult;
|
|
75
76
|
updateProject: WriteResult;
|
|
77
|
+
getProfileCompletionRate: {
|
|
78
|
+
completionRate: number;
|
|
79
|
+
};
|
|
76
80
|
createUser: WriteResult;
|
|
77
81
|
deleteUser: WriteResult;
|
|
78
82
|
updateUser: WriteResult;
|
package/build/api.validate.js
CHANGED
|
@@ -88,19 +88,24 @@ const schemasForAllRoutes = {
|
|
|
88
88
|
...contactCreate,
|
|
89
89
|
}),
|
|
90
90
|
deleteProject: zod_1.z.object({}),
|
|
91
|
-
updateProject: zod_1.z
|
|
91
|
+
updateProject: zod_1.z
|
|
92
|
+
.object({
|
|
92
93
|
...projectBody,
|
|
93
94
|
...contactUpdate,
|
|
94
|
-
})
|
|
95
|
+
})
|
|
96
|
+
.partial(),
|
|
97
|
+
getProfileCompletionRate: zod_1.z.object({}),
|
|
95
98
|
createUser: zod_1.z.object({
|
|
96
99
|
...userBody,
|
|
97
100
|
...contactCreate,
|
|
98
101
|
}),
|
|
99
102
|
deleteUser: zod_1.z.object({}),
|
|
100
|
-
updateUser: zod_1.z
|
|
103
|
+
updateUser: zod_1.z
|
|
104
|
+
.object({
|
|
101
105
|
...userBody,
|
|
102
106
|
...contactUpdate,
|
|
103
|
-
})
|
|
107
|
+
})
|
|
108
|
+
.partial(),
|
|
104
109
|
updateVisibility: zod_1.z.object({
|
|
105
110
|
visibility: zVisibility,
|
|
106
111
|
}),
|
|
@@ -15,7 +15,9 @@ function asRecord(value) {
|
|
|
15
15
|
* Construit les objets candidats à inspecter pour retrouver code/message :
|
|
16
16
|
* - error
|
|
17
17
|
* - error[dataInKeys]
|
|
18
|
+
* - error[codeKeys]
|
|
18
19
|
* - error[dataInKeys][dataInKeys]
|
|
20
|
+
* - error[dataInKeys][codeKeys]
|
|
19
21
|
*/
|
|
20
22
|
function getErrorCandidates(e) {
|
|
21
23
|
const root = asRecord(e);
|
|
@@ -23,15 +25,17 @@ function getErrorCandidates(e) {
|
|
|
23
25
|
return [];
|
|
24
26
|
}
|
|
25
27
|
const directData = (0, arrayUtils_1.compact)(dataInKeys.map(key => asRecord(root[key])));
|
|
28
|
+
const directCode = (0, arrayUtils_1.compact)(codeKeys.map(key => asRecord(root[key])));
|
|
26
29
|
const nestedData = directData.flatMap(data => (0, arrayUtils_1.compact)(dataInKeys.map(key => asRecord(data[key]))));
|
|
27
|
-
|
|
30
|
+
const nestedCode = directData.flatMap(data => (0, arrayUtils_1.compact)(codeKeys.map(key => asRecord(data[key]))));
|
|
31
|
+
return [root, ...directData, ...directCode, ...nestedData, ...nestedCode];
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Helper pour récupérer le code number d'une erreur
|
|
31
35
|
*/
|
|
32
36
|
function errCode(e) {
|
|
33
37
|
const candidates = getErrorCandidates(e);
|
|
34
|
-
const code = candidates?.flatMap(candidate => codeKeys.map(key => candidate[key])).find(value => typeof value === "number");
|
|
38
|
+
const code = candidates?.flatMap(candidate => [candidate, ...codeKeys.map(key => candidate[key])]).find(value => typeof value === "number");
|
|
35
39
|
return code ?? 500;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
@@ -39,7 +43,7 @@ function errCode(e) {
|
|
|
39
43
|
*/
|
|
40
44
|
function errStringCode(e) {
|
|
41
45
|
const candidates = getErrorCandidates(e);
|
|
42
|
-
const code = candidates?.flatMap(candidate => codeKeys.map(key => candidate[key])).find(value => typeof value === "string");
|
|
46
|
+
const code = candidates?.flatMap(candidate => [candidate, ...codeKeys.map(key => candidate[key])]).find(value => typeof value === "string");
|
|
43
47
|
return code;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
@@ -47,6 +51,6 @@ function errStringCode(e) {
|
|
|
47
51
|
*/
|
|
48
52
|
function errMessage(e) {
|
|
49
53
|
const candidates = getErrorCandidates(e);
|
|
50
|
-
const stringErr = candidates?.flatMap(candidate => messageKeys.map(key => candidate[key])).find(value => typeof value === "string");
|
|
54
|
+
const stringErr = candidates?.flatMap(candidate => [candidate, ...messageKeys.map(key => candidate[key])]).find(value => typeof value === "string");
|
|
51
55
|
return stringErr ?? JSON.stringify(e).trim().slice(0, 100);
|
|
52
56
|
}
|