@cofondateurauchomage/libs 1.0.47 → 1.0.49
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 +5 -5
- package/build/api.validate.d.ts +1 -1
- package/build/api.validate.js +10 -10
- package/build/const.d.ts +1 -0
- package/build/const.js +2 -1
- package/build/validate.d.ts +2 -3
- package/build/validate.js +4 -4
- package/package.json +1 -1
package/build/api.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IProject, IUser } from "./db.model";
|
|
2
|
-
export type CloudFunctionNames = "createProjectCall" | "
|
|
2
|
+
export type CloudFunctionNames = "createProjectCall" | "updateProjectCall" | "deleteProjectCall" | "updateProjectStripeIdCall" | "updateProjectActiveCall" | "createUserCall" | "updateUserCall" | "deleteUserCall";
|
|
3
3
|
export type RouteNames = "checkout_session" | "delete_customer" | "portal_session" | "webhook";
|
|
4
4
|
export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
|
|
5
5
|
createProjectCall: Omit<IProject, "active" | "clicks" | "creationDate" | "likes" | "stripeId">;
|
|
6
|
-
setProjectCall: Pick<IProject, "city" | "description" | "invest" | "linkedin" | "partner" | "skills" | "tel" | "zipCode">;
|
|
7
6
|
deleteProjectCall: {};
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
updateProjectCall: Pick<IProject, "city" | "description" | "invest" | "linkedin" | "partner" | "skills" | "tel" | "zipCode">;
|
|
8
|
+
updateProjectStripeIdCall: Pick<IProject, "email" | "stripeId">;
|
|
9
|
+
updateProjectActiveCall: Pick<IProject, "stripeId" | "active">;
|
|
10
10
|
createUserCall: Omit<IUser, "clicks" | "creationDate" | "likes">;
|
|
11
|
-
setUserCall: Pick<IUser, "business" | "city" | "invest" | "linkedin" | "motivations" | "partner" | "skills" | "tel" | "zipCode">;
|
|
12
11
|
deleteUserCall: {};
|
|
12
|
+
updateUserCall: Pick<IUser, "business" | "city" | "invest" | "linkedin" | "motivations" | "partner" | "skills" | "tel" | "zipCode">;
|
|
13
13
|
checkout_session: {
|
|
14
14
|
stripeId?: string;
|
|
15
15
|
email: string;
|
package/build/api.validate.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { BodyForO, CloudFunctionNames, RouteNames } from "./api";
|
|
|
5
5
|
* @param body - Body to validate.
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function validateBodyForO<O extends CloudFunctionNames | RouteNames>(route: O, body: unknown): BodyForO<O>;
|
package/build/api.validate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateBodyForO = void 0;
|
|
4
4
|
const const_1 = require("./const");
|
|
5
5
|
const regex_1 = require("./regex");
|
|
6
6
|
const validate_1 = require("./validate");
|
|
@@ -44,7 +44,8 @@ const validatorsForAllRoutes = {
|
|
|
44
44
|
tel,
|
|
45
45
|
zipCode,
|
|
46
46
|
},
|
|
47
|
-
|
|
47
|
+
deleteProjectCall: {},
|
|
48
|
+
updateProjectCall: {
|
|
48
49
|
city,
|
|
49
50
|
description,
|
|
50
51
|
invest,
|
|
@@ -54,12 +55,11 @@ const validatorsForAllRoutes = {
|
|
|
54
55
|
tel,
|
|
55
56
|
zipCode,
|
|
56
57
|
},
|
|
57
|
-
|
|
58
|
-
setStripeIdProjectCall: {
|
|
58
|
+
updateProjectStripeIdCall: {
|
|
59
59
|
email,
|
|
60
60
|
stripeId,
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
updateProjectActiveCall: {
|
|
63
63
|
active: (0, validate_1.isBoolean)(),
|
|
64
64
|
stripeId,
|
|
65
65
|
},
|
|
@@ -78,7 +78,8 @@ const validatorsForAllRoutes = {
|
|
|
78
78
|
tel,
|
|
79
79
|
zipCode,
|
|
80
80
|
},
|
|
81
|
-
|
|
81
|
+
deleteUserCall: {},
|
|
82
|
+
updateUserCall: {
|
|
82
83
|
business,
|
|
83
84
|
city,
|
|
84
85
|
invest,
|
|
@@ -89,7 +90,6 @@ const validatorsForAllRoutes = {
|
|
|
89
90
|
tel,
|
|
90
91
|
zipCode,
|
|
91
92
|
},
|
|
92
|
-
deleteUserCall: {},
|
|
93
93
|
//////////
|
|
94
94
|
// Routes
|
|
95
95
|
checkout_session: {
|
|
@@ -110,7 +110,7 @@ const validatorsForAllRoutes = {
|
|
|
110
110
|
* @param body - Body to validate.
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
|
-
function
|
|
114
|
-
return (0, validate_1.
|
|
113
|
+
function validateBodyForO(route, body) {
|
|
114
|
+
return (0, validate_1.validateBody)(body, validatorsForAllRoutes[route]);
|
|
115
115
|
}
|
|
116
|
-
exports.
|
|
116
|
+
exports.validateBodyForO = validateBodyForO;
|
package/build/const.d.ts
CHANGED
package/build/const.js
CHANGED
package/build/validate.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BodyForO, CloudFunctionNames, RouteNames } from "./api";
|
|
2
1
|
export type ValidatorFn = (value: unknown) => boolean;
|
|
3
2
|
/**
|
|
4
3
|
* Class representing a custom validator.
|
|
@@ -79,7 +78,7 @@ export declare class ValidationError extends Error {
|
|
|
79
78
|
* Validate the request body against the provided validators.
|
|
80
79
|
* @param body - Body to validate.
|
|
81
80
|
* @param validators - validator for each key of the body.
|
|
82
|
-
* @returns {
|
|
81
|
+
* @returns {O} - The validated body.
|
|
83
82
|
* @throws {ValidationError} - Throws a ValidationError exception if validation fails.
|
|
84
83
|
*/
|
|
85
|
-
export declare function
|
|
84
|
+
export declare function validateBody<O extends Record<string, any>>(body: unknown, validators: Record<keyof O, Validator>): O;
|
package/build/validate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateBody = exports.ValidationError = exports.isMatchRegex = exports.isArray = exports.isBoolean = exports.isString = exports.isNumber = exports.Validator = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Class representing a custom validator.
|
|
6
6
|
*/
|
|
@@ -130,10 +130,10 @@ exports.ValidationError = ValidationError;
|
|
|
130
130
|
* Validate the request body against the provided validators.
|
|
131
131
|
* @param body - Body to validate.
|
|
132
132
|
* @param validators - validator for each key of the body.
|
|
133
|
-
* @returns {
|
|
133
|
+
* @returns {O} - The validated body.
|
|
134
134
|
* @throws {ValidationError} - Throws a ValidationError exception if validation fails.
|
|
135
135
|
*/
|
|
136
|
-
function
|
|
136
|
+
function validateBody(body, validators) {
|
|
137
137
|
if (typeof body !== "object" || body === null) {
|
|
138
138
|
throw new ValidationError(400, "Body non fourni ou invalide");
|
|
139
139
|
}
|
|
@@ -146,4 +146,4 @@ function validateBodyForO(body, validators) {
|
|
|
146
146
|
}
|
|
147
147
|
return result;
|
|
148
148
|
}
|
|
149
|
-
exports.
|
|
149
|
+
exports.validateBody = validateBody;
|