@veho/turvo-integration-sdk 0.1.0-beta.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.
Files changed (57) hide show
  1. package/README.md +473 -0
  2. package/index.ts +1 -0
  3. package/lib/cjs/api/turvoInternalApi.d.ts +23 -0
  4. package/lib/cjs/api/turvoInternalApi.js +36 -0
  5. package/lib/cjs/api/turvoPublicApi.d.ts +99 -0
  6. package/lib/cjs/api/turvoPublicApi.js +103 -0
  7. package/lib/cjs/client/turvoClient.d.ts +49 -0
  8. package/lib/cjs/client/turvoClient.js +180 -0
  9. package/lib/cjs/constants.d.ts +29 -0
  10. package/lib/cjs/constants.js +33 -0
  11. package/lib/cjs/index.d.ts +6 -0
  12. package/lib/cjs/index.js +37 -0
  13. package/lib/cjs/shipmentTracking/index.d.ts +22 -0
  14. package/lib/cjs/shipmentTracking/index.js +39 -0
  15. package/lib/cjs/shipmentTracking/trackingService.d.ts +25 -0
  16. package/lib/cjs/shipmentTracking/trackingService.js +85 -0
  17. package/lib/cjs/types/common.d.ts +64 -0
  18. package/lib/cjs/types/common.js +27 -0
  19. package/lib/cjs/types/config.d.ts +13 -0
  20. package/lib/cjs/types/config.js +3 -0
  21. package/lib/cjs/types/errors.d.ts +35 -0
  22. package/lib/cjs/types/errors.js +63 -0
  23. package/lib/cjs/types/index.d.ts +5 -0
  24. package/lib/cjs/types/index.js +27 -0
  25. package/lib/cjs/types/shipment.d.ts +379 -0
  26. package/lib/cjs/types/shipment.js +46 -0
  27. package/lib/cjs/types/tracking.d.ts +65 -0
  28. package/lib/cjs/types/tracking.js +3 -0
  29. package/lib/esm/api/turvoInternalApi.d.ts +23 -0
  30. package/lib/esm/api/turvoInternalApi.js +32 -0
  31. package/lib/esm/api/turvoPublicApi.d.ts +99 -0
  32. package/lib/esm/api/turvoPublicApi.js +99 -0
  33. package/lib/esm/client/turvoClient.d.ts +49 -0
  34. package/lib/esm/client/turvoClient.js +172 -0
  35. package/lib/esm/constants.d.ts +29 -0
  36. package/lib/esm/constants.js +30 -0
  37. package/lib/esm/index.d.ts +6 -0
  38. package/lib/esm/index.js +11 -0
  39. package/lib/esm/shipmentTracking/index.d.ts +22 -0
  40. package/lib/esm/shipmentTracking/index.js +36 -0
  41. package/lib/esm/shipmentTracking/trackingService.d.ts +25 -0
  42. package/lib/esm/shipmentTracking/trackingService.js +81 -0
  43. package/lib/esm/types/common.d.ts +64 -0
  44. package/lib/esm/types/common.js +23 -0
  45. package/lib/esm/types/config.d.ts +13 -0
  46. package/lib/esm/types/config.js +2 -0
  47. package/lib/esm/types/errors.d.ts +35 -0
  48. package/lib/esm/types/errors.js +55 -0
  49. package/lib/esm/types/index.d.ts +5 -0
  50. package/lib/esm/types/index.js +11 -0
  51. package/lib/esm/types/shipment.d.ts +379 -0
  52. package/lib/esm/types/shipment.js +43 -0
  53. package/lib/esm/types/tracking.d.ts +65 -0
  54. package/lib/esm/types/tracking.js +2 -0
  55. package/lib/tsconfig.cjs.tsbuildinfo +1 -0
  56. package/lib/tsconfig.esm.tsbuildinfo +1 -0
  57. package/package.json +126 -0
package/README.md ADDED
@@ -0,0 +1,473 @@
1
+ # @veho/turvo-sdk
2
+
3
+ TypeScript SDK for Turvo API integration. Provides clean abstractions for shipment tracking and management operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @veho/turvo-sdk
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ ### AWS Secrets Manager Setup
14
+
15
+ The SDK expects Turvo credentials in AWS Secrets Manager at `/turvo/api` (configurable):
16
+
17
+ ```json
18
+ {
19
+ "apiKey": "your-turvo-api-key",
20
+ "username": "your-service-account-username",
21
+ "password": "your-service-account-password",
22
+ "urlBase": "https://api.turvo.com"
23
+ }
24
+ ```
25
+
26
+ ### IAM Permissions
27
+
28
+ Grant your Lambda/service permission to read the secret:
29
+
30
+ ```typescript
31
+ import { TURVO_SECRET_PATH } from '@veho/turvo-sdk'
32
+ import * as iam from 'aws-cdk-lib/aws-iam'
33
+
34
+ myLambda.addToRolePolicy(new iam.PolicyStatement({
35
+ actions: ['secretsmanager:GetSecretValue'],
36
+ resources: [`arn:aws:secretsmanager:*:*:secret:${TURVO_SECRET_PATH}*`],
37
+ }))
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Use Cases
43
+
44
+ ### Use Case 1: Track Shipment Progress
45
+
46
+ **When to use:** Monitor shipment status, ETA, GPS location, and stop progress.
47
+
48
+ ```typescript
49
+ import { getShipmentTracking } from '@veho/turvo-sdk'
50
+
51
+ // Get tracking data for a shipment
52
+ const tracking = await getShipmentTracking('12345', {
53
+ includeGps: true // Include GPS ping history (default: true)
54
+ })
55
+
56
+ console.log({
57
+ status: tracking.status, // "En route"
58
+ isLate: tracking.isLate, // false
59
+ lateBy: tracking.lateBy, // null
60
+ currentLocation: tracking.currentLocation, // "Biscoe, AR"
61
+ completedStops: tracking.completedStops, // 2
62
+ totalStops: tracking.totalStops, // 5
63
+ etaUtc: tracking.etaUtc, // "2024-01-28T15:30:00Z"
64
+ milesRemaining: tracking.milesRemaining, // 127
65
+
66
+ // GPS tracking (if available)
67
+ hasGpsTracking: tracking.hasGpsTracking, // true
68
+ pingCount: tracking.pingCount, // 45
69
+ lastPingAt: tracking.lastPingAt, // "2024-01-28T14:22:00Z"
70
+
71
+ // Stops with details
72
+ stops: tracking.stops
73
+ // [
74
+ // {
75
+ // sequence: 1,
76
+ // stopType: "Pickup",
77
+ // isCompleted: true,
78
+ // facilityCode: "PHL 01",
79
+ // city: "Philadelphia",
80
+ // state: "PA",
81
+ // appointmentTimeUtc: "2024-01-28T08:00:00Z",
82
+ // actualArrivalUtc: "2024-01-28T07:45:00Z",
83
+ // actualDepartureUtc: "2024-01-28T09:15:00Z"
84
+ // },
85
+ // ...
86
+ // ]
87
+ })
88
+ ```
89
+
90
+ **Note:** GPS tracking (location updates) requires internal API access. Currently stubbed and returns `null`.
91
+
92
+ ---
93
+
94
+ ### Use Case 2: Create New Shipments
95
+
96
+ **When to use:** Upload a new shipment to Turvo from your system.
97
+
98
+ ```typescript
99
+ import { TurvoClient, TurvoPublicApi } from '@veho/turvo-sdk'
100
+
101
+ const client = new TurvoClient()
102
+ const publicApi = new TurvoPublicApi(client)
103
+
104
+ // Create a complete shipment
105
+ const result = await publicApi.uploadShipment({
106
+ shipment: {
107
+ id: 0, // Will be assigned by Turvo
108
+ customId: 'VEHO-LOAD-98765',
109
+ ltlShipment: false,
110
+ startDate: {
111
+ date: '2024-01-28T08:00:00',
112
+ timeZone: 'America/New_York'
113
+ },
114
+ endDate: {
115
+ date: '2024-01-30T17:00:00',
116
+ timeZone: 'America/Los_Angeles',
117
+ flex: 0
118
+ },
119
+ status: {
120
+ code: { key: '2101', value: 'Tendered' }
121
+ },
122
+ equipment: [{
123
+ type: { key: 'VAN', value: 'Van' },
124
+ size: { key: '53', value: '53ft' }
125
+ }],
126
+ lane: {
127
+ start: 'Philadelphia, PA',
128
+ end: 'Los Angeles, CA'
129
+ },
130
+ globalRoute: [{
131
+ id: 0,
132
+ name: 'Pickup at PHL',
133
+ sequence: 1,
134
+ segmentSequence: 1,
135
+ state: 'OPEN',
136
+ stopType: { key: 'PICKUP', value: 'Pickup' },
137
+ schedulingType: { key: 'APPOINTMENT', value: 'Appointment' },
138
+ location: { id: 12345 },
139
+ appointment: {
140
+ date: '2024-01-28T08:00:00',
141
+ timeZone: 'America/New_York',
142
+ hasTime: true
143
+ }
144
+ }, {
145
+ id: 0,
146
+ name: 'Delivery at LAX',
147
+ sequence: 2,
148
+ segmentSequence: 2,
149
+ state: 'OPEN',
150
+ stopType: { key: 'DELIVERY', value: 'Delivery' },
151
+ schedulingType: { key: 'APPOINTMENT', value: 'Appointment' },
152
+ location: { id: 67890 },
153
+ appointment: {
154
+ date: '2024-01-30T17:00:00',
155
+ timeZone: 'America/Los_Angeles',
156
+ hasTime: true
157
+ }
158
+ }],
159
+ customerOrder: [{
160
+ customer: { id: 111, name: 'Acme Corp' },
161
+ customerOrderSourceId: 98765,
162
+ externalIds: [{
163
+ type: { key: '1401', value: 'Reference #' },
164
+ value: 'REF-98765',
165
+ copyToCarrierOrder: true
166
+ }]
167
+ }],
168
+ carrierOrder: [{
169
+ _operation: 0,
170
+ carrier: { id: 222, name: 'Swift Transport' },
171
+ carrierOrderSourceId: 55555
172
+ }]
173
+ },
174
+ vehoLoadId: 'LOAD-98765' // For logging purposes
175
+ })
176
+
177
+ console.log(`Created shipment with ID: ${result.details.id}`)
178
+ // Created shipment with ID: 12345
179
+ ```
180
+
181
+ ---
182
+
183
+ ### Use Case 3: Update Shipment Status
184
+
185
+ **When to use:** Update status as shipment progresses through stops.
186
+
187
+ ```typescript
188
+ import {
189
+ TurvoClient,
190
+ TurvoPublicApi,
191
+ TURVO_SHIPMENT_STATUS_AT_PICKUP,
192
+ TURVO_SHIPMENT_STATUS_PICKED_UP,
193
+ TURVO_SHIPMENT_STATUS_EN_ROUTE,
194
+ TURVO_SHIPMENT_STATUS_AT_DELIVERY,
195
+ TURVO_SHIPMENT_STATUS_DELIVERED
196
+ } from '@veho/turvo-sdk'
197
+
198
+ const client = new TurvoClient()
199
+ const publicApi = new TurvoPublicApi(client)
200
+
201
+ // Mark arrived at pickup
202
+ await publicApi.updateShipmentStatus({
203
+ turvoShipmentId: 12345,
204
+ turvoStopId: 11111, // First stop ID from globalRoute
205
+ turvoStatusCode: TURVO_SHIPMENT_STATUS_AT_PICKUP,
206
+ statusDate: '2024-01-28T07:45:00',
207
+ statusTimezone: 'America/New_York'
208
+ })
209
+
210
+ // Mark picked up
211
+ await publicApi.updateShipmentStatus({
212
+ turvoShipmentId: 12345,
213
+ turvoStopId: 11111,
214
+ turvoStatusCode: TURVO_SHIPMENT_STATUS_PICKED_UP,
215
+ statusDate: '2024-01-28T09:15:00',
216
+ statusTimezone: 'America/New_York'
217
+ })
218
+
219
+ // Mark en route
220
+ await publicApi.updateShipmentStatus({
221
+ turvoShipmentId: 12345,
222
+ turvoStopId: 22222, // Second stop ID
223
+ turvoStatusCode: TURVO_SHIPMENT_STATUS_EN_ROUTE,
224
+ statusDate: '2024-01-28T09:30:00',
225
+ statusTimezone: 'America/New_York'
226
+ })
227
+ ```
228
+
229
+ ---
230
+
231
+ ### Use Case 4: Tag Shipments
232
+
233
+ **When to use:** Add metadata tags for filtering and organization.
234
+
235
+ ```typescript
236
+ import { TurvoClient, TurvoPublicApi } from '@veho/turvo-sdk'
237
+
238
+ const client = new TurvoClient()
239
+ const publicApi = new TurvoPublicApi(client)
240
+
241
+ // Add tags to categorize shipment
242
+ await publicApi.associateTagsToShipment({
243
+ turvoShipmentId: 12345,
244
+ tags: ['urgent', 'fragile', 'high-value']
245
+ })
246
+ ```
247
+
248
+ ---
249
+
250
+ ### Use Case 5: Cancel Shipments
251
+
252
+ **When to use:** Mark shipment as cancelled in Turvo.
253
+
254
+ ```typescript
255
+ import { TurvoClient, TurvoPublicApi } from '@veho/turvo-sdk'
256
+
257
+ const client = new TurvoClient()
258
+ const publicApi = new TurvoPublicApi(client)
259
+
260
+ // Cancel a shipment
261
+ await publicApi.cancelShipment({
262
+ turvoShipmentId: 12345
263
+ })
264
+ ```
265
+
266
+ ---
267
+
268
+ ### Use Case 6: Query Shipments
269
+
270
+ **When to use:** Fetch shipments by location and date range.
271
+
272
+ ```typescript
273
+ import { TurvoClient, TurvoPublicApi } from '@veho/turvo-sdk'
274
+
275
+ const client = new TurvoClient()
276
+ const publicApi = new TurvoPublicApi(client)
277
+
278
+ // Get shipments for a location
279
+ let start = 0
280
+ let moreAvailable = true
281
+
282
+ while (moreAvailable) {
283
+ const result = await publicApi.filterShipments({
284
+ turvoLocationId: 12345,
285
+ pickupDateStart: '2024-01-01',
286
+ start
287
+ })
288
+
289
+ const shipments = result.details.shipments || []
290
+ console.log(`Retrieved ${shipments.length} shipments`)
291
+
292
+ shipments.forEach(shipment => {
293
+ console.log({
294
+ id: shipment.id,
295
+ customId: shipment.customId,
296
+ status: shipment.status.code.value,
297
+ customer: shipment.customerOrder[0]?.customer.name,
298
+ carrier: shipment.carrierOrder[0]?.carrier.name
299
+ })
300
+ })
301
+
302
+ // Check pagination
303
+ moreAvailable = result.details.pagination.moreAvailable
304
+ start += result.details.pagination.pageSize
305
+ }
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Configuration
311
+
312
+ ### Custom Secret Path
313
+
314
+ Use a different AWS Secrets Manager path:
315
+
316
+ ```typescript
317
+ const client = new TurvoClient('/custom/secret/path')
318
+ ```
319
+
320
+ ### Custom Secret Path for Tracking
321
+
322
+ ```typescript
323
+ const tracking = await getShipmentTracking('12345', {
324
+ secretPath: '/custom/secret/path',
325
+ includeGps: true
326
+ })
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Available Status Constants
332
+
333
+ ```typescript
334
+ import {
335
+ TURVO_SHIPMENT_STATUS_AT_PICKUP,
336
+ TURVO_SHIPMENT_STATUS_PICKED_UP,
337
+ TURVO_SHIPMENT_STATUS_EN_ROUTE,
338
+ TURVO_SHIPMENT_STATUS_AT_DELIVERY,
339
+ TURVO_SHIPMENT_STATUS_DELIVERED
340
+ } from '@veho/turvo-sdk'
341
+ ```
342
+
343
+ ---
344
+
345
+ ## Error Handling
346
+
347
+ ```typescript
348
+ import {
349
+ TurvoApiError,
350
+ TurvoNotFoundError,
351
+ TurvoAuthError,
352
+ TurvoRateLimitError
353
+ } from '@veho/turvo-sdk'
354
+
355
+ try {
356
+ const tracking = await getShipmentTracking('12345')
357
+ } catch (error) {
358
+ if (error instanceof TurvoNotFoundError) {
359
+ console.error(`Shipment not found: ${error.shipmentId}`)
360
+ } else if (error instanceof TurvoAuthError) {
361
+ console.error('Authentication failed - check credentials')
362
+ } else if (error instanceof TurvoRateLimitError) {
363
+ console.error(`Rate limited. Retry after ${error.retryAfter}s`)
364
+ } else if (error instanceof TurvoApiError) {
365
+ console.error(`API error: ${error.errorCode} - ${error.errorMessage}`)
366
+ } else {
367
+ console.error('Unexpected error:', error)
368
+ }
369
+ }
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Type Definitions
375
+
376
+ All types are fully exported:
377
+
378
+ ```typescript
379
+ import type {
380
+ // Tracking types
381
+ ShipmentTracking,
382
+ Stop,
383
+ LocationUpdate,
384
+ GetTrackingOptions,
385
+
386
+ // Shipment types
387
+ TurvoShipment,
388
+ TurvoShipmentStatus,
389
+ TurvoGlobalRoute,
390
+ TurvoCustomerOrder,
391
+ TurvoCarrierOrder,
392
+
393
+ // API types
394
+ TurvoApiResult,
395
+ TurvoApiMethod,
396
+ TurvoCredentials,
397
+
398
+ // Error types
399
+ TurvoApiError,
400
+ TurvoNotFoundError,
401
+ TurvoAuthError
402
+ } from '@veho/turvo-sdk'
403
+ ```
404
+
405
+ ---
406
+
407
+ ## Advanced Usage
408
+
409
+ ### Direct HTTP Client Access
410
+
411
+ For operations not covered by the SDK:
412
+
413
+ ```typescript
414
+ import { TurvoClient, TurvoApiMethod } from '@veho/turvo-sdk'
415
+
416
+ const client = new TurvoClient()
417
+ const httpClient = await client.getAuthenticatedClient()
418
+
419
+ // Make custom API call
420
+ const result = await httpClient.sendRequest(
421
+ '/custom/endpoint',
422
+ TurvoApiMethod.GET,
423
+ {
424
+ query: { param: 'value' },
425
+ headers: { 'Custom-Header': 'value' }
426
+ }
427
+ )
428
+ ```
429
+
430
+ ### Get Raw Credentials
431
+
432
+ ```typescript
433
+ const client = new TurvoClient()
434
+ const credentials = await client.getCredentials()
435
+
436
+ console.log({
437
+ apiKey: credentials.apiKey,
438
+ username: credentials.username,
439
+ urlBase: credentials.urlBase
440
+ })
441
+ ```
442
+
443
+ ---
444
+
445
+ ## Rate Limiting & Retries
446
+
447
+ The SDK automatically handles:
448
+ - **Rate limiting:** 1 request per second (uses `p-throttle`)
449
+ - **Retries:** Up to 2 retry attempts on transient failures (uses `p-retry`)
450
+ - **Token caching:** OAuth tokens cached in memory to avoid repeated auth calls
451
+
452
+ These are currently not configurable but use sensible defaults.
453
+
454
+ ---
455
+
456
+ ## Known Limitations
457
+
458
+ 1. **Internal API (GPS tracking):** Currently stubbed. `getShipmentTracking()` will return `hasGpsTracking: false` and `locationUpdates: null` until internal API is implemented.
459
+
460
+ 2. **Transformation logic:** `ShipmentTracking` response contains TODOs for computed fields like `lateBy`, `isLate`, `completedStops`. These will return placeholder values until transformation logic is completed.
461
+
462
+ ---
463
+
464
+ ## Requirements
465
+
466
+ - Node.js >= 22.20.0
467
+ - AWS credentials (for Secrets Manager access)
468
+
469
+ ---
470
+
471
+ ## License
472
+
473
+ UNLICENSED - Internal Veho Technologies package
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src'
@@ -0,0 +1,23 @@
1
+ import { TurvoClient } from '../client/turvoClient';
2
+ import { LocationUpdate } from '../types/tracking';
3
+ /**
4
+ * TurvoInternalApi provides access to undocumented Turvo internal APIs.
5
+ * ⚠️ WARNING: These APIs are not officially supported and may break without notice.
6
+ *
7
+ * Current status: STUB - All methods return null. Implementation pending.
8
+ */
9
+ export declare class TurvoInternalApi {
10
+ private client;
11
+ constructor(client: TurvoClient);
12
+ /**
13
+ * GET /api/locationUpdates/
14
+ * Returns GPS ping history for a shipment
15
+ * ⚠️ Undocumented - may break
16
+ *
17
+ * @param _shipmentId - The shipment ID to fetch location updates for
18
+ * @returns Array of location updates, or null if not available
19
+ *
20
+ * TODO: Implement when internal API is ready
21
+ */
22
+ getLocationUpdates(shipmentId: string): Promise<LocationUpdate[] | null>;
23
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurvoInternalApi = void 0;
4
+ /**
5
+ * TurvoInternalApi provides access to undocumented Turvo internal APIs.
6
+ * ⚠️ WARNING: These APIs are not officially supported and may break without notice.
7
+ *
8
+ * Current status: STUB - All methods return null. Implementation pending.
9
+ */
10
+ class TurvoInternalApi {
11
+ client;
12
+ constructor(client) {
13
+ this.client = client;
14
+ }
15
+ /**
16
+ * GET /api/locationUpdates/
17
+ * Returns GPS ping history for a shipment
18
+ * ⚠️ Undocumented - may break
19
+ *
20
+ * @param _shipmentId - The shipment ID to fetch location updates for
21
+ * @returns Array of location updates, or null if not available
22
+ *
23
+ * TODO: Implement when internal API is ready
24
+ */
25
+ async getLocationUpdates(shipmentId) {
26
+ // Stub implementation - will use this.client and shipmentId when ready
27
+ void this.client;
28
+ void shipmentId;
29
+ // TODO: Implement internal API call
30
+ // const httpClient = await this.client.getAuthenticatedClient()
31
+ // return httpClient.sendRequest('/api/locationUpdates/...', ...)
32
+ return null;
33
+ }
34
+ }
35
+ exports.TurvoInternalApi = TurvoInternalApi;
36
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHVydm9JbnRlcm5hbEFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGkvdHVydm9JbnRlcm5hbEFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFHQTs7Ozs7R0FLRztBQUNILE1BQWEsZ0JBQWdCO0lBQ1A7SUFBcEIsWUFBb0IsTUFBbUI7UUFBbkIsV0FBTSxHQUFOLE1BQU0sQ0FBYTtJQUFHLENBQUM7SUFFM0M7Ozs7Ozs7OztPQVNHO0lBQ0gsS0FBSyxDQUFDLGtCQUFrQixDQUFDLFVBQWtCO1FBQ3pDLHVFQUF1RTtRQUN2RSxLQUFLLElBQUksQ0FBQyxNQUFNLENBQUE7UUFDaEIsS0FBSyxVQUFVLENBQUE7UUFDZixvQ0FBb0M7UUFDcEMsZ0VBQWdFO1FBQ2hFLGlFQUFpRTtRQUNqRSxPQUFPLElBQUksQ0FBQTtJQUNiLENBQUM7Q0FDRjtBQXRCRCw0Q0FzQkMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBUdXJ2b0NsaWVudCB9IGZyb20gJy4uL2NsaWVudC90dXJ2b0NsaWVudCdcbmltcG9ydCB7IExvY2F0aW9uVXBkYXRlIH0gZnJvbSAnLi4vdHlwZXMvdHJhY2tpbmcnXG5cbi8qKlxuICogVHVydm9JbnRlcm5hbEFwaSBwcm92aWRlcyBhY2Nlc3MgdG8gdW5kb2N1bWVudGVkIFR1cnZvIGludGVybmFsIEFQSXMuXG4gKiDimqDvuI8gV0FSTklORzogVGhlc2UgQVBJcyBhcmUgbm90IG9mZmljaWFsbHkgc3VwcG9ydGVkIGFuZCBtYXkgYnJlYWsgd2l0aG91dCBub3RpY2UuXG4gKlxuICogQ3VycmVudCBzdGF0dXM6IFNUVUIgLSBBbGwgbWV0aG9kcyByZXR1cm4gbnVsbC4gSW1wbGVtZW50YXRpb24gcGVuZGluZy5cbiAqL1xuZXhwb3J0IGNsYXNzIFR1cnZvSW50ZXJuYWxBcGkge1xuICBjb25zdHJ1Y3Rvcihwcml2YXRlIGNsaWVudDogVHVydm9DbGllbnQpIHt9XG5cbiAgLyoqXG4gICAqIEdFVCAvYXBpL2xvY2F0aW9uVXBkYXRlcy9cbiAgICogUmV0dXJucyBHUFMgcGluZyBoaXN0b3J5IGZvciBhIHNoaXBtZW50XG4gICAqIOKaoO+4jyBVbmRvY3VtZW50ZWQgLSBtYXkgYnJlYWtcbiAgICpcbiAgICogQHBhcmFtIF9zaGlwbWVudElkIC0gVGhlIHNoaXBtZW50IElEIHRvIGZldGNoIGxvY2F0aW9uIHVwZGF0ZXMgZm9yXG4gICAqIEByZXR1cm5zIEFycmF5IG9mIGxvY2F0aW9uIHVwZGF0ZXMsIG9yIG51bGwgaWYgbm90IGF2YWlsYWJsZVxuICAgKlxuICAgKiBUT0RPOiBJbXBsZW1lbnQgd2hlbiBpbnRlcm5hbCBBUEkgaXMgcmVhZHlcbiAgICovXG4gIGFzeW5jIGdldExvY2F0aW9uVXBkYXRlcyhzaGlwbWVudElkOiBzdHJpbmcpOiBQcm9taXNlPExvY2F0aW9uVXBkYXRlW10gfCBudWxsPiB7XG4gICAgLy8gU3R1YiBpbXBsZW1lbnRhdGlvbiAtIHdpbGwgdXNlIHRoaXMuY2xpZW50IGFuZCBzaGlwbWVudElkIHdoZW4gcmVhZHlcbiAgICB2b2lkIHRoaXMuY2xpZW50XG4gICAgdm9pZCBzaGlwbWVudElkXG4gICAgLy8gVE9ETzogSW1wbGVtZW50IGludGVybmFsIEFQSSBjYWxsXG4gICAgLy8gY29uc3QgaHR0cENsaWVudCA9IGF3YWl0IHRoaXMuY2xpZW50LmdldEF1dGhlbnRpY2F0ZWRDbGllbnQoKVxuICAgIC8vIHJldHVybiBodHRwQ2xpZW50LnNlbmRSZXF1ZXN0KCcvYXBpL2xvY2F0aW9uVXBkYXRlcy8uLi4nLCAuLi4pXG4gICAgcmV0dXJuIG51bGxcbiAgfVxufVxuIl19
@@ -0,0 +1,99 @@
1
+ import { TurvoClient } from '../client/turvoClient';
2
+ import { TurvoApiResult, TurvoFilterShipmentsResultItem, TurvoPagedResult } from '../types/common';
3
+ import { TurvoAssociateTagsApiResult, TurvoCancelShipmentApiResult, TurvoCreateShipmentApiResult, TurvoShipment, TurvoShipmentStatus, TurvoUpdateShipmentStatusApiResult } from '../types/shipment';
4
+ /**
5
+ * Parameters for uploading a shipment to Turvo
6
+ */
7
+ export interface UploadShipmentParams {
8
+ /** The formatted shipment to upload */
9
+ shipment: TurvoShipment;
10
+ /** The Load ID, solely for logging purposes */
11
+ vehoLoadId: string;
12
+ }
13
+ /**
14
+ * Parameters for associating tags to a shipment
15
+ */
16
+ export interface AssociateTagsParams {
17
+ /** The shipment ID to associate tags with */
18
+ turvoShipmentId: number;
19
+ /** List of tag names to assign */
20
+ tags: string[];
21
+ }
22
+ /**
23
+ * Parameters for cancelling a shipment
24
+ */
25
+ export interface CancelShipmentParams {
26
+ /** The Turvo system Shipment ID to cancel */
27
+ turvoShipmentId: number;
28
+ }
29
+ /**
30
+ * Parameters for updating shipment status
31
+ */
32
+ export interface UpdateShipmentStatusParams {
33
+ /** The Turvo shipment ID */
34
+ turvoShipmentId: number;
35
+ /** The Turvo stop ID */
36
+ turvoStopId: number;
37
+ /** The status code to set */
38
+ turvoStatusCode: TurvoShipmentStatus;
39
+ /** The status date in ISO format */
40
+ statusDate: string;
41
+ /** The timezone for the status date */
42
+ statusTimezone: string;
43
+ }
44
+ /**
45
+ * Parameters for retrieving a shipment
46
+ */
47
+ export interface GetShipmentParams {
48
+ /** The shipment ID to retrieve */
49
+ shipmentId: number;
50
+ }
51
+ /**
52
+ * Parameters for filtering shipments
53
+ */
54
+ export interface FilterShipmentsParams {
55
+ /** Turvo location ID to filter by */
56
+ turvoLocationId: number;
57
+ /** Pickup date start filter (ISO format) */
58
+ pickupDateStart: string;
59
+ /** Optional pagination start offset */
60
+ start?: number;
61
+ }
62
+ /**
63
+ * TurvoPublicApi provides access to documented Turvo API endpoints.
64
+ * All shipment management operations (create, update, cancel, query) go through this class.
65
+ */
66
+ export declare class TurvoPublicApi {
67
+ private client;
68
+ constructor(client: TurvoClient);
69
+ /**
70
+ * GET /v1/shipments/{id}
71
+ * Returns shipment details, stops, status
72
+ */
73
+ getShipment(params: GetShipmentParams): Promise<TurvoApiResult<TurvoShipment>>;
74
+ /**
75
+ * POST /v1/shipments
76
+ * Upload properly formatted shipment to Turvo
77
+ */
78
+ uploadShipment(params: UploadShipmentParams): Promise<TurvoApiResult<TurvoCreateShipmentApiResult>>;
79
+ /**
80
+ * PUT /v1/tags/attach/shipment/{id}
81
+ * Associate a list of tags with a shipment by ID
82
+ */
83
+ associateTagsToShipment(params: AssociateTagsParams): Promise<TurvoApiResult<TurvoAssociateTagsApiResult>>;
84
+ /**
85
+ * PUT /v1/shipments/status/{id}
86
+ * Set shipment status to Cancelled in Turvo
87
+ */
88
+ cancelShipment(params: CancelShipmentParams): Promise<TurvoApiResult<TurvoCancelShipmentApiResult>>;
89
+ /**
90
+ * PUT /v1/shipments/status/{id}
91
+ * Update shipment status at a specific stop
92
+ */
93
+ updateShipmentStatus(params: UpdateShipmentStatusParams): Promise<TurvoApiResult<TurvoUpdateShipmentStatusApiResult>>;
94
+ /**
95
+ * GET /v1/shipments/list
96
+ * Query shipments from Turvo with pagination support
97
+ */
98
+ filterShipments(params: FilterShipmentsParams): Promise<TurvoApiResult<TurvoPagedResult<'shipments', TurvoFilterShipmentsResultItem>>>;
99
+ }