@markwharton/eh-payroll 2.7.1 → 3.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.
- package/README.md +3 -0
- package/dist/client.d.ts +12 -4
- package/dist/client.js +22 -0
- package/dist/employee-types.generated.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -2
- package/dist/types.d.ts +18 -6
- package/dist/types.js +4 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ All methods return `Result<T>` — see [api-core Result Pattern](../../README.md
|
|
|
84
84
|
| `validateApiKey()` | — | `Result<void>` |
|
|
85
85
|
| `getEmployees(options?)` | `EHEmployeeOptions?` | `Result<EHAuEmployee[]>` |
|
|
86
86
|
| `getEmployee(employeeId)` | `number` | `Result<EHAuEmployee>` |
|
|
87
|
+
| `getEmployeeImage(employeeId)` | `number` | `Result<EHEmployeeImage>` |
|
|
87
88
|
| `getStandardHours(employeeId)` | `number` | `Result<EHStandardHours>` |
|
|
88
89
|
| `getLocations()` | — | `Result<EHLocation[]>` |
|
|
89
90
|
| `getEmployeeGroups()` | — | `Result<EHEmployeeGroup[]>` |
|
|
@@ -115,6 +116,8 @@ Returns leave requests with all filters applied server-side. The business-level
|
|
|
115
116
|
| `employeeId` | `number` | Filter by employee ID |
|
|
116
117
|
| `leaveCategoryId` | `number` | Filter by leave category ID |
|
|
117
118
|
| `locationId` | `number` | Filter by location ID |
|
|
119
|
+
| `groupBy` | `'Employee' \| 'LeaveType'` | Group results by employee or leave type |
|
|
120
|
+
| `restrictOverlappingLeave` | `boolean` | Restrict results to leave overlapping the date range |
|
|
118
121
|
|
|
119
122
|
### `getEmployeeLeaveRequests()`
|
|
120
123
|
|
package/dist/client.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://api.keypay.com.au/
|
|
8
8
|
*/
|
|
9
|
-
import type { EHConfig, EHLeaveRequest, EHLeaveRequestOptions, EHEmployeeLeaveRequestOptions, EHEmployeeOptions, EHStandardHours, EHLocation, EHEmployeeGroup, EHRosterShift, EHRosterShiftOptions, EHKiosk, EHKioskEmployee, EHKioskStaffOptions } from './types.js';
|
|
10
|
-
import type {
|
|
9
|
+
import type { EHConfig, EHLeaveRequest, EHLeaveRequestOptions, EHEmployeeLeaveRequestOptions, EHEmployeeOptions, EHStandardHours, EHLocation, EHEmployeeGroup, EHRosterShift, EHRosterShiftOptions, EHKiosk, EHKioskEmployee, EHKioskStaffOptions, EHEmployeeImage } from './types.js';
|
|
10
|
+
import type { EHEmployee } from './employee-types.generated.js';
|
|
11
11
|
import type { Result } from '@markwharton/api-core';
|
|
12
12
|
/**
|
|
13
13
|
* Employment Hero Payroll API Client
|
|
@@ -112,11 +112,19 @@ export declare class EHClient {
|
|
|
112
112
|
/**
|
|
113
113
|
* Get all employees
|
|
114
114
|
*/
|
|
115
|
-
getEmployees(options?: EHEmployeeOptions): Promise<Result<
|
|
115
|
+
getEmployees(options?: EHEmployeeOptions): Promise<Result<EHEmployee[]>>;
|
|
116
116
|
/**
|
|
117
117
|
* Get a single employee by ID
|
|
118
118
|
*/
|
|
119
|
-
getEmployee(employeeId: number): Promise<Result<
|
|
119
|
+
getEmployee(employeeId: number): Promise<Result<EHEmployee>>;
|
|
120
|
+
/**
|
|
121
|
+
* Get employee profile image
|
|
122
|
+
*
|
|
123
|
+
* Returns binary image data. Not cached (large binary blobs).
|
|
124
|
+
*
|
|
125
|
+
* @see https://api.keypay.com.au/australia/reference/employee/au-employee--get-employee-profile-image.html
|
|
126
|
+
*/
|
|
127
|
+
getEmployeeImage(employeeId: number): Promise<Result<EHEmployeeImage>>;
|
|
120
128
|
/**
|
|
121
129
|
* Get standard hours for an employee (includes FTE value)
|
|
122
130
|
*/
|
package/dist/client.js
CHANGED
|
@@ -235,6 +235,10 @@ export class EHClient {
|
|
|
235
235
|
parts.push(`lcid:${options.leaveCategoryId}`);
|
|
236
236
|
if (options?.locationId != null)
|
|
237
237
|
parts.push(`lid:${options.locationId}`);
|
|
238
|
+
if (options?.groupBy)
|
|
239
|
+
parts.push(`gb:${options.groupBy}`);
|
|
240
|
+
if (options?.restrictOverlappingLeave)
|
|
241
|
+
parts.push('rol');
|
|
238
242
|
const cacheKey = parts.join(':');
|
|
239
243
|
return this.cached(cacheKey, this.cacheTtl.leaveRequestsTtl, async () => {
|
|
240
244
|
const params = new URLSearchParams();
|
|
@@ -250,6 +254,10 @@ export class EHClient {
|
|
|
250
254
|
params.set('LeaveCategoryId', String(options.leaveCategoryId));
|
|
251
255
|
if (options?.locationId != null)
|
|
252
256
|
params.set('LocationId', String(options.locationId));
|
|
257
|
+
if (options?.groupBy)
|
|
258
|
+
params.set('GroupBy', options.groupBy);
|
|
259
|
+
if (options?.restrictOverlappingLeave)
|
|
260
|
+
params.set('RestrictOverlappingLeave', 'true');
|
|
253
261
|
const url = this.businessUrl(ENTITIES.EHLeaveRequest.path, params);
|
|
254
262
|
return this.fetchAndParse(url, async (r) => {
|
|
255
263
|
return (await r.json())
|
|
@@ -328,6 +336,20 @@ export class EHClient {
|
|
|
328
336
|
});
|
|
329
337
|
}, this.restrictedPersistOpt);
|
|
330
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Get employee profile image
|
|
341
|
+
*
|
|
342
|
+
* Returns binary image data. Not cached (large binary blobs).
|
|
343
|
+
*
|
|
344
|
+
* @see https://api.keypay.com.au/australia/reference/employee/au-employee--get-employee-profile-image.html
|
|
345
|
+
*/
|
|
346
|
+
async getEmployeeImage(employeeId) {
|
|
347
|
+
const url = this.businessUrl(`employee/${employeeId}/image`);
|
|
348
|
+
return this.fetchAndParse(url, async (r) => ({
|
|
349
|
+
data: await r.arrayBuffer(),
|
|
350
|
+
contentType: r.headers.get('content-type') || 'application/octet-stream',
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
331
353
|
// ============================================================================
|
|
332
354
|
// Standard Hours
|
|
333
355
|
// ============================================================================
|
|
@@ -79,7 +79,7 @@ export interface EHEmployeeCommon {
|
|
|
79
79
|
workTypes: string | null;
|
|
80
80
|
}
|
|
81
81
|
/** AU region employee (70 region-specific fields) */
|
|
82
|
-
export interface
|
|
82
|
+
export interface EHEmployee extends EHEmployeeCommon {
|
|
83
83
|
australianResident: boolean;
|
|
84
84
|
automaticallyApplyPublicHolidayNotWorkedEarningsLines: boolean;
|
|
85
85
|
awardId: number | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,13 +20,12 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export { EHClient } from './client.js';
|
|
23
|
-
export type { EHConfig, EHCacheConfig, EHRetryConfig, EHLeaveRequest,
|
|
24
|
-
export {
|
|
23
|
+
export type { EHConfig, EHCacheConfig, EHRetryConfig, EHLeaveRequest, EHLeaveRequestOptions, EHEmployeeLeaveRequestOptions, EHLeaveRequestStatus, EHEmployee, EHEmployeeOptions, EHStandardHours, EHLocation, EHEmployeeGroup, EHRosterShift, EHRosterShiftOptions, EHAttendanceStatus, EHKiosk, EHKioskEmployee, EHKioskStaffOptions, EHEmployeeImage, } from './types.js';
|
|
24
|
+
export { EMPLOYEE_FIELDS, LEAVE_REQUEST_FIELDS, LOCATION_FIELDS, EMPLOYEE_GROUP_FIELDS, ROSTER_SHIFT_FIELDS, KIOSK_FIELDS, KIOSK_EMPLOYEE_FIELDS, ENTITIES, } from './types.js';
|
|
25
25
|
export type { AccessTier } from './types.js';
|
|
26
26
|
export { METHOD_TIERS } from './types.js';
|
|
27
|
-
export type { EHAuEmployee } from './employee-types.generated.js';
|
|
28
27
|
export { buildBasicAuthHeader } from './utils.js';
|
|
29
|
-
export { ok, err, getErrorMessage, pickFields, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
|
|
28
|
+
export { ok, err, getErrorMessage, pickFields, normalizeEnum, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
|
|
30
29
|
export type { Result, RetryConfig, OnRequestCallback, ClientConfig, Cache, CacheStore, CacheGetOptions } from '@markwharton/api-core';
|
|
31
30
|
export { EH_API_BASE, EH_REGION_URLS } from './constants.js';
|
|
32
31
|
export type { EHRegion } from './constants.js';
|
package/dist/index.js
CHANGED
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
// Main client
|
|
23
23
|
export { EHClient } from './client.js';
|
|
24
24
|
// Field definitions (for pickFields)
|
|
25
|
-
export {
|
|
25
|
+
export { EMPLOYEE_FIELDS, LEAVE_REQUEST_FIELDS, LOCATION_FIELDS, EMPLOYEE_GROUP_FIELDS, ROSTER_SHIFT_FIELDS, KIOSK_FIELDS, KIOSK_EMPLOYEE_FIELDS, ENTITIES, } from './types.js';
|
|
26
26
|
export { METHOD_TIERS } from './types.js';
|
|
27
27
|
// Utilities
|
|
28
28
|
export { buildBasicAuthHeader } from './utils.js';
|
|
29
29
|
// Re-exported from @markwharton/api-core
|
|
30
|
-
export { ok, err, getErrorMessage, pickFields, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
|
|
30
|
+
export { ok, err, getErrorMessage, pickFields, normalizeEnum, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
|
|
31
31
|
// Constants
|
|
32
32
|
export { EH_API_BASE, EH_REGION_URLS } from './constants.js';
|
|
33
33
|
// Errors
|
package/dist/types.d.ts
CHANGED
|
@@ -53,11 +53,10 @@ export interface EHConfig extends ClientConfig {
|
|
|
53
53
|
* Employee from unstructured endpoint
|
|
54
54
|
*
|
|
55
55
|
* Region-specific types are generated from Swagger specs.
|
|
56
|
-
* EHEmployee is an alias for EHAuEmployee for backward compatibility.
|
|
57
56
|
*
|
|
58
57
|
* @see employee-types.generated.ts
|
|
59
58
|
*/
|
|
60
|
-
export type {
|
|
59
|
+
export type { EHEmployee } from './employee-types.generated.js';
|
|
61
60
|
/**
|
|
62
61
|
* Standard hours for an employee
|
|
63
62
|
*
|
|
@@ -204,8 +203,17 @@ export interface EHLeaveRequest {
|
|
|
204
203
|
/** Status: Approved, Pending, Rejected, Cancelled */
|
|
205
204
|
status: string;
|
|
206
205
|
}
|
|
207
|
-
/**
|
|
208
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Employee profile image
|
|
208
|
+
*
|
|
209
|
+
* From GET /business/{id}/employee/{eid}/image
|
|
210
|
+
* Returns binary data with content type.
|
|
211
|
+
*/
|
|
212
|
+
export interface EHEmployeeImage {
|
|
213
|
+
/** Image data as ArrayBuffer */
|
|
214
|
+
data: ArrayBuffer;
|
|
215
|
+
/** Content type from response header (e.g., 'image/png') */
|
|
216
|
+
contentType: string;
|
|
209
217
|
}
|
|
210
218
|
/** Leave request status values */
|
|
211
219
|
export type EHLeaveRequestStatus = 'Approved' | 'Pending' | 'Rejected' | 'Cancelled';
|
|
@@ -227,6 +235,10 @@ export interface EHLeaveRequestOptions {
|
|
|
227
235
|
leaveCategoryId?: number;
|
|
228
236
|
/** Filter by location ID (→ API LocationId) */
|
|
229
237
|
locationId?: number;
|
|
238
|
+
/** Group results by 'Employee' or 'LeaveType' (→ API GroupBy) */
|
|
239
|
+
groupBy?: 'Employee' | 'LeaveType';
|
|
240
|
+
/** Restrict results to leave overlapping the date range (→ API RestrictOverlappingLeave) */
|
|
241
|
+
restrictOverlappingLeave?: boolean;
|
|
230
242
|
}
|
|
231
243
|
/**
|
|
232
244
|
* Options for getEmployeeLeaveRequests
|
|
@@ -405,8 +417,8 @@ export declare const ROSTER_SHIFT_FIELDS: {
|
|
|
405
417
|
readonly published: true;
|
|
406
418
|
readonly accepted: true;
|
|
407
419
|
};
|
|
408
|
-
/** Fields for
|
|
409
|
-
export declare const
|
|
420
|
+
/** Fields for EHEmployee — set false to exclude from API responses */
|
|
421
|
+
export declare const EMPLOYEE_FIELDS: {
|
|
410
422
|
readonly id: true;
|
|
411
423
|
readonly externalId: true;
|
|
412
424
|
readonly firstName: true;
|
package/dist/types.js
CHANGED
|
@@ -41,8 +41,8 @@ export const ROSTER_SHIFT_FIELDS = {
|
|
|
41
41
|
workTypeId: true, workTypeName: true, startTime: true, endTime: true,
|
|
42
42
|
notes: true, published: true, accepted: true,
|
|
43
43
|
};
|
|
44
|
-
/** Fields for
|
|
45
|
-
export const
|
|
44
|
+
/** Fields for EHEmployee — set false to exclude from API responses */
|
|
45
|
+
export const EMPLOYEE_FIELDS = {
|
|
46
46
|
// Identity
|
|
47
47
|
id: true, externalId: true, firstName: true, surname: true, status: true,
|
|
48
48
|
// Dates
|
|
@@ -111,7 +111,7 @@ export const AU_EMPLOYEE_FIELDS = {
|
|
|
111
111
|
};
|
|
112
112
|
/** Entity registry — maps interface names to field specs and API path segments. */
|
|
113
113
|
export const ENTITIES = {
|
|
114
|
-
EHAuEmployee: { fields:
|
|
114
|
+
EHAuEmployee: { fields: EMPLOYEE_FIELDS, path: 'employee/unstructured', apiRef: 'employee/au-employee--get-employees', apiRefById: 'employee/au-employee--get-employee-by-id' },
|
|
115
115
|
EHLeaveRequest: { fields: LEAVE_REQUEST_FIELDS, path: 'leaverequest', apiRef: 'leave-requests/au-business-hours-leave-request--list-leave-requests' },
|
|
116
116
|
EHEmployeeLeaveRequest: { fields: LEAVE_REQUEST_FIELDS, path: 'employee/{employeeId}/leaverequest', apiRef: 'leave-requests/au-hours-leave-request--get-leave-requests' },
|
|
117
117
|
EHLocation: { fields: LOCATION_FIELDS, path: 'location', apiRef: 'location/au-location--get-locations' },
|
|
@@ -138,5 +138,6 @@ export const METHOD_TIERS = {
|
|
|
138
138
|
getLeaveRequests: 'restricted',
|
|
139
139
|
getEmployeeLeaveRequests: 'restricted',
|
|
140
140
|
getEmployee: 'restricted',
|
|
141
|
+
getEmployeeImage: 'restricted',
|
|
141
142
|
getStandardHours: 'restricted',
|
|
142
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markwharton/eh-payroll",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Employment Hero Payroll API client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"clean": "rm -rf dist"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@markwharton/api-core": "^1.6.
|
|
19
|
+
"@markwharton/api-core": "^1.6.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^20.10.0",
|