@brownandroot/api 1.1.0 → 1.2.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 +296 -160
- package/dist/businessUnits.remote.d.ts +0 -1
- package/dist/businessUnits.remote.js +0 -1
- package/dist/cache.d.ts +152 -0
- package/dist/cache.js +324 -0
- package/dist/costcodes.remote.d.ts +0 -6
- package/dist/costcodes.remote.js +0 -7
- package/dist/employees.remote.d.ts +1 -4
- package/dist/employees.remote.js +1 -4
- package/dist/idb.d.ts +13 -0
- package/dist/idb.js +79 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +4 -0
- package/dist/paytypes.remote.d.ts +0 -1
- package/dist/paytypes.remote.js +0 -1
- package/dist/workorders.remote.d.ts +0 -2
- package/dist/workorders.remote.js +0 -2
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -10,9 +10,11 @@ npm install @brownandroot/api
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Client-Side Cache API (recommended for SvelteKit)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
The package ships a browser-side API at `@brownandroot/api/cache` that wraps every remote function with an **IndexedDB stale-while-revalidate cache**. On the first call the data is fetched from the server; on every subsequent call the cached data is returned instantly and a background refresh keeps the cache warm.
|
|
16
|
+
|
|
17
|
+
All list and dropdown functions accept an optional filter object — every entity field is available as an optional filter key. The `q` field performs a case-insensitive partial-text match across the entity's searchable text fields.
|
|
16
18
|
|
|
17
19
|
### Setup
|
|
18
20
|
|
|
@@ -27,21 +29,225 @@ Enable remote functions in `svelte.config.js` (if not already):
|
|
|
27
29
|
|
|
28
30
|
```js
|
|
29
31
|
kit: {
|
|
30
|
-
|
|
32
|
+
experimental: {
|
|
33
|
+
remoteFunctions: true
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
```
|
|
33
37
|
|
|
34
38
|
### Usage
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
```svelte
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
import { getWorkordersDropdown, getEmployees, clearCache } from '@brownandroot/api/cache'
|
|
43
|
+
|
|
44
|
+
// First page load: fetches from server and caches in IndexedDB.
|
|
45
|
+
// Subsequent loads: returns from IndexedDB instantly, refreshes in background.
|
|
46
|
+
const workorders = $derived(await getWorkordersDropdown({ businessUnitId: 'BU001' }))
|
|
47
|
+
|
|
48
|
+
// Multiple filters compose freely
|
|
49
|
+
const employees = $derived(await getEmployees({
|
|
50
|
+
hbu: 'TX01',
|
|
51
|
+
payClass: 'H',
|
|
52
|
+
q: 'john',
|
|
53
|
+
}))
|
|
54
|
+
|
|
55
|
+
// After a mutation, clear the affected entity so the next read re-fetches
|
|
56
|
+
async function onCreate() {
|
|
57
|
+
await createWorkorder(formData)
|
|
58
|
+
clearCache('workorders')
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Filter reference
|
|
64
|
+
|
|
65
|
+
All filter fields are optional. Omit the filter object entirely to return all records.
|
|
66
|
+
|
|
67
|
+
#### Workorders
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { getWorkorders, getWorkordersDropdown } from '@brownandroot/api/cache'
|
|
71
|
+
|
|
72
|
+
interface WorkorderFilters {
|
|
73
|
+
businessUnitId?: string // exact match
|
|
74
|
+
costCodeId?: string // exact match
|
|
75
|
+
isActive?: boolean // exact match
|
|
76
|
+
completed?: boolean // exact match
|
|
77
|
+
area?: string // exact match
|
|
78
|
+
parentWorkOrder?: string // exact match
|
|
79
|
+
q?: string // partial match on description or clientWorkOrderId
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Returns Workorder[]
|
|
83
|
+
const all = await getWorkorders()
|
|
84
|
+
const active = await getWorkorders({ isActive: true })
|
|
85
|
+
const byBu = await getWorkorders({ businessUnitId: 'BU001', isActive: true })
|
|
86
|
+
const search = await getWorkorders({ q: 'pipe' })
|
|
87
|
+
|
|
88
|
+
// Returns { value, label }[] — always applies isActive: true by default
|
|
89
|
+
const dropdown = await getWorkordersDropdown({ businessUnitId: 'BU001' })
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Employees
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { getEmployees, getEmployeesDropdown } from '@brownandroot/api/cache'
|
|
96
|
+
|
|
97
|
+
interface EmployeeFilters {
|
|
98
|
+
businessUnitId?: string // exact match
|
|
99
|
+
hbu?: string // exact match on home business unit
|
|
100
|
+
supervisor?: string // exact match on supervisor employee ID
|
|
101
|
+
payClass?: string // exact match
|
|
102
|
+
jobType?: string // exact match
|
|
103
|
+
jobStep?: string // exact match
|
|
104
|
+
sector?: string // exact match
|
|
105
|
+
division?: string // exact match
|
|
106
|
+
q?: string // partial match on name or email
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const byHbu = await getEmployees({ hbu: 'TX01' })
|
|
110
|
+
const byName = await getEmployees({ q: 'john' })
|
|
111
|
+
const dropdown = await getEmployeesDropdown({ businessUnitId: 'BU001' })
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Cost Codes
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { getCostcodes, getCostcodesDropdown } from '@brownandroot/api/cache'
|
|
118
|
+
|
|
119
|
+
interface CostcodeFilters {
|
|
120
|
+
businessUnitId?: string // exact match
|
|
121
|
+
isActive?: boolean // exact match
|
|
122
|
+
entryFlag?: boolean // exact match
|
|
123
|
+
payTypeCode?: string // resolves pay type → objectAccount, filters by match
|
|
124
|
+
q?: string // partial match on description or jdeCostCode
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const byBu = await getCostcodes({ businessUnitId: 'BU001' })
|
|
128
|
+
const search = await getCostcodes({ q: 'labor' })
|
|
129
|
+
|
|
130
|
+
// Dropdown applies isActive: true and entryFlag: true by default,
|
|
131
|
+
// and also excludes expired cost codes
|
|
132
|
+
const dropdown = await getCostcodesDropdown({ businessUnitId: 'BU001' })
|
|
133
|
+
const dropdownByPayType = await getCostcodesDropdown({
|
|
134
|
+
businessUnitId: 'BU001',
|
|
135
|
+
payTypeCode: 'PT01',
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
> **payTypeCode cross-reference:** When `payTypeCode` is set, the filter looks up that pay type's `objectAccount` from the (also cached) pay types list and only returns cost codes whose `objectAccount` matches. If the pay type has no `objectAccount`, all cost codes pass this filter.
|
|
140
|
+
|
|
141
|
+
#### Pay Types
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { getPaytypes, getPaytypesDropdown } from '@brownandroot/api/cache'
|
|
145
|
+
|
|
146
|
+
interface PaytypeFilters {
|
|
147
|
+
payClass?: string // exact match
|
|
148
|
+
category?: string // exact match
|
|
149
|
+
type?: string // exact match
|
|
150
|
+
isActive?: boolean // exact match
|
|
151
|
+
perDiemPayType?: boolean // exact match
|
|
152
|
+
q?: string // partial match on description
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hourly = await getPaytypes({ payClass: 'H' })
|
|
156
|
+
const dropdown = await getPaytypesDropdown({ isActive: true })
|
|
157
|
+
// Dropdown returns { value, label, payClass }[]
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Business Units
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { getBusinessUnits, getBusinessUnitsDropdown } from '@brownandroot/api/cache'
|
|
164
|
+
|
|
165
|
+
interface BusinessUnitFilters {
|
|
166
|
+
subsector?: string // exact match
|
|
167
|
+
isActive?: boolean // exact match
|
|
168
|
+
clientId?: string // exact match
|
|
169
|
+
q?: string // partial match on description or clientDescription
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const active = await getBusinessUnits({ isActive: true })
|
|
173
|
+
const dropdown = await getBusinessUnitsDropdown({ subsector: 'Gulf Coast' })
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Job Type / Job Steps
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { getJobtypejobsteps, getJobtypejobstepsDropdown } from '@brownandroot/api/cache'
|
|
180
|
+
|
|
181
|
+
interface JobtypejobstepFilters {
|
|
182
|
+
jobType?: string // exact match
|
|
183
|
+
payclass?: string // exact match
|
|
184
|
+
isActive?: boolean // exact match
|
|
185
|
+
grp?: string // exact match
|
|
186
|
+
q?: string // partial match on description, jobType, or jobStep
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const welders = await getJobtypejobsteps({ jobType: 'WE' })
|
|
190
|
+
const dropdown = await getJobtypejobstepsDropdown({ isActive: true })
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Single-record lookups
|
|
194
|
+
|
|
195
|
+
Single-record functions always fetch fresh from the server (no IndexedDB):
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import {
|
|
199
|
+
getEmployee,
|
|
200
|
+
getSupervisorChain,
|
|
201
|
+
getJdeFromEmail,
|
|
202
|
+
verifyIdentity,
|
|
203
|
+
getWorkorder,
|
|
204
|
+
getCostcode,
|
|
205
|
+
getPaytype,
|
|
206
|
+
getBusinessUnit,
|
|
207
|
+
getJobtypejobstep,
|
|
208
|
+
} from '@brownandroot/api/cache'
|
|
209
|
+
|
|
210
|
+
const emp = await getEmployee('12345')
|
|
211
|
+
const chain = await getSupervisorChain('12345')
|
|
212
|
+
const { jde, employee } = await getJdeFromEmail('john@example.com')
|
|
213
|
+
const verified = await verifyIdentity({
|
|
214
|
+
first3FirstName: 'joh',
|
|
215
|
+
first3LastName: 'doe',
|
|
216
|
+
dob: '1985-03-15',
|
|
217
|
+
ssn4: '4321',
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Cache management
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { clearCache } from '@brownandroot/api/cache'
|
|
225
|
+
|
|
226
|
+
clearCache() // clear all entities
|
|
227
|
+
clearCache('workorders') // clear a specific entity
|
|
228
|
+
clearCache('employees')
|
|
229
|
+
clearCache('costcodes')
|
|
230
|
+
clearCache('paytypes')
|
|
231
|
+
clearCache('businessUnits')
|
|
232
|
+
clearCache('jobtypejobsteps')
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Call `clearCache(entity)` immediately after any mutation that changes that entity so the next read fetches fresh data.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Remote Functions (server-side)
|
|
240
|
+
|
|
241
|
+
For SvelteKit apps that need direct server-side access without the IndexedDB layer, the package also ships ready-to-use remote functions that run on the server and read credentials from environment variables automatically.
|
|
37
242
|
|
|
38
243
|
```svelte
|
|
39
244
|
<script lang="ts">
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
245
|
+
import { getEmployees } from '@brownandroot/api/employees'
|
|
246
|
+
import { getBusinessUnits } from '@brownandroot/api/businessUnits'
|
|
42
247
|
|
|
43
|
-
|
|
44
|
-
const
|
|
248
|
+
// These always fetch from the server on every call
|
|
249
|
+
const employees = $derived(await getEmployees())
|
|
250
|
+
const businessUnits = $derived(await getBusinessUnits())
|
|
45
251
|
</script>
|
|
46
252
|
```
|
|
47
253
|
|
|
@@ -52,7 +258,7 @@ import { query } from '$app/server'
|
|
|
52
258
|
import { getSupervisorChain } from '@brownandroot/api/employees'
|
|
53
259
|
|
|
54
260
|
export const getMyManagers = query(async () => {
|
|
55
|
-
|
|
261
|
+
return (await getSupervisorChain('12345')).slice(0, 2)
|
|
56
262
|
})
|
|
57
263
|
```
|
|
58
264
|
|
|
@@ -85,36 +291,15 @@ const client = new ApiHubClient({
|
|
|
85
291
|
### Fetching
|
|
86
292
|
|
|
87
293
|
```typescript
|
|
88
|
-
// All employees
|
|
89
294
|
const employees = await client.getEmployees()
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
// Single employee by ID — throws if not found
|
|
95
|
-
const employee = await client.getEmployee('12345')
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Search
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
// By name (case-insensitive partial match)
|
|
102
|
-
const results = await client.searchByName('John')
|
|
103
|
-
|
|
104
|
-
// By email (case-insensitive partial match)
|
|
105
|
-
const results = await client.searchByEmail('john@example.com')
|
|
106
|
-
|
|
107
|
-
// By home business unit (case-insensitive partial match)
|
|
108
|
-
const results = await client.searchByHbu('TX01')
|
|
295
|
+
const dropdown = await client.getEmployeesDropdown() // { value: employeeId, label: name }[]
|
|
296
|
+
const employee = await client.getEmployee('12345') // throws if not found
|
|
297
|
+
const employeePrivileged = await client.getEmployeePrivileged('12345') // includes hourlyRate and annualSalary
|
|
109
298
|
```
|
|
110
299
|
|
|
111
300
|
### Org hierarchy
|
|
112
301
|
|
|
113
302
|
```typescript
|
|
114
|
-
// All employees reporting directly to a supervisor
|
|
115
|
-
const reports = await client.getBySupervisor('12345')
|
|
116
|
-
|
|
117
|
-
// Full supervisor chain above an employee (excludes the employee themselves)
|
|
118
303
|
const chain = await client.getSupervisorChain('12345')
|
|
119
304
|
```
|
|
120
305
|
|
|
@@ -128,21 +313,14 @@ const { jde, employee } = await client.getJdeFromEmail('john@example.com')
|
|
|
128
313
|
|
|
129
314
|
### Identity verification
|
|
130
315
|
|
|
131
|
-
Verifies an employee's identity from name, date of birth, and last 4 of SSN alone — no employee ID needed. Returns the full employee record on a match.
|
|
132
|
-
|
|
133
316
|
```typescript
|
|
134
317
|
const employee = await client.verifyIdentity({
|
|
135
|
-
first3FirstName: 'joh',
|
|
136
|
-
first3LastName: 'doe',
|
|
137
|
-
dob: '1985-03-15',
|
|
138
|
-
ssn4: '4321',
|
|
318
|
+
first3FirstName: 'joh',
|
|
319
|
+
first3LastName: 'doe',
|
|
320
|
+
dob: '1985-03-15',
|
|
321
|
+
ssn4: '4321',
|
|
139
322
|
})
|
|
140
|
-
|
|
141
|
-
if (employee) {
|
|
142
|
-
// identity confirmed — full Employee object returned
|
|
143
|
-
} else {
|
|
144
|
-
// no employee matched these inputs
|
|
145
|
-
}
|
|
323
|
+
// Employee on match, null on no match
|
|
146
324
|
// Throws on 400 (missing fields) or 503 (not configured server-side)
|
|
147
325
|
```
|
|
148
326
|
|
|
@@ -150,75 +328,59 @@ if (employee) {
|
|
|
150
328
|
|
|
151
329
|
```typescript
|
|
152
330
|
interface Employee {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// PTO
|
|
200
|
-
topFlexPtoDate: string | null // ISO timestamp
|
|
201
|
-
clientPtoDate: string | null // ISO timestamp
|
|
202
|
-
|
|
203
|
-
// Security & reporting
|
|
204
|
-
securityLevel: string | null
|
|
205
|
-
reportingLevel: string | null
|
|
206
|
-
|
|
207
|
-
// Relationships
|
|
208
|
-
supervisor: string | null // supervisor employee ID
|
|
209
|
-
mentor: string | null
|
|
210
|
-
|
|
211
|
-
// Dates
|
|
212
|
-
hireDate: string | null
|
|
213
|
-
termDate: string | null
|
|
214
|
-
adjustedServiceDate: string | null
|
|
215
|
-
|
|
216
|
-
// Metadata
|
|
217
|
-
source: string | null
|
|
218
|
-
createdAt: string | null
|
|
219
|
-
updatedAtJulian: number | null
|
|
220
|
-
updatedAt: string | null
|
|
331
|
+
employeeId: string
|
|
332
|
+
name: string | null
|
|
333
|
+
email: string | null
|
|
334
|
+
personalEmail: string | null
|
|
335
|
+
clientEmail: string | null
|
|
336
|
+
workEmail: string | null
|
|
337
|
+
badgeNumber: string | null
|
|
338
|
+
nccerNumber: string | null
|
|
339
|
+
company: string | null
|
|
340
|
+
businessUnitId: string | null
|
|
341
|
+
hbu: string | null
|
|
342
|
+
departmentCode: string | null
|
|
343
|
+
division: string | null
|
|
344
|
+
sector: string | null
|
|
345
|
+
subsector: string | null
|
|
346
|
+
phone: string | null
|
|
347
|
+
employementStatus: string | null
|
|
348
|
+
employeePayStatus: string | null
|
|
349
|
+
recordType: string | null
|
|
350
|
+
jobType: string | null
|
|
351
|
+
jobStep: string | null
|
|
352
|
+
jobDescription: string | null
|
|
353
|
+
workSchedule: string | null
|
|
354
|
+
shift: string | null
|
|
355
|
+
payClass: string | null
|
|
356
|
+
payFrequency: string | null
|
|
357
|
+
payCycleCode: string | null
|
|
358
|
+
checkRouteCode: string | null
|
|
359
|
+
residentTaxArea: string | null
|
|
360
|
+
workTaxArea: string | null
|
|
361
|
+
benefitGroup: string | null
|
|
362
|
+
topFlexPtoDate: string | null
|
|
363
|
+
clientPtoDate: string | null
|
|
364
|
+
securityLevel: string | null
|
|
365
|
+
reportingLevel: string | null
|
|
366
|
+
supervisor: string | null
|
|
367
|
+
mentor: string | null
|
|
368
|
+
hireDate: string | null
|
|
369
|
+
termDate: string | null
|
|
370
|
+
adjustedServiceDate: string | null
|
|
371
|
+
identityHash: string | null
|
|
372
|
+
source: string | null
|
|
373
|
+
createdAt: string | null
|
|
374
|
+
updatedAtJulian: number | null
|
|
375
|
+
updatedAt: string | null
|
|
221
376
|
}
|
|
377
|
+
|
|
378
|
+
interface EmployeePrivileged extends Employee {
|
|
379
|
+
hourlyRate: string | null
|
|
380
|
+
annualSalary: string | null
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
getEmployees, getEmployee, employee searches, getJdeFromEmail, and verifyIdentity all return the public Employee shape (without compensation fields). Use getEmployeePrivileged when compensation fields are required.
|
|
222
384
|
```
|
|
223
385
|
|
|
224
386
|
---
|
|
@@ -229,9 +391,6 @@ interface Employee {
|
|
|
229
391
|
const units = await client.getBusinessUnits()
|
|
230
392
|
const dropdown = await client.getBusinessUnitsDropdown() // { value, label }[]
|
|
231
393
|
const unit = await client.getBusinessUnit('BU001')
|
|
232
|
-
|
|
233
|
-
// Search by description (case-insensitive partial match)
|
|
234
|
-
const results = await client.searchBusinessUnits('west')
|
|
235
394
|
```
|
|
236
395
|
|
|
237
396
|
---
|
|
@@ -242,15 +401,6 @@ const results = await client.searchBusinessUnits('west')
|
|
|
242
401
|
const codes = await client.getCostcodes()
|
|
243
402
|
const dropdown = await client.getCostcodesDropdown() // { value, label }[]
|
|
244
403
|
const code = await client.getCostcode('CC001')
|
|
245
|
-
|
|
246
|
-
// Filtered by business unit
|
|
247
|
-
const buDropdown = await client.getCostcodesDropdownByBu('BU001')
|
|
248
|
-
|
|
249
|
-
// Filtered by business unit and pay type
|
|
250
|
-
const buPtDropdown = await client.getCostcodesDropdownByBuAndPayType('BU001', 'PT01')
|
|
251
|
-
|
|
252
|
-
// Search by description or JDE cost code (case-insensitive partial match)
|
|
253
|
-
const results = await client.searchCostcodes('labor')
|
|
254
404
|
```
|
|
255
405
|
|
|
256
406
|
---
|
|
@@ -261,9 +411,6 @@ const results = await client.searchCostcodes('labor')
|
|
|
261
411
|
const types = await client.getPaytypes()
|
|
262
412
|
const dropdown = await client.getPaytypesDropdown() // { value, label, payClass }[]
|
|
263
413
|
const type = await client.getPaytype('PT001')
|
|
264
|
-
|
|
265
|
-
// Search by description (case-insensitive partial match)
|
|
266
|
-
const results = await client.searchPaytypes('regular')
|
|
267
414
|
```
|
|
268
415
|
|
|
269
416
|
---
|
|
@@ -274,12 +421,6 @@ const results = await client.searchPaytypes('regular')
|
|
|
274
421
|
const orders = await client.getWorkorders()
|
|
275
422
|
const dropdown = await client.getWorkordersDropdown() // { value, label }[]
|
|
276
423
|
const order = await client.getWorkorder('WO001')
|
|
277
|
-
|
|
278
|
-
// Filtered by business unit
|
|
279
|
-
const buDropdown = await client.getWorkordersDropdownByBu('BU001')
|
|
280
|
-
|
|
281
|
-
// Search by description or client work order ID (case-insensitive partial match)
|
|
282
|
-
const results = await client.searchWorkorders('pipe')
|
|
283
424
|
```
|
|
284
425
|
|
|
285
426
|
---
|
|
@@ -301,11 +442,11 @@ const item = await client.getJobtypejobstep('JTJS001')
|
|
|
301
442
|
```typescript
|
|
302
443
|
const result = await client.chat({
|
|
303
444
|
messages: [{ role: 'user', content: 'Summarize this document...' }],
|
|
304
|
-
source: 'my-app',
|
|
305
|
-
user: 'jane.doe',
|
|
306
|
-
function: 'summarize',
|
|
307
|
-
temperature: 0.7,
|
|
308
|
-
maxTokens: 1000,
|
|
445
|
+
source: 'my-app',
|
|
446
|
+
user: 'jane.doe',
|
|
447
|
+
function: 'summarize',
|
|
448
|
+
temperature: 0.7,
|
|
449
|
+
maxTokens: 1000,
|
|
309
450
|
})
|
|
310
451
|
|
|
311
452
|
console.log(result.message.content)
|
|
@@ -314,17 +455,13 @@ console.log(result.usage) // { tokensIn, tokensOut, totalTokens }
|
|
|
314
455
|
|
|
315
456
|
### Streaming chat
|
|
316
457
|
|
|
317
|
-
Returns a raw SSE `Response` for you to proxy or consume directly.
|
|
318
|
-
|
|
319
458
|
```typescript
|
|
320
459
|
const response = await client.chatStream({
|
|
321
460
|
messages: [{ role: 'user', content: 'Hello' }],
|
|
322
461
|
userContext: { name: 'Jane Doe', department: 'Engineering', roles: ['admin'] },
|
|
323
|
-
useRag: true,
|
|
324
|
-
tools: ['...'], // optional
|
|
462
|
+
useRag: true,
|
|
325
463
|
source: 'my-app',
|
|
326
464
|
})
|
|
327
|
-
|
|
328
465
|
// Proxy to the browser, or read the SSE stream directly
|
|
329
466
|
```
|
|
330
467
|
|
|
@@ -338,31 +475,20 @@ const logs = await client.getLlmLogs() // newest first
|
|
|
338
475
|
|
|
339
476
|
## Documents (RAG)
|
|
340
477
|
|
|
341
|
-
Upload and search documents in the knowledge base.
|
|
342
|
-
|
|
343
478
|
```typescript
|
|
344
|
-
// Upload a document (PDF or CSV)
|
|
345
479
|
const doc = await client.uploadDocument('report.pdf', base64Content, 'jane.doe')
|
|
346
|
-
|
|
347
|
-
// List all documents
|
|
348
480
|
const docs = await client.listDocuments()
|
|
349
|
-
|
|
350
|
-
// Search with a natural language query
|
|
351
481
|
const results = await client.searchDocuments('overtime policy', 5)
|
|
352
482
|
// results: { chunkId, content, fileName, documentType, score }[]
|
|
353
|
-
|
|
354
|
-
// Delete a document and all its chunks
|
|
355
483
|
await client.deleteDocument(doc.id)
|
|
356
484
|
```
|
|
357
485
|
|
|
358
486
|
---
|
|
359
487
|
|
|
360
|
-
## Cache management
|
|
361
|
-
|
|
362
|
-
All GET methods cache responses client-side for `cacheTtl` milliseconds (default 5 minutes). To invalidate:
|
|
488
|
+
## Cache management (ApiHubClient)
|
|
363
489
|
|
|
364
490
|
```typescript
|
|
365
|
-
client.clearCache()
|
|
491
|
+
client.clearCache() // clear everything
|
|
366
492
|
client.clearCache('/employees') // clear a specific path
|
|
367
493
|
```
|
|
368
494
|
|
|
@@ -390,20 +516,30 @@ import type {
|
|
|
390
516
|
DropdownOption,
|
|
391
517
|
PaytypeDropdownOption,
|
|
392
518
|
} from '@brownandroot/api'
|
|
519
|
+
|
|
520
|
+
// Filter interfaces (from cache module)
|
|
521
|
+
import type {
|
|
522
|
+
EmployeeFilters,
|
|
523
|
+
WorkorderFilters,
|
|
524
|
+
CostcodeFilters,
|
|
525
|
+
PaytypeFilters,
|
|
526
|
+
BusinessUnitFilters,
|
|
527
|
+
JobtypejobstepFilters,
|
|
528
|
+
} from '@brownandroot/api/cache'
|
|
393
529
|
```
|
|
394
530
|
|
|
395
531
|
---
|
|
396
532
|
|
|
397
533
|
## Error handling
|
|
398
534
|
|
|
399
|
-
All methods throw an `Error` when the API returns a non-OK response.
|
|
535
|
+
All methods throw an `Error` when the API returns a non-OK response.
|
|
400
536
|
|
|
401
537
|
```typescript
|
|
402
538
|
try {
|
|
403
|
-
const emp = await
|
|
539
|
+
const emp = await getEmployee('99999')
|
|
404
540
|
} catch (err) {
|
|
405
541
|
console.error(err.message) // "Employee not found"
|
|
406
542
|
}
|
|
407
543
|
```
|
|
408
544
|
|
|
409
|
-
`verifyIdentity`
|
|
545
|
+
`verifyIdentity` returns `null` when no employee matches the inputs, and only throws for request errors (400, 503, network failure).
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const getBusinessUnits: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").BusinessUnit[]>;
|
|
2
2
|
export declare const getBusinessUnitsDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
3
|
export declare const getBusinessUnit: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit>;
|
|
4
|
-
export declare const searchBusinessUnits: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").BusinessUnit[]>;
|
|
@@ -4,4 +4,3 @@ import { getClient } from './client.js';
|
|
|
4
4
|
export const getBusinessUnits = query(async () => getClient().getBusinessUnits());
|
|
5
5
|
export const getBusinessUnitsDropdown = query(async () => getClient().getBusinessUnitsDropdown());
|
|
6
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/cache.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side cache API for @brownandroot/api.
|
|
3
|
+
*
|
|
4
|
+
* Wraps remote functions with an IndexedDB stale-while-revalidate cache so
|
|
5
|
+
* pages load instantly on subsequent visits. Filters are applied in-memory
|
|
6
|
+
* against the full cached dataset — no per-field server endpoints needed.
|
|
7
|
+
*
|
|
8
|
+
* Import from: @brownandroot/api/cache
|
|
9
|
+
*/
|
|
10
|
+
import type { Employee, EmployeePrivileged, BusinessUnit, Costcode, Paytype, Workorder, Jobtypejobstep, DropdownOption, PaytypeDropdownOption } from './index.js';
|
|
11
|
+
import { type IdbStore } from './idb.js';
|
|
12
|
+
export interface EmployeeFilters {
|
|
13
|
+
/** Exact match on businessUnitId */
|
|
14
|
+
businessUnitId?: string;
|
|
15
|
+
/** Exact match on home business unit (hbu) */
|
|
16
|
+
hbu?: string;
|
|
17
|
+
/** Exact match on supervisor employee ID */
|
|
18
|
+
supervisor?: string;
|
|
19
|
+
/** Exact match on payClass */
|
|
20
|
+
payClass?: string;
|
|
21
|
+
/** Exact match on jobType */
|
|
22
|
+
jobType?: string;
|
|
23
|
+
/** Exact match on jobStep */
|
|
24
|
+
jobStep?: string;
|
|
25
|
+
/** Exact match on sector */
|
|
26
|
+
sector?: string;
|
|
27
|
+
/** Exact match on division */
|
|
28
|
+
division?: string;
|
|
29
|
+
/** Case-insensitive partial match on name or email */
|
|
30
|
+
q?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WorkorderFilters {
|
|
33
|
+
/** Exact match on businessUnitId */
|
|
34
|
+
businessUnitId?: string;
|
|
35
|
+
/** Exact match on costCodeId */
|
|
36
|
+
costCodeId?: string;
|
|
37
|
+
/** Exact match on isActive */
|
|
38
|
+
isActive?: boolean;
|
|
39
|
+
/** Exact match on completed */
|
|
40
|
+
completed?: boolean;
|
|
41
|
+
/** Exact match on area */
|
|
42
|
+
area?: string;
|
|
43
|
+
/** Exact match on parentWorkOrder */
|
|
44
|
+
parentWorkOrder?: string;
|
|
45
|
+
/** Case-insensitive partial match on description or clientWorkOrderId */
|
|
46
|
+
q?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CostcodeFilters {
|
|
49
|
+
/** Exact match on businessUnitId */
|
|
50
|
+
businessUnitId?: string;
|
|
51
|
+
/** Exact match on isActive */
|
|
52
|
+
isActive?: boolean;
|
|
53
|
+
/** Exact match on entryFlag */
|
|
54
|
+
entryFlag?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Filter by pay type — resolves the pay type's objectAccount and returns
|
|
57
|
+
* only cost codes whose objectAccount matches. If the pay type has no
|
|
58
|
+
* objectAccount, all cost codes pass this filter.
|
|
59
|
+
*/
|
|
60
|
+
payTypeCode?: string;
|
|
61
|
+
/** Case-insensitive partial match on description or jdeCostCode */
|
|
62
|
+
q?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface PaytypeFilters {
|
|
65
|
+
/** Exact match on payClass */
|
|
66
|
+
payClass?: string;
|
|
67
|
+
/** Exact match on category */
|
|
68
|
+
category?: string;
|
|
69
|
+
/** Exact match on type */
|
|
70
|
+
type?: string;
|
|
71
|
+
/** Exact match on isActive */
|
|
72
|
+
isActive?: boolean;
|
|
73
|
+
/** Exact match on perDiemPayType */
|
|
74
|
+
perDiemPayType?: boolean;
|
|
75
|
+
/** Case-insensitive partial match on description */
|
|
76
|
+
q?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface BusinessUnitFilters {
|
|
79
|
+
/** Exact match on subsector */
|
|
80
|
+
subsector?: string;
|
|
81
|
+
/** Exact match on isActive */
|
|
82
|
+
isActive?: boolean;
|
|
83
|
+
/** Exact match on clientId */
|
|
84
|
+
clientId?: string;
|
|
85
|
+
/** Case-insensitive partial match on description or clientDescription */
|
|
86
|
+
q?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface JobtypejobstepFilters {
|
|
89
|
+
/** Exact match on jobType */
|
|
90
|
+
jobType?: string;
|
|
91
|
+
/** Exact match on payclass */
|
|
92
|
+
payclass?: string;
|
|
93
|
+
/** Exact match on isActive */
|
|
94
|
+
isActive?: boolean;
|
|
95
|
+
/** Exact match on grp */
|
|
96
|
+
grp?: string;
|
|
97
|
+
/** Case-insensitive partial match on description, jobType, or jobStep */
|
|
98
|
+
q?: string;
|
|
99
|
+
}
|
|
100
|
+
export declare function getEmployees(filters?: EmployeeFilters): Promise<Employee[]>;
|
|
101
|
+
export declare function getEmployeesDropdown(filters?: EmployeeFilters): Promise<DropdownOption[]>;
|
|
102
|
+
/** Single employee by ID — always fetches fresh (no IndexedDB). */
|
|
103
|
+
export declare function getEmployee(employeeId: string): Promise<Employee>;
|
|
104
|
+
/** Single employee by ID including compensation fields — always fetches fresh (no IndexedDB). */
|
|
105
|
+
export declare function getEmployeePrivileged(employeeId: string): Promise<EmployeePrivileged>;
|
|
106
|
+
/** Full supervisor chain above an employee — always fetches fresh. */
|
|
107
|
+
export declare function getSupervisorChain(employeeId: string): Promise<Employee[]>;
|
|
108
|
+
/** Look up JDE number and employee from email — always fetches fresh. */
|
|
109
|
+
export declare function getJdeFromEmail(email: string): Promise<{
|
|
110
|
+
jde: string | null;
|
|
111
|
+
employee: Employee | null;
|
|
112
|
+
}>;
|
|
113
|
+
/** Verify employee identity — always fetches fresh. */
|
|
114
|
+
export declare function verifyIdentity(inputs: {
|
|
115
|
+
first3FirstName: string;
|
|
116
|
+
first3LastName: string;
|
|
117
|
+
dob: string;
|
|
118
|
+
ssn4: string;
|
|
119
|
+
}): Promise<Employee | null>;
|
|
120
|
+
export declare function getWorkorders(filters?: WorkorderFilters): Promise<Workorder[]>;
|
|
121
|
+
export declare function getWorkordersDropdown(filters?: WorkorderFilters): Promise<DropdownOption[]>;
|
|
122
|
+
/** Single workorder by ID — always fetches fresh (no IndexedDB). */
|
|
123
|
+
export declare function getWorkorder(id: string): Promise<Workorder>;
|
|
124
|
+
export declare function getCostcodes(filters?: CostcodeFilters): Promise<Costcode[]>;
|
|
125
|
+
export declare function getCostcodesDropdown(filters?: CostcodeFilters): Promise<DropdownOption[]>;
|
|
126
|
+
/** Single cost code by ID — always fetches fresh (no IndexedDB). */
|
|
127
|
+
export declare function getCostcode(id: string): Promise<Costcode>;
|
|
128
|
+
export declare function getPaytypes(filters?: PaytypeFilters): Promise<Paytype[]>;
|
|
129
|
+
export declare function getPaytypesDropdown(filters?: PaytypeFilters): Promise<PaytypeDropdownOption[]>;
|
|
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>;
|
|
140
|
+
/**
|
|
141
|
+
* Clear the IndexedDB cache for a specific entity, or all entities.
|
|
142
|
+
*
|
|
143
|
+
* Call after mutations to ensure the next read fetches fresh data from
|
|
144
|
+
* the server instead of returning stale cached results.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* await createWorkorder(data)
|
|
148
|
+
* clearCache('workorders') // next getWorkorders() will re-fetch
|
|
149
|
+
*
|
|
150
|
+
* clearCache() // clear everything
|
|
151
|
+
*/
|
|
152
|
+
export declare function clearCache(entity?: IdbStore): void;
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side cache API for @brownandroot/api.
|
|
3
|
+
*
|
|
4
|
+
* Wraps remote functions with an IndexedDB stale-while-revalidate cache so
|
|
5
|
+
* pages load instantly on subsequent visits. Filters are applied in-memory
|
|
6
|
+
* against the full cached dataset — no per-field server endpoints needed.
|
|
7
|
+
*
|
|
8
|
+
* Import from: @brownandroot/api/cache
|
|
9
|
+
*/
|
|
10
|
+
import { idbGet, idbSet, idbClear } from './idb.js';
|
|
11
|
+
// Remote functions — called as HTTP on the client, directly on the server (SSR)
|
|
12
|
+
import { getEmployees as _getEmployees, getEmployee as _getEmployee, getEmployeePrivileged as _getEmployeePrivileged, getJdeFromEmail as _getJdeFromEmail, getSupervisorChain as _getSupervisorChain, verifyIdentity as _verifyIdentity, } from './employees.remote.js';
|
|
13
|
+
import { getBusinessUnits as _getBusinessUnits, getBusinessUnit as _getBusinessUnit } from './businessUnits.remote.js';
|
|
14
|
+
import { getCostcodes as _getCostcodes, getCostcode as _getCostcode } from './costcodes.remote.js';
|
|
15
|
+
import { getPaytypes as _getPaytypes, getPaytype as _getPaytype } from './paytypes.remote.js';
|
|
16
|
+
import { getWorkorders as _getWorkorders, getWorkorder as _getWorkorder } from './workorders.remote.js';
|
|
17
|
+
import { getJobtypejobsteps as _getJobtypejobsteps, getJobtypejobstep as _getJobtypejobstep, } from './jobtypejobsteps.remote.js';
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Internal: stale-while-revalidate fetch helpers
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
async function loadCached(store, fetcher) {
|
|
22
|
+
const cached = await idbGet(store, 'all');
|
|
23
|
+
if (cached) {
|
|
24
|
+
// Return stale data immediately; refresh in background for next call
|
|
25
|
+
fetcher()
|
|
26
|
+
.then((fresh) => idbSet(store, 'all', fresh))
|
|
27
|
+
.catch(() => { });
|
|
28
|
+
return cached.data;
|
|
29
|
+
}
|
|
30
|
+
// Cache miss — must await
|
|
31
|
+
const data = await fetcher();
|
|
32
|
+
await idbSet(store, 'all', data);
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Internal: filter helpers
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
function applyEmployeeFilters(data, f) {
|
|
39
|
+
if (!f)
|
|
40
|
+
return data;
|
|
41
|
+
return data.filter((e) => {
|
|
42
|
+
if (f.businessUnitId !== undefined && e.businessUnitId !== f.businessUnitId)
|
|
43
|
+
return false;
|
|
44
|
+
if (f.hbu !== undefined && e.hbu !== f.hbu)
|
|
45
|
+
return false;
|
|
46
|
+
if (f.supervisor !== undefined && e.supervisor !== f.supervisor)
|
|
47
|
+
return false;
|
|
48
|
+
if (f.payClass !== undefined && e.payClass !== f.payClass)
|
|
49
|
+
return false;
|
|
50
|
+
if (f.jobType !== undefined && e.jobType !== f.jobType)
|
|
51
|
+
return false;
|
|
52
|
+
if (f.jobStep !== undefined && e.jobStep !== f.jobStep)
|
|
53
|
+
return false;
|
|
54
|
+
if (f.sector !== undefined && e.sector !== f.sector)
|
|
55
|
+
return false;
|
|
56
|
+
if (f.division !== undefined && e.division !== f.division)
|
|
57
|
+
return false;
|
|
58
|
+
if (f.q) {
|
|
59
|
+
const q = f.q.toLowerCase();
|
|
60
|
+
const name = e.name?.toLowerCase() ?? '';
|
|
61
|
+
const email = e.email?.toLowerCase() ?? '';
|
|
62
|
+
if (!name.includes(q) && !email.includes(q))
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function applyWorkorderFilters(data, f) {
|
|
69
|
+
if (!f)
|
|
70
|
+
return data;
|
|
71
|
+
return data.filter((w) => {
|
|
72
|
+
if (f.businessUnitId !== undefined && w.businessUnitId !== f.businessUnitId)
|
|
73
|
+
return false;
|
|
74
|
+
if (f.costCodeId !== undefined && w.costCodeId !== f.costCodeId)
|
|
75
|
+
return false;
|
|
76
|
+
if (f.isActive !== undefined && w.isActive !== f.isActive)
|
|
77
|
+
return false;
|
|
78
|
+
if (f.completed !== undefined && w.completed !== f.completed)
|
|
79
|
+
return false;
|
|
80
|
+
if (f.area !== undefined && w.area !== f.area)
|
|
81
|
+
return false;
|
|
82
|
+
if (f.parentWorkOrder !== undefined && w.parentWorkOrder !== f.parentWorkOrder)
|
|
83
|
+
return false;
|
|
84
|
+
if (f.q) {
|
|
85
|
+
const q = f.q.toLowerCase();
|
|
86
|
+
const desc = w.description?.toLowerCase() ?? '';
|
|
87
|
+
const wo = w.clientWorkOrderId?.toLowerCase() ?? '';
|
|
88
|
+
if (!desc.includes(q) && !wo.includes(q))
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function applyPaytypeFilters(data, f) {
|
|
95
|
+
if (!f)
|
|
96
|
+
return data;
|
|
97
|
+
return data.filter((p) => {
|
|
98
|
+
if (f.payClass !== undefined && p.payClass !== f.payClass)
|
|
99
|
+
return false;
|
|
100
|
+
if (f.category !== undefined && p.category !== f.category)
|
|
101
|
+
return false;
|
|
102
|
+
if (f.type !== undefined && p.type !== f.type)
|
|
103
|
+
return false;
|
|
104
|
+
if (f.isActive !== undefined && p.isActive !== f.isActive)
|
|
105
|
+
return false;
|
|
106
|
+
if (f.perDiemPayType !== undefined && p.perDiemPayType !== f.perDiemPayType)
|
|
107
|
+
return false;
|
|
108
|
+
if (f.q) {
|
|
109
|
+
const q = f.q.toLowerCase();
|
|
110
|
+
if (!p.description.toLowerCase().includes(q))
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function applyBusinessUnitFilters(data, f) {
|
|
117
|
+
if (!f)
|
|
118
|
+
return data;
|
|
119
|
+
return data.filter((b) => {
|
|
120
|
+
if (f.subsector !== undefined && b.subsector !== f.subsector)
|
|
121
|
+
return false;
|
|
122
|
+
if (f.isActive !== undefined && b.isActive !== f.isActive)
|
|
123
|
+
return false;
|
|
124
|
+
if (f.clientId !== undefined && b.clientId !== f.clientId)
|
|
125
|
+
return false;
|
|
126
|
+
if (f.q) {
|
|
127
|
+
const q = f.q.toLowerCase();
|
|
128
|
+
const desc = b.description.toLowerCase();
|
|
129
|
+
const client = b.clientDescription?.toLowerCase() ?? '';
|
|
130
|
+
if (!desc.includes(q) && !client.includes(q))
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function applyJobtypejobstepFilters(data, f) {
|
|
137
|
+
if (!f)
|
|
138
|
+
return data;
|
|
139
|
+
return data.filter((j) => {
|
|
140
|
+
if (f.jobType !== undefined && j.jobType !== f.jobType)
|
|
141
|
+
return false;
|
|
142
|
+
if (f.payclass !== undefined && j.payclass !== f.payclass)
|
|
143
|
+
return false;
|
|
144
|
+
if (f.isActive !== undefined && j.isActive !== f.isActive)
|
|
145
|
+
return false;
|
|
146
|
+
if (f.grp !== undefined && j.grp !== f.grp)
|
|
147
|
+
return false;
|
|
148
|
+
if (f.q) {
|
|
149
|
+
const q = f.q.toLowerCase();
|
|
150
|
+
const desc = j.description?.toLowerCase() ?? '';
|
|
151
|
+
const jt = j.jobType?.toLowerCase() ?? '';
|
|
152
|
+
const js = j.jobStep?.toLowerCase() ?? '';
|
|
153
|
+
if (!desc.includes(q) && !jt.includes(q) && !js.includes(q))
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// Costcodes filter is async because payTypeCode requires a cross-reference
|
|
160
|
+
async function applyCostcodeFilters(data, f) {
|
|
161
|
+
if (!f)
|
|
162
|
+
return data;
|
|
163
|
+
// Resolve payTypeCode → objectAccount
|
|
164
|
+
let payTypeObjectAccount;
|
|
165
|
+
if (f.payTypeCode !== undefined) {
|
|
166
|
+
const allPaytypes = await loadCached('paytypes', () => _getPaytypes());
|
|
167
|
+
payTypeObjectAccount = allPaytypes.find((p) => p.id === f.payTypeCode)?.objectAccount;
|
|
168
|
+
}
|
|
169
|
+
return data.filter((c) => {
|
|
170
|
+
if (f.businessUnitId !== undefined && c.businessUnitId !== f.businessUnitId)
|
|
171
|
+
return false;
|
|
172
|
+
if (f.isActive !== undefined && c.isActive !== f.isActive)
|
|
173
|
+
return false;
|
|
174
|
+
if (f.entryFlag !== undefined && c.entryFlag !== f.entryFlag)
|
|
175
|
+
return false;
|
|
176
|
+
if (f.payTypeCode !== undefined) {
|
|
177
|
+
// If paytype has an objectAccount, cost code must match it
|
|
178
|
+
if (payTypeObjectAccount && c.objectAccount !== payTypeObjectAccount)
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
if (f.q) {
|
|
182
|
+
const q = f.q.toLowerCase();
|
|
183
|
+
const desc = c.description?.toLowerCase() ?? '';
|
|
184
|
+
const code = c.jdeCostCode?.toLowerCase() ?? '';
|
|
185
|
+
if (!desc.includes(q) && !code.includes(q))
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// Public API — Employees
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
export async function getEmployees(filters) {
|
|
195
|
+
const all = await loadCached('employees', () => _getEmployees());
|
|
196
|
+
return applyEmployeeFilters(all, filters);
|
|
197
|
+
}
|
|
198
|
+
export async function getEmployeesDropdown(filters) {
|
|
199
|
+
const results = await getEmployees(filters);
|
|
200
|
+
return results.map((e) => ({ value: e.employeeId, label: e.name ?? e.employeeId }));
|
|
201
|
+
}
|
|
202
|
+
/** Single employee by ID — always fetches fresh (no IndexedDB). */
|
|
203
|
+
export async function getEmployee(employeeId) {
|
|
204
|
+
return _getEmployee(employeeId);
|
|
205
|
+
}
|
|
206
|
+
/** Single employee by ID including compensation fields — always fetches fresh (no IndexedDB). */
|
|
207
|
+
export async function getEmployeePrivileged(employeeId) {
|
|
208
|
+
return _getEmployeePrivileged(employeeId);
|
|
209
|
+
}
|
|
210
|
+
/** Full supervisor chain above an employee — always fetches fresh. */
|
|
211
|
+
export async function getSupervisorChain(employeeId) {
|
|
212
|
+
return _getSupervisorChain(employeeId);
|
|
213
|
+
}
|
|
214
|
+
/** Look up JDE number and employee from email — always fetches fresh. */
|
|
215
|
+
export async function getJdeFromEmail(email) {
|
|
216
|
+
return _getJdeFromEmail(email);
|
|
217
|
+
}
|
|
218
|
+
/** Verify employee identity — always fetches fresh. */
|
|
219
|
+
export async function verifyIdentity(inputs) {
|
|
220
|
+
return _verifyIdentity(inputs);
|
|
221
|
+
}
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
// Public API — Workorders
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
export async function getWorkorders(filters) {
|
|
226
|
+
const all = await loadCached('workorders', () => _getWorkorders());
|
|
227
|
+
return applyWorkorderFilters(all, filters);
|
|
228
|
+
}
|
|
229
|
+
export async function getWorkordersDropdown(filters) {
|
|
230
|
+
const results = await getWorkorders({ isActive: true, ...filters });
|
|
231
|
+
return results.map((w) => ({ value: w.id, label: w.description ?? w.id }));
|
|
232
|
+
}
|
|
233
|
+
/** Single workorder by ID — always fetches fresh (no IndexedDB). */
|
|
234
|
+
export async function getWorkorder(id) {
|
|
235
|
+
return _getWorkorder(id);
|
|
236
|
+
}
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
// Public API — Cost Codes
|
|
239
|
+
// ---------------------------------------------------------------------------
|
|
240
|
+
export async function getCostcodes(filters) {
|
|
241
|
+
const all = await loadCached('costcodes', () => _getCostcodes());
|
|
242
|
+
return applyCostcodeFilters(all, filters);
|
|
243
|
+
}
|
|
244
|
+
export async function getCostcodesDropdown(filters) {
|
|
245
|
+
const mergedFilters = { isActive: true, entryFlag: true, ...filters };
|
|
246
|
+
const results = await getCostcodes(mergedFilters);
|
|
247
|
+
const now = new Date();
|
|
248
|
+
return results
|
|
249
|
+
.filter((c) => !c.expirationDate || new Date(c.expirationDate) >= now)
|
|
250
|
+
.map((c) => ({
|
|
251
|
+
value: c.id,
|
|
252
|
+
label: `${c.jdeCostCode ?? c.id} - ${c.description ?? ''}`,
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
/** Single cost code by ID — always fetches fresh (no IndexedDB). */
|
|
256
|
+
export async function getCostcode(id) {
|
|
257
|
+
return _getCostcode(id);
|
|
258
|
+
}
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
// Public API — Pay Types
|
|
261
|
+
// ---------------------------------------------------------------------------
|
|
262
|
+
export async function getPaytypes(filters) {
|
|
263
|
+
const all = await loadCached('paytypes', () => _getPaytypes());
|
|
264
|
+
return applyPaytypeFilters(all, filters);
|
|
265
|
+
}
|
|
266
|
+
export async function getPaytypesDropdown(filters) {
|
|
267
|
+
const results = await getPaytypes(filters);
|
|
268
|
+
return results.map((p) => ({ value: p.id, label: p.description, payClass: p.payClass }));
|
|
269
|
+
}
|
|
270
|
+
/** Single pay type by ID — always fetches fresh (no IndexedDB). */
|
|
271
|
+
export async function getPaytype(id) {
|
|
272
|
+
return _getPaytype(id);
|
|
273
|
+
}
|
|
274
|
+
// ---------------------------------------------------------------------------
|
|
275
|
+
// Public API — Business Units
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
export async function getBusinessUnits(filters) {
|
|
278
|
+
const all = await loadCached('businessUnits', () => _getBusinessUnits());
|
|
279
|
+
return applyBusinessUnitFilters(all, filters);
|
|
280
|
+
}
|
|
281
|
+
export async function getBusinessUnitsDropdown(filters) {
|
|
282
|
+
const results = await getBusinessUnits(filters);
|
|
283
|
+
return results.map((b) => ({ value: b.id, label: b.description }));
|
|
284
|
+
}
|
|
285
|
+
/** Single business unit by ID — always fetches fresh (no IndexedDB). */
|
|
286
|
+
export async function getBusinessUnit(id) {
|
|
287
|
+
return _getBusinessUnit(id);
|
|
288
|
+
}
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
// Public API — Job Type / Job Steps
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
export async function getJobtypejobsteps(filters) {
|
|
293
|
+
const all = await loadCached('jobtypejobsteps', () => _getJobtypejobsteps());
|
|
294
|
+
return applyJobtypejobstepFilters(all, filters);
|
|
295
|
+
}
|
|
296
|
+
export async function getJobtypejobstepsDropdown(filters) {
|
|
297
|
+
const results = await getJobtypejobsteps(filters);
|
|
298
|
+
return results.map((j) => ({
|
|
299
|
+
value: j.id,
|
|
300
|
+
label: j.description ?? `${j.jobType ?? ''} ${j.jobStep ?? ''}`.trim(),
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
/** Single job type/job step by ID — always fetches fresh (no IndexedDB). */
|
|
304
|
+
export async function getJobtypejobstep(id) {
|
|
305
|
+
return _getJobtypejobstep(id);
|
|
306
|
+
}
|
|
307
|
+
// ---------------------------------------------------------------------------
|
|
308
|
+
// Cache management
|
|
309
|
+
// ---------------------------------------------------------------------------
|
|
310
|
+
/**
|
|
311
|
+
* Clear the IndexedDB cache for a specific entity, or all entities.
|
|
312
|
+
*
|
|
313
|
+
* Call after mutations to ensure the next read fetches fresh data from
|
|
314
|
+
* the server instead of returning stale cached results.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* await createWorkorder(data)
|
|
318
|
+
* clearCache('workorders') // next getWorkorders() will re-fetch
|
|
319
|
+
*
|
|
320
|
+
* clearCache() // clear everything
|
|
321
|
+
*/
|
|
322
|
+
export function clearCache(entity) {
|
|
323
|
+
idbClear(entity).catch(() => { });
|
|
324
|
+
}
|
|
@@ -1,9 +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
3
|
export declare const getCostcode: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode>;
|
|
4
|
-
export declare const getCostcodesDropdownByBu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").DropdownOption[]>;
|
|
5
|
-
export declare const getCostcodesDropdownByBuAndPayType: import("@sveltejs/kit").RemoteQueryFunction<{
|
|
6
|
-
businessUnitId: string;
|
|
7
|
-
payTypeCode: string;
|
|
8
|
-
}, import("./index.js").DropdownOption[]>;
|
|
9
|
-
export declare const searchCostcodes: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Costcode[]>;
|
package/dist/costcodes.remote.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { query } from '$app/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { getClient } from './client.js';
|
|
4
|
-
const buPayTypeSchema = z.object({
|
|
5
|
-
businessUnitId: z.string(),
|
|
6
|
-
payTypeCode: z.string(),
|
|
7
|
-
});
|
|
8
4
|
export const getCostcodes = query(async () => getClient().getCostcodes());
|
|
9
5
|
export const getCostcodesDropdown = query(async () => getClient().getCostcodesDropdown());
|
|
10
6
|
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));
|
|
@@ -1,15 +1,12 @@
|
|
|
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
3
|
export declare const getEmployee: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee>;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const getBySupervisor: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
6
|
-
export declare const searchByEmail: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
4
|
+
export declare const getEmployeePrivileged: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").EmployeePrivileged>;
|
|
7
5
|
export declare const getSupervisorChain: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
8
6
|
export declare const getJdeFromEmail: import("@sveltejs/kit").RemoteQueryFunction<string, {
|
|
9
7
|
jde: string | null;
|
|
10
8
|
employee: import("./index.js").Employee | null;
|
|
11
9
|
}>;
|
|
12
|
-
export declare const searchByHbu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Employee[]>;
|
|
13
10
|
export declare const verifyIdentity: import("@sveltejs/kit").RemoteCommand<{
|
|
14
11
|
first3FirstName: string;
|
|
15
12
|
first3LastName: string;
|
package/dist/employees.remote.js
CHANGED
|
@@ -11,10 +11,7 @@ const verifyIdentitySchema = z.object({
|
|
|
11
11
|
export const getEmployees = query(async () => getClient().getEmployees());
|
|
12
12
|
export const getEmployeesDropdown = query(async () => getClient().getEmployeesDropdown());
|
|
13
13
|
export const getEmployee = query(employeeIdSchema, async (employeeId) => getClient().getEmployee(employeeId));
|
|
14
|
-
export const
|
|
15
|
-
export const getBySupervisor = query(employeeIdSchema, async (supervisorId) => getClient().getBySupervisor(supervisorId));
|
|
16
|
-
export const searchByEmail = query(z.string(), async (email) => getClient().searchByEmail(email));
|
|
14
|
+
export const getEmployeePrivileged = query(employeeIdSchema, async (employeeId) => getClient().getEmployeePrivileged(employeeId));
|
|
17
15
|
export const getSupervisorChain = query(employeeIdSchema, async (employeeId) => getClient().getSupervisorChain(employeeId));
|
|
18
16
|
export const getJdeFromEmail = query(z.string(), async (email) => getClient().getJdeFromEmail(email));
|
|
19
|
-
export const searchByHbu = query(z.string(), async (hbu) => getClient().searchByHbu(hbu));
|
|
20
17
|
export const verifyIdentity = command(verifyIdentitySchema, async (inputs) => getClient().verifyIdentity(inputs));
|
package/dist/idb.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const STORES: readonly ["workorders", "employees", "costcodes", "paytypes", "businessUnits", "jobtypejobsteps"];
|
|
2
|
+
export type IdbStore = (typeof STORES)[number];
|
|
3
|
+
interface IdbEntry<T> {
|
|
4
|
+
data: T;
|
|
5
|
+
fetchedAt: number;
|
|
6
|
+
}
|
|
7
|
+
/** Get a cached entry. Returns null in SSR (no window) or on cache miss. */
|
|
8
|
+
export declare function idbGet<T>(store: IdbStore, key: string): Promise<IdbEntry<T> | null>;
|
|
9
|
+
/** Store a value with the current timestamp. */
|
|
10
|
+
export declare function idbSet<T>(store: IdbStore, key: string, data: T): Promise<void>;
|
|
11
|
+
/** Clear a specific store, or all stores when called with no argument. */
|
|
12
|
+
export declare function idbClear(store?: IdbStore): Promise<void>;
|
|
13
|
+
export {};
|
package/dist/idb.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const DB_NAME = 'apihub-cache';
|
|
2
|
+
const DB_VERSION = 1;
|
|
3
|
+
const STORES = [
|
|
4
|
+
'workorders',
|
|
5
|
+
'employees',
|
|
6
|
+
'costcodes',
|
|
7
|
+
'paytypes',
|
|
8
|
+
'businessUnits',
|
|
9
|
+
'jobtypejobsteps',
|
|
10
|
+
];
|
|
11
|
+
function openDb() {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
14
|
+
req.onupgradeneeded = () => {
|
|
15
|
+
const db = req.result;
|
|
16
|
+
for (const store of STORES) {
|
|
17
|
+
if (!db.objectStoreNames.contains(store)) {
|
|
18
|
+
db.createObjectStore(store);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
req.onsuccess = () => resolve(req.result);
|
|
23
|
+
req.onerror = () => reject(req.error);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Get a cached entry. Returns null in SSR (no window) or on cache miss. */
|
|
27
|
+
export async function idbGet(store, key) {
|
|
28
|
+
if (typeof window === 'undefined')
|
|
29
|
+
return null;
|
|
30
|
+
try {
|
|
31
|
+
const db = await openDb();
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const tx = db.transaction(store, 'readonly');
|
|
34
|
+
const req = tx.objectStore(store).get(key);
|
|
35
|
+
req.onsuccess = () => resolve(req.result ?? null);
|
|
36
|
+
req.onerror = () => reject(req.error);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Store a value with the current timestamp. */
|
|
44
|
+
export async function idbSet(store, key, data) {
|
|
45
|
+
if (typeof window === 'undefined')
|
|
46
|
+
return;
|
|
47
|
+
try {
|
|
48
|
+
const db = await openDb();
|
|
49
|
+
await new Promise((resolve, reject) => {
|
|
50
|
+
const tx = db.transaction(store, 'readwrite');
|
|
51
|
+
const req = tx.objectStore(store).put({ data, fetchedAt: Date.now() }, key);
|
|
52
|
+
req.onsuccess = () => resolve();
|
|
53
|
+
req.onerror = () => reject(req.error);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Ignore write failures — cache is best-effort
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Clear a specific store, or all stores when called with no argument. */
|
|
61
|
+
export async function idbClear(store) {
|
|
62
|
+
if (typeof window === 'undefined')
|
|
63
|
+
return;
|
|
64
|
+
try {
|
|
65
|
+
const db = await openDb();
|
|
66
|
+
const storeNames = store ? [store] : [...STORES];
|
|
67
|
+
await new Promise((resolve, reject) => {
|
|
68
|
+
const tx = db.transaction(storeNames, 'readwrite');
|
|
69
|
+
for (const s of storeNames) {
|
|
70
|
+
tx.objectStore(s).clear();
|
|
71
|
+
}
|
|
72
|
+
tx.oncomplete = () => resolve();
|
|
73
|
+
tx.onerror = () => reject(tx.error);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Ignore failures
|
|
78
|
+
}
|
|
79
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,8 +24,6 @@ export interface Employee {
|
|
|
24
24
|
jobDescription: string | null;
|
|
25
25
|
workSchedule: string | null;
|
|
26
26
|
shift: string | null;
|
|
27
|
-
hourlyRate: string | null;
|
|
28
|
-
annualSalary: string | null;
|
|
29
27
|
termDate: string | null;
|
|
30
28
|
hireDate: string | null;
|
|
31
29
|
topFlexPtoDate: string | null;
|
|
@@ -50,6 +48,10 @@ export interface Employee {
|
|
|
50
48
|
updatedAtJulian: number | null;
|
|
51
49
|
updatedAt: string | null;
|
|
52
50
|
}
|
|
51
|
+
export interface EmployeePrivileged extends Employee {
|
|
52
|
+
hourlyRate: string | null;
|
|
53
|
+
annualSalary: string | null;
|
|
54
|
+
}
|
|
53
55
|
export interface ApiHubClientOptions {
|
|
54
56
|
baseUrl: string;
|
|
55
57
|
apiKey: string;
|
|
@@ -218,6 +220,8 @@ export declare class ApiHubClient {
|
|
|
218
220
|
getEmployeesDropdown(): Promise<DropdownOption[]>;
|
|
219
221
|
/** Get a single employee by employeeId */
|
|
220
222
|
getEmployee(employeeId: string): Promise<Employee>;
|
|
223
|
+
/** Get a single employee with compensation fields by employeeId */
|
|
224
|
+
getEmployeePrivileged(employeeId: string): Promise<EmployeePrivileged>;
|
|
221
225
|
/** Search employees by name (case-insensitive partial match) */
|
|
222
226
|
searchByName(name: string): Promise<Employee[]>;
|
|
223
227
|
/** Get all employees reporting to a supervisor */
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,10 @@ export class ApiHubClient {
|
|
|
61
61
|
async getEmployee(employeeId) {
|
|
62
62
|
return this.request(`/employees/${encodeURIComponent(employeeId)}`);
|
|
63
63
|
}
|
|
64
|
+
/** Get a single employee with compensation fields by employeeId */
|
|
65
|
+
async getEmployeePrivileged(employeeId) {
|
|
66
|
+
return this.request(`/employees/privileged/${encodeURIComponent(employeeId)}`);
|
|
67
|
+
}
|
|
64
68
|
/** Search employees by name (case-insensitive partial match) */
|
|
65
69
|
async searchByName(name) {
|
|
66
70
|
return this.request(`/employees/search?name=${encodeURIComponent(name)}`);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const getPaytypes: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Paytype[]>;
|
|
2
2
|
export declare const getPaytypesDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").PaytypeDropdownOption[]>;
|
|
3
3
|
export declare const getPaytype: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype>;
|
|
4
|
-
export declare const searchPaytypes: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Paytype[]>;
|
package/dist/paytypes.remote.js
CHANGED
|
@@ -4,4 +4,3 @@ import { getClient } from './client.js';
|
|
|
4
4
|
export const getPaytypes = query(async () => getClient().getPaytypes());
|
|
5
5
|
export const getPaytypesDropdown = query(async () => getClient().getPaytypesDropdown());
|
|
6
6
|
export const getPaytype = query(z.string(), async (id) => getClient().getPaytype(id));
|
|
7
|
-
export const searchPaytypes = query(z.string(), async (q) => getClient().searchPaytypes(q));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export declare const getWorkorders: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").Workorder[]>;
|
|
2
2
|
export declare const getWorkordersDropdown: import("@sveltejs/kit").RemoteQueryFunction<void, import("./index.js").DropdownOption[]>;
|
|
3
|
-
export declare const getWorkordersDropdownByBu: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").DropdownOption[]>;
|
|
4
3
|
export declare const getWorkorder: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder>;
|
|
5
|
-
export declare const searchWorkorders: import("@sveltejs/kit").RemoteQueryFunction<string, import("./index.js").Workorder[]>;
|
|
@@ -3,6 +3,4 @@ import { z } from 'zod';
|
|
|
3
3
|
import { getClient } from './client.js';
|
|
4
4
|
export const getWorkorders = query(async () => getClient().getWorkorders());
|
|
5
5
|
export const getWorkordersDropdown = query(async () => getClient().getWorkordersDropdown());
|
|
6
|
-
export const getWorkordersDropdownByBu = query(z.string(), async (businessUnitId) => getClient().getWorkordersDropdownByBu(businessUnitId));
|
|
7
6
|
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": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
},
|
|
17
|
+
"./cache": {
|
|
18
|
+
"types": "./dist/cache.d.ts",
|
|
19
|
+
"default": "./dist/cache.js"
|
|
20
|
+
},
|
|
17
21
|
"./employees": {
|
|
18
22
|
"types": "./dist/employees.remote.d.ts",
|
|
19
23
|
"default": "./dist/employees.remote.js"
|