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