@brownandroot/api 0.15.0 → 1.0.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/README.md +15 -3
- package/dist/businessUnits.remote.d.ts +4 -0
- package/dist/businessUnits.remote.js +7 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +21 -0
- package/dist/costcodes.remote.d.ts +6 -0
- package/dist/costcodes.remote.js +13 -0
- package/dist/employees.remote.d.ts +10 -0
- package/dist/employees.remote.js +20 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/dist/jobtypejobsteps.remote.d.ts +3 -0
- package/dist/jobtypejobsteps.remote.js +6 -0
- package/dist/llm.remote.d.ts +2 -0
- package/dist/llm.remote.js +17 -0
- package/dist/paytypes.remote.d.ts +4 -0
- package/dist/paytypes.remote.js +7 -0
- package/dist/rag.remote.d.ts +4 -0
- package/dist/rag.remote.js +16 -0
- package/dist/workorders.remote.d.ts +5 -0
- package/dist/workorders.remote.js +8 -0
- package/package.json +58 -6
package/README.md
CHANGED
|
@@ -171,6 +171,9 @@ interface Employee {
|
|
|
171
171
|
const units = await client.getBusinessUnits()
|
|
172
172
|
const dropdown = await client.getBusinessUnitsDropdown() // { value, label }[]
|
|
173
173
|
const unit = await client.getBusinessUnit('BU001')
|
|
174
|
+
|
|
175
|
+
// Search by description (case-insensitive partial match)
|
|
176
|
+
const results = await client.searchBusinessUnits('west')
|
|
174
177
|
```
|
|
175
178
|
|
|
176
179
|
---
|
|
@@ -183,10 +186,13 @@ const dropdown = await client.getCostcodesDropdown() // { value, label }[]
|
|
|
183
186
|
const code = await client.getCostcode('CC001')
|
|
184
187
|
|
|
185
188
|
// Filtered by business unit
|
|
186
|
-
const
|
|
189
|
+
const buDropdown = await client.getCostcodesDropdownByBu('BU001')
|
|
187
190
|
|
|
188
191
|
// Filtered by business unit and pay type
|
|
189
|
-
const
|
|
192
|
+
const buPtDropdown = await client.getCostcodesDropdownByBuAndPayType('BU001', 'PT01')
|
|
193
|
+
|
|
194
|
+
// Search by description or JDE cost code (case-insensitive partial match)
|
|
195
|
+
const results = await client.searchCostcodes('labor')
|
|
190
196
|
```
|
|
191
197
|
|
|
192
198
|
---
|
|
@@ -197,6 +203,9 @@ const dropdown = await client.getCostcodesDropdownByBuAndPayType('BU001', 'PT01'
|
|
|
197
203
|
const types = await client.getPaytypes()
|
|
198
204
|
const dropdown = await client.getPaytypesDropdown() // { value, label, payClass }[]
|
|
199
205
|
const type = await client.getPaytype('PT001')
|
|
206
|
+
|
|
207
|
+
// Search by description (case-insensitive partial match)
|
|
208
|
+
const results = await client.searchPaytypes('regular')
|
|
200
209
|
```
|
|
201
210
|
|
|
202
211
|
---
|
|
@@ -209,7 +218,10 @@ const dropdown = await client.getWorkordersDropdown() // { value, label }[]
|
|
|
209
218
|
const order = await client.getWorkorder('WO001')
|
|
210
219
|
|
|
211
220
|
// Filtered by business unit
|
|
212
|
-
const
|
|
221
|
+
const buDropdown = await client.getWorkordersDropdownByBu('BU001')
|
|
222
|
+
|
|
223
|
+
// Search by description or client work order ID (case-insensitive partial match)
|
|
224
|
+
const results = await client.searchWorkorders('pipe')
|
|
213
225
|
```
|
|
214
226
|
|
|
215
227
|
---
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getBusinessUnits = query(async () => getClient().getBusinessUnits());
|
|
5
|
+
export const getBusinessUnitsDropdown = query(async () => getClient().getBusinessUnitsDropdown());
|
|
6
|
+
export const getBusinessUnit = query(z.string(), async (id) => getClient().getBusinessUnit(id));
|
|
7
|
+
export const searchBusinessUnits = query(z.string(), async (q) => getClient().searchBusinessUnits(q));
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApiHubClient } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a singleton ApiHubClient configured from the consuming app's
|
|
4
|
+
* APIHUB_URL and APIHUB_API_KEY environment variables.
|
|
5
|
+
*
|
|
6
|
+
* Must only be called inside remote function bodies (server-side only).
|
|
7
|
+
*/
|
|
8
|
+
export declare function getClient(): ApiHubClient;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { env } from '$env/dynamic/private';
|
|
2
|
+
import { ApiHubClient } from './index.js';
|
|
3
|
+
let _client = null;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a singleton ApiHubClient configured from the consuming app's
|
|
6
|
+
* APIHUB_URL and APIHUB_API_KEY environment variables.
|
|
7
|
+
*
|
|
8
|
+
* Must only be called inside remote function bodies (server-side only).
|
|
9
|
+
*/
|
|
10
|
+
export function getClient() {
|
|
11
|
+
if (!_client) {
|
|
12
|
+
const baseUrl = env.APIHUB_URL;
|
|
13
|
+
const apiKey = env.APIHUB_API_KEY;
|
|
14
|
+
if (!baseUrl)
|
|
15
|
+
throw new Error('APIHUB_URL environment variable is not set');
|
|
16
|
+
if (!apiKey)
|
|
17
|
+
throw new Error('APIHUB_API_KEY environment variable is not set');
|
|
18
|
+
_client = new ApiHubClient({ baseUrl, apiKey });
|
|
19
|
+
}
|
|
20
|
+
return _client;
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getCostcodes: any;
|
|
2
|
+
export declare const getCostcodesDropdown: any;
|
|
3
|
+
export declare const getCostcode: any;
|
|
4
|
+
export declare const getCostcodesDropdownByBu: any;
|
|
5
|
+
export declare const getCostcodesDropdownByBuAndPayType: any;
|
|
6
|
+
export declare const searchCostcodes: any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const buPayTypeSchema = z.object({
|
|
5
|
+
businessUnitId: z.string(),
|
|
6
|
+
payTypeCode: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export const getCostcodes = query(async () => getClient().getCostcodes());
|
|
9
|
+
export const getCostcodesDropdown = query(async () => getClient().getCostcodesDropdown());
|
|
10
|
+
export const getCostcode = query(z.string(), async (id) => getClient().getCostcode(id));
|
|
11
|
+
export const getCostcodesDropdownByBu = query(z.string(), async (businessUnitId) => getClient().getCostcodesDropdownByBu(businessUnitId));
|
|
12
|
+
export const getCostcodesDropdownByBuAndPayType = query(buPayTypeSchema, async ({ businessUnitId, payTypeCode }) => getClient().getCostcodesDropdownByBuAndPayType(businessUnitId, payTypeCode));
|
|
13
|
+
export const searchCostcodes = query(z.string(), async (q) => getClient().searchCostcodes(q));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const getEmployees: any;
|
|
2
|
+
export declare const getEmployeesDropdown: any;
|
|
3
|
+
export declare const getEmployee: any;
|
|
4
|
+
export declare const searchByName: any;
|
|
5
|
+
export declare const getBySupervisor: any;
|
|
6
|
+
export declare const searchByEmail: any;
|
|
7
|
+
export declare const getSupervisorChain: any;
|
|
8
|
+
export declare const getJdeFromEmail: any;
|
|
9
|
+
export declare const searchByHbu: any;
|
|
10
|
+
export declare const verifyIdentity: any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const employeeIdSchema = z.string().min(1);
|
|
5
|
+
const verifyIdentitySchema = z.object({
|
|
6
|
+
first3FirstName: z.string(),
|
|
7
|
+
first3LastName: z.string(),
|
|
8
|
+
dob: z.string(),
|
|
9
|
+
ssn4: z.string(),
|
|
10
|
+
});
|
|
11
|
+
export const getEmployees = query(async () => getClient().getEmployees());
|
|
12
|
+
export const getEmployeesDropdown = query(async () => getClient().getEmployeesDropdown());
|
|
13
|
+
export const getEmployee = query(employeeIdSchema, async (employeeId) => getClient().getEmployee(employeeId));
|
|
14
|
+
export const searchByName = query(z.string(), async (name) => getClient().searchByName(name));
|
|
15
|
+
export const getBySupervisor = query(employeeIdSchema, async (supervisorId) => getClient().getBySupervisor(supervisorId));
|
|
16
|
+
export const searchByEmail = query(z.string(), async (email) => getClient().searchByEmail(email));
|
|
17
|
+
export const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
18
|
+
export const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
|
19
|
+
export const searchByHbu = query(z.string(), async (hbu) => getClient().searchByHbu(hbu));
|
|
20
|
+
export const verifyIdentity = command(verifyIdentitySchema, async (inputs) => getClient().verifyIdentity(inputs));
|
package/dist/index.d.ts
CHANGED
|
@@ -258,6 +258,7 @@ export declare class ApiHubClient {
|
|
|
258
258
|
getBusinessUnits(): Promise<BusinessUnit[]>;
|
|
259
259
|
getBusinessUnitsDropdown(): Promise<DropdownOption[]>;
|
|
260
260
|
getBusinessUnit(id: string): Promise<BusinessUnit>;
|
|
261
|
+
searchBusinessUnits(q: string): Promise<BusinessUnit[]>;
|
|
261
262
|
getCostcodes(): Promise<Costcode[]>;
|
|
262
263
|
getCostcodesDropdown(): Promise<DropdownOption[]>;
|
|
263
264
|
getCostcode(id: string): Promise<Costcode>;
|
|
@@ -265,14 +266,17 @@ export declare class ApiHubClient {
|
|
|
265
266
|
getCostcodesDropdownByBu(businessUnitId: string): Promise<DropdownOption[]>;
|
|
266
267
|
/** Get cost codes for a specific business unit and pay type, formatted for dropdown controls */
|
|
267
268
|
getCostcodesDropdownByBuAndPayType(businessUnitId: string, payTypeCode: string): Promise<DropdownOption[]>;
|
|
269
|
+
searchCostcodes(q: string): Promise<Costcode[]>;
|
|
268
270
|
getPaytypes(): Promise<Paytype[]>;
|
|
269
271
|
getPaytypesDropdown(): Promise<PaytypeDropdownOption[]>;
|
|
270
272
|
getPaytype(id: string): Promise<Paytype>;
|
|
273
|
+
searchPaytypes(q: string): Promise<Paytype[]>;
|
|
271
274
|
getWorkorders(): Promise<Workorder[]>;
|
|
272
275
|
getWorkordersDropdown(): Promise<DropdownOption[]>;
|
|
273
276
|
/** Get work orders for a specific business unit, formatted for dropdown controls */
|
|
274
277
|
getWorkordersDropdownByBu(businessUnitId: string): Promise<DropdownOption[]>;
|
|
275
278
|
getWorkorder(id: string): Promise<Workorder>;
|
|
279
|
+
searchWorkorders(q: string): Promise<Workorder[]>;
|
|
276
280
|
getJobtypejobsteps(): Promise<Jobtypejobstep[]>;
|
|
277
281
|
getJobtypejobstepsDropdown(): Promise<DropdownOption[]>;
|
|
278
282
|
getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,9 @@ export class ApiHubClient {
|
|
|
256
256
|
async getBusinessUnit(id) {
|
|
257
257
|
return this.request(`/business-units/${encodeURIComponent(id)}`);
|
|
258
258
|
}
|
|
259
|
+
async searchBusinessUnits(q) {
|
|
260
|
+
return this.request(`/business-units/search?q=${encodeURIComponent(q)}`);
|
|
261
|
+
}
|
|
259
262
|
// -----------------------------------------------------------------------
|
|
260
263
|
// Cost Codes
|
|
261
264
|
// -----------------------------------------------------------------------
|
|
@@ -276,6 +279,9 @@ export class ApiHubClient {
|
|
|
276
279
|
async getCostcodesDropdownByBuAndPayType(businessUnitId, payTypeCode) {
|
|
277
280
|
return this.cachedRequest(`/costcodes/by-bu/${encodeURIComponent(businessUnitId)}/by-paytype/${encodeURIComponent(payTypeCode)}/dropdown`);
|
|
278
281
|
}
|
|
282
|
+
async searchCostcodes(q) {
|
|
283
|
+
return this.request(`/costcodes/search?q=${encodeURIComponent(q)}`);
|
|
284
|
+
}
|
|
279
285
|
// -----------------------------------------------------------------------
|
|
280
286
|
// Pay Types
|
|
281
287
|
// -----------------------------------------------------------------------
|
|
@@ -288,6 +294,9 @@ export class ApiHubClient {
|
|
|
288
294
|
async getPaytype(id) {
|
|
289
295
|
return this.request(`/paytypes/${encodeURIComponent(id)}`);
|
|
290
296
|
}
|
|
297
|
+
async searchPaytypes(q) {
|
|
298
|
+
return this.request(`/paytypes/search?q=${encodeURIComponent(q)}`);
|
|
299
|
+
}
|
|
291
300
|
// -----------------------------------------------------------------------
|
|
292
301
|
// Work Orders
|
|
293
302
|
// -----------------------------------------------------------------------
|
|
@@ -304,6 +313,9 @@ export class ApiHubClient {
|
|
|
304
313
|
async getWorkorder(id) {
|
|
305
314
|
return this.request(`/workorders/${encodeURIComponent(id)}`);
|
|
306
315
|
}
|
|
316
|
+
async searchWorkorders(q) {
|
|
317
|
+
return this.request(`/workorders/search?q=${encodeURIComponent(q)}`);
|
|
318
|
+
}
|
|
307
319
|
// -----------------------------------------------------------------------
|
|
308
320
|
// Job Type / Job Steps
|
|
309
321
|
// -----------------------------------------------------------------------
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getJobtypejobsteps = query(async () => getClient().getJobtypejobsteps());
|
|
5
|
+
export const getJobtypejobstepsDropdown = query(async () => getClient().getJobtypejobstepsDropdown());
|
|
6
|
+
export const getJobtypejobstep = query(z.string(), async (id) => getClient().getJobtypejobstep(id));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const chatMessageSchema = z.object({
|
|
5
|
+
role: z.enum(['system', 'user', 'assistant']),
|
|
6
|
+
content: z.string(),
|
|
7
|
+
});
|
|
8
|
+
const chatRequestSchema = z.object({
|
|
9
|
+
messages: z.array(chatMessageSchema),
|
|
10
|
+
source: z.string(),
|
|
11
|
+
user: z.string(),
|
|
12
|
+
function: z.string().optional(),
|
|
13
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
14
|
+
maxTokens: z.number().int().positive().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const getLlmLogs = query(async () => getClient().getLlmLogs());
|
|
17
|
+
export const chat = command(chatRequestSchema, async (request) => getClient().chat(request));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getPaytypes = query(async () => getClient().getPaytypes());
|
|
5
|
+
export const getPaytypesDropdown = query(async () => getClient().getPaytypesDropdown());
|
|
6
|
+
export const getPaytype = query(z.string(), async (id) => getClient().getPaytype(id));
|
|
7
|
+
export const searchPaytypes = query(z.string(), async (q) => getClient().searchPaytypes(q));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { query, command } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
const uploadDocumentSchema = z.object({
|
|
5
|
+
fileName: z.string().min(1),
|
|
6
|
+
base64Content: z.string().min(1),
|
|
7
|
+
uploadedBy: z.string().min(1),
|
|
8
|
+
});
|
|
9
|
+
const searchDocumentsSchema = z.object({
|
|
10
|
+
query: z.string().min(1),
|
|
11
|
+
topK: z.number().int().positive().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const listDocuments = query(async () => getClient().listDocuments());
|
|
14
|
+
export const uploadDocument = command(uploadDocumentSchema, async ({ fileName, base64Content, uploadedBy }) => getClient().uploadDocument(fileName, base64Content, uploadedBy));
|
|
15
|
+
export const deleteDocument = command(z.number().int().positive(), async (id) => getClient().deleteDocument(id));
|
|
16
|
+
export const searchDocuments = command(searchDocumentsSchema, async ({ query: q, topK }) => getClient().searchDocuments(q, topK));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { query } from '$app/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getClient } from './client.js';
|
|
4
|
+
export const getWorkorders = query(async () => getClient().getWorkorders());
|
|
5
|
+
export const getWorkordersDropdown = query(async () => getClient().getWorkordersDropdown());
|
|
6
|
+
export const getWorkordersDropdownByBu = query(z.string(), async (businessUnitId) => getClient().getWorkordersDropdownByBu(businessUnitId));
|
|
7
|
+
export const getWorkorder = query(z.string(), async (id) => getClient().getWorkorder(id));
|
|
8
|
+
export const searchWorkorders = query(z.string(), async (q) => getClient().searchWorkorders(q));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brownandroot/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,19 +11,71 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./employees": {
|
|
18
|
+
"types": "./dist/employees.remote.d.ts",
|
|
19
|
+
"default": "./dist/employees.remote.js"
|
|
20
|
+
},
|
|
21
|
+
"./businessUnits": {
|
|
22
|
+
"types": "./dist/businessUnits.remote.d.ts",
|
|
23
|
+
"default": "./dist/businessUnits.remote.js"
|
|
24
|
+
},
|
|
25
|
+
"./costcodes": {
|
|
26
|
+
"types": "./dist/costcodes.remote.d.ts",
|
|
27
|
+
"default": "./dist/costcodes.remote.js"
|
|
28
|
+
},
|
|
29
|
+
"./paytypes": {
|
|
30
|
+
"types": "./dist/paytypes.remote.d.ts",
|
|
31
|
+
"default": "./dist/paytypes.remote.js"
|
|
32
|
+
},
|
|
33
|
+
"./workorders": {
|
|
34
|
+
"types": "./dist/workorders.remote.d.ts",
|
|
35
|
+
"default": "./dist/workorders.remote.js"
|
|
36
|
+
},
|
|
37
|
+
"./jobtypejobsteps": {
|
|
38
|
+
"types": "./dist/jobtypejobsteps.remote.d.ts",
|
|
39
|
+
"default": "./dist/jobtypejobsteps.remote.js"
|
|
40
|
+
},
|
|
41
|
+
"./llm": {
|
|
42
|
+
"types": "./dist/llm.remote.d.ts",
|
|
43
|
+
"default": "./dist/llm.remote.js"
|
|
44
|
+
},
|
|
45
|
+
"./rag": {
|
|
46
|
+
"types": "./dist/rag.remote.d.ts",
|
|
47
|
+
"default": "./dist/rag.remote.js"
|
|
16
48
|
}
|
|
17
49
|
},
|
|
18
50
|
"files": [
|
|
19
51
|
"dist"
|
|
20
52
|
],
|
|
21
53
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
54
|
+
"prepare": "bun svelte-kit sync || echo ''",
|
|
55
|
+
"build": "bun svelte-kit sync && bun svelte-package",
|
|
56
|
+
"prepublishOnly": "bun run build",
|
|
24
57
|
"publish:manual": "npm publish --access public"
|
|
25
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@sveltejs/kit": "^2.0.0",
|
|
61
|
+
"svelte": "^5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@sveltejs/kit": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"svelte": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
26
71
|
"devDependencies": {
|
|
27
|
-
"
|
|
72
|
+
"@sveltejs/adapter-node": "^5.0.0",
|
|
73
|
+
"@sveltejs/kit": "^2.0.0",
|
|
74
|
+
"@sveltejs/package": "^2.0.0",
|
|
75
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
76
|
+
"svelte": "^5.0.0",
|
|
77
|
+
"typescript": "^5.0.0",
|
|
78
|
+
"vite": "^6.0.0",
|
|
79
|
+
"zod": "^3.0.0"
|
|
28
80
|
}
|
|
29
81
|
}
|