@brownandroot/api 0.1.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/index.d.ts +60 -0
- package/dist/index.js +38 -0
- package/package.json +24 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Employee type matching the API response shape.
|
|
3
|
+
*/
|
|
4
|
+
export interface Employee {
|
|
5
|
+
employeeId: number | null;
|
|
6
|
+
name: string | null;
|
|
7
|
+
email: string | null;
|
|
8
|
+
badgeNumber: string | null;
|
|
9
|
+
employementStatus: string | null;
|
|
10
|
+
residentTaxArea: string | null;
|
|
11
|
+
workTaxArea: string | null;
|
|
12
|
+
company: string | null;
|
|
13
|
+
businessUnitId: string | null;
|
|
14
|
+
hbu: string | null;
|
|
15
|
+
checkRouteCode: string | null;
|
|
16
|
+
employeePayStatus: string | null;
|
|
17
|
+
payFrequency: string | null;
|
|
18
|
+
payClass: string | null;
|
|
19
|
+
jobType: string | null;
|
|
20
|
+
jobStep: string | null;
|
|
21
|
+
workSchedule: string | null;
|
|
22
|
+
shift: string | null;
|
|
23
|
+
termDate: string | null;
|
|
24
|
+
hireDate: string | null;
|
|
25
|
+
securityLevel: string | null;
|
|
26
|
+
reportingLevel: string | null;
|
|
27
|
+
recordType: string | null;
|
|
28
|
+
payCycleCode: string | null;
|
|
29
|
+
dateTimeStamps: string | null;
|
|
30
|
+
benefitGroup: string | null;
|
|
31
|
+
supervisor: number | null;
|
|
32
|
+
adjustedServiceDate: string | null;
|
|
33
|
+
departmentCode: string | null;
|
|
34
|
+
dateUpdated: string | null;
|
|
35
|
+
nccerNumber: string | null;
|
|
36
|
+
mentor: number | null;
|
|
37
|
+
source: string | null;
|
|
38
|
+
createdAt: string | null;
|
|
39
|
+
updatedAt: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface ApiHubClientOptions {
|
|
42
|
+
baseUrl: string;
|
|
43
|
+
apiKey: string;
|
|
44
|
+
}
|
|
45
|
+
export declare class ApiHubClient {
|
|
46
|
+
private baseUrl;
|
|
47
|
+
private apiKey;
|
|
48
|
+
constructor(options: ApiHubClientOptions);
|
|
49
|
+
private request;
|
|
50
|
+
/** Get all employees */
|
|
51
|
+
getEmployees(): Promise<Employee[]>;
|
|
52
|
+
/** Get a single employee by employeeId */
|
|
53
|
+
getEmployee(employeeId: number): Promise<Employee>;
|
|
54
|
+
/** Search employees by name (case-insensitive partial match) */
|
|
55
|
+
searchByName(name: string): Promise<Employee[]>;
|
|
56
|
+
/** Get all employees reporting to a supervisor */
|
|
57
|
+
getBySupervisor(supervisorId: number): Promise<Employee[]>;
|
|
58
|
+
/** Get the supervisor chain above an employee */
|
|
59
|
+
getSupervisorChain(employeeId: number): Promise<Employee[]>;
|
|
60
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class ApiHubClient {
|
|
2
|
+
baseUrl;
|
|
3
|
+
apiKey;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, '');
|
|
6
|
+
this.apiKey = options.apiKey;
|
|
7
|
+
}
|
|
8
|
+
async request(path) {
|
|
9
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
10
|
+
headers: { 'x-api-key': this.apiKey },
|
|
11
|
+
});
|
|
12
|
+
if (!res.ok) {
|
|
13
|
+
const body = await res.json().catch(() => ({}));
|
|
14
|
+
throw new Error(body.error ?? `Request failed: ${res.status}`);
|
|
15
|
+
}
|
|
16
|
+
return res.json();
|
|
17
|
+
}
|
|
18
|
+
/** Get all employees */
|
|
19
|
+
async getEmployees() {
|
|
20
|
+
return this.request('/employees');
|
|
21
|
+
}
|
|
22
|
+
/** Get a single employee by employeeId */
|
|
23
|
+
async getEmployee(employeeId) {
|
|
24
|
+
return this.request(`/employees/${employeeId}`);
|
|
25
|
+
}
|
|
26
|
+
/** Search employees by name (case-insensitive partial match) */
|
|
27
|
+
async searchByName(name) {
|
|
28
|
+
return this.request(`/employees/search?name=${encodeURIComponent(name)}`);
|
|
29
|
+
}
|
|
30
|
+
/** Get all employees reporting to a supervisor */
|
|
31
|
+
async getBySupervisor(supervisorId) {
|
|
32
|
+
return this.request(`/employees/by-supervisor/${supervisorId}`);
|
|
33
|
+
}
|
|
34
|
+
/** Get the supervisor chain above an employee */
|
|
35
|
+
async getSupervisorChain(employeeId) {
|
|
36
|
+
return this.request(`/employees/${employeeId}/supervisor-chain`);
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brownandroot/api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"publish:manual": "npm publish --access public"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|