@activepieces/piece-omnihr 0.0.1
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/README.md +7 -0
- package/package.json +26 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +104 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/get-direct-reports.d.ts +7 -0
- package/src/lib/actions/get-direct-reports.js +35 -0
- package/src/lib/actions/get-direct-reports.js.map +1 -0
- package/src/lib/actions/get-employee-info.d.ts +7 -0
- package/src/lib/actions/get-employee-info.js +35 -0
- package/src/lib/actions/get-employee-info.js.map +1 -0
- package/src/lib/actions/get-employee-organizational-chart.d.ts +7 -0
- package/src/lib/actions/get-employee-organizational-chart.js +74 -0
- package/src/lib/actions/get-employee-organizational-chart.js.map +1 -0
- package/src/lib/actions/get-employee-system-id.d.ts +7 -0
- package/src/lib/actions/get-employee-system-id.js +48 -0
- package/src/lib/actions/get-employee-system-id.js.map +1 -0
- package/src/lib/common/client.d.ts +9 -0
- package/src/lib/common/client.js +35 -0
- package/src/lib/common/client.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-omnihr",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.34.11",
|
|
6
|
+
"axios": "1.13.1",
|
|
7
|
+
"axios-retry": "4.4.1",
|
|
8
|
+
"deepmerge-ts": "7.1.0",
|
|
9
|
+
"form-data": "4.0.4",
|
|
10
|
+
"mime-types": "2.1.35",
|
|
11
|
+
"nanoid": "3.3.8",
|
|
12
|
+
"semver": "7.6.0",
|
|
13
|
+
"socket.io-client": "4.8.1",
|
|
14
|
+
"zod": "4.1.13",
|
|
15
|
+
"@activepieces/pieces-common": "0.11.1",
|
|
16
|
+
"@activepieces/pieces-framework": "0.23.0",
|
|
17
|
+
"@activepieces/shared": "0.30.4",
|
|
18
|
+
"tslib": "2.6.2"
|
|
19
|
+
},
|
|
20
|
+
"resolutions": {
|
|
21
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
22
|
+
},
|
|
23
|
+
"types": "./src/index.d.ts",
|
|
24
|
+
"main": "./src/index.js",
|
|
25
|
+
"type": "commonjs"
|
|
26
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const omnihrAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const omnihr: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
7
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
9
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.omnihr = exports.omnihrAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const get_employee_system_id_1 = require("./lib/actions/get-employee-system-id");
|
|
9
|
+
const get_employee_info_1 = require("./lib/actions/get-employee-info");
|
|
10
|
+
const get_employee_organizational_chart_1 = require("./lib/actions/get-employee-organizational-chart");
|
|
11
|
+
const get_direct_reports_1 = require("./lib/actions/get-direct-reports");
|
|
12
|
+
const OMNIHR_API_BASE_URL = 'https://api.omnihr.co/api/';
|
|
13
|
+
const OMNIHR_TOKEN_URL = 'https://api.omnihr.co/api/v1/auth/token/';
|
|
14
|
+
const markdown = 'Enter your OmniHR credentials to authenticate:';
|
|
15
|
+
function getAccessToken(username, password, origin) {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const headers = {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
Origin: origin,
|
|
20
|
+
};
|
|
21
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
22
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
23
|
+
url: OMNIHR_TOKEN_URL,
|
|
24
|
+
headers,
|
|
25
|
+
body: {
|
|
26
|
+
username,
|
|
27
|
+
password,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (!response.body.access) {
|
|
31
|
+
throw new Error('Failed to obtain access token.');
|
|
32
|
+
}
|
|
33
|
+
return response.body.access;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.omnihrAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
37
|
+
description: markdown,
|
|
38
|
+
required: true,
|
|
39
|
+
props: {
|
|
40
|
+
username: pieces_framework_1.Property.ShortText({
|
|
41
|
+
displayName: 'Username',
|
|
42
|
+
description: 'Your OmniHR email address',
|
|
43
|
+
required: true,
|
|
44
|
+
}),
|
|
45
|
+
password: pieces_framework_1.PieceAuth.SecretText({
|
|
46
|
+
displayName: 'Password',
|
|
47
|
+
description: 'Your OmniHR password',
|
|
48
|
+
required: true,
|
|
49
|
+
}),
|
|
50
|
+
origin: pieces_framework_1.Property.ShortText({
|
|
51
|
+
displayName: 'Origin',
|
|
52
|
+
description: 'Your OmniHR origin URL',
|
|
53
|
+
required: true,
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
57
|
+
try {
|
|
58
|
+
const { username, password, origin } = auth;
|
|
59
|
+
yield getAccessToken(username, password, origin);
|
|
60
|
+
return {
|
|
61
|
+
valid: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
valid: false,
|
|
67
|
+
error: `Authentication failed: ${error.message || 'Invalid credentials'}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
exports.omnihr = (0, pieces_framework_1.createPiece)({
|
|
73
|
+
displayName: 'Omni HR',
|
|
74
|
+
description: 'Smart, all-in-one HR platform for managing employees, time tracking, and HR workflows',
|
|
75
|
+
auth: exports.omnihrAuth,
|
|
76
|
+
minimumSupportedRelease: '0.36.1',
|
|
77
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/omnihr.png',
|
|
78
|
+
authors: ['arinmak'],
|
|
79
|
+
categories: [shared_1.PieceCategory.HUMAN_RESOURCES],
|
|
80
|
+
actions: [
|
|
81
|
+
get_employee_system_id_1.getEmployeeSystemId,
|
|
82
|
+
get_employee_info_1.getEmployeeInfo,
|
|
83
|
+
get_employee_organizational_chart_1.getEmployeeOrganizationalChart,
|
|
84
|
+
get_direct_reports_1.getDirectReports,
|
|
85
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
86
|
+
baseUrl: () => OMNIHR_API_BASE_URL,
|
|
87
|
+
auth: exports.omnihrAuth,
|
|
88
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
+
const { username, password, origin } = auth.props;
|
|
90
|
+
const accessToken = yield getAccessToken(username, password, origin);
|
|
91
|
+
const headers = {
|
|
92
|
+
Authorization: `Bearer ${accessToken}`,
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
};
|
|
95
|
+
if (origin) {
|
|
96
|
+
headers['Origin'] = origin;
|
|
97
|
+
}
|
|
98
|
+
return headers;
|
|
99
|
+
}),
|
|
100
|
+
}),
|
|
101
|
+
],
|
|
102
|
+
triggers: [],
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/omnihr/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,+DAIqC;AACrC,iDAAqD;AACrD,iFAA2E;AAC3E,uEAAkE;AAClE,uGAAiG;AACjG,yEAAoE;AAEpE,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AACzD,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AACpE,MAAM,QAAQ,GAAG,gDAAgD,CAAC;AAElE,SAAe,cAAc,CAC3B,QAAgB,EAChB,QAAgB,EAChB,MAAc;;QAEd,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,MAAM;SACf,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAK1C;YACD,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,gBAAgB;YACrB,OAAO;YACP,IAAI,EAAE;gBACJ,QAAQ;gBACR,QAAQ;aACT;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;CAAA;AAEY,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC7C,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,2BAA2B;YACxC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QA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Q,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;gBAClD,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBACrE,MAAM,OAAO,GAA2B;oBACtC,aAAa,EAAE,UAAU,WAAW,EAAE;oBACtC,cAAc,EAAE,kBAAkB;iBACnC,CAAC;gBAEF,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;gBAC7B,CAAC;gBAED,OAAO,OAAO,CAAC;YACjB,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getDirectReports: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
system_id: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDirectReports = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getDirectReports = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.omnihrAuth,
|
|
11
|
+
name: 'get_direct_reports',
|
|
12
|
+
displayName: 'Get Employee Direct Reports',
|
|
13
|
+
description: 'Retrieves a list of employees who directly report to the specified employee',
|
|
14
|
+
props: {
|
|
15
|
+
system_id: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'User ID',
|
|
17
|
+
description: 'The user ID of the employee',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { system_id } = context.propsValue;
|
|
24
|
+
const auth = context.auth;
|
|
25
|
+
const headers = yield (0, client_1.getAuthHeaders)(auth);
|
|
26
|
+
const directReportsResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
27
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
28
|
+
url: `https://api.omnihr.co/api/v1/employee/${system_id}/direct-reports/`,
|
|
29
|
+
headers,
|
|
30
|
+
});
|
|
31
|
+
return directReportsResponse.body;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=get-direct-reports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-direct-reports.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/omnihr/src/lib/actions/get-direct-reports.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AACzC,6CAA8D;AAEjD,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EACT,6EAA6E;IAC/E,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAkB,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;YAE3C,MAAM,qBAAqB,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBACzD,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,yCAAyC,SAAS,kBAAkB;gBACzE,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,qBAAqB,CAAC,IAAI,CAAC;QACpC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getEmployeeInfo: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
system_id: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmployeeInfo = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getEmployeeInfo = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.omnihrAuth,
|
|
11
|
+
name: 'get_employee_info',
|
|
12
|
+
displayName: 'Get Employee Details by System ID',
|
|
13
|
+
description: 'Retrieves detailed employee information using their system ID',
|
|
14
|
+
props: {
|
|
15
|
+
system_id: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'System ID',
|
|
17
|
+
description: 'The system ID of the employee',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { system_id } = context.propsValue;
|
|
24
|
+
const auth = context.auth;
|
|
25
|
+
const headers = yield (0, client_1.getAuthHeaders)(auth);
|
|
26
|
+
const employeeResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
27
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
28
|
+
url: `https://api.omnihr.co/api/v1/employee/${system_id}/`,
|
|
29
|
+
headers,
|
|
30
|
+
});
|
|
31
|
+
return employeeResponse.body;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=get-employee-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-employee-info.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/omnihr/src/lib/actions/get-employee-info.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AACzC,6CAA8D;AAEjD,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mCAAmC;IAChD,WAAW,EAAE,+DAA+D;IAC5E,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAkB,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;YAE3C,MAAM,gBAAgB,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBACpD,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,yCAAyC,SAAS,GAAG;gBAC1D,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,gBAAgB,CAAC,IAAI,CAAC;QAC/B,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getEmployeeOrganizationalChart: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
system_id: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmployeeOrganizationalChart = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getEmployeeOrganizationalChart = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.omnihrAuth,
|
|
11
|
+
name: 'get_employee_organizational_chart',
|
|
12
|
+
displayName: 'Get Employee Organizational Chart',
|
|
13
|
+
description: 'Retrieves employee organizational relationships including the complete management chain, direct reports, and peers',
|
|
14
|
+
props: {
|
|
15
|
+
system_id: pieces_framework_1.Property.Number({
|
|
16
|
+
displayName: 'System ID',
|
|
17
|
+
description: 'The system ID of the employee',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const { system_id } = context.propsValue;
|
|
25
|
+
const auth = context.auth;
|
|
26
|
+
const headers = yield (0, client_1.getAuthHeaders)(auth);
|
|
27
|
+
const snapshotResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
28
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
29
|
+
url: `https://api.omnihr.co/api/v1/employee/${system_id}/snapshot/`,
|
|
30
|
+
headers,
|
|
31
|
+
});
|
|
32
|
+
const snapshot = snapshotResponse.body;
|
|
33
|
+
const managementChain = [];
|
|
34
|
+
let currentManager = snapshot.manager;
|
|
35
|
+
while ((_a = currentManager === null || currentManager === void 0 ? void 0 : currentManager.manager_data) === null || _a === void 0 ? void 0 : _a.system_id) {
|
|
36
|
+
managementChain.push({
|
|
37
|
+
id: currentManager.manager_data.id,
|
|
38
|
+
system_id: currentManager.manager_data.system_id,
|
|
39
|
+
full_name: currentManager.manager_data.full_name,
|
|
40
|
+
first_name: currentManager.manager_data.first_name,
|
|
41
|
+
last_name: currentManager.manager_data.last_name,
|
|
42
|
+
preferred_name: currentManager.manager_data.preferred_name,
|
|
43
|
+
email: (_b = currentManager.manager_data.primary_email) === null || _b === void 0 ? void 0 : _b.value,
|
|
44
|
+
phone: (_c = currentManager.manager_data.primary_phone) === null || _c === void 0 ? void 0 : _c.value,
|
|
45
|
+
position: currentManager.manager_data.position,
|
|
46
|
+
department: currentManager.manager_data.department,
|
|
47
|
+
location: currentManager.manager_data.location_name,
|
|
48
|
+
country: currentManager.manager_data.country,
|
|
49
|
+
employee_type: currentManager.manager_data.employee_type,
|
|
50
|
+
effective_date: currentManager.effective_date,
|
|
51
|
+
});
|
|
52
|
+
const managerSystemId = currentManager.manager_data.system_id;
|
|
53
|
+
try {
|
|
54
|
+
const managerSnapshotResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
55
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
56
|
+
url: `https://api.omnihr.co/api/v1/employee/${managerSystemId}/snapshot/`,
|
|
57
|
+
headers,
|
|
58
|
+
});
|
|
59
|
+
currentManager = managerSnapshotResponse.body.manager;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
career_journey: snapshot.career_journey,
|
|
67
|
+
management_chain: managementChain,
|
|
68
|
+
direct_reports: snapshot.direct_reports,
|
|
69
|
+
peers: snapshot.peers,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=get-employee-organizational-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-employee-organizational-chart.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/omnihr/src/lib/actions/get-employee-organizational-chart.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AACzC,6CAA8D;AAEjD,QAAA,8BAA8B,GAAG,IAAA,+BAAY,EAAC;IACzD,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,mCAAmC;IACzC,WAAW,EAAE,mCAAmC;IAChD,WAAW,EACT,oHAAoH;IACtH,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAkB,CAAC;YACxC,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;YAE3C,MAAM,gBAAgB,GAAG,MAAM,0BAAU,C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AAG,MAAM,0BAAU,CAAC,WAAW,CAAC;wBAC3D,MAAM,EAAE,0BAAU,CAAC,GAAG;wBACtB,GAAG,EAAE,yCAAyC,eAAe,YAAY;wBACzE,OAAO;qBACR,CAAC,CAAC;oBAEH,cAAc,GAAG,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC;gBACxD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM;gBACR,CAAC;YACH,CAAC;YAED,OAAO;gBACL,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,gBAAgB,EAAE,eAAe;gBACjC,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,KAAK,EAAE,QAAQ,CAAC,KAAK;aACtB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getEmployeeSystemId: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
origin: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>, {
|
|
6
|
+
email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmployeeSystemId = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getEmployeeSystemId = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: index_1.omnihrAuth,
|
|
11
|
+
name: 'get_employee_system_id',
|
|
12
|
+
displayName: 'Get Employee System ID by Email',
|
|
13
|
+
description: 'Searches for an employee by email and returns their system ID and user ID',
|
|
14
|
+
props: {
|
|
15
|
+
email: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Employee Email',
|
|
17
|
+
description: 'The email address of the employee to look up',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { email } = context.propsValue;
|
|
24
|
+
const auth = context.auth;
|
|
25
|
+
const headers = yield (0, client_1.getAuthHeaders)(auth);
|
|
26
|
+
let nextUrl = 'https://api.omnihr.co/api/v1/employee/list';
|
|
27
|
+
while (nextUrl) {
|
|
28
|
+
const listResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
29
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
30
|
+
url: nextUrl,
|
|
31
|
+
headers,
|
|
32
|
+
});
|
|
33
|
+
const employee = listResponse.body.results.find((emp) => emp.primary_email.value.toLowerCase() === email.toLowerCase());
|
|
34
|
+
if (employee) {
|
|
35
|
+
return {
|
|
36
|
+
system_id: employee.system_id,
|
|
37
|
+
user_id: employee.id,
|
|
38
|
+
full_name: employee.full_name,
|
|
39
|
+
email: employee.primary_email.value,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
nextUrl = listResponse.body.next;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Employee with email "${email}" not found`);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=get-employee-system-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-employee-system-id.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/omnihr/src/lib/actions/get-employee-system-id.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,uCAAyC;AACzC,6CAA8D;AAEjD,QAAA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AM,IAAI,KAAK,CAAC,wBAAwB,KAAK,aAAa,CAAC,CAAC;QAC9D,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type OmniHrAuth = {
|
|
2
|
+
props: {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function getAccessToken(auth: OmniHrAuth): Promise<string>;
|
|
9
|
+
export declare function getAuthHeaders(auth: OmniHrAuth): Promise<Record<string, string>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccessToken = getAccessToken;
|
|
4
|
+
exports.getAuthHeaders = getAuthHeaders;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
function getAccessToken(auth) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const headers = {
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
Origin: auth.props.origin,
|
|
12
|
+
};
|
|
13
|
+
const tokenResponse = yield pieces_common_1.httpClient.sendRequest({
|
|
14
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
15
|
+
url: 'https://api.omnihr.co/api/v1/auth/token/',
|
|
16
|
+
headers,
|
|
17
|
+
body: {
|
|
18
|
+
username: auth.props.username,
|
|
19
|
+
password: auth.props.password,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return tokenResponse.body.access;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function getAuthHeaders(auth) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const accessToken = yield getAccessToken(auth);
|
|
28
|
+
return {
|
|
29
|
+
Authorization: `Bearer ${accessToken}`,
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
Origin: auth.props.origin,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/omnihr/src/lib/common/client.ts"],"names":[],"mappings":";;AAUA,wCAoBC;AAED,wCAUC;;AA1CD,+DAAqE;AAUrE,SAAsB,cAAc,CAAC,IAAgB;;QACnD,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;SAC1B,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,0BAAU,CAAC,WAAW,CAG/C;YACD,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,0CAA0C;YAC/C,OAAO;YACP,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;gBAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;aAC9B;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACnC,CAAC;CAAA;AAED,SAAsB,cAAc,CAClC,IAAgB;;QAEhB,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;QAE/C,OAAO;YACL,aAAa,EAAE,UAAU,WAAW,EAAE;YACtC,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;SAC1B,CAAC;IACJ,CAAC;CAAA"}
|