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/dist/index.cjs
CHANGED
|
@@ -900,7 +900,14 @@ var V6PaginatedResponseSchema = zod.z.object({
|
|
|
900
900
|
var InventoryResponseSchema = V6PaginatedResponseSchema;
|
|
901
901
|
var TransactionSearchResponseSchema = V6PaginatedResponseSchema;
|
|
902
902
|
var IntakeOperationSearchResponseSchema = V6PaginatedResponseSchema;
|
|
903
|
-
var SampleOperationSearchResponseSchema =
|
|
903
|
+
var SampleOperationSearchResponseSchema = zod.z.object({
|
|
904
|
+
status: zod.z.string().optional(),
|
|
905
|
+
message: zod.z.string().nullable().optional(),
|
|
906
|
+
resultCount: zod.z.number().nullable().optional(),
|
|
907
|
+
resultLimit: zod.z.number().optional(),
|
|
908
|
+
nextResult: zod.z.number().nullable().optional(),
|
|
909
|
+
samples: zod.z.array(zod.z.unknown()).optional()
|
|
910
|
+
});
|
|
904
911
|
var SearchListResponseSchema = V6PaginatedResponseSchema;
|
|
905
912
|
var MeasurementSchema = zod.z.object({
|
|
906
913
|
value: zod.z.number().optional(),
|
|
@@ -976,6 +983,12 @@ var LiveMetricSchema = zod.z.object({
|
|
|
976
983
|
value: zod.z.number().optional(),
|
|
977
984
|
interfaceMappedName: zod.z.string().optional()
|
|
978
985
|
});
|
|
986
|
+
var AnalysisResultSchema = zod.z.object({
|
|
987
|
+
name: zod.z.string(),
|
|
988
|
+
value: zod.z.number().nullable().optional(),
|
|
989
|
+
interfaceMappedName: zod.z.string().nullable().optional(),
|
|
990
|
+
nonNumericValue: zod.z.string().nullable().optional()
|
|
991
|
+
});
|
|
979
992
|
var SparklingInfoSchema = zod.z.object({
|
|
980
993
|
state: zod.z.string().optional()
|
|
981
994
|
});
|
|
@@ -1109,13 +1122,13 @@ var BlockAssessmentOverviewSchema = zod.z.object({
|
|
|
1109
1122
|
blockName: zod.z.string().optional(),
|
|
1110
1123
|
variety: zod.z.string().optional()
|
|
1111
1124
|
});
|
|
1112
|
-
|
|
1125
|
+
PaginatedResponseSchema(BlockAssessmentOverviewSchema);
|
|
1113
1126
|
var VineyardSchema = zod.z.object({
|
|
1114
1127
|
id: zod.z.number().optional(),
|
|
1115
1128
|
name: zod.z.string().optional(),
|
|
1116
1129
|
grower: ExtIdentifiableEntitySchema.optional()
|
|
1117
1130
|
});
|
|
1118
|
-
|
|
1131
|
+
zod.z.object({
|
|
1119
1132
|
data: VineyardSchema.optional()
|
|
1120
1133
|
});
|
|
1121
1134
|
var MaturitySampleSchema = zod.z.object({
|
|
@@ -1131,7 +1144,7 @@ var MaturitySampleSchema = zod.z.object({
|
|
|
1131
1144
|
ta: zod.z.number().optional(),
|
|
1132
1145
|
grade: zod.z.string().optional()
|
|
1133
1146
|
});
|
|
1134
|
-
|
|
1147
|
+
zod.z.object({
|
|
1135
1148
|
data: MaturitySampleSchema.optional()
|
|
1136
1149
|
});
|
|
1137
1150
|
var PartyV7Schema = zod.z.object({
|
|
@@ -1144,7 +1157,7 @@ var PartyV7Schema = zod.z.object({
|
|
|
1144
1157
|
isOrganization: zod.z.boolean().optional(),
|
|
1145
1158
|
address: AddressSchema.optional()
|
|
1146
1159
|
});
|
|
1147
|
-
|
|
1160
|
+
PaginatedResponseSchema(PartyV7Schema);
|
|
1148
1161
|
var ShipmentDestinationSchema = zod.z.object({
|
|
1149
1162
|
name: zod.z.string().optional(),
|
|
1150
1163
|
address: AddressSchema.optional()
|
|
@@ -1164,7 +1177,7 @@ var ShipmentDataSchema = zod.z.object({
|
|
|
1164
1177
|
destination: ShipmentDestinationSchema.optional(),
|
|
1165
1178
|
wineDetails: ShipmentWineDetailsSchema.array().optional()
|
|
1166
1179
|
});
|
|
1167
|
-
|
|
1180
|
+
PaginatedResponseSchema(ShipmentDataSchema);
|
|
1168
1181
|
var BarrelTreatmentTypeSchema = zod.z.object({
|
|
1169
1182
|
id: zod.z.number().optional(),
|
|
1170
1183
|
name: zod.z.string().optional(),
|
|
@@ -1182,7 +1195,7 @@ var BarrelTreatmentDataSchema = zod.z.object({
|
|
|
1182
1195
|
treatment: BarrelTreatmentTypeSchema.optional(),
|
|
1183
1196
|
barrels: ShipmentBarrelDetailsSchema.array().optional()
|
|
1184
1197
|
});
|
|
1185
|
-
|
|
1198
|
+
PaginatedResponseSchema(BarrelTreatmentDataSchema);
|
|
1186
1199
|
var FruitIntakeSchema = zod.z.object({
|
|
1187
1200
|
id: zod.z.number().optional(),
|
|
1188
1201
|
intakeDate: zod.z.number().optional(),
|
|
@@ -1207,13 +1220,20 @@ var CreateFruitIntakeSuccessResponseSchema = zod.z.object({
|
|
|
1207
1220
|
data: FruitIntakeSchema.optional()
|
|
1208
1221
|
});
|
|
1209
1222
|
var UpdateFruitIntakePricingSchema = zod.z.object({
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1223
|
+
gross: MeasurementSchema.optional(),
|
|
1224
|
+
tare: MeasurementSchema.optional(),
|
|
1225
|
+
net: MeasurementSchema.optional(),
|
|
1226
|
+
unitPrice: MeasurementSchema.optional()
|
|
1213
1227
|
});
|
|
1214
1228
|
var UpdateFruitIntakePricingResponseSchema = zod.z.object({
|
|
1215
1229
|
data: UpdateFruitIntakePricingSchema.optional()
|
|
1216
1230
|
});
|
|
1231
|
+
var UpdateMetricsSchema = zod.z.object({
|
|
1232
|
+
metrics: zod.z.array(AnalysisResultSchema).optional()
|
|
1233
|
+
});
|
|
1234
|
+
var UpdateMetricsResponseSchema = zod.z.object({
|
|
1235
|
+
data: UpdateMetricsSchema.optional()
|
|
1236
|
+
});
|
|
1217
1237
|
var BulkIntakeSchema = zod.z.object({
|
|
1218
1238
|
id: zod.z.number().optional(),
|
|
1219
1239
|
code: zod.z.string().optional(),
|
|
@@ -1225,7 +1245,7 @@ var BulkIntakeSchema = zod.z.object({
|
|
|
1225
1245
|
volume: MeasurementSchema.optional(),
|
|
1226
1246
|
status: zod.z.string().optional()
|
|
1227
1247
|
});
|
|
1228
|
-
|
|
1248
|
+
PaginatedResponseSchema(BulkIntakeSchema);
|
|
1229
1249
|
var TrialBlendSchema = zod.z.object({
|
|
1230
1250
|
id: zod.z.number().optional(),
|
|
1231
1251
|
name: zod.z.string().optional(),
|
|
@@ -1243,7 +1263,7 @@ var TrialBlendSchema = zod.z.object({
|
|
|
1243
1263
|
})
|
|
1244
1264
|
).optional()
|
|
1245
1265
|
});
|
|
1246
|
-
|
|
1266
|
+
PaginatedResponseSchema(TrialBlendSchema);
|
|
1247
1267
|
var WorkOrderV7Schema = zod.z.object({
|
|
1248
1268
|
id: zod.z.number().optional(),
|
|
1249
1269
|
code: zod.z.string().optional(),
|
|
@@ -1254,7 +1274,7 @@ var WorkOrderV7Schema = zod.z.object({
|
|
|
1254
1274
|
assignedTo: zod.z.string().optional(),
|
|
1255
1275
|
summary: zod.z.string().optional()
|
|
1256
1276
|
});
|
|
1257
|
-
|
|
1277
|
+
PaginatedResponseSchema(WorkOrderV7Schema);
|
|
1258
1278
|
var TirageSourceWineDetailsSchema = zod.z.object({
|
|
1259
1279
|
productId: zod.z.number().optional(),
|
|
1260
1280
|
productName: zod.z.string().optional(),
|
|
@@ -1419,39 +1439,12 @@ var VintraceV7Api = class {
|
|
|
1419
1439
|
get blocks() {
|
|
1420
1440
|
return this._blocks ?? (this._blocks = new BlocksClient(this.client));
|
|
1421
1441
|
}
|
|
1422
|
-
get assessments() {
|
|
1423
|
-
return this._assessments ?? (this._assessments = new AssessmentsClient(this.client));
|
|
1424
|
-
}
|
|
1425
|
-
get vineyards() {
|
|
1426
|
-
return this._vineyards ?? (this._vineyards = new VineyardsClient(this.client));
|
|
1427
|
-
}
|
|
1428
|
-
get maturitySamples() {
|
|
1429
|
-
return this._maturitySamples ?? (this._maturitySamples = new MaturitySamplesClient(this.client));
|
|
1430
|
-
}
|
|
1431
|
-
get parties() {
|
|
1432
|
-
return this._parties ?? (this._parties = new PartiesV7Client(this.client));
|
|
1433
|
-
}
|
|
1434
|
-
get shipments() {
|
|
1435
|
-
return this._shipments ?? (this._shipments = new ShipmentsClient(this.client));
|
|
1436
|
-
}
|
|
1437
|
-
get barrelTreatments() {
|
|
1438
|
-
return this._barrelTreatments ?? (this._barrelTreatments = new BarrelTreatmentsClient(this.client));
|
|
1439
|
-
}
|
|
1440
1442
|
get bookings() {
|
|
1441
1443
|
return this._bookings ?? (this._bookings = new BookingsClient(this.client));
|
|
1442
1444
|
}
|
|
1443
1445
|
get fruitIntakes() {
|
|
1444
1446
|
return this._fruitIntakes ?? (this._fruitIntakes = new FruitIntakesClient(this.client));
|
|
1445
1447
|
}
|
|
1446
|
-
get bulkIntakes() {
|
|
1447
|
-
return this._bulkIntakes ?? (this._bulkIntakes = new BulkIntakesClient(this.client));
|
|
1448
|
-
}
|
|
1449
|
-
get trialBlends() {
|
|
1450
|
-
return this._trialBlends ?? (this._trialBlends = new TrialBlendsClient(this.client));
|
|
1451
|
-
}
|
|
1452
|
-
get workOrders() {
|
|
1453
|
-
return this._workOrders ?? (this._workOrders = new WorkOrdersV7Client(this.client));
|
|
1454
|
-
}
|
|
1455
1448
|
get tirage() {
|
|
1456
1449
|
return this._tirage ?? (this._tirage = new TirageClient(this.client));
|
|
1457
1450
|
}
|
|
@@ -1461,6 +1454,21 @@ var VintraceV7Api = class {
|
|
|
1461
1454
|
get vesselDetailsReport() {
|
|
1462
1455
|
return this._vesselDetailsReport ?? (this._vesselDetailsReport = new VesselDetailsReportClient(this.client));
|
|
1463
1456
|
}
|
|
1457
|
+
get wineBatches() {
|
|
1458
|
+
return this._wineBatches ?? (this._wineBatches = new WineBatchesClient(this.client));
|
|
1459
|
+
}
|
|
1460
|
+
get documents() {
|
|
1461
|
+
return this._documents ?? (this._documents = new DocumentsClient(this.client));
|
|
1462
|
+
}
|
|
1463
|
+
get stock() {
|
|
1464
|
+
return this._stock ?? (this._stock = new StockClient(this.client));
|
|
1465
|
+
}
|
|
1466
|
+
get vessels() {
|
|
1467
|
+
return this._vessels ?? (this._vessels = new VesselsClient(this.client));
|
|
1468
|
+
}
|
|
1469
|
+
get purchaseOrders() {
|
|
1470
|
+
return this._purchaseOrders ?? (this._purchaseOrders = new PurchaseOrdersClient(this.client));
|
|
1471
|
+
}
|
|
1464
1472
|
};
|
|
1465
1473
|
var WorkOrdersClient = class {
|
|
1466
1474
|
constructor(client) {
|
|
@@ -1992,6 +2000,19 @@ var BlocksClient = class {
|
|
|
1992
2000
|
patch(id, data) {
|
|
1993
2001
|
return this.client.request(`v7/harvest/blocks/${id}`, "PATCH", {}, data);
|
|
1994
2002
|
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Upsert assessment data for a block.
|
|
2005
|
+
*
|
|
2006
|
+
* Create or update assessment data for a block by its blockId.
|
|
2007
|
+
*/
|
|
2008
|
+
createAssessment(blockId, data) {
|
|
2009
|
+
return this.client.request(
|
|
2010
|
+
`v7/harvest/blocks/${blockId}/assessments`,
|
|
2011
|
+
"POST",
|
|
2012
|
+
{},
|
|
2013
|
+
data
|
|
2014
|
+
);
|
|
2015
|
+
}
|
|
1995
2016
|
};
|
|
1996
2017
|
var BookingsClient = class {
|
|
1997
2018
|
constructor(client) {
|
|
@@ -2142,22 +2163,22 @@ var CostsClient = class {
|
|
|
2142
2163
|
return [allResults, null];
|
|
2143
2164
|
}
|
|
2144
2165
|
};
|
|
2145
|
-
var
|
|
2166
|
+
var WineBatchesClient = class {
|
|
2146
2167
|
constructor(client) {
|
|
2147
2168
|
this.client = client;
|
|
2148
2169
|
}
|
|
2149
2170
|
/**
|
|
2150
|
-
* Get
|
|
2171
|
+
* Get a list of wine batches.
|
|
2151
2172
|
*
|
|
2152
|
-
* Returns a paginated list of
|
|
2173
|
+
* Returns a paginated list of wine batches.
|
|
2153
2174
|
*/
|
|
2154
2175
|
async getAll(params) {
|
|
2155
2176
|
const limit = params?.limit ?? 100;
|
|
2156
2177
|
const firstResponse = await this.client.request(
|
|
2157
|
-
"v7/
|
|
2178
|
+
"v7/operation/wine-batches",
|
|
2158
2179
|
"GET",
|
|
2159
|
-
{
|
|
2160
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2180
|
+
{},
|
|
2181
|
+
{ ...params, limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2161
2182
|
);
|
|
2162
2183
|
if (firstResponse[1]) {
|
|
2163
2184
|
return [null, firstResponse[1]];
|
|
@@ -2180,10 +2201,10 @@ var AssessmentsClient = class {
|
|
|
2180
2201
|
const offset = (i + j) * limit;
|
|
2181
2202
|
batchPromises.push(
|
|
2182
2203
|
this.client.request(
|
|
2183
|
-
"v7/
|
|
2204
|
+
"v7/operation/wine-batches",
|
|
2184
2205
|
"GET",
|
|
2185
|
-
{
|
|
2186
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2206
|
+
{},
|
|
2207
|
+
{ ...params, limit: String(limit), offset: String(offset) }
|
|
2187
2208
|
)
|
|
2188
2209
|
);
|
|
2189
2210
|
}
|
|
@@ -2192,237 +2213,67 @@ var AssessmentsClient = class {
|
|
|
2192
2213
|
if (pageError) {
|
|
2193
2214
|
return [null, pageError];
|
|
2194
2215
|
}
|
|
2195
|
-
|
|
2196
|
-
|
|
2216
|
+
const pData = pageData;
|
|
2217
|
+
if (pData?.results) {
|
|
2218
|
+
allResults.push(...pData.results);
|
|
2197
2219
|
}
|
|
2198
2220
|
}
|
|
2199
2221
|
}
|
|
2200
2222
|
return [allResults, null];
|
|
2201
2223
|
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Create a wine batch.
|
|
2226
|
+
*/
|
|
2227
|
+
create(data) {
|
|
2228
|
+
return this.client.request("v7/operation/wine-batches", "POST", {}, data);
|
|
2229
|
+
}
|
|
2202
2230
|
};
|
|
2203
|
-
var
|
|
2231
|
+
var TirageClient = class {
|
|
2204
2232
|
constructor(client) {
|
|
2205
2233
|
this.client = client;
|
|
2206
2234
|
}
|
|
2207
2235
|
/**
|
|
2208
|
-
*
|
|
2236
|
+
* Get a tirage by operation ID.
|
|
2209
2237
|
*
|
|
2210
|
-
*
|
|
2238
|
+
* Returns a single tirage by its operation ID.
|
|
2211
2239
|
*/
|
|
2212
|
-
|
|
2213
|
-
return this.client.request(
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
{ responseSchema: VineyardResponseSchema },
|
|
2217
|
-
data
|
|
2218
|
-
);
|
|
2219
|
-
}
|
|
2220
|
-
};
|
|
2221
|
-
var MaturitySamplesClient = class {
|
|
2222
|
-
constructor(client) {
|
|
2223
|
-
this.client = client;
|
|
2240
|
+
get(operationId) {
|
|
2241
|
+
return this.client.request(`v7/operation/tirage/${operationId}`, "GET", {
|
|
2242
|
+
responseSchema: TirageSuccessResponseSchema
|
|
2243
|
+
});
|
|
2224
2244
|
}
|
|
2225
2245
|
/**
|
|
2226
|
-
*
|
|
2246
|
+
* Patch a tirage.
|
|
2227
2247
|
*
|
|
2228
|
-
*
|
|
2248
|
+
* Updates a tirage record.
|
|
2229
2249
|
*/
|
|
2230
|
-
|
|
2250
|
+
patch(operationId, data) {
|
|
2231
2251
|
return this.client.request(
|
|
2232
|
-
|
|
2233
|
-
"
|
|
2234
|
-
{ responseSchema:
|
|
2252
|
+
`v7/operation/tirage/${operationId}`,
|
|
2253
|
+
"PATCH",
|
|
2254
|
+
{ responseSchema: TirageSuccessResponseSchema },
|
|
2235
2255
|
data
|
|
2236
2256
|
);
|
|
2237
2257
|
}
|
|
2238
2258
|
};
|
|
2239
|
-
var
|
|
2259
|
+
var BarrelsMovementsClient = class {
|
|
2240
2260
|
constructor(client) {
|
|
2241
2261
|
this.client = client;
|
|
2242
2262
|
}
|
|
2243
2263
|
/**
|
|
2244
|
-
*
|
|
2245
|
-
*
|
|
2246
|
-
* Returns a paginated list of parties.
|
|
2247
|
-
*/
|
|
2248
|
-
async getAll(params) {
|
|
2249
|
-
const limit = params?.limit ?? 100;
|
|
2250
|
-
const firstResponse = await this.client.request(
|
|
2251
|
-
"v7/identity/parties",
|
|
2252
|
-
"GET",
|
|
2253
|
-
{ responseSchema: GetPartiesV7ResponseSchema },
|
|
2254
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2255
|
-
);
|
|
2256
|
-
if (firstResponse[1]) {
|
|
2257
|
-
return [null, firstResponse[1]];
|
|
2258
|
-
}
|
|
2259
|
-
const response = firstResponse[0];
|
|
2260
|
-
if (!response) {
|
|
2261
|
-
return [[], null];
|
|
2262
|
-
}
|
|
2263
|
-
const totalCount = response.totalResults ?? response.results?.length ?? 0;
|
|
2264
|
-
if (totalCount <= limit) {
|
|
2265
|
-
return [response.results ?? [], null];
|
|
2266
|
-
}
|
|
2267
|
-
const pagesNeeded = Math.ceil(totalCount / limit);
|
|
2268
|
-
const parallelLimit = this.client.options.parallelLimit;
|
|
2269
|
-
const allResults = [...response.results ?? []];
|
|
2270
|
-
for (let i = 1; i < pagesNeeded; i += parallelLimit) {
|
|
2271
|
-
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2272
|
-
const batchPromises = [];
|
|
2273
|
-
for (let j = 0; j < batchSize; j++) {
|
|
2274
|
-
const offset = (i + j) * limit;
|
|
2275
|
-
batchPromises.push(
|
|
2276
|
-
this.client.request(
|
|
2277
|
-
"v7/identity/parties",
|
|
2278
|
-
"GET",
|
|
2279
|
-
{ responseSchema: GetPartiesV7ResponseSchema },
|
|
2280
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2281
|
-
)
|
|
2282
|
-
);
|
|
2283
|
-
}
|
|
2284
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2285
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2286
|
-
if (pageError) {
|
|
2287
|
-
return [null, pageError];
|
|
2288
|
-
}
|
|
2289
|
-
if (pageData?.results) {
|
|
2290
|
-
allResults.push(...pageData.results);
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
return [allResults, null];
|
|
2295
|
-
}
|
|
2296
|
-
/**
|
|
2297
|
-
* Upsert a party.
|
|
2264
|
+
* Create a barrels movement.
|
|
2298
2265
|
*
|
|
2299
|
-
* Creates
|
|
2266
|
+
* Creates a new barrels movement in the system.
|
|
2300
2267
|
*/
|
|
2301
2268
|
post(data) {
|
|
2302
2269
|
return this.client.request(
|
|
2303
|
-
"v7/
|
|
2270
|
+
"v7/operation/barrels-movements",
|
|
2304
2271
|
"POST",
|
|
2305
|
-
{
|
|
2272
|
+
{ requestSchema: CreateBarrelsMovementRequestSchema },
|
|
2306
2273
|
data
|
|
2307
2274
|
);
|
|
2308
2275
|
}
|
|
2309
2276
|
};
|
|
2310
|
-
var ShipmentsClient = class {
|
|
2311
|
-
constructor(client) {
|
|
2312
|
-
this.client = client;
|
|
2313
|
-
}
|
|
2314
|
-
/**
|
|
2315
|
-
* List all shipments.
|
|
2316
|
-
*
|
|
2317
|
-
* Returns a paginated list of shipments.
|
|
2318
|
-
*/
|
|
2319
|
-
async getAll(params) {
|
|
2320
|
-
const limit = params?.limit ?? 100;
|
|
2321
|
-
const firstResponse = await this.client.request(
|
|
2322
|
-
"v7/operation/shipments",
|
|
2323
|
-
"GET",
|
|
2324
|
-
{ responseSchema: GetShipmentsSuccessResponseSchema },
|
|
2325
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2326
|
-
);
|
|
2327
|
-
if (firstResponse[1]) {
|
|
2328
|
-
return [null, firstResponse[1]];
|
|
2329
|
-
}
|
|
2330
|
-
const response = firstResponse[0];
|
|
2331
|
-
if (!response) {
|
|
2332
|
-
return [[], null];
|
|
2333
|
-
}
|
|
2334
|
-
const totalCount = response.totalResults ?? response.results?.length ?? 0;
|
|
2335
|
-
if (totalCount <= limit) {
|
|
2336
|
-
return [response.results ?? [], null];
|
|
2337
|
-
}
|
|
2338
|
-
const pagesNeeded = Math.ceil(totalCount / limit);
|
|
2339
|
-
const parallelLimit = this.client.options.parallelLimit;
|
|
2340
|
-
const allResults = [...response.results ?? []];
|
|
2341
|
-
for (let i = 1; i < pagesNeeded; i += parallelLimit) {
|
|
2342
|
-
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2343
|
-
const batchPromises = [];
|
|
2344
|
-
for (let j = 0; j < batchSize; j++) {
|
|
2345
|
-
const offset = (i + j) * limit;
|
|
2346
|
-
batchPromises.push(
|
|
2347
|
-
this.client.request(
|
|
2348
|
-
"v7/operation/shipments",
|
|
2349
|
-
"GET",
|
|
2350
|
-
{ responseSchema: GetShipmentsSuccessResponseSchema },
|
|
2351
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2352
|
-
)
|
|
2353
|
-
);
|
|
2354
|
-
}
|
|
2355
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2356
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2357
|
-
if (pageError) {
|
|
2358
|
-
return [null, pageError];
|
|
2359
|
-
}
|
|
2360
|
-
if (pageData?.results) {
|
|
2361
|
-
allResults.push(...pageData.results);
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
return [allResults, null];
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
var BarrelTreatmentsClient = class {
|
|
2369
|
-
constructor(client) {
|
|
2370
|
-
this.client = client;
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* List all barrel treatments.
|
|
2374
|
-
*
|
|
2375
|
-
* Returns a paginated list of barrel treatments.
|
|
2376
|
-
*/
|
|
2377
|
-
async getAll(params) {
|
|
2378
|
-
const limit = params?.limit ?? 100;
|
|
2379
|
-
const firstResponse = await this.client.request(
|
|
2380
|
-
"v7/operation/barrel-treatments",
|
|
2381
|
-
"GET",
|
|
2382
|
-
{ responseSchema: GetBarrelTreatmentsSuccessResponseSchema },
|
|
2383
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2384
|
-
);
|
|
2385
|
-
if (firstResponse[1]) {
|
|
2386
|
-
return [null, firstResponse[1]];
|
|
2387
|
-
}
|
|
2388
|
-
const response = firstResponse[0];
|
|
2389
|
-
if (!response) {
|
|
2390
|
-
return [[], null];
|
|
2391
|
-
}
|
|
2392
|
-
const totalCount = response.totalResults ?? response.results?.length ?? 0;
|
|
2393
|
-
if (totalCount <= limit) {
|
|
2394
|
-
return [response.results ?? [], null];
|
|
2395
|
-
}
|
|
2396
|
-
const pagesNeeded = Math.ceil(totalCount / limit);
|
|
2397
|
-
const parallelLimit = this.client.options.parallelLimit;
|
|
2398
|
-
const allResults = [...response.results ?? []];
|
|
2399
|
-
for (let i = 1; i < pagesNeeded; i += parallelLimit) {
|
|
2400
|
-
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2401
|
-
const batchPromises = [];
|
|
2402
|
-
for (let j = 0; j < batchSize; j++) {
|
|
2403
|
-
const offset = (i + j) * limit;
|
|
2404
|
-
batchPromises.push(
|
|
2405
|
-
this.client.request(
|
|
2406
|
-
"v7/operation/barrel-treatments",
|
|
2407
|
-
"GET",
|
|
2408
|
-
{ responseSchema: GetBarrelTreatmentsSuccessResponseSchema },
|
|
2409
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2410
|
-
)
|
|
2411
|
-
);
|
|
2412
|
-
}
|
|
2413
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2414
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2415
|
-
if (pageError) {
|
|
2416
|
-
return [null, pageError];
|
|
2417
|
-
}
|
|
2418
|
-
if (pageData?.results) {
|
|
2419
|
-
allResults.push(...pageData.results);
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
return [allResults, null];
|
|
2424
|
-
}
|
|
2425
|
-
};
|
|
2426
2277
|
var FruitIntakesClient = class {
|
|
2427
2278
|
constructor(client) {
|
|
2428
2279
|
this.client = client;
|
|
@@ -2430,194 +2281,86 @@ var FruitIntakesClient = class {
|
|
|
2430
2281
|
/**
|
|
2431
2282
|
* Create a fruit intake.
|
|
2432
2283
|
*
|
|
2433
|
-
*
|
|
2284
|
+
* Record a new fruit intake transaction.
|
|
2434
2285
|
*/
|
|
2435
|
-
|
|
2286
|
+
create(data) {
|
|
2436
2287
|
return this.client.request(
|
|
2437
2288
|
"v7/operation/fruit-intakes",
|
|
2438
2289
|
"POST",
|
|
2439
2290
|
{
|
|
2440
|
-
|
|
2441
|
-
|
|
2291
|
+
requestSchema: FruitIntakeRequestSchema,
|
|
2292
|
+
responseSchema: CreateFruitIntakeSuccessResponseSchema
|
|
2442
2293
|
},
|
|
2443
2294
|
data
|
|
2444
2295
|
);
|
|
2445
2296
|
}
|
|
2446
2297
|
/**
|
|
2447
|
-
* Update fruit intake
|
|
2298
|
+
* Update pricing for a fruit intake.
|
|
2448
2299
|
*
|
|
2449
|
-
*
|
|
2300
|
+
* Update the pricing related data for this fruit intake record.
|
|
2450
2301
|
*/
|
|
2451
2302
|
updatePricing(fruitIntakeId, data) {
|
|
2452
2303
|
return this.client.request(
|
|
2453
2304
|
`v7/operation/fruit-intakes/${fruitIntakeId}/pricing`,
|
|
2454
|
-
"
|
|
2455
|
-
{
|
|
2305
|
+
"PUT",
|
|
2306
|
+
{
|
|
2307
|
+
requestSchema: UpdateFruitIntakePricingSchema,
|
|
2308
|
+
responseSchema: UpdateFruitIntakePricingResponseSchema
|
|
2309
|
+
},
|
|
2456
2310
|
data
|
|
2457
2311
|
);
|
|
2458
2312
|
}
|
|
2459
2313
|
/**
|
|
2460
|
-
* Update fruit intake
|
|
2314
|
+
* Update metrics for a fruit intake.
|
|
2461
2315
|
*
|
|
2462
|
-
*
|
|
2316
|
+
* Update the metrics for this fruit intake record.
|
|
2463
2317
|
*/
|
|
2464
2318
|
updateMetrics(fruitIntakeId, data) {
|
|
2465
2319
|
return this.client.request(
|
|
2466
2320
|
`v7/operation/fruit-intakes/${fruitIntakeId}/metrics`,
|
|
2467
|
-
"
|
|
2468
|
-
{},
|
|
2321
|
+
"PUT",
|
|
2322
|
+
{ responseSchema: UpdateMetricsResponseSchema, requestSchema: UpdateMetricsSchema },
|
|
2469
2323
|
data
|
|
2470
2324
|
);
|
|
2471
2325
|
}
|
|
2472
2326
|
};
|
|
2473
|
-
var
|
|
2327
|
+
var DocumentsClient = class {
|
|
2474
2328
|
constructor(client) {
|
|
2475
2329
|
this.client = client;
|
|
2476
2330
|
}
|
|
2477
2331
|
/**
|
|
2478
|
-
*
|
|
2479
|
-
*
|
|
2480
|
-
* Returns a paginated list of bulk intakes.
|
|
2481
|
-
*/
|
|
2482
|
-
async getAll(params) {
|
|
2483
|
-
const limit = params?.limit ?? 100;
|
|
2484
|
-
const firstResponse = await this.client.request(
|
|
2485
|
-
"v7/operation/bulk-intakes",
|
|
2486
|
-
"GET",
|
|
2487
|
-
{ responseSchema: GetBulkIntakesSuccessResponseSchema },
|
|
2488
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2489
|
-
);
|
|
2490
|
-
if (firstResponse[1]) {
|
|
2491
|
-
return [null, firstResponse[1]];
|
|
2492
|
-
}
|
|
2493
|
-
const response = firstResponse[0];
|
|
2494
|
-
if (!response) {
|
|
2495
|
-
return [[], null];
|
|
2496
|
-
}
|
|
2497
|
-
const totalCount = response.totalResults ?? response.results?.length ?? 0;
|
|
2498
|
-
if (totalCount <= limit) {
|
|
2499
|
-
return [response.results ?? [], null];
|
|
2500
|
-
}
|
|
2501
|
-
const pagesNeeded = Math.ceil(totalCount / limit);
|
|
2502
|
-
const parallelLimit = this.client.options.parallelLimit;
|
|
2503
|
-
const allResults = [...response.results ?? []];
|
|
2504
|
-
for (let i = 1; i < pagesNeeded; i += parallelLimit) {
|
|
2505
|
-
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2506
|
-
const batchPromises = [];
|
|
2507
|
-
for (let j = 0; j < batchSize; j++) {
|
|
2508
|
-
const offset = (i + j) * limit;
|
|
2509
|
-
batchPromises.push(
|
|
2510
|
-
this.client.request(
|
|
2511
|
-
"v7/operation/bulk-intakes",
|
|
2512
|
-
"GET",
|
|
2513
|
-
{ responseSchema: GetBulkIntakesSuccessResponseSchema },
|
|
2514
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2515
|
-
)
|
|
2516
|
-
);
|
|
2517
|
-
}
|
|
2518
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2519
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2520
|
-
if (pageError) {
|
|
2521
|
-
return [null, pageError];
|
|
2522
|
-
}
|
|
2523
|
-
if (pageData?.results) {
|
|
2524
|
-
allResults.push(...pageData.results);
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
return [allResults, null];
|
|
2529
|
-
}
|
|
2530
|
-
/**
|
|
2531
|
-
* Create a bulk intake.
|
|
2532
|
-
*
|
|
2533
|
-
* Creates a new bulk intake in the system.
|
|
2534
|
-
*/
|
|
2535
|
-
post(data) {
|
|
2536
|
-
return this.client.request("v7/operation/bulk-intakes", "POST", {}, data);
|
|
2537
|
-
}
|
|
2538
|
-
/**
|
|
2539
|
-
* Partially update a bulk intake.
|
|
2332
|
+
* Upload a file to an operation.
|
|
2540
2333
|
*
|
|
2541
|
-
*
|
|
2334
|
+
* Attach documents to a specified operation.
|
|
2542
2335
|
*/
|
|
2543
|
-
|
|
2544
|
-
return this.client.request(
|
|
2336
|
+
attach(data) {
|
|
2337
|
+
return this.client.request("v7/operation/operation/documents", "PUT", {}, data);
|
|
2545
2338
|
}
|
|
2546
2339
|
};
|
|
2547
|
-
var
|
|
2340
|
+
var StockClient = class {
|
|
2548
2341
|
constructor(client) {
|
|
2549
2342
|
this.client = client;
|
|
2550
2343
|
}
|
|
2551
2344
|
/**
|
|
2552
|
-
*
|
|
2345
|
+
* Receive stock.
|
|
2553
2346
|
*
|
|
2554
|
-
*
|
|
2347
|
+
* Perform a receive stock operation in the system.
|
|
2555
2348
|
*/
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
const firstResponse = await this.client.request(
|
|
2559
|
-
"v7/operation/trial-blends",
|
|
2560
|
-
"GET",
|
|
2561
|
-
{ responseSchema: GetTrialBlendsSuccessResponseSchema },
|
|
2562
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2563
|
-
);
|
|
2564
|
-
if (firstResponse[1]) {
|
|
2565
|
-
return [null, firstResponse[1]];
|
|
2566
|
-
}
|
|
2567
|
-
const response = firstResponse[0];
|
|
2568
|
-
if (!response) {
|
|
2569
|
-
return [[], null];
|
|
2570
|
-
}
|
|
2571
|
-
const totalCount = response.totalResults ?? response.results?.length ?? 0;
|
|
2572
|
-
if (totalCount <= limit) {
|
|
2573
|
-
return [response.results ?? [], null];
|
|
2574
|
-
}
|
|
2575
|
-
const pagesNeeded = Math.ceil(totalCount / limit);
|
|
2576
|
-
const parallelLimit = this.client.options.parallelLimit;
|
|
2577
|
-
const allResults = [...response.results ?? []];
|
|
2578
|
-
for (let i = 1; i < pagesNeeded; i += parallelLimit) {
|
|
2579
|
-
const batchSize = Math.min(parallelLimit, pagesNeeded - i);
|
|
2580
|
-
const batchPromises = [];
|
|
2581
|
-
for (let j = 0; j < batchSize; j++) {
|
|
2582
|
-
const offset = (i + j) * limit;
|
|
2583
|
-
batchPromises.push(
|
|
2584
|
-
this.client.request(
|
|
2585
|
-
"v7/operation/trial-blends",
|
|
2586
|
-
"GET",
|
|
2587
|
-
{ responseSchema: GetTrialBlendsSuccessResponseSchema },
|
|
2588
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2589
|
-
)
|
|
2590
|
-
);
|
|
2591
|
-
}
|
|
2592
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2593
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2594
|
-
if (pageError) {
|
|
2595
|
-
return [null, pageError];
|
|
2596
|
-
}
|
|
2597
|
-
if (pageData?.results) {
|
|
2598
|
-
allResults.push(...pageData.results);
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
return [allResults, null];
|
|
2603
|
-
}
|
|
2604
|
-
};
|
|
2605
|
-
var WorkOrdersV7Client = class {
|
|
2606
|
-
constructor(client) {
|
|
2607
|
-
this.client = client;
|
|
2349
|
+
receive(data) {
|
|
2350
|
+
return this.client.request("v7/stock/receivals", "POST", {}, data);
|
|
2608
2351
|
}
|
|
2609
2352
|
/**
|
|
2610
|
-
*
|
|
2353
|
+
* Get all stock dispatches.
|
|
2611
2354
|
*
|
|
2612
|
-
* Returns a paginated list of
|
|
2355
|
+
* Returns a paginated list of stock dispatch actions.
|
|
2613
2356
|
*/
|
|
2614
|
-
async
|
|
2357
|
+
async getDispatches(params) {
|
|
2615
2358
|
const limit = params?.limit ?? 100;
|
|
2616
2359
|
const firstResponse = await this.client.request(
|
|
2617
|
-
"v7/
|
|
2360
|
+
"v7/stock/dispatches",
|
|
2618
2361
|
"GET",
|
|
2619
|
-
{
|
|
2620
|
-
{ limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2362
|
+
{},
|
|
2363
|
+
{ ...params, limit: String(limit), offset: String(params?.offset ?? 0) }
|
|
2621
2364
|
);
|
|
2622
2365
|
if (firstResponse[1]) {
|
|
2623
2366
|
return [null, firstResponse[1]];
|
|
@@ -2640,10 +2383,10 @@ var WorkOrdersV7Client = class {
|
|
|
2640
2383
|
const offset = (i + j) * limit;
|
|
2641
2384
|
batchPromises.push(
|
|
2642
2385
|
this.client.request(
|
|
2643
|
-
"v7/
|
|
2386
|
+
"v7/stock/dispatches",
|
|
2644
2387
|
"GET",
|
|
2645
|
-
{
|
|
2646
|
-
{ limit: String(limit), offset: String(offset) }
|
|
2388
|
+
{},
|
|
2389
|
+
{ ...params, limit: String(limit), offset: String(offset) }
|
|
2647
2390
|
)
|
|
2648
2391
|
);
|
|
2649
2392
|
}
|
|
@@ -2652,53 +2395,53 @@ var WorkOrdersV7Client = class {
|
|
|
2652
2395
|
if (pageError) {
|
|
2653
2396
|
return [null, pageError];
|
|
2654
2397
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2398
|
+
const pData = pageData;
|
|
2399
|
+
if (pData?.results) {
|
|
2400
|
+
allResults.push(...pData.results);
|
|
2657
2401
|
}
|
|
2658
2402
|
}
|
|
2659
2403
|
}
|
|
2660
2404
|
return [allResults, null];
|
|
2661
2405
|
}
|
|
2662
2406
|
};
|
|
2663
|
-
var
|
|
2407
|
+
var VesselsClient = class {
|
|
2664
2408
|
constructor(client) {
|
|
2665
2409
|
this.client = client;
|
|
2666
2410
|
}
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
*
|
|
2670
|
-
* Returns a single tirage by its operation ID.
|
|
2671
|
-
*/
|
|
2672
|
-
get(operationId) {
|
|
2673
|
-
return this.client.request(`v7/operation/tirage/${operationId}`, "GET", {
|
|
2674
|
-
responseSchema: TirageSuccessResponseSchema
|
|
2675
|
-
});
|
|
2411
|
+
getBarrel(id) {
|
|
2412
|
+
return this.client.request(`v7/vessel/barrels/${id}`, "GET");
|
|
2676
2413
|
}
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2414
|
+
getBarrelGroup(id) {
|
|
2415
|
+
return this.client.request(`v7/vessel/barrel-groups/${id}`, "GET");
|
|
2416
|
+
}
|
|
2417
|
+
createTank(data) {
|
|
2418
|
+
return this.client.request("v7/vessel/tanks", "POST", {}, data);
|
|
2419
|
+
}
|
|
2420
|
+
getTank(id) {
|
|
2421
|
+
return this.client.request(`v7/vessel/tanks/${id}`, "GET");
|
|
2422
|
+
}
|
|
2423
|
+
getTanker(id) {
|
|
2424
|
+
return this.client.request(`v7/vessel/tankers/${id}`, "GET");
|
|
2425
|
+
}
|
|
2426
|
+
getBin(id) {
|
|
2427
|
+
return this.client.request(`v7/vessel/bins/${id}`, "GET");
|
|
2684
2428
|
}
|
|
2685
2429
|
};
|
|
2686
|
-
var
|
|
2430
|
+
var PurchaseOrdersClient = class {
|
|
2687
2431
|
constructor(client) {
|
|
2688
2432
|
this.client = client;
|
|
2689
2433
|
}
|
|
2690
2434
|
/**
|
|
2691
|
-
* Create a
|
|
2692
|
-
*
|
|
2693
|
-
* Creates a new barrels movement in the system.
|
|
2435
|
+
* Create or update a purchase order.
|
|
2694
2436
|
*/
|
|
2695
|
-
|
|
2696
|
-
return this.client.request(
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2437
|
+
create(data) {
|
|
2438
|
+
return this.client.request("v7/account/purchase-orders", "POST", {}, data);
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Get purchase order details by id.
|
|
2442
|
+
*/
|
|
2443
|
+
get(id) {
|
|
2444
|
+
return this.client.request(`v7/account/purchase-orders/${id}`, "GET");
|
|
2702
2445
|
}
|
|
2703
2446
|
};
|
|
2704
2447
|
var TransactionsClient = class {
|
|
@@ -2824,15 +2567,63 @@ var SampleOperationsClient = class {
|
|
|
2824
2567
|
/**
|
|
2825
2568
|
* Maturity samples search.
|
|
2826
2569
|
*
|
|
2827
|
-
* Returns a list of maturity samples matching search criteria
|
|
2570
|
+
* Returns a list of maturity samples matching search criteria from
|
|
2571
|
+
* `GET v6/sample-operations/search`.
|
|
2572
|
+
*
|
|
2573
|
+
* **Pagination behaviour:**
|
|
2574
|
+
* - By default (`maxResults` and `firstResult` omitted) the method
|
|
2575
|
+
* auto-paginates and returns **all** matching records by following the
|
|
2576
|
+
* API's `nextResult` cursor until a short page signals the end.
|
|
2577
|
+
* - Pass `maxResults` and/or `firstResult` to control pagination yourself —
|
|
2578
|
+
* in that case a single page is returned as-is.
|
|
2579
|
+
*
|
|
2580
|
+
* @param params.blockId - Filter by vintrace block ID.
|
|
2581
|
+
* @param params.blockName - Filter by block name (partial match).
|
|
2582
|
+
* @param params.vineyardId - Filter by vineyard ID.
|
|
2583
|
+
* @param params.vineyardName - Filter by vineyard name.
|
|
2584
|
+
* @param params.growerId - Filter by grower ID.
|
|
2585
|
+
* @param params.growerName - Filter by grower name.
|
|
2586
|
+
* @param params.ownerId - Filter by owner ID.
|
|
2587
|
+
* @param params.ownerName - Filter by owner name.
|
|
2588
|
+
* @param params.vintage - Filter by vintage year in YYYY format (e.g. `"2022"`).
|
|
2589
|
+
* @param params.operationId - Filter by a specific operation ID.
|
|
2590
|
+
* @param params.processId - Filter by delivery process ID.
|
|
2591
|
+
* @param params.externalBlockId - Filter by external block ID.
|
|
2592
|
+
* @param params.externalSystemBlocksOnly - Only return blocks that have an external ID set.
|
|
2593
|
+
* @param params.recordedAfter - Only return records with an effective date after this
|
|
2594
|
+
* timestamp (milliseconds since Unix epoch, e.g. `157813337000`).
|
|
2595
|
+
* @param params.recordedBefore - Only return records with an effective date before this
|
|
2596
|
+
* timestamp (milliseconds since Unix epoch, e.g. `157813337000`).
|
|
2597
|
+
* @param params.modifiedSince - Only return records added/modified/reversed since this
|
|
2598
|
+
* timestamp (milliseconds since Unix epoch).
|
|
2599
|
+
* @param params.maxResults - Page size (default `100`). Supply this to opt out of
|
|
2600
|
+
* auto-pagination and receive a single page.
|
|
2601
|
+
* @param params.firstResult - Zero-based offset to start from. Supply this together
|
|
2602
|
+
* with `maxResults` to manually page through results.
|
|
2603
|
+
* @param params.customAdapter - Special adapter reference for customised `additionalDetails`
|
|
2604
|
+
* fields (use as directed by vintrace support).
|
|
2605
|
+
*
|
|
2606
|
+
* @example
|
|
2607
|
+
* // Auto-paginate — returns every matching sample
|
|
2608
|
+
* const [samples, error] = await client.v6.sampleOperations.search({
|
|
2609
|
+
* vintage: '2023',
|
|
2610
|
+
* recordedBefore: String(Date.now()),
|
|
2611
|
+
* });
|
|
2612
|
+
*
|
|
2613
|
+
* @example
|
|
2614
|
+
* // Manual page — first 20 results only
|
|
2615
|
+
* const [page, error] = await client.v6.sampleOperations.search({
|
|
2616
|
+
* maxResults: 20,
|
|
2617
|
+
* firstResult: 0,
|
|
2618
|
+
* });
|
|
2828
2619
|
*/
|
|
2829
2620
|
async search(params) {
|
|
2830
|
-
const limit = params?.maxResults
|
|
2621
|
+
const limit = params?.maxResults ?? 100;
|
|
2831
2622
|
const firstResponse = await this.client.request(
|
|
2832
2623
|
"v6/sample-operations/search",
|
|
2833
2624
|
"GET",
|
|
2834
2625
|
{ responseSchema: SampleOperationSearchResponseSchema },
|
|
2835
|
-
{ ...params, maxResults: limit, firstResult: 0 }
|
|
2626
|
+
{ ...params, maxResults: limit, firstResult: params?.firstResult ?? 0 }
|
|
2836
2627
|
);
|
|
2837
2628
|
if (firstResponse[1]) {
|
|
2838
2629
|
return [null, firstResponse[1]];
|
|
@@ -2841,36 +2632,25 @@ var SampleOperationsClient = class {
|
|
|
2841
2632
|
if (!response) {
|
|
2842
2633
|
return [[], null];
|
|
2843
2634
|
}
|
|
2844
|
-
const
|
|
2845
|
-
if (
|
|
2846
|
-
return [
|
|
2635
|
+
const firstPage = response.samples ?? [];
|
|
2636
|
+
if (params?.maxResults != null || params?.firstResult != null) {
|
|
2637
|
+
return [firstPage, null];
|
|
2847
2638
|
}
|
|
2848
|
-
const
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
"GET",
|
|
2860
|
-
{ responseSchema: SampleOperationSearchResponseSchema },
|
|
2861
|
-
{ ...params, maxResults: limit, firstResult: offset }
|
|
2862
|
-
)
|
|
2863
|
-
);
|
|
2864
|
-
}
|
|
2865
|
-
const batchResults = await Promise.all(batchPromises);
|
|
2866
|
-
for (const [pageData, pageError] of batchResults) {
|
|
2867
|
-
if (pageError) {
|
|
2868
|
-
return [null, pageError];
|
|
2869
|
-
}
|
|
2870
|
-
if (pageData?.results) {
|
|
2871
|
-
allResults.push(...pageData.results);
|
|
2872
|
-
}
|
|
2639
|
+
const allResults = [...firstPage];
|
|
2640
|
+
let nextOffset = firstPage.length >= limit ? response.nextResult : null;
|
|
2641
|
+
while (nextOffset != null) {
|
|
2642
|
+
const [pageData, pageError] = await this.client.request(
|
|
2643
|
+
"v6/sample-operations/search",
|
|
2644
|
+
"GET",
|
|
2645
|
+
{ responseSchema: SampleOperationSearchResponseSchema },
|
|
2646
|
+
{ ...params, maxResults: limit, firstResult: nextOffset }
|
|
2647
|
+
);
|
|
2648
|
+
if (pageError) {
|
|
2649
|
+
return [null, pageError];
|
|
2873
2650
|
}
|
|
2651
|
+
const page = pageData?.samples ?? [];
|
|
2652
|
+
allResults.push(...page);
|
|
2653
|
+
nextOffset = page.length >= limit ? pageData?.nextResult ?? null : null;
|
|
2874
2654
|
}
|
|
2875
2655
|
return [allResults, null];
|
|
2876
2656
|
}
|
|
@@ -2995,6 +2775,14 @@ var InventoryClient = class {
|
|
|
2995
2775
|
}
|
|
2996
2776
|
return [allResults, null];
|
|
2997
2777
|
}
|
|
2778
|
+
/**
|
|
2779
|
+
* Get stock item by code or id.
|
|
2780
|
+
*
|
|
2781
|
+
* Returns a single stock item by code or id.
|
|
2782
|
+
*/
|
|
2783
|
+
lookup(params) {
|
|
2784
|
+
return this.client.request("v6/stock/lookup", "GET", {}, params);
|
|
2785
|
+
}
|
|
2998
2786
|
};
|
|
2999
2787
|
var SearchClient = class {
|
|
3000
2788
|
constructor(client) {
|