@brownandroot/api 0.4.1 → 0.6.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 +142 -0
- package/dist/index.js +121 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,11 +42,117 @@ 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
|
+
}
|
|
74
|
+
export interface BusinessUnit {
|
|
75
|
+
id: string;
|
|
76
|
+
companyId: string;
|
|
77
|
+
description: string;
|
|
78
|
+
clientId: string | null;
|
|
79
|
+
clientDescription: string | null;
|
|
80
|
+
workOrderRequired: boolean;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
expirationDate: string | null;
|
|
83
|
+
createdBy: string;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedBy: string | null;
|
|
86
|
+
updatedAt: string | null;
|
|
87
|
+
subsector: string | null;
|
|
88
|
+
}
|
|
89
|
+
export interface Costcode {
|
|
90
|
+
id: string;
|
|
91
|
+
jdeCostCode: string | null;
|
|
92
|
+
description: string | null;
|
|
93
|
+
businessUnitId: string;
|
|
94
|
+
objectAccount: string | null;
|
|
95
|
+
suba: string | null;
|
|
96
|
+
isActive: boolean;
|
|
97
|
+
expirationDate: string | null;
|
|
98
|
+
createdBy: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
updatedBy: string | null;
|
|
101
|
+
updatedAt: string | null;
|
|
102
|
+
billFlag: string | null;
|
|
103
|
+
entryEffectiveDate: string | null;
|
|
104
|
+
entryFlag: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface Paytype {
|
|
107
|
+
id: string;
|
|
108
|
+
companyCode: string | null;
|
|
109
|
+
payClass: string | null;
|
|
110
|
+
description: string;
|
|
111
|
+
isActive: boolean;
|
|
112
|
+
sortOrder: string | null;
|
|
113
|
+
objectAccount: string | null;
|
|
114
|
+
category: string | null;
|
|
115
|
+
perDiemPayType: boolean;
|
|
116
|
+
type: string | null;
|
|
117
|
+
}
|
|
118
|
+
export interface Shift {
|
|
119
|
+
drky: string;
|
|
120
|
+
drsy: string | null;
|
|
121
|
+
drrt: string | null;
|
|
122
|
+
drdl01: string | null;
|
|
123
|
+
drdl02: string | null;
|
|
124
|
+
drsphd: string | null;
|
|
125
|
+
drudco: string | null;
|
|
126
|
+
drhrdc: string | null;
|
|
127
|
+
druser: string | null;
|
|
128
|
+
drpid: string | null;
|
|
129
|
+
drumpmj: string | null;
|
|
130
|
+
drjobn: string | null;
|
|
131
|
+
drupmt: string | null;
|
|
132
|
+
}
|
|
133
|
+
export interface Workorder {
|
|
134
|
+
id: string;
|
|
135
|
+
businessUnitId: string;
|
|
136
|
+
costCodeId: string | null;
|
|
137
|
+
clientWorkOrderId: string | null;
|
|
138
|
+
description: string | null;
|
|
139
|
+
completed: boolean;
|
|
140
|
+
area: string | null;
|
|
141
|
+
isActive: boolean;
|
|
142
|
+
expirationDate: string | null;
|
|
143
|
+
createdBy: string;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
updatedBy: string | null;
|
|
146
|
+
updatedAt: string | null;
|
|
147
|
+
parentWorkOrder: string | null;
|
|
148
|
+
workOrder2: string | null;
|
|
149
|
+
}
|
|
45
150
|
export declare class ApiHubClient {
|
|
46
151
|
private baseUrl;
|
|
47
152
|
private apiKey;
|
|
48
153
|
constructor(options: ApiHubClientOptions);
|
|
49
154
|
private request;
|
|
155
|
+
private requestWithBody;
|
|
50
156
|
/** Get all employees */
|
|
51
157
|
getEmployees(): Promise<Employee[]>;
|
|
52
158
|
/** Get a single employee by employeeId */
|
|
@@ -59,4 +165,40 @@ export declare class ApiHubClient {
|
|
|
59
165
|
searchByEmail(email: string): Promise<Employee[]>;
|
|
60
166
|
/** Get the supervisor chain above an employee */
|
|
61
167
|
getSupervisorChain(employeeId: number): Promise<Employee[]>;
|
|
168
|
+
/** Look up JDE number and employee data from email (with JDEService/CoreService fallback) */
|
|
169
|
+
getJdeFromEmail(email: string): Promise<{
|
|
170
|
+
jde: string | null;
|
|
171
|
+
employee: Employee | null;
|
|
172
|
+
}>;
|
|
173
|
+
/** List all LLM log entries (newest first) */
|
|
174
|
+
getLlmLogs(): Promise<LlmLog[]>;
|
|
175
|
+
/** Create a new LLM log entry */
|
|
176
|
+
createLlmLog(input: CreateLlmLogInput): Promise<LlmLog>;
|
|
177
|
+
/** Update an existing LLM log entry */
|
|
178
|
+
updateLlmLog(id: number, input: UpdateLlmLogInput): Promise<LlmLog>;
|
|
179
|
+
getBusinessUnits(): Promise<BusinessUnit[]>;
|
|
180
|
+
getBusinessUnit(id: string): Promise<BusinessUnit>;
|
|
181
|
+
createBusinessUnit(input: Partial<BusinessUnit>): Promise<BusinessUnit>;
|
|
182
|
+
updateBusinessUnit(id: string, input: Partial<BusinessUnit>): Promise<BusinessUnit>;
|
|
183
|
+
deleteBusinessUnit(id: string): Promise<BusinessUnit>;
|
|
184
|
+
getCostcodes(): Promise<Costcode[]>;
|
|
185
|
+
getCostcode(id: string): Promise<Costcode>;
|
|
186
|
+
createCostcode(input: Partial<Costcode>): Promise<Costcode>;
|
|
187
|
+
updateCostcode(id: string, input: Partial<Costcode>): Promise<Costcode>;
|
|
188
|
+
deleteCostcode(id: string): Promise<Costcode>;
|
|
189
|
+
getPaytypes(): Promise<Paytype[]>;
|
|
190
|
+
getPaytype(id: string): Promise<Paytype>;
|
|
191
|
+
createPaytype(input: Partial<Paytype>): Promise<Paytype>;
|
|
192
|
+
updatePaytype(id: string, input: Partial<Paytype>): Promise<Paytype>;
|
|
193
|
+
deletePaytype(id: string): Promise<Paytype>;
|
|
194
|
+
getShifts(): Promise<Shift[]>;
|
|
195
|
+
getShift(id: string): Promise<Shift>;
|
|
196
|
+
createShift(input: Partial<Shift>): Promise<Shift>;
|
|
197
|
+
updateShift(id: string, input: Partial<Shift>): Promise<Shift>;
|
|
198
|
+
deleteShift(id: string): Promise<Shift>;
|
|
199
|
+
getWorkorders(): Promise<Workorder[]>;
|
|
200
|
+
getWorkorder(id: string): Promise<Workorder>;
|
|
201
|
+
createWorkorder(input: Partial<Workorder>): Promise<Workorder>;
|
|
202
|
+
updateWorkorder(id: string, input: Partial<Workorder>): Promise<Workorder>;
|
|
203
|
+
deleteWorkorder(id: string): Promise<Workorder>;
|
|
62
204
|
}
|
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,113 @@ 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
|
+
}
|
|
73
|
+
// -----------------------------------------------------------------------
|
|
74
|
+
// Business Units
|
|
75
|
+
// -----------------------------------------------------------------------
|
|
76
|
+
async getBusinessUnits() {
|
|
77
|
+
return this.request('/business-units');
|
|
78
|
+
}
|
|
79
|
+
async getBusinessUnit(id) {
|
|
80
|
+
return this.request(`/business-units/${encodeURIComponent(id)}`);
|
|
81
|
+
}
|
|
82
|
+
async createBusinessUnit(input) {
|
|
83
|
+
return this.requestWithBody('/business-units', 'POST', input);
|
|
84
|
+
}
|
|
85
|
+
async updateBusinessUnit(id, input) {
|
|
86
|
+
return this.requestWithBody(`/business-units/${encodeURIComponent(id)}`, 'PATCH', input);
|
|
87
|
+
}
|
|
88
|
+
async deleteBusinessUnit(id) {
|
|
89
|
+
return this.requestWithBody(`/business-units/${encodeURIComponent(id)}`, 'DELETE', {});
|
|
90
|
+
}
|
|
91
|
+
// -----------------------------------------------------------------------
|
|
92
|
+
// Cost Codes
|
|
93
|
+
// -----------------------------------------------------------------------
|
|
94
|
+
async getCostcodes() {
|
|
95
|
+
return this.request('/costcodes');
|
|
96
|
+
}
|
|
97
|
+
async getCostcode(id) {
|
|
98
|
+
return this.request(`/costcodes/${encodeURIComponent(id)}`);
|
|
99
|
+
}
|
|
100
|
+
async createCostcode(input) {
|
|
101
|
+
return this.requestWithBody('/costcodes', 'POST', input);
|
|
102
|
+
}
|
|
103
|
+
async updateCostcode(id, input) {
|
|
104
|
+
return this.requestWithBody(`/costcodes/${encodeURIComponent(id)}`, 'PATCH', input);
|
|
105
|
+
}
|
|
106
|
+
async deleteCostcode(id) {
|
|
107
|
+
return this.requestWithBody(`/costcodes/${encodeURIComponent(id)}`, 'DELETE', {});
|
|
108
|
+
}
|
|
109
|
+
// -----------------------------------------------------------------------
|
|
110
|
+
// Pay Types
|
|
111
|
+
// -----------------------------------------------------------------------
|
|
112
|
+
async getPaytypes() {
|
|
113
|
+
return this.request('/paytypes');
|
|
114
|
+
}
|
|
115
|
+
async getPaytype(id) {
|
|
116
|
+
return this.request(`/paytypes/${encodeURIComponent(id)}`);
|
|
117
|
+
}
|
|
118
|
+
async createPaytype(input) {
|
|
119
|
+
return this.requestWithBody('/paytypes', 'POST', input);
|
|
120
|
+
}
|
|
121
|
+
async updatePaytype(id, input) {
|
|
122
|
+
return this.requestWithBody(`/paytypes/${encodeURIComponent(id)}`, 'PATCH', input);
|
|
123
|
+
}
|
|
124
|
+
async deletePaytype(id) {
|
|
125
|
+
return this.requestWithBody(`/paytypes/${encodeURIComponent(id)}`, 'DELETE', {});
|
|
126
|
+
}
|
|
127
|
+
// -----------------------------------------------------------------------
|
|
128
|
+
// Shifts
|
|
129
|
+
// -----------------------------------------------------------------------
|
|
130
|
+
async getShifts() {
|
|
131
|
+
return this.request('/shifts');
|
|
132
|
+
}
|
|
133
|
+
async getShift(id) {
|
|
134
|
+
return this.request(`/shifts/${encodeURIComponent(id)}`);
|
|
135
|
+
}
|
|
136
|
+
async createShift(input) {
|
|
137
|
+
return this.requestWithBody('/shifts', 'POST', input);
|
|
138
|
+
}
|
|
139
|
+
async updateShift(id, input) {
|
|
140
|
+
return this.requestWithBody(`/shifts/${encodeURIComponent(id)}`, 'PATCH', input);
|
|
141
|
+
}
|
|
142
|
+
async deleteShift(id) {
|
|
143
|
+
return this.requestWithBody(`/shifts/${encodeURIComponent(id)}`, 'DELETE', {});
|
|
144
|
+
}
|
|
145
|
+
// -----------------------------------------------------------------------
|
|
146
|
+
// Work Orders
|
|
147
|
+
// -----------------------------------------------------------------------
|
|
148
|
+
async getWorkorders() {
|
|
149
|
+
return this.request('/workorders');
|
|
150
|
+
}
|
|
151
|
+
async getWorkorder(id) {
|
|
152
|
+
return this.request(`/workorders/${encodeURIComponent(id)}`);
|
|
153
|
+
}
|
|
154
|
+
async createWorkorder(input) {
|
|
155
|
+
return this.requestWithBody('/workorders', 'POST', input);
|
|
156
|
+
}
|
|
157
|
+
async updateWorkorder(id, input) {
|
|
158
|
+
return this.requestWithBody(`/workorders/${encodeURIComponent(id)}`, 'PATCH', input);
|
|
159
|
+
}
|
|
160
|
+
async deleteWorkorder(id) {
|
|
161
|
+
return this.requestWithBody(`/workorders/${encodeURIComponent(id)}`, 'DELETE', {});
|
|
162
|
+
}
|
|
42
163
|
}
|