vintrace-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +75 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +425 -3
- package/dist/index.d.ts +425 -3
- package/dist/index.js +75 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1458,6 +1458,59 @@ var PurchaseOrderSchema = zod.z.object({
|
|
|
1458
1458
|
var PurchaseOrderResponseSchema = zod.z.object({
|
|
1459
1459
|
data: PurchaseOrderSchema
|
|
1460
1460
|
});
|
|
1461
|
+
var FractionTypeEnum = zod.z.enum([
|
|
1462
|
+
"FREE_RUN",
|
|
1463
|
+
"PRESSINGS",
|
|
1464
|
+
"MUST",
|
|
1465
|
+
"LEES",
|
|
1466
|
+
"UNKNOWN",
|
|
1467
|
+
"COMBINED",
|
|
1468
|
+
"CONDENSATE",
|
|
1469
|
+
"PRESSINGS_LIGHT",
|
|
1470
|
+
"PRESSINGS_HEAVY",
|
|
1471
|
+
"DRAININGS",
|
|
1472
|
+
"PRESSINGS_OVERNIGHT",
|
|
1473
|
+
"SAIGNEE"
|
|
1474
|
+
]);
|
|
1475
|
+
var WineBatchVesselSchema = zod.z.object({
|
|
1476
|
+
id: zod.z.number().optional(),
|
|
1477
|
+
name: zod.z.string().optional(),
|
|
1478
|
+
type: zod.z.enum(["TANK", "BIN", "BARREL", "BARREL_GROUP", "BIN_GROUP", "PRESS", "TANKER"]).optional(),
|
|
1479
|
+
amount: MeasurementSchema.optional()
|
|
1480
|
+
});
|
|
1481
|
+
var WineBatchDataSchema = zod.z.object({
|
|
1482
|
+
id: zod.z.number().optional(),
|
|
1483
|
+
batchCode: zod.z.string().optional(),
|
|
1484
|
+
batchNumber: zod.z.string().optional(),
|
|
1485
|
+
description: zod.z.string().optional(),
|
|
1486
|
+
productionYear: zod.z.number().optional(),
|
|
1487
|
+
owner: ExtIdentifiableEntitySchema.optional(),
|
|
1488
|
+
grading: VesselGradingSchema.optional(),
|
|
1489
|
+
program: IdentifiableEntitySchema.optional(),
|
|
1490
|
+
designatedRegion: IdentifiableEntitySchema.optional(),
|
|
1491
|
+
designatedSubRegion: IdentifiableEntitySchema.optional(),
|
|
1492
|
+
designatedVariety: IdentifiableEntitySchema.optional(),
|
|
1493
|
+
winery: WinerySchema.optional(),
|
|
1494
|
+
category: IdentifiableEntitySchema.optional(),
|
|
1495
|
+
designatedProduct: IdentifiableEntitySchema.optional(),
|
|
1496
|
+
costsTrackedPercentage: zod.z.number().optional(),
|
|
1497
|
+
ageOfSpirits: zod.z.string().optional(),
|
|
1498
|
+
serviceOrder: IdentifiableEntitySchema.optional(),
|
|
1499
|
+
fractionType: FractionTypeEnum.optional(),
|
|
1500
|
+
inactive: zod.z.boolean().optional(),
|
|
1501
|
+
vessels: zod.z.array(WineBatchVesselSchema).optional(),
|
|
1502
|
+
allocations: zod.z.array(AllocationSliceSchema).optional()
|
|
1503
|
+
});
|
|
1504
|
+
var GetWineBatchSuccessResponseSchema = PaginatedResponseSchema(WineBatchDataSchema);
|
|
1505
|
+
var CreateWineBatchSuccessResponseSchema = zod.z.object({
|
|
1506
|
+
data: WineBatchDataSchema.optional()
|
|
1507
|
+
});
|
|
1508
|
+
var CreateWineBatchRequestSchema = WineBatchDataSchema.extend({
|
|
1509
|
+
batchCode: zod.z.string(),
|
|
1510
|
+
productionYear: zod.z.number(),
|
|
1511
|
+
winery: WinerySchema,
|
|
1512
|
+
owner: ExtIdentifiableEntitySchema
|
|
1513
|
+
});
|
|
1461
1514
|
|
|
1462
1515
|
// src/client/VintraceClient.ts
|
|
1463
1516
|
var VintraceClient = class {
|
|
@@ -2311,11 +2364,17 @@ var WineBatchesClient = class {
|
|
|
2311
2364
|
*/
|
|
2312
2365
|
async getAll(params) {
|
|
2313
2366
|
const limit = params?.limit ?? 100;
|
|
2367
|
+
const queryParams = {
|
|
2368
|
+
limit: String(limit),
|
|
2369
|
+
offset: String(params?.offset ?? 0)
|
|
2370
|
+
};
|
|
2371
|
+
if (params?.ids) queryParams.ids = params.ids;
|
|
2372
|
+
if (params?.include) queryParams.include = params.include;
|
|
2314
2373
|
const firstResponse = await this.client.request(
|
|
2315
2374
|
"v7/operation/wine-batches",
|
|
2316
2375
|
"GET",
|
|
2317
|
-
{},
|
|
2318
|
-
|
|
2376
|
+
{ responseSchema: GetWineBatchSuccessResponseSchema },
|
|
2377
|
+
queryParams
|
|
2319
2378
|
);
|
|
2320
2379
|
if (firstResponse[1]) {
|
|
2321
2380
|
return [null, firstResponse[1]];
|
|
@@ -2335,13 +2394,13 @@ var WineBatchesClient = class {
|
|
|
2335
2394
|
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2336
2395
|
const batchPromises = [];
|
|
2337
2396
|
for (let j = 0; j < batchSize; j++) {
|
|
2338
|
-
const
|
|
2397
|
+
const pageOffset = (i + j) * limit;
|
|
2339
2398
|
batchPromises.push(
|
|
2340
2399
|
this.client.request(
|
|
2341
2400
|
"v7/operation/wine-batches",
|
|
2342
2401
|
"GET",
|
|
2343
|
-
{},
|
|
2344
|
-
{ ...
|
|
2402
|
+
{ responseSchema: GetWineBatchSuccessResponseSchema },
|
|
2403
|
+
{ ...queryParams, offset: String(pageOffset) }
|
|
2345
2404
|
)
|
|
2346
2405
|
);
|
|
2347
2406
|
}
|
|
@@ -2350,9 +2409,8 @@ var WineBatchesClient = class {
|
|
|
2350
2409
|
if (pageError) {
|
|
2351
2410
|
return [null, pageError];
|
|
2352
2411
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
allResults.push(...pData.results);
|
|
2412
|
+
if (pageData?.results) {
|
|
2413
|
+
allResults.push(...pageData.results);
|
|
2356
2414
|
}
|
|
2357
2415
|
}
|
|
2358
2416
|
}
|
|
@@ -2362,7 +2420,15 @@ var WineBatchesClient = class {
|
|
|
2362
2420
|
* Create a wine batch.
|
|
2363
2421
|
*/
|
|
2364
2422
|
create(data) {
|
|
2365
|
-
return this.client.request(
|
|
2423
|
+
return this.client.request(
|
|
2424
|
+
"v7/operation/wine-batches",
|
|
2425
|
+
"POST",
|
|
2426
|
+
{
|
|
2427
|
+
responseSchema: CreateWineBatchSuccessResponseSchema,
|
|
2428
|
+
requestSchema: CreateWineBatchRequestSchema
|
|
2429
|
+
},
|
|
2430
|
+
data
|
|
2431
|
+
);
|
|
2366
2432
|
}
|
|
2367
2433
|
};
|
|
2368
2434
|
var TirageClient = class {
|