vintrace-sdk 0.1.3 → 0.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/dist/index.cjs CHANGED
@@ -359,10 +359,12 @@ async function batchFetch(ids, fetchFn) {
359
359
  }
360
360
  var ExtIdentifiableEntitySchema = zod.z.object({
361
361
  id: zod.z.number().optional(),
362
- extId: zod.z.string().optional()
362
+ extId: zod.z.string().optional(),
363
+ name: zod.z.string().optional()
363
364
  });
364
365
  var IdentifiableEntitySchema = zod.z.object({
365
- id: zod.z.number().optional()
366
+ id: zod.z.number().optional(),
367
+ name: zod.z.string().optional()
366
368
  });
367
369
  var CodedIdentifiableEntitySchema = zod.z.object({
368
370
  id: zod.z.number().optional(),
@@ -880,15 +882,94 @@ var PaginatedResponseSchema = (itemSchema) => zod.z.object({
880
882
  last: zod.z.string().nullable().optional(),
881
883
  results: zod.z.array(itemSchema).optional()
882
884
  });
885
+ var VineyardIdentifiableEntitySchema = IdentifiableEntitySchema.extend({
886
+ name: zod.z.string(),
887
+ grower: ExtIdentifiableEntitySchema
888
+ });
889
+ var GradingSchema = zod.z.object({
890
+ id: zod.z.number().optional(),
891
+ value: zod.z.string().optional(),
892
+ scaleName: zod.z.string().optional(),
893
+ scaleId: zod.z.number().optional()
894
+ });
895
+ var BulkStockSchema = zod.z.object({
896
+ totalVolume: VolumeSchema.optional(),
897
+ equivalentVolume: VolumeSchema.optional(),
898
+ equivalentWeight: VolumeSchema.optional(),
899
+ compWeighting: zod.z.number().optional(),
900
+ percentageOfFruit: zod.z.number().optional(),
901
+ batchId: zod.z.number().optional(),
902
+ batchName: zod.z.string().optional(),
903
+ grading: GradingSchema.nullable().optional()
904
+ });
905
+ var FruitPlacementSchema = zod.z.object({
906
+ vintage: zod.z.string().optional(),
907
+ bulkStocks: zod.z.array(BulkStockSchema).optional()
908
+ });
883
909
  var BlockDataSchema = zod.z.object({
884
910
  id: zod.z.number(),
885
911
  code: zod.z.string().optional(),
886
- name: zod.z.string().optional(),
887
- description: zod.z.string().optional(),
912
+ name: zod.z.string(),
888
913
  extId: zod.z.string().optional(),
889
- inactive: zod.z.boolean().optional()
914
+ inactive: zod.z.boolean().optional(),
915
+ description: zod.z.string().optional(),
916
+ rowNumbers: zod.z.string().optional(),
917
+ estate: zod.z.boolean().optional(),
918
+ grower: ExtIdentifiableEntitySchema.optional(),
919
+ vineyard: VineyardIdentifiableEntitySchema.optional(),
920
+ region: IdentifiableEntitySchema.optional(),
921
+ subRegion: IdentifiableEntitySchema.optional(),
922
+ variety: IdentifiableEntitySchema.optional(),
923
+ intendedUse: IdentifiableEntitySchema.optional(),
924
+ grading: GradingSchema.nullable().optional(),
925
+ fruitPlacement: FruitPlacementSchema.optional()
890
926
  });
891
927
  var GetBlocksSuccessResponseSchema = PaginatedResponseSchema(BlockDataSchema);
928
+ var BlockSchema = ExtIdentifiableEntitySchema.extend({
929
+ extId: zod.z.string(),
930
+ name: zod.z.string(),
931
+ estate: zod.z.boolean().optional(),
932
+ vineyard: VineyardIdentifiableEntitySchema,
933
+ variety: IdentifiableEntitySchema,
934
+ countyCode: zod.z.string().optional(),
935
+ inactive: zod.z.boolean().optional(),
936
+ noOfVines: zod.z.number().optional(),
937
+ area: zod.z.number().optional(),
938
+ rootStock: IdentifiableEntitySchema.optional(),
939
+ clone: IdentifiableEntitySchema.optional(),
940
+ vineSpacing: zod.z.string().optional(),
941
+ rowSpacing: zod.z.string().optional(),
942
+ soilProfile: zod.z.string().optional(),
943
+ trellis: IdentifiableEntitySchema.optional(),
944
+ aspect: zod.z.string().optional(),
945
+ plantedTime: zod.z.number().optional(),
946
+ pruningType: zod.z.string().optional(),
947
+ averageGradient: zod.z.number().optional(),
948
+ irrigationType: zod.z.string().optional(),
949
+ frostProtection: zod.z.string().optional(),
950
+ organic: zod.z.boolean().optional(),
951
+ organicCertifiedTime: zod.z.number().optional(),
952
+ township: zod.z.string().optional(),
953
+ range: zod.z.string().optional(),
954
+ section: zod.z.string().optional(),
955
+ emitterRate: zod.z.number().optional(),
956
+ emitterSize: zod.z.string().optional(),
957
+ siteId: zod.z.string().optional(),
958
+ noOfRows: zod.z.number().optional(),
959
+ districtCode: zod.z.string().optional(),
960
+ regionalAdminCode: zod.z.string().optional(),
961
+ comments: zod.z.string().optional(),
962
+ code: zod.z.string().optional(),
963
+ defaultHarvestMethod: zod.z.string().optional(),
964
+ description: zod.z.string().optional(),
965
+ graftedDate: zod.z.number().optional(),
966
+ intendedUse: IdentifiableEntitySchema.optional(),
967
+ rowNumbers: zod.z.string().optional(),
968
+ vineStructure: IdentifiableEntitySchema.optional()
969
+ });
970
+ var BlockResponseSchema = zod.z.object({
971
+ data: BlockSchema
972
+ });
892
973
  var V6PaginatedResponseSchema = zod.z.object({
893
974
  totalResultCount: zod.z.number().optional(),
894
975
  firstResult: zod.z.number().optional(),
@@ -918,7 +999,7 @@ var WinerySchema = zod.z.object({
918
999
  name: zod.z.string().optional(),
919
1000
  businessUnit: zod.z.string().optional()
920
1001
  });
921
- var GradingSchema = zod.z.object({
1002
+ var VesselGradingSchema = zod.z.object({
922
1003
  scaleId: zod.z.number().optional(),
923
1004
  scaleName: zod.z.string().optional(),
924
1005
  valueId: zod.z.number().optional(),
@@ -935,7 +1016,7 @@ var WineBatchDetailsSchema = zod.z.object({
935
1016
  program: zod.z.string().optional(),
936
1017
  productCategory: CodedIdentifiableEntitySchema.optional(),
937
1018
  designatedProduct: CodedIdentifiableEntitySchema.optional(),
938
- grading: GradingSchema.optional()
1019
+ grading: VesselGradingSchema.optional()
939
1020
  });
940
1021
  var ProductStateSchema = zod.z.object({
941
1022
  id: zod.z.number().optional(),
@@ -983,6 +1064,12 @@ var LiveMetricSchema = zod.z.object({
983
1064
  value: zod.z.number().optional(),
984
1065
  interfaceMappedName: zod.z.string().optional()
985
1066
  });
1067
+ var AnalysisResultSchema = zod.z.object({
1068
+ name: zod.z.string(),
1069
+ value: zod.z.number().nullable().optional(),
1070
+ interfaceMappedName: zod.z.string().nullable().optional(),
1071
+ nonNumericValue: zod.z.string().nullable().optional()
1072
+ });
986
1073
  var SparklingInfoSchema = zod.z.object({
987
1074
  state: zod.z.string().optional()
988
1075
  });
@@ -1116,13 +1203,13 @@ var BlockAssessmentOverviewSchema = zod.z.object({
1116
1203
  blockName: zod.z.string().optional(),
1117
1204
  variety: zod.z.string().optional()
1118
1205
  });
1119
- var GetAssessmentsResponseSchema = PaginatedResponseSchema(BlockAssessmentOverviewSchema);
1206
+ PaginatedResponseSchema(BlockAssessmentOverviewSchema);
1120
1207
  var VineyardSchema = zod.z.object({
1121
1208
  id: zod.z.number().optional(),
1122
1209
  name: zod.z.string().optional(),
1123
1210
  grower: ExtIdentifiableEntitySchema.optional()
1124
1211
  });
1125
- var VineyardResponseSchema = zod.z.object({
1212
+ zod.z.object({
1126
1213
  data: VineyardSchema.optional()
1127
1214
  });
1128
1215
  var MaturitySampleSchema = zod.z.object({
@@ -1138,7 +1225,7 @@ var MaturitySampleSchema = zod.z.object({
1138
1225
  ta: zod.z.number().optional(),
1139
1226
  grade: zod.z.string().optional()
1140
1227
  });
1141
- var MaturitySampleResponseSchema = zod.z.object({
1228
+ zod.z.object({
1142
1229
  data: MaturitySampleSchema.optional()
1143
1230
  });
1144
1231
  var PartyV7Schema = zod.z.object({
@@ -1151,7 +1238,7 @@ var PartyV7Schema = zod.z.object({
1151
1238
  isOrganization: zod.z.boolean().optional(),
1152
1239
  address: AddressSchema.optional()
1153
1240
  });
1154
- var GetPartiesV7ResponseSchema = PaginatedResponseSchema(PartyV7Schema);
1241
+ PaginatedResponseSchema(PartyV7Schema);
1155
1242
  var ShipmentDestinationSchema = zod.z.object({
1156
1243
  name: zod.z.string().optional(),
1157
1244
  address: AddressSchema.optional()
@@ -1171,7 +1258,7 @@ var ShipmentDataSchema = zod.z.object({
1171
1258
  destination: ShipmentDestinationSchema.optional(),
1172
1259
  wineDetails: ShipmentWineDetailsSchema.array().optional()
1173
1260
  });
1174
- var GetShipmentsSuccessResponseSchema = PaginatedResponseSchema(ShipmentDataSchema);
1261
+ PaginatedResponseSchema(ShipmentDataSchema);
1175
1262
  var BarrelTreatmentTypeSchema = zod.z.object({
1176
1263
  id: zod.z.number().optional(),
1177
1264
  name: zod.z.string().optional(),
@@ -1189,7 +1276,7 @@ var BarrelTreatmentDataSchema = zod.z.object({
1189
1276
  treatment: BarrelTreatmentTypeSchema.optional(),
1190
1277
  barrels: ShipmentBarrelDetailsSchema.array().optional()
1191
1278
  });
1192
- var GetBarrelTreatmentsSuccessResponseSchema = PaginatedResponseSchema(BarrelTreatmentDataSchema);
1279
+ PaginatedResponseSchema(BarrelTreatmentDataSchema);
1193
1280
  var FruitIntakeSchema = zod.z.object({
1194
1281
  id: zod.z.number().optional(),
1195
1282
  intakeDate: zod.z.number().optional(),
@@ -1214,13 +1301,20 @@ var CreateFruitIntakeSuccessResponseSchema = zod.z.object({
1214
1301
  data: FruitIntakeSchema.optional()
1215
1302
  });
1216
1303
  var UpdateFruitIntakePricingSchema = zod.z.object({
1217
- pricePerTon: zod.z.number().optional(),
1218
- pricePerKg: zod.z.number().optional(),
1219
- bypassed: zod.z.boolean().optional()
1304
+ gross: MeasurementSchema.optional(),
1305
+ tare: MeasurementSchema.optional(),
1306
+ net: MeasurementSchema.optional(),
1307
+ unitPrice: MeasurementSchema.optional()
1220
1308
  });
1221
1309
  var UpdateFruitIntakePricingResponseSchema = zod.z.object({
1222
1310
  data: UpdateFruitIntakePricingSchema.optional()
1223
1311
  });
1312
+ var UpdateMetricsSchema = zod.z.object({
1313
+ metrics: zod.z.array(AnalysisResultSchema).optional()
1314
+ });
1315
+ var UpdateMetricsResponseSchema = zod.z.object({
1316
+ data: UpdateMetricsSchema.optional()
1317
+ });
1224
1318
  var BulkIntakeSchema = zod.z.object({
1225
1319
  id: zod.z.number().optional(),
1226
1320
  code: zod.z.string().optional(),
@@ -1232,7 +1326,7 @@ var BulkIntakeSchema = zod.z.object({
1232
1326
  volume: MeasurementSchema.optional(),
1233
1327
  status: zod.z.string().optional()
1234
1328
  });
1235
- var GetBulkIntakesSuccessResponseSchema = PaginatedResponseSchema(BulkIntakeSchema);
1329
+ PaginatedResponseSchema(BulkIntakeSchema);
1236
1330
  var TrialBlendSchema = zod.z.object({
1237
1331
  id: zod.z.number().optional(),
1238
1332
  name: zod.z.string().optional(),
@@ -1250,7 +1344,7 @@ var TrialBlendSchema = zod.z.object({
1250
1344
  })
1251
1345
  ).optional()
1252
1346
  });
1253
- var GetTrialBlendsSuccessResponseSchema = PaginatedResponseSchema(TrialBlendSchema);
1347
+ PaginatedResponseSchema(TrialBlendSchema);
1254
1348
  var WorkOrderV7Schema = zod.z.object({
1255
1349
  id: zod.z.number().optional(),
1256
1350
  code: zod.z.string().optional(),
@@ -1261,7 +1355,7 @@ var WorkOrderV7Schema = zod.z.object({
1261
1355
  assignedTo: zod.z.string().optional(),
1262
1356
  summary: zod.z.string().optional()
1263
1357
  });
1264
- var GetWorkOrdersV7ResponseSchema = PaginatedResponseSchema(WorkOrderV7Schema);
1358
+ PaginatedResponseSchema(WorkOrderV7Schema);
1265
1359
  var TirageSourceWineDetailsSchema = zod.z.object({
1266
1360
  productId: zod.z.number().optional(),
1267
1361
  productName: zod.z.string().optional(),
@@ -1324,6 +1418,46 @@ zod.z.object({
1324
1418
  status: zod.z.string().optional(),
1325
1419
  message: zod.z.string().optional()
1326
1420
  });
1421
+ var PurchaseOrderStateEnum = zod.z.enum(["NEW", "APPROVED"]);
1422
+ var FulfillmentEnum = zod.z.enum(["NOT_FULFILLED", "PART_FULFILLED", "FULFILLED", "OVER_FULFILLED"]);
1423
+ var TaxPolicyEnum = zod.z.enum(["TAX_INCLUSIVE", "TAX_EXCLUSIVE", "NO_TAX"]);
1424
+ var PurchaseOrderLineTypeEnum = zod.z.enum(["GENERAL", "ADHOC", "WINE_BATCH", "STOCK"]);
1425
+ var PurchaseOrderLineSchema = zod.z.object({
1426
+ id: zod.z.number(),
1427
+ type: PurchaseOrderLineTypeEnum,
1428
+ lineNumber: zod.z.string().nullable().optional(),
1429
+ itemCode: zod.z.string().nullable().optional(),
1430
+ vendorCode: zod.z.string().nullable().optional(),
1431
+ description: zod.z.string().nullable().optional(),
1432
+ itemName: zod.z.string().optional(),
1433
+ unitPrice: zod.z.number().optional(),
1434
+ totalPrice: zod.z.number().optional(),
1435
+ taxable: zod.z.boolean().optional(),
1436
+ quantityOrdered: MeasurementSchema.optional(),
1437
+ quantityFulfilled: MeasurementSchema.optional()
1438
+ });
1439
+ var PurchaseOrderSchema = zod.z.object({
1440
+ id: zod.z.number(),
1441
+ name: zod.z.string(),
1442
+ state: PurchaseOrderStateEnum.optional(),
1443
+ fulfillment: FulfillmentEnum.optional(),
1444
+ taxPolicy: TaxPolicyEnum.optional(),
1445
+ freightCost: zod.z.number().nullable().optional(),
1446
+ inactive: zod.z.boolean().optional(),
1447
+ vendor: ExtIdentifiableEntitySchema.optional(),
1448
+ vendorReference: zod.z.string().nullable().optional(),
1449
+ deliverBy: zod.z.number().nullable().optional(),
1450
+ notes: zod.z.string().nullable().optional(),
1451
+ winery: zod.z.object({
1452
+ id: zod.z.number().optional(),
1453
+ name: zod.z.string().optional(),
1454
+ businessUnit: zod.z.string().nullable().optional()
1455
+ }).optional(),
1456
+ lines: PurchaseOrderLineSchema.array().optional()
1457
+ });
1458
+ var PurchaseOrderResponseSchema = zod.z.object({
1459
+ data: PurchaseOrderSchema
1460
+ });
1327
1461
 
1328
1462
  // src/client/VintraceClient.ts
1329
1463
  var VintraceClient = class {
@@ -1360,7 +1494,9 @@ var VintraceClient = class {
1360
1494
  timeout: options?.timeout ?? this.options.timeout,
1361
1495
  maxRetries: options?.maxRetries ?? this.options.maxRetries,
1362
1496
  validateRequest: options?.validateRequest ?? this.options.validateRequests,
1363
- validateResponse: options?.validateResponse ?? this.options.validateResponses
1497
+ validateResponse: options?.validateResponse ?? this.options.validateResponses,
1498
+ responseSchema: options?.responseSchema,
1499
+ requestSchema: options?.requestSchema
1364
1500
  },
1365
1501
  body
1366
1502
  );
@@ -1426,39 +1562,12 @@ var VintraceV7Api = class {
1426
1562
  get blocks() {
1427
1563
  return this._blocks ?? (this._blocks = new BlocksClient(this.client));
1428
1564
  }
1429
- get assessments() {
1430
- return this._assessments ?? (this._assessments = new AssessmentsClient(this.client));
1431
- }
1432
- get vineyards() {
1433
- return this._vineyards ?? (this._vineyards = new VineyardsClient(this.client));
1434
- }
1435
- get maturitySamples() {
1436
- return this._maturitySamples ?? (this._maturitySamples = new MaturitySamplesClient(this.client));
1437
- }
1438
- get parties() {
1439
- return this._parties ?? (this._parties = new PartiesV7Client(this.client));
1440
- }
1441
- get shipments() {
1442
- return this._shipments ?? (this._shipments = new ShipmentsClient(this.client));
1443
- }
1444
- get barrelTreatments() {
1445
- return this._barrelTreatments ?? (this._barrelTreatments = new BarrelTreatmentsClient(this.client));
1446
- }
1447
1565
  get bookings() {
1448
1566
  return this._bookings ?? (this._bookings = new BookingsClient(this.client));
1449
1567
  }
1450
1568
  get fruitIntakes() {
1451
1569
  return this._fruitIntakes ?? (this._fruitIntakes = new FruitIntakesClient(this.client));
1452
1570
  }
1453
- get bulkIntakes() {
1454
- return this._bulkIntakes ?? (this._bulkIntakes = new BulkIntakesClient(this.client));
1455
- }
1456
- get trialBlends() {
1457
- return this._trialBlends ?? (this._trialBlends = new TrialBlendsClient(this.client));
1458
- }
1459
- get workOrders() {
1460
- return this._workOrders ?? (this._workOrders = new WorkOrdersV7Client(this.client));
1461
- }
1462
1571
  get tirage() {
1463
1572
  return this._tirage ?? (this._tirage = new TirageClient(this.client));
1464
1573
  }
@@ -1468,6 +1577,21 @@ var VintraceV7Api = class {
1468
1577
  get vesselDetailsReport() {
1469
1578
  return this._vesselDetailsReport ?? (this._vesselDetailsReport = new VesselDetailsReportClient(this.client));
1470
1579
  }
1580
+ get wineBatches() {
1581
+ return this._wineBatches ?? (this._wineBatches = new WineBatchesClient(this.client));
1582
+ }
1583
+ get documents() {
1584
+ return this._documents ?? (this._documents = new DocumentsClient(this.client));
1585
+ }
1586
+ get stock() {
1587
+ return this._stock ?? (this._stock = new StockClient(this.client));
1588
+ }
1589
+ get vessels() {
1590
+ return this._vessels ?? (this._vessels = new VesselsClient(this.client));
1591
+ }
1592
+ get purchaseOrders() {
1593
+ return this._purchaseOrders ?? (this._purchaseOrders = new PurchaseOrdersClient(this.client));
1594
+ }
1471
1595
  };
1472
1596
  var WorkOrdersClient = class {
1473
1597
  constructor(client) {
@@ -1940,12 +2064,17 @@ var BlocksClient = class {
1940
2064
  * API consumer can use the include and vintage query params to request including more information in the response.
1941
2065
  */
1942
2066
  async getAll(params) {
1943
- const limit = params?.limit ? parseInt(String(params.limit), 10) : 100;
2067
+ const limit = params?.limit ?? 100;
2068
+ const queryParams = { limit: String(limit), offset: "0" };
2069
+ if (params?.include) queryParams.include = params.include;
2070
+ if (params?.vintage) queryParams.vintage = params.vintage;
2071
+ if (params?.VintraceEntityIds) queryParams.VintraceEntityIds = params.VintraceEntityIds;
2072
+ if (params?.offset) queryParams.offset = String(params.offset);
1944
2073
  const firstResponse = await this.client.request(
1945
2074
  "v7/harvest/blocks",
1946
2075
  "GET",
1947
2076
  { responseSchema: GetBlocksSuccessResponseSchema },
1948
- { ...params, limit: String(limit), offset: "0" }
2077
+ queryParams
1949
2078
  );
1950
2079
  if (firstResponse[1]) {
1951
2080
  return [null, firstResponse[1]];
@@ -1965,13 +2094,14 @@ var BlocksClient = class {
1965
2094
  const batchSize = Math.min(parallelLimit, pagesNeeded - i);
1966
2095
  const batchPromises = [];
1967
2096
  for (let j = 0; j < batchSize; j++) {
1968
- const offset = (i + j) * limit;
2097
+ const pageOffset = (i + j) * limit;
2098
+ const pageParams = { ...queryParams, offset: String(pageOffset) };
1969
2099
  batchPromises.push(
1970
2100
  this.client.request(
1971
2101
  "v7/harvest/blocks",
1972
2102
  "GET",
1973
2103
  { responseSchema: GetBlocksSuccessResponseSchema },
1974
- { ...params, limit: String(limit), offset: String(offset) }
2104
+ pageParams
1975
2105
  )
1976
2106
  );
1977
2107
  }
@@ -1987,18 +2117,39 @@ var BlocksClient = class {
1987
2117
  }
1988
2118
  return [allResults, null];
1989
2119
  }
1990
- get(id) {
1991
- return this.client.request(`v7/harvest/blocks/${id}`, "GET");
1992
- }
1993
- getMany(ids) {
1994
- return batchFetch(ids, (id) => this.get(id));
1995
- }
1996
- post(data) {
1997
- return this.client.request("v7/harvest/blocks", "POST", {}, data);
2120
+ /**
2121
+ * Upsert block data into system.
2122
+ *
2123
+ * Create or update block data in the system. Provide a Block object in `data`.
2124
+ * Example fields: `extId`, `name`, `estate`, `vineyard`, `variety`, `area`.
2125
+ */
2126
+ async post(data) {
2127
+ const [response, error] = await this.client.request(
2128
+ "v7/harvest/blocks",
2129
+ "POST",
2130
+ { responseSchema: BlockResponseSchema },
2131
+ data
2132
+ );
2133
+ if (error) return [null, error];
2134
+ if (!response?.data) return [null, null];
2135
+ return [response.data, null];
1998
2136
  }
1999
2137
  patch(id, data) {
2000
2138
  return this.client.request(`v7/harvest/blocks/${id}`, "PATCH", {}, data);
2001
2139
  }
2140
+ /**
2141
+ * Upsert assessment data for a block.
2142
+ *
2143
+ * Create or update assessment data for a block by its blockId.
2144
+ */
2145
+ createAssessment(blockId, data) {
2146
+ return this.client.request(
2147
+ `v7/harvest/blocks/${blockId}/assessments`,
2148
+ "POST",
2149
+ {},
2150
+ data
2151
+ );
2152
+ }
2002
2153
  };
2003
2154
  var BookingsClient = class {
2004
2155
  constructor(client) {
@@ -2149,22 +2300,22 @@ var CostsClient = class {
2149
2300
  return [allResults, null];
2150
2301
  }
2151
2302
  };
2152
- var AssessmentsClient = class {
2303
+ var WineBatchesClient = class {
2153
2304
  constructor(client) {
2154
2305
  this.client = client;
2155
2306
  }
2156
2307
  /**
2157
- * Get all assessments.
2308
+ * Get a list of wine batches.
2158
2309
  *
2159
- * Returns a paginated list of block assessments.
2310
+ * Returns a paginated list of wine batches.
2160
2311
  */
2161
2312
  async getAll(params) {
2162
2313
  const limit = params?.limit ?? 100;
2163
2314
  const firstResponse = await this.client.request(
2164
- "v7/harvest/assessments",
2315
+ "v7/operation/wine-batches",
2165
2316
  "GET",
2166
- { responseSchema: GetAssessmentsResponseSchema },
2167
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2317
+ {},
2318
+ { ...params, limit: String(limit), offset: String(params?.offset ?? 0) }
2168
2319
  );
2169
2320
  if (firstResponse[1]) {
2170
2321
  return [null, firstResponse[1]];
@@ -2187,10 +2338,10 @@ var AssessmentsClient = class {
2187
2338
  const offset = (i + j) * limit;
2188
2339
  batchPromises.push(
2189
2340
  this.client.request(
2190
- "v7/harvest/assessments",
2341
+ "v7/operation/wine-batches",
2191
2342
  "GET",
2192
- { responseSchema: GetAssessmentsResponseSchema },
2193
- { limit: String(limit), offset: String(offset) }
2343
+ {},
2344
+ { ...params, limit: String(limit), offset: String(offset) }
2194
2345
  )
2195
2346
  );
2196
2347
  }
@@ -2199,237 +2350,67 @@ var AssessmentsClient = class {
2199
2350
  if (pageError) {
2200
2351
  return [null, pageError];
2201
2352
  }
2202
- if (pageData?.results) {
2203
- allResults.push(...pageData.results);
2353
+ const pData = pageData;
2354
+ if (pData?.results) {
2355
+ allResults.push(...pData.results);
2204
2356
  }
2205
2357
  }
2206
2358
  }
2207
2359
  return [allResults, null];
2208
2360
  }
2361
+ /**
2362
+ * Create a wine batch.
2363
+ */
2364
+ create(data) {
2365
+ return this.client.request("v7/operation/wine-batches", "POST", {}, data);
2366
+ }
2209
2367
  };
2210
- var VineyardsClient = class {
2368
+ var TirageClient = class {
2211
2369
  constructor(client) {
2212
2370
  this.client = client;
2213
2371
  }
2214
2372
  /**
2215
- * Create a vineyard.
2373
+ * Get a tirage by operation ID.
2216
2374
  *
2217
- * Creates a new vineyard in the system.
2375
+ * Returns a single tirage by its operation ID.
2218
2376
  */
2219
- post(data) {
2220
- return this.client.request(
2221
- "v7/harvest/vineyards",
2222
- "POST",
2223
- { responseSchema: VineyardResponseSchema },
2224
- data
2225
- );
2226
- }
2227
- };
2228
- var MaturitySamplesClient = class {
2229
- constructor(client) {
2230
- this.client = client;
2377
+ get(operationId) {
2378
+ return this.client.request(`v7/operation/tirage/${operationId}`, "GET", {
2379
+ responseSchema: TirageSuccessResponseSchema
2380
+ });
2231
2381
  }
2232
2382
  /**
2233
- * Create a maturity sample.
2383
+ * Patch a tirage.
2234
2384
  *
2235
- * Creates a new maturity sample in the system.
2385
+ * Updates a tirage record.
2236
2386
  */
2237
- post(data) {
2387
+ patch(operationId, data) {
2238
2388
  return this.client.request(
2239
- "v7/harvest/maturity-samples",
2240
- "POST",
2241
- { responseSchema: MaturitySampleResponseSchema },
2389
+ `v7/operation/tirage/${operationId}`,
2390
+ "PATCH",
2391
+ { responseSchema: TirageSuccessResponseSchema },
2242
2392
  data
2243
2393
  );
2244
2394
  }
2245
2395
  };
2246
- var PartiesV7Client = class {
2396
+ var BarrelsMovementsClient = class {
2247
2397
  constructor(client) {
2248
2398
  this.client = client;
2249
2399
  }
2250
2400
  /**
2251
- * List all parties.
2252
- *
2253
- * Returns a paginated list of parties.
2254
- */
2255
- async getAll(params) {
2256
- const limit = params?.limit ?? 100;
2257
- const firstResponse = await this.client.request(
2258
- "v7/identity/parties",
2259
- "GET",
2260
- { responseSchema: GetPartiesV7ResponseSchema },
2261
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2262
- );
2263
- if (firstResponse[1]) {
2264
- return [null, firstResponse[1]];
2265
- }
2266
- const response = firstResponse[0];
2267
- if (!response) {
2268
- return [[], null];
2269
- }
2270
- const totalCount = response.totalResults ?? response.results?.length ?? 0;
2271
- if (totalCount <= limit) {
2272
- return [response.results ?? [], null];
2273
- }
2274
- const pagesNeeded = Math.ceil(totalCount / limit);
2275
- const parallelLimit = this.client.options.parallelLimit;
2276
- const allResults = [...response.results ?? []];
2277
- for (let i = 1; i < pagesNeeded; i += parallelLimit) {
2278
- const batchSize = Math.min(parallelLimit, pagesNeeded - i);
2279
- const batchPromises = [];
2280
- for (let j = 0; j < batchSize; j++) {
2281
- const offset = (i + j) * limit;
2282
- batchPromises.push(
2283
- this.client.request(
2284
- "v7/identity/parties",
2285
- "GET",
2286
- { responseSchema: GetPartiesV7ResponseSchema },
2287
- { limit: String(limit), offset: String(offset) }
2288
- )
2289
- );
2290
- }
2291
- const batchResults = await Promise.all(batchPromises);
2292
- for (const [pageData, pageError] of batchResults) {
2293
- if (pageError) {
2294
- return [null, pageError];
2295
- }
2296
- if (pageData?.results) {
2297
- allResults.push(...pageData.results);
2298
- }
2299
- }
2300
- }
2301
- return [allResults, null];
2302
- }
2303
- /**
2304
- * Upsert a party.
2401
+ * Create a barrels movement.
2305
2402
  *
2306
- * Creates or updates a party.
2403
+ * Creates a new barrels movement in the system.
2307
2404
  */
2308
2405
  post(data) {
2309
2406
  return this.client.request(
2310
- "v7/identity/parties",
2407
+ "v7/operation/barrels-movements",
2311
2408
  "POST",
2312
- { responseSchema: PartyV7Schema },
2409
+ { requestSchema: CreateBarrelsMovementRequestSchema },
2313
2410
  data
2314
2411
  );
2315
2412
  }
2316
2413
  };
2317
- var ShipmentsClient = class {
2318
- constructor(client) {
2319
- this.client = client;
2320
- }
2321
- /**
2322
- * List all shipments.
2323
- *
2324
- * Returns a paginated list of shipments.
2325
- */
2326
- async getAll(params) {
2327
- const limit = params?.limit ?? 100;
2328
- const firstResponse = await this.client.request(
2329
- "v7/operation/shipments",
2330
- "GET",
2331
- { responseSchema: GetShipmentsSuccessResponseSchema },
2332
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2333
- );
2334
- if (firstResponse[1]) {
2335
- return [null, firstResponse[1]];
2336
- }
2337
- const response = firstResponse[0];
2338
- if (!response) {
2339
- return [[], null];
2340
- }
2341
- const totalCount = response.totalResults ?? response.results?.length ?? 0;
2342
- if (totalCount <= limit) {
2343
- return [response.results ?? [], null];
2344
- }
2345
- const pagesNeeded = Math.ceil(totalCount / limit);
2346
- const parallelLimit = this.client.options.parallelLimit;
2347
- const allResults = [...response.results ?? []];
2348
- for (let i = 1; i < pagesNeeded; i += parallelLimit) {
2349
- const batchSize = Math.min(parallelLimit, pagesNeeded - i);
2350
- const batchPromises = [];
2351
- for (let j = 0; j < batchSize; j++) {
2352
- const offset = (i + j) * limit;
2353
- batchPromises.push(
2354
- this.client.request(
2355
- "v7/operation/shipments",
2356
- "GET",
2357
- { responseSchema: GetShipmentsSuccessResponseSchema },
2358
- { limit: String(limit), offset: String(offset) }
2359
- )
2360
- );
2361
- }
2362
- const batchResults = await Promise.all(batchPromises);
2363
- for (const [pageData, pageError] of batchResults) {
2364
- if (pageError) {
2365
- return [null, pageError];
2366
- }
2367
- if (pageData?.results) {
2368
- allResults.push(...pageData.results);
2369
- }
2370
- }
2371
- }
2372
- return [allResults, null];
2373
- }
2374
- };
2375
- var BarrelTreatmentsClient = class {
2376
- constructor(client) {
2377
- this.client = client;
2378
- }
2379
- /**
2380
- * List all barrel treatments.
2381
- *
2382
- * Returns a paginated list of barrel treatments.
2383
- */
2384
- async getAll(params) {
2385
- const limit = params?.limit ?? 100;
2386
- const firstResponse = await this.client.request(
2387
- "v7/operation/barrel-treatments",
2388
- "GET",
2389
- { responseSchema: GetBarrelTreatmentsSuccessResponseSchema },
2390
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2391
- );
2392
- if (firstResponse[1]) {
2393
- return [null, firstResponse[1]];
2394
- }
2395
- const response = firstResponse[0];
2396
- if (!response) {
2397
- return [[], null];
2398
- }
2399
- const totalCount = response.totalResults ?? response.results?.length ?? 0;
2400
- if (totalCount <= limit) {
2401
- return [response.results ?? [], null];
2402
- }
2403
- const pagesNeeded = Math.ceil(totalCount / limit);
2404
- const parallelLimit = this.client.options.parallelLimit;
2405
- const allResults = [...response.results ?? []];
2406
- for (let i = 1; i < pagesNeeded; i += parallelLimit) {
2407
- const batchSize = Math.min(parallelLimit, pagesNeeded - i);
2408
- const batchPromises = [];
2409
- for (let j = 0; j < batchSize; j++) {
2410
- const offset = (i + j) * limit;
2411
- batchPromises.push(
2412
- this.client.request(
2413
- "v7/operation/barrel-treatments",
2414
- "GET",
2415
- { responseSchema: GetBarrelTreatmentsSuccessResponseSchema },
2416
- { limit: String(limit), offset: String(offset) }
2417
- )
2418
- );
2419
- }
2420
- const batchResults = await Promise.all(batchPromises);
2421
- for (const [pageData, pageError] of batchResults) {
2422
- if (pageError) {
2423
- return [null, pageError];
2424
- }
2425
- if (pageData?.results) {
2426
- allResults.push(...pageData.results);
2427
- }
2428
- }
2429
- }
2430
- return [allResults, null];
2431
- }
2432
- };
2433
2414
  var FruitIntakesClient = class {
2434
2415
  constructor(client) {
2435
2416
  this.client = client;
@@ -2437,194 +2418,86 @@ var FruitIntakesClient = class {
2437
2418
  /**
2438
2419
  * Create a fruit intake.
2439
2420
  *
2440
- * Creates a new fruit intake in the system.
2421
+ * Record a new fruit intake transaction.
2441
2422
  */
2442
- post(data) {
2423
+ create(data) {
2443
2424
  return this.client.request(
2444
2425
  "v7/operation/fruit-intakes",
2445
2426
  "POST",
2446
2427
  {
2447
- responseSchema: CreateFruitIntakeSuccessResponseSchema,
2448
- requestSchema: FruitIntakeRequestSchema
2428
+ requestSchema: FruitIntakeRequestSchema,
2429
+ responseSchema: CreateFruitIntakeSuccessResponseSchema
2449
2430
  },
2450
2431
  data
2451
2432
  );
2452
2433
  }
2453
2434
  /**
2454
- * Update fruit intake pricing.
2435
+ * Update pricing for a fruit intake.
2455
2436
  *
2456
- * Updates pricing information for a fruit intake.
2437
+ * Update the pricing related data for this fruit intake record.
2457
2438
  */
2458
2439
  updatePricing(fruitIntakeId, data) {
2459
2440
  return this.client.request(
2460
2441
  `v7/operation/fruit-intakes/${fruitIntakeId}/pricing`,
2461
- "POST",
2462
- { responseSchema: UpdateFruitIntakePricingResponseSchema },
2442
+ "PUT",
2443
+ {
2444
+ requestSchema: UpdateFruitIntakePricingSchema,
2445
+ responseSchema: UpdateFruitIntakePricingResponseSchema
2446
+ },
2463
2447
  data
2464
2448
  );
2465
2449
  }
2466
2450
  /**
2467
- * Update fruit intake metrics.
2451
+ * Update metrics for a fruit intake.
2468
2452
  *
2469
- * Updates metrics for a fruit intake.
2453
+ * Update the metrics for this fruit intake record.
2470
2454
  */
2471
2455
  updateMetrics(fruitIntakeId, data) {
2472
2456
  return this.client.request(
2473
2457
  `v7/operation/fruit-intakes/${fruitIntakeId}/metrics`,
2474
- "POST",
2475
- {},
2458
+ "PUT",
2459
+ { responseSchema: UpdateMetricsResponseSchema, requestSchema: UpdateMetricsSchema },
2476
2460
  data
2477
2461
  );
2478
2462
  }
2479
2463
  };
2480
- var BulkIntakesClient = class {
2464
+ var DocumentsClient = class {
2481
2465
  constructor(client) {
2482
2466
  this.client = client;
2483
2467
  }
2484
2468
  /**
2485
- * List all bulk intakes.
2469
+ * Upload a file to an operation.
2486
2470
  *
2487
- * Returns a paginated list of bulk intakes.
2471
+ * Attach documents to a specified operation.
2488
2472
  */
2489
- async getAll(params) {
2490
- const limit = params?.limit ?? 100;
2491
- const firstResponse = await this.client.request(
2492
- "v7/operation/bulk-intakes",
2493
- "GET",
2494
- { responseSchema: GetBulkIntakesSuccessResponseSchema },
2495
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2496
- );
2497
- if (firstResponse[1]) {
2498
- return [null, firstResponse[1]];
2499
- }
2500
- const response = firstResponse[0];
2501
- if (!response) {
2502
- return [[], null];
2503
- }
2504
- const totalCount = response.totalResults ?? response.results?.length ?? 0;
2505
- if (totalCount <= limit) {
2506
- return [response.results ?? [], null];
2507
- }
2508
- const pagesNeeded = Math.ceil(totalCount / limit);
2509
- const parallelLimit = this.client.options.parallelLimit;
2510
- const allResults = [...response.results ?? []];
2511
- for (let i = 1; i < pagesNeeded; i += parallelLimit) {
2512
- const batchSize = Math.min(parallelLimit, pagesNeeded - i);
2513
- const batchPromises = [];
2514
- for (let j = 0; j < batchSize; j++) {
2515
- const offset = (i + j) * limit;
2516
- batchPromises.push(
2517
- this.client.request(
2518
- "v7/operation/bulk-intakes",
2519
- "GET",
2520
- { responseSchema: GetBulkIntakesSuccessResponseSchema },
2521
- { limit: String(limit), offset: String(offset) }
2522
- )
2523
- );
2524
- }
2525
- const batchResults = await Promise.all(batchPromises);
2526
- for (const [pageData, pageError] of batchResults) {
2527
- if (pageError) {
2528
- return [null, pageError];
2529
- }
2530
- if (pageData?.results) {
2531
- allResults.push(...pageData.results);
2532
- }
2533
- }
2534
- }
2535
- return [allResults, null];
2536
- }
2537
- /**
2538
- * Create a bulk intake.
2539
- *
2540
- * Creates a new bulk intake in the system.
2541
- */
2542
- post(data) {
2543
- return this.client.request("v7/operation/bulk-intakes", "POST", {}, data);
2544
- }
2545
- /**
2546
- * Partially update a bulk intake.
2547
- *
2548
- * Updates specific fields on a bulk intake.
2549
- */
2550
- patch(id, data) {
2551
- return this.client.request(`v7/operation/bulk-intakes/${id}`, "PATCH", {}, data);
2473
+ attach(data) {
2474
+ return this.client.request("v7/operation/operation/documents", "PUT", {}, data);
2552
2475
  }
2553
2476
  };
2554
- var TrialBlendsClient = class {
2477
+ var StockClient = class {
2555
2478
  constructor(client) {
2556
2479
  this.client = client;
2557
2480
  }
2558
2481
  /**
2559
- * List all trial blends.
2482
+ * Receive stock.
2560
2483
  *
2561
- * Returns a paginated list of trial blends.
2484
+ * Perform a receive stock operation in the system.
2562
2485
  */
2563
- async getAll(params) {
2564
- const limit = params?.limit ?? 100;
2565
- const firstResponse = await this.client.request(
2566
- "v7/operation/trial-blends",
2567
- "GET",
2568
- { responseSchema: GetTrialBlendsSuccessResponseSchema },
2569
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2570
- );
2571
- if (firstResponse[1]) {
2572
- return [null, firstResponse[1]];
2573
- }
2574
- const response = firstResponse[0];
2575
- if (!response) {
2576
- return [[], null];
2577
- }
2578
- const totalCount = response.totalResults ?? response.results?.length ?? 0;
2579
- if (totalCount <= limit) {
2580
- return [response.results ?? [], null];
2581
- }
2582
- const pagesNeeded = Math.ceil(totalCount / limit);
2583
- const parallelLimit = this.client.options.parallelLimit;
2584
- const allResults = [...response.results ?? []];
2585
- for (let i = 1; i < pagesNeeded; i += parallelLimit) {
2586
- const batchSize = Math.min(parallelLimit, pagesNeeded - i);
2587
- const batchPromises = [];
2588
- for (let j = 0; j < batchSize; j++) {
2589
- const offset = (i + j) * limit;
2590
- batchPromises.push(
2591
- this.client.request(
2592
- "v7/operation/trial-blends",
2593
- "GET",
2594
- { responseSchema: GetTrialBlendsSuccessResponseSchema },
2595
- { limit: String(limit), offset: String(offset) }
2596
- )
2597
- );
2598
- }
2599
- const batchResults = await Promise.all(batchPromises);
2600
- for (const [pageData, pageError] of batchResults) {
2601
- if (pageError) {
2602
- return [null, pageError];
2603
- }
2604
- if (pageData?.results) {
2605
- allResults.push(...pageData.results);
2606
- }
2607
- }
2608
- }
2609
- return [allResults, null];
2610
- }
2611
- };
2612
- var WorkOrdersV7Client = class {
2613
- constructor(client) {
2614
- this.client = client;
2486
+ receive(data) {
2487
+ return this.client.request("v7/stock/receivals", "POST", {}, data);
2615
2488
  }
2616
2489
  /**
2617
- * List all work orders.
2490
+ * Get all stock dispatches.
2618
2491
  *
2619
- * Returns a paginated list of work orders.
2492
+ * Returns a paginated list of stock dispatch actions.
2620
2493
  */
2621
- async getAll(params) {
2494
+ async getDispatches(params) {
2622
2495
  const limit = params?.limit ?? 100;
2623
2496
  const firstResponse = await this.client.request(
2624
- "v7/operation/work-orders",
2497
+ "v7/stock/dispatches",
2625
2498
  "GET",
2626
- { responseSchema: GetWorkOrdersV7ResponseSchema },
2627
- { limit: String(limit), offset: String(params?.offset ?? 0) }
2499
+ {},
2500
+ { ...params, limit: String(limit), offset: String(params?.offset ?? 0) }
2628
2501
  );
2629
2502
  if (firstResponse[1]) {
2630
2503
  return [null, firstResponse[1]];
@@ -2647,10 +2520,10 @@ var WorkOrdersV7Client = class {
2647
2520
  const offset = (i + j) * limit;
2648
2521
  batchPromises.push(
2649
2522
  this.client.request(
2650
- "v7/operation/work-orders",
2523
+ "v7/stock/dispatches",
2651
2524
  "GET",
2652
- { responseSchema: GetWorkOrdersV7ResponseSchema },
2653
- { limit: String(limit), offset: String(offset) }
2525
+ {},
2526
+ { ...params, limit: String(limit), offset: String(offset) }
2654
2527
  )
2655
2528
  );
2656
2529
  }
@@ -2659,53 +2532,60 @@ var WorkOrdersV7Client = class {
2659
2532
  if (pageError) {
2660
2533
  return [null, pageError];
2661
2534
  }
2662
- if (pageData?.results) {
2663
- allResults.push(...pageData.results);
2535
+ const pData = pageData;
2536
+ if (pData?.results) {
2537
+ allResults.push(...pData.results);
2664
2538
  }
2665
2539
  }
2666
2540
  }
2667
2541
  return [allResults, null];
2668
2542
  }
2669
2543
  };
2670
- var TirageClient = class {
2544
+ var VesselsClient = class {
2671
2545
  constructor(client) {
2672
2546
  this.client = client;
2673
2547
  }
2674
- /**
2675
- * Get a tirage by operation ID.
2676
- *
2677
- * Returns a single tirage by its operation ID.
2678
- */
2679
- get(operationId) {
2680
- return this.client.request(`v7/operation/tirage/${operationId}`, "GET", {
2681
- responseSchema: TirageSuccessResponseSchema
2682
- });
2548
+ getBarrel(id) {
2549
+ return this.client.request(`v7/vessel/barrels/${id}`, "GET");
2683
2550
  }
2684
- /**
2685
- * Patch a tirage.
2686
- *
2687
- * Updates a tirage record.
2688
- */
2689
- patch(operationId, data) {
2690
- return this.client.request(`v7/operation/tirage/${operationId}`, "PATCH", {}, data);
2551
+ getBarrelGroup(id) {
2552
+ return this.client.request(`v7/vessel/barrel-groups/${id}`, "GET");
2553
+ }
2554
+ createTank(data) {
2555
+ return this.client.request("v7/vessel/tanks", "POST", {}, data);
2556
+ }
2557
+ getTank(id) {
2558
+ return this.client.request(`v7/vessel/tanks/${id}`, "GET");
2559
+ }
2560
+ getTanker(id) {
2561
+ return this.client.request(`v7/vessel/tankers/${id}`, "GET");
2562
+ }
2563
+ getBin(id) {
2564
+ return this.client.request(`v7/vessel/bins/${id}`, "GET");
2691
2565
  }
2692
2566
  };
2693
- var BarrelsMovementsClient = class {
2567
+ var PurchaseOrdersClient = class {
2694
2568
  constructor(client) {
2695
2569
  this.client = client;
2696
2570
  }
2697
2571
  /**
2698
- * Create a barrels movement.
2699
- *
2700
- * Creates a new barrels movement in the system.
2572
+ * Create or update a purchase order.
2701
2573
  */
2702
- post(data) {
2703
- return this.client.request(
2704
- "v7/operation/barrels-movements",
2705
- "POST",
2706
- { requestSchema: CreateBarrelsMovementRequestSchema },
2707
- data
2574
+ create(data) {
2575
+ return this.client.request("v7/account/purchase-orders", "POST", {}, data);
2576
+ }
2577
+ /**
2578
+ * Get purchase order details by id.
2579
+ */
2580
+ async get(id) {
2581
+ const [response, error] = await this.client.request(
2582
+ `v7/account/purchase-orders/${id}`,
2583
+ "GET",
2584
+ { responseSchema: PurchaseOrderResponseSchema }
2708
2585
  );
2586
+ if (error) return [null, error];
2587
+ if (!response?.data) return [null, null];
2588
+ return [response.data, null];
2709
2589
  }
2710
2590
  };
2711
2591
  var TransactionsClient = class {
@@ -3039,6 +2919,14 @@ var InventoryClient = class {
3039
2919
  }
3040
2920
  return [allResults, null];
3041
2921
  }
2922
+ /**
2923
+ * Get stock item by code or id.
2924
+ *
2925
+ * Returns a single stock item by code or id.
2926
+ */
2927
+ lookup(params) {
2928
+ return this.client.request("v6/stock/lookup", "GET", {}, params);
2929
+ }
3042
2930
  };
3043
2931
  var SearchClient = class {
3044
2932
  constructor(client) {