@cofondateurauchomage/libs 1.1.19 → 1.1.20

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
@@ -7,7 +7,7 @@ export type BodyForO<O extends CloudFunctionNames | RouteNames> = {
7
7
  newsletterMarketing?: boolean;
8
8
  };
9
9
  deleteProject: {};
10
- updateProject: Pick<IProject, "city" | "description" | "invest" | "name" | "partner" | "skills" | "zipCode"> & Omit<IContact, "email">;
10
+ updateProject: Pick<IProject, "city" | "description" | "invest" | "name" | "partner" | "skills" | "zipCode" | "status"> & Omit<IContact, "email">;
11
11
  addStripeIdToProject: {
12
12
  email: string;
13
13
  stripeId: string;
@@ -26,21 +26,23 @@ const stripeId = (0, validate_1.isString)().setMin(4).setMax(50);
26
26
  const zipCode = (0, validate_1.isNumber)().setMin(1000).setMax(97680);
27
27
  const newsletterMatch = (0, validate_1.isBoolean)().isOptional();
28
28
  const newsletterMarketing = (0, validate_1.isBoolean)().isOptional();
29
+ const projectStatus = (0, validate_1.isMatchEnum)(const_1.PROJECT_STATUS).isOptional();
29
30
  const validatorsForAllRoutes = {
30
31
  ///////////////////
31
32
  // Cloud functions
32
33
  createProject: {
33
- city,
34
- description,
35
34
  email,
36
- firstName,
37
- invest,
38
- lastName,
39
35
  linkedin,
40
36
  name,
41
- partner,
37
+ lastName,
38
+ firstName,
39
+ status: projectStatus,
42
40
  skills,
43
41
  zipCode,
42
+ city,
43
+ invest,
44
+ description,
45
+ partner,
44
46
  redstart: (0, validate_1.isBoolean)().isOptional(),
45
47
  level: (0, validate_1.isBoolean)().isOptional(),
46
48
  newsletterMatch,
@@ -48,14 +50,15 @@ const validatorsForAllRoutes = {
48
50
  },
49
51
  deleteProject: {},
50
52
  updateProject: {
51
- city,
52
- description,
53
- invest,
54
53
  linkedin,
55
54
  name,
56
- partner,
55
+ status: projectStatus,
57
56
  skills,
58
57
  zipCode,
58
+ city,
59
+ invest,
60
+ description,
61
+ partner,
59
62
  },
60
63
  addStripeIdToProject: {
61
64
  email,
package/build/const.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { TSkill } from "./db.model";
1
+ import { TProjectStatus, TSkill } from "./db.model";
2
2
  export declare const EMAIL = "contact@cofondateurauchomage.fr";
3
3
  export declare const SKILLS: TSkill[];
4
+ export declare const PROJECT_STATUS: TProjectStatus[];
package/build/const.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SKILLS = exports.EMAIL = void 0;
3
+ exports.PROJECT_STATUS = exports.SKILLS = exports.EMAIL = void 0;
4
4
  exports.EMAIL = "contact@cofondateurauchomage.fr";
5
5
  exports.SKILLS = [
6
6
  "Business",
@@ -9,3 +9,9 @@ exports.SKILLS = [
9
9
  "Produit",
10
10
  "Tech",
11
11
  ];
12
+ exports.PROJECT_STATUS = [
13
+ "idea",
14
+ "creation",
15
+ "launch",
16
+ "growth",
17
+ ];
@@ -14,16 +14,16 @@ export interface IClicks {
14
14
  }
15
15
  export interface IUser {
16
16
  id: string;
17
- business: string;
18
- city: string;
17
+ lastName: string;
19
18
  firstName: string;
19
+ skills: TSkill[];
20
+ zipCode: number;
21
+ city: string;
20
22
  invest?: number;
21
23
  joblessDate: string;
22
- lastName: string;
23
24
  motivations: string;
24
25
  partner: string;
25
- skills: TSkill[];
26
- zipCode: number;
26
+ business: string;
27
27
  active: boolean;
28
28
  clicks: IClicks;
29
29
  creationDate: number;
@@ -32,15 +32,16 @@ export interface IUser {
32
32
  }
33
33
  export interface IProject {
34
34
  id: string;
35
- city: string;
36
- description: string;
37
- firstName: string;
38
- invest?: number;
39
- lastName: string;
40
35
  name: string;
41
- partner: string;
36
+ lastName: string;
37
+ firstName: string;
38
+ status?: TProjectStatus;
42
39
  skills: TSkill[];
43
40
  zipCode: number;
41
+ city: string;
42
+ invest?: number;
43
+ description: string;
44
+ partner: string;
44
45
  active: boolean;
45
46
  clicks: IClicks;
46
47
  creationDate: number;
@@ -50,6 +51,7 @@ export interface IProject {
50
51
  redstart?: boolean;
51
52
  level?: boolean;
52
53
  }
54
+ export type TProjectStatus = "idea" | "creation" | "launch" | "growth";
53
55
  export interface IContact {
54
56
  email: string;
55
57
  linkedin?: string;
package/build/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * from "./api.validate";
3
3
  export * from "./const";
4
4
  export * from "./db.model";
5
5
  export * from "./regex";
6
+ export * from "./utils/arrayUtils";
6
7
  export * from "./validate";
package/build/index.js CHANGED
@@ -19,4 +19,5 @@ __exportStar(require("./api.validate"), exports);
19
19
  __exportStar(require("./const"), exports);
20
20
  __exportStar(require("./db.model"), exports);
21
21
  __exportStar(require("./regex"), exports);
22
+ __exportStar(require("./utils/arrayUtils"), exports);
22
23
  __exportStar(require("./validate"), exports);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Includes typé
3
+ */
4
+ export declare function includes<T extends string>(array: T[], value: string): value is T;
5
+ /**
6
+ * Retourne un array sans valeurs null ou undefined
7
+ */
8
+ export declare const compact: <T>(array: (T | null | undefined)[]) => T[];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compact = exports.includes = void 0;
4
+ /**
5
+ * Includes typé
6
+ */
7
+ function includes(array, value) {
8
+ return array.includes(value);
9
+ }
10
+ exports.includes = includes;
11
+ /**
12
+ * Retourne un array sans valeurs null ou undefined
13
+ */
14
+ const compact = (array) => array.filter(Boolean);
15
+ exports.compact = compact;
@@ -3,7 +3,7 @@ export type ValidatorFn = (value: unknown) => boolean;
3
3
  * Class representing a custom validator.
4
4
  */
5
5
  export declare class Validator {
6
- private fn;
6
+ private readonly fn;
7
7
  /**
8
8
  * Flag indicating if the field is required.
9
9
  * @private
@@ -62,6 +62,11 @@ export declare const isArray: () => Validator;
62
62
  * @returns
63
63
  */
64
64
  export declare const isMatchRegex: (pattern: RegExp) => Validator;
65
+ /**
66
+ * Create a new validator for enum.
67
+ * @param values - The enum values.
68
+ */
69
+ export declare const isMatchEnum: <T extends string>(values: T[]) => Validator;
65
70
  /**
66
71
  * Custom error class to handle validation errors.
67
72
  */
package/build/validate.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
+ //////////////
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateBody = exports.ValidationError = exports.isMatchRegex = exports.isArray = exports.isBoolean = exports.isString = exports.isNumber = exports.Validator = void 0;
4
+ exports.validateBody = exports.ValidationError = exports.isMatchEnum = exports.isMatchRegex = exports.isArray = exports.isBoolean = exports.isString = exports.isNumber = exports.Validator = void 0;
5
+ const arrayUtils_1 = require("./utils/arrayUtils");
4
6
  /**
5
7
  * Class representing a custom validator.
6
8
  */
@@ -108,6 +110,12 @@ exports.isArray = isArray;
108
110
  */
109
111
  const isMatchRegex = (pattern) => new Validator((value) => typeof value === "string" && pattern.test(value));
110
112
  exports.isMatchRegex = isMatchRegex;
113
+ /**
114
+ * Create a new validator for enum.
115
+ * @param values - The enum values.
116
+ */
117
+ const isMatchEnum = (values) => new Validator((value) => typeof value === "string" && (0, arrayUtils_1.includes)(values, value));
118
+ exports.isMatchEnum = isMatchEnum;
111
119
  /////////////
112
120
  // Validate
113
121
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofondateurauchomage/libs",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "",
5
5
  "main": "build/index",
6
6
  "scripts": {