@takeshape/purchase-order-chat 1.51.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +305 -0
- package/dist/pdf-CYwqEJpJ.js +20562 -0
- package/dist/pdf-CYwqEJpJ.js.map +1 -0
- package/dist/pdf.worker-eoyvlo7V.js +37634 -0
- package/dist/pdf.worker-eoyvlo7V.js.map +1 -0
- package/dist/purchase-order-chat-wrapper-D8d5NFc9.js +7899 -0
- package/dist/purchase-order-chat-wrapper-D8d5NFc9.js.map +1 -0
- package/dist/shadow.d.ts +1505 -0
- package/dist/shadow.js +58 -0
- package/dist/shadow.js.map +1 -0
- package/dist/sources.css +4 -0
- package/dist/tailwind.d.ts +1502 -0
- package/dist/tailwind.js +15 -0
- package/dist/tailwind.js.map +1 -0
- package/dist/testing.d.ts +456 -0
- package/dist/testing.js +610 -0
- package/dist/testing.js.map +1 -0
- package/dist/theme.css +75 -0
- package/dist/utilities.css +233 -0
- package/package.json +87 -0
|
@@ -0,0 +1,1502 @@
|
|
|
1
|
+
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { RequestOptions } from 'graphql-request';
|
|
4
|
+
import { ResultOf } from 'gql.tada';
|
|
5
|
+
import { TadaDocumentNode } from 'gql.tada';
|
|
6
|
+
import { Variables } from 'graphql-request';
|
|
7
|
+
|
|
8
|
+
declare class B2BClient {
|
|
9
|
+
private b2bToken;
|
|
10
|
+
private companyId;
|
|
11
|
+
private channelId;
|
|
12
|
+
private graphQLClient;
|
|
13
|
+
private getB2BJwt;
|
|
14
|
+
readonly initPromise: Promise<void>;
|
|
15
|
+
constructor(config: B2BClientConfig);
|
|
16
|
+
get isAvailable(): boolean;
|
|
17
|
+
private init;
|
|
18
|
+
/**
|
|
19
|
+
* Execute a request with retry logic (up to 5 attempts with exponential backoff)
|
|
20
|
+
*/
|
|
21
|
+
private request;
|
|
22
|
+
private getB2BStorefrontToken;
|
|
23
|
+
private getB2BCompanyId;
|
|
24
|
+
getCompanyAddresses(): Promise<CustomerAddress[]>;
|
|
25
|
+
createCartRedirectUrls(cartId: string): Promise<{
|
|
26
|
+
redirectedCheckoutUrl: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare interface B2BClientConfig {
|
|
31
|
+
channelId: number;
|
|
32
|
+
/** Optional B2B JWT fetcher. Receives channelId and returns a B2B storefront token. If not provided, B2B features are disabled. */
|
|
33
|
+
getB2BJwt?: (channelId: number) => Promise<string | null>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare class BigCommerceClient {
|
|
37
|
+
private endpoint;
|
|
38
|
+
private storefrontToken;
|
|
39
|
+
private graphQLClient;
|
|
40
|
+
private isProcessing;
|
|
41
|
+
private requestQueue;
|
|
42
|
+
readonly channelId: number;
|
|
43
|
+
constructor(config: BigCommerceConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Execute a request with retry logic (up to 5 attempts with exponential backoff)
|
|
46
|
+
*/
|
|
47
|
+
private executeWithRetry;
|
|
48
|
+
/**
|
|
49
|
+
* Process the next request in the queue
|
|
50
|
+
*/
|
|
51
|
+
private processNextInQueue;
|
|
52
|
+
request<const R, V extends Variables | undefined>(options: TadaRequestOptions<R, V>): Promise<R>;
|
|
53
|
+
/**
|
|
54
|
+
* Get an existing cart by ID
|
|
55
|
+
*/
|
|
56
|
+
getCart(cartEntityId?: string): Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
entityId: string;
|
|
59
|
+
lineItems: {
|
|
60
|
+
physicalItems: {
|
|
61
|
+
entityId: string;
|
|
62
|
+
productEntityId: number;
|
|
63
|
+
variantEntityId: number | null;
|
|
64
|
+
quantity: number;
|
|
65
|
+
name: string;
|
|
66
|
+
sku: string | null;
|
|
67
|
+
originalPrice: {
|
|
68
|
+
value: number;
|
|
69
|
+
currencyCode: string;
|
|
70
|
+
};
|
|
71
|
+
listPrice: {
|
|
72
|
+
value: number;
|
|
73
|
+
currencyCode: string;
|
|
74
|
+
};
|
|
75
|
+
extendedListPrice: {
|
|
76
|
+
value: number;
|
|
77
|
+
currencyCode: string;
|
|
78
|
+
};
|
|
79
|
+
extendedSalePrice: {
|
|
80
|
+
value: number;
|
|
81
|
+
currencyCode: string;
|
|
82
|
+
};
|
|
83
|
+
imageUrl: string | null;
|
|
84
|
+
}[];
|
|
85
|
+
digitalItems: {
|
|
86
|
+
entityId: string;
|
|
87
|
+
productEntityId: number;
|
|
88
|
+
variantEntityId: number | null;
|
|
89
|
+
quantity: number;
|
|
90
|
+
name: string;
|
|
91
|
+
sku: string | null;
|
|
92
|
+
originalPrice: {
|
|
93
|
+
value: number;
|
|
94
|
+
currencyCode: string;
|
|
95
|
+
};
|
|
96
|
+
listPrice: {
|
|
97
|
+
value: number;
|
|
98
|
+
currencyCode: string;
|
|
99
|
+
};
|
|
100
|
+
extendedListPrice: {
|
|
101
|
+
value: number;
|
|
102
|
+
currencyCode: string;
|
|
103
|
+
};
|
|
104
|
+
extendedSalePrice: {
|
|
105
|
+
value: number;
|
|
106
|
+
currencyCode: string;
|
|
107
|
+
};
|
|
108
|
+
imageUrl: string | null;
|
|
109
|
+
}[];
|
|
110
|
+
};
|
|
111
|
+
amount: {
|
|
112
|
+
value: number;
|
|
113
|
+
currencyCode: string;
|
|
114
|
+
};
|
|
115
|
+
baseAmount: {
|
|
116
|
+
value: number;
|
|
117
|
+
currencyCode: string;
|
|
118
|
+
};
|
|
119
|
+
discountedAmount: {
|
|
120
|
+
value: number;
|
|
121
|
+
currencyCode: string;
|
|
122
|
+
};
|
|
123
|
+
createdAt: {
|
|
124
|
+
utc: string;
|
|
125
|
+
};
|
|
126
|
+
updatedAt: {
|
|
127
|
+
utc: string;
|
|
128
|
+
};
|
|
129
|
+
} | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Create a new cart with line items
|
|
132
|
+
* Batches items if more than CART_BATCH_SIZE
|
|
133
|
+
*/
|
|
134
|
+
createCart(lineItems: CartLineItemInput[]): Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
entityId: string;
|
|
137
|
+
lineItems: {
|
|
138
|
+
physicalItems: {
|
|
139
|
+
entityId: string;
|
|
140
|
+
productEntityId: number;
|
|
141
|
+
variantEntityId: number | null;
|
|
142
|
+
quantity: number;
|
|
143
|
+
name: string;
|
|
144
|
+
sku: string | null;
|
|
145
|
+
originalPrice: {
|
|
146
|
+
value: number;
|
|
147
|
+
currencyCode: string;
|
|
148
|
+
};
|
|
149
|
+
listPrice: {
|
|
150
|
+
value: number;
|
|
151
|
+
currencyCode: string;
|
|
152
|
+
};
|
|
153
|
+
extendedListPrice: {
|
|
154
|
+
value: number;
|
|
155
|
+
currencyCode: string;
|
|
156
|
+
};
|
|
157
|
+
extendedSalePrice: {
|
|
158
|
+
value: number;
|
|
159
|
+
currencyCode: string;
|
|
160
|
+
};
|
|
161
|
+
imageUrl: string | null;
|
|
162
|
+
}[];
|
|
163
|
+
digitalItems: {
|
|
164
|
+
entityId: string;
|
|
165
|
+
productEntityId: number;
|
|
166
|
+
variantEntityId: number | null;
|
|
167
|
+
quantity: number;
|
|
168
|
+
name: string;
|
|
169
|
+
sku: string | null;
|
|
170
|
+
originalPrice: {
|
|
171
|
+
value: number;
|
|
172
|
+
currencyCode: string;
|
|
173
|
+
};
|
|
174
|
+
listPrice: {
|
|
175
|
+
value: number;
|
|
176
|
+
currencyCode: string;
|
|
177
|
+
};
|
|
178
|
+
extendedListPrice: {
|
|
179
|
+
value: number;
|
|
180
|
+
currencyCode: string;
|
|
181
|
+
};
|
|
182
|
+
extendedSalePrice: {
|
|
183
|
+
value: number;
|
|
184
|
+
currencyCode: string;
|
|
185
|
+
};
|
|
186
|
+
imageUrl: string | null;
|
|
187
|
+
}[];
|
|
188
|
+
};
|
|
189
|
+
amount: {
|
|
190
|
+
value: number;
|
|
191
|
+
currencyCode: string;
|
|
192
|
+
};
|
|
193
|
+
baseAmount: {
|
|
194
|
+
value: number;
|
|
195
|
+
currencyCode: string;
|
|
196
|
+
};
|
|
197
|
+
discountedAmount: {
|
|
198
|
+
value: number;
|
|
199
|
+
currencyCode: string;
|
|
200
|
+
};
|
|
201
|
+
createdAt: {
|
|
202
|
+
utc: string;
|
|
203
|
+
};
|
|
204
|
+
updatedAt: {
|
|
205
|
+
utc: string;
|
|
206
|
+
};
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Add a single batch of line items to a cart
|
|
210
|
+
* Returns the updated cart or null if the operation failed
|
|
211
|
+
*/
|
|
212
|
+
private addBatchToCart;
|
|
213
|
+
/**
|
|
214
|
+
* Add line items to an existing cart
|
|
215
|
+
* Batches items if more than CART_BATCH_SIZE
|
|
216
|
+
*/
|
|
217
|
+
addCartLineItems(cartEntityId: string, lineItems: CartLineItemInput[]): Promise<{
|
|
218
|
+
id: string;
|
|
219
|
+
entityId: string;
|
|
220
|
+
lineItems: {
|
|
221
|
+
physicalItems: {
|
|
222
|
+
entityId: string;
|
|
223
|
+
productEntityId: number;
|
|
224
|
+
variantEntityId: number | null;
|
|
225
|
+
quantity: number;
|
|
226
|
+
name: string;
|
|
227
|
+
sku: string | null;
|
|
228
|
+
originalPrice: {
|
|
229
|
+
value: number;
|
|
230
|
+
currencyCode: string;
|
|
231
|
+
};
|
|
232
|
+
listPrice: {
|
|
233
|
+
value: number;
|
|
234
|
+
currencyCode: string;
|
|
235
|
+
};
|
|
236
|
+
extendedListPrice: {
|
|
237
|
+
value: number;
|
|
238
|
+
currencyCode: string;
|
|
239
|
+
};
|
|
240
|
+
extendedSalePrice: {
|
|
241
|
+
value: number;
|
|
242
|
+
currencyCode: string;
|
|
243
|
+
};
|
|
244
|
+
imageUrl: string | null;
|
|
245
|
+
}[];
|
|
246
|
+
digitalItems: {
|
|
247
|
+
entityId: string;
|
|
248
|
+
productEntityId: number;
|
|
249
|
+
variantEntityId: number | null;
|
|
250
|
+
quantity: number;
|
|
251
|
+
name: string;
|
|
252
|
+
sku: string | null;
|
|
253
|
+
originalPrice: {
|
|
254
|
+
value: number;
|
|
255
|
+
currencyCode: string;
|
|
256
|
+
};
|
|
257
|
+
listPrice: {
|
|
258
|
+
value: number;
|
|
259
|
+
currencyCode: string;
|
|
260
|
+
};
|
|
261
|
+
extendedListPrice: {
|
|
262
|
+
value: number;
|
|
263
|
+
currencyCode: string;
|
|
264
|
+
};
|
|
265
|
+
extendedSalePrice: {
|
|
266
|
+
value: number;
|
|
267
|
+
currencyCode: string;
|
|
268
|
+
};
|
|
269
|
+
imageUrl: string | null;
|
|
270
|
+
}[];
|
|
271
|
+
};
|
|
272
|
+
amount: {
|
|
273
|
+
value: number;
|
|
274
|
+
currencyCode: string;
|
|
275
|
+
};
|
|
276
|
+
baseAmount: {
|
|
277
|
+
value: number;
|
|
278
|
+
currencyCode: string;
|
|
279
|
+
};
|
|
280
|
+
discountedAmount: {
|
|
281
|
+
value: number;
|
|
282
|
+
currencyCode: string;
|
|
283
|
+
};
|
|
284
|
+
createdAt: {
|
|
285
|
+
utc: string;
|
|
286
|
+
};
|
|
287
|
+
updatedAt: {
|
|
288
|
+
utc: string;
|
|
289
|
+
};
|
|
290
|
+
} | null>;
|
|
291
|
+
/**
|
|
292
|
+
* Update the quantity of a cart line item
|
|
293
|
+
*/
|
|
294
|
+
updateCartLineItem(cartEntityId: string, lineItemEntityId: string, quantity: number, productEntityId: number, variantEntityId?: number): Promise<{
|
|
295
|
+
id: string;
|
|
296
|
+
entityId: string;
|
|
297
|
+
lineItems: {
|
|
298
|
+
physicalItems: {
|
|
299
|
+
entityId: string;
|
|
300
|
+
productEntityId: number;
|
|
301
|
+
variantEntityId: number | null;
|
|
302
|
+
quantity: number;
|
|
303
|
+
name: string;
|
|
304
|
+
sku: string | null;
|
|
305
|
+
originalPrice: {
|
|
306
|
+
value: number;
|
|
307
|
+
currencyCode: string;
|
|
308
|
+
};
|
|
309
|
+
listPrice: {
|
|
310
|
+
value: number;
|
|
311
|
+
currencyCode: string;
|
|
312
|
+
};
|
|
313
|
+
extendedListPrice: {
|
|
314
|
+
value: number;
|
|
315
|
+
currencyCode: string;
|
|
316
|
+
};
|
|
317
|
+
extendedSalePrice: {
|
|
318
|
+
value: number;
|
|
319
|
+
currencyCode: string;
|
|
320
|
+
};
|
|
321
|
+
imageUrl: string | null;
|
|
322
|
+
}[];
|
|
323
|
+
digitalItems: {
|
|
324
|
+
entityId: string;
|
|
325
|
+
productEntityId: number;
|
|
326
|
+
variantEntityId: number | null;
|
|
327
|
+
quantity: number;
|
|
328
|
+
name: string;
|
|
329
|
+
sku: string | null;
|
|
330
|
+
originalPrice: {
|
|
331
|
+
value: number;
|
|
332
|
+
currencyCode: string;
|
|
333
|
+
};
|
|
334
|
+
listPrice: {
|
|
335
|
+
value: number;
|
|
336
|
+
currencyCode: string;
|
|
337
|
+
};
|
|
338
|
+
extendedListPrice: {
|
|
339
|
+
value: number;
|
|
340
|
+
currencyCode: string;
|
|
341
|
+
};
|
|
342
|
+
extendedSalePrice: {
|
|
343
|
+
value: number;
|
|
344
|
+
currencyCode: string;
|
|
345
|
+
};
|
|
346
|
+
imageUrl: string | null;
|
|
347
|
+
}[];
|
|
348
|
+
};
|
|
349
|
+
amount: {
|
|
350
|
+
value: number;
|
|
351
|
+
currencyCode: string;
|
|
352
|
+
};
|
|
353
|
+
baseAmount: {
|
|
354
|
+
value: number;
|
|
355
|
+
currencyCode: string;
|
|
356
|
+
};
|
|
357
|
+
discountedAmount: {
|
|
358
|
+
value: number;
|
|
359
|
+
currencyCode: string;
|
|
360
|
+
};
|
|
361
|
+
createdAt: {
|
|
362
|
+
utc: string;
|
|
363
|
+
};
|
|
364
|
+
updatedAt: {
|
|
365
|
+
utc: string;
|
|
366
|
+
};
|
|
367
|
+
} | null>;
|
|
368
|
+
/**
|
|
369
|
+
* Remove a line item from the cart
|
|
370
|
+
*/
|
|
371
|
+
deleteCartLineItem(cartEntityId: string, lineItemEntityId: string): Promise<{
|
|
372
|
+
id: string;
|
|
373
|
+
entityId: string;
|
|
374
|
+
lineItems: {
|
|
375
|
+
physicalItems: {
|
|
376
|
+
entityId: string;
|
|
377
|
+
productEntityId: number;
|
|
378
|
+
variantEntityId: number | null;
|
|
379
|
+
quantity: number;
|
|
380
|
+
name: string;
|
|
381
|
+
sku: string | null;
|
|
382
|
+
originalPrice: {
|
|
383
|
+
value: number;
|
|
384
|
+
currencyCode: string;
|
|
385
|
+
};
|
|
386
|
+
listPrice: {
|
|
387
|
+
value: number;
|
|
388
|
+
currencyCode: string;
|
|
389
|
+
};
|
|
390
|
+
extendedListPrice: {
|
|
391
|
+
value: number;
|
|
392
|
+
currencyCode: string;
|
|
393
|
+
};
|
|
394
|
+
extendedSalePrice: {
|
|
395
|
+
value: number;
|
|
396
|
+
currencyCode: string;
|
|
397
|
+
};
|
|
398
|
+
imageUrl: string | null;
|
|
399
|
+
}[];
|
|
400
|
+
digitalItems: {
|
|
401
|
+
entityId: string;
|
|
402
|
+
productEntityId: number;
|
|
403
|
+
variantEntityId: number | null;
|
|
404
|
+
quantity: number;
|
|
405
|
+
name: string;
|
|
406
|
+
sku: string | null;
|
|
407
|
+
originalPrice: {
|
|
408
|
+
value: number;
|
|
409
|
+
currencyCode: string;
|
|
410
|
+
};
|
|
411
|
+
listPrice: {
|
|
412
|
+
value: number;
|
|
413
|
+
currencyCode: string;
|
|
414
|
+
};
|
|
415
|
+
extendedListPrice: {
|
|
416
|
+
value: number;
|
|
417
|
+
currencyCode: string;
|
|
418
|
+
};
|
|
419
|
+
extendedSalePrice: {
|
|
420
|
+
value: number;
|
|
421
|
+
currencyCode: string;
|
|
422
|
+
};
|
|
423
|
+
imageUrl: string | null;
|
|
424
|
+
}[];
|
|
425
|
+
};
|
|
426
|
+
amount: {
|
|
427
|
+
value: number;
|
|
428
|
+
currencyCode: string;
|
|
429
|
+
};
|
|
430
|
+
baseAmount: {
|
|
431
|
+
value: number;
|
|
432
|
+
currencyCode: string;
|
|
433
|
+
};
|
|
434
|
+
discountedAmount: {
|
|
435
|
+
value: number;
|
|
436
|
+
currencyCode: string;
|
|
437
|
+
};
|
|
438
|
+
createdAt: {
|
|
439
|
+
utc: string;
|
|
440
|
+
};
|
|
441
|
+
updatedAt: {
|
|
442
|
+
utc: string;
|
|
443
|
+
};
|
|
444
|
+
} | null>;
|
|
445
|
+
/**
|
|
446
|
+
* Delete an entire cart
|
|
447
|
+
*/
|
|
448
|
+
deleteCart(cartEntityId: string): Promise<string | null>;
|
|
449
|
+
/**
|
|
450
|
+
* Create a cart or add to existing cart
|
|
451
|
+
* Convenience method that handles both cases
|
|
452
|
+
*/
|
|
453
|
+
addToCart(lineItems: CartLineItemInput[], existingCartId?: string): Promise<{
|
|
454
|
+
id: string;
|
|
455
|
+
entityId: string;
|
|
456
|
+
lineItems: {
|
|
457
|
+
physicalItems: {
|
|
458
|
+
entityId: string;
|
|
459
|
+
productEntityId: number;
|
|
460
|
+
variantEntityId: number | null;
|
|
461
|
+
quantity: number;
|
|
462
|
+
name: string;
|
|
463
|
+
sku: string | null;
|
|
464
|
+
originalPrice: {
|
|
465
|
+
value: number;
|
|
466
|
+
currencyCode: string;
|
|
467
|
+
};
|
|
468
|
+
listPrice: {
|
|
469
|
+
value: number;
|
|
470
|
+
currencyCode: string;
|
|
471
|
+
};
|
|
472
|
+
extendedListPrice: {
|
|
473
|
+
value: number;
|
|
474
|
+
currencyCode: string;
|
|
475
|
+
};
|
|
476
|
+
extendedSalePrice: {
|
|
477
|
+
value: number;
|
|
478
|
+
currencyCode: string;
|
|
479
|
+
};
|
|
480
|
+
imageUrl: string | null;
|
|
481
|
+
}[];
|
|
482
|
+
digitalItems: {
|
|
483
|
+
entityId: string;
|
|
484
|
+
productEntityId: number;
|
|
485
|
+
variantEntityId: number | null;
|
|
486
|
+
quantity: number;
|
|
487
|
+
name: string;
|
|
488
|
+
sku: string | null;
|
|
489
|
+
originalPrice: {
|
|
490
|
+
value: number;
|
|
491
|
+
currencyCode: string;
|
|
492
|
+
};
|
|
493
|
+
listPrice: {
|
|
494
|
+
value: number;
|
|
495
|
+
currencyCode: string;
|
|
496
|
+
};
|
|
497
|
+
extendedListPrice: {
|
|
498
|
+
value: number;
|
|
499
|
+
currencyCode: string;
|
|
500
|
+
};
|
|
501
|
+
extendedSalePrice: {
|
|
502
|
+
value: number;
|
|
503
|
+
currencyCode: string;
|
|
504
|
+
};
|
|
505
|
+
imageUrl: string | null;
|
|
506
|
+
}[];
|
|
507
|
+
};
|
|
508
|
+
amount: {
|
|
509
|
+
value: number;
|
|
510
|
+
currencyCode: string;
|
|
511
|
+
};
|
|
512
|
+
baseAmount: {
|
|
513
|
+
value: number;
|
|
514
|
+
currencyCode: string;
|
|
515
|
+
};
|
|
516
|
+
discountedAmount: {
|
|
517
|
+
value: number;
|
|
518
|
+
currencyCode: string;
|
|
519
|
+
};
|
|
520
|
+
createdAt: {
|
|
521
|
+
utc: string;
|
|
522
|
+
};
|
|
523
|
+
updatedAt: {
|
|
524
|
+
utc: string;
|
|
525
|
+
};
|
|
526
|
+
} | null>;
|
|
527
|
+
/**
|
|
528
|
+
* Create single-use redirect URLs for a cart
|
|
529
|
+
* URLs should be generated just-in-time (within 30s of use)
|
|
530
|
+
*/
|
|
531
|
+
createCartRedirectUrls(cartEntityId: string): Promise<CartRedirectUrls | null>;
|
|
532
|
+
/**
|
|
533
|
+
* Create a metafield on a cart
|
|
534
|
+
*/
|
|
535
|
+
createCartMetafield(cartEntityId: string, key: string, value: string): Promise<void>;
|
|
536
|
+
/**
|
|
537
|
+
* Get checkout by entity ID
|
|
538
|
+
* Checkouts are automatically created when a cart is created
|
|
539
|
+
*/
|
|
540
|
+
getCheckout(checkoutEntityId?: string): Promise<{
|
|
541
|
+
entityId: string;
|
|
542
|
+
subtotal: {
|
|
543
|
+
value: number;
|
|
544
|
+
currencyCode: string;
|
|
545
|
+
} | null;
|
|
546
|
+
taxTotal: {
|
|
547
|
+
value: number;
|
|
548
|
+
currencyCode: string;
|
|
549
|
+
} | null;
|
|
550
|
+
grandTotal: {
|
|
551
|
+
value: number;
|
|
552
|
+
currencyCode: string;
|
|
553
|
+
} | null;
|
|
554
|
+
shippingCostTotal: {
|
|
555
|
+
value: number;
|
|
556
|
+
currencyCode: string;
|
|
557
|
+
} | null;
|
|
558
|
+
handlingCostTotal: {
|
|
559
|
+
value: number;
|
|
560
|
+
currencyCode: string;
|
|
561
|
+
} | null;
|
|
562
|
+
billingAddress: {
|
|
563
|
+
firstName: string | null;
|
|
564
|
+
lastName: string | null;
|
|
565
|
+
address1: string | null;
|
|
566
|
+
address2: string | null;
|
|
567
|
+
city: string | null;
|
|
568
|
+
stateOrProvince: string | null;
|
|
569
|
+
stateOrProvinceCode: string | null;
|
|
570
|
+
countryCode: string;
|
|
571
|
+
postalCode: string | null;
|
|
572
|
+
phone: string | null;
|
|
573
|
+
email: string | null;
|
|
574
|
+
} | null;
|
|
575
|
+
shippingConsignments: {
|
|
576
|
+
entityId: string;
|
|
577
|
+
address: {
|
|
578
|
+
firstName: string | null;
|
|
579
|
+
lastName: string | null;
|
|
580
|
+
address1: string | null;
|
|
581
|
+
address2: string | null;
|
|
582
|
+
city: string | null;
|
|
583
|
+
stateOrProvince: string | null;
|
|
584
|
+
stateOrProvinceCode: string | null;
|
|
585
|
+
countryCode: string;
|
|
586
|
+
postalCode: string | null;
|
|
587
|
+
phone: string | null;
|
|
588
|
+
email: string | null;
|
|
589
|
+
};
|
|
590
|
+
availableShippingOptions: {
|
|
591
|
+
entityId: string;
|
|
592
|
+
description: string;
|
|
593
|
+
type: string;
|
|
594
|
+
cost: {
|
|
595
|
+
value: number;
|
|
596
|
+
currencyCode: string;
|
|
597
|
+
};
|
|
598
|
+
}[] | null;
|
|
599
|
+
selectedShippingOption: {
|
|
600
|
+
entityId: string;
|
|
601
|
+
description: string;
|
|
602
|
+
type: string;
|
|
603
|
+
cost: {
|
|
604
|
+
value: number;
|
|
605
|
+
currencyCode: string;
|
|
606
|
+
};
|
|
607
|
+
} | null;
|
|
608
|
+
shippingCost: {
|
|
609
|
+
value: number;
|
|
610
|
+
currencyCode: string;
|
|
611
|
+
} | null;
|
|
612
|
+
lineItemIds: string[];
|
|
613
|
+
}[] | null;
|
|
614
|
+
} | null>;
|
|
615
|
+
/**
|
|
616
|
+
* Add shipping consignments (addresses) to a checkout
|
|
617
|
+
* This is required for tax calculation
|
|
618
|
+
*/
|
|
619
|
+
setCheckoutShippingAddress(checkoutEntityId: string, address: CheckoutAddress, lineItems: CheckoutConsignmentLineItem[]): Promise<{
|
|
620
|
+
entityId: string;
|
|
621
|
+
subtotal: {
|
|
622
|
+
value: number;
|
|
623
|
+
currencyCode: string;
|
|
624
|
+
} | null;
|
|
625
|
+
taxTotal: {
|
|
626
|
+
value: number;
|
|
627
|
+
currencyCode: string;
|
|
628
|
+
} | null;
|
|
629
|
+
grandTotal: {
|
|
630
|
+
value: number;
|
|
631
|
+
currencyCode: string;
|
|
632
|
+
} | null;
|
|
633
|
+
shippingCostTotal: {
|
|
634
|
+
value: number;
|
|
635
|
+
currencyCode: string;
|
|
636
|
+
} | null;
|
|
637
|
+
handlingCostTotal: {
|
|
638
|
+
value: number;
|
|
639
|
+
currencyCode: string;
|
|
640
|
+
} | null;
|
|
641
|
+
billingAddress: {
|
|
642
|
+
firstName: string | null;
|
|
643
|
+
lastName: string | null;
|
|
644
|
+
address1: string | null;
|
|
645
|
+
address2: string | null;
|
|
646
|
+
city: string | null;
|
|
647
|
+
stateOrProvince: string | null;
|
|
648
|
+
stateOrProvinceCode: string | null;
|
|
649
|
+
countryCode: string;
|
|
650
|
+
postalCode: string | null;
|
|
651
|
+
phone: string | null;
|
|
652
|
+
email: string | null;
|
|
653
|
+
} | null;
|
|
654
|
+
shippingConsignments: {
|
|
655
|
+
entityId: string;
|
|
656
|
+
address: {
|
|
657
|
+
firstName: string | null;
|
|
658
|
+
lastName: string | null;
|
|
659
|
+
address1: string | null;
|
|
660
|
+
address2: string | null;
|
|
661
|
+
city: string | null;
|
|
662
|
+
stateOrProvince: string | null;
|
|
663
|
+
stateOrProvinceCode: string | null;
|
|
664
|
+
countryCode: string;
|
|
665
|
+
postalCode: string | null;
|
|
666
|
+
phone: string | null;
|
|
667
|
+
email: string | null;
|
|
668
|
+
};
|
|
669
|
+
availableShippingOptions: {
|
|
670
|
+
entityId: string;
|
|
671
|
+
description: string;
|
|
672
|
+
type: string;
|
|
673
|
+
cost: {
|
|
674
|
+
value: number;
|
|
675
|
+
currencyCode: string;
|
|
676
|
+
};
|
|
677
|
+
}[] | null;
|
|
678
|
+
selectedShippingOption: {
|
|
679
|
+
entityId: string;
|
|
680
|
+
description: string;
|
|
681
|
+
type: string;
|
|
682
|
+
cost: {
|
|
683
|
+
value: number;
|
|
684
|
+
currencyCode: string;
|
|
685
|
+
};
|
|
686
|
+
} | null;
|
|
687
|
+
shippingCost: {
|
|
688
|
+
value: number;
|
|
689
|
+
currencyCode: string;
|
|
690
|
+
} | null;
|
|
691
|
+
lineItemIds: string[];
|
|
692
|
+
}[] | null;
|
|
693
|
+
} | null>;
|
|
694
|
+
/**
|
|
695
|
+
* Add shipping consignments (addresses) to a checkout
|
|
696
|
+
* This is required for tax calculation
|
|
697
|
+
*/
|
|
698
|
+
setCheckoutBillingAddress(checkoutEntityId: string, address: CheckoutAddress): Promise<{
|
|
699
|
+
entityId: string;
|
|
700
|
+
subtotal: {
|
|
701
|
+
value: number;
|
|
702
|
+
currencyCode: string;
|
|
703
|
+
} | null;
|
|
704
|
+
taxTotal: {
|
|
705
|
+
value: number;
|
|
706
|
+
currencyCode: string;
|
|
707
|
+
} | null;
|
|
708
|
+
grandTotal: {
|
|
709
|
+
value: number;
|
|
710
|
+
currencyCode: string;
|
|
711
|
+
} | null;
|
|
712
|
+
shippingCostTotal: {
|
|
713
|
+
value: number;
|
|
714
|
+
currencyCode: string;
|
|
715
|
+
} | null;
|
|
716
|
+
handlingCostTotal: {
|
|
717
|
+
value: number;
|
|
718
|
+
currencyCode: string;
|
|
719
|
+
} | null;
|
|
720
|
+
billingAddress: {
|
|
721
|
+
firstName: string | null;
|
|
722
|
+
lastName: string | null;
|
|
723
|
+
address1: string | null;
|
|
724
|
+
address2: string | null;
|
|
725
|
+
city: string | null;
|
|
726
|
+
stateOrProvince: string | null;
|
|
727
|
+
stateOrProvinceCode: string | null;
|
|
728
|
+
countryCode: string;
|
|
729
|
+
postalCode: string | null;
|
|
730
|
+
phone: string | null;
|
|
731
|
+
email: string | null;
|
|
732
|
+
} | null;
|
|
733
|
+
shippingConsignments: {
|
|
734
|
+
entityId: string;
|
|
735
|
+
address: {
|
|
736
|
+
firstName: string | null;
|
|
737
|
+
lastName: string | null;
|
|
738
|
+
address1: string | null;
|
|
739
|
+
address2: string | null;
|
|
740
|
+
city: string | null;
|
|
741
|
+
stateOrProvince: string | null;
|
|
742
|
+
stateOrProvinceCode: string | null;
|
|
743
|
+
countryCode: string;
|
|
744
|
+
postalCode: string | null;
|
|
745
|
+
phone: string | null;
|
|
746
|
+
email: string | null;
|
|
747
|
+
};
|
|
748
|
+
availableShippingOptions: {
|
|
749
|
+
entityId: string;
|
|
750
|
+
description: string;
|
|
751
|
+
type: string;
|
|
752
|
+
cost: {
|
|
753
|
+
value: number;
|
|
754
|
+
currencyCode: string;
|
|
755
|
+
};
|
|
756
|
+
}[] | null;
|
|
757
|
+
selectedShippingOption: {
|
|
758
|
+
entityId: string;
|
|
759
|
+
description: string;
|
|
760
|
+
type: string;
|
|
761
|
+
cost: {
|
|
762
|
+
value: number;
|
|
763
|
+
currencyCode: string;
|
|
764
|
+
};
|
|
765
|
+
} | null;
|
|
766
|
+
shippingCost: {
|
|
767
|
+
value: number;
|
|
768
|
+
currencyCode: string;
|
|
769
|
+
} | null;
|
|
770
|
+
lineItemIds: string[];
|
|
771
|
+
}[] | null;
|
|
772
|
+
} | null>;
|
|
773
|
+
/**
|
|
774
|
+
* Get customer's saved addresses and customer info
|
|
775
|
+
* Requires the customer to be logged in
|
|
776
|
+
* Automatically paginates through all addresses
|
|
777
|
+
*/
|
|
778
|
+
getCustomerAddresses(): Promise<{
|
|
779
|
+
customerInfo: CustomerInfo | null;
|
|
780
|
+
addresses: CustomerAddress[];
|
|
781
|
+
}>;
|
|
782
|
+
/**
|
|
783
|
+
* Update checkout customer message (order notes)
|
|
784
|
+
* This message will be included with the order
|
|
785
|
+
*/
|
|
786
|
+
updateCheckoutCustomerMessage(checkoutEntityId: string, options: {
|
|
787
|
+
purchaseOrderNumber: string | null;
|
|
788
|
+
threadId: string | null;
|
|
789
|
+
}): Promise<{
|
|
790
|
+
entityId: string;
|
|
791
|
+
subtotal: {
|
|
792
|
+
value: number;
|
|
793
|
+
currencyCode: string;
|
|
794
|
+
} | null;
|
|
795
|
+
taxTotal: {
|
|
796
|
+
value: number;
|
|
797
|
+
currencyCode: string;
|
|
798
|
+
} | null;
|
|
799
|
+
grandTotal: {
|
|
800
|
+
value: number;
|
|
801
|
+
currencyCode: string;
|
|
802
|
+
} | null;
|
|
803
|
+
shippingCostTotal: {
|
|
804
|
+
value: number;
|
|
805
|
+
currencyCode: string;
|
|
806
|
+
} | null;
|
|
807
|
+
handlingCostTotal: {
|
|
808
|
+
value: number;
|
|
809
|
+
currencyCode: string;
|
|
810
|
+
} | null;
|
|
811
|
+
billingAddress: {
|
|
812
|
+
firstName: string | null;
|
|
813
|
+
lastName: string | null;
|
|
814
|
+
address1: string | null;
|
|
815
|
+
address2: string | null;
|
|
816
|
+
city: string | null;
|
|
817
|
+
stateOrProvince: string | null;
|
|
818
|
+
stateOrProvinceCode: string | null;
|
|
819
|
+
countryCode: string;
|
|
820
|
+
postalCode: string | null;
|
|
821
|
+
phone: string | null;
|
|
822
|
+
email: string | null;
|
|
823
|
+
} | null;
|
|
824
|
+
shippingConsignments: {
|
|
825
|
+
entityId: string;
|
|
826
|
+
address: {
|
|
827
|
+
firstName: string | null;
|
|
828
|
+
lastName: string | null;
|
|
829
|
+
address1: string | null;
|
|
830
|
+
address2: string | null;
|
|
831
|
+
city: string | null;
|
|
832
|
+
stateOrProvince: string | null;
|
|
833
|
+
stateOrProvinceCode: string | null;
|
|
834
|
+
countryCode: string;
|
|
835
|
+
postalCode: string | null;
|
|
836
|
+
phone: string | null;
|
|
837
|
+
email: string | null;
|
|
838
|
+
};
|
|
839
|
+
availableShippingOptions: {
|
|
840
|
+
entityId: string;
|
|
841
|
+
description: string;
|
|
842
|
+
type: string;
|
|
843
|
+
cost: {
|
|
844
|
+
value: number;
|
|
845
|
+
currencyCode: string;
|
|
846
|
+
};
|
|
847
|
+
}[] | null;
|
|
848
|
+
selectedShippingOption: {
|
|
849
|
+
entityId: string;
|
|
850
|
+
description: string;
|
|
851
|
+
type: string;
|
|
852
|
+
cost: {
|
|
853
|
+
value: number;
|
|
854
|
+
currencyCode: string;
|
|
855
|
+
};
|
|
856
|
+
} | null;
|
|
857
|
+
shippingCost: {
|
|
858
|
+
value: number;
|
|
859
|
+
currencyCode: string;
|
|
860
|
+
} | null;
|
|
861
|
+
lineItemIds: string[];
|
|
862
|
+
}[] | null;
|
|
863
|
+
} | null>;
|
|
864
|
+
/**
|
|
865
|
+
* Get product variant details for multiple products
|
|
866
|
+
* Returns product options and all variants with their option values
|
|
867
|
+
* Automatically paginates through all variants, options, and option values
|
|
868
|
+
*/
|
|
869
|
+
getProductVariantDetails(productEntityIds: number[]): Promise<ProductVariantDetails[]>;
|
|
870
|
+
/**
|
|
871
|
+
* Get product paths for building product page URLs
|
|
872
|
+
* Returns a map of productEntityId to path
|
|
873
|
+
*/
|
|
874
|
+
getProductPaths(productEntityIds: number[]): Promise<Map<number, string>>;
|
|
875
|
+
/**
|
|
876
|
+
* Get products for display (used by showProducts tool)
|
|
877
|
+
* Returns product names, images, prices, and variant information
|
|
878
|
+
*/
|
|
879
|
+
getProductsForDisplay(productEntityIds: number[]): Promise<ProductForDisplay[]>;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export declare interface BigCommerceConfig {
|
|
883
|
+
endpoint: string;
|
|
884
|
+
/** Storefront API token. Optional when using a proxy that handles authentication server-side. */
|
|
885
|
+
storefrontToken?: string;
|
|
886
|
+
channelId?: number;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
export declare interface BigCommerceConfigProps {
|
|
890
|
+
/** GraphQL endpoint URL (absolute or relative for proxy) */
|
|
891
|
+
endpoint: string;
|
|
892
|
+
/** Storefront API token. Optional when using a proxy that handles authentication server-side. */
|
|
893
|
+
storefrontToken?: string;
|
|
894
|
+
/** BigCommerce channel ID */
|
|
895
|
+
channelId: number;
|
|
896
|
+
/** B2B JWT fetcher. Receives channelId and returns a B2B storefront token. For Stencil, use `stencilB2BJwt`. */
|
|
897
|
+
getB2BJwt?: (channelId: number) => Promise<string | null>;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export declare interface BigCommerceIntegration {
|
|
901
|
+
client: BigCommerceClient | MockBigCommerceClient;
|
|
902
|
+
onViewProduct?: (product: {
|
|
903
|
+
productEntityId?: number;
|
|
904
|
+
sku: string;
|
|
905
|
+
name: string;
|
|
906
|
+
path?: string;
|
|
907
|
+
}) => void;
|
|
908
|
+
/** Called when checkout is initiated. If not provided, defaults to window.location.href redirect. */
|
|
909
|
+
onCheckout?: (checkoutUrl: string) => void | Promise<void>;
|
|
910
|
+
/** B2B JWT fetcher. Receives channelId and returns a B2B storefront token. For Stencil, use `stencilB2BJwt`. */
|
|
911
|
+
getB2BJwt?: (channelId: number) => Promise<string | null>;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
declare type Cart = ResultOf<typeof CartFragment>;
|
|
915
|
+
|
|
916
|
+
declare const CartFragment: TadaDocumentNode< {
|
|
917
|
+
id: string;
|
|
918
|
+
entityId: string;
|
|
919
|
+
lineItems: {
|
|
920
|
+
physicalItems: {
|
|
921
|
+
entityId: string;
|
|
922
|
+
productEntityId: number;
|
|
923
|
+
variantEntityId: number | null;
|
|
924
|
+
quantity: number;
|
|
925
|
+
name: string;
|
|
926
|
+
sku: string | null;
|
|
927
|
+
originalPrice: {
|
|
928
|
+
value: number;
|
|
929
|
+
currencyCode: string;
|
|
930
|
+
};
|
|
931
|
+
listPrice: {
|
|
932
|
+
value: number;
|
|
933
|
+
currencyCode: string;
|
|
934
|
+
};
|
|
935
|
+
extendedListPrice: {
|
|
936
|
+
value: number;
|
|
937
|
+
currencyCode: string;
|
|
938
|
+
};
|
|
939
|
+
extendedSalePrice: {
|
|
940
|
+
value: number;
|
|
941
|
+
currencyCode: string;
|
|
942
|
+
};
|
|
943
|
+
imageUrl: string | null;
|
|
944
|
+
}[];
|
|
945
|
+
digitalItems: {
|
|
946
|
+
entityId: string;
|
|
947
|
+
productEntityId: number;
|
|
948
|
+
variantEntityId: number | null;
|
|
949
|
+
quantity: number;
|
|
950
|
+
name: string;
|
|
951
|
+
sku: string | null;
|
|
952
|
+
originalPrice: {
|
|
953
|
+
value: number;
|
|
954
|
+
currencyCode: string;
|
|
955
|
+
};
|
|
956
|
+
listPrice: {
|
|
957
|
+
value: number;
|
|
958
|
+
currencyCode: string;
|
|
959
|
+
};
|
|
960
|
+
extendedListPrice: {
|
|
961
|
+
value: number;
|
|
962
|
+
currencyCode: string;
|
|
963
|
+
};
|
|
964
|
+
extendedSalePrice: {
|
|
965
|
+
value: number;
|
|
966
|
+
currencyCode: string;
|
|
967
|
+
};
|
|
968
|
+
imageUrl: string | null;
|
|
969
|
+
}[];
|
|
970
|
+
};
|
|
971
|
+
amount: {
|
|
972
|
+
value: number;
|
|
973
|
+
currencyCode: string;
|
|
974
|
+
};
|
|
975
|
+
baseAmount: {
|
|
976
|
+
value: number;
|
|
977
|
+
currencyCode: string;
|
|
978
|
+
};
|
|
979
|
+
discountedAmount: {
|
|
980
|
+
value: number;
|
|
981
|
+
currencyCode: string;
|
|
982
|
+
};
|
|
983
|
+
createdAt: {
|
|
984
|
+
utc: string;
|
|
985
|
+
};
|
|
986
|
+
updatedAt: {
|
|
987
|
+
utc: string;
|
|
988
|
+
};
|
|
989
|
+
}, {}, {
|
|
990
|
+
fragment: "CartFields";
|
|
991
|
+
on: "Cart";
|
|
992
|
+
masked: true;
|
|
993
|
+
}>;
|
|
994
|
+
|
|
995
|
+
export declare interface CartItem extends Product {
|
|
996
|
+
quantity: number;
|
|
997
|
+
status: 'matched' | 'price-mismatch' | 'unavailable' | 'pending';
|
|
998
|
+
poPriceValue?: number;
|
|
999
|
+
poPriceCurrencyCode?: string;
|
|
1000
|
+
catalogPriceCurrencyCode?: string;
|
|
1001
|
+
bcLineItemEntityId?: string;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
declare interface CartLineItemInput {
|
|
1005
|
+
productEntityId: number;
|
|
1006
|
+
variantEntityId?: number;
|
|
1007
|
+
quantity: number;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
declare interface CartRedirectUrls {
|
|
1011
|
+
redirectedCheckoutUrl: string;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
declare type Checkout = ResultOf<typeof CheckoutFragment>;
|
|
1015
|
+
|
|
1016
|
+
declare interface CheckoutAddress {
|
|
1017
|
+
firstName?: string;
|
|
1018
|
+
lastName?: string;
|
|
1019
|
+
company?: string;
|
|
1020
|
+
address1?: string;
|
|
1021
|
+
address2?: string;
|
|
1022
|
+
city?: string;
|
|
1023
|
+
stateOrProvince?: string;
|
|
1024
|
+
stateOrProvinceCode?: string;
|
|
1025
|
+
countryCode: string;
|
|
1026
|
+
postalCode?: string;
|
|
1027
|
+
phone?: string;
|
|
1028
|
+
email?: string;
|
|
1029
|
+
shouldSaveAddress: boolean;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
declare interface CheckoutConsignmentLineItem {
|
|
1033
|
+
lineItemEntityId: string;
|
|
1034
|
+
quantity: number;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
declare const CheckoutFragment: TadaDocumentNode< {
|
|
1038
|
+
entityId: string;
|
|
1039
|
+
subtotal: {
|
|
1040
|
+
value: number;
|
|
1041
|
+
currencyCode: string;
|
|
1042
|
+
} | null;
|
|
1043
|
+
taxTotal: {
|
|
1044
|
+
value: number;
|
|
1045
|
+
currencyCode: string;
|
|
1046
|
+
} | null;
|
|
1047
|
+
grandTotal: {
|
|
1048
|
+
value: number;
|
|
1049
|
+
currencyCode: string;
|
|
1050
|
+
} | null;
|
|
1051
|
+
shippingCostTotal: {
|
|
1052
|
+
value: number;
|
|
1053
|
+
currencyCode: string;
|
|
1054
|
+
} | null;
|
|
1055
|
+
handlingCostTotal: {
|
|
1056
|
+
value: number;
|
|
1057
|
+
currencyCode: string;
|
|
1058
|
+
} | null;
|
|
1059
|
+
billingAddress: {
|
|
1060
|
+
firstName: string | null;
|
|
1061
|
+
lastName: string | null;
|
|
1062
|
+
address1: string | null;
|
|
1063
|
+
address2: string | null;
|
|
1064
|
+
city: string | null;
|
|
1065
|
+
stateOrProvince: string | null;
|
|
1066
|
+
stateOrProvinceCode: string | null;
|
|
1067
|
+
countryCode: string;
|
|
1068
|
+
postalCode: string | null;
|
|
1069
|
+
phone: string | null;
|
|
1070
|
+
email: string | null;
|
|
1071
|
+
} | null;
|
|
1072
|
+
shippingConsignments: {
|
|
1073
|
+
entityId: string;
|
|
1074
|
+
address: {
|
|
1075
|
+
firstName: string | null;
|
|
1076
|
+
lastName: string | null;
|
|
1077
|
+
address1: string | null;
|
|
1078
|
+
address2: string | null;
|
|
1079
|
+
city: string | null;
|
|
1080
|
+
stateOrProvince: string | null;
|
|
1081
|
+
stateOrProvinceCode: string | null;
|
|
1082
|
+
countryCode: string;
|
|
1083
|
+
postalCode: string | null;
|
|
1084
|
+
phone: string | null;
|
|
1085
|
+
email: string | null;
|
|
1086
|
+
};
|
|
1087
|
+
availableShippingOptions: {
|
|
1088
|
+
entityId: string;
|
|
1089
|
+
description: string;
|
|
1090
|
+
type: string;
|
|
1091
|
+
cost: {
|
|
1092
|
+
value: number;
|
|
1093
|
+
currencyCode: string;
|
|
1094
|
+
};
|
|
1095
|
+
}[] | null;
|
|
1096
|
+
selectedShippingOption: {
|
|
1097
|
+
entityId: string;
|
|
1098
|
+
description: string;
|
|
1099
|
+
type: string;
|
|
1100
|
+
cost: {
|
|
1101
|
+
value: number;
|
|
1102
|
+
currencyCode: string;
|
|
1103
|
+
};
|
|
1104
|
+
} | null;
|
|
1105
|
+
shippingCost: {
|
|
1106
|
+
value: number;
|
|
1107
|
+
currencyCode: string;
|
|
1108
|
+
} | null;
|
|
1109
|
+
lineItemIds: string[];
|
|
1110
|
+
}[] | null;
|
|
1111
|
+
}, {}, {
|
|
1112
|
+
fragment: "CheckoutFields";
|
|
1113
|
+
on: "Checkout";
|
|
1114
|
+
masked: true;
|
|
1115
|
+
}>;
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Create a B2B client with the given configuration.
|
|
1119
|
+
*/
|
|
1120
|
+
export declare function createB2BClient(config: B2BClientConfig): B2BClient;
|
|
1121
|
+
|
|
1122
|
+
/**
|
|
1123
|
+
* Create a BigCommerce client instance
|
|
1124
|
+
*/
|
|
1125
|
+
export declare function createBigCommerceClient(config: BigCommerceConfig): BigCommerceClient;
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Construct the BigCommerce GraphQL Storefront API endpoint from a store hash.
|
|
1129
|
+
* Use this when you have a store hash (e.g., from Catalyst's BIGCOMMERCE_STORE_HASH).
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* const endpoint = createBigCommerceEndpoint('abc123');
|
|
1133
|
+
* // Returns: 'https://store-abc123.mybigcommerce.com/graphql'
|
|
1134
|
+
*/
|
|
1135
|
+
export declare function createBigCommerceEndpoint(storeHash: string): string;
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Create a mock BigCommerce client instance
|
|
1139
|
+
*/
|
|
1140
|
+
export declare function createMockBigCommerceClient(config?: BigCommerceConfig): MockBigCommerceClient;
|
|
1141
|
+
|
|
1142
|
+
declare interface CustomerAddress {
|
|
1143
|
+
source: 'storefront' | 'b2b' | 'po';
|
|
1144
|
+
id: string;
|
|
1145
|
+
firstName: string;
|
|
1146
|
+
lastName: string;
|
|
1147
|
+
address1: string;
|
|
1148
|
+
address2?: string;
|
|
1149
|
+
city: string;
|
|
1150
|
+
stateOrProvince?: string;
|
|
1151
|
+
postalCode?: string;
|
|
1152
|
+
countryCode: string;
|
|
1153
|
+
country?: string;
|
|
1154
|
+
phone?: string;
|
|
1155
|
+
isShipping: boolean;
|
|
1156
|
+
isBilling: boolean;
|
|
1157
|
+
isDefaultShipping: boolean;
|
|
1158
|
+
isDefaultBilling: boolean;
|
|
1159
|
+
label?: string;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
declare interface CustomerInfo {
|
|
1163
|
+
entityId: number;
|
|
1164
|
+
firstName: string;
|
|
1165
|
+
lastName: string;
|
|
1166
|
+
email: string;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
export declare class MockBigCommerceClient {
|
|
1170
|
+
private carts;
|
|
1171
|
+
private checkouts;
|
|
1172
|
+
private checkoutToCartId;
|
|
1173
|
+
private nextCartId;
|
|
1174
|
+
private nextCheckoutId;
|
|
1175
|
+
private nextLineItemId;
|
|
1176
|
+
private nextConsignmentId;
|
|
1177
|
+
private nextShippingOptionId;
|
|
1178
|
+
readonly channelId = 1;
|
|
1179
|
+
constructor(_config?: BigCommerceConfig);
|
|
1180
|
+
/**
|
|
1181
|
+
* Helper: Create a Money object
|
|
1182
|
+
*/
|
|
1183
|
+
private createMoney;
|
|
1184
|
+
/**
|
|
1185
|
+
* Helper: Generate cart entity ID
|
|
1186
|
+
*/
|
|
1187
|
+
private generateCartId;
|
|
1188
|
+
/**
|
|
1189
|
+
* Helper: Generate checkout entity ID
|
|
1190
|
+
*/
|
|
1191
|
+
private generateCheckoutId;
|
|
1192
|
+
/**
|
|
1193
|
+
* Helper: Generate line item entity ID
|
|
1194
|
+
*/
|
|
1195
|
+
private generateLineItemId;
|
|
1196
|
+
/**
|
|
1197
|
+
* Helper: Generate consignment entity ID
|
|
1198
|
+
*/
|
|
1199
|
+
private generateConsignmentId;
|
|
1200
|
+
/**
|
|
1201
|
+
* Helper: Generate shipping option entity ID
|
|
1202
|
+
*/
|
|
1203
|
+
private generateShippingOptionId;
|
|
1204
|
+
/**
|
|
1205
|
+
* Helper: Create a cart line item from input
|
|
1206
|
+
*/
|
|
1207
|
+
private createCartLineItem;
|
|
1208
|
+
/**
|
|
1209
|
+
* Helper: Calculate cart totals
|
|
1210
|
+
*/
|
|
1211
|
+
private calculateCartTotals;
|
|
1212
|
+
/**
|
|
1213
|
+
* Helper: Calculate checkout totals
|
|
1214
|
+
*/
|
|
1215
|
+
private calculateCheckoutTotals;
|
|
1216
|
+
/**
|
|
1217
|
+
* Get an existing cart by ID
|
|
1218
|
+
*/
|
|
1219
|
+
getCart(cartEntityId?: string): Promise<Cart | null>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Create a new cart with line items
|
|
1222
|
+
*/
|
|
1223
|
+
createCart(lineItems: CartLineItemInput[]): Promise<Cart | null>;
|
|
1224
|
+
/**
|
|
1225
|
+
* Add line items to an existing cart
|
|
1226
|
+
*/
|
|
1227
|
+
addCartLineItems(cartEntityId: string, lineItems: CartLineItemInput[]): Promise<Cart | null>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Update the quantity of a cart line item
|
|
1230
|
+
*/
|
|
1231
|
+
updateCartLineItem(cartEntityId: string, lineItemEntityId: string, quantity: number, _productEntityId: number, _variantEntityId?: number): Promise<Cart | null>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Remove a line item from the cart
|
|
1234
|
+
*/
|
|
1235
|
+
deleteCartLineItem(cartEntityId: string, lineItemEntityId: string): Promise<Cart | null>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Delete an entire cart
|
|
1238
|
+
*/
|
|
1239
|
+
deleteCart(cartEntityId: string): Promise<string | null>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Create a cart or add to existing cart
|
|
1242
|
+
* Convenience method that handles both cases
|
|
1243
|
+
*/
|
|
1244
|
+
addToCart(lineItems: CartLineItemInput[], existingCartId?: string): Promise<Cart | null>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Create single-use redirect URLs for a cart
|
|
1247
|
+
*/
|
|
1248
|
+
createCartRedirectUrls(cartEntityId: string): Promise<CartRedirectUrls | null>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Get checkout by entity ID
|
|
1251
|
+
*/
|
|
1252
|
+
getCheckout(checkoutEntityId?: string): Promise<Checkout | null>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Add shipping consignments (addresses) to a checkout
|
|
1255
|
+
*/
|
|
1256
|
+
setCheckoutShippingAddress(checkoutEntityId: string, address: CheckoutAddress, lineItems: CheckoutConsignmentLineItem[]): Promise<Checkout | null>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Add billing address to a checkout
|
|
1259
|
+
*/
|
|
1260
|
+
setCheckoutBillingAddress(checkoutEntityId: string, address: CheckoutAddress): Promise<Checkout | null>;
|
|
1261
|
+
/**
|
|
1262
|
+
* Get customer's saved addresses and customer info
|
|
1263
|
+
* Always returns empty for mock (simulates logged-out state)
|
|
1264
|
+
*/
|
|
1265
|
+
getCustomerAddresses(): Promise<{
|
|
1266
|
+
customerInfo: CustomerInfo | null;
|
|
1267
|
+
addresses: CustomerAddress[];
|
|
1268
|
+
}>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Update checkout customer message (order notes)
|
|
1271
|
+
*/
|
|
1272
|
+
updateCheckoutCustomerMessage(checkoutEntityId: string, _message: any): Promise<Checkout | null>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Create a metafield on a cart (no-op in mock)
|
|
1275
|
+
*/
|
|
1276
|
+
createCartMetafield(_cartEntityId: string, _key: string, _value: string): Promise<void>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Low-level request method (not implemented in mock)
|
|
1279
|
+
*/
|
|
1280
|
+
request<T = unknown>(_options: unknown): Promise<T>;
|
|
1281
|
+
/**
|
|
1282
|
+
* Get product paths for building product page URLs
|
|
1283
|
+
* Returns a map of productEntityId to path
|
|
1284
|
+
*/
|
|
1285
|
+
getProductPaths(productEntityIds: number[]): Promise<Map<number, string>>;
|
|
1286
|
+
/**
|
|
1287
|
+
* Get products for display (used by showProducts tool)
|
|
1288
|
+
* Returns mock product names, images, prices, and variant information
|
|
1289
|
+
*/
|
|
1290
|
+
getProductsForDisplay(productEntityIds: number[]): Promise<ProductForDisplay[]>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Get product variant details for multiple products
|
|
1293
|
+
* Returns mock product options and variants
|
|
1294
|
+
*/
|
|
1295
|
+
getProductVariantDetails(productEntityIds: number[]): Promise<ProductVariantDetails[]>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Reset all state (useful for testing)
|
|
1298
|
+
*/
|
|
1299
|
+
reset(): void;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
export declare interface Product {
|
|
1303
|
+
id: string;
|
|
1304
|
+
sku: string;
|
|
1305
|
+
name: string;
|
|
1306
|
+
path?: string;
|
|
1307
|
+
price?: number;
|
|
1308
|
+
imageUrl?: string;
|
|
1309
|
+
availableQuantity?: number;
|
|
1310
|
+
isInStock?: boolean;
|
|
1311
|
+
productEntityId?: number;
|
|
1312
|
+
variantEntityId?: number;
|
|
1313
|
+
defaultImage?: {
|
|
1314
|
+
urlTemplate?: string;
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
declare interface ProductForDisplay {
|
|
1319
|
+
entityId: number;
|
|
1320
|
+
name: string;
|
|
1321
|
+
sku: string;
|
|
1322
|
+
path?: string;
|
|
1323
|
+
defaultImage?: {
|
|
1324
|
+
urlTemplate: string;
|
|
1325
|
+
};
|
|
1326
|
+
variants: Array<{
|
|
1327
|
+
entityId: number;
|
|
1328
|
+
sku: string;
|
|
1329
|
+
isPurchasable: boolean;
|
|
1330
|
+
defaultImage?: {
|
|
1331
|
+
urlTemplate: string;
|
|
1332
|
+
};
|
|
1333
|
+
prices?: {
|
|
1334
|
+
price?: {
|
|
1335
|
+
value: number;
|
|
1336
|
+
currencyCode: string;
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
inventory?: {
|
|
1340
|
+
isInStock: boolean;
|
|
1341
|
+
aggregated?: {
|
|
1342
|
+
availableToSell: number;
|
|
1343
|
+
warningLevel: number;
|
|
1344
|
+
};
|
|
1345
|
+
};
|
|
1346
|
+
}>;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
declare interface ProductOption {
|
|
1350
|
+
entityId: number;
|
|
1351
|
+
displayName: string;
|
|
1352
|
+
isRequired: boolean;
|
|
1353
|
+
isVariantOption: boolean;
|
|
1354
|
+
displayStyle?: string;
|
|
1355
|
+
values: ProductOptionValue[];
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
declare interface ProductOptionValue {
|
|
1359
|
+
entityId: number;
|
|
1360
|
+
label: string;
|
|
1361
|
+
isDefault: boolean;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
declare interface ProductVariant {
|
|
1365
|
+
entityId: number;
|
|
1366
|
+
sku: string;
|
|
1367
|
+
isPurchasable: boolean;
|
|
1368
|
+
defaultImage?: {
|
|
1369
|
+
urlTemplate: string;
|
|
1370
|
+
};
|
|
1371
|
+
prices?: {
|
|
1372
|
+
price?: {
|
|
1373
|
+
value: number;
|
|
1374
|
+
currencyCode: string;
|
|
1375
|
+
};
|
|
1376
|
+
};
|
|
1377
|
+
inventory?: {
|
|
1378
|
+
isInStock?: boolean;
|
|
1379
|
+
aggregated?: {
|
|
1380
|
+
availableToSell: number;
|
|
1381
|
+
warningLevel: number;
|
|
1382
|
+
};
|
|
1383
|
+
};
|
|
1384
|
+
options: VariantOption[];
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
declare interface ProductVariantDetails {
|
|
1388
|
+
entityId: number;
|
|
1389
|
+
productOptions: ProductOption[];
|
|
1390
|
+
variants: ProductVariant[];
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
export declare function PurchaseOrderChat(props: PurchaseOrderChatProps): JSX.Element;
|
|
1394
|
+
|
|
1395
|
+
export declare interface PurchaseOrderChatProps {
|
|
1396
|
+
className?: string;
|
|
1397
|
+
/** TakeShape agent name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
1398
|
+
agentName?: string;
|
|
1399
|
+
/** TakeShape input name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
1400
|
+
inputName?: string;
|
|
1401
|
+
bigcommerce: BigCommerceIntegration;
|
|
1402
|
+
/** When true, launches ChatView in a fullscreen modal on transition to ready state */
|
|
1403
|
+
expandOnReady?: boolean;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* Simplified PurchaseOrderChatWidget component that handles all configuration internally.
|
|
1408
|
+
* This is the recommended way to integrate the component in most applications.
|
|
1409
|
+
*
|
|
1410
|
+
* For advanced use cases requiring custom provider setup, use PurchaseOrderChat
|
|
1411
|
+
* with TakeShapeConfigProvider directly.
|
|
1412
|
+
*/
|
|
1413
|
+
export declare function PurchaseOrderChatWidget({ takeshape, bigcommerce, agentName, inputName, onViewProduct, onCheckout, className, expandOnReady }: PurchaseOrderChatWidgetProps): JSX.Element;
|
|
1414
|
+
|
|
1415
|
+
export declare interface PurchaseOrderChatWidgetProps {
|
|
1416
|
+
/** TakeShape API configuration */
|
|
1417
|
+
takeshape: TakeShapeConfigProps;
|
|
1418
|
+
/** BigCommerce storefront configuration */
|
|
1419
|
+
bigcommerce: BigCommerceConfigProps;
|
|
1420
|
+
/** TakeShape agent name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
1421
|
+
agentName?: string;
|
|
1422
|
+
/** TakeShape input name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
1423
|
+
inputName?: string;
|
|
1424
|
+
/** Called when user clicks to view a product */
|
|
1425
|
+
onViewProduct?: (product: {
|
|
1426
|
+
productEntityId?: number;
|
|
1427
|
+
sku: string;
|
|
1428
|
+
name: string;
|
|
1429
|
+
path?: string;
|
|
1430
|
+
}) => void;
|
|
1431
|
+
/** Called when checkout is initiated. If not provided, defaults to window.location.href redirect. */
|
|
1432
|
+
onCheckout?: (checkoutUrl: string) => void | Promise<void>;
|
|
1433
|
+
/** CSS class for the container */
|
|
1434
|
+
className?: string;
|
|
1435
|
+
/** When true, launches ChatView in a fullscreen modal on transition to ready state */
|
|
1436
|
+
expandOnReady?: boolean;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* B2B JWT fetcher for Stencil storefronts.
|
|
1441
|
+
* Fetches the customer JWT from /customer/current.jwt and exchanges it for a B2B storefront token.
|
|
1442
|
+
*
|
|
1443
|
+
* @param channelId - BigCommerce channel ID (passed by the B2BClient)
|
|
1444
|
+
* @returns B2B storefront token, or null if not available
|
|
1445
|
+
*
|
|
1446
|
+
* @example
|
|
1447
|
+
* ```tsx
|
|
1448
|
+
* import { stencilB2BJwt } from '@takeshape/purchase-order-chat';
|
|
1449
|
+
*
|
|
1450
|
+
* <PurchaseOrderChat
|
|
1451
|
+
* bigCommerce={{
|
|
1452
|
+
* endpoint: '/graphql',
|
|
1453
|
+
* channelId: 1,
|
|
1454
|
+
* getB2BJwt: stencilB2BJwt
|
|
1455
|
+
* }}
|
|
1456
|
+
* // ...
|
|
1457
|
+
* />
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
export declare function stencilB2BJwt(channelId: number): Promise<string | null>;
|
|
1461
|
+
|
|
1462
|
+
declare type TadaRequestOptions<R, V> = RequestOptions & {
|
|
1463
|
+
document: TadaDocumentNode<R, V>;
|
|
1464
|
+
variables?: V;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
export declare type TakeShapeConfig = {
|
|
1468
|
+
projectId: string;
|
|
1469
|
+
apiKey: string;
|
|
1470
|
+
origin: string;
|
|
1471
|
+
sseOrigin: string;
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
export declare interface TakeShapeConfigProps {
|
|
1475
|
+
projectId: string;
|
|
1476
|
+
apiKey: string;
|
|
1477
|
+
origin?: string;
|
|
1478
|
+
sseOrigin?: string;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
export declare function TakeShapeConfigProvider({ projectId, apiKey, origin, sseOrigin, children }: TakeShapeConfigProviderProps): JSX.Element;
|
|
1482
|
+
|
|
1483
|
+
declare type TakeShapeConfigProviderProps = {
|
|
1484
|
+
projectId: string;
|
|
1485
|
+
apiKey: string;
|
|
1486
|
+
origin?: string;
|
|
1487
|
+
sseOrigin?: string;
|
|
1488
|
+
children: ReactNode;
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
declare interface VariantOption {
|
|
1492
|
+
entityId: number;
|
|
1493
|
+
displayName: string;
|
|
1494
|
+
values: VariantOptionValue[];
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
declare interface VariantOptionValue {
|
|
1498
|
+
entityId: number;
|
|
1499
|
+
label: string;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
export { }
|