@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 CHANGED
@@ -1,15 +1,15 @@
1
1
  import { IProject, IUser } from "./db.model";
2
- export type CloudFunctionNames = "createProjectCall" | "setProjectCall" | "deleteProjectCall" | "setStripeIdProjectCall" | "setActiveProjectCall" | "createUserCall" | "setUserCall" | "deleteUserCall";
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
- setStripeIdProjectCall: Pick<IProject, "email" | "stripeId">;
9
- setActiveProjectCall: Pick<IProject, "stripeId" | "active">;
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;
@@ -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 validateBody<O extends CloudFunctionNames | RouteNames>(route: O, body: unknown): BodyForO<O>;
8
+ export declare function validateBodyForO<O extends CloudFunctionNames | RouteNames>(route: O, body: unknown): BodyForO<O>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateBody = void 0;
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
- setProjectCall: {
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
- deleteProjectCall: {},
58
- setStripeIdProjectCall: {
58
+ updateProjectStripeIdCall: {
59
59
  email,
60
60
  stripeId,
61
61
  },
62
- setActiveProjectCall: {
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
- setUserCall: {
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 validateBody(route, body) {
114
- return (0, validate_1.validateBodyForO)(body, validatorsForAllRoutes[route]);
113
+ function validateBodyForO(route, body) {
114
+ return (0, validate_1.validateBody)(body, validatorsForAllRoutes[route]);
115
115
  }
116
- exports.validateBody = validateBody;
116
+ exports.validateBodyForO = validateBodyForO;
package/build/const.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { TSkill } from "./db.model";
2
+ export declare const EMAIL = "contact@cofondateurauchomage.fr";
2
3
  export declare const SKILLS: TSkill[];
package/build/const.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SKILLS = void 0;
3
+ exports.SKILLS = exports.EMAIL = void 0;
4
+ exports.EMAIL = "contact@cofondateurauchomage.fr";
4
5
  exports.SKILLS = [
5
6
  "Business",
6
7
  "Design",
@@ -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 {BodyForO<O>} - The validated body.
81
+ * @returns {O} - The validated body.
83
82
  * @throws {ValidationError} - Throws a ValidationError exception if validation fails.
84
83
  */
85
- export declare function validateBodyForO<O extends CloudFunctionNames | RouteNames>(body: unknown, validators: Record<keyof BodyForO<O>, Validator>): BodyForO<O>;
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.validateBodyForO = exports.ValidationError = exports.isMatchRegex = exports.isArray = exports.isBoolean = exports.isString = exports.isNumber = exports.Validator = void 0;
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 {BodyForO<O>} - The validated body.
133
+ * @returns {O} - The validated body.
134
134
  * @throws {ValidationError} - Throws a ValidationError exception if validation fails.
135
135
  */
136
- function validateBodyForO(body, validators) {
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.validateBodyForO = validateBodyForO;
149
+ exports.validateBody = validateBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {