@markwharton/eh-payroll 1.1.1 → 1.2.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 CHANGED
@@ -29,10 +29,10 @@ const { employees } = await client.getEmployees();
29
29
  const { employees: filtered } = await client.getEmployees({ locationId: 5 });
30
30
 
31
31
  // Get roster shifts for a date range (auto-paginates)
32
- const { shifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
32
+ const { rosterShifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
33
33
 
34
34
  // Get roster shifts with filters
35
- const { shifts: published } = await client.getRosterShifts('2026-02-03', '2026-02-09', {
35
+ const { rosterShifts: published } = await client.getRosterShifts('2026-02-03', '2026-02-09', {
36
36
  employeeId: 42,
37
37
  shiftStatus: 'Published',
38
38
  selectAllRoles: true
@@ -42,7 +42,7 @@ const { shifts: published } = await client.getRosterShifts('2026-02-03', '2026-0
42
42
  const { staff } = await client.getKioskStaff(kioskId);
43
43
 
44
44
  // Get employee groups
45
- const { groups } = await client.getEmployeeGroups();
45
+ const { employeeGroups } = await client.getEmployeeGroups();
46
46
 
47
47
  // Get standard hours for an employee (includes FTE value)
48
48
  const { standardHours } = await client.getStandardHours(employeeId);
@@ -66,15 +66,15 @@ All methods return `{ data?, error? }` result objects rather than throwing excep
66
66
  | `getEmployees(options?)` | `EHEmployeeOptions?` | `{ employees?, error? }` |
67
67
  | `getEmployee(employeeId)` | `number` | `{ employee?, error? }` |
68
68
  | `getStandardHours(employeeId)` | `number` | `{ standardHours?, error? }` |
69
- | `getEmployeeGroups()` | — | `{ groups?, error? }` |
70
- | `getRosterShifts(from, to, options?)` | `string, string, EHRosterShiftOptions?` | `{ shifts?, error? }` |
69
+ | `getEmployeeGroups()` | — | `{ employeeGroups?, error? }` |
70
+ | `getRosterShifts(from, to, options?)` | `string, string, EHRosterShiftOptions?` | `{ rosterShifts?, error? }` |
71
71
  | `getKioskStaff(kioskId, options?)` | `number, EHKioskStaffOptions?` | `{ staff?, error? }` |
72
72
  | `getReportFields()` | — | `{ fields?, error? }` |
73
73
  | `getEmployeeDetailsReport(options?)` | `EHEmployeeDetailsReportOptions?` | `{ records?, error? }` |
74
74
 
75
75
  ### `getRosterShifts()`
76
76
 
77
- Automatically paginates through all results (100 per page). Returns the complete set of shifts for the requested date range. All filter options are applied server-side, reducing the number of results and pages fetched.
77
+ Automatically paginates through all results (100 per page). Returns the complete set of roster shifts for the requested date range. All filter options are applied server-side, reducing the number of results and pages fetched.
78
78
 
79
79
  ### Query Parameter Casing
80
80
 
package/dist/client.d.ts CHANGED
@@ -83,7 +83,7 @@ export declare class EHClient {
83
83
  * Get all employee groups
84
84
  */
85
85
  getEmployeeGroups(): Promise<{
86
- groups?: EHEmployeeGroup[];
86
+ employeeGroups?: EHEmployeeGroup[];
87
87
  error?: EHErrorInfo;
88
88
  }>;
89
89
  /**
@@ -94,7 +94,7 @@ export declare class EHClient {
94
94
  * @param options - Optional filters
95
95
  */
96
96
  getRosterShifts(fromDate: string, toDate: string, options?: EHRosterShiftOptions): Promise<{
97
- shifts?: EHRosterShift[];
97
+ rosterShifts?: EHRosterShift[];
98
98
  error?: EHErrorInfo;
99
99
  }>;
100
100
  /**
package/dist/client.js CHANGED
@@ -46,6 +46,7 @@ export class EHClient {
46
46
  groupsTtl: config.cache?.groupsTtl ?? 300000,
47
47
  standardHoursTtl: config.cache?.standardHoursTtl ?? 300000,
48
48
  rosterShiftsTtl: config.cache?.rosterShiftsTtl ?? 120000,
49
+ kioskStaffTtl: config.cache?.kioskStaffTtl ?? 60000,
49
50
  reportFieldsTtl: config.cache?.reportFieldsTtl ?? 600000,
50
51
  };
51
52
  // Initialize retry config with defaults if provided
@@ -234,7 +235,7 @@ export class EHClient {
234
235
  * Get all employee groups
235
236
  */
236
237
  async getEmployeeGroups() {
237
- return this.cached('groups', this.cacheTtl.groupsTtl, async () => {
238
+ return this.cached('employeeGroups', this.cacheTtl.groupsTtl, async () => {
238
239
  const params = new URLSearchParams({
239
240
  '$top': String(DEFAULT_PAGE_SIZE),
240
241
  });
@@ -257,7 +258,7 @@ export class EHClient {
257
258
  break;
258
259
  skip += DEFAULT_PAGE_SIZE;
259
260
  }
260
- return { groups: allGroups };
261
+ return { employeeGroups: allGroups };
261
262
  }
262
263
  catch (error) {
263
264
  return { error: { message: getErrorMessage(error), statusCode: 0 } };
@@ -361,7 +362,7 @@ export class EHClient {
361
362
  break;
362
363
  currentPage++;
363
364
  }
364
- return { shifts: allShifts };
365
+ return { rosterShifts: allShifts };
365
366
  }
366
367
  catch (error) {
367
368
  return { error: { message: getErrorMessage(error), statusCode: 0 } };
@@ -378,19 +379,24 @@ export class EHClient {
378
379
  * @param options - Optional query parameters
379
380
  */
380
381
  async getKioskStaff(kioskId, options) {
381
- const params = new URLSearchParams();
382
- if (options?.restrictCurrentShiftsToCurrentKioskLocation) {
383
- params.set('restrictCurrentShiftsToCurrentKioskLocation', 'true');
384
- }
385
- const queryString = params.toString();
386
- const url = queryString
387
- ? `${this.baseUrl}/business/${this.businessId}/kiosk/${kioskId}/staff?${queryString}`
388
- : `${this.baseUrl}/business/${this.businessId}/kiosk/${kioskId}/staff`;
389
- const { data, error } = await this.fetchAndParse(url, async (r) => {
390
- return (await r.json())
391
- .map(item => pickFields(item, KIOSK_EMPLOYEE_FIELDS));
382
+ const cacheKey = options?.restrictCurrentShiftsToCurrentKioskLocation
383
+ ? `kiosk:${kioskId}:rcs`
384
+ : `kiosk:${kioskId}`;
385
+ return this.cached(cacheKey, this.cacheTtl.kioskStaffTtl, async () => {
386
+ const params = new URLSearchParams();
387
+ if (options?.restrictCurrentShiftsToCurrentKioskLocation) {
388
+ params.set('restrictCurrentShiftsToCurrentKioskLocation', 'true');
389
+ }
390
+ const queryString = params.toString();
391
+ const url = queryString
392
+ ? `${this.baseUrl}/business/${this.businessId}/kiosk/${kioskId}/staff?${queryString}`
393
+ : `${this.baseUrl}/business/${this.businessId}/kiosk/${kioskId}/staff`;
394
+ const { data, error } = await this.fetchAndParse(url, async (r) => {
395
+ return (await r.json())
396
+ .map(item => pickFields(item, KIOSK_EMPLOYEE_FIELDS));
397
+ });
398
+ return error ? { error } : { staff: data };
392
399
  });
393
- return error ? { error } : { staff: data };
394
400
  }
395
401
  // ============================================================================
396
402
  // Employee Details Report
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * const { employees } = await client.getEmployees();
17
17
  *
18
18
  * // Get roster shifts
19
- * const { shifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
19
+ * const { rosterShifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
20
20
  * ```
21
21
  */
22
22
  export { EHClient } from './client.js';
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * const { employees } = await client.getEmployees();
17
17
  *
18
18
  * // Get roster shifts
19
- * const { shifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
19
+ * const { rosterShifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
20
20
  * ```
21
21
  */
22
22
  // Main client
package/dist/types.d.ts CHANGED
@@ -20,6 +20,8 @@ export interface EHCacheConfig {
20
20
  standardHoursTtl?: number;
21
21
  /** TTL for roster shifts (default: 120000 = 2 min) */
22
22
  rosterShiftsTtl?: number;
23
+ /** TTL for kiosk staff (default: 60000 = 1 min) */
24
+ kioskStaffTtl?: number;
23
25
  /** TTL for report fields (default: 600000 = 10 min) */
24
26
  reportFieldsTtl?: number;
25
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markwharton/eh-payroll",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Employment Hero Payroll API client",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",