@geniehr/utilities 1.0.8 → 1.0.10
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/apiUtils/httpUtils.d.ts +6 -0
- package/dist/apiUtils/httpUtils.js +36 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schema/files/person/personSchema.d.ts +51 -48
- package/dist/schema/files/person/personSchema.js +18 -17
- package/dist/schema/schemaMappings.js +2 -0
- package/dist/schema/validation.js +1 -0
- package/dist/types/GHRContext.d.ts +1 -0
- package/package.json +2 -1
|
@@ -9,4 +9,10 @@ export declare class HttpClient {
|
|
|
9
9
|
patch<T = any>(url: string, data: any, correlationId: string, config?: AxiosRequestConfig): Promise<T>;
|
|
10
10
|
private formatError;
|
|
11
11
|
}
|
|
12
|
+
export declare class GraphQLClient {
|
|
13
|
+
private url;
|
|
14
|
+
private headers;
|
|
15
|
+
constructor(url: string, headers?: Record<string, string>);
|
|
16
|
+
query<T = any>(query: string, variables?: Record<string, any>, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
17
|
+
}
|
|
12
18
|
export default HttpClient;
|
|
@@ -103,4 +103,40 @@ export class HttpClient {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
export class GraphQLClient {
|
|
107
|
+
url;
|
|
108
|
+
headers;
|
|
109
|
+
constructor(url, headers = {}) {
|
|
110
|
+
this.url = url;
|
|
111
|
+
this.headers = headers;
|
|
112
|
+
}
|
|
113
|
+
async query(query, variables = {}, additionalHeaders = {}) {
|
|
114
|
+
try {
|
|
115
|
+
const response = await fetch(this.url, {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
headers: {
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
...this.headers,
|
|
120
|
+
...additionalHeaders,
|
|
121
|
+
},
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
query,
|
|
124
|
+
variables,
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
throw new Error(`HTTP Error: ${response.statusText}`);
|
|
129
|
+
}
|
|
130
|
+
const result = await response.json();
|
|
131
|
+
if (result.errors) {
|
|
132
|
+
throw new Error(JSON.stringify(result.errors));
|
|
133
|
+
}
|
|
134
|
+
return result.data;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
// Improve error formatting to match existing style or be meaningful
|
|
138
|
+
throw new Error(`GraphQL Request Failed: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
106
142
|
export default HttpClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { HttpStatusCode } from './shared/enums/HttpStatusCodes.js';
|
|
|
6
6
|
export { InvalidRequestException, InvalidEnvironmentException, AppException } from './shared/exceptions/index.js';
|
|
7
7
|
export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action } from './secrets/aws.js';
|
|
8
8
|
export { CognitoUserService } from './secrets/CognitoUserService.js';
|
|
9
|
-
export { HttpClient } from './apiUtils/httpUtils.js';
|
|
9
|
+
export { HttpClient, GraphQLClient } from './apiUtils/httpUtils.js';
|
|
10
10
|
export { sendResponse } from './apiUtils/api.js';
|
|
11
11
|
export { services } from './shared/services.js';
|
|
12
12
|
export { ImageCompressor } from './shared/helper/ImageCompressor.js';
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { HttpStatusCode } from './shared/enums/HttpStatusCodes.js';
|
|
|
6
6
|
export { InvalidRequestException, InvalidEnvironmentException, AppException } from './shared/exceptions/index.js';
|
|
7
7
|
export { getAWSParameters, matchFace, registerFace, generatePresignedUrl, getCustomAttribute, updateCustomAttribute, executeS3Action } from './secrets/aws.js';
|
|
8
8
|
export { CognitoUserService } from './secrets/CognitoUserService.js';
|
|
9
|
-
export { HttpClient } from './apiUtils/httpUtils.js';
|
|
9
|
+
export { HttpClient, GraphQLClient } from './apiUtils/httpUtils.js';
|
|
10
10
|
export { sendResponse } from './apiUtils/api.js';
|
|
11
11
|
export { services } from './shared/services.js';
|
|
12
12
|
export { ImageCompressor } from './shared/helper/ImageCompressor.js';
|
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const personSchema: z.ZodObject<{
|
|
3
3
|
firstName: z.ZodString;
|
|
4
|
-
middleName: z.ZodOptional<z.ZodString
|
|
5
|
-
lastName: z.ZodOptional<z.ZodString
|
|
6
|
-
dateOfBirth: z.ZodOptional<z.ZodDate
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
bloodGroupId: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
bloodGroupName: z.ZodOptional<z.ZodString>;
|
|
11
|
-
maritalStatus: z.ZodOptional<z.ZodString>;
|
|
12
|
-
maritalStatusId: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
mobileNo: z.ZodOptional<z.ZodString>;
|
|
14
|
-
emailAddress: z.ZodOptional<z.ZodString>;
|
|
15
|
-
about: z.ZodOptional<z.ZodString>;
|
|
16
|
-
iamId: z.ZodOptional<z.ZodString>;
|
|
17
|
-
employeeNo: z.ZodOptional<z.ZodString>;
|
|
18
|
-
ghrId: z.ZodNumber;
|
|
4
|
+
middleName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
5
|
+
lastName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
dateOfBirth: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
|
|
7
|
+
mobileNo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
emailAddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
9
|
personTypeId: z.ZodNumber;
|
|
20
|
-
|
|
10
|
+
maritalStatusId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
11
|
+
genderId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
+
bloodGroupId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
13
|
+
ghrId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
14
|
+
orgPath: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
15
|
+
personTypeName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
16
|
+
maritalStatusName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
genderName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
bloodGroupName: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
about: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
iamId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
employeeNo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
22
|
}, "strip", z.ZodTypeAny, {
|
|
22
23
|
firstName: string;
|
|
23
|
-
ghrId: number;
|
|
24
24
|
personTypeId: number;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
middleName?: string | null | undefined;
|
|
26
|
+
lastName?: string | null | undefined;
|
|
27
|
+
dateOfBirth?: Date | null | undefined;
|
|
28
|
+
mobileNo?: string | null | undefined;
|
|
29
|
+
emailAddress?: string | null | undefined;
|
|
30
|
+
maritalStatusId?: number | null | undefined;
|
|
31
|
+
genderId?: number | null | undefined;
|
|
32
|
+
bloodGroupId?: number | null | undefined;
|
|
33
|
+
ghrId?: number | null | undefined;
|
|
34
|
+
orgPath?: string | null | undefined;
|
|
35
|
+
personTypeName?: string | null | undefined;
|
|
36
|
+
maritalStatusName?: string | null | undefined;
|
|
37
|
+
genderName?: string | null | undefined;
|
|
38
|
+
bloodGroupName?: string | null | undefined;
|
|
39
|
+
about?: string | null | undefined;
|
|
40
|
+
iamId?: string | null | undefined;
|
|
41
|
+
employeeNo?: string | null | undefined;
|
|
40
42
|
}, {
|
|
41
43
|
firstName: string;
|
|
42
|
-
ghrId: number;
|
|
43
44
|
personTypeId: number;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
middleName?: string | null | undefined;
|
|
46
|
+
lastName?: string | null | undefined;
|
|
47
|
+
dateOfBirth?: Date | null | undefined;
|
|
48
|
+
mobileNo?: string | null | undefined;
|
|
49
|
+
emailAddress?: string | null | undefined;
|
|
50
|
+
maritalStatusId?: number | null | undefined;
|
|
51
|
+
genderId?: number | null | undefined;
|
|
52
|
+
bloodGroupId?: number | null | undefined;
|
|
53
|
+
ghrId?: number | null | undefined;
|
|
54
|
+
orgPath?: string | null | undefined;
|
|
55
|
+
personTypeName?: string | null | undefined;
|
|
56
|
+
maritalStatusName?: string | null | undefined;
|
|
57
|
+
genderName?: string | null | undefined;
|
|
58
|
+
bloodGroupName?: string | null | undefined;
|
|
59
|
+
about?: string | null | undefined;
|
|
60
|
+
iamId?: string | null | undefined;
|
|
61
|
+
employeeNo?: string | null | undefined;
|
|
59
62
|
}>;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export const personSchema = z.object({
|
|
3
3
|
firstName: z.string().trim().min(1).max(45),
|
|
4
|
-
middleName: z.string().trim().max(45).optional(),
|
|
5
|
-
lastName: z.string().trim().max(45).optional(),
|
|
6
|
-
dateOfBirth: z.coerce.date().optional(),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
middleName: z.string().trim().max(45).optional().nullable(),
|
|
5
|
+
lastName: z.string().trim().max(45).optional().nullable(),
|
|
6
|
+
dateOfBirth: z.coerce.date().optional().nullable(),
|
|
7
|
+
mobileNo: z.string().trim().max(15).optional().nullable(),
|
|
8
|
+
emailAddress: z.string().trim().email().max(46).optional().nullable(),
|
|
9
|
+
personTypeId: z.coerce.number().int(),
|
|
10
|
+
maritalStatusId: z.coerce.number().int().optional().nullable(),
|
|
11
|
+
genderId: z.coerce.number().int().optional().nullable(),
|
|
12
|
+
bloodGroupId: z.coerce.number().int().optional().nullable(),
|
|
13
|
+
ghrId: z.coerce.number().int().optional().nullable(),
|
|
14
|
+
orgPath: z.string().trim().optional().nullable(),
|
|
15
|
+
personTypeName: z.string().trim().max(100).optional().nullable(),
|
|
16
|
+
maritalStatusName: z.string().trim().max(100).optional().nullable(),
|
|
17
|
+
genderName: z.string().trim().max(100).optional().nullable(),
|
|
18
|
+
bloodGroupName: z.string().trim().max(100).optional().nullable(),
|
|
19
|
+
about: z.string().trim().optional().nullable(),
|
|
20
|
+
iamId: z.string().trim().max(50).optional().nullable(),
|
|
21
|
+
employeeNo: z.string().trim().max(45).optional().nullable(),
|
|
21
22
|
});
|
|
@@ -2,6 +2,7 @@ import { emergencyContactsSchema, pastExperiencesSchema, personSchema, primaryCo
|
|
|
2
2
|
export const mappings = {
|
|
3
3
|
'people-ms': {
|
|
4
4
|
'post': {
|
|
5
|
+
'/people/person': personSchema,
|
|
5
6
|
'/people/person/profile': personSchema,
|
|
6
7
|
'/people/work/details': workDetailsSchema,
|
|
7
8
|
'/people/work/past-experience': pastExperiencesSchema,
|
|
@@ -13,6 +14,7 @@ export const mappings = {
|
|
|
13
14
|
},
|
|
14
15
|
'bff-ms': {
|
|
15
16
|
'post': {
|
|
17
|
+
'/api/person': personSchema,
|
|
16
18
|
'/api/employee/profile': personSchema,
|
|
17
19
|
'/api/employee/work/details': workDetailsSchema,
|
|
18
20
|
'/api/employee/work/past-experience': pastExperiencesSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geniehr/utilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/Genie-HR/ghr-utilities#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"axios": "^1.10.0",
|
|
40
40
|
"express": "^5.1.0",
|
|
41
41
|
"ioredis": "^5.8.2",
|
|
42
|
+
"mongodb": "^6.13.1",
|
|
42
43
|
"sharp": "^0.34.4",
|
|
43
44
|
"winston": "^3.17.0",
|
|
44
45
|
"winston-cloudwatch": "^6.3.0",
|