@purveyors/sdk 0.2.0 → 0.3.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.d.ts +765 -13
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,24 @@ interface paths {
|
|
|
141
141
|
"application/json": components["schemas"]["CatalogAccessResponse"];
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
|
+
/** @description Authentication required */
|
|
145
|
+
401: {
|
|
146
|
+
headers: {
|
|
147
|
+
[name: string]: unknown;
|
|
148
|
+
};
|
|
149
|
+
content: {
|
|
150
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/** @description Insufficient entitlement (plan or role) */
|
|
154
|
+
403: {
|
|
155
|
+
headers: {
|
|
156
|
+
[name: string]: unknown;
|
|
157
|
+
};
|
|
158
|
+
content: {
|
|
159
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
160
|
+
};
|
|
161
|
+
};
|
|
144
162
|
};
|
|
145
163
|
};
|
|
146
164
|
put?: never;
|
|
@@ -160,7 +178,7 @@ interface paths {
|
|
|
160
178
|
};
|
|
161
179
|
/**
|
|
162
180
|
* List public catalog coffees
|
|
163
|
-
* @description Public catalog listing. Excludes wholesale-restricted rows and returns only public fields. API-key callers are capped to their plan's per-call row limit.
|
|
181
|
+
* @description Public catalog listing. Excludes wholesale-restricted rows and returns only public fields. API-key callers are capped to their plan's per-call row limit. Requesting entitlement-gated params (price/score ranges, process facets, advanced sorts) you are not entitled to is handled per PADR-0013 §7: strict callers (API keys, bearer-session JWTs) receive a 401/403; lenient callers (anonymous, first-party web) get the params stripped with a `meta.notices` entry. Send `Prefer: handling=strict` to opt into strict enforcement; `Prefer: handling=lenient` is honored only for callers already lenient-eligible and cannot downgrade a strict caller's enforcement.
|
|
164
182
|
*/
|
|
165
183
|
get: {
|
|
166
184
|
parameters: {
|
|
@@ -170,8 +188,40 @@ interface paths {
|
|
|
170
188
|
stocked?: "true" | "false" | "all";
|
|
171
189
|
sort?: string;
|
|
172
190
|
order?: "asc" | "desc";
|
|
191
|
+
showWholesale?: "true" | "false";
|
|
192
|
+
wholesaleOnly?: "true" | "false";
|
|
193
|
+
origin?: string;
|
|
194
|
+
continent?: string;
|
|
195
|
+
country?: string | string[];
|
|
196
|
+
region?: string;
|
|
197
|
+
source?: string | string[];
|
|
198
|
+
name?: string;
|
|
199
|
+
processing?: string;
|
|
200
|
+
variety?: string;
|
|
201
|
+
type?: string;
|
|
202
|
+
grade?: string;
|
|
203
|
+
appearance?: string;
|
|
204
|
+
supplier?: string;
|
|
205
|
+
dryingMethod?: string;
|
|
206
|
+
flavorKeywords?: string | string[];
|
|
207
|
+
arrivalDate?: string;
|
|
208
|
+
stockedDate?: string;
|
|
209
|
+
stockedDays?: number;
|
|
210
|
+
coffeeIds?: string;
|
|
211
|
+
scoreValueMin?: number | null;
|
|
212
|
+
scoreValueMax?: number | null;
|
|
213
|
+
pricePerLbMin?: number | null;
|
|
214
|
+
pricePerLbMax?: number | null;
|
|
215
|
+
processing_base_method?: string;
|
|
216
|
+
fermentation_type?: string;
|
|
217
|
+
process_additive?: string;
|
|
218
|
+
has_additives?: "true" | "false";
|
|
219
|
+
processing_disclosure_level?: string;
|
|
220
|
+
processing_confidence_min?: number | null;
|
|
221
|
+
};
|
|
222
|
+
header?: {
|
|
223
|
+
Prefer?: string;
|
|
173
224
|
};
|
|
174
|
-
header?: never;
|
|
175
225
|
path?: never;
|
|
176
226
|
cookie?: never;
|
|
177
227
|
};
|
|
@@ -186,6 +236,175 @@ interface paths {
|
|
|
186
236
|
"application/json": components["schemas"]["CatalogListResponse"];
|
|
187
237
|
};
|
|
188
238
|
};
|
|
239
|
+
/** @description Authentication required */
|
|
240
|
+
401: {
|
|
241
|
+
headers: {
|
|
242
|
+
[name: string]: unknown;
|
|
243
|
+
};
|
|
244
|
+
content: {
|
|
245
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/** @description Insufficient entitlement (plan or role) */
|
|
249
|
+
403: {
|
|
250
|
+
headers: {
|
|
251
|
+
[name: string]: unknown;
|
|
252
|
+
};
|
|
253
|
+
content: {
|
|
254
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
put?: never;
|
|
260
|
+
post?: never;
|
|
261
|
+
delete?: never;
|
|
262
|
+
options?: never;
|
|
263
|
+
head?: never;
|
|
264
|
+
patch?: never;
|
|
265
|
+
trace?: never;
|
|
266
|
+
};
|
|
267
|
+
"/v1/catalog/facets": {
|
|
268
|
+
parameters: {
|
|
269
|
+
query?: never;
|
|
270
|
+
header?: never;
|
|
271
|
+
path?: never;
|
|
272
|
+
cookie?: never;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Catalog filter metadata and counted facets
|
|
276
|
+
* @description Returns access-aware catalog filter metadata. Values are computed after visibility and entitled content filters are applied; premium process metadata is included only for member sessions and paid API tiers. Requesting entitlement-gated filters you are not entitled to is handled per PADR-0013 §7: strict callers (API keys, bearer-session JWTs) receive a 401/403; lenient callers (anonymous, first-party web) get the filters stripped with a `meta.notices` entry. Send `Prefer: handling=strict` to opt into strict enforcement; `Prefer: handling=lenient` is honored only for callers already lenient-eligible and cannot downgrade a strict caller's enforcement.
|
|
277
|
+
*/
|
|
278
|
+
get: {
|
|
279
|
+
parameters: {
|
|
280
|
+
query?: {
|
|
281
|
+
stocked?: "true" | "false" | "all";
|
|
282
|
+
showWholesale?: "true" | "false";
|
|
283
|
+
wholesaleOnly?: "true" | "false";
|
|
284
|
+
origin?: string;
|
|
285
|
+
continent?: string;
|
|
286
|
+
country?: string | string[];
|
|
287
|
+
region?: string;
|
|
288
|
+
source?: string | string[];
|
|
289
|
+
name?: string;
|
|
290
|
+
processing?: string;
|
|
291
|
+
variety?: string;
|
|
292
|
+
type?: string;
|
|
293
|
+
grade?: string;
|
|
294
|
+
appearance?: string;
|
|
295
|
+
supplier?: string;
|
|
296
|
+
dryingMethod?: string;
|
|
297
|
+
flavorKeywords?: string | string[];
|
|
298
|
+
arrivalDate?: string;
|
|
299
|
+
stockedDate?: string;
|
|
300
|
+
stockedDays?: number;
|
|
301
|
+
coffeeIds?: string | string[];
|
|
302
|
+
scoreValueMin?: number | null;
|
|
303
|
+
scoreValueMax?: number | null;
|
|
304
|
+
pricePerLbMin?: number | null;
|
|
305
|
+
pricePerLbMax?: number | null;
|
|
306
|
+
processing_base_method?: string;
|
|
307
|
+
fermentation_type?: string;
|
|
308
|
+
process_additive?: string;
|
|
309
|
+
has_additives?: "true" | "false";
|
|
310
|
+
processing_disclosure_level?: string;
|
|
311
|
+
processing_confidence_min?: number | null;
|
|
312
|
+
};
|
|
313
|
+
header?: {
|
|
314
|
+
Prefer?: string;
|
|
315
|
+
};
|
|
316
|
+
path?: never;
|
|
317
|
+
cookie?: never;
|
|
318
|
+
};
|
|
319
|
+
requestBody?: never;
|
|
320
|
+
responses: {
|
|
321
|
+
/** @description Access-aware catalog filter metadata */
|
|
322
|
+
200: {
|
|
323
|
+
headers: {
|
|
324
|
+
[name: string]: unknown;
|
|
325
|
+
};
|
|
326
|
+
content: {
|
|
327
|
+
"application/json": components["schemas"]["CatalogFacetsResponse"];
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
/** @description Authentication required */
|
|
331
|
+
401: {
|
|
332
|
+
headers: {
|
|
333
|
+
[name: string]: unknown;
|
|
334
|
+
};
|
|
335
|
+
content: {
|
|
336
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
/** @description Insufficient entitlement (plan or role) */
|
|
340
|
+
403: {
|
|
341
|
+
headers: {
|
|
342
|
+
[name: string]: unknown;
|
|
343
|
+
};
|
|
344
|
+
content: {
|
|
345
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
put?: never;
|
|
351
|
+
post?: never;
|
|
352
|
+
delete?: never;
|
|
353
|
+
options?: never;
|
|
354
|
+
head?: never;
|
|
355
|
+
patch?: never;
|
|
356
|
+
trace?: never;
|
|
357
|
+
};
|
|
358
|
+
"/v1/catalog/origin-price-stats": {
|
|
359
|
+
parameters: {
|
|
360
|
+
query?: never;
|
|
361
|
+
header?: never;
|
|
362
|
+
path?: never;
|
|
363
|
+
cookie?: never;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Live catalog price context by origin
|
|
367
|
+
* @description Returns per-origin live catalog price percentiles over the caller-visible stocked catalog. Used by first-party surfaces to compare a lot's visible display price against origin peers.
|
|
368
|
+
*/
|
|
369
|
+
get: {
|
|
370
|
+
parameters: {
|
|
371
|
+
query?: {
|
|
372
|
+
showWholesale?: "true" | "false";
|
|
373
|
+
wholesaleOnly?: "true" | "false";
|
|
374
|
+
};
|
|
375
|
+
header?: never;
|
|
376
|
+
path?: never;
|
|
377
|
+
cookie?: never;
|
|
378
|
+
};
|
|
379
|
+
requestBody?: never;
|
|
380
|
+
responses: {
|
|
381
|
+
/** @description Per-origin price context for caller-visible catalog rows */
|
|
382
|
+
200: {
|
|
383
|
+
headers: {
|
|
384
|
+
[name: string]: unknown;
|
|
385
|
+
};
|
|
386
|
+
content: {
|
|
387
|
+
"application/json": components["schemas"]["CatalogOriginPriceStatsResponse"];
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
/** @description Authentication required */
|
|
391
|
+
401: {
|
|
392
|
+
headers: {
|
|
393
|
+
[name: string]: unknown;
|
|
394
|
+
};
|
|
395
|
+
content: {
|
|
396
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
/** @description Insufficient entitlement (plan or role) */
|
|
400
|
+
403: {
|
|
401
|
+
headers: {
|
|
402
|
+
[name: string]: unknown;
|
|
403
|
+
};
|
|
404
|
+
content: {
|
|
405
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
406
|
+
};
|
|
407
|
+
};
|
|
189
408
|
};
|
|
190
409
|
};
|
|
191
410
|
put?: never;
|
|
@@ -225,6 +444,24 @@ interface paths {
|
|
|
225
444
|
"application/json": components["schemas"]["CatalogProofCoverageResponse"];
|
|
226
445
|
};
|
|
227
446
|
};
|
|
447
|
+
/** @description Authentication required */
|
|
448
|
+
401: {
|
|
449
|
+
headers: {
|
|
450
|
+
[name: string]: unknown;
|
|
451
|
+
};
|
|
452
|
+
content: {
|
|
453
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
/** @description Insufficient entitlement (plan or role) */
|
|
457
|
+
403: {
|
|
458
|
+
headers: {
|
|
459
|
+
[name: string]: unknown;
|
|
460
|
+
};
|
|
461
|
+
content: {
|
|
462
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
463
|
+
};
|
|
464
|
+
};
|
|
228
465
|
};
|
|
229
466
|
};
|
|
230
467
|
put?: never;
|
|
@@ -697,6 +934,12 @@ interface components {
|
|
|
697
934
|
canExport: boolean;
|
|
698
935
|
};
|
|
699
936
|
};
|
|
937
|
+
ErrorResponse: {
|
|
938
|
+
error: {
|
|
939
|
+
code: string;
|
|
940
|
+
message: string;
|
|
941
|
+
};
|
|
942
|
+
};
|
|
700
943
|
CatalogItem: {
|
|
701
944
|
id: number;
|
|
702
945
|
name?: string | null;
|
|
@@ -712,9 +955,41 @@ interface components {
|
|
|
712
955
|
score_value?: number | null;
|
|
713
956
|
cost_lb?: number | null;
|
|
714
957
|
price_per_lb?: number | null;
|
|
958
|
+
price_tiers?: unknown;
|
|
715
959
|
arrival_date?: string | null;
|
|
716
960
|
stocked_date?: string | null;
|
|
717
961
|
stocked?: boolean | null;
|
|
962
|
+
wholesale?: boolean | null;
|
|
963
|
+
public_coffee?: boolean | null;
|
|
964
|
+
purveyor_score?: number | null;
|
|
965
|
+
purveyor_score_confidence?: number | null;
|
|
966
|
+
purveyor_score_tier?: string | null;
|
|
967
|
+
purveyor_score_factors?: unknown;
|
|
968
|
+
purveyor_score_version?: string | null;
|
|
969
|
+
purveyor_score_updated_at?: string | null;
|
|
970
|
+
processing_base_method?: string | null;
|
|
971
|
+
fermentation_type?: string | null;
|
|
972
|
+
process_additives?: unknown;
|
|
973
|
+
process_additive_detail?: string | null;
|
|
974
|
+
fermentation_duration_hours?: number | null;
|
|
975
|
+
processing_notes?: string | null;
|
|
976
|
+
processing_disclosure_level?: string | null;
|
|
977
|
+
processing_confidence?: number | null;
|
|
978
|
+
processing_evidence_available?: boolean | null;
|
|
979
|
+
drying_method?: string | null;
|
|
980
|
+
farm_notes?: string | null;
|
|
981
|
+
description_short?: string | null;
|
|
982
|
+
description_long?: string | null;
|
|
983
|
+
cupping_notes?: string | null;
|
|
984
|
+
roast_recs?: string | null;
|
|
985
|
+
lot_size?: string | null;
|
|
986
|
+
bag_size?: string | null;
|
|
987
|
+
packaging?: string | null;
|
|
988
|
+
link?: string | null;
|
|
989
|
+
last_updated?: string | null;
|
|
990
|
+
unstocked_date?: string | null;
|
|
991
|
+
ai_description?: string | null;
|
|
992
|
+
ai_tasting_notes?: unknown;
|
|
718
993
|
};
|
|
719
994
|
CatalogListResponse: {
|
|
720
995
|
data: components["schemas"]["CatalogItem"][];
|
|
@@ -743,10 +1018,174 @@ interface components {
|
|
|
743
1018
|
};
|
|
744
1019
|
access: {
|
|
745
1020
|
publicOnly: boolean;
|
|
1021
|
+
showWholesale: boolean;
|
|
1022
|
+
wholesaleOnly: boolean;
|
|
746
1023
|
rowLimit: number | null;
|
|
747
1024
|
limited: boolean;
|
|
748
1025
|
totalAvailable: number;
|
|
749
1026
|
};
|
|
1027
|
+
/** @description Present only when requested filters/sorts were stripped because the caller lacked the capability. The request still returns 200 with the entitled subset applied. */
|
|
1028
|
+
notices?: {
|
|
1029
|
+
status: 401 | 403;
|
|
1030
|
+
/** @enum {string} */
|
|
1031
|
+
code: "auth_required" | "entitlement_required";
|
|
1032
|
+
message: string;
|
|
1033
|
+
deniedParams: string[];
|
|
1034
|
+
}[];
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
CatalogFacetsResponse: {
|
|
1038
|
+
/** @description Compatibility-friendly unique values for dropdown filters. Keys with no values are omitted. */
|
|
1039
|
+
values: {
|
|
1040
|
+
sources?: string[];
|
|
1041
|
+
continents?: string[];
|
|
1042
|
+
countries?: string[];
|
|
1043
|
+
regions?: string[];
|
|
1044
|
+
processing?: string[];
|
|
1045
|
+
cultivar_detail?: string[];
|
|
1046
|
+
type?: string[];
|
|
1047
|
+
grade?: string[];
|
|
1048
|
+
appearance?: string[];
|
|
1049
|
+
arrivalDates?: string[];
|
|
1050
|
+
drying_method?: string[];
|
|
1051
|
+
wholesale?: string[];
|
|
1052
|
+
processing_base_method?: string[];
|
|
1053
|
+
fermentation_type?: string[];
|
|
1054
|
+
process_additives?: string[];
|
|
1055
|
+
processing_disclosure_level?: string[];
|
|
1056
|
+
};
|
|
1057
|
+
/** @description Counted facet values for CLI/agent use. Counts are computed after visibility and entitled query filters are applied. */
|
|
1058
|
+
facets: {
|
|
1059
|
+
sources?: {
|
|
1060
|
+
value: string;
|
|
1061
|
+
count: number;
|
|
1062
|
+
}[];
|
|
1063
|
+
continents?: {
|
|
1064
|
+
value: string;
|
|
1065
|
+
count: number;
|
|
1066
|
+
}[];
|
|
1067
|
+
countries?: {
|
|
1068
|
+
value: string;
|
|
1069
|
+
count: number;
|
|
1070
|
+
}[];
|
|
1071
|
+
regions?: {
|
|
1072
|
+
value: string;
|
|
1073
|
+
count: number;
|
|
1074
|
+
}[];
|
|
1075
|
+
processing?: {
|
|
1076
|
+
value: string;
|
|
1077
|
+
count: number;
|
|
1078
|
+
}[];
|
|
1079
|
+
cultivar_detail?: {
|
|
1080
|
+
value: string;
|
|
1081
|
+
count: number;
|
|
1082
|
+
}[];
|
|
1083
|
+
type?: {
|
|
1084
|
+
value: string;
|
|
1085
|
+
count: number;
|
|
1086
|
+
}[];
|
|
1087
|
+
grade?: {
|
|
1088
|
+
value: string;
|
|
1089
|
+
count: number;
|
|
1090
|
+
}[];
|
|
1091
|
+
appearance?: {
|
|
1092
|
+
value: string;
|
|
1093
|
+
count: number;
|
|
1094
|
+
}[];
|
|
1095
|
+
arrivalDates?: {
|
|
1096
|
+
value: string;
|
|
1097
|
+
count: number;
|
|
1098
|
+
}[];
|
|
1099
|
+
drying_method?: {
|
|
1100
|
+
value: string;
|
|
1101
|
+
count: number;
|
|
1102
|
+
}[];
|
|
1103
|
+
wholesale?: {
|
|
1104
|
+
value: string;
|
|
1105
|
+
count: number;
|
|
1106
|
+
}[];
|
|
1107
|
+
processing_base_method?: {
|
|
1108
|
+
value: string;
|
|
1109
|
+
count: number;
|
|
1110
|
+
}[];
|
|
1111
|
+
fermentation_type?: {
|
|
1112
|
+
value: string;
|
|
1113
|
+
count: number;
|
|
1114
|
+
}[];
|
|
1115
|
+
process_additives?: {
|
|
1116
|
+
value: string;
|
|
1117
|
+
count: number;
|
|
1118
|
+
}[];
|
|
1119
|
+
processing_disclosure_level?: {
|
|
1120
|
+
value: string;
|
|
1121
|
+
count: number;
|
|
1122
|
+
}[];
|
|
1123
|
+
};
|
|
1124
|
+
meta: {
|
|
1125
|
+
/** @enum {string} */
|
|
1126
|
+
resource: "catalog-facets";
|
|
1127
|
+
/** @enum {string} */
|
|
1128
|
+
namespace: "/v1/catalog/facets";
|
|
1129
|
+
/** @enum {string} */
|
|
1130
|
+
version: "v1";
|
|
1131
|
+
auth: {
|
|
1132
|
+
/** @enum {string} */
|
|
1133
|
+
kind: "session" | "api-key";
|
|
1134
|
+
/** @enum {string|null} */
|
|
1135
|
+
role: "viewer" | "member" | "admin" | null;
|
|
1136
|
+
/** @enum {string|null} */
|
|
1137
|
+
apiPlan: "viewer" | "member" | "enterprise" | null;
|
|
1138
|
+
};
|
|
1139
|
+
access: {
|
|
1140
|
+
publicOnly: boolean;
|
|
1141
|
+
showWholesale: boolean;
|
|
1142
|
+
wholesaleOnly: boolean;
|
|
1143
|
+
stocked: boolean | null;
|
|
1144
|
+
premiumMetadata: boolean;
|
|
1145
|
+
};
|
|
1146
|
+
notices?: {
|
|
1147
|
+
status: 401 | 403;
|
|
1148
|
+
/** @enum {string} */
|
|
1149
|
+
code: "auth_required" | "entitlement_required";
|
|
1150
|
+
message: string;
|
|
1151
|
+
deniedParams: string[];
|
|
1152
|
+
}[];
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
CatalogOriginPriceStatsResponse: {
|
|
1156
|
+
originPriceStats: {
|
|
1157
|
+
origin: string;
|
|
1158
|
+
median: number;
|
|
1159
|
+
q1: number;
|
|
1160
|
+
q3: number;
|
|
1161
|
+
min: number;
|
|
1162
|
+
max: number;
|
|
1163
|
+
sample_size: number;
|
|
1164
|
+
supplier_count: number;
|
|
1165
|
+
}[];
|
|
1166
|
+
meta: {
|
|
1167
|
+
/** @enum {string} */
|
|
1168
|
+
resource: "catalog-origin-price-stats";
|
|
1169
|
+
/** @enum {string} */
|
|
1170
|
+
namespace: "/v1/catalog/origin-price-stats";
|
|
1171
|
+
/** @enum {string} */
|
|
1172
|
+
version: "v1";
|
|
1173
|
+
auth: {
|
|
1174
|
+
/** @enum {string} */
|
|
1175
|
+
kind: "anonymous" | "session" | "api-key";
|
|
1176
|
+
/** @enum {string|null} */
|
|
1177
|
+
role: "viewer" | "member" | "admin" | null;
|
|
1178
|
+
/** @enum {string|null} */
|
|
1179
|
+
apiPlan: "viewer" | "member" | "enterprise" | null;
|
|
1180
|
+
};
|
|
1181
|
+
access: {
|
|
1182
|
+
publicOnly: boolean;
|
|
1183
|
+
showWholesale: boolean;
|
|
1184
|
+
wholesaleOnly: boolean;
|
|
1185
|
+
/** @enum {string} */
|
|
1186
|
+
scope: "retail" | "wholesale" | "all";
|
|
1187
|
+
totalAvailable: number;
|
|
1188
|
+
};
|
|
750
1189
|
};
|
|
751
1190
|
};
|
|
752
1191
|
CatalogProofCoverageResponse: {
|
|
@@ -866,12 +1305,6 @@ interface components {
|
|
|
866
1305
|
};
|
|
867
1306
|
};
|
|
868
1307
|
};
|
|
869
|
-
ErrorResponse: {
|
|
870
|
-
error: {
|
|
871
|
-
code: string;
|
|
872
|
-
message: string;
|
|
873
|
-
};
|
|
874
|
-
};
|
|
875
1308
|
CatalogSimilarityTarget: {
|
|
876
1309
|
id: number;
|
|
877
1310
|
name: string;
|
|
@@ -1243,6 +1676,19 @@ interface ParchmentClientOptions {
|
|
|
1243
1676
|
}
|
|
1244
1677
|
/** Query parameters for {@link ParchmentClient.catalog.list}. */
|
|
1245
1678
|
type CatalogListQuery = NonNullable<paths["/v1/catalog"]["get"]["parameters"]["query"]>;
|
|
1679
|
+
/** Query parameters for {@link ParchmentClient.catalog.facets}. */
|
|
1680
|
+
type CatalogFacetsQuery = NonNullable<paths["/v1/catalog/facets"]["get"]["parameters"]["query"]>;
|
|
1681
|
+
/**
|
|
1682
|
+
* Optional headers for {@link ParchmentClient.catalog.list}, notably the
|
|
1683
|
+
* RFC 7240 `Prefer: handling=lenient|strict` override (PADR-0013 §7). Sending
|
|
1684
|
+
* `handling=lenient` opts a strict caller (API key or bearer-session JWT) back
|
|
1685
|
+
* into strip-with-notice degradation instead of a 401/403 hard-deny.
|
|
1686
|
+
*/
|
|
1687
|
+
type CatalogListHeaders = NonNullable<paths["/v1/catalog"]["get"]["parameters"]["header"]>;
|
|
1688
|
+
/** Optional headers for {@link ParchmentClient.catalog.facets}; see {@link CatalogListHeaders}. */
|
|
1689
|
+
type CatalogFacetsHeaders = NonNullable<paths["/v1/catalog/facets"]["get"]["parameters"]["header"]>;
|
|
1690
|
+
/** Query parameters for {@link ParchmentClient.catalog.originPriceStats}. */
|
|
1691
|
+
type CatalogOriginPriceStatsQuery = NonNullable<paths["/v1/catalog/origin-price-stats"]["get"]["parameters"]["query"]>;
|
|
1246
1692
|
/** Query parameters for {@link ParchmentClient.catalog.similar}. */
|
|
1247
1693
|
type CatalogSimilarQuery = NonNullable<paths["/v1/catalog/{id}/similar"]["get"]["parameters"]["query"]>;
|
|
1248
1694
|
/** Query parameters for {@link ParchmentClient.priceIndex.list}. */
|
|
@@ -1343,7 +1789,7 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1343
1789
|
access: () => Promise<openapi_fetch.FetchResponse<{
|
|
1344
1790
|
parameters: {
|
|
1345
1791
|
query?: never;
|
|
1346
|
-
header
|
|
1792
|
+
header? /** Catalog capabilities and visibility for the caller. */: never;
|
|
1347
1793
|
path?: never;
|
|
1348
1794
|
cookie?: never;
|
|
1349
1795
|
};
|
|
@@ -1357,11 +1803,27 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1357
1803
|
"application/json": components["schemas"]["CatalogAccessResponse"];
|
|
1358
1804
|
};
|
|
1359
1805
|
};
|
|
1806
|
+
401: {
|
|
1807
|
+
headers: {
|
|
1808
|
+
[name: string]: unknown;
|
|
1809
|
+
};
|
|
1810
|
+
content: {
|
|
1811
|
+
"application/json": components["schemas"] /** Live catalog price context by origin. */["ErrorResponse"];
|
|
1812
|
+
};
|
|
1813
|
+
};
|
|
1814
|
+
403: {
|
|
1815
|
+
headers: {
|
|
1816
|
+
[name: string]: unknown;
|
|
1817
|
+
};
|
|
1818
|
+
content: {
|
|
1819
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1820
|
+
};
|
|
1821
|
+
};
|
|
1360
1822
|
};
|
|
1361
1823
|
}, openapi_fetch.FetchOptions<{
|
|
1362
1824
|
parameters: {
|
|
1363
1825
|
query?: never;
|
|
1364
|
-
header
|
|
1826
|
+
header? /** Catalog capabilities and visibility for the caller. */: never;
|
|
1365
1827
|
path?: never;
|
|
1366
1828
|
cookie?: never;
|
|
1367
1829
|
};
|
|
@@ -1375,10 +1837,29 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1375
1837
|
"application/json": components["schemas"]["CatalogAccessResponse"];
|
|
1376
1838
|
};
|
|
1377
1839
|
};
|
|
1840
|
+
401: {
|
|
1841
|
+
headers: {
|
|
1842
|
+
[name: string]: unknown;
|
|
1843
|
+
};
|
|
1844
|
+
content: {
|
|
1845
|
+
"application/json": components["schemas"] /** Live catalog price context by origin. */["ErrorResponse"];
|
|
1846
|
+
};
|
|
1847
|
+
};
|
|
1848
|
+
403: {
|
|
1849
|
+
headers: {
|
|
1850
|
+
[name: string]: unknown;
|
|
1851
|
+
};
|
|
1852
|
+
content: {
|
|
1853
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1854
|
+
};
|
|
1855
|
+
};
|
|
1378
1856
|
};
|
|
1379
1857
|
}> | undefined, `${string}/${string}`>>;
|
|
1380
|
-
/**
|
|
1381
|
-
|
|
1858
|
+
/**
|
|
1859
|
+
* List public catalog coffees (paginated). Pass `headers` to send the
|
|
1860
|
+
* `Prefer: handling=lenient|strict` override (see {@link CatalogListHeaders}).
|
|
1861
|
+
*/
|
|
1862
|
+
list: (query?: CatalogListQuery, headers?: CatalogListHeaders) => Promise<openapi_fetch.FetchResponse<{
|
|
1382
1863
|
parameters: {
|
|
1383
1864
|
query?: {
|
|
1384
1865
|
page?: number;
|
|
@@ -1386,8 +1867,40 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1386
1867
|
stocked?: "true" | "false" | "all";
|
|
1387
1868
|
sort?: string;
|
|
1388
1869
|
order?: "asc" | "desc";
|
|
1870
|
+
showWholesale?: "true" | "false";
|
|
1871
|
+
wholesaleOnly?: "true" | "false";
|
|
1872
|
+
origin?: string;
|
|
1873
|
+
continent?: string;
|
|
1874
|
+
country?: string | string[];
|
|
1875
|
+
region?: string;
|
|
1876
|
+
source?: string | string[];
|
|
1877
|
+
name?: string;
|
|
1878
|
+
processing?: string;
|
|
1879
|
+
variety?: string;
|
|
1880
|
+
type?: string;
|
|
1881
|
+
grade?: string;
|
|
1882
|
+
appearance?: string;
|
|
1883
|
+
supplier?: string;
|
|
1884
|
+
dryingMethod?: string;
|
|
1885
|
+
flavorKeywords?: string | string[];
|
|
1886
|
+
arrivalDate?: string;
|
|
1887
|
+
stockedDate?: string;
|
|
1888
|
+
stockedDays?: number;
|
|
1889
|
+
coffeeIds?: string;
|
|
1890
|
+
scoreValueMin?: number | null;
|
|
1891
|
+
scoreValueMax?: number | null;
|
|
1892
|
+
pricePerLbMin?: number | null;
|
|
1893
|
+
pricePerLbMax?: number | null;
|
|
1894
|
+
processing_base_method?: string;
|
|
1895
|
+
fermentation_type?: string;
|
|
1896
|
+
process_additive?: string;
|
|
1897
|
+
has_additives?: "true" | "false";
|
|
1898
|
+
processing_disclosure_level?: string;
|
|
1899
|
+
processing_confidence_min?: number | null;
|
|
1900
|
+
};
|
|
1901
|
+
header?: {
|
|
1902
|
+
Prefer?: string;
|
|
1389
1903
|
};
|
|
1390
|
-
header?: never;
|
|
1391
1904
|
path?: never;
|
|
1392
1905
|
cookie?: never;
|
|
1393
1906
|
};
|
|
@@ -1401,6 +1914,22 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1401
1914
|
"application/json": components["schemas"]["CatalogListResponse"];
|
|
1402
1915
|
};
|
|
1403
1916
|
};
|
|
1917
|
+
401: {
|
|
1918
|
+
headers: {
|
|
1919
|
+
[name: string]: unknown;
|
|
1920
|
+
};
|
|
1921
|
+
content: {
|
|
1922
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1923
|
+
};
|
|
1924
|
+
};
|
|
1925
|
+
403: {
|
|
1926
|
+
headers: {
|
|
1927
|
+
[name: string]: unknown;
|
|
1928
|
+
};
|
|
1929
|
+
content: {
|
|
1930
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1931
|
+
};
|
|
1932
|
+
};
|
|
1404
1933
|
};
|
|
1405
1934
|
}, {
|
|
1406
1935
|
params: {
|
|
@@ -1410,6 +1939,197 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1410
1939
|
stocked?: "true" | "false" | "all";
|
|
1411
1940
|
sort?: string;
|
|
1412
1941
|
order?: "asc" | "desc";
|
|
1942
|
+
showWholesale?: "true" | "false";
|
|
1943
|
+
wholesaleOnly?: "true" | "false";
|
|
1944
|
+
origin?: string;
|
|
1945
|
+
continent?: string;
|
|
1946
|
+
country?: string | string[];
|
|
1947
|
+
region?: string;
|
|
1948
|
+
source?: string | string[];
|
|
1949
|
+
name?: string;
|
|
1950
|
+
processing?: string;
|
|
1951
|
+
variety?: string;
|
|
1952
|
+
type?: string;
|
|
1953
|
+
grade?: string;
|
|
1954
|
+
appearance?: string;
|
|
1955
|
+
supplier?: string;
|
|
1956
|
+
dryingMethod?: string;
|
|
1957
|
+
flavorKeywords?: string | string[];
|
|
1958
|
+
arrivalDate?: string;
|
|
1959
|
+
stockedDate?: string;
|
|
1960
|
+
stockedDays?: number;
|
|
1961
|
+
coffeeIds?: string;
|
|
1962
|
+
scoreValueMin?: number | null;
|
|
1963
|
+
scoreValueMax?: number | null;
|
|
1964
|
+
pricePerLbMin?: number | null;
|
|
1965
|
+
pricePerLbMax?: number | null;
|
|
1966
|
+
processing_base_method?: string;
|
|
1967
|
+
fermentation_type?: string;
|
|
1968
|
+
process_additive?: string;
|
|
1969
|
+
has_additives?: "true" | "false";
|
|
1970
|
+
processing_disclosure_level?: string;
|
|
1971
|
+
processing_confidence_min?: number | null;
|
|
1972
|
+
} | undefined;
|
|
1973
|
+
header: {
|
|
1974
|
+
Prefer?: string;
|
|
1975
|
+
} | undefined;
|
|
1976
|
+
};
|
|
1977
|
+
}, `${string}/${string}`>>;
|
|
1978
|
+
/**
|
|
1979
|
+
* Catalog filter metadata and counted facets. Pass `headers` to send the
|
|
1980
|
+
* `Prefer: handling=lenient|strict` override (see {@link CatalogFacetsHeaders}).
|
|
1981
|
+
*/
|
|
1982
|
+
facets: (query?: CatalogFacetsQuery, headers?: CatalogFacetsHeaders) => Promise<openapi_fetch.FetchResponse<{
|
|
1983
|
+
parameters: {
|
|
1984
|
+
query?: {
|
|
1985
|
+
stocked?: "true" | "false" | "all";
|
|
1986
|
+
showWholesale?: "true" | "false";
|
|
1987
|
+
wholesaleOnly?: "true" | "false";
|
|
1988
|
+
origin?: string;
|
|
1989
|
+
continent?: string;
|
|
1990
|
+
country?: string | string[];
|
|
1991
|
+
region?: string;
|
|
1992
|
+
source?: string | string[];
|
|
1993
|
+
name?: string;
|
|
1994
|
+
processing?: string;
|
|
1995
|
+
variety?: string;
|
|
1996
|
+
type?: string;
|
|
1997
|
+
grade?: string;
|
|
1998
|
+
appearance?: string;
|
|
1999
|
+
supplier?: string;
|
|
2000
|
+
dryingMethod?: string;
|
|
2001
|
+
flavorKeywords?: string | string[];
|
|
2002
|
+
arrivalDate?: string;
|
|
2003
|
+
stockedDate?: string;
|
|
2004
|
+
stockedDays?: number;
|
|
2005
|
+
coffeeIds?: string | string[];
|
|
2006
|
+
scoreValueMin?: number | null;
|
|
2007
|
+
scoreValueMax?: number | null;
|
|
2008
|
+
pricePerLbMin?: number | null;
|
|
2009
|
+
pricePerLbMax?: number | null;
|
|
2010
|
+
processing_base_method?: string;
|
|
2011
|
+
fermentation_type?: string;
|
|
2012
|
+
process_additive?: string;
|
|
2013
|
+
has_additives?: "true" | "false";
|
|
2014
|
+
processing_disclosure_level?: string;
|
|
2015
|
+
processing_confidence_min?: number | null;
|
|
2016
|
+
};
|
|
2017
|
+
header?: {
|
|
2018
|
+
Prefer?: string;
|
|
2019
|
+
};
|
|
2020
|
+
path?: never;
|
|
2021
|
+
cookie?: never;
|
|
2022
|
+
};
|
|
2023
|
+
requestBody?: never;
|
|
2024
|
+
responses: {
|
|
2025
|
+
200: {
|
|
2026
|
+
headers: {
|
|
2027
|
+
[name: string]: unknown;
|
|
2028
|
+
};
|
|
2029
|
+
content: {
|
|
2030
|
+
"application/json": components["schemas"]["CatalogFacetsResponse"];
|
|
2031
|
+
};
|
|
2032
|
+
};
|
|
2033
|
+
401: {
|
|
2034
|
+
headers: {
|
|
2035
|
+
[name: string]: unknown;
|
|
2036
|
+
};
|
|
2037
|
+
content: {
|
|
2038
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2039
|
+
};
|
|
2040
|
+
};
|
|
2041
|
+
403: {
|
|
2042
|
+
headers: {
|
|
2043
|
+
[name: string]: unknown;
|
|
2044
|
+
};
|
|
2045
|
+
content: {
|
|
2046
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2047
|
+
};
|
|
2048
|
+
};
|
|
2049
|
+
};
|
|
2050
|
+
}, {
|
|
2051
|
+
params: {
|
|
2052
|
+
query: {
|
|
2053
|
+
stocked?: "true" | "false" | "all";
|
|
2054
|
+
showWholesale?: "true" | "false";
|
|
2055
|
+
wholesaleOnly?: "true" | "false";
|
|
2056
|
+
origin?: string;
|
|
2057
|
+
continent?: string;
|
|
2058
|
+
country?: string | string[];
|
|
2059
|
+
region?: string;
|
|
2060
|
+
source?: string | string[];
|
|
2061
|
+
name?: string;
|
|
2062
|
+
processing?: string;
|
|
2063
|
+
variety?: string;
|
|
2064
|
+
type?: string;
|
|
2065
|
+
grade?: string;
|
|
2066
|
+
appearance?: string;
|
|
2067
|
+
supplier?: string;
|
|
2068
|
+
dryingMethod?: string;
|
|
2069
|
+
flavorKeywords?: string | string[];
|
|
2070
|
+
arrivalDate?: string;
|
|
2071
|
+
stockedDate?: string;
|
|
2072
|
+
stockedDays?: number;
|
|
2073
|
+
coffeeIds?: string | string[];
|
|
2074
|
+
scoreValueMin?: number | null;
|
|
2075
|
+
scoreValueMax?: number | null;
|
|
2076
|
+
pricePerLbMin?: number | null;
|
|
2077
|
+
pricePerLbMax?: number | null;
|
|
2078
|
+
processing_base_method?: string;
|
|
2079
|
+
fermentation_type?: string;
|
|
2080
|
+
process_additive?: string;
|
|
2081
|
+
has_additives?: "true" | "false";
|
|
2082
|
+
processing_disclosure_level?: string;
|
|
2083
|
+
processing_confidence_min?: number | null;
|
|
2084
|
+
} | undefined;
|
|
2085
|
+
header: {
|
|
2086
|
+
Prefer?: string;
|
|
2087
|
+
} | undefined;
|
|
2088
|
+
};
|
|
2089
|
+
}, `${string}/${string}`>>;
|
|
2090
|
+
/** Live catalog price context by origin. */
|
|
2091
|
+
originPriceStats: (query?: CatalogOriginPriceStatsQuery) => Promise<openapi_fetch.FetchResponse<{
|
|
2092
|
+
parameters: {
|
|
2093
|
+
query?: {
|
|
2094
|
+
showWholesale?: "true" | "false";
|
|
2095
|
+
wholesaleOnly?: "true" | "false";
|
|
2096
|
+
};
|
|
2097
|
+
header?: never;
|
|
2098
|
+
path?: never;
|
|
2099
|
+
cookie?: never;
|
|
2100
|
+
};
|
|
2101
|
+
requestBody?: never;
|
|
2102
|
+
responses: {
|
|
2103
|
+
200: {
|
|
2104
|
+
headers: {
|
|
2105
|
+
[name: string]: unknown;
|
|
2106
|
+
};
|
|
2107
|
+
content: {
|
|
2108
|
+
"application/json": components["schemas"]["CatalogOriginPriceStatsResponse"];
|
|
2109
|
+
};
|
|
2110
|
+
};
|
|
2111
|
+
401: {
|
|
2112
|
+
headers: {
|
|
2113
|
+
[name: string]: unknown;
|
|
2114
|
+
};
|
|
2115
|
+
content: {
|
|
2116
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2117
|
+
};
|
|
2118
|
+
};
|
|
2119
|
+
403: {
|
|
2120
|
+
headers: {
|
|
2121
|
+
[name: string]: unknown;
|
|
2122
|
+
};
|
|
2123
|
+
content: {
|
|
2124
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2125
|
+
};
|
|
2126
|
+
};
|
|
2127
|
+
};
|
|
2128
|
+
}, {
|
|
2129
|
+
params: {
|
|
2130
|
+
query: {
|
|
2131
|
+
showWholesale?: "true" | "false";
|
|
2132
|
+
wholesaleOnly?: "true" | "false";
|
|
1413
2133
|
} | undefined;
|
|
1414
2134
|
};
|
|
1415
2135
|
}, `${string}/${string}`>>;
|
|
@@ -1431,6 +2151,22 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1431
2151
|
"application/json": components["schemas"]["CatalogProofCoverageResponse"];
|
|
1432
2152
|
};
|
|
1433
2153
|
};
|
|
2154
|
+
401: {
|
|
2155
|
+
headers: {
|
|
2156
|
+
[name: string]: unknown;
|
|
2157
|
+
};
|
|
2158
|
+
content: {
|
|
2159
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2160
|
+
};
|
|
2161
|
+
};
|
|
2162
|
+
403: {
|
|
2163
|
+
headers: {
|
|
2164
|
+
[name: string]: unknown;
|
|
2165
|
+
};
|
|
2166
|
+
content: {
|
|
2167
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2168
|
+
};
|
|
2169
|
+
};
|
|
1434
2170
|
};
|
|
1435
2171
|
}, openapi_fetch.FetchOptions<{
|
|
1436
2172
|
parameters: {
|
|
@@ -1449,6 +2185,22 @@ declare function createParchmentClient(options: ParchmentClientOptions): {
|
|
|
1449
2185
|
"application/json": components["schemas"]["CatalogProofCoverageResponse"];
|
|
1450
2186
|
};
|
|
1451
2187
|
};
|
|
2188
|
+
401: {
|
|
2189
|
+
headers: {
|
|
2190
|
+
[name: string]: unknown;
|
|
2191
|
+
};
|
|
2192
|
+
content: {
|
|
2193
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2194
|
+
};
|
|
2195
|
+
};
|
|
2196
|
+
403: {
|
|
2197
|
+
headers: {
|
|
2198
|
+
[name: string]: unknown;
|
|
2199
|
+
};
|
|
2200
|
+
content: {
|
|
2201
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
2202
|
+
};
|
|
2203
|
+
};
|
|
1452
2204
|
};
|
|
1453
2205
|
}> | undefined, `${string}/${string}`>>;
|
|
1454
2206
|
/** Find catalog coffees similar to a target coffee. */
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,20 @@ function createParchmentClient(options) {
|
|
|
17
17
|
catalog: {
|
|
18
18
|
/** Catalog capabilities and visibility for the caller. */
|
|
19
19
|
access: () => client.GET("/v1/catalog/access"),
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* List public catalog coffees (paginated). Pass `headers` to send the
|
|
22
|
+
* `Prefer: handling=lenient|strict` override (see {@link CatalogListHeaders}).
|
|
23
|
+
*/
|
|
24
|
+
list: (query, headers) => client.GET("/v1/catalog", { params: { query, header: headers } }),
|
|
25
|
+
/**
|
|
26
|
+
* Catalog filter metadata and counted facets. Pass `headers` to send the
|
|
27
|
+
* `Prefer: handling=lenient|strict` override (see {@link CatalogFacetsHeaders}).
|
|
28
|
+
*/
|
|
29
|
+
facets: (query, headers) => client.GET("/v1/catalog/facets", {
|
|
30
|
+
params: { query, header: headers }
|
|
31
|
+
}),
|
|
32
|
+
/** Live catalog price context by origin. */
|
|
33
|
+
originPriceStats: (query) => client.GET("/v1/catalog/origin-price-stats", { params: { query } }),
|
|
22
34
|
/** Aggregate proof-coverage over the public catalog. */
|
|
23
35
|
proofCoverage: () => client.GET("/v1/catalog/proof-coverage"),
|
|
24
36
|
/** Find catalog coffees similar to a target coffee. */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient, { type ClientOptions } from \"openapi-fetch\";\nimport type { components, paths } from \"./schema\";\n\nexport interface ParchmentClientOptions {\n /** Base URL of the Parchment API, e.g. https://api.purveyors.io */\n baseUrl: string;\n /**\n * Optional bearer token (a Supabase JWT or, later, an API key). Sent as\n * `Authorization: Bearer <token>`. Auth is resolved server-side against the\n * unified principal model; the SDK only forwards the credential.\n */\n token?: string;\n /** Override the fetch implementation (useful for tests or custom runtimes). */\n fetch?: ClientOptions[\"fetch\"];\n}\n\n/** Query parameters for {@link ParchmentClient.catalog.list}. */\nexport type CatalogListQuery = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.similar}. */\nexport type CatalogSimilarQuery = NonNullable<\n paths[\"/v1/catalog/{id}/similar\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.priceIndex.list}. */\nexport type PriceIndexQuery = NonNullable<\n paths[\"/v1/price-index\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.procurement.briefs.matches}. */\nexport type BriefMatchesQuery = NonNullable<\n paths[\"/v1/procurement/briefs/{id}/matches\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.procurement.briefs.create}. */\nexport type SourcingBriefCreateRequest =\n components[\"schemas\"][\"SourcingBriefCreateRequest\"];\n\n/**\n * Create a typed Parchment API client.\n *\n * The generated core (openapi-fetch over the generated `paths` types) is the\n * contract truth; the named helpers below are the hand-maintained ergonomic\n * layer and grow as endpoints land. `raw` always exposes the underlying typed\n * client for direct path access to anything not yet wrapped.\n */\nexport function createParchmentClient(options: ParchmentClientOptions) {\n const { baseUrl, token, fetch: fetchImpl } = options;\n\n const client = createClient<paths>({\n baseUrl,\n fetch: fetchImpl,\n headers: token ? { Authorization: `Bearer ${token}` } : undefined,\n });\n\n return {\n /** The underlying typed openapi-fetch client for direct path access. */\n raw: client,\n /** Liveness and service identity. */\n health: () => client.GET(\"/health\"),\n /** Resolved principal and entitlements for the caller. */\n me: () => client.GET(\"/v1/me\"),\n catalog: {\n /** Catalog capabilities and visibility for the caller. */\n access: () => client.GET(\"/v1/catalog/access\"),\n
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import createClient, { type ClientOptions } from \"openapi-fetch\";\nimport type { components, paths } from \"./schema\";\n\nexport interface ParchmentClientOptions {\n /** Base URL of the Parchment API, e.g. https://api.purveyors.io */\n baseUrl: string;\n /**\n * Optional bearer token (a Supabase JWT or, later, an API key). Sent as\n * `Authorization: Bearer <token>`. Auth is resolved server-side against the\n * unified principal model; the SDK only forwards the credential.\n */\n token?: string;\n /** Override the fetch implementation (useful for tests or custom runtimes). */\n fetch?: ClientOptions[\"fetch\"];\n}\n\n/** Query parameters for {@link ParchmentClient.catalog.list}. */\nexport type CatalogListQuery = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.facets}. */\nexport type CatalogFacetsQuery = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/**\n * Optional headers for {@link ParchmentClient.catalog.list}, notably the\n * RFC 7240 `Prefer: handling=lenient|strict` override (PADR-0013 §7). Sending\n * `handling=lenient` opts a strict caller (API key or bearer-session JWT) back\n * into strip-with-notice degradation instead of a 401/403 hard-deny.\n */\nexport type CatalogListHeaders = NonNullable<\n paths[\"/v1/catalog\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Optional headers for {@link ParchmentClient.catalog.facets}; see {@link CatalogListHeaders}. */\nexport type CatalogFacetsHeaders = NonNullable<\n paths[\"/v1/catalog/facets\"][\"get\"][\"parameters\"][\"header\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.originPriceStats}. */\nexport type CatalogOriginPriceStatsQuery = NonNullable<\n paths[\"/v1/catalog/origin-price-stats\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.catalog.similar}. */\nexport type CatalogSimilarQuery = NonNullable<\n paths[\"/v1/catalog/{id}/similar\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.priceIndex.list}. */\nexport type PriceIndexQuery = NonNullable<\n paths[\"/v1/price-index\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Query parameters for {@link ParchmentClient.procurement.briefs.matches}. */\nexport type BriefMatchesQuery = NonNullable<\n paths[\"/v1/procurement/briefs/{id}/matches\"][\"get\"][\"parameters\"][\"query\"]\n>;\n/** Request body for {@link ParchmentClient.procurement.briefs.create}. */\nexport type SourcingBriefCreateRequest =\n components[\"schemas\"][\"SourcingBriefCreateRequest\"];\n\n/**\n * Create a typed Parchment API client.\n *\n * The generated core (openapi-fetch over the generated `paths` types) is the\n * contract truth; the named helpers below are the hand-maintained ergonomic\n * layer and grow as endpoints land. `raw` always exposes the underlying typed\n * client for direct path access to anything not yet wrapped.\n */\nexport function createParchmentClient(options: ParchmentClientOptions) {\n const { baseUrl, token, fetch: fetchImpl } = options;\n\n const client = createClient<paths>({\n baseUrl,\n fetch: fetchImpl,\n headers: token ? { Authorization: `Bearer ${token}` } : undefined,\n });\n\n return {\n /** The underlying typed openapi-fetch client for direct path access. */\n raw: client,\n /** Liveness and service identity. */\n health: () => client.GET(\"/health\"),\n /** Resolved principal and entitlements for the caller. */\n me: () => client.GET(\"/v1/me\"),\n catalog: {\n /** Catalog capabilities and visibility for the caller. */\n access: () => client.GET(\"/v1/catalog/access\"),\n /**\n * List public catalog coffees (paginated). Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogListHeaders}).\n */\n list: (query?: CatalogListQuery, headers?: CatalogListHeaders) =>\n client.GET(\"/v1/catalog\", { params: { query, header: headers } }),\n /**\n * Catalog filter metadata and counted facets. Pass `headers` to send the\n * `Prefer: handling=lenient|strict` override (see {@link CatalogFacetsHeaders}).\n */\n facets: (query?: CatalogFacetsQuery, headers?: CatalogFacetsHeaders) =>\n client.GET(\"/v1/catalog/facets\", {\n params: { query, header: headers },\n }),\n /** Live catalog price context by origin. */\n originPriceStats: (query?: CatalogOriginPriceStatsQuery) =>\n client.GET(\"/v1/catalog/origin-price-stats\", { params: { query } }),\n /** Aggregate proof-coverage over the public catalog. */\n proofCoverage: () => client.GET(\"/v1/catalog/proof-coverage\"),\n /** Find catalog coffees similar to a target coffee. */\n similar: (id: string, query?: CatalogSimilarQuery) =>\n client.GET(\"/v1/catalog/{id}/similar\", {\n params: { path: { id }, query },\n }),\n },\n priceIndex: {\n /** Parchment Price Index (aggregate snapshots). */\n list: (query?: PriceIndexQuery) =>\n client.GET(\"/v1/price-index\", { params: { query } }),\n },\n procurement: {\n briefs: {\n /** List the caller's saved sourcing briefs. */\n list: () => client.GET(\"/v1/procurement/briefs\"),\n /** Create a saved sourcing brief. */\n create: (body: SourcingBriefCreateRequest) =>\n client.POST(\"/v1/procurement/briefs\", { body }),\n /** Fetch one of the caller's sourcing briefs by id. */\n get: (id: string) =>\n client.GET(\"/v1/procurement/briefs/{id}\", {\n params: { path: { id } },\n }),\n /** Run a saved brief against the catalog (paginated matches). */\n matches: (id: string, query?: BriefMatchesQuery) =>\n client.GET(\"/v1/procurement/briefs/{id}/matches\", {\n params: { path: { id }, query },\n }),\n },\n },\n };\n}\n\nexport type ParchmentClient = ReturnType<typeof createParchmentClient>;\n"],"mappings":";AAAA,OAAO,kBAA0C;AAiE1C,SAAS,sBAAsB,SAAiC;AACrE,QAAM,EAAE,SAAS,OAAO,OAAO,UAAU,IAAI;AAE7C,QAAM,SAAS,aAAoB;AAAA,IACjC;AAAA,IACA,OAAO;AAAA,IACP,SAAS,QAAQ,EAAE,eAAe,UAAU,KAAK,GAAG,IAAI;AAAA,EAC1D,CAAC;AAED,SAAO;AAAA;AAAA,IAEL,KAAK;AAAA;AAAA,IAEL,QAAQ,MAAM,OAAO,IAAI,SAAS;AAAA;AAAA,IAElC,IAAI,MAAM,OAAO,IAAI,QAAQ;AAAA,IAC7B,SAAS;AAAA;AAAA,MAEP,QAAQ,MAAM,OAAO,IAAI,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,MAK7C,MAAM,CAAC,OAA0B,YAC/B,OAAO,IAAI,eAAe,EAAE,QAAQ,EAAE,OAAO,QAAQ,QAAQ,EAAE,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,MAKlE,QAAQ,CAAC,OAA4B,YACnC,OAAO,IAAI,sBAAsB;AAAA,QAC/B,QAAQ,EAAE,OAAO,QAAQ,QAAQ;AAAA,MACnC,CAAC;AAAA;AAAA,MAEH,kBAAkB,CAAC,UACjB,OAAO,IAAI,kCAAkC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAAA;AAAA,MAEpE,eAAe,MAAM,OAAO,IAAI,4BAA4B;AAAA;AAAA,MAE5D,SAAS,CAAC,IAAY,UACpB,OAAO,IAAI,4BAA4B;AAAA,QACrC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM;AAAA,MAChC,CAAC;AAAA,IACL;AAAA,IACA,YAAY;AAAA;AAAA,MAEV,MAAM,CAAC,UACL,OAAO,IAAI,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAAA,IACvD;AAAA,IACA,aAAa;AAAA,MACX,QAAQ;AAAA;AAAA,QAEN,MAAM,MAAM,OAAO,IAAI,wBAAwB;AAAA;AAAA,QAE/C,QAAQ,CAAC,SACP,OAAO,KAAK,0BAA0B,EAAE,KAAK,CAAC;AAAA;AAAA,QAEhD,KAAK,CAAC,OACJ,OAAO,IAAI,+BAA+B;AAAA,UACxC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE;AAAA,QACzB,CAAC;AAAA;AAAA,QAEH,SAAS,CAAC,IAAY,UACpB,OAAO,IAAI,uCAAuC;AAAA,UAChD,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM;AAAA,QAChC,CAAC;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|