@thejob/util 1.0.24 → 1.0.25
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/dist/cjs/completeness/completeness.d.ts +8 -1
- package/dist/cjs/completeness/completeness.d.ts.map +1 -1
- package/dist/cjs/completeness/completeness.js +101 -116
- package/dist/esm/completeness/completeness.d.ts +8 -1
- package/dist/esm/completeness/completeness.d.ts.map +1 -1
- package/dist/esm/completeness/completeness.js +100 -117
- package/package.json +2 -2
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { TCompletenessScoreSchema, TUserCompletenessSchema, TUserSchema } from "@thejob/schema";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the profile completeness score for a given user object.
|
|
4
|
+
* Pure function — no database calls required.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the section weights used in UsersService.getCompleteness().
|
|
7
|
+
*/
|
|
8
|
+
export declare function calculateProfileCompleteness(user: Partial<TUserSchema>): Record<keyof TUserCompletenessSchema, TCompletenessScoreSchema>;
|
|
2
9
|
//# sourceMappingURL=completeness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completeness.d.ts","sourceRoot":"","sources":["../../../src/completeness/completeness.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"completeness.d.ts","sourceRoot":"","sources":["../../../src/completeness/completeness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAGxB;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,MAAM,CAAC,MAAM,uBAAuB,EAAE,wBAAwB,CAAC,CA6GjE"}
|
|
@@ -1,119 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
3
|
+
exports.calculateProfileCompleteness = calculateProfileCompleteness;
|
|
4
|
+
const schema_1 = require("@thejob/schema");
|
|
5
|
+
const utils_1 = require("../common/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the profile completeness score for a given user object.
|
|
8
|
+
* Pure function — no database calls required.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors the section weights used in UsersService.getCompleteness().
|
|
11
|
+
*/
|
|
12
|
+
function calculateProfileCompleteness(user) {
|
|
13
|
+
const { educations, workExperiences, projects, skills, languages, interests, certifications, socialAccounts, additionalInfo, } = user;
|
|
14
|
+
// General (7 steps: name, headline, aboutMe, email, mobile, location, image)
|
|
15
|
+
const generalTotalSteps = 7;
|
|
16
|
+
const generalCompletedSteps = [
|
|
17
|
+
!!user.name,
|
|
18
|
+
!!user.headline,
|
|
19
|
+
!!user.aboutMe,
|
|
20
|
+
!!user.email,
|
|
21
|
+
!!user.mobile,
|
|
22
|
+
!!user.location,
|
|
23
|
+
!!user.image,
|
|
24
|
+
].filter(Boolean).length;
|
|
25
|
+
// Sections with 1 step each (has at least one item)
|
|
26
|
+
const workExperiencesCompleted = workExperiences?.length ? 1 : 0;
|
|
27
|
+
const educationsCompleted = educations?.length ? 1 : 0;
|
|
28
|
+
const projectsCompleted = projects?.length ? 1 : 0;
|
|
29
|
+
const skillsCompleted = skills?.length ? 1 : 0;
|
|
30
|
+
const languagesCompleted = languages?.length ? 1 : 0;
|
|
31
|
+
const interestsCompleted = interests?.length ? 1 : 0;
|
|
32
|
+
const certificationsCompleted = certifications?.length ? 1 : 0;
|
|
33
|
+
const socialAccountsCompleted = socialAccounts?.length ? 1 : 0;
|
|
34
|
+
const additionalInfoCompleted = additionalInfo?.length ? 1 : 0;
|
|
35
|
+
// Overview total excludes additionalInfo (matches original service logic)
|
|
36
|
+
const totalSteps = generalTotalSteps + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; // 15
|
|
37
|
+
const completedSteps = generalCompletedSteps +
|
|
38
|
+
workExperiencesCompleted +
|
|
39
|
+
educationsCompleted +
|
|
40
|
+
projectsCompleted +
|
|
41
|
+
skillsCompleted +
|
|
42
|
+
languagesCompleted +
|
|
43
|
+
interestsCompleted +
|
|
44
|
+
certificationsCompleted +
|
|
45
|
+
socialAccountsCompleted;
|
|
46
|
+
const score = (completedSteps / totalSteps) * 100;
|
|
47
|
+
return {
|
|
48
|
+
[schema_1.UserDetailType.Overview]: {
|
|
49
|
+
score: (0, utils_1.toPositiveWholeNumber)(score),
|
|
50
|
+
completedSteps,
|
|
51
|
+
totalSteps,
|
|
52
|
+
},
|
|
53
|
+
[schema_1.UserDetailType.General]: {
|
|
54
|
+
score: (0, utils_1.toPositiveWholeNumber)((generalCompletedSteps / generalTotalSteps) * 100),
|
|
55
|
+
completedSteps: generalCompletedSteps,
|
|
56
|
+
totalSteps: generalTotalSteps,
|
|
57
|
+
},
|
|
58
|
+
[schema_1.UserDetailType.WorkExperiences]: {
|
|
59
|
+
score: (0, utils_1.toPositiveWholeNumber)(workExperiencesCompleted * 100),
|
|
60
|
+
completedSteps: workExperiencesCompleted,
|
|
61
|
+
totalSteps: 1,
|
|
62
|
+
},
|
|
63
|
+
[schema_1.UserDetailType.Educations]: {
|
|
64
|
+
score: (0, utils_1.toPositiveWholeNumber)(educationsCompleted * 100),
|
|
65
|
+
completedSteps: educationsCompleted,
|
|
66
|
+
totalSteps: 1,
|
|
67
|
+
},
|
|
68
|
+
[schema_1.UserDetailType.Projects]: {
|
|
69
|
+
score: (0, utils_1.toPositiveWholeNumber)(projectsCompleted * 100),
|
|
70
|
+
completedSteps: projectsCompleted,
|
|
71
|
+
totalSteps: 1,
|
|
72
|
+
},
|
|
73
|
+
[schema_1.UserDetailType.Skills]: {
|
|
74
|
+
score: (0, utils_1.toPositiveWholeNumber)(skillsCompleted * 100),
|
|
75
|
+
completedSteps: skillsCompleted,
|
|
76
|
+
totalSteps: 1,
|
|
77
|
+
},
|
|
78
|
+
[schema_1.UserDetailType.Languages]: {
|
|
79
|
+
score: (0, utils_1.toPositiveWholeNumber)(languagesCompleted * 100),
|
|
80
|
+
completedSteps: languagesCompleted,
|
|
81
|
+
totalSteps: 1,
|
|
82
|
+
},
|
|
83
|
+
[schema_1.UserDetailType.Interests]: {
|
|
84
|
+
score: (0, utils_1.toPositiveWholeNumber)(interestsCompleted * 100),
|
|
85
|
+
completedSteps: interestsCompleted,
|
|
86
|
+
totalSteps: 1,
|
|
87
|
+
},
|
|
88
|
+
[schema_1.UserDetailType.Certifications]: {
|
|
89
|
+
score: (0, utils_1.toPositiveWholeNumber)(certificationsCompleted * 100),
|
|
90
|
+
completedSteps: certificationsCompleted,
|
|
91
|
+
totalSteps: 1,
|
|
92
|
+
},
|
|
93
|
+
[schema_1.UserDetailType.SocialAccounts]: {
|
|
94
|
+
score: (0, utils_1.toPositiveWholeNumber)(socialAccountsCompleted * 100),
|
|
95
|
+
completedSteps: socialAccountsCompleted,
|
|
96
|
+
totalSteps: 1,
|
|
97
|
+
},
|
|
98
|
+
[schema_1.UserDetailType.AdditionalInfo]: {
|
|
99
|
+
score: (0, utils_1.toPositiveWholeNumber)(additionalInfoCompleted * 100),
|
|
100
|
+
completedSteps: additionalInfoCompleted,
|
|
101
|
+
totalSteps: 1,
|
|
102
|
+
},
|
|
41
103
|
};
|
|
42
|
-
|
|
43
|
-
const fieldSchema = schemaFields[key];
|
|
44
|
-
if (!fieldSchema)
|
|
45
|
-
continue;
|
|
46
|
-
const currentPath = prefix ? `${prefix}.${key}` : key;
|
|
47
|
-
processField(key, fieldSchema, currentPath);
|
|
48
|
-
}
|
|
49
|
-
return extractedFields;
|
|
50
|
-
};
|
|
51
|
-
// const getValueByPath = (data: any, path: string) => {
|
|
52
|
-
// const parts = path.replace("[]", "").split(".");
|
|
53
|
-
// return parts.reduce((acc, part) => {
|
|
54
|
-
// if (acc === undefined || acc === null) return undefined;
|
|
55
|
-
// const match = part.match(/^(\d+)$/);
|
|
56
|
-
// if (match && match[1]) {
|
|
57
|
-
// const index = parseInt(match[1]);
|
|
58
|
-
// return Array.isArray(acc) ? acc[index] : undefined;
|
|
59
|
-
// }
|
|
60
|
-
// return acc[part];
|
|
61
|
-
// }, data);
|
|
62
|
-
// };
|
|
63
|
-
// export const getCompletenessScore = <T>(
|
|
64
|
-
// schema: any,
|
|
65
|
-
// data: T | T[],
|
|
66
|
-
// options: CompletenessOptions = { includeOptionals: false }
|
|
67
|
-
// ): CompletenessScore => {
|
|
68
|
-
// const { includeOptionals = false, emptyArrayScore } = options;
|
|
69
|
-
// if (Array.isArray(data)) {
|
|
70
|
-
// if (data.length === 0) {
|
|
71
|
-
// return {
|
|
72
|
-
// score: emptyArrayScore === "perfect" ? 100 : 0,
|
|
73
|
-
// completedSteps: 0,
|
|
74
|
-
// totalSteps: 0,
|
|
75
|
-
// children: [],
|
|
76
|
-
// };
|
|
77
|
-
// }
|
|
78
|
-
// const children = data.map((item) =>
|
|
79
|
-
// getCompletenessScore(schema, item, options)
|
|
80
|
-
// );
|
|
81
|
-
// const contentScore =
|
|
82
|
-
// children.reduce((sum, child) => sum + child.score, 0) / children.length;
|
|
83
|
-
// return {
|
|
84
|
-
// score: Math.round(contentScore),
|
|
85
|
-
// completedSteps: children.reduce((sum, c) => sum + c.completedSteps, 0),
|
|
86
|
-
// totalSteps: children.reduce((sum, c) => sum + c.totalSteps, 0),
|
|
87
|
-
// children,
|
|
88
|
-
// };
|
|
89
|
-
// }
|
|
90
|
-
// const fields = extractFields(schema, "", includeOptionals);
|
|
91
|
-
// const requiredFields = fields.filter((f) => f.required);
|
|
92
|
-
// const totalSteps = includeOptionals ? fields.length : requiredFields.length;
|
|
93
|
-
// let completedSteps = 0;
|
|
94
|
-
// const meta = {
|
|
95
|
-
// steps: fields.map((f) => f.key),
|
|
96
|
-
// completed: [] as string[],
|
|
97
|
-
// incomplete: [] as string[],
|
|
98
|
-
// };
|
|
99
|
-
// fields.forEach(({ key, required }) => {
|
|
100
|
-
// const value = getValueByPath(data, key);
|
|
101
|
-
// const exists = value !== undefined && value !== null && value !== "";
|
|
102
|
-
// if (exists) {
|
|
103
|
-
// meta.completed.push(key);
|
|
104
|
-
// if (includeOptionals || required) completedSteps++;
|
|
105
|
-
// } else {
|
|
106
|
-
// if (includeOptionals || required) meta.incomplete.push(key);
|
|
107
|
-
// }
|
|
108
|
-
// });
|
|
109
|
-
// const score =
|
|
110
|
-
// totalSteps > 0 ? Math.floor((completedSteps / totalSteps) * 100) : 100;
|
|
111
|
-
// return {
|
|
112
|
-
// score,
|
|
113
|
-
// completedSteps: includeOptionals
|
|
114
|
-
// ? completedSteps
|
|
115
|
-
// : Math.min(completedSteps, requiredFields.length),
|
|
116
|
-
// totalSteps,
|
|
117
|
-
// meta,
|
|
118
|
-
// };
|
|
119
|
-
// };
|
|
104
|
+
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { TCompletenessScoreSchema, TUserCompletenessSchema, TUserSchema } from "@thejob/schema";
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the profile completeness score for a given user object.
|
|
4
|
+
* Pure function — no database calls required.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the section weights used in UsersService.getCompleteness().
|
|
7
|
+
*/
|
|
8
|
+
export declare function calculateProfileCompleteness(user: Partial<TUserSchema>): Record<keyof TUserCompletenessSchema, TCompletenessScoreSchema>;
|
|
2
9
|
//# sourceMappingURL=completeness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completeness.d.ts","sourceRoot":"","sources":["../../../src/completeness/completeness.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"completeness.d.ts","sourceRoot":"","sources":["../../../src/completeness/completeness.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAGxB;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GACzB,MAAM,CAAC,MAAM,uBAAuB,EAAE,wBAAwB,CAAC,CA6GjE"}
|
|
@@ -1,118 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { UserDetailType, } from "@thejob/schema";
|
|
2
|
+
import { toPositiveWholeNumber } from "../common/utils";
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the profile completeness score for a given user object.
|
|
5
|
+
* Pure function — no database calls required.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the section weights used in UsersService.getCompleteness().
|
|
8
|
+
*/
|
|
9
|
+
export function calculateProfileCompleteness(user) {
|
|
10
|
+
const { educations, workExperiences, projects, skills, languages, interests, certifications, socialAccounts, additionalInfo, } = user;
|
|
11
|
+
// General (7 steps: name, headline, aboutMe, email, mobile, location, image)
|
|
12
|
+
const generalTotalSteps = 7;
|
|
13
|
+
const generalCompletedSteps = [
|
|
14
|
+
!!user.name,
|
|
15
|
+
!!user.headline,
|
|
16
|
+
!!user.aboutMe,
|
|
17
|
+
!!user.email,
|
|
18
|
+
!!user.mobile,
|
|
19
|
+
!!user.location,
|
|
20
|
+
!!user.image,
|
|
21
|
+
].filter(Boolean).length;
|
|
22
|
+
// Sections with 1 step each (has at least one item)
|
|
23
|
+
const workExperiencesCompleted = workExperiences?.length ? 1 : 0;
|
|
24
|
+
const educationsCompleted = educations?.length ? 1 : 0;
|
|
25
|
+
const projectsCompleted = projects?.length ? 1 : 0;
|
|
26
|
+
const skillsCompleted = skills?.length ? 1 : 0;
|
|
27
|
+
const languagesCompleted = languages?.length ? 1 : 0;
|
|
28
|
+
const interestsCompleted = interests?.length ? 1 : 0;
|
|
29
|
+
const certificationsCompleted = certifications?.length ? 1 : 0;
|
|
30
|
+
const socialAccountsCompleted = socialAccounts?.length ? 1 : 0;
|
|
31
|
+
const additionalInfoCompleted = additionalInfo?.length ? 1 : 0;
|
|
32
|
+
// Overview total excludes additionalInfo (matches original service logic)
|
|
33
|
+
const totalSteps = generalTotalSteps + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; // 15
|
|
34
|
+
const completedSteps = generalCompletedSteps +
|
|
35
|
+
workExperiencesCompleted +
|
|
36
|
+
educationsCompleted +
|
|
37
|
+
projectsCompleted +
|
|
38
|
+
skillsCompleted +
|
|
39
|
+
languagesCompleted +
|
|
40
|
+
interestsCompleted +
|
|
41
|
+
certificationsCompleted +
|
|
42
|
+
socialAccountsCompleted;
|
|
43
|
+
const score = (completedSteps / totalSteps) * 100;
|
|
44
|
+
return {
|
|
45
|
+
[UserDetailType.Overview]: {
|
|
46
|
+
score: toPositiveWholeNumber(score),
|
|
47
|
+
completedSteps,
|
|
48
|
+
totalSteps,
|
|
49
|
+
},
|
|
50
|
+
[UserDetailType.General]: {
|
|
51
|
+
score: toPositiveWholeNumber((generalCompletedSteps / generalTotalSteps) * 100),
|
|
52
|
+
completedSteps: generalCompletedSteps,
|
|
53
|
+
totalSteps: generalTotalSteps,
|
|
54
|
+
},
|
|
55
|
+
[UserDetailType.WorkExperiences]: {
|
|
56
|
+
score: toPositiveWholeNumber(workExperiencesCompleted * 100),
|
|
57
|
+
completedSteps: workExperiencesCompleted,
|
|
58
|
+
totalSteps: 1,
|
|
59
|
+
},
|
|
60
|
+
[UserDetailType.Educations]: {
|
|
61
|
+
score: toPositiveWholeNumber(educationsCompleted * 100),
|
|
62
|
+
completedSteps: educationsCompleted,
|
|
63
|
+
totalSteps: 1,
|
|
64
|
+
},
|
|
65
|
+
[UserDetailType.Projects]: {
|
|
66
|
+
score: toPositiveWholeNumber(projectsCompleted * 100),
|
|
67
|
+
completedSteps: projectsCompleted,
|
|
68
|
+
totalSteps: 1,
|
|
69
|
+
},
|
|
70
|
+
[UserDetailType.Skills]: {
|
|
71
|
+
score: toPositiveWholeNumber(skillsCompleted * 100),
|
|
72
|
+
completedSteps: skillsCompleted,
|
|
73
|
+
totalSteps: 1,
|
|
74
|
+
},
|
|
75
|
+
[UserDetailType.Languages]: {
|
|
76
|
+
score: toPositiveWholeNumber(languagesCompleted * 100),
|
|
77
|
+
completedSteps: languagesCompleted,
|
|
78
|
+
totalSteps: 1,
|
|
79
|
+
},
|
|
80
|
+
[UserDetailType.Interests]: {
|
|
81
|
+
score: toPositiveWholeNumber(interestsCompleted * 100),
|
|
82
|
+
completedSteps: interestsCompleted,
|
|
83
|
+
totalSteps: 1,
|
|
84
|
+
},
|
|
85
|
+
[UserDetailType.Certifications]: {
|
|
86
|
+
score: toPositiveWholeNumber(certificationsCompleted * 100),
|
|
87
|
+
completedSteps: certificationsCompleted,
|
|
88
|
+
totalSteps: 1,
|
|
89
|
+
},
|
|
90
|
+
[UserDetailType.SocialAccounts]: {
|
|
91
|
+
score: toPositiveWholeNumber(socialAccountsCompleted * 100),
|
|
92
|
+
completedSteps: socialAccountsCompleted,
|
|
93
|
+
totalSteps: 1,
|
|
94
|
+
},
|
|
95
|
+
[UserDetailType.AdditionalInfo]: {
|
|
96
|
+
score: toPositiveWholeNumber(additionalInfoCompleted * 100),
|
|
97
|
+
completedSteps: additionalInfoCompleted,
|
|
98
|
+
totalSteps: 1,
|
|
99
|
+
},
|
|
39
100
|
};
|
|
40
|
-
|
|
41
|
-
const fieldSchema = schemaFields[key];
|
|
42
|
-
if (!fieldSchema)
|
|
43
|
-
continue;
|
|
44
|
-
const currentPath = prefix ? `${prefix}.${key}` : key;
|
|
45
|
-
processField(key, fieldSchema, currentPath);
|
|
46
|
-
}
|
|
47
|
-
return extractedFields;
|
|
48
|
-
};
|
|
49
|
-
export {};
|
|
50
|
-
// const getValueByPath = (data: any, path: string) => {
|
|
51
|
-
// const parts = path.replace("[]", "").split(".");
|
|
52
|
-
// return parts.reduce((acc, part) => {
|
|
53
|
-
// if (acc === undefined || acc === null) return undefined;
|
|
54
|
-
// const match = part.match(/^(\d+)$/);
|
|
55
|
-
// if (match && match[1]) {
|
|
56
|
-
// const index = parseInt(match[1]);
|
|
57
|
-
// return Array.isArray(acc) ? acc[index] : undefined;
|
|
58
|
-
// }
|
|
59
|
-
// return acc[part];
|
|
60
|
-
// }, data);
|
|
61
|
-
// };
|
|
62
|
-
// export const getCompletenessScore = <T>(
|
|
63
|
-
// schema: any,
|
|
64
|
-
// data: T | T[],
|
|
65
|
-
// options: CompletenessOptions = { includeOptionals: false }
|
|
66
|
-
// ): CompletenessScore => {
|
|
67
|
-
// const { includeOptionals = false, emptyArrayScore } = options;
|
|
68
|
-
// if (Array.isArray(data)) {
|
|
69
|
-
// if (data.length === 0) {
|
|
70
|
-
// return {
|
|
71
|
-
// score: emptyArrayScore === "perfect" ? 100 : 0,
|
|
72
|
-
// completedSteps: 0,
|
|
73
|
-
// totalSteps: 0,
|
|
74
|
-
// children: [],
|
|
75
|
-
// };
|
|
76
|
-
// }
|
|
77
|
-
// const children = data.map((item) =>
|
|
78
|
-
// getCompletenessScore(schema, item, options)
|
|
79
|
-
// );
|
|
80
|
-
// const contentScore =
|
|
81
|
-
// children.reduce((sum, child) => sum + child.score, 0) / children.length;
|
|
82
|
-
// return {
|
|
83
|
-
// score: Math.round(contentScore),
|
|
84
|
-
// completedSteps: children.reduce((sum, c) => sum + c.completedSteps, 0),
|
|
85
|
-
// totalSteps: children.reduce((sum, c) => sum + c.totalSteps, 0),
|
|
86
|
-
// children,
|
|
87
|
-
// };
|
|
88
|
-
// }
|
|
89
|
-
// const fields = extractFields(schema, "", includeOptionals);
|
|
90
|
-
// const requiredFields = fields.filter((f) => f.required);
|
|
91
|
-
// const totalSteps = includeOptionals ? fields.length : requiredFields.length;
|
|
92
|
-
// let completedSteps = 0;
|
|
93
|
-
// const meta = {
|
|
94
|
-
// steps: fields.map((f) => f.key),
|
|
95
|
-
// completed: [] as string[],
|
|
96
|
-
// incomplete: [] as string[],
|
|
97
|
-
// };
|
|
98
|
-
// fields.forEach(({ key, required }) => {
|
|
99
|
-
// const value = getValueByPath(data, key);
|
|
100
|
-
// const exists = value !== undefined && value !== null && value !== "";
|
|
101
|
-
// if (exists) {
|
|
102
|
-
// meta.completed.push(key);
|
|
103
|
-
// if (includeOptionals || required) completedSteps++;
|
|
104
|
-
// } else {
|
|
105
|
-
// if (includeOptionals || required) meta.incomplete.push(key);
|
|
106
|
-
// }
|
|
107
|
-
// });
|
|
108
|
-
// const score =
|
|
109
|
-
// totalSteps > 0 ? Math.floor((completedSteps / totalSteps) * 100) : 100;
|
|
110
|
-
// return {
|
|
111
|
-
// score,
|
|
112
|
-
// completedSteps: includeOptionals
|
|
113
|
-
// ? completedSteps
|
|
114
|
-
// : Math.min(completedSteps, requiredFields.length),
|
|
115
|
-
// totalSteps,
|
|
116
|
-
// meta,
|
|
117
|
-
// };
|
|
118
|
-
// };
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thejob/util",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript": "^5.7.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thejob/schema": "^1.0.
|
|
37
|
+
"@thejob/schema": "^1.0.97",
|
|
38
38
|
"dayjs": "^1.11.13",
|
|
39
39
|
"mongoose": "^8.11.0",
|
|
40
40
|
"nanoid": "3.3.5",
|