@thejob/util 1.0.0

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.
Files changed (91) hide show
  1. package/dist/cjs/common/constants.d.ts +2 -0
  2. package/dist/cjs/common/constants.d.ts.map +1 -0
  3. package/dist/cjs/common/constants.js +2 -0
  4. package/dist/cjs/common/index.d.ts +4 -0
  5. package/dist/cjs/common/index.d.ts.map +1 -0
  6. package/dist/cjs/common/index.js +19 -0
  7. package/dist/cjs/common/types.d.ts +2 -0
  8. package/dist/cjs/common/types.d.ts.map +1 -0
  9. package/dist/cjs/common/types.js +17 -0
  10. package/dist/cjs/common/utils.d.ts +95 -0
  11. package/dist/cjs/common/utils.d.ts.map +1 -0
  12. package/dist/cjs/common/utils.js +402 -0
  13. package/dist/cjs/completeness/completeness.d.ts +2 -0
  14. package/dist/cjs/completeness/completeness.d.ts.map +1 -0
  15. package/dist/cjs/completeness/completeness.js +119 -0
  16. package/dist/cjs/completeness/index.d.ts +2 -0
  17. package/dist/cjs/completeness/index.d.ts.map +1 -0
  18. package/dist/cjs/completeness/index.js +17 -0
  19. package/dist/cjs/date/index.d.ts +2 -0
  20. package/dist/cjs/date/index.d.ts.map +1 -0
  21. package/dist/cjs/date/index.js +17 -0
  22. package/dist/cjs/date/utils.d.ts +14 -0
  23. package/dist/cjs/date/utils.d.ts.map +1 -0
  24. package/dist/cjs/date/utils.js +70 -0
  25. package/dist/cjs/index.d.ts +7 -0
  26. package/dist/cjs/index.d.ts.map +1 -0
  27. package/dist/cjs/index.js +22 -0
  28. package/dist/cjs/job/index.d.ts +2 -0
  29. package/dist/cjs/job/index.d.ts.map +1 -0
  30. package/dist/cjs/job/index.js +17 -0
  31. package/dist/cjs/job/utils.d.ts +2 -0
  32. package/dist/cjs/job/utils.d.ts.map +1 -0
  33. package/dist/cjs/job/utils.js +2 -0
  34. package/dist/cjs/job-application/index.d.ts +2 -0
  35. package/dist/cjs/job-application/index.d.ts.map +1 -0
  36. package/dist/cjs/job-application/index.js +17 -0
  37. package/dist/cjs/job-application/utils.d.ts +3 -0
  38. package/dist/cjs/job-application/utils.d.ts.map +1 -0
  39. package/dist/cjs/job-application/utils.js +19 -0
  40. package/dist/cjs/user/index.d.ts +2 -0
  41. package/dist/cjs/user/index.d.ts.map +1 -0
  42. package/dist/cjs/user/index.js +17 -0
  43. package/dist/cjs/user/utils.d.ts +8 -0
  44. package/dist/cjs/user/utils.d.ts.map +1 -0
  45. package/dist/cjs/user/utils.js +18 -0
  46. package/dist/esm/common/constants.d.ts +2 -0
  47. package/dist/esm/common/constants.d.ts.map +1 -0
  48. package/dist/esm/common/constants.js +1 -0
  49. package/dist/esm/common/index.d.ts +4 -0
  50. package/dist/esm/common/index.d.ts.map +1 -0
  51. package/dist/esm/common/index.js +3 -0
  52. package/dist/esm/common/types.d.ts +2 -0
  53. package/dist/esm/common/types.d.ts.map +1 -0
  54. package/dist/esm/common/types.js +16 -0
  55. package/dist/esm/common/utils.d.ts +95 -0
  56. package/dist/esm/common/utils.d.ts.map +1 -0
  57. package/dist/esm/common/utils.js +372 -0
  58. package/dist/esm/completeness/completeness.d.ts +2 -0
  59. package/dist/esm/completeness/completeness.d.ts.map +1 -0
  60. package/dist/esm/completeness/completeness.js +118 -0
  61. package/dist/esm/completeness/index.d.ts +2 -0
  62. package/dist/esm/completeness/index.d.ts.map +1 -0
  63. package/dist/esm/completeness/index.js +1 -0
  64. package/dist/esm/date/index.d.ts +2 -0
  65. package/dist/esm/date/index.d.ts.map +1 -0
  66. package/dist/esm/date/index.js +1 -0
  67. package/dist/esm/date/utils.d.ts +14 -0
  68. package/dist/esm/date/utils.d.ts.map +1 -0
  69. package/dist/esm/date/utils.js +61 -0
  70. package/dist/esm/index.d.ts +7 -0
  71. package/dist/esm/index.d.ts.map +1 -0
  72. package/dist/esm/index.js +6 -0
  73. package/dist/esm/job/index.d.ts +2 -0
  74. package/dist/esm/job/index.d.ts.map +1 -0
  75. package/dist/esm/job/index.js +1 -0
  76. package/dist/esm/job/utils.d.ts +2 -0
  77. package/dist/esm/job/utils.d.ts.map +1 -0
  78. package/dist/esm/job/utils.js +1 -0
  79. package/dist/esm/job-application/index.d.ts +2 -0
  80. package/dist/esm/job-application/index.d.ts.map +1 -0
  81. package/dist/esm/job-application/index.js +1 -0
  82. package/dist/esm/job-application/utils.d.ts +3 -0
  83. package/dist/esm/job-application/utils.d.ts.map +1 -0
  84. package/dist/esm/job-application/utils.js +15 -0
  85. package/dist/esm/user/index.d.ts +2 -0
  86. package/dist/esm/user/index.d.ts.map +1 -0
  87. package/dist/esm/user/index.js +1 -0
  88. package/dist/esm/user/utils.d.ts +8 -0
  89. package/dist/esm/user/utils.d.ts.map +1 -0
  90. package/dist/esm/user/utils.js +14 -0
  91. package/package.json +52 -0
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const extractFields = (schema, prefix = "", includeOptionals = false) => {
4
+ if (!schema?.fields)
5
+ return [];
6
+ const schemaFields = schema.fields;
7
+ let extractedFields = [];
8
+ const processField = (key, fieldSchema, currentPath) => {
9
+ const isRequired = !fieldSchema.spec?.optional;
10
+ const type = fieldSchema.type;
11
+ const innerType = fieldSchema.innerType?.type;
12
+ if (!isRequired && !includeOptionals)
13
+ return;
14
+ if (type === "array") {
15
+ const minItems = fieldSchema.tests?.find((t) => t.OPTIONS?.name === "min")?.OPTIONS
16
+ ?.params?.min || 0;
17
+ const itemSchema = fieldSchema.innerType;
18
+ // Handle required array items
19
+ for (let i = 0; i < minItems; i++) {
20
+ const indexPath = `${currentPath}.${i}`;
21
+ const itemFields = extractFields(itemSchema, indexPath, includeOptionals);
22
+ extractedFields.push(...itemFields);
23
+ if (itemFields.length === 0) {
24
+ extractedFields.push({ key: indexPath, required: true });
25
+ }
26
+ }
27
+ // Handle optional array items
28
+ if (includeOptionals) {
29
+ const optionalFields = extractFields(itemSchema, currentPath, includeOptionals).map((f) => ({ ...f, key: `${f.key}[]`, required: false }));
30
+ extractedFields.push(...optionalFields);
31
+ }
32
+ }
33
+ else if (type === "object" || innerType === "object") {
34
+ const targetSchema = type === "object" ? fieldSchema : fieldSchema.innerType;
35
+ const nestedFields = extractFields(targetSchema, currentPath, includeOptionals);
36
+ extractedFields.push(...nestedFields);
37
+ }
38
+ else {
39
+ extractedFields.push({ key: currentPath, required: isRequired });
40
+ }
41
+ };
42
+ for (const key in schemaFields) {
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
+ // };
@@ -0,0 +1,2 @@
1
+ export * from "./completeness";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/completeness/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./completeness"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./utils";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,14 @@
1
+ import { DateRangeOption } from "@thejob/schema";
2
+ import dayjs, { Dayjs } from "dayjs";
3
+ export declare const toDayJS: ({ date, dateFormat, strict, utc, }?: {
4
+ date?: string | Dayjs;
5
+ dateFormat?: string;
6
+ strict?: boolean;
7
+ utc?: boolean;
8
+ }) => dayjs.Dayjs;
9
+ export declare const dateAgo: (value: number | string | Date) => string;
10
+ export declare const dateRangeOptionToDateRange: (option: DateRangeOption) => {
11
+ startDate: string | undefined;
12
+ endDate: string | undefined;
13
+ };
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/date/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAQrC,eAAO,MAAM,OAAO,GAAI,qCAKrB;IACD,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACV,gBASL,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,IAAI,WAEpD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,QAAQ,eAAe;;;CA4CjE,CAAC"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.dateRangeOptionToDateRange = exports.dateAgo = exports.toDayJS = void 0;
7
+ const schema_1 = require("@thejob/schema");
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const localizedFormat_1 = __importDefault(require("dayjs/plugin/localizedFormat"));
10
+ const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
11
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
12
+ dayjs_1.default.extend(relativeTime_1.default);
13
+ dayjs_1.default.extend(localizedFormat_1.default);
14
+ dayjs_1.default.extend(customParseFormat_1.default);
15
+ const toDayJS = ({ date, dateFormat = schema_1.SystemDateFormat, strict = false, utc = false, } = {}) => {
16
+ return (0, dayjs_1.default)(date, {
17
+ utc,
18
+ format: dateFormat,
19
+ }, strict);
20
+ };
21
+ exports.toDayJS = toDayJS;
22
+ const dateAgo = (value) => {
23
+ return (0, dayjs_1.default)(value).fromNow();
24
+ };
25
+ exports.dateAgo = dateAgo;
26
+ const dateRangeOptionToDateRange = (option) => {
27
+ const today = (0, exports.toDayJS)({ utc: true });
28
+ let dateRange = {
29
+ startDate: undefined,
30
+ endDate: undefined,
31
+ };
32
+ switch (option) {
33
+ case schema_1.DateRangeOption.LastMonth:
34
+ dateRange = {
35
+ startDate: today.subtract(1, "month"), //.startOf("month"),
36
+ endDate: today,
37
+ };
38
+ break;
39
+ case schema_1.DateRangeOption.LastWeek:
40
+ dateRange = {
41
+ startDate: today.subtract(1, "week"), //.startOf("week"),
42
+ endDate: today, //.endOf("week"),
43
+ };
44
+ break;
45
+ case schema_1.DateRangeOption.Last_3_Days:
46
+ dateRange = {
47
+ startDate: today.subtract(3, "days"),
48
+ endDate: today,
49
+ };
50
+ break;
51
+ case schema_1.DateRangeOption.Last_24_Hours:
52
+ dateRange = {
53
+ startDate: today.subtract(24, "hours"),
54
+ endDate: today,
55
+ };
56
+ break;
57
+ case schema_1.DateRangeOption.Any:
58
+ default:
59
+ dateRange = {
60
+ startDate: undefined,
61
+ endDate: undefined,
62
+ };
63
+ break;
64
+ }
65
+ return {
66
+ startDate: dateRange.startDate?.format(schema_1.SystemDateFormat),
67
+ endDate: dateRange.endDate?.format(schema_1.SystemDateFormat),
68
+ };
69
+ };
70
+ exports.dateRangeOptionToDateRange = dateRangeOptionToDateRange;
@@ -0,0 +1,7 @@
1
+ export * from "./common";
2
+ export * from "./completeness";
3
+ export * from "./user";
4
+ export * from "./date";
5
+ export * from "./job";
6
+ export * from "./job-application";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./completeness"), exports);
19
+ __exportStar(require("./user"), exports);
20
+ __exportStar(require("./date"), exports);
21
+ __exportStar(require("./job"), exports);
22
+ __exportStar(require("./job-application"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./utils";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/job/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/job/utils.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./utils";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/job-application/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,3 @@
1
+ import { JobApplicationScore } from "@thejob/schema";
2
+ export declare const jobApplicationScoreToLabel: (score: JobApplicationScore) => "Exceptional" | "Qualified" | "Potential" | "Not Recommended" | "Unknown";
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/job-application/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,eAAO,MAAM,0BAA0B,GAAI,OAAO,mBAAmB,8EAapE,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jobApplicationScoreToLabel = void 0;
4
+ const schema_1 = require("@thejob/schema");
5
+ const jobApplicationScoreToLabel = (score) => {
6
+ switch (score) {
7
+ case schema_1.JobApplicationScore.Exceptional:
8
+ return "Exceptional";
9
+ case schema_1.JobApplicationScore.Qualified:
10
+ return "Qualified";
11
+ case schema_1.JobApplicationScore.Potential:
12
+ return "Potential";
13
+ case schema_1.JobApplicationScore.NotRecommended:
14
+ return "Not Recommended";
15
+ default:
16
+ return "Unknown";
17
+ }
18
+ };
19
+ exports.jobApplicationScoreToLabel = jobApplicationScoreToLabel;
@@ -0,0 +1,2 @@
1
+ export * from "./utils";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,8 @@
1
+ export declare const parseName: (name: string | {
2
+ first: string;
3
+ last: string;
4
+ }) => {
5
+ first: string;
6
+ last: string;
7
+ };
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/user/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;WAAtB,MAAM;UAAQ,MAAM;CAWrE,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseName = void 0;
4
+ const schema_1 = require("@thejob/schema");
5
+ const parseName = (name) => {
6
+ if (typeof name === "string") {
7
+ const nameParts = name.trim().split(/\s+/); // Split by spaces, ensuring no extra whitespace
8
+ const nameObject = {
9
+ first: nameParts[0] || "", // Assign the first part as first name
10
+ last: nameParts.length > 1 ? nameParts.slice(1).join(" ") : schema_1.EmptyString, // Join the rest as last name if exists
11
+ };
12
+ return nameObject;
13
+ }
14
+ else {
15
+ return name;
16
+ }
17
+ };
18
+ exports.parseName = parseName;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/common/constants.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./constants";
3
+ export * from "./utils";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./constants";
3
+ export * from "./utils";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ // import { UserDetailType } from "@thejob/schema";
2
+ export {};
3
+ // export type CompletenessScore = {
4
+ // score: number;
5
+ // completedSteps: number;
6
+ // totalSteps: number;
7
+ // children?: CompletenessScore[];
8
+ // meta?: {
9
+ // steps: string[];
10
+ // completed: string[];
11
+ // incomplete: string[];
12
+ // };
13
+ // };
14
+ // export type TProfileCompleteness = Partial<
15
+ // Record<UserDetailType, CompletenessScore>
16
+ // >;
@@ -0,0 +1,95 @@
1
+ import { ProficiencyLevel, TLocationValue, TMobileNumberSchema, TName, TUserCompletenessSchema, TUserSchema } from "@thejob/schema";
2
+ import { AnySchema } from "yup";
3
+ export declare const removeEmpty: (obj: any) => any;
4
+ export declare const deepEqual: (obj1: unknown, obj2: unknown) => boolean;
5
+ export declare const getYupDefaults: <T>(schema: AnySchema) => T;
6
+ export declare const getFormDefaultValues: (inputValue: any, // TODO: Use react hook form default values type definition,,
7
+ onComplete?: (data: any) => void) => () => Promise<any>;
8
+ export declare const proficiencyLevelToRating: (level: ProficiencyLevel) => number;
9
+ export declare const slugify: (str: string) => string;
10
+ export declare const getShortId: (size?: number) => string;
11
+ export declare const minifyString: (seed: string, length?: number) => string;
12
+ /**
13
+ * Extracts the ID from a given string pattern.
14
+ * Assumes the ID is the last segment after the final hyphen.
15
+ *
16
+ * @param input - The string to extract the ID from.
17
+ * @returns The extracted ID or null if not found.
18
+ */
19
+ export declare const extractShortID: (slug: string) => string | null | undefined;
20
+ type AllResults<T extends unknown[]> = {
21
+ [K in keyof T]: T[K] extends Promise<infer U> ? U | {
22
+ error: any;
23
+ } : never;
24
+ };
25
+ export declare const allResults: <T extends unknown[]>(promises: readonly [...T]) => Promise<AllResults<T>>;
26
+ export declare const sleep: (duration: number) => Promise<unknown>;
27
+ export declare const hasOtherValue: (input: any) => boolean;
28
+ export declare const fromWithOtherValue: (input: any, displayFn?: (value: any) => any) => any;
29
+ export declare const isJSON: (value: any) => boolean;
30
+ export declare const displayByName: (option: any) => any;
31
+ export declare const displayLocation: (location: TLocationValue, display: "address" | "medium" | "small") => string;
32
+ /**
33
+ * Generates a random integer between two given values (inclusive).
34
+ *
35
+ * @param {number} min - The minimum value (inclusive).
36
+ * @param {number} max - The maximum value (inclusive).
37
+ * @returns {number} A random integer between min and max.
38
+ */
39
+ export declare const getRandomInt: (min: number, max: number) => number;
40
+ /**
41
+ * Generates a random floating-point number between two given values (inclusive).
42
+ *
43
+ * @param {number} min - The minimum value (inclusive).
44
+ * @param {number} max - The maximum value (inclusive).
45
+ * @returns {number} A random floating-point number between min and max.
46
+ */
47
+ export declare const getRandomFloat: (min: number, max: number) => number;
48
+ export declare const displayNameLabel: (name: TName | string, type?: "full" | "first" | "last") => string;
49
+ export declare const displayMobileNumberLabel: (mobileNumber: TMobileNumberSchema, options?: {
50
+ countryName?: boolean;
51
+ }) => string;
52
+ export declare const toPositiveWholeNumber: (value: any) => number;
53
+ export declare const formatNumberToKMB: (num: number) => string;
54
+ export declare const formatCountWithLabel: (count: number, options: {
55
+ singularLabel: string;
56
+ pluralLabel: string;
57
+ zeroCountLabel?: string;
58
+ }) => string;
59
+ /**
60
+ * Recursively parses a dirty fields object to detect if the form or a specific field is dirty.
61
+ *
62
+ * @param dirtyFields The object representing the dirty state of form fields.
63
+ * @param fieldName (Optional) The name of a specific field to check for dirtiness.
64
+ * @returns True if the form or the specified field is dirty, false otherwise.
65
+ */
66
+ export declare const isFormDirty: (dirtyFields: any, //PickFrom<FormState<any>, "dirtyFields">,
67
+ fieldName?: string) => boolean;
68
+ interface ErrorDetail {
69
+ value: number;
70
+ path: string;
71
+ type: string;
72
+ params: Record<string, any>;
73
+ errors: string[];
74
+ inner: ErrorDetail[];
75
+ name: string;
76
+ message: string;
77
+ }
78
+ interface InputObject {
79
+ value: Record<string, any>;
80
+ errors: string[];
81
+ inner: ErrorDetail[];
82
+ name: string;
83
+ message: string;
84
+ }
85
+ /**
86
+ * Extracts the root path of each error within the 'inner' property of the input object.
87
+ *
88
+ * @param data The input object containing error details.
89
+ * @returns An array of strings, where each string is the root path of an error.
90
+ */
91
+ export declare const getErrorRootPaths: <T>(data: InputObject) => Array<keyof T>;
92
+ export declare const getRequiredUserInformation: (completeness: TUserCompletenessSchema, skip?: Array<keyof TUserCompletenessSchema>) => never[];
93
+ export declare const getRequiredInformationByUser: (user: Partial<TUserSchema>, completeness: TUserCompletenessSchema) => never[];
94
+ export {};
95
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,gBAAgB,EAEhB,cAAc,EACd,mBAAmB,EACnB,KAAK,EACL,uBAAuB,EACvB,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,QA2BnC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,EAAE,MAAM,OAAO,KAAG,OAIxD,CAAC;AAqDF,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,QAAQ,SAAS,KAEI,CACtD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,GAAG,EAAE,6DAA6D;AAC9E,aAAY,CAAC,IAAI,EAAE,GAAG,KAAK,IAAiB,uBAQ7C,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,OAAO,gBAAgB,KAAG,MAelE,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,WASlC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAM,MAAW,WAK3C,CAAC;AAEF,eAA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