@brownandroot/api 1.2.1 → 2.0.1
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 +95 -469
- package/dist/businessUnits.remote.d.ts +1 -1
- package/dist/businessUnits.remote.js +16 -1
- package/dist/cache.d.ts +51 -28
- package/dist/cache.js +193 -39
- package/dist/costcodes.remote.d.ts +1 -1
- package/dist/costcodes.remote.js +16 -1
- package/dist/employees.remote.d.ts +1 -1
- package/dist/employees.remote.js +16 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +133 -14
- package/dist/jobtypejobsteps.remote.d.ts +1 -1
- package/dist/jobtypejobsteps.remote.js +16 -1
- package/dist/llm.remote.d.ts +1 -0
- package/dist/llm.remote.js +1 -0
- package/dist/paytypes.remote.d.ts +1 -1
- package/dist/paytypes.remote.js +16 -1
- package/dist/workorders.remote.d.ts +1 -1
- package/dist/workorders.remote.js +16 -1
- package/package.json +1 -37
package/dist/cache.d.ts
CHANGED
|
@@ -97,46 +97,34 @@ export interface JobtypejobstepFilters {
|
|
|
97
97
|
/** Case-insensitive partial match on description, jobType, or jobStep */
|
|
98
98
|
q?: string;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/** Single employee by ID — always fetches fresh (no IndexedDB). */
|
|
103
|
-
export declare function getEmployee(employeeId: string): Promise<Employee>;
|
|
100
|
+
declare function getEmployees(filters?: EmployeeFilters): Promise<Employee[]>;
|
|
101
|
+
declare function getEmployeesDropdown(filters?: EmployeeFilters): Promise<DropdownOption[]>;
|
|
104
102
|
/** Single employee by ID including compensation fields — always fetches fresh (no IndexedDB). */
|
|
105
|
-
|
|
103
|
+
declare function getEmployeePrivileged(employeeId: string): Promise<EmployeePrivileged>;
|
|
106
104
|
/** Full supervisor chain above an employee — always fetches fresh. */
|
|
107
|
-
|
|
105
|
+
declare function getSupervisorChain(employeeId: string): Promise<Employee[]>;
|
|
108
106
|
/** Look up JDE number and employee from email — always fetches fresh. */
|
|
109
|
-
|
|
107
|
+
declare function getJdeFromEmail(email: string): Promise<{
|
|
110
108
|
jde: string | null;
|
|
111
109
|
employee: Employee | null;
|
|
112
110
|
}>;
|
|
113
111
|
/** Verify employee identity — always fetches fresh. */
|
|
114
|
-
|
|
112
|
+
declare function verifyIdentity(inputs: {
|
|
115
113
|
first3FirstName: string;
|
|
116
114
|
first3LastName: string;
|
|
117
115
|
dob: string;
|
|
118
116
|
ssn4: string;
|
|
119
117
|
}): Promise<Employee | null>;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/** Single pay type by ID — always fetches fresh (no IndexedDB). */
|
|
131
|
-
export declare function getPaytype(id: string): Promise<Paytype>;
|
|
132
|
-
export declare function getBusinessUnits(filters?: BusinessUnitFilters): Promise<BusinessUnit[]>;
|
|
133
|
-
export declare function getBusinessUnitsDropdown(filters?: BusinessUnitFilters): Promise<DropdownOption[]>;
|
|
134
|
-
/** Single business unit by ID — always fetches fresh (no IndexedDB). */
|
|
135
|
-
export declare function getBusinessUnit(id: string): Promise<BusinessUnit>;
|
|
136
|
-
export declare function getJobtypejobsteps(filters?: JobtypejobstepFilters): Promise<Jobtypejobstep[]>;
|
|
137
|
-
export declare function getJobtypejobstepsDropdown(filters?: JobtypejobstepFilters): Promise<DropdownOption[]>;
|
|
138
|
-
/** Single job type/job step by ID — always fetches fresh (no IndexedDB). */
|
|
139
|
-
export declare function getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
|
118
|
+
declare function getWorkorders(filters?: WorkorderFilters): Promise<Workorder[]>;
|
|
119
|
+
declare function getWorkordersDropdown(filters?: WorkorderFilters): Promise<DropdownOption[]>;
|
|
120
|
+
declare function getCostcodes(filters?: CostcodeFilters): Promise<Costcode[]>;
|
|
121
|
+
declare function getCostcodesDropdown(filters?: CostcodeFilters): Promise<DropdownOption[]>;
|
|
122
|
+
declare function getPaytypes(filters?: PaytypeFilters): Promise<Paytype[]>;
|
|
123
|
+
declare function getPaytypesDropdown(filters?: PaytypeFilters): Promise<PaytypeDropdownOption[]>;
|
|
124
|
+
declare function getBusinessUnits(filters?: BusinessUnitFilters): Promise<BusinessUnit[]>;
|
|
125
|
+
declare function getBusinessUnitsDropdown(filters?: BusinessUnitFilters): Promise<DropdownOption[]>;
|
|
126
|
+
declare function getJobtypejobsteps(filters?: JobtypejobstepFilters): Promise<Jobtypejobstep[]>;
|
|
127
|
+
declare function getJobtypejobstepsDropdown(filters?: JobtypejobstepFilters): Promise<DropdownOption[]>;
|
|
140
128
|
/**
|
|
141
129
|
* Clear the IndexedDB cache for a specific entity, or all entities.
|
|
142
130
|
*
|
|
@@ -150,3 +138,38 @@ export declare function getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
|
|
150
138
|
* clearCache() // clear everything
|
|
151
139
|
*/
|
|
152
140
|
export declare function clearCache(entity?: IdbStore): void;
|
|
141
|
+
export declare const employees: {
|
|
142
|
+
getAll: typeof getEmployees;
|
|
143
|
+
dropdown: typeof getEmployeesDropdown;
|
|
144
|
+
get: (id: string) => Promise<Employee | null>;
|
|
145
|
+
getPrivileged: typeof getEmployeePrivileged;
|
|
146
|
+
getSupervisorChain: typeof getSupervisorChain;
|
|
147
|
+
getJdeFromEmail: typeof getJdeFromEmail;
|
|
148
|
+
verifyIdentity: typeof verifyIdentity;
|
|
149
|
+
};
|
|
150
|
+
export declare const workorders: {
|
|
151
|
+
getAll: typeof getWorkorders;
|
|
152
|
+
dropdown: typeof getWorkordersDropdown;
|
|
153
|
+
get: (id: string) => Promise<Workorder | null>;
|
|
154
|
+
};
|
|
155
|
+
export declare const costcodes: {
|
|
156
|
+
getAll: typeof getCostcodes;
|
|
157
|
+
dropdown: typeof getCostcodesDropdown;
|
|
158
|
+
get: (id: string) => Promise<Costcode | null>;
|
|
159
|
+
};
|
|
160
|
+
export declare const paytypes: {
|
|
161
|
+
getAll: typeof getPaytypes;
|
|
162
|
+
dropdown: typeof getPaytypesDropdown;
|
|
163
|
+
get: (id: string) => Promise<Paytype | null>;
|
|
164
|
+
};
|
|
165
|
+
export declare const businessUnits: {
|
|
166
|
+
getAll: typeof getBusinessUnits;
|
|
167
|
+
dropdown: typeof getBusinessUnitsDropdown;
|
|
168
|
+
get: (id: string) => Promise<BusinessUnit | null>;
|
|
169
|
+
};
|
|
170
|
+
export declare const jobtypejobsteps: {
|
|
171
|
+
getAll: typeof getJobtypejobsteps;
|
|
172
|
+
dropdown: typeof getJobtypejobstepsDropdown;
|
|
173
|
+
get: (id: string) => Promise<Jobtypejobstep | null>;
|
|
174
|
+
};
|
|
175
|
+
export {};
|
package/dist/cache.js
CHANGED
|
@@ -20,7 +20,25 @@ import { getJobtypejobsteps as _getJobtypejobsteps, getJobtypejobstep as _getJob
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
/** How long cached data is considered fresh before a background refresh is triggered. */
|
|
22
22
|
const CACHE_TTL_MS = 4 * 60 * 60 * 1000; // 4 hours
|
|
23
|
+
/** Server-side in-memory cache TTL for SSR/BFF usage. */
|
|
24
|
+
const SERVER_CACHE_TTL_MS = 2 * 60 * 1000; // 2 minutes
|
|
25
|
+
const serverCache = new Map();
|
|
26
|
+
function logReadFailure(operation, error) {
|
|
27
|
+
if (typeof window !== 'undefined')
|
|
28
|
+
return;
|
|
29
|
+
const detail = error instanceof Error ? { name: error.name, message: error.message } : { error };
|
|
30
|
+
console.error(`[APIHubReadFailOpen] ${operation}`, detail);
|
|
31
|
+
}
|
|
23
32
|
async function loadCached(store, fetcher) {
|
|
33
|
+
if (typeof window === 'undefined') {
|
|
34
|
+
const cached = serverCache.get(store);
|
|
35
|
+
if (cached && Date.now() - cached.fetchedAt < SERVER_CACHE_TTL_MS) {
|
|
36
|
+
return cached.data;
|
|
37
|
+
}
|
|
38
|
+
const data = await fetcher();
|
|
39
|
+
serverCache.set(store, { data, fetchedAt: Date.now() });
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
24
42
|
const cached = await idbGet(store, 'all');
|
|
25
43
|
if (cached) {
|
|
26
44
|
// Only refresh in the background if the cached data is older than the TTL
|
|
@@ -195,57 +213,102 @@ async function applyCostcodeFilters(data, f) {
|
|
|
195
213
|
// ---------------------------------------------------------------------------
|
|
196
214
|
// Public API — Employees
|
|
197
215
|
// ---------------------------------------------------------------------------
|
|
198
|
-
|
|
199
|
-
|
|
216
|
+
async function getEmployees(filters) {
|
|
217
|
+
let all;
|
|
218
|
+
try {
|
|
219
|
+
all = await loadCached('employees', () => _getEmployees());
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
logReadFailure('employees.getAll', error);
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
200
225
|
return applyEmployeeFilters(all, filters);
|
|
201
226
|
}
|
|
202
|
-
|
|
227
|
+
async function getEmployeesDropdown(filters) {
|
|
203
228
|
const results = await getEmployees(filters);
|
|
204
229
|
return results.map((e) => ({ value: e.employeeId, label: e.name ?? e.employeeId }));
|
|
205
230
|
}
|
|
206
231
|
/** Single employee by ID — always fetches fresh (no IndexedDB). */
|
|
207
|
-
|
|
208
|
-
|
|
232
|
+
async function getEmployee(employeeId) {
|
|
233
|
+
try {
|
|
234
|
+
return await _getEmployee(employeeId);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
logReadFailure('employees.get', error);
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
209
240
|
}
|
|
210
241
|
/** Single employee by ID including compensation fields — always fetches fresh (no IndexedDB). */
|
|
211
|
-
|
|
242
|
+
async function getEmployeePrivileged(employeeId) {
|
|
212
243
|
return _getEmployeePrivileged(employeeId);
|
|
213
244
|
}
|
|
214
245
|
/** Full supervisor chain above an employee — always fetches fresh. */
|
|
215
|
-
|
|
216
|
-
|
|
246
|
+
async function getSupervisorChain(employeeId) {
|
|
247
|
+
try {
|
|
248
|
+
return await _getSupervisorChain(employeeId);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
logReadFailure('employees.getSupervisorChain', error);
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
217
254
|
}
|
|
218
255
|
/** Look up JDE number and employee from email — always fetches fresh. */
|
|
219
|
-
|
|
220
|
-
|
|
256
|
+
async function getJdeFromEmail(email) {
|
|
257
|
+
try {
|
|
258
|
+
return await _getJdeFromEmail(email);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
logReadFailure('employees.getJdeFromEmail', error);
|
|
262
|
+
return { jde: null, employee: null };
|
|
263
|
+
}
|
|
221
264
|
}
|
|
222
265
|
/** Verify employee identity — always fetches fresh. */
|
|
223
|
-
|
|
266
|
+
async function verifyIdentity(inputs) {
|
|
224
267
|
return _verifyIdentity(inputs);
|
|
225
268
|
}
|
|
226
269
|
// ---------------------------------------------------------------------------
|
|
227
270
|
// Public API — Workorders
|
|
228
271
|
// ---------------------------------------------------------------------------
|
|
229
|
-
|
|
230
|
-
|
|
272
|
+
async function getWorkorders(filters) {
|
|
273
|
+
let all;
|
|
274
|
+
try {
|
|
275
|
+
all = await loadCached('workorders', () => _getWorkorders());
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
logReadFailure('workorders.getAll', error);
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
231
281
|
return applyWorkorderFilters(all, filters);
|
|
232
282
|
}
|
|
233
|
-
|
|
283
|
+
async function getWorkordersDropdown(filters) {
|
|
234
284
|
const results = await getWorkorders({ isActive: true, ...filters });
|
|
235
285
|
return results.map((w) => ({ value: w.id, label: w.description ?? w.id }));
|
|
236
286
|
}
|
|
237
287
|
/** Single workorder by ID — always fetches fresh (no IndexedDB). */
|
|
238
|
-
|
|
239
|
-
|
|
288
|
+
async function getWorkorder(id) {
|
|
289
|
+
try {
|
|
290
|
+
return await _getWorkorder(id);
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
logReadFailure('workorders.get', error);
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
240
296
|
}
|
|
241
297
|
// ---------------------------------------------------------------------------
|
|
242
298
|
// Public API — Cost Codes
|
|
243
299
|
// ---------------------------------------------------------------------------
|
|
244
|
-
|
|
245
|
-
|
|
300
|
+
async function getCostcodes(filters) {
|
|
301
|
+
let all;
|
|
302
|
+
try {
|
|
303
|
+
all = await loadCached('costcodes', () => _getCostcodes());
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
logReadFailure('costcodes.getAll', error);
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
246
309
|
return applyCostcodeFilters(all, filters);
|
|
247
310
|
}
|
|
248
|
-
|
|
311
|
+
async function getCostcodesDropdown(filters) {
|
|
249
312
|
const mergedFilters = { isActive: true, entryFlag: true, ...filters };
|
|
250
313
|
const results = await getCostcodes(mergedFilters);
|
|
251
314
|
const now = new Date();
|
|
@@ -257,56 +320,104 @@ export async function getCostcodesDropdown(filters) {
|
|
|
257
320
|
}));
|
|
258
321
|
}
|
|
259
322
|
/** Single cost code by ID — always fetches fresh (no IndexedDB). */
|
|
260
|
-
|
|
261
|
-
|
|
323
|
+
async function getCostcode(id) {
|
|
324
|
+
try {
|
|
325
|
+
return await _getCostcode(id);
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
logReadFailure('costcodes.get', error);
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
262
331
|
}
|
|
263
332
|
// ---------------------------------------------------------------------------
|
|
264
333
|
// Public API — Pay Types
|
|
265
334
|
// ---------------------------------------------------------------------------
|
|
266
|
-
|
|
267
|
-
|
|
335
|
+
async function getPaytypes(filters) {
|
|
336
|
+
let all;
|
|
337
|
+
try {
|
|
338
|
+
all = await loadCached('paytypes', () => _getPaytypes());
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
logReadFailure('paytypes.getAll', error);
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
268
344
|
return applyPaytypeFilters(all, filters);
|
|
269
345
|
}
|
|
270
|
-
|
|
271
|
-
const
|
|
346
|
+
async function getPaytypesDropdown(filters) {
|
|
347
|
+
const mergedFilters = { isActive: true, ...filters };
|
|
348
|
+
const results = await getPaytypes(mergedFilters);
|
|
272
349
|
return results.map((p) => ({ value: p.id, label: p.description, payClass: p.payClass }));
|
|
273
350
|
}
|
|
274
351
|
/** Single pay type by ID — always fetches fresh (no IndexedDB). */
|
|
275
|
-
|
|
276
|
-
|
|
352
|
+
async function getPaytype(id) {
|
|
353
|
+
try {
|
|
354
|
+
return await _getPaytype(id);
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
logReadFailure('paytypes.get', error);
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
277
360
|
}
|
|
278
361
|
// ---------------------------------------------------------------------------
|
|
279
362
|
// Public API — Business Units
|
|
280
363
|
// ---------------------------------------------------------------------------
|
|
281
|
-
|
|
282
|
-
|
|
364
|
+
async function getBusinessUnits(filters) {
|
|
365
|
+
let all;
|
|
366
|
+
try {
|
|
367
|
+
all = await loadCached('businessUnits', () => _getBusinessUnits());
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
logReadFailure('businessUnits.getAll', error);
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
283
373
|
return applyBusinessUnitFilters(all, filters);
|
|
284
374
|
}
|
|
285
|
-
|
|
286
|
-
const
|
|
375
|
+
async function getBusinessUnitsDropdown(filters) {
|
|
376
|
+
const mergedFilters = { isActive: true, ...filters };
|
|
377
|
+
const results = await getBusinessUnits(mergedFilters);
|
|
287
378
|
return results.map((b) => ({ value: b.id, label: b.description }));
|
|
288
379
|
}
|
|
289
380
|
/** Single business unit by ID — always fetches fresh (no IndexedDB). */
|
|
290
|
-
|
|
291
|
-
|
|
381
|
+
async function getBusinessUnit(id) {
|
|
382
|
+
try {
|
|
383
|
+
return await _getBusinessUnit(id);
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
logReadFailure('businessUnits.get', error);
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
292
389
|
}
|
|
293
390
|
// ---------------------------------------------------------------------------
|
|
294
391
|
// Public API — Job Type / Job Steps
|
|
295
392
|
// ---------------------------------------------------------------------------
|
|
296
|
-
|
|
297
|
-
|
|
393
|
+
async function getJobtypejobsteps(filters) {
|
|
394
|
+
let all;
|
|
395
|
+
try {
|
|
396
|
+
all = await loadCached('jobtypejobsteps', () => _getJobtypejobsteps());
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
logReadFailure('jobtypejobsteps.getAll', error);
|
|
400
|
+
return [];
|
|
401
|
+
}
|
|
298
402
|
return applyJobtypejobstepFilters(all, filters);
|
|
299
403
|
}
|
|
300
|
-
|
|
301
|
-
const
|
|
404
|
+
async function getJobtypejobstepsDropdown(filters) {
|
|
405
|
+
const mergedFilters = { isActive: true, ...filters };
|
|
406
|
+
const results = await getJobtypejobsteps(mergedFilters);
|
|
302
407
|
return results.map((j) => ({
|
|
303
408
|
value: j.id,
|
|
304
409
|
label: j.description ?? `${j.jobType ?? ''} ${j.jobStep ?? ''}`.trim(),
|
|
305
410
|
}));
|
|
306
411
|
}
|
|
307
412
|
/** Single job type/job step by ID — always fetches fresh (no IndexedDB). */
|
|
308
|
-
|
|
309
|
-
|
|
413
|
+
async function getJobtypejobstep(id) {
|
|
414
|
+
try {
|
|
415
|
+
return await _getJobtypejobstep(id);
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
logReadFailure('jobtypejobsteps.get', error);
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
310
421
|
}
|
|
311
422
|
// ---------------------------------------------------------------------------
|
|
312
423
|
// Cache management
|
|
@@ -324,5 +435,48 @@ export async function getJobtypejobstep(id) {
|
|
|
324
435
|
* clearCache() // clear everything
|
|
325
436
|
*/
|
|
326
437
|
export function clearCache(entity) {
|
|
438
|
+
if (entity) {
|
|
439
|
+
serverCache.delete(entity);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
serverCache.clear();
|
|
443
|
+
}
|
|
327
444
|
idbClear(entity).catch(() => { });
|
|
328
445
|
}
|
|
446
|
+
// ---------------------------------------------------------------------------
|
|
447
|
+
// Unified domain-style API (v2 contract)
|
|
448
|
+
// ---------------------------------------------------------------------------
|
|
449
|
+
export const employees = {
|
|
450
|
+
getAll: getEmployees,
|
|
451
|
+
dropdown: getEmployeesDropdown,
|
|
452
|
+
get: (id) => getEmployee(id),
|
|
453
|
+
getPrivileged: getEmployeePrivileged,
|
|
454
|
+
getSupervisorChain,
|
|
455
|
+
getJdeFromEmail,
|
|
456
|
+
verifyIdentity,
|
|
457
|
+
};
|
|
458
|
+
export const workorders = {
|
|
459
|
+
getAll: getWorkorders,
|
|
460
|
+
dropdown: getWorkordersDropdown,
|
|
461
|
+
get: (id) => getWorkorder(id),
|
|
462
|
+
};
|
|
463
|
+
export const costcodes = {
|
|
464
|
+
getAll: getCostcodes,
|
|
465
|
+
dropdown: getCostcodesDropdown,
|
|
466
|
+
get: (id) => getCostcode(id),
|
|
467
|
+
};
|
|
468
|
+
export const paytypes = {
|
|
469
|
+
getAll: getPaytypes,
|
|
470
|
+
dropdown: getPaytypesDropdown,
|
|
471
|
+
get: (id) => getPaytype(id),
|
|
472
|
+
};
|
|
473
|
+
export const businessUnits = {
|
|
474
|
+
getAll: getBusinessUnits,
|
|
475
|
+
dropdown: getBusinessUnitsDropdown,
|
|
476
|
+
get: (id) => getBusinessUnit(id),
|
|
477
|
+
};
|
|
478
|
+
export const jobtypejobsteps = {
|
|
479
|
+
getAll: getJobtypejobsteps,
|
|
480
|
+
dropdown: getJobtypejobstepsDropdown,
|
|
481
|
+
get: (id) => getJobtypejobstep(id),
|
|
482
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const getCostcodes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Costcode[]>;
|
|
2
2
|
export declare const getCostcodesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
-
export declare const getCostcode: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode>;
|
|
3
|
+
export declare const getCostcode: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode | null>;
|
package/dist/costcodes.remote.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { query } from '$app/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { getClient } from './client.js';
|
|
4
|
+
function isNotFoundError(error) {
|
|
5
|
+
if (!(error instanceof Error))
|
|
6
|
+
return false;
|
|
7
|
+
return /not found/i.test(error.message);
|
|
8
|
+
}
|
|
9
|
+
async function asNullable(fetcher) {
|
|
10
|
+
try {
|
|
11
|
+
return await fetcher();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (isNotFoundError(error))
|
|
15
|
+
return null;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
4
19
|
export const getCostcodes = query(async () => getClient().getCostcodes());
|
|
5
20
|
export const getCostcodesDropdown = query(async () => getClient().getCostcodesDropdown());
|
|
6
|
-
export const getCostcode = query(z.string(), async (id) => getClient().getCostcode(id));
|
|
21
|
+
export const getCostcode = query(z.string(), async (id) => asNullable(() => getClient().getCostcode(id)));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const getEmployees: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Employee[]>;
|
|
2
2
|
export declare const getEmployeesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
-
export declare const getEmployee: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee>;
|
|
3
|
+
export declare const getEmployee: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee | null>;
|
|
4
4
|
export declare const getEmployeePrivileged: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").EmployeePrivileged>;
|
|
5
5
|
export declare const getSupervisorChain: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
6
6
|
export declare const getJdeFromEmail: import("@sveltejs/kit").RemoteQueryFunction<string, {
|
package/dist/employees.remote.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { query, command } from '$app/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { getClient } from './client.js';
|
|
4
|
+
function isNotFoundError(error) {
|
|
5
|
+
if (!(error instanceof Error))
|
|
6
|
+
return false;
|
|
7
|
+
return /not found/i.test(error.message);
|
|
8
|
+
}
|
|
9
|
+
async function asNullable(fetcher) {
|
|
10
|
+
try {
|
|
11
|
+
return await fetcher();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (isNotFoundError(error))
|
|
15
|
+
return null;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
4
19
|
const employeeIdSchema = z.string().min(1);
|
|
5
20
|
const verifyIdentitySchema = z.object({
|
|
6
21
|
first3FirstName: z.string(),
|
|
@@ -10,7 +25,7 @@ const verifyIdentitySchema = z.object({
|
|
|
10
25
|
});
|
|
11
26
|
export const getEmployees = query(async () => getClient().getEmployees());
|
|
12
27
|
export const getEmployeesDropdown = query(async () => getClient().getEmployeesDropdown());
|
|
13
|
-
export const getEmployee = query(employeeIdSchema, async (employeeId) => getClient().getEmployee(employeeId));
|
|
28
|
+
export const getEmployee = query(employeeIdSchema, async (employeeId) => asNullable(() => getClient().getEmployee(employeeId)));
|
|
14
29
|
export const getEmployeePrivileged = query(employeeIdSchema, async (employeeId) => getClient().getEmployeePrivileged(employeeId));
|
|
15
30
|
export const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
16
31
|
export const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,29 @@ export interface ApiHubClientOptions {
|
|
|
57
57
|
apiKey: string;
|
|
58
58
|
/** Default cache TTL in milliseconds. Set to 0 to disable caching. Default: 5 minutes. */
|
|
59
59
|
cacheTtl?: number;
|
|
60
|
+
/** Request timeout in milliseconds. Default: 10000. */
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
/** Retry count for idempotent GET requests on transient failures. Default: 2. */
|
|
63
|
+
retryCount?: number;
|
|
64
|
+
/** Optional hook invoked whenever an APIHubError is raised. */
|
|
65
|
+
onError?: (error: ApiHubError) => void;
|
|
66
|
+
}
|
|
67
|
+
export declare class ApiHubError extends Error {
|
|
68
|
+
status: number | null;
|
|
69
|
+
path: string;
|
|
70
|
+
url: string;
|
|
71
|
+
responseBody: unknown;
|
|
72
|
+
retriable: boolean;
|
|
73
|
+
service: string;
|
|
74
|
+
constructor(options: {
|
|
75
|
+
message: string;
|
|
76
|
+
status: number | null;
|
|
77
|
+
path: string;
|
|
78
|
+
url: string;
|
|
79
|
+
responseBody: unknown;
|
|
80
|
+
retriable: boolean;
|
|
81
|
+
service?: string;
|
|
82
|
+
});
|
|
60
83
|
}
|
|
61
84
|
export interface DropdownOption {
|
|
62
85
|
value: number | string;
|
|
@@ -89,6 +112,8 @@ export interface ChatRequest {
|
|
|
89
112
|
function?: string;
|
|
90
113
|
temperature?: number;
|
|
91
114
|
maxTokens?: number;
|
|
115
|
+
/** Flag to enable RAG context enrichment in chat responses. */
|
|
116
|
+
enableRag?: boolean;
|
|
92
117
|
}
|
|
93
118
|
export interface ChatResponse {
|
|
94
119
|
message: ChatMessage;
|
|
@@ -126,7 +151,7 @@ export interface StreamChatRequest {
|
|
|
126
151
|
content: string;
|
|
127
152
|
}[];
|
|
128
153
|
userContext?: StreamChatUserContext;
|
|
129
|
-
|
|
154
|
+
enableRag?: boolean;
|
|
130
155
|
tools?: string[];
|
|
131
156
|
source?: string;
|
|
132
157
|
}
|
|
@@ -208,8 +233,15 @@ export declare class ApiHubClient {
|
|
|
208
233
|
private baseUrl;
|
|
209
234
|
private apiKey;
|
|
210
235
|
private cacheTtl;
|
|
236
|
+
private timeoutMs;
|
|
237
|
+
private retryCount;
|
|
238
|
+
private onError?;
|
|
211
239
|
private cache;
|
|
212
240
|
constructor(options: ApiHubClientOptions);
|
|
241
|
+
private isRetriableStatus;
|
|
242
|
+
private createApiHubError;
|
|
243
|
+
private fetchWithTimeout;
|
|
244
|
+
private delay;
|
|
213
245
|
/** Clear all cached responses, or a specific path */
|
|
214
246
|
clearCache(path?: string): void;
|
|
215
247
|
private cachedRequest;
|
|
@@ -288,3 +320,33 @@ export declare class ApiHubClient {
|
|
|
288
320
|
getJobtypejobstepsDropdown(): Promise<DropdownOption[]>;
|
|
289
321
|
getJobtypejobstep(id: string): Promise<Jobtypejobstep>;
|
|
290
322
|
}
|
|
323
|
+
export { employees, workorders, costcodes, paytypes, businessUnits, jobtypejobsteps, clearCache } from './cache.js';
|
|
324
|
+
export declare const llm: {
|
|
325
|
+
getLogs: import("@sveltejs/kit").RemoteQueryFunction<void, LlmLog[]>;
|
|
326
|
+
chat: import("@sveltejs/kit").RemoteCommand<{
|
|
327
|
+
user: string;
|
|
328
|
+
messages: {
|
|
329
|
+
role: "system" | "user" | "assistant";
|
|
330
|
+
content: string;
|
|
331
|
+
}[];
|
|
332
|
+
source: string;
|
|
333
|
+
function?: string | undefined;
|
|
334
|
+
temperature?: number | undefined;
|
|
335
|
+
maxTokens?: number | undefined;
|
|
336
|
+
enableRag?: boolean | undefined;
|
|
337
|
+
}, Promise<ChatResponse>>;
|
|
338
|
+
};
|
|
339
|
+
export declare const rag: {
|
|
340
|
+
list: import("@sveltejs/kit").RemoteQueryFunction<void, DocumentRecord[]>;
|
|
341
|
+
upload: import("@sveltejs/kit").RemoteCommand<{
|
|
342
|
+
fileName: string;
|
|
343
|
+
base64Content: string;
|
|
344
|
+
uploadedBy: string;
|
|
345
|
+
}, Promise<DocumentRecord>>;
|
|
346
|
+
delete: import("@sveltejs/kit").RemoteCommand<number, Promise<void>>;
|
|
347
|
+
search: import("@sveltejs/kit").RemoteCommand<{
|
|
348
|
+
query: string;
|
|
349
|
+
topK?: number | undefined;
|
|
350
|
+
}, Promise<SearchResult[]>>;
|
|
351
|
+
};
|
|
352
|
+
export type { EmployeeFilters, WorkorderFilters, CostcodeFilters, PaytypeFilters, BusinessUnitFilters, JobtypejobstepFilters, } from './cache.js';
|