@brownandroot/api 0.4.1 → 0.5.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 +41 -0
- package/dist/index.js +31 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,11 +42,41 @@ export interface ApiHubClientOptions {
|
|
|
42
42
|
baseUrl: string;
|
|
43
43
|
apiKey: string;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* LLM log entry matching the API response shape.
|
|
47
|
+
*/
|
|
48
|
+
export interface LlmLog {
|
|
49
|
+
id: number;
|
|
50
|
+
source: string;
|
|
51
|
+
user: string;
|
|
52
|
+
function: string | null;
|
|
53
|
+
tokensIn: number | null;
|
|
54
|
+
tokensOut: number | null;
|
|
55
|
+
totalTokens: number | null;
|
|
56
|
+
createdAt: string | null;
|
|
57
|
+
}
|
|
58
|
+
export interface CreateLlmLogInput {
|
|
59
|
+
source: string;
|
|
60
|
+
user: string;
|
|
61
|
+
function?: string;
|
|
62
|
+
tokensIn?: number;
|
|
63
|
+
tokensOut?: number;
|
|
64
|
+
totalTokens?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface UpdateLlmLogInput {
|
|
67
|
+
source?: string;
|
|
68
|
+
user?: string;
|
|
69
|
+
function?: string;
|
|
70
|
+
tokensIn?: number;
|
|
71
|
+
tokensOut?: number;
|
|
72
|
+
totalTokens?: number;
|
|
73
|
+
}
|
|
45
74
|
export declare class ApiHubClient {
|
|
46
75
|
private baseUrl;
|
|
47
76
|
private apiKey;
|
|
48
77
|
constructor(options: ApiHubClientOptions);
|
|
49
78
|
private request;
|
|
79
|
+
private requestWithBody;
|
|
50
80
|
/** Get all employees */
|
|
51
81
|
getEmployees(): Promise<Employee[]>;
|
|
52
82
|
/** Get a single employee by employeeId */
|
|
@@ -59,4 +89,15 @@ export declare class ApiHubClient {
|
|
|
59
89
|
searchByEmail(email: string): Promise<Employee[]>;
|
|
60
90
|
/** Get the supervisor chain above an employee */
|
|
61
91
|
getSupervisorChain(employeeId: number): Promise<Employee[]>;
|
|
92
|
+
/** Look up JDE number and employee data from email (with JDEService/CoreService fallback) */
|
|
93
|
+
getJdeFromEmail(email: string): Promise<{
|
|
94
|
+
jde: string | null;
|
|
95
|
+
employee: Employee | null;
|
|
96
|
+
}>;
|
|
97
|
+
/** List all LLM log entries (newest first) */
|
|
98
|
+
getLlmLogs(): Promise<LlmLog[]>;
|
|
99
|
+
/** Create a new LLM log entry */
|
|
100
|
+
createLlmLog(input: CreateLlmLogInput): Promise<LlmLog>;
|
|
101
|
+
/** Update an existing LLM log entry */
|
|
102
|
+
updateLlmLog(id: number, input: UpdateLlmLogInput): Promise<LlmLog>;
|
|
62
103
|
}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,18 @@ export class ApiHubClient {
|
|
|
15
15
|
}
|
|
16
16
|
return res.json();
|
|
17
17
|
}
|
|
18
|
+
async requestWithBody(path, method, body) {
|
|
19
|
+
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
20
|
+
method,
|
|
21
|
+
headers: { 'x-api-key': this.apiKey, 'Content-Type': 'application/json' },
|
|
22
|
+
body: JSON.stringify(body),
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
const respBody = await res.json().catch(() => ({}));
|
|
26
|
+
throw new Error(respBody.error ?? `Request failed: ${res.status}`);
|
|
27
|
+
}
|
|
28
|
+
return res.json();
|
|
29
|
+
}
|
|
18
30
|
/** Get all employees */
|
|
19
31
|
async getEmployees() {
|
|
20
32
|
return this.request('/employees');
|
|
@@ -39,4 +51,23 @@ export class ApiHubClient {
|
|
|
39
51
|
async getSupervisorChain(employeeId) {
|
|
40
52
|
return this.request(`/employees/${employeeId}/supervisor-chain`);
|
|
41
53
|
}
|
|
54
|
+
/** Look up JDE number and employee data from email (with JDEService/CoreService fallback) */
|
|
55
|
+
async getJdeFromEmail(email) {
|
|
56
|
+
return this.request(`/employees/jde-from-email/${encodeURIComponent(email)}`);
|
|
57
|
+
}
|
|
58
|
+
// -----------------------------------------------------------------------
|
|
59
|
+
// LLM Logs
|
|
60
|
+
// -----------------------------------------------------------------------
|
|
61
|
+
/** List all LLM log entries (newest first) */
|
|
62
|
+
async getLlmLogs() {
|
|
63
|
+
return this.request('/llm-logs');
|
|
64
|
+
}
|
|
65
|
+
/** Create a new LLM log entry */
|
|
66
|
+
async createLlmLog(input) {
|
|
67
|
+
return this.requestWithBody('/llm-logs', 'POST', input);
|
|
68
|
+
}
|
|
69
|
+
/** Update an existing LLM log entry */
|
|
70
|
+
async updateLlmLog(id, input) {
|
|
71
|
+
return this.requestWithBody(`/llm-logs/${id}`, 'PATCH', input);
|
|
72
|
+
}
|
|
42
73
|
}
|