@brownandroot/api 0.2.4 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @brownandroot/api
2
+
3
+ TypeScript client for the Brown & Root APIHub employee data service.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @brownandroot/api
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ ```typescript
14
+ import { ApiHubClient } from '@brownandroot/api'
15
+
16
+ const client = new ApiHubClient({
17
+ baseUrl: 'https://your-apihub-url.com',
18
+ apiKey: 'your-api-key',
19
+ })
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Get all employees
25
+
26
+ ```typescript
27
+ const employees = await client.getEmployees()
28
+ ```
29
+
30
+ ### Get a single employee
31
+
32
+ ```typescript
33
+ const employee = await client.getEmployee(12345)
34
+ ```
35
+
36
+ ### Search by name
37
+
38
+ Case-insensitive partial match:
39
+
40
+ ```typescript
41
+ const results = await client.searchByName('John')
42
+ ```
43
+
44
+ ### Get employees by supervisor
45
+
46
+ ```typescript
47
+ const reports = await client.getBySupervisor(12345)
48
+ ```
49
+
50
+ ### Get supervisor chain
51
+
52
+ Returns the chain of supervisors above an employee (excludes the employee themselves):
53
+
54
+ ```typescript
55
+ const chain = await client.getSupervisorChain(12345)
56
+ // [directSupervisor, theirSupervisor, ...]
57
+ ```
58
+
59
+ ## Types
60
+
61
+ The package exports the `Employee` interface and `ApiHubClientOptions`:
62
+
63
+ ```typescript
64
+ import type { Employee, ApiHubClientOptions } from '@brownandroot/api'
65
+ ```
66
+
67
+ ## Error Handling
68
+
69
+ Methods throw an `Error` when the API returns a non-OK response. The error message contains the server's error detail or the HTTP status code.
70
+
71
+ ```typescript
72
+ try {
73
+ const emp = await client.getEmployee(99999)
74
+ } catch (err) {
75
+ console.error(err.message) // "Employee not found"
76
+ }
77
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brownandroot/api",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",