vintrace-sdk 0.1.2 → 0.1.4
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 +89 -57
- package/dist/index.cjs +237 -449
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +270 -181
- package/dist/index.d.ts +270 -181
- package/dist/index.js +237 -449
- package/dist/index.js.map +1 -1
- package/package.json +11 -13
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A TypeScript SDK for the Vintrace API.
|
|
|
4
4
|
|
|
5
5
|
> **Disclaimer**: This SDK is not affiliated with or endorsed by Vintrace. It is an independent, third-party project. Use at your own risk. Always refer to the official Vintrace API documentation. Provided as-is without warranties. Test thoroughly before using in production.
|
|
6
6
|
>
|
|
7
|
-
> **GitHub**: https://github.com/
|
|
7
|
+
> **GitHub**: https://github.com/TheAPIguys/vintrace-sdk
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -29,18 +29,44 @@ pnpm add vintrace-sdk
|
|
|
29
29
|
import { VintraceClient } from 'vintrace-sdk';
|
|
30
30
|
|
|
31
31
|
const client = new VintraceClient({
|
|
32
|
-
baseUrl:
|
|
33
|
-
organization:
|
|
32
|
+
baseUrl: process.env.VINTRACE_BASE_URL!, // e.g. https://oz50.vintrace.net
|
|
33
|
+
organization: process.env.VINTRACE_ORG!, // your customer/organization code
|
|
34
34
|
token: process.env.VINTRACE_TOKEN!,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
const [
|
|
37
|
+
// List work orders
|
|
38
|
+
const [orders, error] = await client.v6.workOrders.getAll({ max: '5', workOrderState: 'ANY' });
|
|
39
39
|
if (error) {
|
|
40
|
-
console.error(error.status, error.
|
|
41
|
-
|
|
40
|
+
console.error('Error:', error.message, '| status:', error.status);
|
|
41
|
+
console.error('Body:', JSON.stringify(error.body, null, 2));
|
|
42
|
+
console.error('Correlation ID:', error.correlationId);
|
|
43
|
+
} else {
|
|
44
|
+
console.log(JSON.stringify(orders, null, 2));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// List sales orders filtered by invoice date
|
|
48
|
+
const [sales, salesError] = await client.v6.salesOrders.getAll({
|
|
49
|
+
max: '100',
|
|
50
|
+
invStartDate: '2026-01-01',
|
|
51
|
+
});
|
|
52
|
+
if (salesError) {
|
|
53
|
+
console.error('Error:', salesError.message, '| status:', salesError.status);
|
|
54
|
+
} else {
|
|
55
|
+
console.log(JSON.stringify(sales, null, 2));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Vessel details report
|
|
59
|
+
const [vessels, vesselsError] = await client.v7.vesselDetailsReport.get({
|
|
60
|
+
limit: 100,
|
|
61
|
+
offset: 0,
|
|
62
|
+
asAtDate: Date.now(),
|
|
63
|
+
vesselType: 'TANK',
|
|
64
|
+
});
|
|
65
|
+
if (vesselsError) {
|
|
66
|
+
console.error('Error:', vesselsError.message, '| status:', vesselsError.status);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(JSON.stringify(vessels.results, null, 2));
|
|
42
69
|
}
|
|
43
|
-
console.log(order.id); // fully typed, never null here
|
|
44
70
|
```
|
|
45
71
|
|
|
46
72
|
---
|
|
@@ -53,11 +79,11 @@ const client = new VintraceClient({
|
|
|
53
79
|
organization: 'wrw',
|
|
54
80
|
token: 'your-bearer-token',
|
|
55
81
|
options: {
|
|
56
|
-
timeout: 30000,
|
|
57
|
-
maxRetries: 3,
|
|
58
|
-
parallelLimit: 5,
|
|
59
|
-
validateRequests: true,
|
|
60
|
-
validateResponses: true,
|
|
82
|
+
timeout: 30000, // request timeout in ms (default: 30000)
|
|
83
|
+
maxRetries: 3, // exponential backoff retries (default: 3)
|
|
84
|
+
parallelLimit: 5, // max concurrent requests for batch operations (default: 5)
|
|
85
|
+
validateRequests: true, // Zod validate request payloads (default: true)
|
|
86
|
+
validateResponses: true, // Zod validate API responses (default: true)
|
|
61
87
|
},
|
|
62
88
|
});
|
|
63
89
|
```
|
|
@@ -136,19 +162,25 @@ Fetches multiple IDs concurrently (default: 5 at a time):
|
|
|
136
162
|
|
|
137
163
|
```typescript
|
|
138
164
|
const [results, error] = await client.v6.salesOrders.getMany(['id1', 'id2', 'id3']);
|
|
139
|
-
if (error) {
|
|
165
|
+
if (error) {
|
|
166
|
+
/* handle VintraceAggregateError */
|
|
167
|
+
}
|
|
140
168
|
```
|
|
141
169
|
|
|
142
170
|
### Create
|
|
143
171
|
|
|
144
172
|
```typescript
|
|
145
|
-
const [newOrder, error] = await client.v6.salesOrders.post({
|
|
173
|
+
const [newOrder, error] = await client.v6.salesOrders.post({
|
|
174
|
+
/* payload */
|
|
175
|
+
});
|
|
146
176
|
```
|
|
147
177
|
|
|
148
178
|
### Update
|
|
149
179
|
|
|
150
180
|
```typescript
|
|
151
|
-
const [updated, error] = await client.v6.salesOrders.update('123', {
|
|
181
|
+
const [updated, error] = await client.v6.salesOrders.update('123', {
|
|
182
|
+
/* payload */
|
|
183
|
+
});
|
|
152
184
|
```
|
|
153
185
|
|
|
154
186
|
---
|
|
@@ -157,9 +189,9 @@ const [updated, error] = await client.v6.salesOrders.update('123', { /* payload
|
|
|
157
189
|
|
|
158
190
|
```typescript
|
|
159
191
|
type VintraceResult<T> =
|
|
160
|
-
| [data: T,
|
|
161
|
-
| [data: null, error: VintraceError]
|
|
162
|
-
| [data: null, error: null];
|
|
192
|
+
| [data: T, error: null] // success
|
|
193
|
+
| [data: null, error: VintraceError] // error
|
|
194
|
+
| [data: null, error: null]; // 204 No Content
|
|
163
195
|
```
|
|
164
196
|
|
|
165
197
|
---
|
|
@@ -177,42 +209,42 @@ type VintraceResult<T> =
|
|
|
177
209
|
|
|
178
210
|
### v6 Endpoints
|
|
179
211
|
|
|
180
|
-
| Module
|
|
181
|
-
|
|
182
|
-
| WorkOrders
|
|
183
|
-
| SalesOrders
|
|
184
|
-
| Refunds
|
|
185
|
-
| Parties
|
|
186
|
-
| Products
|
|
187
|
-
| ProductUpdate
|
|
188
|
-
| Transactions
|
|
189
|
-
| IntakeOperations | `search`
|
|
190
|
-
| SampleOperations | `search`
|
|
191
|
-
| BlockAssessments | `post`
|
|
192
|
-
| MRPStock
|
|
193
|
-
| Inventory
|
|
194
|
-
| Search
|
|
212
|
+
| Module | Methods |
|
|
213
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
214
|
+
| WorkOrders | `getAll`, `get`, `getMany`, `post`, `update` |
|
|
215
|
+
| SalesOrders | `getAll`, `get`, `getMany`, `post`, `update` |
|
|
216
|
+
| Refunds | `getAll`, `get`, `getMany`, `post` |
|
|
217
|
+
| Parties | `getAll`, `get`, `getMany`, `post` |
|
|
218
|
+
| Products | `getAll`, `get`, `getMany`, `post` |
|
|
219
|
+
| ProductUpdate | `post` |
|
|
220
|
+
| Transactions | `search` |
|
|
221
|
+
| IntakeOperations | `search` |
|
|
222
|
+
| SampleOperations | `search` |
|
|
223
|
+
| BlockAssessments | `post` |
|
|
224
|
+
| MRPStock | `get`, `updateFields`, `getDistributions`, `getHistoryItems`, `getRawComponents`, `getNotes`, `postNote`, `updateNote` |
|
|
225
|
+
| Inventory | `getAll` |
|
|
226
|
+
| Search | `list`, `lookup` |
|
|
195
227
|
|
|
196
228
|
### v7 Endpoints
|
|
197
229
|
|
|
198
|
-
| Module
|
|
199
|
-
|
|
200
|
-
| Costs
|
|
201
|
-
| Blocks
|
|
202
|
-
| Assessments
|
|
203
|
-
| Vineyards
|
|
204
|
-
| MaturitySamples
|
|
205
|
-
| Parties (v7)
|
|
206
|
-
| Shipments
|
|
207
|
-
| BarrelTreatments
|
|
208
|
-
| Bookings
|
|
209
|
-
| FruitIntakes
|
|
210
|
-
| BulkIntakes
|
|
211
|
-
| TrialBlends
|
|
212
|
-
| WorkOrders (v7)
|
|
213
|
-
| Tirage
|
|
214
|
-
| BarrelsMovements
|
|
215
|
-
| VesselDetailsReport | Ready
|
|
230
|
+
| Module | Status | Methods |
|
|
231
|
+
| ------------------- | ------- | ---------------------------------------- |
|
|
232
|
+
| Costs | Ready | `businessUnitTransactions` |
|
|
233
|
+
| Blocks | Partial | `getAll`, `get`, `post`, `patch` |
|
|
234
|
+
| Assessments | Ready | `getAll` |
|
|
235
|
+
| Vineyards | Ready | `post` |
|
|
236
|
+
| MaturitySamples | Ready | `post` |
|
|
237
|
+
| Parties (v7) | Ready | `getAll`, `post` |
|
|
238
|
+
| Shipments | Ready | `getAll` |
|
|
239
|
+
| BarrelTreatments | Ready | `getAll` |
|
|
240
|
+
| Bookings | Ready | `post`, `deactivate` |
|
|
241
|
+
| FruitIntakes | Ready | `post`, `updatePricing`, `updateMetrics` |
|
|
242
|
+
| BulkIntakes | Ready | `getAll`, `post`, `patch` |
|
|
243
|
+
| TrialBlends | Ready | `getAll` |
|
|
244
|
+
| WorkOrders (v7) | Ready | `getAll` |
|
|
245
|
+
| Tirage | Ready | `get`, `patch` |
|
|
246
|
+
| BarrelsMovements | Ready | `post` |
|
|
247
|
+
| VesselDetailsReport | Ready | `get` |
|
|
216
248
|
|
|
217
249
|
---
|
|
218
250
|
|
|
@@ -231,11 +263,11 @@ pnpm generate-types # Regenerate types from OpenAPI YAML
|
|
|
231
263
|
|
|
232
264
|
### Output
|
|
233
265
|
|
|
234
|
-
| Format | File
|
|
235
|
-
|
|
236
|
-
| ESM
|
|
237
|
-
| CJS
|
|
238
|
-
| Types
|
|
266
|
+
| Format | File |
|
|
267
|
+
| ------ | ----------------- |
|
|
268
|
+
| ESM | `dist/index.js` |
|
|
269
|
+
| CJS | `dist/index.cjs` |
|
|
270
|
+
| Types | `dist/index.d.ts` |
|
|
239
271
|
|
|
240
272
|
---
|
|
241
273
|
|