@markwharton/eh-payroll 3.0.1 → 3.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/dist/errors.d.ts CHANGED
@@ -11,7 +11,7 @@ import type { ParsedError } from '@markwharton/api-core';
11
11
  /**
12
12
  * Parsed EH error response
13
13
  */
14
- export type EHPayrollParsedError = ParsedError;
14
+ export type PayrollParsedError = ParsedError;
15
15
  /**
16
16
  * Parse EH API error response text into a human-readable message.
17
17
  *
@@ -22,16 +22,16 @@ export type EHPayrollParsedError = ParsedError;
22
22
  * @param status - HTTP status code
23
23
  * @returns Parsed error with message
24
24
  */
25
- export declare function parseEHPayrollErrorResponse(errorText: string, status: number): EHPayrollParsedError;
25
+ export declare function parsePayrollErrorResponse(errorText: string, status: number): PayrollParsedError;
26
26
  /**
27
27
  * Custom error class for EH API errors
28
28
  */
29
- export declare class EHPayrollError extends ApiError {
29
+ export declare class PayrollError extends ApiError {
30
30
  constructor(message: string, status: number, options?: {
31
31
  rawResponse?: string;
32
32
  });
33
33
  /**
34
- * Create an EHPayrollError from an API response
34
+ * Create an PayrollError from an API response
35
35
  */
36
- static fromResponse(status: number, responseText: string): EHPayrollError;
36
+ static fromResponse(status: number, responseText: string): PayrollError;
37
37
  }
package/dist/errors.js CHANGED
@@ -17,23 +17,23 @@ import { ApiError, parseJsonErrorResponse } from '@markwharton/api-core';
17
17
  * @param status - HTTP status code
18
18
  * @returns Parsed error with message
19
19
  */
20
- export function parseEHPayrollErrorResponse(errorText, status) {
20
+ export function parsePayrollErrorResponse(errorText, status) {
21
21
  return parseJsonErrorResponse(errorText, status);
22
22
  }
23
23
  /**
24
24
  * Custom error class for EH API errors
25
25
  */
26
- export class EHPayrollError extends ApiError {
26
+ export class PayrollError extends ApiError {
27
27
  constructor(message, status, options) {
28
28
  super(message, status, options);
29
- this.name = 'EHPayrollError';
29
+ this.name = 'PayrollError';
30
30
  }
31
31
  /**
32
- * Create an EHPayrollError from an API response
32
+ * Create an PayrollError from an API response
33
33
  */
34
34
  static fromResponse(status, responseText) {
35
- const parsed = parseEHPayrollErrorResponse(responseText, status);
36
- return new EHPayrollError(parsed.message, status, {
35
+ const parsed = parsePayrollErrorResponse(responseText, status);
36
+ return new PayrollError(parsed.message, status, {
37
37
  rawResponse: responseText,
38
38
  });
39
39
  }
package/dist/index.d.ts CHANGED
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * @example
7
7
  * ```typescript
8
- * import { EHClient } from '@markwharton/eh-payroll';
8
+ * import { PayrollClient } from '@markwharton/eh-payroll';
9
9
  *
10
- * const client = new EHClient({ apiKey: 'xxx', businessId: 123 });
10
+ * const client = new PayrollClient({ apiKey: 'xxx', businessId: 123 });
11
11
  *
12
12
  * // Validate credentials
13
13
  * await client.validateApiKey();
@@ -19,15 +19,22 @@
19
19
  * const { data: rosterShifts } = await client.getRosterShifts('2026-02-03', '2026-02-09');
20
20
  * ```
21
21
  */
22
- export { EHClient } from './client.js';
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';
22
+ export { PayrollClient } from './client.js';
23
+ export type { PayrollConfig, PayrollCacheConfig, PayrollRetryConfig, PayrollLeaveRequest, PayrollLeaveRequestOptions, PayrollLeaveRequestGroupBy, PayrollEmployeeLeaveRequestOptions, PayrollLeaveRequestStatus, PayrollEmployee, PayrollEmployeeStatus, PayrollLeaveAccrualStartDateType, PayrollCloselyHeldReporting, PayrollMedicareLevySurchargeWithholdingTier, PayrollSingleTouchPayrollCategory, PayrollTaxCategory, PayrollEmployeeOptions, PayrollStandardHours, PayrollLocation, PayrollEmployeeGroup, PayrollRosterShift, PayrollRosterShiftOptions, PayrollShiftStatus, PayrollAttendanceStatus, PayrollKiosk, PayrollKioskEmployee, PayrollKioskStaffOptions, PayrollEmployeeImage, } from './types.js';
24
+ export { PAYROLL_EMPLOYEE_FIELDS, PAYROLL_LEAVE_REQUEST_FIELDS, PAYROLL_LOCATION_FIELDS, PAYROLL_EMPLOYEE_GROUP_FIELDS, PAYROLL_ROSTER_SHIFT_FIELDS, PAYROLL_KIOSK_FIELDS, PAYROLL_KIOSK_EMPLOYEE_FIELDS, ENTITIES, } from './types.js';
25
25
  export type { AccessTier } from './types.js';
26
26
  export { METHOD_TIERS } from './types.js';
27
27
  export { buildBasicAuthHeader } from './utils.js';
28
28
  export { ok, err, getErrorMessage, pickFields, normalizeEnum, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
29
29
  export type { Result, RetryConfig, OnRequestCallback, ClientConfig, Cache, CacheStore, CacheGetOptions } from '@markwharton/api-core';
30
- export { EH_API_BASE, EH_REGION_URLS } from './constants.js';
31
- export type { EHRegion } from './constants.js';
32
- export { EHPayrollError, parseEHPayrollErrorResponse } from './errors.js';
33
- export type { EHPayrollParsedError } from './errors.js';
30
+ export { PAYROLL_API_BASE, PAYROLL_REGION_URLS } from './constants.js';
31
+ export type { PayrollRegion } from './constants.js';
32
+ export { PayrollError, parsePayrollErrorResponse } from './errors.js';
33
+ export type { PayrollParsedError } from './errors.js';
34
+ export { PayrollClient as EHClient } from './client.js';
35
+ export type { PayrollConfig as EHConfig, PayrollCacheConfig as EHCacheConfig, PayrollRetryConfig as EHRetryConfig, PayrollLeaveRequest as EHLeaveRequest, PayrollLeaveRequestOptions as EHLeaveRequestOptions, PayrollLeaveRequestGroupBy as EHLeaveRequestGroupBy, PayrollEmployeeLeaveRequestOptions as EHEmployeeLeaveRequestOptions, PayrollLeaveRequestStatus as EHLeaveRequestStatus, PayrollEmployee as EHEmployee, PayrollEmployeeStatus as EHEmployeeStatus, PayrollLeaveAccrualStartDateType as EHLeaveAccrualStartDateType, PayrollCloselyHeldReporting as EHCloselyHeldReporting, PayrollMedicareLevySurchargeWithholdingTier as EHMedicareLevySurchargeWithholdingTier, PayrollSingleTouchPayrollCategory as EHSingleTouchPayrollCategory, PayrollTaxCategory as EHTaxCategory, PayrollEmployeeOptions as EHEmployeeOptions, PayrollStandardHours as EHStandardHours, PayrollLocation as EHLocation, PayrollEmployeeGroup as EHEmployeeGroup, PayrollRosterShift as EHRosterShift, PayrollRosterShiftOptions as EHRosterShiftOptions, PayrollShiftStatus as EHShiftStatus, PayrollAttendanceStatus as EHAttendanceStatus, PayrollKiosk as EHKiosk, PayrollKioskEmployee as EHKioskEmployee, PayrollKioskStaffOptions as EHKioskStaffOptions, PayrollEmployeeImage as EHEmployeeImage, } from './types.js';
36
+ export { PAYROLL_EMPLOYEE_FIELDS as EMPLOYEE_FIELDS, PAYROLL_LEAVE_REQUEST_FIELDS as LEAVE_REQUEST_FIELDS, PAYROLL_LOCATION_FIELDS as LOCATION_FIELDS, PAYROLL_EMPLOYEE_GROUP_FIELDS as EMPLOYEE_GROUP_FIELDS, PAYROLL_ROSTER_SHIFT_FIELDS as ROSTER_SHIFT_FIELDS, PAYROLL_KIOSK_FIELDS as KIOSK_FIELDS, PAYROLL_KIOSK_EMPLOYEE_FIELDS as KIOSK_EMPLOYEE_FIELDS, } from './types.js';
37
+ export { PAYROLL_API_BASE as EH_API_BASE, PAYROLL_REGION_URLS as EH_REGION_URLS } from './constants.js';
38
+ export type { PayrollRegion as EHRegion } from './constants.js';
39
+ export { PayrollError as EHPayrollError, parsePayrollErrorResponse as parseEHPayrollErrorResponse } from './errors.js';
40
+ export type { PayrollParsedError as EHPayrollParsedError } from './errors.js';
package/dist/index.js CHANGED
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * @example
7
7
  * ```typescript
8
- * import { EHClient } from '@markwharton/eh-payroll';
8
+ * import { PayrollClient } from '@markwharton/eh-payroll';
9
9
  *
10
- * const client = new EHClient({ apiKey: 'xxx', businessId: 123 });
10
+ * const client = new PayrollClient({ apiKey: 'xxx', businessId: 123 });
11
11
  *
12
12
  * // Validate credentials
13
13
  * await client.validateApiKey();
@@ -20,15 +20,26 @@
20
20
  * ```
21
21
  */
22
22
  // Main client
23
- export { EHClient } from './client.js';
23
+ export { PayrollClient } from './client.js';
24
24
  // Field definitions (for pickFields)
25
- export { EMPLOYEE_FIELDS, LEAVE_REQUEST_FIELDS, LOCATION_FIELDS, EMPLOYEE_GROUP_FIELDS, ROSTER_SHIFT_FIELDS, KIOSK_FIELDS, KIOSK_EMPLOYEE_FIELDS, ENTITIES, } from './types.js';
25
+ export { PAYROLL_EMPLOYEE_FIELDS, PAYROLL_LEAVE_REQUEST_FIELDS, PAYROLL_LOCATION_FIELDS, PAYROLL_EMPLOYEE_GROUP_FIELDS, PAYROLL_ROSTER_SHIFT_FIELDS, PAYROLL_KIOSK_FIELDS, PAYROLL_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
30
  export { ok, err, getErrorMessage, pickFields, normalizeEnum, RateLimiter, TTLCache, MemoryCacheStore, LayeredCache } from '@markwharton/api-core';
31
31
  // Constants
32
- export { EH_API_BASE, EH_REGION_URLS } from './constants.js';
32
+ export { PAYROLL_API_BASE, PAYROLL_REGION_URLS } from './constants.js';
33
33
  // Errors
34
- export { EHPayrollError, parseEHPayrollErrorResponse } from './errors.js';
34
+ export { PayrollError, parsePayrollErrorResponse } from './errors.js';
35
+ // ============================================================================
36
+ // Backward compatibility aliases (deprecated — use Payroll* names)
37
+ // ============================================================================
38
+ // Client
39
+ export { PayrollClient as EHClient } from './client.js';
40
+ // Field definitions
41
+ export { PAYROLL_EMPLOYEE_FIELDS as EMPLOYEE_FIELDS, PAYROLL_LEAVE_REQUEST_FIELDS as LEAVE_REQUEST_FIELDS, PAYROLL_LOCATION_FIELDS as LOCATION_FIELDS, PAYROLL_EMPLOYEE_GROUP_FIELDS as EMPLOYEE_GROUP_FIELDS, PAYROLL_ROSTER_SHIFT_FIELDS as ROSTER_SHIFT_FIELDS, PAYROLL_KIOSK_FIELDS as KIOSK_FIELDS, PAYROLL_KIOSK_EMPLOYEE_FIELDS as KIOSK_EMPLOYEE_FIELDS, } from './types.js';
42
+ // Constants
43
+ export { PAYROLL_API_BASE as EH_API_BASE, PAYROLL_REGION_URLS as EH_REGION_URLS } from './constants.js';
44
+ // Errors
45
+ export { PayrollError as EHPayrollError, parsePayrollErrorResponse as parseEHPayrollErrorResponse } from './errors.js';
package/dist/types.d.ts CHANGED
@@ -4,15 +4,15 @@
4
4
  * Types for the Employment Hero Payroll (KeyPay) API.
5
5
  * Based on the API reference and KeyPay .NET SDK models.
6
6
  */
7
- import type { EHRegion } from './constants.js';
7
+ import type { PayrollRegion } from './constants.js';
8
8
  import type { RetryConfig, ClientConfig } from '@markwharton/api-core';
9
9
  /**
10
- * Cache configuration for EHClient
10
+ * Cache configuration for PayrollClient
11
11
  *
12
- * When provided to EHConfig, enables in-memory TTL caching of API responses.
12
+ * When provided to PayrollConfig, enables in-memory TTL caching of API responses.
13
13
  * All TTL values are in milliseconds. Omit individual TTLs to use defaults.
14
14
  */
15
- export interface EHCacheConfig {
15
+ export interface PayrollCacheConfig {
16
16
  /** TTL for employee list (default: 300000 = 5 min) */
17
17
  employeesTtl?: number;
18
18
  /** TTL for leave requests (default: 120000 = 2 min) */
@@ -31,19 +31,19 @@ export interface EHCacheConfig {
31
31
  kioskStaffTtl?: number;
32
32
  }
33
33
  /** @deprecated Use `RetryConfig` from `@markwharton/api-core` directly. */
34
- export type EHRetryConfig = RetryConfig;
34
+ export type PayrollRetryConfig = RetryConfig;
35
35
  /**
36
36
  * Employment Hero Payroll configuration for API access
37
37
  */
38
- export interface EHConfig extends ClientConfig {
38
+ export interface PayrollConfig extends ClientConfig {
39
39
  /** API key for authentication (used as Basic Auth username) */
40
40
  apiKey: string;
41
41
  /** Business ID to operate on */
42
42
  businessId: number;
43
43
  /** API region (default: 'au'). Sets the base URL automatically. */
44
- region?: EHRegion;
44
+ region?: PayrollRegion;
45
45
  /** Enable caching with optional TTL overrides. Omit to disable caching. */
46
- cache?: EHCacheConfig;
46
+ cache?: PayrollCacheConfig;
47
47
  /** Max requests per second (default: 5 per API spec). Set 0 to disable. */
48
48
  rateLimitPerSecond?: number;
49
49
  /** Whether to persist restricted-tier data in persistent cache stores (default: true). Set false to keep restricted data in memory only. */
@@ -56,14 +56,14 @@ export interface EHConfig extends ClientConfig {
56
56
  *
57
57
  * @see employee-types.generated.ts
58
58
  */
59
- export type { EHEmployee } from './employee-types.generated.js';
59
+ export type { PayrollEmployee, PayrollEmployeeStatus, PayrollLeaveAccrualStartDateType, PayrollCloselyHeldReporting, PayrollMedicareLevySurchargeWithholdingTier, PayrollSingleTouchPayrollCategory, PayrollTaxCategory, } from './employee-types.generated.js';
60
60
  /**
61
61
  * Standard hours for an employee
62
62
  *
63
63
  * From GET /business/{id}/employee/{eid}/standardhours
64
64
  * Contains the FullTimeEquivalentHours field needed for FTE calculations.
65
65
  */
66
- export interface EHStandardHours {
66
+ export interface PayrollStandardHours {
67
67
  /** Employee ID */
68
68
  employeeId: number;
69
69
  /** Standard hours per week */
@@ -78,7 +78,7 @@ export interface EHStandardHours {
78
78
  *
79
79
  * From GET /business/{id}/location
80
80
  */
81
- export interface EHLocation {
81
+ export interface PayrollLocation {
82
82
  /** Location ID */
83
83
  id: number;
84
84
  /** Parent location ID (for hierarchy) */
@@ -101,7 +101,7 @@ export interface EHLocation {
101
101
  /**
102
102
  * Employee group
103
103
  */
104
- export interface EHEmployeeGroup {
104
+ export interface PayrollEmployeeGroup {
105
105
  /** Group ID */
106
106
  id: number;
107
107
  /** Group name */
@@ -112,7 +112,7 @@ export interface EHEmployeeGroup {
112
112
  *
113
113
  * From GET /business/{id}/rostershift
114
114
  */
115
- export interface EHRosterShift {
115
+ export interface PayrollRosterShift {
116
116
  /** Shift ID */
117
117
  id: number;
118
118
  /** Employee ID (null for unassigned shifts) */
@@ -141,13 +141,13 @@ export interface EHRosterShift {
141
141
  /**
142
142
  * Time and attendance status
143
143
  */
144
- export type EHAttendanceStatus = 'NotClockedOn' | 'ClockedOn' | 'OnBreak' | 'ClockedOff';
144
+ export type PayrollAttendanceStatus = 'NotClockedOn' | 'ClockedOn' | 'OnBreak' | 'ClockedOff';
145
145
  /**
146
146
  * Kiosk employee from time and attendance
147
147
  *
148
148
  * From GET /business/{id}/kiosk/{kid}/staff
149
149
  */
150
- export interface EHKioskEmployee {
150
+ export interface PayrollKioskEmployee {
151
151
  /** Employee ID */
152
152
  employeeId: number;
153
153
  /** First name */
@@ -157,7 +157,7 @@ export interface EHKioskEmployee {
157
157
  /** Full name */
158
158
  name: string | null;
159
159
  /** Attendance status */
160
- status: EHAttendanceStatus;
160
+ status: PayrollAttendanceStatus;
161
161
  /** Clock-on time in UTC */
162
162
  clockOnTimeUtc: string | null;
163
163
  /** Break start time in UTC */
@@ -179,7 +179,7 @@ export interface EHKioskEmployee {
179
179
  * From GET /business/{id}/leaverequest
180
180
  * Fields from Swagger HourLeaveRequestResponseModel.
181
181
  */
182
- export interface EHLeaveRequest {
182
+ export interface PayrollLeaveRequest {
183
183
  /** Leave request ID */
184
184
  id: number;
185
185
  /** Employee ID */
@@ -209,26 +209,28 @@ export interface EHLeaveRequest {
209
209
  * From GET /business/{id}/employee/{eid}/image
210
210
  * Returns binary data with content type.
211
211
  */
212
- export interface EHEmployeeImage {
212
+ export interface PayrollEmployeeImage {
213
213
  /** Image data as ArrayBuffer */
214
214
  data: ArrayBuffer;
215
215
  /** Content type from response header (e.g., 'image/png') */
216
216
  contentType: string;
217
217
  }
218
218
  /** Leave request status values */
219
- export type EHLeaveRequestStatus = 'Approved' | 'Pending' | 'Rejected' | 'Cancelled';
219
+ export type PayrollLeaveRequestStatus = 'Approved' | 'Pending' | 'Rejected' | 'Cancelled';
220
+ /** Leave request grouping options */
221
+ export type PayrollLeaveRequestGroupBy = 'Employee' | 'LeaveType';
220
222
  /**
221
223
  * Options for getLeaveRequests
222
224
  *
223
225
  * All filters are passed server-side to the API.
224
226
  */
225
- export interface EHLeaveRequestOptions {
227
+ export interface PayrollLeaveRequestOptions {
226
228
  /** Filter by start date (ISO 8601 date-time → API FromDate) */
227
229
  fromDate?: string;
228
230
  /** Filter by end date (ISO 8601 date-time → API ToDate) */
229
231
  toDate?: string;
230
232
  /** Filter by status (→ API Status) */
231
- status?: EHLeaveRequestStatus;
233
+ status?: PayrollLeaveRequestStatus;
232
234
  /** Filter by employee ID (→ API EmployeeId) */
233
235
  employeeId?: number;
234
236
  /** Filter by leave category ID (→ API LeaveCategoryId) */
@@ -236,7 +238,7 @@ export interface EHLeaveRequestOptions {
236
238
  /** Filter by location ID (→ API LocationId) */
237
239
  locationId?: number;
238
240
  /** Group results by 'Employee' or 'LeaveType' (→ API GroupBy) */
239
- groupBy?: 'Employee' | 'LeaveType';
241
+ groupBy?: PayrollLeaveRequestGroupBy;
240
242
  /** Restrict results to leave overlapping the date range (→ API RestrictOverlappingLeave) */
241
243
  restrictOverlappingLeave?: boolean;
242
244
  }
@@ -245,9 +247,9 @@ export interface EHLeaveRequestOptions {
245
247
  *
246
248
  * Filters are passed as OData $filter to the per-employee endpoint.
247
249
  */
248
- export interface EHEmployeeLeaveRequestOptions {
250
+ export interface PayrollEmployeeLeaveRequestOptions {
249
251
  /** Filter by status */
250
- status?: EHLeaveRequestStatus;
252
+ status?: PayrollLeaveRequestStatus;
251
253
  /** Filter by start date (ISO 8601 date-time) */
252
254
  fromDate?: string;
253
255
  /** Filter by end date (ISO 8601 date-time) */
@@ -256,16 +258,18 @@ export interface EHEmployeeLeaveRequestOptions {
256
258
  /**
257
259
  * Options for getEmployees
258
260
  */
259
- export interface EHEmployeeOptions {
261
+ export interface PayrollEmployeeOptions {
260
262
  /** Filter by pay schedule ID */
261
263
  payScheduleId?: number;
262
264
  /** Filter by location ID */
263
265
  locationId?: number;
264
266
  }
267
+ /** Roster shift status filter values */
268
+ export type PayrollShiftStatus = 'All' | 'Published' | 'Unpublished' | 'Accepted';
265
269
  /**
266
270
  * Options for getRosterShifts
267
271
  */
268
- export interface EHRosterShiftOptions {
272
+ export interface PayrollRosterShiftOptions {
269
273
  /** Filter by employee ID */
270
274
  employeeId?: number;
271
275
  /** Filter by location ID */
@@ -275,9 +279,9 @@ export interface EHRosterShiftOptions {
275
279
  /** Include shifts with all roles (default: only unassigned roles) */
276
280
  selectAllRoles?: boolean;
277
281
  /** Filter by single shift status */
278
- shiftStatus?: 'All' | 'Published' | 'Unpublished' | 'Accepted';
282
+ shiftStatus?: PayrollShiftStatus;
279
283
  /** Filter by multiple shift statuses */
280
- shiftStatuses?: ('All' | 'Published' | 'Unpublished' | 'Accepted')[];
284
+ shiftStatuses?: PayrollShiftStatus[];
281
285
  /** Filter by specific locations (multiple) */
282
286
  selectedLocations?: string[];
283
287
  /** Filter by specific employees (multiple) */
@@ -296,7 +300,7 @@ export interface EHRosterShiftOptions {
296
300
  *
297
301
  * From GET /business/{id}/kiosk
298
302
  */
299
- export interface EHKiosk {
303
+ export interface PayrollKiosk {
300
304
  /** Kiosk ID */
301
305
  id: number;
302
306
  /** External identifier */
@@ -333,12 +337,12 @@ export interface EHKiosk {
333
337
  /**
334
338
  * Options for getKioskStaff
335
339
  */
336
- export interface EHKioskStaffOptions {
340
+ export interface PayrollKioskStaffOptions {
337
341
  /** Restrict current shifts to current kiosk location (default: false) */
338
342
  restrictCurrentShiftsToCurrentKioskLocation?: boolean;
339
343
  }
340
- /** Fields for EHLeaveRequest — set false to exclude from API responses */
341
- export declare const LEAVE_REQUEST_FIELDS: {
344
+ /** Fields for PayrollLeaveRequest — set false to exclude from API responses */
345
+ export declare const PAYROLL_LEAVE_REQUEST_FIELDS: {
342
346
  readonly id: true;
343
347
  readonly employeeId: true;
344
348
  readonly leaveCategoryId: true;
@@ -351,8 +355,8 @@ export declare const LEAVE_REQUEST_FIELDS: {
351
355
  readonly notes: true;
352
356
  readonly status: true;
353
357
  };
354
- /** Fields for EHLocation — set false to exclude from API responses */
355
- export declare const LOCATION_FIELDS: {
358
+ /** Fields for PayrollLocation — set false to exclude from API responses */
359
+ export declare const PAYROLL_LOCATION_FIELDS: {
356
360
  readonly id: true;
357
361
  readonly parentId: true;
358
362
  readonly name: true;
@@ -363,8 +367,8 @@ export declare const LOCATION_FIELDS: {
363
367
  readonly state: true;
364
368
  readonly country: true;
365
369
  };
366
- /** Fields for EHKiosk — set false to exclude from API responses */
367
- export declare const KIOSK_FIELDS: {
370
+ /** Fields for PayrollKiosk — set false to exclude from API responses */
371
+ export declare const PAYROLL_KIOSK_FIELDS: {
368
372
  readonly id: true;
369
373
  readonly externalId: true;
370
374
  readonly name: true;
@@ -382,8 +386,8 @@ export declare const KIOSK_FIELDS: {
382
386
  readonly canAddEmployees: true;
383
387
  readonly paidBreaksEnabled: true;
384
388
  };
385
- /** Fields for EHKioskEmployee — set false to exclude from API responses */
386
- export declare const KIOSK_EMPLOYEE_FIELDS: {
389
+ /** Fields for PayrollKioskEmployee — set false to exclude from API responses */
390
+ export declare const PAYROLL_KIOSK_EMPLOYEE_FIELDS: {
387
391
  readonly employeeId: true;
388
392
  readonly firstName: true;
389
393
  readonly surname: true;
@@ -397,13 +401,13 @@ export declare const KIOSK_EMPLOYEE_FIELDS: {
397
401
  readonly longShift: true;
398
402
  readonly recordedTimeUtc: true;
399
403
  };
400
- /** Fields for EHEmployeeGroup — set false to exclude from API responses */
401
- export declare const EMPLOYEE_GROUP_FIELDS: {
404
+ /** Fields for PayrollEmployeeGroup — set false to exclude from API responses */
405
+ export declare const PAYROLL_EMPLOYEE_GROUP_FIELDS: {
402
406
  readonly id: true;
403
407
  readonly name: true;
404
408
  };
405
- /** Fields for EHRosterShift — set false to exclude from API responses */
406
- export declare const ROSTER_SHIFT_FIELDS: {
409
+ /** Fields for PayrollRosterShift — set false to exclude from API responses */
410
+ export declare const PAYROLL_ROSTER_SHIFT_FIELDS: {
407
411
  readonly id: true;
408
412
  readonly employeeId: true;
409
413
  readonly employeeName: true;
@@ -417,8 +421,8 @@ export declare const ROSTER_SHIFT_FIELDS: {
417
421
  readonly published: true;
418
422
  readonly accepted: true;
419
423
  };
420
- /** Fields for EHEmployee — set false to exclude from API responses */
421
- export declare const EMPLOYEE_FIELDS: {
424
+ /** Fields for PayrollEmployee — set false to exclude from API responses */
425
+ export declare const PAYROLL_EMPLOYEE_FIELDS: {
422
426
  readonly id: true;
423
427
  readonly externalId: true;
424
428
  readonly firstName: true;
package/dist/types.js CHANGED
@@ -7,42 +7,42 @@
7
7
  // ============================================================================
8
8
  // Field Definitions (for pickFields)
9
9
  // ============================================================================
10
- /** Fields for EHLeaveRequest — set false to exclude from API responses */
11
- export const LEAVE_REQUEST_FIELDS = {
10
+ /** Fields for PayrollLeaveRequest — set false to exclude from API responses */
11
+ export const PAYROLL_LEAVE_REQUEST_FIELDS = {
12
12
  id: true, employeeId: true, leaveCategoryId: true, employee: true, leaveCategory: true,
13
13
  fromDate: true, toDate: true, totalHours: true, hoursApplied: true, notes: true, status: true,
14
14
  };
15
- /** Fields for EHLocation — set false to exclude from API responses */
16
- export const LOCATION_FIELDS = {
15
+ /** Fields for PayrollLocation — set false to exclude from API responses */
16
+ export const PAYROLL_LOCATION_FIELDS = {
17
17
  id: true, parentId: true, name: true, externalId: true, source: true,
18
18
  fullyQualifiedName: true, isGlobal: true, state: true, country: true,
19
19
  };
20
- /** Fields for EHKiosk — set false to exclude from API responses */
21
- export const KIOSK_FIELDS = {
20
+ /** Fields for PayrollKiosk — set false to exclude from API responses */
21
+ export const PAYROLL_KIOSK_FIELDS = {
22
22
  id: true, externalId: true, name: true, locationId: true, timeZone: true, ianaTimeZone: true,
23
23
  allowHigherClassificationSelection: true, isLocationRequired: true, isWorkTypeRequired: true,
24
24
  restrictLocationsForEmployees: true, allowEmployeeShiftSelection: true,
25
25
  clockOnWindowMinutes: true, clockOffWindowMinutes: true,
26
26
  isPhotoRequired: true, canAddEmployees: true, paidBreaksEnabled: true,
27
27
  };
28
- /** Fields for EHKioskEmployee — set false to exclude from API responses */
29
- export const KIOSK_EMPLOYEE_FIELDS = {
28
+ /** Fields for PayrollKioskEmployee — set false to exclude from API responses */
29
+ export const PAYROLL_KIOSK_EMPLOYEE_FIELDS = {
30
30
  employeeId: true, firstName: true, surname: true, name: true, status: true,
31
31
  clockOnTimeUtc: true, breakStartTimeUtc: true, currentShiftId: true,
32
32
  employeeStartDate: true, employeeGroupIds: true, longShift: true, recordedTimeUtc: true,
33
33
  };
34
- /** Fields for EHEmployeeGroup — set false to exclude from API responses */
35
- export const EMPLOYEE_GROUP_FIELDS = {
34
+ /** Fields for PayrollEmployeeGroup — set false to exclude from API responses */
35
+ export const PAYROLL_EMPLOYEE_GROUP_FIELDS = {
36
36
  id: true, name: true,
37
37
  };
38
- /** Fields for EHRosterShift — set false to exclude from API responses */
39
- export const ROSTER_SHIFT_FIELDS = {
38
+ /** Fields for PayrollRosterShift — set false to exclude from API responses */
39
+ export const PAYROLL_ROSTER_SHIFT_FIELDS = {
40
40
  id: true, employeeId: true, employeeName: true, locationId: true, locationName: true,
41
41
  workTypeId: true, workTypeName: true, startTime: true, endTime: true,
42
42
  notes: true, published: true, accepted: true,
43
43
  };
44
- /** Fields for EHEmployee — set false to exclude from API responses */
45
- export const EMPLOYEE_FIELDS = {
44
+ /** Fields for PayrollEmployee — set false to exclude from API responses */
45
+ export const PAYROLL_EMPLOYEE_FIELDS = {
46
46
  // Identity
47
47
  id: true, externalId: true, firstName: true, surname: true, status: true,
48
48
  // Dates
@@ -111,15 +111,15 @@ export const EMPLOYEE_FIELDS = {
111
111
  };
112
112
  /** Entity registry — maps interface names to field specs and API path segments. */
113
113
  export const ENTITIES = {
114
- EHEmployee: { fields: EMPLOYEE_FIELDS, path: 'employee/unstructured', apiRef: 'employee/au-employee--get-employees', apiRefById: 'employee/au-employee--get-employee-by-id' },
115
- EHLeaveRequest: { fields: LEAVE_REQUEST_FIELDS, path: 'leaverequest', apiRef: 'leave-requests/au-business-hours-leave-request--list-leave-requests' },
116
- EHEmployeeLeaveRequest: { fields: LEAVE_REQUEST_FIELDS, path: 'employee/{employeeId}/leaverequest', apiRef: 'leave-requests/au-hours-leave-request--get-leave-requests' },
117
- EHLocation: { fields: LOCATION_FIELDS, path: 'location', apiRef: 'location/au-location--get-locations' },
118
- EHRosterShift: { fields: ROSTER_SHIFT_FIELDS, path: 'rostershift', apiRef: 'roster-shifts/au-roster-shift--get' },
119
- EHKiosk: { fields: KIOSK_FIELDS, path: 'kiosk', apiRef: 'time-and-attendance/kiosk--get-all' },
120
- EHKioskEmployee: { fields: KIOSK_EMPLOYEE_FIELDS, path: 'kiosk/{kioskId}/staff', apiRef: 'time-and-attendance/generic-time-and-attendance--get-staff' },
121
- EHEmployeeGroup: { fields: EMPLOYEE_GROUP_FIELDS, path: 'employeegroup', apiRef: 'employee-groups/au-employee-group--get-groups' },
122
- EHStandardHours: { path: 'employee/{employeeId}/standardhours', apiRef: 'employee/au-employee-standard-hours--get' },
114
+ PayrollEmployee: { fields: PAYROLL_EMPLOYEE_FIELDS, path: 'employee/unstructured', apiRef: 'employee/au-employee--get-employees', apiRefById: 'employee/au-employee--get-employee-by-id' },
115
+ PayrollLeaveRequest: { fields: PAYROLL_LEAVE_REQUEST_FIELDS, path: 'leaverequest', apiRef: 'leave-requests/au-business-hours-leave-request--list-leave-requests' },
116
+ PayrollEmployeeLeaveRequest: { fields: PAYROLL_LEAVE_REQUEST_FIELDS, path: 'employee/{employeeId}/leaverequest', apiRef: 'leave-requests/au-hours-leave-request--get-leave-requests' },
117
+ PayrollLocation: { fields: PAYROLL_LOCATION_FIELDS, path: 'location', apiRef: 'location/au-location--get-locations' },
118
+ PayrollRosterShift: { fields: PAYROLL_ROSTER_SHIFT_FIELDS, path: 'rostershift', apiRef: 'roster-shifts/au-roster-shift--get' },
119
+ PayrollKiosk: { fields: PAYROLL_KIOSK_FIELDS, path: 'kiosk', apiRef: 'time-and-attendance/kiosk--get-all' },
120
+ PayrollKioskEmployee: { fields: PAYROLL_KIOSK_EMPLOYEE_FIELDS, path: 'kiosk/{kioskId}/staff', apiRef: 'time-and-attendance/generic-time-and-attendance--get-staff' },
121
+ PayrollEmployeeGroup: { fields: PAYROLL_EMPLOYEE_GROUP_FIELDS, path: 'employeegroup', apiRef: 'employee-groups/au-employee-group--get-groups' },
122
+ PayrollStandardHours: { path: 'employee/{employeeId}/standardhours', apiRef: 'employee/au-employee-standard-hours--get' },
123
123
  };
124
124
  /**
125
125
  * Access tier for each data method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markwharton/eh-payroll",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "description": "Employment Hero Payroll API client",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/dist/cache.d.ts DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * Simple in-memory TTL cache with request coalescing
3
- *
4
- * Provides per-instance memoization for EHClient API responses.
5
- * In serverless environments (Azure Functions, Static Web Apps),
6
- * module-level state persists across warm invocations within the
7
- * same instance — this cache leverages that behavior.
8
- *
9
- * Request coalescing: when multiple concurrent callers request the
10
- * same expired key, only one factory call is made. All callers
11
- * receive the same resolved value (or the same rejection).
12
- *
13
- * Not a distributed cache: each instance has its own cache.
14
- * Cold starts and instance recycling naturally clear stale data.
15
- */
16
- export declare class TTLCache {
17
- private store;
18
- private inflight;
19
- /**
20
- * Get a cached value, or call the factory to populate it.
21
- *
22
- * If a factory call is already in progress for this key,
23
- * returns the existing promise instead of starting a duplicate.
24
- *
25
- * @param key - Cache key
26
- * @param ttlMs - Time-to-live in milliseconds
27
- * @param factory - Async function to produce the value on cache miss
28
- */
29
- get<T>(key: string, ttlMs: number, factory: () => Promise<T>): Promise<T>;
30
- /**
31
- * Invalidate cache entries matching a key prefix.
32
- */
33
- invalidate(prefix: string): void;
34
- /**
35
- * Clear all cached data and in-flight requests.
36
- */
37
- clear(): void;
38
- }
package/dist/cache.js DELETED
@@ -1,73 +0,0 @@
1
- /**
2
- * Simple in-memory TTL cache with request coalescing
3
- *
4
- * Provides per-instance memoization for EHClient API responses.
5
- * In serverless environments (Azure Functions, Static Web Apps),
6
- * module-level state persists across warm invocations within the
7
- * same instance — this cache leverages that behavior.
8
- *
9
- * Request coalescing: when multiple concurrent callers request the
10
- * same expired key, only one factory call is made. All callers
11
- * receive the same resolved value (or the same rejection).
12
- *
13
- * Not a distributed cache: each instance has its own cache.
14
- * Cold starts and instance recycling naturally clear stale data.
15
- */
16
- export class TTLCache {
17
- constructor() {
18
- this.store = new Map();
19
- this.inflight = new Map();
20
- }
21
- /**
22
- * Get a cached value, or call the factory to populate it.
23
- *
24
- * If a factory call is already in progress for this key,
25
- * returns the existing promise instead of starting a duplicate.
26
- *
27
- * @param key - Cache key
28
- * @param ttlMs - Time-to-live in milliseconds
29
- * @param factory - Async function to produce the value on cache miss
30
- */
31
- async get(key, ttlMs, factory) {
32
- const existing = this.store.get(key);
33
- if (existing && existing.expiresAt > Date.now()) {
34
- return existing.data;
35
- }
36
- const pending = this.inflight.get(key);
37
- if (pending) {
38
- return pending;
39
- }
40
- const promise = factory().then((data) => {
41
- this.store.set(key, { data, expiresAt: Date.now() + ttlMs });
42
- this.inflight.delete(key);
43
- return data;
44
- }, (err) => {
45
- this.inflight.delete(key);
46
- throw err;
47
- });
48
- this.inflight.set(key, promise);
49
- return promise;
50
- }
51
- /**
52
- * Invalidate cache entries matching a key prefix.
53
- */
54
- invalidate(prefix) {
55
- for (const key of this.store.keys()) {
56
- if (key.startsWith(prefix)) {
57
- this.store.delete(key);
58
- }
59
- }
60
- for (const key of this.inflight.keys()) {
61
- if (key.startsWith(prefix)) {
62
- this.inflight.delete(key);
63
- }
64
- }
65
- }
66
- /**
67
- * Clear all cached data and in-flight requests.
68
- */
69
- clear() {
70
- this.store.clear();
71
- this.inflight.clear();
72
- }
73
- }