@thorprovider/types 7.7.0 → 7.9.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +18 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.mts +693 -10
- package/dist/index.d.ts +693 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/auth.ts +20 -0
- package/src/cart.ts +75 -1
- package/src/checkout.ts +17 -0
- package/src/commerce-provider.ts +86 -10
- package/src/common.ts +33 -0
- package/src/index.ts +76 -0
- package/src/order.ts +688 -1
package/src/order.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Universal interfaces compatible with: Shopify, Medusa.js, WooCommerce, Magento, BigCommerce
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { Money, Image } from './common';
|
|
7
|
+
import type { Money, Image, PromotionSummary } from './common';
|
|
8
8
|
import type { Address, Customer } from './customer';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -97,6 +97,8 @@ export interface OrderDeliveryGroup {
|
|
|
97
97
|
/**
|
|
98
98
|
* Order-line ids belonging to this group, only when the backend exposes the
|
|
99
99
|
* membership. Consumers MUST NOT invent an assignment when it is absent.
|
|
100
|
+
* A line whose allocations span more than one group is ambiguous and is
|
|
101
|
+
* omitted from every group rather than assigned arbitrarily.
|
|
100
102
|
*/
|
|
101
103
|
lineIds?: string[];
|
|
102
104
|
}
|
|
@@ -138,6 +140,14 @@ export interface Order {
|
|
|
138
140
|
// Customer
|
|
139
141
|
customerId?: string;
|
|
140
142
|
customer?: Customer;
|
|
143
|
+
/**
|
|
144
|
+
* Sales channel the order belongs to (Medusa `sales_channel_id`).
|
|
145
|
+
*
|
|
146
|
+
* Carried so the runtime can prove a receipt belongs to the validated store
|
|
147
|
+
* channel before rendering it; a provider that cannot expose it leaves it
|
|
148
|
+
* absent and the receipt path fails closed.
|
|
149
|
+
*/
|
|
150
|
+
salesChannelId?: string;
|
|
141
151
|
|
|
142
152
|
// Items
|
|
143
153
|
items: OrderItem[];
|
|
@@ -177,6 +187,11 @@ export interface Order {
|
|
|
177
187
|
* can render its breakdown after a reload without inventing amounts.
|
|
178
188
|
*/
|
|
179
189
|
payments?: OrderPayment[];
|
|
190
|
+
/**
|
|
191
|
+
* One row per promotion resolved from the order's item and shipping
|
|
192
|
+
* adjustments. Absent when the backend does not expose a breakdown.
|
|
193
|
+
*/
|
|
194
|
+
promotions?: PromotionSummary[];
|
|
180
195
|
/** Backend tax rate in basis points, when the order reports one rate. */
|
|
181
196
|
taxRateBps?: number;
|
|
182
197
|
|
|
@@ -262,6 +277,215 @@ export interface GetOrdersOptions {
|
|
|
262
277
|
* @see {@link GetOrdersCallback} for callback signature
|
|
263
278
|
*/
|
|
264
279
|
customFetcher?: GetOrdersCallback;
|
|
280
|
+
/**
|
|
281
|
+
* Optional server-side history query. Additive: omitted callers keep the
|
|
282
|
+
* legacy array-returning behaviour.
|
|
283
|
+
*/
|
|
284
|
+
query?: CustomerOrderHistoryQuery;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Native Medusa payment status shared by Order Detail and Order History.
|
|
289
|
+
*
|
|
290
|
+
* Kept wider than {@link PaymentStatus} because neither surface may collapse
|
|
291
|
+
* `partially_captured`, `partially_authorized`, `awaiting` or `requires_action`
|
|
292
|
+
* without lying about the financial state. The host maps it to its own view.
|
|
293
|
+
*/
|
|
294
|
+
export type CustomerOrderPaymentStatus =
|
|
295
|
+
| 'not_paid'
|
|
296
|
+
| 'awaiting'
|
|
297
|
+
| 'authorized'
|
|
298
|
+
| 'partially_authorized'
|
|
299
|
+
| 'captured'
|
|
300
|
+
| 'partially_captured'
|
|
301
|
+
| 'partially_refunded'
|
|
302
|
+
| 'refunded'
|
|
303
|
+
| 'canceled'
|
|
304
|
+
| 'requires_action';
|
|
305
|
+
|
|
306
|
+
/** Native Medusa fulfillment status shared by Order Detail and Order History. */
|
|
307
|
+
export type CustomerOrderFulfillmentStatus =
|
|
308
|
+
| 'not_fulfilled'
|
|
309
|
+
| 'partially_fulfilled'
|
|
310
|
+
| 'fulfilled'
|
|
311
|
+
| 'partially_shipped'
|
|
312
|
+
| 'shipped'
|
|
313
|
+
| 'partially_delivered'
|
|
314
|
+
| 'delivered'
|
|
315
|
+
| 'canceled';
|
|
316
|
+
|
|
317
|
+
/** Surface-level status of one fulfillment, shared with Order Detail. */
|
|
318
|
+
export type CustomerOrderFulfillmentItemStatus =
|
|
319
|
+
| 'pending'
|
|
320
|
+
| 'preparing'
|
|
321
|
+
| 'shipped'
|
|
322
|
+
| 'delivered'
|
|
323
|
+
| 'partially_delivered'
|
|
324
|
+
| 'ready_for_pickup'
|
|
325
|
+
| 'picked_up'
|
|
326
|
+
| 'cancelled';
|
|
327
|
+
|
|
328
|
+
/** Actions the backend can prove from the order state. */
|
|
329
|
+
export type CustomerOrderAction =
|
|
330
|
+
| 'reorder'
|
|
331
|
+
| 'invoice'
|
|
332
|
+
| 'track'
|
|
333
|
+
| 'return'
|
|
334
|
+
| 'exchange'
|
|
335
|
+
| 'problem'
|
|
336
|
+
| 'cancel'
|
|
337
|
+
| 'pay-balance'
|
|
338
|
+
| 'support';
|
|
339
|
+
|
|
340
|
+
export type CustomerOrderHistoryQuick =
|
|
341
|
+
| 'all'
|
|
342
|
+
| 'in-progress'
|
|
343
|
+
| 'completed'
|
|
344
|
+
| 'cancelled'
|
|
345
|
+
| 'attention';
|
|
346
|
+
|
|
347
|
+
export type CustomerOrderHistorySort =
|
|
348
|
+
| 'newest'
|
|
349
|
+
| 'oldest'
|
|
350
|
+
| 'total-desc'
|
|
351
|
+
| 'total-asc'
|
|
352
|
+
| 'updated';
|
|
353
|
+
|
|
354
|
+
export type CustomerOrderHistoryDatePreset =
|
|
355
|
+
| 'today'
|
|
356
|
+
| '7d'
|
|
357
|
+
| '30d'
|
|
358
|
+
| '90d'
|
|
359
|
+
| 'year'
|
|
360
|
+
| 'custom';
|
|
361
|
+
|
|
362
|
+
export type CustomerOrderHistoryCommercialStatus =
|
|
363
|
+
| 'pending'
|
|
364
|
+
| 'processing'
|
|
365
|
+
| 'completed'
|
|
366
|
+
| 'cancelled';
|
|
367
|
+
|
|
368
|
+
export type CustomerOrderHistoryCommercialFilter =
|
|
369
|
+
| CustomerOrderHistoryCommercialStatus
|
|
370
|
+
| 'requires-action';
|
|
371
|
+
|
|
372
|
+
export type CustomerOrderHistoryPaymentFilter =
|
|
373
|
+
| 'unpaid'
|
|
374
|
+
| 'authorized'
|
|
375
|
+
| 'partially_paid'
|
|
376
|
+
| 'paid';
|
|
377
|
+
|
|
378
|
+
export type CustomerOrderHistoryRefundFilter = 'none' | 'partial' | 'full';
|
|
379
|
+
|
|
380
|
+
export type CustomerOrderHistoryFulfilmentFilter =
|
|
381
|
+
| 'unfulfilled'
|
|
382
|
+
| 'preparing'
|
|
383
|
+
| 'shipped'
|
|
384
|
+
| 'partially_delivered'
|
|
385
|
+
| 'delivered'
|
|
386
|
+
| 'delayed'
|
|
387
|
+
| 'ready_for_pickup';
|
|
388
|
+
|
|
389
|
+
export type CustomerOrderHistoryDeliveryMode = 'shipping' | 'pickup' | 'mixed';
|
|
390
|
+
|
|
391
|
+
export type CustomerOrderHistoryReturnStatus =
|
|
392
|
+
| 'none'
|
|
393
|
+
| 'requested'
|
|
394
|
+
| 'in_progress'
|
|
395
|
+
| 'completed';
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Server-side history filter selection. OR inside a group, AND between groups.
|
|
399
|
+
*
|
|
400
|
+
* The B2B groups intentionally have no fields: buyer, company, branch, payment
|
|
401
|
+
* terms and purchase order have no real source yet and are rejected by the
|
|
402
|
+
* backend instead of being silently ignored.
|
|
403
|
+
*/
|
|
404
|
+
export interface CustomerOrderHistoryFilters {
|
|
405
|
+
commercial?: CustomerOrderHistoryCommercialFilter[];
|
|
406
|
+
payment?: CustomerOrderHistoryPaymentFilter[];
|
|
407
|
+
refund?: CustomerOrderHistoryRefundFilter[];
|
|
408
|
+
fulfilment?: CustomerOrderHistoryFulfilmentFilter[];
|
|
409
|
+
mode?: CustomerOrderHistoryDeliveryMode[];
|
|
410
|
+
returns?: CustomerOrderHistoryReturnStatus[];
|
|
411
|
+
products?: string;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** One server-side Order History query. */
|
|
415
|
+
export interface CustomerOrderHistoryQuery {
|
|
416
|
+
search?: string;
|
|
417
|
+
quick?: CustomerOrderHistoryQuick;
|
|
418
|
+
filters?: CustomerOrderHistoryFilters;
|
|
419
|
+
date?: { preset: CustomerOrderHistoryDatePreset; from?: string; to?: string };
|
|
420
|
+
/** Integer minor units in `currency`; never converted. */
|
|
421
|
+
amount?: { min?: number; max?: number; currency: string };
|
|
422
|
+
sort?: CustomerOrderHistorySort;
|
|
423
|
+
page?: number;
|
|
424
|
+
pageSize?: number;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Options for one authenticated customer history read. */
|
|
428
|
+
export interface CustomerOrderHistoryOptions extends CustomerOrderHistoryQuery {
|
|
429
|
+
salesChannelId?: string;
|
|
430
|
+
signal?: AbortSignal;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** One shipment summary inside an Order History record. */
|
|
434
|
+
export interface CustomerOrderHistoryShipment {
|
|
435
|
+
id: string;
|
|
436
|
+
mode: 'shipping' | 'pickup';
|
|
437
|
+
status: CustomerOrderFulfillmentItemStatus;
|
|
438
|
+
itemCount: number;
|
|
439
|
+
shippedAt?: string;
|
|
440
|
+
deliveredAt?: string;
|
|
441
|
+
trackingNumber?: string;
|
|
442
|
+
trackingUrl?: string;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* One normalised Order History row.
|
|
447
|
+
*
|
|
448
|
+
* Native payment and fulfillment statuses are preserved. The host maps them to
|
|
449
|
+
* the block contract; this type never invents credit terms, buyer context or
|
|
450
|
+
* partial cancellations.
|
|
451
|
+
*/
|
|
452
|
+
export interface CustomerOrderHistoryRecord {
|
|
453
|
+
id: string;
|
|
454
|
+
orderNumber: string;
|
|
455
|
+
placedAt: string;
|
|
456
|
+
updatedAt: string;
|
|
457
|
+
total: Money;
|
|
458
|
+
items: OrderItem[];
|
|
459
|
+
itemCount: number;
|
|
460
|
+
commercial: OrderStatus;
|
|
461
|
+
payment: {
|
|
462
|
+
status: CustomerOrderPaymentStatus;
|
|
463
|
+
due: Money;
|
|
464
|
+
paid: Money;
|
|
465
|
+
refunded: Money;
|
|
466
|
+
credit?: Money;
|
|
467
|
+
creditTerms: boolean;
|
|
468
|
+
};
|
|
469
|
+
refund: 'none' | 'partial' | 'full';
|
|
470
|
+
fulfilment: {
|
|
471
|
+
status: CustomerOrderFulfillmentStatus;
|
|
472
|
+
shipments: CustomerOrderHistoryShipment[];
|
|
473
|
+
};
|
|
474
|
+
deliveryMode: CustomerOrderHistoryDeliveryMode;
|
|
475
|
+
returns: CustomerOrderHistoryReturnStatus;
|
|
476
|
+
availableActions: CustomerOrderAction[];
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** One server-side Order History page. */
|
|
480
|
+
export interface CustomerOrderHistoryPage {
|
|
481
|
+
items: CustomerOrderHistoryRecord[];
|
|
482
|
+
total: number;
|
|
483
|
+
totalAll: number;
|
|
484
|
+
pageCount: number;
|
|
485
|
+
counts?: Record<CustomerOrderHistoryQuick, number>;
|
|
486
|
+
warning?: boolean;
|
|
487
|
+
limit: number;
|
|
488
|
+
offset: number;
|
|
265
489
|
}
|
|
266
490
|
|
|
267
491
|
/**
|
|
@@ -280,6 +504,8 @@ export interface GetCustomerOrdersPageOptions {
|
|
|
280
504
|
pageSize?: number;
|
|
281
505
|
/** The store's configured sales channel id (explicit; never a blind first id). */
|
|
282
506
|
salesChannelId?: string;
|
|
507
|
+
/** Optional server-side history filters. Additive. */
|
|
508
|
+
query?: CustomerOrderHistoryQuery;
|
|
283
509
|
}
|
|
284
510
|
|
|
285
511
|
/**
|
|
@@ -296,3 +522,464 @@ export interface CustomerOrdersPage {
|
|
|
296
522
|
limit: number;
|
|
297
523
|
offset: number;
|
|
298
524
|
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Sections of one authenticated customer order detail.
|
|
528
|
+
*
|
|
529
|
+
* The identifiers match the `OrderDetailPort` section ids so a host can map a
|
|
530
|
+
* per-section issue without translating names.
|
|
531
|
+
*/
|
|
532
|
+
export type CustomerOrderDetailSection =
|
|
533
|
+
| 'logistics'
|
|
534
|
+
| 'items'
|
|
535
|
+
| 'pricing'
|
|
536
|
+
| 'payments'
|
|
537
|
+
| 'afterSales'
|
|
538
|
+
| 'documents'
|
|
539
|
+
| 'b2b'
|
|
540
|
+
| 'revisions';
|
|
541
|
+
|
|
542
|
+
/** Why one section of a detail read could not be delivered. */
|
|
543
|
+
export type CustomerOrderDetailIssue = 'unavailable' | 'error' | 'forbidden';
|
|
544
|
+
|
|
545
|
+
/** Native Medusa payment status for a detail read (shared with history). */
|
|
546
|
+
export type CustomerOrderDetailPaymentStatus = CustomerOrderPaymentStatus;
|
|
547
|
+
|
|
548
|
+
/** Native Medusa fulfillment status for a detail read (shared with history). */
|
|
549
|
+
export type CustomerOrderDetailFulfillmentStatus = CustomerOrderFulfillmentStatus;
|
|
550
|
+
|
|
551
|
+
export type CustomerOrderDetailAdjustmentScope =
|
|
552
|
+
| 'product'
|
|
553
|
+
| 'order'
|
|
554
|
+
| 'shipping'
|
|
555
|
+
| 'payment';
|
|
556
|
+
|
|
557
|
+
export type CustomerOrderDetailAdjustmentDirection = 'discount' | 'surcharge';
|
|
558
|
+
|
|
559
|
+
export type CustomerOrderDetailAdjustmentSource =
|
|
560
|
+
| 'promotion'
|
|
561
|
+
| 'manual'
|
|
562
|
+
| 'contract'
|
|
563
|
+
| 'tax';
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* One persisted adjustment as read from the order.
|
|
567
|
+
*
|
|
568
|
+
* `amount` is the backend's historical amount. A discount is never re-derived
|
|
569
|
+
* from the current catalog or from a promotion's nominal value.
|
|
570
|
+
*/
|
|
571
|
+
export interface CustomerOrderDetailAdjustment {
|
|
572
|
+
id: string;
|
|
573
|
+
label: string;
|
|
574
|
+
scope: CustomerOrderDetailAdjustmentScope;
|
|
575
|
+
direction: CustomerOrderDetailAdjustmentDirection;
|
|
576
|
+
amount: Money;
|
|
577
|
+
source: CustomerOrderDetailAdjustmentSource;
|
|
578
|
+
promotionId?: string;
|
|
579
|
+
code?: string;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** One persisted tax line attached to a product line or a shipping method. */
|
|
583
|
+
export interface CustomerOrderDetailTaxLine {
|
|
584
|
+
id: string;
|
|
585
|
+
label: string;
|
|
586
|
+
/** Display-only rate (percent). Never used to recalculate the amount. */
|
|
587
|
+
rate?: number;
|
|
588
|
+
amount: Money;
|
|
589
|
+
included?: boolean;
|
|
590
|
+
exemption?: boolean;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export type CustomerOrderDetailAttributeKind = 'variant' | 'commercial' | 'custom';
|
|
594
|
+
|
|
595
|
+
/** One product attribute captured on the order line. */
|
|
596
|
+
export interface CustomerOrderDetailAttribute {
|
|
597
|
+
id: string;
|
|
598
|
+
label: string;
|
|
599
|
+
value: string;
|
|
600
|
+
kind: CustomerOrderDetailAttributeKind;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export type CustomerOrderDetailPriceKind =
|
|
604
|
+
| 'list'
|
|
605
|
+
| 'volume'
|
|
606
|
+
| 'contract'
|
|
607
|
+
| 'customer'
|
|
608
|
+
| 'promotion';
|
|
609
|
+
|
|
610
|
+
/** Historical unit price: list/original and applied, with its price kind. */
|
|
611
|
+
export interface CustomerOrderDetailLinePrice {
|
|
612
|
+
original: Money;
|
|
613
|
+
applied: Money;
|
|
614
|
+
kind: CustomerOrderDetailPriceKind;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export type CustomerOrderDetailProductKind =
|
|
618
|
+
| 'physical'
|
|
619
|
+
| 'digital'
|
|
620
|
+
| 'bundle'
|
|
621
|
+
| 'service'
|
|
622
|
+
| 'configured'
|
|
623
|
+
| 'custom'
|
|
624
|
+
| 'serialized'
|
|
625
|
+
| 'warranty'
|
|
626
|
+
| 'measured';
|
|
627
|
+
|
|
628
|
+
/** A file linked to the product variant (manual, warranty, spec sheet). */
|
|
629
|
+
export interface CustomerOrderDetailAttachment {
|
|
630
|
+
id: string;
|
|
631
|
+
name: string;
|
|
632
|
+
url: string;
|
|
633
|
+
mimeType?: string;
|
|
634
|
+
size?: number;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/** Units of one line attributed to one fulfillment. */
|
|
638
|
+
export interface CustomerOrderDetailAllocation {
|
|
639
|
+
fulfillmentId: string;
|
|
640
|
+
quantity: number;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* One historical order line.
|
|
645
|
+
*
|
|
646
|
+
* `quantity` is the ordered quantity; `cancelledQuantity` is only non-zero when
|
|
647
|
+
* Medusa cancelled the whole order, and excludes units already delivered.
|
|
648
|
+
*/
|
|
649
|
+
export interface CustomerOrderDetailLine {
|
|
650
|
+
id: string;
|
|
651
|
+
productId?: string;
|
|
652
|
+
variantId?: string;
|
|
653
|
+
title: string;
|
|
654
|
+
variantTitle?: string;
|
|
655
|
+
sku?: string;
|
|
656
|
+
image?: Image;
|
|
657
|
+
quantity: number;
|
|
658
|
+
cancelledQuantity: number;
|
|
659
|
+
unitPrice: CustomerOrderDetailLinePrice;
|
|
660
|
+
subtotal: Money;
|
|
661
|
+
total: Money;
|
|
662
|
+
discounts: CustomerOrderDetailAdjustment[];
|
|
663
|
+
taxes: CustomerOrderDetailTaxLine[];
|
|
664
|
+
attributes: CustomerOrderDetailAttribute[];
|
|
665
|
+
attachments?: CustomerOrderDetailAttachment[];
|
|
666
|
+
kind: CustomerOrderDetailProductKind;
|
|
667
|
+
serialNumber?: string;
|
|
668
|
+
warranty?: string;
|
|
669
|
+
measure?: { quantity: number; unit: string };
|
|
670
|
+
bundle?: { name: string; sku: string; quantity: number }[];
|
|
671
|
+
note?: string;
|
|
672
|
+
allocations?: CustomerOrderDetailAllocation[];
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** The selected method of one logistics group. */
|
|
676
|
+
export interface CustomerOrderDetailShippingMethod {
|
|
677
|
+
id: string;
|
|
678
|
+
name: string;
|
|
679
|
+
description?: string;
|
|
680
|
+
/** Internal warehouse/profile id; never rendered by the surface. */
|
|
681
|
+
profileId?: string;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export type CustomerOrderDetailPickupStatus =
|
|
685
|
+
| 'scheduled'
|
|
686
|
+
| 'ready'
|
|
687
|
+
| 'picked_up'
|
|
688
|
+
| 'expired';
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Pickup point details the backend can prove.
|
|
692
|
+
*
|
|
693
|
+
* Schedule, instructions and evidence are absent when the backend does not
|
|
694
|
+
* report them; the host must not invent them.
|
|
695
|
+
*/
|
|
696
|
+
export interface CustomerOrderDetailPickup {
|
|
697
|
+
locationName: string;
|
|
698
|
+
address?: Address;
|
|
699
|
+
status: CustomerOrderDetailPickupStatus;
|
|
700
|
+
code?: string;
|
|
701
|
+
availableFrom?: string;
|
|
702
|
+
expiresAt?: string;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** One confirmed logistics group on the order. */
|
|
706
|
+
export interface CustomerOrderDetailGroup {
|
|
707
|
+
id: string;
|
|
708
|
+
mode: 'shipping' | 'pickup';
|
|
709
|
+
method: CustomerOrderDetailShippingMethod;
|
|
710
|
+
shippingSubtotal: Money;
|
|
711
|
+
discounts: CustomerOrderDetailAdjustment[];
|
|
712
|
+
taxes: CustomerOrderDetailTaxLine[];
|
|
713
|
+
total: Money;
|
|
714
|
+
etaLabel?: string;
|
|
715
|
+
pickup?: CustomerOrderDetailPickup;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/** Surface-level status of one fulfillment (shared with history). */
|
|
719
|
+
export type CustomerOrderDetailFulfillmentItemStatus =
|
|
720
|
+
CustomerOrderFulfillmentItemStatus;
|
|
721
|
+
|
|
722
|
+
/** One package/label attached to a fulfillment. */
|
|
723
|
+
export interface CustomerOrderDetailPackage {
|
|
724
|
+
id: string;
|
|
725
|
+
label?: string;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** One fulfillment with its allocations, packages and tracking. */
|
|
729
|
+
export interface CustomerOrderDetailFulfillment {
|
|
730
|
+
id: string;
|
|
731
|
+
groupId: string;
|
|
732
|
+
status: CustomerOrderDetailFulfillmentItemStatus;
|
|
733
|
+
providerId?: string;
|
|
734
|
+
carrier?: string;
|
|
735
|
+
trackingNumber?: string;
|
|
736
|
+
trackingUrl?: string;
|
|
737
|
+
packedAt?: string;
|
|
738
|
+
shippedAt?: string;
|
|
739
|
+
deliveredAt?: string;
|
|
740
|
+
canceledAt?: string;
|
|
741
|
+
packages: CustomerOrderDetailPackage[];
|
|
742
|
+
allocations: CustomerOrderDetailAllocation[];
|
|
743
|
+
pickup?: CustomerOrderDetailPickup;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export type CustomerOrderDetailPromotionScope =
|
|
747
|
+
| 'product'
|
|
748
|
+
| 'order'
|
|
749
|
+
| 'shipping'
|
|
750
|
+
| 'payment';
|
|
751
|
+
|
|
752
|
+
export type CustomerOrderDetailPromotionApplication = 'automatic' | 'code';
|
|
753
|
+
|
|
754
|
+
export type CustomerOrderDetailPromotionNominal =
|
|
755
|
+
| { kind: 'percent'; percent: number }
|
|
756
|
+
| { kind: 'fixed'; money: Money };
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* One promotion aggregated from the order's persisted adjustments.
|
|
760
|
+
*
|
|
761
|
+
* `discounted` is the sum of the unique adjustment ids in `adjustmentIds`;
|
|
762
|
+
* `nominal` is display context only and never the charged amount.
|
|
763
|
+
*/
|
|
764
|
+
export interface CustomerOrderDetailPromotion {
|
|
765
|
+
id: string;
|
|
766
|
+
code?: string;
|
|
767
|
+
name?: string;
|
|
768
|
+
type?: 'standard' | 'buyget';
|
|
769
|
+
scope: CustomerOrderDetailPromotionScope;
|
|
770
|
+
application: CustomerOrderDetailPromotionApplication;
|
|
771
|
+
nominal?: CustomerOrderDetailPromotionNominal;
|
|
772
|
+
discounted: Money;
|
|
773
|
+
adjustmentIds: string[];
|
|
774
|
+
lineIds: string[];
|
|
775
|
+
groupIds?: string[];
|
|
776
|
+
buyXGetY?: {
|
|
777
|
+
conditionLineIds: string[];
|
|
778
|
+
rewardLineIds: string[];
|
|
779
|
+
rewardQuantity?: number;
|
|
780
|
+
freeQuantity?: number;
|
|
781
|
+
partial?: boolean;
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
export type CustomerOrderDetailTransactionKind =
|
|
786
|
+
| 'payment'
|
|
787
|
+
| 'authorization'
|
|
788
|
+
| 'refund'
|
|
789
|
+
| 'credit';
|
|
790
|
+
|
|
791
|
+
export type CustomerOrderDetailTransactionStatus =
|
|
792
|
+
| 'pending'
|
|
793
|
+
| 'authorized'
|
|
794
|
+
| 'captured'
|
|
795
|
+
| 'refunded'
|
|
796
|
+
| 'failed'
|
|
797
|
+
| 'canceled';
|
|
798
|
+
|
|
799
|
+
export type CustomerOrderDetailTransactionMethod =
|
|
800
|
+
| 'card'
|
|
801
|
+
| 'wallet'
|
|
802
|
+
| 'transfer'
|
|
803
|
+
| 'credit'
|
|
804
|
+
| 'cash'
|
|
805
|
+
| 'system'
|
|
806
|
+
| 'gift_card'
|
|
807
|
+
| 'store_credit'
|
|
808
|
+
| 'other';
|
|
809
|
+
|
|
810
|
+
/** One financial movement (payment, authorization, refund or credit). */
|
|
811
|
+
export interface CustomerOrderDetailTransaction {
|
|
812
|
+
id: string;
|
|
813
|
+
kind: CustomerOrderDetailTransactionKind;
|
|
814
|
+
status: CustomerOrderDetailTransactionStatus;
|
|
815
|
+
amount: Money;
|
|
816
|
+
at: string;
|
|
817
|
+
providerId?: string;
|
|
818
|
+
method?: CustomerOrderDetailTransactionMethod;
|
|
819
|
+
reference?: string;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export type CustomerOrderDetailCaseType = 'return' | 'exchange' | 'claim';
|
|
823
|
+
|
|
824
|
+
export type CustomerOrderDetailCaseStatus =
|
|
825
|
+
| 'requested'
|
|
826
|
+
| 'approved'
|
|
827
|
+
| 'in_transit'
|
|
828
|
+
| 'received'
|
|
829
|
+
| 'partially_received'
|
|
830
|
+
| 'completed'
|
|
831
|
+
| 'rejected'
|
|
832
|
+
| 'canceled';
|
|
833
|
+
|
|
834
|
+
export interface CustomerOrderDetailCaseLine {
|
|
835
|
+
lineId: string;
|
|
836
|
+
quantity: number;
|
|
837
|
+
receivedQuantity?: number;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/** One basic after-sales case (native return, exchange or claim). */
|
|
841
|
+
export interface CustomerOrderDetailCase {
|
|
842
|
+
id: string;
|
|
843
|
+
type: CustomerOrderDetailCaseType;
|
|
844
|
+
status: CustomerOrderDetailCaseStatus;
|
|
845
|
+
createdAt: string;
|
|
846
|
+
reason?: string;
|
|
847
|
+
lines: CustomerOrderDetailCaseLine[];
|
|
848
|
+
refund?: Money;
|
|
849
|
+
differenceDue?: Money;
|
|
850
|
+
replacement?: { name: string; sku: string; quantity: number }[];
|
|
851
|
+
shipment?: {
|
|
852
|
+
carrier?: string;
|
|
853
|
+
trackingNumber?: string;
|
|
854
|
+
trackingUrl?: string;
|
|
855
|
+
status?: string;
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export type CustomerOrderDetailDocumentKind =
|
|
860
|
+
| 'invoice'
|
|
861
|
+
| 'receipt'
|
|
862
|
+
| 'payment-proof'
|
|
863
|
+
| 'credit-note'
|
|
864
|
+
| 'shipping'
|
|
865
|
+
| 'business';
|
|
866
|
+
|
|
867
|
+
/** One document the store can actually issue. Absent when none exists. */
|
|
868
|
+
export interface CustomerOrderDetailDocument {
|
|
869
|
+
id: string;
|
|
870
|
+
kind: CustomerOrderDetailDocumentKind;
|
|
871
|
+
label: string;
|
|
872
|
+
issuedAt?: string;
|
|
873
|
+
available: boolean;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
export type CustomerOrderDetailInvoiceStatus =
|
|
877
|
+
| 'not_issued'
|
|
878
|
+
| 'pending'
|
|
879
|
+
| 'issued'
|
|
880
|
+
| 'overdue';
|
|
881
|
+
|
|
882
|
+
export type CustomerOrderDetailApprovalStatus = 'pending' | 'approved' | 'rejected';
|
|
883
|
+
|
|
884
|
+
/** B2B extension. Not produced by the current backend. */
|
|
885
|
+
export interface CustomerOrderDetailBusiness {
|
|
886
|
+
company: string;
|
|
887
|
+
buyer: string;
|
|
888
|
+
branch?: string;
|
|
889
|
+
purchaseOrder?: string;
|
|
890
|
+
internalReference?: string;
|
|
891
|
+
costCenter?: string;
|
|
892
|
+
paymentTerms?: string;
|
|
893
|
+
creditLimit?: Money;
|
|
894
|
+
creditUsed?: Money;
|
|
895
|
+
dueAt?: string;
|
|
896
|
+
invoiceStatus?: CustomerOrderDetailInvoiceStatus;
|
|
897
|
+
approval?: { status: CustomerOrderDetailApprovalStatus; by?: string; at?: string };
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
export type CustomerOrderDetailRevisionKind =
|
|
901
|
+
| 'item-added'
|
|
902
|
+
| 'item-removed'
|
|
903
|
+
| 'quantity'
|
|
904
|
+
| 'price'
|
|
905
|
+
| 'shipping'
|
|
906
|
+
| 'tax'
|
|
907
|
+
| 'cancel';
|
|
908
|
+
|
|
909
|
+
/** Post-creation revision extension. Not produced by the current backend. */
|
|
910
|
+
export interface CustomerOrderDetailRevision {
|
|
911
|
+
id: string;
|
|
912
|
+
at: string;
|
|
913
|
+
kind: CustomerOrderDetailRevisionKind;
|
|
914
|
+
summary: string;
|
|
915
|
+
delta?: Money;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/** Actions the backend can prove from the order state (shared with history). */
|
|
919
|
+
export type CustomerOrderDetailAction = CustomerOrderAction;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* The authoritative economic summary of the detail.
|
|
923
|
+
*
|
|
924
|
+
* `paid`, `refunded`, `due` and `credit` are computed by the backend from the
|
|
925
|
+
* payment collections; no consumer recalculates them from transactions.
|
|
926
|
+
*/
|
|
927
|
+
export interface CustomerOrderDetailTotals {
|
|
928
|
+
itemsSubtotal: Money;
|
|
929
|
+
itemDiscounts: Money;
|
|
930
|
+
orderDiscounts: Money;
|
|
931
|
+
shippingSubtotal: Money;
|
|
932
|
+
shippingDiscounts: Money;
|
|
933
|
+
tax: Money;
|
|
934
|
+
adjustments: Money;
|
|
935
|
+
total: Money;
|
|
936
|
+
authorized?: Money;
|
|
937
|
+
paid: Money;
|
|
938
|
+
refunded: Money;
|
|
939
|
+
due: Money;
|
|
940
|
+
credit?: Money;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/** One authenticated customer order detail. */
|
|
944
|
+
export interface CustomerOrderDetailOrder {
|
|
945
|
+
id: string;
|
|
946
|
+
orderNumber: string;
|
|
947
|
+
status: OrderStatus;
|
|
948
|
+
paymentStatus: CustomerOrderDetailPaymentStatus;
|
|
949
|
+
fulfillmentStatus: CustomerOrderDetailFulfillmentStatus;
|
|
950
|
+
currencyCode: string;
|
|
951
|
+
salesChannelId?: string;
|
|
952
|
+
createdAt: string;
|
|
953
|
+
updatedAt: string;
|
|
954
|
+
completedAt?: string;
|
|
955
|
+
cancelledAt?: string;
|
|
956
|
+
shippingAddress?: Address;
|
|
957
|
+
billingAddress?: Address;
|
|
958
|
+
lines: CustomerOrderDetailLine[];
|
|
959
|
+
groups: CustomerOrderDetailGroup[];
|
|
960
|
+
fulfillments: CustomerOrderDetailFulfillment[];
|
|
961
|
+
promotions: CustomerOrderDetailPromotion[];
|
|
962
|
+
adjustments: CustomerOrderDetailAdjustment[];
|
|
963
|
+
payments: OrderPayment[];
|
|
964
|
+
transactions: CustomerOrderDetailTransaction[];
|
|
965
|
+
cases: CustomerOrderDetailCase[];
|
|
966
|
+
documents: CustomerOrderDetailDocument[];
|
|
967
|
+
business?: CustomerOrderDetailBusiness;
|
|
968
|
+
revisions: CustomerOrderDetailRevision[];
|
|
969
|
+
totals: CustomerOrderDetailTotals;
|
|
970
|
+
availableActions: CustomerOrderDetailAction[];
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* The detail read snapshot: one order plus truthful per-section issues and a
|
|
975
|
+
* non-blocking partial-load warning. Absent `issues` means every section is
|
|
976
|
+
* valid; an affected section must not invalidate the rest of the order.
|
|
977
|
+
*/
|
|
978
|
+
export interface CustomerOrderDetailSnapshot {
|
|
979
|
+
order: CustomerOrderDetailOrder;
|
|
980
|
+
issues?: Partial<Record<CustomerOrderDetailSection, CustomerOrderDetailIssue>>;
|
|
981
|
+
warning?: boolean;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/** Alias kept for the backend/OpenSpec contract name. */
|
|
985
|
+
export type CustomerOrderDetail = CustomerOrderDetailSnapshot;
|