@01.software/cli 0.11.2 → 0.13.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.
@@ -12,49 +12,79 @@ var MCP_RESOURCE_INVENTORY = [
12
12
  {
13
13
  uri: "docs://sdk/getting-started",
14
14
  label: "getting-started",
15
- registeredName: "docs-getting-started"
15
+ registeredName: "docs-getting-started",
16
+ canonicalDocsSlug: ["developers", "sdk"],
17
+ canonicalDocsKeywords: ["Install the package", "@01.software/sdk"]
18
+ },
19
+ {
20
+ uri: "docs://sdk/guides",
21
+ label: "guides",
22
+ registeredName: "docs-guides",
23
+ canonicalDocsSlug: ["developers", "sdk"],
24
+ canonicalDocsKeywords: ["Setup Flow", "Next Actions"]
25
+ },
26
+ {
27
+ uri: "docs://sdk/api",
28
+ label: "api",
29
+ registeredName: "docs-api",
30
+ canonicalDocsSlug: ["developers", "api"],
31
+ canonicalDocsKeywords: ["/api/openapi", "OpenAPI"]
16
32
  },
17
- { uri: "docs://sdk/guides", label: "guides", registeredName: "docs-guides" },
18
- { uri: "docs://sdk/api", label: "api", registeredName: "docs-api" },
19
33
  {
20
34
  uri: "docs://sdk/query-builder",
21
35
  label: "query-builder",
22
- registeredName: "docs-query-builder"
36
+ registeredName: "docs-query-builder",
37
+ canonicalDocsSlug: ["developers", "sdk"],
38
+ canonicalDocsKeywords: ["query helpers", "@01.software/sdk/query"]
23
39
  },
24
40
  {
25
41
  uri: "docs://sdk/react-query",
26
42
  label: "react-query",
27
- registeredName: "docs-react-query"
43
+ registeredName: "docs-react-query",
44
+ canonicalDocsSlug: ["developers", "sdk"],
45
+ canonicalDocsKeywords: ["React", "@tanstack/react-query"]
28
46
  },
29
47
  {
30
48
  uri: "docs://sdk/server-api",
31
49
  label: "server-api",
32
- registeredName: "docs-server-api"
50
+ registeredName: "docs-server-api",
51
+ canonicalDocsSlug: ["developers", "api"],
52
+ canonicalDocsKeywords: ["Server writes", "trusted server credentials"]
33
53
  },
34
54
  {
35
55
  uri: "docs://sdk/customer-auth",
36
56
  label: "customer-auth",
37
- registeredName: "docs-customer-auth"
57
+ registeredName: "docs-customer-auth",
58
+ canonicalDocsSlug: ["developers", "authentication"],
59
+ canonicalDocsKeywords: ["Publishable Key", "Secret Key"]
38
60
  },
39
61
  {
40
62
  uri: "docs://sdk/browser-vs-server",
41
63
  label: "browser-vs-server",
42
- registeredName: "docs-browser-vs-server"
64
+ registeredName: "docs-browser-vs-server",
65
+ canonicalDocsSlug: ["developers", "sdk"],
66
+ canonicalDocsKeywords: ["browser client", "server client"]
43
67
  },
44
68
  {
45
69
  uri: "docs://sdk/file-upload",
46
70
  label: "file-upload",
47
- registeredName: "docs-file-upload"
71
+ registeredName: "docs-file-upload",
72
+ canonicalDocsSlug: ["developers", "api"],
73
+ canonicalDocsKeywords: ["direct HTTP", "machine-readable contract"]
48
74
  },
49
75
  {
50
76
  uri: "docs://sdk/webhook",
51
77
  label: "webhook",
52
- registeredName: "docs-webhook"
78
+ registeredName: "docs-webhook",
79
+ canonicalDocsSlug: ["developers", "webhooks"],
80
+ canonicalDocsKeywords: ["Webhook", "commerce.notification"]
53
81
  },
54
82
  {
55
83
  uri: "docs://sdk/product-detail",
56
84
  label: "product-detail",
57
- registeredName: "docs-product-detail"
85
+ registeredName: "docs-product-detail",
86
+ canonicalDocsSlug: ["recipes", "product-detail"],
87
+ canonicalDocsKeywords: ["Product detail page", "commerce.product.detail"]
58
88
  }
59
89
  ];
60
90
  var MCP_RESOURCE_LABELS = MCP_RESOURCE_INVENTORY.map(
@@ -333,7 +363,6 @@ var productFieldShape = {
333
363
  weight: z2.number().int().min(0).optional().nullable(),
334
364
  minOrderQuantity: z2.number().int().min(1).optional().nullable(),
335
365
  maxOrderQuantity: z2.number().int().min(1).optional().nullable(),
336
- listingPrimaryOption: IdSchema.optional().nullable(),
337
366
  isFeatured: z2.boolean().optional(),
338
367
  publishedAt: z2.string().optional().nullable(),
339
368
  categories: z2.array(IdSchema).optional(),
@@ -458,6 +487,29 @@ var transactionStatusSchema = z3.enum([
458
487
  "failed",
459
488
  "canceled"
460
489
  ]);
490
+ var financialStatusSchema = z3.enum([
491
+ "pending",
492
+ "paid",
493
+ "failed",
494
+ "canceled",
495
+ "partially_refunded",
496
+ "refunded"
497
+ ]);
498
+ var confirmationStatusSchema = z3.enum(["unconfirmed", "confirmed"]);
499
+ var fulfillmentOrderStatusSchema = z3.enum([
500
+ "open",
501
+ "in_progress",
502
+ "on_hold",
503
+ "canceled",
504
+ "closed"
505
+ ]);
506
+ var shipmentStatusSchema = z3.enum([
507
+ "pending",
508
+ "shipped",
509
+ "delivered",
510
+ "canceled",
511
+ "failed"
512
+ ]);
461
513
  var orderStatusSchema = z3.enum([
462
514
  "pending",
463
515
  "paid",
@@ -472,7 +524,7 @@ var orderStatusSchema = z3.enum([
472
524
  "return_processing",
473
525
  "returned"
474
526
  ]);
475
- var entityIdSchema = z3.union([z3.string(), z3.number()]).transform(String);
527
+ var entityIdSchema = z3.union([z3.string().min(1), z3.number()]).transform(String);
476
528
  var createOrderItemSchema = z3.object({
477
529
  product: entityIdSchema,
478
530
  variant: entityIdSchema,
@@ -480,7 +532,7 @@ var createOrderItemSchema = z3.object({
480
532
  quantity: z3.number().int().positive("quantity must be a positive integer"),
481
533
  unitPrice: z3.number().optional(),
482
534
  totalPrice: z3.number().optional()
483
- });
535
+ }).strict();
484
536
  var createOrderSchema = z3.object({
485
537
  pgPaymentId: z3.string().min(1).optional(),
486
538
  orderNumber: z3.string().min(1, "orderNumber is required"),
@@ -489,7 +541,7 @@ var createOrderSchema = z3.object({
489
541
  name: z3.string().optional(),
490
542
  email: z3.string().email("Invalid email format"),
491
543
  phone: z3.string().optional()
492
- }),
544
+ }).strict(),
493
545
  shippingAddress: z3.object({
494
546
  postalCode: z3.string().optional(),
495
547
  address: z3.string().optional(),
@@ -497,12 +549,12 @@ var createOrderSchema = z3.object({
497
549
  deliveryMessage: z3.string().optional(),
498
550
  recipientName: z3.string().optional(),
499
551
  phone: z3.string().optional()
500
- }),
552
+ }).strict(),
501
553
  orderItems: z3.array(createOrderItemSchema).min(1, "At least one order item is required").max(100, "Maximum 100 items per order"),
502
554
  totalAmount: z3.number().nonnegative("totalAmount must be non-negative"),
503
555
  shippingAmount: z3.number().min(0).optional(),
504
556
  discountCode: z3.string().optional()
505
- });
557
+ }).strict();
506
558
  var CreateOrderSchema = createOrderSchema;
507
559
  var updateTransactionSchema = z3.object({
508
560
  pgPaymentId: z3.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
@@ -536,6 +588,9 @@ var confirmPaymentSchema = z3.object({
536
588
  "provider_api_confirm",
537
589
  "manual_server"
538
590
  ]).optional(),
591
+ paymentKey: z3.string().min(1).optional().describe(
592
+ "Optional provider payment key from the client confirm handshake; stored for BFF/provider refund workflows (also accepted as metadata.tossPaymentKey). Local cancel does not read this field."
593
+ ),
539
594
  metadata: z3.record(z3.string(), z3.unknown()).optional()
540
595
  }).strict();
541
596
  var ConfirmPaymentSchema = confirmPaymentSchema;
@@ -548,7 +603,7 @@ var returnReasonSchema = z3.enum([
548
603
  ]);
549
604
  var restockActionSchema = z3.enum(["return_to_stock", "discard"]);
550
605
  var returnWithRefundItemSchema = z3.object({
551
- orderItem: z3.union([z3.string(), z3.number()]).transform(String),
606
+ orderItem: z3.union([z3.string().min(1), z3.number()]).transform(String),
552
607
  quantity: z3.number().int().positive("quantity must be a positive integer"),
553
608
  restockAction: restockActionSchema.default("return_to_stock"),
554
609
  restockingFee: z3.number().min(0, "restockingFee must be non-negative").optional().describe("Restocking fee charged for this line (ADR 0005 \xA7Gap 1)")
@@ -562,10 +617,29 @@ var returnWithRefundSchema = z3.object({
562
617
  returnShippingFee: z3.number().min(0, "returnShippingFee must be non-negative").optional().describe(
563
618
  "Return shipping fee charged to the customer (ADR 0005 \xA7Gap 1)"
564
619
  ),
620
+ initialShippingRefundAmount: z3.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
621
+ initialShippingRefundOverrideNote: z3.string().min(1).optional().describe(
622
+ "Operator audit note required when overriding policy suggestion"
623
+ ),
565
624
  pgPaymentId: z3.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
566
625
  paymentKey: z3.string().min(1).optional().describe("Provider payment key for verified refund"),
567
626
  refundReceiptUrl: z3.string().optional().describe("Refund receipt URL (optional)")
568
627
  }).strict();
628
+ var createReturnSchema = z3.object({
629
+ orderNumber: z3.string().min(1, "orderNumber is required").describe("Order number (required)"),
630
+ reason: returnReasonSchema.optional().describe("Return reason (optional)"),
631
+ reasonDetail: z3.string().optional().describe("Detailed reason text (optional)"),
632
+ returnItems: z3.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
633
+ refundAmount: z3.number().min(0, "refundAmount must be non-negative").describe(
634
+ "Line refund amount before initial shipping refund (required, min 0)"
635
+ ),
636
+ returnShippingFee: z3.number().min(0, "returnShippingFee must be non-negative").optional().describe("Return shipping fee charged to the customer"),
637
+ initialShippingRefundAmount: z3.number().min(0, "initialShippingRefundAmount must be non-negative").optional().describe("Initial order shipping amount refunded to the customer"),
638
+ initialShippingRefundOverrideNote: z3.string().min(1).optional().describe(
639
+ "Operator audit note required when overriding policy suggestion"
640
+ )
641
+ }).strict();
642
+ var CreateReturnSchema = createReturnSchema;
569
643
  var ReturnWithRefundSchema = returnWithRefundSchema;
570
644
  var cancelReasonCodeSchema = z3.enum([
571
645
  "customer",
@@ -588,20 +662,32 @@ var CancelOrderSchema = cancelOrderSchema;
588
662
  var cancelOrderResponseBaseSchema = {
589
663
  orderId: z3.string().min(1)
590
664
  };
591
- var unpaidCancelResponseFields = {
665
+ var unpaidLocalCancelCommittedResponseFields = {
592
666
  refundedAmount: z3.literal(0),
593
667
  providerRefunded: z3.literal(false)
594
668
  };
595
- var alreadyCanceledResponseFields = {
596
- refundedAmount: z3.number().int().nonnegative(),
597
- providerRefunded: z3.literal(false)
669
+ var paidLocalCancelCommittedResponseFields = {
670
+ transactionId: z3.string().min(1),
671
+ refundedAmount: z3.literal(0),
672
+ providerRefunded: z3.literal(false),
673
+ refundPending: z3.literal(true)
598
674
  };
599
- var providerRefundResponseFields = {
675
+ var legacyProviderRefundResponseFields = {
600
676
  transactionId: z3.string().min(1),
601
677
  refundedAmount: z3.number().int().positive(),
602
678
  refundSeq: z3.number().int().positive(),
603
679
  providerRefunded: z3.literal(true)
604
680
  };
681
+ var alreadyCanceledResponseFields = {
682
+ refundedAmount: z3.number().int().nonnegative(),
683
+ providerRefunded: z3.literal(false)
684
+ };
685
+ var alreadyCanceledRefundPendingResponseFields = {
686
+ transactionId: z3.string().min(1),
687
+ refundedAmount: z3.number().int().nonnegative(),
688
+ providerRefunded: z3.literal(false),
689
+ refundPending: z3.literal(true)
690
+ };
605
691
  var cancelOrderReconciliationStatusSchema = z3.enum([
606
692
  "paid",
607
693
  "preparing",
@@ -616,13 +702,13 @@ var cancelOrderReconciliationStatusSchema = z3.enum([
616
702
  var cancelOrderResponseSchema = z3.union([
617
703
  z3.object({
618
704
  ...cancelOrderResponseBaseSchema,
619
- ...unpaidCancelResponseFields,
705
+ ...paidLocalCancelCommittedResponseFields,
620
706
  status: z3.literal("canceled"),
621
707
  cancelCommitted: z3.literal(true)
622
708
  }).strict(),
623
709
  z3.object({
624
710
  ...cancelOrderResponseBaseSchema,
625
- ...providerRefundResponseFields,
711
+ ...unpaidLocalCancelCommittedResponseFields,
626
712
  status: z3.literal("canceled"),
627
713
  cancelCommitted: z3.literal(true)
628
714
  }).strict(),
@@ -635,12 +721,75 @@ var cancelOrderResponseSchema = z3.union([
635
721
  }).strict(),
636
722
  z3.object({
637
723
  ...cancelOrderResponseBaseSchema,
638
- ...providerRefundResponseFields,
724
+ ...alreadyCanceledRefundPendingResponseFields,
725
+ status: z3.literal("canceled"),
726
+ cancelCommitted: z3.literal(false),
727
+ alreadyCanceled: z3.literal(true)
728
+ }).strict(),
729
+ z3.object({
730
+ ...cancelOrderResponseBaseSchema,
731
+ ...legacyProviderRefundResponseFields,
639
732
  status: cancelOrderReconciliationStatusSchema,
640
733
  cancelCommitted: z3.literal(false),
641
734
  reconciliationRequired: z3.literal(true)
642
735
  }).strict()
643
736
  ]);
737
+ var resolveCancelRefundOutcomeSchema = z3.enum(["succeeded", "failed"]);
738
+ var resolveCancelRefundSchema = z3.object({
739
+ orderNumber: z3.string().min(1, "orderNumber is required").describe("Order number whose pending cancel refund is being resolved"),
740
+ idempotencyKey: idempotencyKeySchema.describe(
741
+ "Stable key for this PG refund result report"
742
+ ),
743
+ outcome: resolveCancelRefundOutcomeSchema.describe(
744
+ "PG refund result reported by the storefront or BFF"
745
+ ),
746
+ refundedAmount: z3.number().int("refundedAmount must be an integer minor-unit amount").nonnegative("refundedAmount must be nonnegative"),
747
+ pgProvider: z3.string().trim().min(1, "pgProvider is required").regex(
748
+ /^[a-z0-9][a-z0-9_-]*$/,
749
+ "pgProvider must be a lowercase provider slug"
750
+ ),
751
+ pgRefundId: z3.string().trim().min(1).optional()
752
+ }).strict().superRefine((value, ctx) => {
753
+ if (value.outcome === "succeeded" && value.refundedAmount <= 0) {
754
+ ctx.addIssue({
755
+ code: z3.ZodIssueCode.custom,
756
+ path: ["refundedAmount"],
757
+ message: "refundedAmount must be positive when outcome is succeeded"
758
+ });
759
+ }
760
+ if (value.outcome === "succeeded" && !value.pgRefundId) {
761
+ ctx.addIssue({
762
+ code: z3.ZodIssueCode.custom,
763
+ path: ["pgRefundId"],
764
+ message: "pgRefundId is required when outcome is succeeded"
765
+ });
766
+ }
767
+ if (value.outcome === "failed" && value.refundedAmount !== 0) {
768
+ ctx.addIssue({
769
+ code: z3.ZodIssueCode.custom,
770
+ path: ["refundedAmount"],
771
+ message: "refundedAmount must be 0 when outcome is failed"
772
+ });
773
+ }
774
+ });
775
+ var resolveCancelRefundResponseSchema = z3.union([
776
+ z3.object({
777
+ orderId: z3.string().min(1),
778
+ transactionId: z3.string().min(1),
779
+ refundTransactionId: z3.string().min(1),
780
+ refundedAmount: z3.number().int().positive(),
781
+ refundStatus: z3.literal("succeeded"),
782
+ transactionStatus: z3.literal("refunded")
783
+ }).strict(),
784
+ z3.object({
785
+ orderId: z3.string().min(1),
786
+ transactionId: z3.string().min(1),
787
+ refundTransactionId: z3.string().min(1),
788
+ refundedAmount: z3.literal(0),
789
+ refundStatus: z3.literal("failed"),
790
+ transactionStatus: z3.literal("paid")
791
+ }).strict()
792
+ ]);
644
793
 
645
794
  // ../../packages/contracts/src/mcp/index.ts
646
795
  var MCP_TOOL_CONTRACT = {
@@ -764,6 +913,11 @@ var MCP_TOOL_CONTRACT = {
764
913
  oauthScope: "mcp:write",
765
914
  readOnly: false
766
915
  },
916
+ "prepare-fulfillment-order": {
917
+ consoleRole: "tenant-admin",
918
+ oauthScope: "mcp:write",
919
+ readOnly: false
920
+ },
767
921
  "update-fulfillment": {
768
922
  consoleRole: "tenant-admin",
769
923
  oauthScope: "mcp:write",
@@ -1036,6 +1190,13 @@ var TOOL_POLICY_MANIFEST = {
1036
1190
  consoleSurface: "POST /api/orders/create-fulfillment",
1037
1191
  annotationPolicy: NON_DESTRUCTIVE_MUTATION_ANNOTATION
1038
1192
  },
1193
+ "prepare-fulfillment-order": {
1194
+ category: "mutation-fulfillment",
1195
+ oauthScope: MCP_SCOPES.write,
1196
+ consoleRole: "tenant-admin",
1197
+ consoleSurface: "POST /api/fulfillment-orders/prepare-fulfillment-order",
1198
+ annotationPolicy: NON_DESTRUCTIVE_MUTATION_ANNOTATION
1199
+ },
1039
1200
  "update-fulfillment": {
1040
1201
  category: "mutation-fulfillment",
1041
1202
  oauthScope: MCP_SCOPES.write,
@@ -1662,22 +1823,13 @@ async function createOrder(params) {
1662
1823
  import { z as z7 } from "zod";
1663
1824
  var schema5 = {
1664
1825
  orderNumber: z7.string().min(1).describe("Order number (required)"),
1665
- status: z7.enum([
1666
- "pending",
1667
- "paid",
1668
- "failed",
1669
- "canceled",
1670
- "preparing",
1671
- "shipped",
1672
- "delivered",
1673
- "confirmed"
1674
- ]).describe(
1675
- "New operator-driven order status. The schema keeps SDK status values for compatibility, but the Console update endpoint rejects server-derived statuses (paid, canceled, returned, refunded); those must be set by payment/refund flows, and return-related statuses must be set via Return endpoints."
1826
+ status: z7.enum(["confirmed"]).describe(
1827
+ "Order confirmation status mutation. Shipping/display statuses are derived from fulfillment orders and shipments; financial/refund states are set by payment/refund flows."
1676
1828
  )
1677
1829
  };
1678
1830
  var metadata5 = {
1679
1831
  name: "update-order",
1680
- description: "Update operator-driven order status. Console accepts transitions such as paid\u2192preparing/shipped/delivered/confirmed and rejects server-derived payment/refund statuses such as paid, canceled, returned, and refunded; the MCP schema keeps SDK status values for compatibility.",
1832
+ description: "Confirm an order after delivery. Financial, fulfillment-order, shipment, return, and display statuses are explicit server-derived axes and are not writable through this tool.",
1681
1833
  annotations: {
1682
1834
  title: "Update order status",
1683
1835
  readOnlyHint: false,
@@ -1735,20 +1887,19 @@ async function checkout(params) {
1735
1887
  import { z as z9 } from "zod";
1736
1888
  var schema7 = {
1737
1889
  orderNumber: z9.string().min(1).describe("Order number (required)"),
1738
- carrier: z9.string().optional().describe("Shipping carrier name (optional)"),
1739
- trackingNumber: z9.string().optional().describe(
1740
- 'Tracking number (optional). Setting carrier + tracking triggers "shipped" status'
1741
- ),
1890
+ fulfillmentOrderId: z9.string().optional().describe("Fulfillment order ID to ship (optional)"),
1891
+ carrier: z9.string().min(1).optional().describe("Shipping carrier name"),
1892
+ trackingNumber: z9.string().min(1).optional().describe("Tracking number"),
1742
1893
  items: z9.array(
1743
1894
  z9.object({
1744
1895
  orderItem: z9.string().min(1).describe("Order item ID"),
1745
1896
  quantity: z9.number().int().positive().describe("Quantity to fulfill")
1746
1897
  })
1747
- ).describe("Array of items to fulfill (required)")
1898
+ ).optional().describe("Array of items to fulfill (optional)")
1748
1899
  };
1749
1900
  var metadata7 = {
1750
1901
  name: "create-fulfillment",
1751
- description: "Create a shipment/fulfillment for order items. Auto-updates order status (paid \u2192 preparing \u2192 shipped).",
1902
+ description: "Create a shipment for fulfillment order items. Tracking information can be supplied now or updated later with update-fulfillment.",
1752
1903
  annotations: {
1753
1904
  title: "Create fulfillment",
1754
1905
  readOnlyHint: false,
@@ -1758,6 +1909,7 @@ var metadata7 = {
1758
1909
  };
1759
1910
  async function createFulfillment({
1760
1911
  orderNumber,
1912
+ fulfillmentOrderId,
1761
1913
  carrier,
1762
1914
  trackingNumber,
1763
1915
  items
@@ -1766,8 +1918,9 @@ async function createFulfillment({
1766
1918
  const client = getClient();
1767
1919
  const result = await client.commerce.orders.createFulfillment({
1768
1920
  orderNumber,
1769
- carrier,
1770
- trackingNumber,
1921
+ fulfillmentOrderId,
1922
+ ...carrier ? { carrier } : {},
1923
+ ...trackingNumber ? { trackingNumber } : {},
1771
1924
  items
1772
1925
  });
1773
1926
  return toolSuccess({ data: result });
@@ -1776,23 +1929,48 @@ async function createFulfillment({
1776
1929
  }
1777
1930
  }
1778
1931
 
1779
- // src/tools/update-fulfillment.ts
1932
+ // src/tools/prepare-fulfillment-order.ts
1780
1933
  import { z as z10 } from "zod";
1781
1934
  var schema8 = {
1782
- fulfillmentId: z10.string().min(1).describe("Fulfillment ID (required)"),
1783
- status: z10.enum(["packed", "shipped", "delivered", "failed"]).describe(
1784
- "New fulfillment status (required). FSM: pending\u2192packed/shipped/failed, packed\u2192shipped/failed, shipped\u2192delivered/failed"
1785
- ),
1786
- carrier: z10.string().optional().describe(
1787
- "Shipping carrier (optional, changeable only in pending/packed status)"
1788
- ),
1789
- trackingNumber: z10.string().optional().describe(
1790
- "Tracking number (optional, changeable only in pending/packed status)"
1791
- )
1935
+ orderNumber: z10.string().min(1).describe("Order number (required)")
1792
1936
  };
1793
1937
  var metadata8 = {
1938
+ name: "prepare-fulfillment-order",
1939
+ description: "Prepare starts fulfillment work and does not require carrier/tracking.",
1940
+ annotations: {
1941
+ title: "Prepare fulfillment order",
1942
+ readOnlyHint: false,
1943
+ destructiveHint: false,
1944
+ idempotentHint: false
1945
+ }
1946
+ };
1947
+ async function prepareFulfillmentOrder({
1948
+ orderNumber
1949
+ }) {
1950
+ try {
1951
+ const client = getClient();
1952
+ const result = await client.commerce.orders.prepareFulfillmentOrder({
1953
+ orderNumber
1954
+ });
1955
+ return toolSuccess({ data: result });
1956
+ } catch (error) {
1957
+ return toolError(error);
1958
+ }
1959
+ }
1960
+
1961
+ // src/tools/update-fulfillment.ts
1962
+ import { z as z11 } from "zod";
1963
+ var schema9 = {
1964
+ fulfillmentId: z11.string().min(1).describe("Fulfillment ID (required)"),
1965
+ status: z11.enum(["shipped", "delivered", "failed"]).optional().describe(
1966
+ "New shipment status. Shipment lifecycle: shipped\u2192delivered/failed"
1967
+ ),
1968
+ carrier: z11.string().optional().describe("Shipping carrier (optional; can be added or corrected later)"),
1969
+ trackingNumber: z11.string().optional().describe("Tracking number (optional; can be added or corrected later)")
1970
+ };
1971
+ var metadata9 = {
1794
1972
  name: "update-fulfillment",
1795
- description: "Update fulfillment status, carrier, and tracking number. Auto-updates order status when all fulfillments are delivered.",
1973
+ description: "Update shipment status, carrier, or tracking number. Tracking can be added after shipment creation.",
1796
1974
  annotations: {
1797
1975
  title: "Update fulfillment",
1798
1976
  readOnlyHint: false,
@@ -1808,11 +1986,16 @@ async function updateFulfillment({
1808
1986
  }) {
1809
1987
  try {
1810
1988
  const client = getClient();
1989
+ if (status === void 0 && carrier === void 0 && trackingNumber === void 0) {
1990
+ return toolError(
1991
+ new Error("status, carrier, or trackingNumber is required")
1992
+ );
1993
+ }
1811
1994
  const result = await client.commerce.orders.updateFulfillment({
1812
1995
  fulfillmentId,
1813
- status,
1814
- carrier,
1815
- trackingNumber
1996
+ ...status ? { status } : {},
1997
+ ...carrier ? { carrier } : {},
1998
+ ...trackingNumber ? { trackingNumber } : {}
1816
1999
  });
1817
2000
  return toolSuccess({ data: result });
1818
2001
  } catch (error) {
@@ -1821,8 +2004,8 @@ async function updateFulfillment({
1821
2004
  }
1822
2005
 
1823
2006
  // src/tools/update-transaction.ts
1824
- var schema9 = UpdateTransactionSchema.shape;
1825
- var metadata9 = {
2007
+ var schema10 = UpdateTransactionSchema.shape;
2008
+ var metadata10 = {
1826
2009
  name: "update-transaction",
1827
2010
  description: "Update transaction status, payment method, and receipt URL.",
1828
2011
  annotations: {
@@ -1858,8 +2041,8 @@ async function updateTransaction({
1858
2041
  }
1859
2042
 
1860
2043
  // src/tools/confirm-payment.ts
1861
- var schema10 = ConfirmPaymentSchema.shape;
1862
- var metadata10 = {
2044
+ var schema11 = ConfirmPaymentSchema.shape;
2045
+ var metadata11 = {
1863
2046
  name: "confirm-payment",
1864
2047
  description: "Confirm a provider-verified ecommerce payment through the generic payment confirmation flow.",
1865
2048
  annotations: {
@@ -1886,10 +2069,10 @@ var CancelOrderToolSchema = CancelOrderSchema.extend({
1886
2069
  "Optional X-Idempotency-Key forwarded to the Console cancel endpoint"
1887
2070
  )
1888
2071
  }).strict();
1889
- var schema11 = CancelOrderToolSchema.shape;
1890
- var metadata11 = {
2072
+ var schema12 = CancelOrderToolSchema.shape;
2073
+ var metadata12 = {
1891
2074
  name: "cancel-order",
1892
- description: "Cancel an eligible pre-fulfillment order through the provider-verified cancellation flow. Paid captured orders are refunded before the local order moves to canceled; shipped, delivered, active-return, and fulfilled orders are rejected.",
2075
+ description: "Cancel an eligible order through the server-derived local cancellation flow. Paid captured orders move to canceled locally and require separate storefront PG refund resolution; preparation fulfillment orders are voided when no shipment exists, while shipped, delivered, active-return, and fulfilled orders are rejected.",
1893
2076
  annotations: {
1894
2077
  title: "Cancel order",
1895
2078
  readOnlyHint: false,
@@ -1914,20 +2097,8 @@ async function cancelOrder(params) {
1914
2097
  }
1915
2098
 
1916
2099
  // src/tools/create-return.ts
1917
- import { z as z11 } from "zod";
1918
- var schema12 = {
1919
- orderNumber: z11.string().min(1).describe("Order number (required)"),
1920
- reason: z11.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
1921
- reasonDetail: z11.string().optional().describe("Detailed reason text (optional)"),
1922
- returnItems: z11.array(
1923
- z11.object({
1924
- orderItem: z11.string().min(1).describe("Order item ID"),
1925
- quantity: z11.number().int().positive().describe("Quantity to return")
1926
- })
1927
- ).describe("Array of products to return (required)"),
1928
- refundAmount: z11.number().nonnegative().describe("Refund amount (required, min 0)")
1929
- };
1930
- var metadata12 = {
2100
+ var schema13 = CreateReturnSchema.shape;
2101
+ var metadata13 = {
1931
2102
  name: "create-return",
1932
2103
  description: "Create a return request for an order. Only works for delivered/confirmed orders. Updates order status to return_requested.",
1933
2104
  annotations: {
@@ -1942,7 +2113,10 @@ async function createReturn({
1942
2113
  reason,
1943
2114
  reasonDetail,
1944
2115
  returnItems,
1945
- refundAmount
2116
+ refundAmount,
2117
+ returnShippingFee,
2118
+ initialShippingRefundAmount,
2119
+ initialShippingRefundOverrideNote
1946
2120
  }) {
1947
2121
  try {
1948
2122
  const client = getClient();
@@ -1951,7 +2125,10 @@ async function createReturn({
1951
2125
  reason,
1952
2126
  reasonDetail,
1953
2127
  returnItems,
1954
- refundAmount
2128
+ refundAmount,
2129
+ returnShippingFee,
2130
+ initialShippingRefundAmount,
2131
+ initialShippingRefundOverrideNote
1955
2132
  });
1956
2133
  return toolSuccess({ data: result });
1957
2134
  } catch (error) {
@@ -1961,13 +2138,13 @@ async function createReturn({
1961
2138
 
1962
2139
  // src/tools/update-return.ts
1963
2140
  import { z as z12 } from "zod";
1964
- var schema13 = {
2141
+ var schema14 = {
1965
2142
  returnId: z12.string().min(1).describe("Return ID (required)"),
1966
2143
  status: z12.enum(["processing", "approved", "rejected", "completed"]).describe(
1967
2144
  "New operator-driven return status (required). The schema keeps SDK status values for compatibility, but Console accepts only requested\u2192processing/rejected and processing\u2192approved/rejected here; completed is server-derived and must be set by return-with-refund."
1968
2145
  )
1969
2146
  };
1970
- var metadata13 = {
2147
+ var metadata14 = {
1971
2148
  name: "update-return",
1972
2149
  description: "Update operator-driven return status with FSM validation. Rejection can restore the order flow; completion and inventory restoration are handled by return-with-refund after provider-verified refund, while the MCP schema keeps SDK status values for compatibility.",
1973
2150
  annotations: {
@@ -1994,8 +2171,8 @@ async function updateReturn({
1994
2171
  }
1995
2172
 
1996
2173
  // src/tools/return-with-refund.ts
1997
- var schema14 = ReturnWithRefundSchema.shape;
1998
- var metadata14 = {
2174
+ var schema15 = ReturnWithRefundSchema.shape;
2175
+ var metadata15 = {
1999
2176
  name: "return-with-refund",
2000
2177
  description: "Combined provider-verified return + refund operation. Creates a completed return, restores eligible stock, records the refund transaction, and advances the order to the returned state.",
2001
2178
  annotations: {
@@ -2012,6 +2189,8 @@ async function returnWithRefund({
2012
2189
  returnItems,
2013
2190
  refundAmount,
2014
2191
  returnShippingFee,
2192
+ initialShippingRefundAmount,
2193
+ initialShippingRefundOverrideNote,
2015
2194
  pgPaymentId,
2016
2195
  paymentKey,
2017
2196
  refundReceiptUrl
@@ -2025,6 +2204,8 @@ async function returnWithRefund({
2025
2204
  returnItems,
2026
2205
  refundAmount,
2027
2206
  returnShippingFee,
2207
+ initialShippingRefundAmount,
2208
+ initialShippingRefundOverrideNote,
2028
2209
  pgPaymentId,
2029
2210
  paymentKey,
2030
2211
  refundReceiptUrl
@@ -2038,14 +2219,14 @@ async function returnWithRefund({
2038
2219
 
2039
2220
  // src/tools/add-cart-item.ts
2040
2221
  import { z as z13 } from "zod";
2041
- var schema15 = {
2222
+ var schema16 = {
2042
2223
  cartId: z13.string().min(1).describe("Cart ID (required)"),
2043
2224
  product: z13.string().min(1).describe("Product ID (required)"),
2044
2225
  variant: z13.string().min(1).describe("Product variant ID (required)"),
2045
2226
  option: z13.string().min(1).describe("Product option ID (required)"),
2046
2227
  quantity: z13.number().int().positive().describe("Quantity to add (required, positive integer)")
2047
2228
  };
2048
- var metadata15 = {
2229
+ var metadata16 = {
2049
2230
  name: "add-cart-item",
2050
2231
  description: "Add a product to cart. Validates stock, merges quantity if item already exists, recalculates totals.",
2051
2232
  annotations: {
@@ -2079,11 +2260,11 @@ async function addCartItem({
2079
2260
 
2080
2261
  // src/tools/update-cart-item.ts
2081
2262
  import { z as z14 } from "zod";
2082
- var schema16 = {
2263
+ var schema17 = {
2083
2264
  cartItemId: z14.string().min(1).describe("Cart item ID (required)"),
2084
2265
  quantity: z14.number().int().positive().describe("New quantity (required, positive integer)")
2085
2266
  };
2086
- var metadata16 = {
2267
+ var metadata17 = {
2087
2268
  name: "update-cart-item",
2088
2269
  description: "Update cart item quantity. Validates stock availability, recalculates cart totals.",
2089
2270
  annotations: {
@@ -2108,10 +2289,10 @@ async function updateCartItem({
2108
2289
 
2109
2290
  // src/tools/remove-cart-item.ts
2110
2291
  import { z as z15 } from "zod";
2111
- var schema17 = {
2292
+ var schema18 = {
2112
2293
  cartItemId: z15.string().min(1).describe("Cart item ID to remove (required)")
2113
2294
  };
2114
- var metadata17 = {
2295
+ var metadata18 = {
2115
2296
  name: "remove-cart-item",
2116
2297
  description: "Remove an item from cart. Recalculates cart totals after removal.",
2117
2298
  annotations: {
@@ -2135,11 +2316,11 @@ async function removeCartItem({
2135
2316
 
2136
2317
  // src/tools/apply-discount.ts
2137
2318
  import { z as z16 } from "zod";
2138
- var schema18 = {
2319
+ var schema19 = {
2139
2320
  cartId: z16.string().min(1).describe("Cart ID (required)"),
2140
2321
  discountCode: z16.string().describe("Discount code to apply (required)")
2141
2322
  };
2142
- var metadata18 = {
2323
+ var metadata19 = {
2143
2324
  name: "apply-discount",
2144
2325
  description: "Apply a discount code to a cart. Validates the code, updates cart totals, and sets free shipping if applicable.",
2145
2326
  annotations: {
@@ -2164,10 +2345,10 @@ async function applyDiscount({
2164
2345
 
2165
2346
  // src/tools/remove-discount.ts
2166
2347
  import { z as z17 } from "zod";
2167
- var schema19 = {
2348
+ var schema20 = {
2168
2349
  cartId: z17.string().min(1).describe("Cart ID (required)")
2169
2350
  };
2170
- var metadata19 = {
2351
+ var metadata20 = {
2171
2352
  name: "remove-discount",
2172
2353
  description: "Remove the applied discount code from a cart and recalculate totals.",
2173
2354
  annotations: {
@@ -2191,10 +2372,10 @@ async function removeDiscount({
2191
2372
 
2192
2373
  // src/tools/clear-cart.ts
2193
2374
  import { z as z18 } from "zod";
2194
- var schema20 = {
2375
+ var schema21 = {
2195
2376
  cartId: z18.string().min(1).describe("Cart ID (required)")
2196
2377
  };
2197
- var metadata20 = {
2378
+ var metadata21 = {
2198
2379
  name: "clear-cart",
2199
2380
  description: "Remove all items from a cart, reset discount and amounts. Shipping fee is preserved.",
2200
2381
  annotations: {
@@ -2218,11 +2399,11 @@ async function clearCart({
2218
2399
 
2219
2400
  // src/tools/validate-discount.ts
2220
2401
  import { z as z19 } from "zod";
2221
- var schema21 = {
2402
+ var schema22 = {
2222
2403
  code: z19.string().describe("Discount code to validate (required)"),
2223
2404
  orderAmount: z19.number().describe("Order amount for validation (required)")
2224
2405
  };
2225
- var metadata21 = {
2406
+ var metadata22 = {
2226
2407
  name: "validate-discount",
2227
2408
  description: "Validate a discount code. Checks active status, date range, usage limits, minimum order amount, and calculates discount.",
2228
2409
  annotations: {
@@ -2250,12 +2431,12 @@ async function validateDiscount({
2250
2431
 
2251
2432
  // src/tools/calculate-shipping.ts
2252
2433
  import { z as z20 } from "zod";
2253
- var schema22 = {
2434
+ var schema23 = {
2254
2435
  shippingPolicyId: z20.string().optional().describe("Shipping policy ID (uses default policy if omitted)"),
2255
2436
  orderAmount: z20.number().describe("Order amount for fee calculation (required)"),
2256
2437
  postalCode: z20.string().optional().describe("Postal code for Jeju surcharge detection (63000-63644)")
2257
2438
  };
2258
- var metadata22 = {
2439
+ var metadata23 = {
2259
2440
  name: "calculate-shipping",
2260
2441
  description: "Calculate shipping fee based on order amount and postal code. Supports free shipping threshold and Jeju surcharge.",
2261
2442
  annotations: {
@@ -2285,7 +2466,7 @@ async function calculateShipping({
2285
2466
 
2286
2467
  // src/tools/stock-check.ts
2287
2468
  import { z as z21 } from "zod";
2288
- var schema23 = {
2469
+ var schema24 = {
2289
2470
  items: z21.array(
2290
2471
  z21.object({
2291
2472
  variantId: z21.string().describe("Product variant ID"),
@@ -2295,7 +2476,7 @@ var schema23 = {
2295
2476
  "Array of items to check stock for (required, max 100). Each: { variantId, quantity }"
2296
2477
  )
2297
2478
  };
2298
- var metadata23 = {
2479
+ var metadata24 = {
2299
2480
  name: "stock-check",
2300
2481
  description: "Batch check product option stock availability. Returns per-item availability and an allAvailable flag.",
2301
2482
  annotations: {
@@ -2319,11 +2500,11 @@ async function stockCheck({
2319
2500
 
2320
2501
  // src/tools/product-detail.ts
2321
2502
  import { z as z22 } from "zod";
2322
- var schema24 = {
2503
+ var schema25 = {
2323
2504
  slug: z22.string().optional().describe("Product slug (one of slug or id required)"),
2324
2505
  id: z22.string().optional().describe("Product id (one of slug or id required)")
2325
2506
  };
2326
- var metadata24 = {
2507
+ var metadata25 = {
2327
2508
  name: "product-detail",
2328
2509
  description: "Fetch full product detail by slug or id. Returns one resolver-ready product with variants, option slugs, option value slugs/media, brand, categories, tags, images, videos, and listing rollup, or found:false with a reason if missing/unpublished/feature disabled. Permission/auth errors still throw.",
2329
2510
  annotations: {
@@ -2351,7 +2532,7 @@ async function productDetail({
2351
2532
  }
2352
2533
 
2353
2534
  // src/tools/product-upsert.ts
2354
- var schema25 = {
2535
+ var schema26 = {
2355
2536
  productId: ProductUpsertObjectSchema.shape.productId.describe(
2356
2537
  "Existing product id for graph-only updates. Prefer this for an existing product on edit after loading GET /api/products/:id/composer-draft."
2357
2538
  ),
@@ -2368,7 +2549,7 @@ var schema25 = {
2368
2549
  "Full desired variant graph. On edit, omitted variants are deleted or deactivated according to server references. Prefer stable option-value IDs."
2369
2550
  )
2370
2551
  };
2371
- var metadata25 = {
2552
+ var metadata26 = {
2372
2553
  name: "product-upsert",
2373
2554
  description: "Create a product or update an existing product graph. Existing products should load composer-draft first, send productId plus graphRevision, and include the full desired options/variants graph.",
2374
2555
  annotations: {
@@ -2409,8 +2590,8 @@ async function getCollectionSchema(collection) {
2409
2590
  }
2410
2591
 
2411
2592
  // src/tools/get-collection-schema.ts
2412
- var schema26 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
2413
- var metadata26 = {
2593
+ var schema27 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
2594
+ var metadata27 = {
2414
2595
  name: "get-collection-schema",
2415
2596
  description: "Get the authoritative tenant-aware collection schema from console. Use this before create/update to understand writable fields, hidden fields, required metadata, and collection-level visibility.",
2416
2597
  annotations: {
@@ -2461,8 +2642,8 @@ async function getTenantFeatureProgress(feature, includeEvidence = false) {
2461
2642
  }
2462
2643
 
2463
2644
  // src/tools/get-tenant-context.ts
2464
- var schema27 = tenantContextToolInputSchema.shape;
2465
- var metadata27 = {
2645
+ var schema28 = tenantContextToolInputSchema.shape;
2646
+ var metadata28 = {
2466
2647
  name: "get-tenant-context",
2467
2648
  description: "Get current tenant features, active collections, and field visibility. Call this at the start of every session. Use includeCounts=true to also get per-collection document counts for setup diagnostics.",
2468
2649
  annotations: {
@@ -2539,8 +2720,8 @@ async function handler({
2539
2720
  }
2540
2721
 
2541
2722
  // src/tools/check-feature-progress.ts
2542
- var schema28 = tenantFeatureProgressInputSchema.shape;
2543
- var metadata28 = {
2723
+ var schema29 = tenantFeatureProgressInputSchema.shape;
2724
+ var metadata29 = {
2544
2725
  name: "check-feature-progress",
2545
2726
  description: "Check tenant implementation progress for a supported feature. Start with feature=ecommerce to inspect catalog, cart, checkout, payment result, webhook, and operations readiness without mutating tenant data.",
2546
2727
  annotations: {
@@ -2586,12 +2767,12 @@ function invalidateFieldConfigCache() {
2586
2767
  }
2587
2768
 
2588
2769
  // src/tools/list-configurable-fields.ts
2589
- var schema29 = {
2770
+ var schema30 = {
2590
2771
  collection: z23.string().optional().describe(
2591
2772
  "Filter by collection slug (optional \u2014 returns all if omitted). Use this filter to reduce response size when you know which collection to check."
2592
2773
  )
2593
2774
  };
2594
- var metadata29 = {
2775
+ var metadata30 = {
2595
2776
  name: "list-configurable-fields",
2596
2777
  description: "List all configurable fields for tenant collections with current visibility state. Shows which fields can be shown/hidden and their current status. Returns all collections including inactive features \u2014 cross-reference with get-tenant-context for active features. Response includes ~300 fields across 47 collections \u2014 use collection filter when possible.",
2597
2778
  annotations: {
@@ -2623,7 +2804,7 @@ async function listConfigurableFields(params) {
2623
2804
 
2624
2805
  // src/tools/update-field-config.ts
2625
2806
  import { z as z24 } from "zod";
2626
- var schema30 = {
2807
+ var schema31 = {
2627
2808
  collection: z24.string().min(1).describe("Collection slug (required)"),
2628
2809
  hiddenFields: z24.array(z24.string().min(1).max(200)).max(300).describe(
2629
2810
  "Fields to hide (required). This is a FULL REPLACE \u2014 fields NOT in this list will be shown. Pass [] to show all fields. Use list-configurable-fields first to see available field paths."
@@ -2632,7 +2813,7 @@ var schema30 = {
2632
2813
  "Hide the entire collection from Admin Panel (optional). When true, individual hiddenFields are irrelevant."
2633
2814
  )
2634
2815
  };
2635
- var metadata30 = {
2816
+ var metadata31 = {
2636
2817
  name: "update-field-config",
2637
2818
  description: "Update field visibility configuration for a tenant collection. Hidden fields are removed from the Admin Panel UI. IMPORTANT: hiddenFields is a full replace, not a merge. Always call list-configurable-fields first to see current state.",
2638
2819
  annotations: {
@@ -3101,7 +3282,7 @@ function getRecipe(goal, runtime = "both") {
3101
3282
  }
3102
3283
 
3103
3284
  // src/tools/sdk-get-recipe.ts
3104
- var schema31 = {
3285
+ var schema32 = {
3105
3286
  goal: z25.enum([
3106
3287
  "fetch-list",
3107
3288
  "fetch-by-id",
@@ -3118,7 +3299,7 @@ var schema31 = {
3118
3299
  collection: z25.string().optional().describe("Specific collection name if applicable"),
3119
3300
  includeExample: z25.boolean().default(true).describe("Whether to include a full code example")
3120
3301
  };
3121
- var metadata31 = {
3302
+ var metadata32 = {
3122
3303
  name: "sdk-get-recipe",
3123
3304
  description: "Get a complete SDK code recipe for a specific task. Returns recommended approach, code example, and related documentation links. Use this FIRST when the user asks how to do something with the SDK.",
3124
3305
  annotations: {
@@ -3299,9 +3480,16 @@ var docIndex = [
3299
3480
  "order",
3300
3481
  "orderChanged",
3301
3482
  "collection.orderChanged",
3302
- "isOrderChangedWebhookEvent"
3483
+ "isOrderChangedWebhookEvent",
3484
+ "commerce.notification",
3485
+ "createCommerceNotificationWebhookHandler",
3486
+ "createCommerceEmailWebhookHandler",
3487
+ "orderCanceled",
3488
+ "resolveCancelRefund",
3489
+ "cancel refund",
3490
+ "external PG refund"
3303
3491
  ],
3304
- summary: "Tenant webhooks deliver signed server-to-server events via WEBHOOK_SECRET, including customer password reset and semantic order changes with collection.orderChanged / isOrderChangedWebhookEvent.",
3492
+ summary: "Tenant webhooks deliver signed server-to-server events via WEBHOOK_SECRET, including customer password reset, semantic order changes, and commerce.notification workers with createCommerceNotificationWebhookHandler for orderCanceled refund handoff.",
3305
3493
  resourceUri: "docs://sdk/webhook"
3306
3494
  },
3307
3495
  // Order API
@@ -3313,8 +3501,8 @@ var docIndex = [
3313
3501
  },
3314
3502
  {
3315
3503
  title: "Order API \u2014 Fulfillment and Shipping",
3316
- keywords: ["fulfillment", "shipping", "tracking", "carrier", "trackingNumber", "createFulfillment", "updateFulfillment", "shipped", "delivered"],
3317
- summary: "client.commerce.orders.createFulfillment({ orderNumber, items, carrier?, trackingNumber? }) creates a shipment. updateFulfillment() advances fulfillment status.",
3504
+ keywords: ["fulfillment", "shipping", "tracking", "carrier", "trackingNumber", "prepareFulfillmentOrder", "createFulfillment", "updateFulfillment", "shipped", "delivered"],
3505
+ summary: "client.commerce.orders.prepareFulfillmentOrder({ orderNumber }) starts fulfillment work. createFulfillment({ orderNumber, ... }) creates a shipment with optional tracking. updateFulfillment() advances shipment status or updates tracking.",
3318
3506
  resourceUri: "docs://sdk/server-api"
3319
3507
  },
3320
3508
  {
@@ -3347,11 +3535,11 @@ function searchDocs(query, limit = 5) {
3347
3535
  }
3348
3536
 
3349
3537
  // src/tools/sdk-search-docs.ts
3350
- var schema32 = {
3538
+ var schema33 = {
3351
3539
  query: z26.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
3352
3540
  limit: z26.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
3353
3541
  };
3354
- var metadata32 = {
3542
+ var metadata33 = {
3355
3543
  name: "sdk-search-docs",
3356
3544
  description: "Search SDK documentation by keyword. Returns matching topics with summaries and resource links. Use when looking for specific SDK features or patterns.",
3357
3545
  annotations: {
@@ -3387,7 +3575,7 @@ function handler4({
3387
3575
 
3388
3576
  // src/tools/sdk-get-auth-setup.ts
3389
3577
  import { z as z27 } from "zod";
3390
- var schema33 = {
3578
+ var schema34 = {
3391
3579
  scenario: z27.enum([
3392
3580
  "browser-client",
3393
3581
  "server-client",
@@ -3397,7 +3585,7 @@ var schema33 = {
3397
3585
  "webhook-verification"
3398
3586
  ]).describe("Authentication scenario")
3399
3587
  };
3400
- var metadata33 = {
3588
+ var metadata34 = {
3401
3589
  name: "sdk-get-auth-setup",
3402
3590
  description: "Get the current authentication setup for a specific scenario. Returns env var names, code snippets, and security notes.",
3403
3591
  annotations: {
@@ -3561,12 +3749,12 @@ function handler5({
3561
3749
  // src/tools/sdk-get-collection-pattern.ts
3562
3750
  import { z as z28 } from "zod";
3563
3751
  import { COLLECTIONS, SERVER_COLLECTIONS as SERVER_COLLECTIONS4 } from "@01.software/sdk";
3564
- var schema34 = {
3752
+ var schema35 = {
3565
3753
  collection: z28.enum(SERVER_COLLECTIONS4).describe("Collection name"),
3566
3754
  operation: z28.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
3567
3755
  surface: z28.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
3568
3756
  };
3569
- var metadata34 = {
3757
+ var metadata35 = {
3570
3758
  name: "sdk-get-collection-pattern",
3571
3759
  description: "Get the recommended CRUD pattern for a specific collection. Returns code examples for the chosen API surface and operation type.",
3572
3760
  annotations: {
@@ -3763,13 +3951,13 @@ function handler6({
3763
3951
 
3764
3952
  // src/prompts/sdk-usage-guide.ts
3765
3953
  import { z as z29 } from "zod";
3766
- var schema35 = {
3954
+ var schema36 = {
3767
3955
  goal: z29.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
3768
3956
  runtime: z29.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
3769
3957
  surface: z29.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
3770
3958
  collection: z29.string().optional().describe("Specific collection if relevant")
3771
3959
  };
3772
- var metadata35 = {
3960
+ var metadata36 = {
3773
3961
  name: "sdk-usage-guide",
3774
3962
  title: "SDK Usage Guide",
3775
3963
  description: "Provides guidance on how to perform a specific task using the 01.software SDK",
@@ -3943,12 +4131,12 @@ const { allAvailable } = await client.commerce.product.stockCheck({
3943
4131
  // src/prompts/collection-query-help.ts
3944
4132
  import { z as z30 } from "zod";
3945
4133
  import { COLLECTIONS as COLLECTIONS2, SERVER_COLLECTIONS as SERVER_COLLECTIONS5 } from "@01.software/sdk";
3946
- var schema36 = {
4134
+ var schema37 = {
3947
4135
  collection: z30.enum(SERVER_COLLECTIONS5).describe("Collection name"),
3948
4136
  operation: z30.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
3949
4137
  filters: z30.string().optional().describe("Filter conditions (JSON string, optional)")
3950
4138
  };
3951
- var metadata36 = {
4139
+ var metadata37 = {
3952
4140
  name: "collection-query-help",
3953
4141
  title: "Collection Query Help",
3954
4142
  description: "Provides guidance on how to write queries for a specific collection",
@@ -4046,7 +4234,7 @@ ${operation === "find" ? `- Use \`where\` option for filtering (Payload query sy
4046
4234
 
4047
4235
  // src/prompts/order-flow-guide.ts
4048
4236
  import { z as z31 } from "zod";
4049
- var schema37 = {
4237
+ var schema38 = {
4050
4238
  scenario: z31.enum([
4051
4239
  "simple-order",
4052
4240
  "cart-checkout",
@@ -4055,7 +4243,7 @@ var schema37 = {
4055
4243
  "fulfillment-tracking"
4056
4244
  ]).describe("Order flow scenario")
4057
4245
  };
4058
- var metadata37 = {
4246
+ var metadata38 = {
4059
4247
  name: "order-flow-guide",
4060
4248
  title: "Order Flow Guide",
4061
4249
  description: "Provides step-by-step guidance for ecommerce order flows including creation, checkout, returns, and fulfillment.",
@@ -4075,10 +4263,16 @@ var SCENARIOS = {
4075
4263
  - Successful confirmation transitions the order to \`paid\`
4076
4264
  - Paid orders reserve sellable quantity (reservedStock += qty); physical stock is decremented on delivery
4077
4265
 
4078
- 3. **Fulfillment** \u2192 \`create-fulfillment\` tool
4079
- - Provide carrier + trackingNumber for shipped status
4080
- - Partial shipment \u2192 order becomes \`preparing\`
4081
- - All items shipped \u2192 order becomes \`shipped\`
4266
+ 3. **Prepare Fulfillment Work** \u2192 \`prepare-fulfillment-order\` tool
4267
+ - Provide orderNumber only
4268
+ - Starts fulfillment-order work without carrier/tracking
4269
+ - Order display status is derived as \`preparing\`
4270
+
4271
+ 4. **Create Shipment** \u2192 \`create-fulfillment\` tool
4272
+ - Provide orderNumber
4273
+ - Optional: carrier + trackingNumber can be supplied now or later
4274
+ - Shipment status starts as \`shipped\`
4275
+ - Shipment state drives the derived order display status
4082
4276
 
4083
4277
  ### Code Example (ServerClient)
4084
4278
  \`\`\`typescript
@@ -4109,7 +4303,12 @@ await client.commerce.orders.confirmPayment({
4109
4303
  confirmationSource: 'provider_api_confirm'
4110
4304
  })
4111
4305
 
4112
- // 3. Ship items
4306
+ // 3. Start fulfillment work without tracking
4307
+ await client.commerce.orders.prepareFulfillmentOrder({
4308
+ orderNumber: 'ORD-240101-001'
4309
+ })
4310
+
4311
+ // 4. Ship items; tracking can be added now or later
4113
4312
  await client.commerce.orders.createFulfillment({
4114
4313
  orderNumber: 'ORD-240101-001',
4115
4314
  carrier: 'cj',
@@ -4166,7 +4365,7 @@ const order = await client.commerce.orders.checkout({
4166
4365
  - Requires pgPaymentId and paymentKey for provider-verified refund
4167
4366
 
4168
4367
  ### Key Points
4169
- - Full refund: original transaction \u2192 \`canceled\`
4368
+ - Full refund: original transaction \u2192 \`canceled\` (**return-with-refund only**; order-cancel does NOT cancel the transaction \u2014 it stays \`paid\` until the storefront PG refund resolves it)
4170
4369
  - Partial refund: new refund transaction created
4171
4370
  - Stock restored: stock += qty, reservedStock -= qty
4172
4371
  - Cumulative refunds tracked: refundAmount + order.refundedAmount \u2264 totalAmount
@@ -4185,23 +4384,25 @@ await client.commerce.orders.returnWithRefund({
4185
4384
  paymentKey: 'payment_key_xxx'
4186
4385
  })
4187
4386
  \`\`\``,
4188
- "order-cancel": `## Provider-Verified Order Cancellation
4387
+ "order-cancel": `## Local Order Cancellation (PG refund separate)
4189
4388
 
4190
4389
  ### Flow
4191
4390
 
4192
4391
  1. **Cancel Order** -> \`cancel-order\` tool
4193
- - Pending or failed unpaid orders cancel without a provider call
4194
- - Paid captured orders use the server-stored provider payment key from the captured transaction
4195
- - Paid captured orders are refunded through the provider-verified path before local status changes
4196
- - Successful paid cancellation releases reservedStock and moves the order to \`canceled\`
4197
- - Duplicate local success returns \`alreadyCanceled: true\`; do not issue a second refund
4198
- - Provider-refunded local blockers return \`reconciliationRequired: true\` on retry
4392
+ - Pending or failed unpaid orders cancel locally without a PG call
4393
+ - Paid captured orders cancel **locally only**: order \`canceled\`, payment transaction stays \`paid\`, reservedStock released
4394
+ - **PG refund is not performed by Console** \u2014 storefront/BFF calls Toss/Portone; webhook sync is a follow-up
4395
+ - \`refundedAmount\` is not incremented on local cancel; new cancels return \`providerRefunded: false\`
4396
+ - \`refundPending: true\` signals storefront PG refund is still required; idempotent retries may return it from server metadata
4397
+ - \`in_progress\` / \`on_hold\` preparation fulfillment orders are voided during cancel when no shipment exists
4398
+ - Legacy inline-PG-cancel rows may still return \`reconciliationRequired: true\` with \`providerRefunded: true\`
4399
+ - Duplicate local success returns \`alreadyCanceled: true\`
4199
4400
 
4200
4401
  ### V1 Rejections
4201
- - Orders with non-failed fulfillments are rejected
4402
+ - Orders with active fulfillments (not \`failed\` / \`canceled\`) are rejected
4202
4403
  - \`shipped\`, \`delivered\`, \`confirmed\`, and return-axis orders are rejected
4203
4404
  - Active returns are rejected; use \`return-with-refund\` after delivery
4204
- - Partial line-item cancellation and no-refund paid cancellation are not supported in v1
4405
+ - Partial line-item cancellation is not supported in v1
4205
4406
 
4206
4407
  ### Code Example
4207
4408
  \`\`\`typescript
@@ -4213,36 +4414,78 @@ await client.commerce.orders.cancelOrder({
4213
4414
  })
4214
4415
  \`\`\`
4215
4416
 
4216
- If \`reconciliationRequired\` is true, stop provider retries and hand off to an operator to reconcile fulfillment, stock, and accounting manually.`,
4417
+ ### Storefront PG refund (BFF only)
4418
+
4419
+ After \`cancelOrder\`, initiate PG refund **only when all of the following hold**:
4420
+
4421
+ - First response: \`cancelCommitted: true\` **and** \`refundPending: true\`
4422
+ - Idempotent retry: \`alreadyCanceled: true\` **and** \`refundPending: true\` (read from server metadata)
4423
+ - PG lookup confirms the payment is still captured / not yet refunded
4424
+
4425
+ **Never** call PG refund when:
4426
+
4427
+ - \`providerRefunded: true\` (legacy inline-PG-cancel or refund already recorded)
4428
+ - \`reconciliationRequired: true\` (escalate to ops \u2014 do not auto-refund)
4429
+ - \`refundPending\` is absent on an unpaid / never-captured order
4430
+
4431
+ Prefer persisting the first \`cancelOrder\` response; use PG \`getPayment\` before refund when state is uncertain.
4432
+
4433
+ After a PG refund attempt reaches a terminal result, report that exact result back to Console. This is a BFF/server-only operation and requires an \`sk01_\` server API key.
4434
+
4435
+ \`\`\`typescript
4436
+ await client.commerce.orders.resolveCancelRefund({
4437
+ orderNumber: 'ORD-240101-001',
4438
+ idempotencyKey: 'refund-cancel-ORD-240101-001-attempt-1',
4439
+ outcome: 'succeeded',
4440
+ refundedAmount: 59800,
4441
+ pgProvider: 'toss',
4442
+ pgRefundId: 'toss-refund-abc'
4443
+ })
4444
+ \`\`\`
4445
+
4446
+ Use one idempotency key per distinct PG refund attempt/result. For PG refund failure, call \`resolveCancelRefund({ outcome: 'failed', refundedAmount: 0, ... })\` with that attempt key. If a later PG attempt succeeds after a reported failure, use a new key such as \`refund-cancel-ORD-240101-001-attempt-2\`. Reuse the exact same \`idempotencyKey\` only for transport retries of the same reported result; never reuse it for a different order, outcome, provider, amount, or provider refund id.`,
4217
4447
  "fulfillment-tracking": `## Fulfillment & Tracking
4218
4448
 
4219
4449
  ### Creating Fulfillment
4220
- 1. **Create Fulfillment** \u2192 \`create-fulfillment\` tool
4221
- - Order must be \`paid\` or \`preparing\`
4222
- - With carrier + trackingNumber \u2192 fulfillment status = \`shipped\`
4223
- - Without \u2192 fulfillment status = \`pending\`
4450
+ 1. **Prepare Fulfillment Work** \u2192 \`prepare-fulfillment-order\` tool
4451
+ - Order must be paid and fulfillable
4452
+ - Provide orderNumber only
4453
+ - No carrier/tracking is required
4454
+ - Fulfillment order status becomes \`in_progress\`
4455
+
4456
+ 2. **Create Shipment** \u2192 \`create-fulfillment\` tool
4457
+ - Provide orderNumber
4458
+ - Optional: carrier and trackingNumber can be supplied now or updated later
4459
+ - Optional: fulfillmentOrderId and item quantities for partial shipments
4460
+ - Shipment status starts as \`shipped\`
4224
4461
 
4225
4462
  ### Updating Fulfillment
4226
- 2. **Update** \u2192 \`update-fulfillment\` tool
4227
- - FSM: pending \u2192 packed \u2192 shipped \u2192 delivered (terminal)
4228
- - Or: pending/packed/shipped \u2192 failed (terminal)
4229
- - Carrier/trackingNumber changeable only in pending/packed status
4463
+ 3. **Update Shipment** \u2192 \`update-fulfillment\` tool
4464
+ - Shipment lifecycle: shipped \u2192 delivered
4465
+ - Or: shipped \u2192 failed
4466
+ - Carrier/trackingNumber can be added or corrected after shipment creation
4230
4467
 
4231
4468
  ### Auto Timestamps
4232
4469
  - \`shipped\` \u2192 sets \`shippedAt\`
4233
4470
  - \`delivered\` \u2192 sets \`deliveredAt\`
4234
4471
 
4235
- ### Order Auto-sync
4236
- - All items shipped with carrier \u2192 order \`shipped\`
4237
- - Partial shipment \u2192 order \`preparing\`
4238
- - All non-failed fulfillments delivered \u2192 order \`delivered\`
4472
+ ### Order Display Projection
4473
+ - \`preparing\` is derived from active fulfillment-order work
4474
+ - \`shipped\` is derived from active shipment rows
4475
+ - \`delivered\` is derived only after all active shipments are delivered
4476
+ - \`confirmed\` is set through \`update-order\` after delivery
4239
4477
 
4240
4478
  ### Carriers
4241
4479
  cj, hanjin, lotte, epost, logen, other
4242
4480
 
4243
4481
  ### Code Example
4244
4482
  \`\`\`typescript
4245
- // Create fulfillment with tracking
4483
+ // Prepare fulfillment work first
4484
+ await client.commerce.orders.prepareFulfillmentOrder({
4485
+ orderNumber: 'ORD-240101-001'
4486
+ })
4487
+
4488
+ // Create shipment; carrier/tracking are optional
4246
4489
  await client.commerce.orders.createFulfillment({
4247
4490
  orderNumber: 'ORD-240101-001',
4248
4491
  carrier: 'cj',
@@ -4250,6 +4493,13 @@ await client.commerce.orders.createFulfillment({
4250
4493
  items: [{ orderItem: 'oi-id', quantity: 2 }]
4251
4494
  })
4252
4495
 
4496
+ // Add or update tracking later
4497
+ await client.commerce.orders.updateFulfillment({
4498
+ fulfillmentId: 'ful-id',
4499
+ carrier: 'cj',
4500
+ trackingNumber: '1234567890'
4501
+ })
4502
+
4253
4503
  // Mark as delivered
4254
4504
  await client.commerce.orders.updateFulfillment({
4255
4505
  fulfillmentId: 'ful-id',
@@ -4267,7 +4517,7 @@ ${SCENARIOS[scenario] || "Unknown scenario."}
4267
4517
  ## Related MCP Tools
4268
4518
  - \`create-order\`, \`get-order\`, \`update-order\`
4269
4519
  - \`checkout\`
4270
- - \`create-fulfillment\`, \`update-fulfillment\`
4520
+ - \`prepare-fulfillment-order\`, \`create-fulfillment\`, \`update-fulfillment\`
4271
4521
  - \`create-return\`, \`update-return\`, \`return-with-refund\`
4272
4522
  - \`confirm-payment\`, \`cancel-order\`, \`update-transaction\`
4273
4523
  - \`validate-discount\`, \`calculate-shipping\``;
@@ -4275,7 +4525,7 @@ ${SCENARIOS[scenario] || "Unknown scenario."}
4275
4525
 
4276
4526
  // src/prompts/feature-setup-guide.ts
4277
4527
  import { z as z32 } from "zod";
4278
- var schema38 = {
4528
+ var schema39 = {
4279
4529
  feature: z32.enum([
4280
4530
  "ecommerce",
4281
4531
  "customers",
@@ -4291,7 +4541,7 @@ var schema38 = {
4291
4541
  "community"
4292
4542
  ]).describe("Feature to get setup guide for")
4293
4543
  };
4294
- var metadata38 = {
4544
+ var metadata39 = {
4295
4545
  name: "feature-setup-guide",
4296
4546
  title: "Feature Setup Guide",
4297
4547
  description: "Setup checklist and remediation guide for a tenant feature. Load with check-feature-progress and get-tenant-context to diagnose setup gaps.",
@@ -4499,7 +4749,7 @@ ${FEATURES[feature] || "Unknown feature."}
4499
4749
  }
4500
4750
 
4501
4751
  // src/resources/(config)/app.ts
4502
- var metadata39 = {
4752
+ var metadata40 = {
4503
4753
  name: "app-config",
4504
4754
  title: "Application Config",
4505
4755
  description: "01.software SDK and MCP server configuration information"
@@ -4543,7 +4793,7 @@ The hosted HTTP MCP endpoint at https://mcp.01.software/mcp exposes only these O
4543
4793
  - \`sdk-get-auth-setup\` - Get framework-specific auth setup guidance
4544
4794
  - \`sdk-get-collection-pattern\` - Get collection-specific usage patterns
4545
4795
 
4546
- ## Local CLI Stdio Surface (33)
4796
+ ## Local CLI Stdio Surface (35)
4547
4797
 
4548
4798
  For trusted local server-key workflows, start the stdio server:
4549
4799
 
@@ -4565,7 +4815,7 @@ Rate limits depend on your tenant plan:
4565
4815
 
4566
4816
  // src/resources/(collections)/schema.ts
4567
4817
  import { COLLECTIONS as COLLECTIONS3 } from "@01.software/sdk";
4568
- var metadata40 = {
4818
+ var metadata41 = {
4569
4819
  name: "collections-schema",
4570
4820
  title: "Collection Schema Info",
4571
4821
  description: "Available collections and their schema information"
@@ -4702,7 +4952,7 @@ Total available collections: ${COLLECTIONS3.length}`;
4702
4952
  }
4703
4953
 
4704
4954
  // src/resources/(docs)/getting-started.ts
4705
- var metadata41 = {
4955
+ var metadata42 = {
4706
4956
  name: "docs-getting-started",
4707
4957
  title: "Getting Started",
4708
4958
  description: "01.software SDK getting started guide"
@@ -4763,7 +5013,7 @@ const result = await client.collections.from('products').find({
4763
5013
  }
4764
5014
 
4765
5015
  // src/resources/(docs)/guides.ts
4766
- var metadata42 = {
5016
+ var metadata43 = {
4767
5017
  name: "docs-guides",
4768
5018
  title: "Guides",
4769
5019
  description: "01.software SDK usage guides"
@@ -4976,7 +5226,7 @@ For more implementation guidance, see the [SDK Guide](/developers/sdk).`;
4976
5226
  }
4977
5227
 
4978
5228
  // src/resources/(docs)/api.ts
4979
- var metadata43 = {
5229
+ var metadata44 = {
4980
5230
  name: "docs-api",
4981
5231
  title: "API Reference",
4982
5232
  description: "01.software SDK API reference documentation"
@@ -5259,7 +5509,7 @@ For more details, see the [API documentation](/developers/api).`;
5259
5509
  }
5260
5510
 
5261
5511
  // src/resources/(docs)/query-builder.ts
5262
- var metadata44 = {
5512
+ var metadata45 = {
5263
5513
  name: "docs-query-builder",
5264
5514
  title: "Query Builder",
5265
5515
  description: "01.software SDK Query Builder API reference (client.collections.from)"
@@ -5412,6 +5662,33 @@ if (page1.hasNextPage) {
5412
5662
  }
5413
5663
  \`\`\`
5414
5664
 
5665
+ ## Join fields (\`joins\`)
5666
+
5667
+ Payload \`type: 'join'\` reverse-relations (e.g. \`products.variants\`, \`products.options\`) are **not** controlled by \`depth\`. When \`joins\` is omitted, each join field defaults to **limit 10** docs.
5668
+
5669
+ Storefront PLPs that query \`products\` with only \`depth\` and group client-side can silently drop color swatches when a product has more than 10 option values. Prefer \`commerce.product.listingGroupsCatalog()\` + \`buildProductListingCard()\`, or spread \`PRODUCT_PLP_FIND_OPTIONS\` from \`@01.software/sdk\` into raw \`find()\` calls.
5670
+
5671
+ \`\`\`typescript
5672
+ import { PRODUCT_PLP_FIND_OPTIONS } from '@01.software/sdk'
5673
+
5674
+ await client.collections.from('products').find({
5675
+ ...PRODUCT_PLP_FIND_OPTIONS,
5676
+ where: { status: { equals: 'published' } },
5677
+ limit: 24,
5678
+ })
5679
+
5680
+ // Or configure joins explicitly (tune limits to your catalog size):
5681
+ await client.collections.from('products').find({
5682
+ joins: {
5683
+ variants: { limit: 50, sort: '_order' },
5684
+ options: { limit: 30, sort: '_order' },
5685
+ },
5686
+ })
5687
+
5688
+ // Disable all join-field population for lightweight lists:
5689
+ await client.collections.from('products').find({ joins: false })
5690
+ \`\`\`
5691
+
5415
5692
  ## Sorting
5416
5693
 
5417
5694
  \`\`\`typescript
@@ -5453,7 +5730,7 @@ console.log(result.hasNextPage) // true
5453
5730
  }
5454
5731
 
5455
5732
  // src/resources/(docs)/react-query.ts
5456
- var metadata45 = {
5733
+ var metadata46 = {
5457
5734
  name: "docs-react-query",
5458
5735
  title: "React Query Hooks",
5459
5736
  description: "01.software SDK React Query hooks reference (@01.software/sdk/query)"
@@ -5685,7 +5962,7 @@ export function ProductList() {
5685
5962
  }
5686
5963
 
5687
5964
  // src/resources/(docs)/server-api.ts
5688
- var metadata46 = {
5965
+ var metadata47 = {
5689
5966
  name: "docs-server-api",
5690
5967
  title: "Server-side API",
5691
5968
  description: "01.software SDK server-side API reference (client.commerce) for orders, fulfillments, returns, carts, and validation"
@@ -5761,25 +6038,34 @@ const order = docs[0] ?? null
5761
6038
  \`\`\`
5762
6039
 
5763
6040
  ### updateOrder()
5764
- Update order status.
6041
+ Confirm an order after delivery. Financial and shipment/display statuses are server-derived.
5765
6042
 
5766
6043
  \`\`\`typescript
5767
6044
  const order = await client.commerce.orders.update({
5768
6045
  orderNumber: 'ORD-20240101-0001',
5769
- status: 'paid', // pending | paid | failed | canceled | preparing | shipped | delivered | confirmed
6046
+ status: 'confirmed',
5770
6047
  })
5771
6048
  \`\`\`
5772
6049
 
5773
6050
  ## Fulfillment API
5774
6051
 
6052
+ ### prepareFulfillmentOrder()
6053
+ Start fulfillment-order work without carrier or tracking.
6054
+
6055
+ \`\`\`typescript
6056
+ const result = await client.commerce.orders.prepareFulfillmentOrder({
6057
+ orderNumber: 'ORD-20240101-0001',
6058
+ })
6059
+ \`\`\`
6060
+
5775
6061
  ### createFulfillment()
5776
- Create a shipment record for order items.
6062
+ Create a shipment record for order items. Carrier and trackingNumber are optional and can be added later.
5777
6063
 
5778
6064
  \`\`\`typescript
5779
6065
  const fulfillment = await client.commerce.orders.createFulfillment({
5780
6066
  orderNumber: 'ORD-20240101-0001',
5781
- carrier?: 'cj', // cj | hanjin | lotte | epost | logen | other
5782
- trackingNumber?: '123456789012',
6067
+ carrier: 'cj', // optional: cj | hanjin | lotte | epost | logen | other
6068
+ trackingNumber: '123456789012', // optional
5783
6069
  items: [
5784
6070
  { orderItem: 'order-item-id', quantity: 2 }
5785
6071
  ],
@@ -5787,14 +6073,13 @@ const fulfillment = await client.commerce.orders.createFulfillment({
5787
6073
  \`\`\`
5788
6074
 
5789
6075
  ### updateFulfillment()
5790
- Update fulfillment status and optionally carrier/tracking.
6076
+ Update fulfillment status or tracking information.
5791
6077
 
5792
6078
  \`\`\`typescript
5793
6079
  const fulfillment = await client.commerce.orders.updateFulfillment({
5794
6080
  fulfillmentId: 'fulfillment-id',
5795
- status: 'delivered', // packed | shipped | delivered | failed
5796
- carrier?: 'cj',
5797
- trackingNumber?: '123456789012',
6081
+ carrier: 'cj',
6082
+ trackingNumber: '123456789012',
5798
6083
  })
5799
6084
  \`\`\`
5800
6085
 
@@ -5809,9 +6094,12 @@ const ret = await client.commerce.orders.createReturn({
5809
6094
  reason?: 'defective', // change_of_mind | defective | wrong_delivery | damaged | other
5810
6095
  reasonDetail?: 'Screen cracked on arrival',
5811
6096
  returnItems: [
5812
- { orderItem: 'order-item-id', quantity: 1 }
6097
+ { orderItem: 'order-item-id', quantity: 1, restockingFee?: 500 }
5813
6098
  ],
5814
6099
  refundAmount: 29900,
6100
+ returnShippingFee?: 1500,
6101
+ initialShippingRefundAmount?: 3000,
6102
+ initialShippingRefundOverrideNote?: 'Policy override note',
5815
6103
  })
5816
6104
  \`\`\`
5817
6105
 
@@ -5838,6 +6126,8 @@ const result = await client.commerce.orders.returnWithRefund({
5838
6126
  ],
5839
6127
  refundAmount: 29900,
5840
6128
  returnShippingFee?: 1500,
6129
+ initialShippingRefundAmount?: 3000,
6130
+ initialShippingRefundOverrideNote?: 'Policy override note',
5841
6131
  pgPaymentId: 'provider-payment-id', // required
5842
6132
  paymentKey: 'provider-payment-key', // required for provider refund
5843
6133
  refundReceiptUrl?: 'https://...',
@@ -5969,7 +6259,7 @@ const result = await client.commerce.shipping.calculate({
5969
6259
  }
5970
6260
 
5971
6261
  // src/resources/(docs)/customer-auth.ts
5972
- var metadata47 = {
6262
+ var metadata48 = {
5973
6263
  name: "docs-customer-auth",
5974
6264
  title: "Customer Auth API",
5975
6265
  description: "01.software SDK Customer Auth API reference (client.customer)"
@@ -6147,7 +6437,7 @@ async function loadProfile() {
6147
6437
  }
6148
6438
 
6149
6439
  // src/resources/(docs)/browser-vs-server.ts
6150
- var metadata48 = {
6440
+ var metadata49 = {
6151
6441
  name: "docs-browser-vs-server",
6152
6442
  title: "Client vs ServerClient",
6153
6443
  description: "When to use Client (createClient) vs ServerClient (createServerClient) in the 01.software SDK"
@@ -6313,7 +6603,7 @@ export function ProductList() {
6313
6603
  }
6314
6604
 
6315
6605
  // src/resources/(docs)/file-upload.ts
6316
- var metadata49 = {
6606
+ var metadata50 = {
6317
6607
  name: "docs-file-upload",
6318
6608
  title: "File Upload",
6319
6609
  description: "01.software SDK file upload patterns using the images collection"
@@ -6464,7 +6754,7 @@ The platform stores files in Cloudflare R2 and serves via CDN (\`cdn.01.software
6464
6754
  }
6465
6755
 
6466
6756
  // src/resources/(docs)/webhook.ts
6467
- var metadata50 = {
6757
+ var metadata51 = {
6468
6758
  name: "docs-webhook",
6469
6759
  title: "Webhooks",
6470
6760
  description: "01.software SDK webhook verification and event handling"
@@ -6533,8 +6823,8 @@ export async function POST(request: Request) {
6533
6823
 
6534
6824
  \`\`\`typescript
6535
6825
  import {
6826
+ createCommerceNotificationWebhookHandler,
6536
6827
  handleWebhook,
6537
- isCommerceNotificationWebhookEvent,
6538
6828
  } from '@01.software/sdk/webhook'
6539
6829
 
6540
6830
  function getWebhookSecret(): string {
@@ -6543,26 +6833,25 @@ function getWebhookSecret(): string {
6543
6833
  return secret
6544
6834
  }
6545
6835
 
6546
- export async function POST(request: Request) {
6547
- return handleWebhook(request, async (event) => {
6548
- if (!isCommerceNotificationWebhookEvent(event)) return
6549
-
6550
- const idempotencyKey = \`\${event.notification.intentId}:\${event.notification.dedupeKey}\`
6551
- const processed = await processOnce(idempotencyKey, async () => {
6552
- if (event.notification.event === 'orderPaid') {
6553
- const orderId = event.notification.orderId ?? event.data.orderId
6554
- if (orderId) await updateOrderWorkflow(orderId)
6555
- }
6836
+ const commerceNotificationHandler = createCommerceNotificationWebhookHandler({
6837
+ async orderPaid({ event, idempotencyKey }) {
6838
+ await processOnce(idempotencyKey, async () => {
6839
+ const orderId = event.notification.orderId ?? event.data.orderId
6840
+ if (orderId) await updateOrderWorkflow(orderId)
6841
+ })
6842
+ },
6556
6843
 
6557
- if (event.notification.event === 'fulfillmentShipped') {
6558
- const fulfillmentId =
6559
- event.notification.fulfillmentId ?? event.data.fulfillmentId
6560
- if (fulfillmentId) await updateFulfillmentWorkflow(fulfillmentId)
6561
- }
6844
+ async fulfillmentShipped({ event, idempotencyKey }) {
6845
+ await processOnce(idempotencyKey, async () => {
6846
+ const fulfillmentId =
6847
+ event.notification.fulfillmentId ?? event.data.fulfillmentId
6848
+ if (fulfillmentId) await updateFulfillmentWorkflow(fulfillmentId)
6562
6849
  })
6850
+ },
6851
+ })
6563
6852
 
6564
- if (!processed) return
6565
- }, {
6853
+ export async function POST(request: Request) {
6854
+ return handleWebhook(request, commerceNotificationHandler, {
6566
6855
  secret: getWebhookSecret(),
6567
6856
  })
6568
6857
  }
@@ -6570,11 +6859,11 @@ export async function POST(request: Request) {
6570
6859
 
6571
6860
  Back \`processOnce()\` with durable storage such as a database unique key or queue idempotency store; do not use process-local memory for webhook idempotency.
6572
6861
 
6573
- ## Headless Commerce Email Workers
6862
+ ## Commerce Notification Workers
6574
6863
 
6575
- For tenant-owned transactional email, use \`commerce.notification\` as the trigger and build a signed worker with \`createCommerceEmailWebhookHandler()\`. 01.software owns event timing, delivery retries, signing, and idempotency signals; the tenant worker owns template rendering, provider credentials, extra order/customer fetches via \`createServerClient\`, and final delivery through a tenant provider such as Resend.
6864
+ For new tenant-owned commerce side effects, use \`commerce.notification\` as the trigger and build a signed worker with \`createCommerceNotificationWebhookHandler()\`. Existing email workers may keep \`createCommerceEmailWebhookHandler()\` as a compatibility alias, but the general helper name should be used in new guidance. 01.software owns event timing, delivery retries, signing, and idempotency signals; the tenant worker owns email, external PG calls, extra order/customer fetches via \`createServerClient\`, and final side effects.
6576
6865
 
6577
- Use \`getCommerceNotificationIdempotencyKey(event)\` or the \`idempotencyKey\` passed by \`createCommerceEmailWebhookHandler()\`, then guard provider sends with durable \`processOnce(idempotencyKey, ...)\` storage. The webhook payload is PII-light and is not enough for recipient data, so fetch recipient/template context with server SDK credentials. In the v1 headless path, do not store tenant ESP secrets in 01.software and do not ask 01.software to send directly through the tenant provider.
6866
+ Use \`getCommerceNotificationIdempotencyKey(event)\` or the \`idempotencyKey\` passed by \`createCommerceNotificationWebhookHandler()\`, then guard side effects with durable \`processOnce(idempotencyKey, ...)\` storage. \`notification.intentId + notification.dedupeKey\` is semantic idempotency. \`deliveryId\` is delivery-attempt observability only.
6578
6867
 
6579
6868
  ## Webhook Payload Structure
6580
6869
 
@@ -6627,9 +6916,11 @@ Canonical example (public operational identifiers only; no PII, payment/provider
6627
6916
  Use \`notification.intentId\` plus \`notification.dedupeKey\` for semantic idempotency. \`deliveryId\` is per delivery attempt / observability and may not be stable across semantic retries.
6628
6917
  Some normalized deliveries may include \`data.source\` or \`change\` metadata, but handlers should treat those fields as optional. Route from \`notification.orderId\`, \`notification.fulfillmentId\`, \`notification.returnId\`, or the matching typed \`data.*Id\` field.
6629
6918
 
6919
+ For CMS/Admin cancellation side effects, route \`commerce.notification/orderCanceled\` workers per the public webhooks guide (**orderCanceled external PG refund handoff**). Use \`orders/update\` only for cache refreshes and local projections. Detailed trusted refetch, PG refund classification, and refund reporting contracts live in that guide\u2014not in this generic webhook resource.
6920
+
6630
6921
  V1 source subscription semantics:
6631
6922
 
6632
- - \`orderPaid\` and \`orderDelivered\` are delivered through \`orders\`-scoped endpoints.
6923
+ - \`orderPaid\`, \`orderCanceled\`, and \`orderDelivered\` are delivered through \`orders\`-scoped endpoints.
6633
6924
  - \`fulfillmentShipped\` is delivered through \`fulfillments\`-scoped endpoints.
6634
6925
  - \`returnRequested\` and \`returnCompleted\` are delivered through \`returns\`-scoped endpoints.
6635
6926
  - Empty, unscoped, and all-collection endpoints do not receive v1 semantic commerce notifications.
@@ -6728,7 +7019,7 @@ Configure webhook URLs in the 01.software console under Tenant Settings > Webhoo
6728
7019
  }
6729
7020
 
6730
7021
  // src/resources/(docs)/product-detail.ts
6731
- var metadata51 = {
7022
+ var metadata52 = {
6732
7023
  name: "docs-product-detail",
6733
7024
  title: "Product Detail Helper",
6734
7025
  description: "01.software SDK commerce.product.detail helper guide"
@@ -6838,7 +7129,7 @@ function runtimeAnnotationsFor(meta) {
6838
7129
  openWorldHint: policy.annotationPolicy.openWorld
6839
7130
  };
6840
7131
  }
6841
- function registerTool(server, schema39, meta, handler20) {
7132
+ function registerTool(server, schema40, meta, handler20) {
6842
7133
  let registered = REGISTERED_TOOLS_BY_SERVER.get(server);
6843
7134
  if (!registered) {
6844
7135
  registered = /* @__PURE__ */ new Set();
@@ -6849,7 +7140,7 @@ function registerTool(server, schema39, meta, handler20) {
6849
7140
  meta.name,
6850
7141
  {
6851
7142
  description: meta.description,
6852
- inputSchema: schema39,
7143
+ inputSchema: schema40,
6853
7144
  annotations: runtimeAnnotationsFor(meta)
6854
7145
  },
6855
7146
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -6899,13 +7190,13 @@ function registerTool(server, schema39, meta, handler20) {
6899
7190
  }
6900
7191
  );
6901
7192
  }
6902
- function registerPrompt(server, schema39, meta, handler20) {
7193
+ function registerPrompt(server, schema40, meta, handler20) {
6903
7194
  server.registerPrompt(
6904
7195
  meta.name,
6905
7196
  {
6906
7197
  title: meta.title,
6907
7198
  description: meta.description,
6908
- argsSchema: schema39
7199
+ argsSchema: schema40
6909
7200
  },
6910
7201
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6911
7202
  (params) => ({
@@ -6965,245 +7256,251 @@ function createServer(options = {}) {
6965
7256
  server,
6966
7257
  schema8,
6967
7258
  metadata8,
6968
- updateFulfillment
7259
+ prepareFulfillmentOrder
6969
7260
  );
6970
7261
  registerTool(
6971
7262
  server,
6972
7263
  schema9,
6973
7264
  metadata9,
6974
- updateTransaction
7265
+ updateFulfillment
6975
7266
  );
6976
7267
  registerTool(
6977
7268
  server,
6978
7269
  schema10,
6979
7270
  metadata10,
6980
- confirmPayment
7271
+ updateTransaction
6981
7272
  );
6982
- registerTool(server, schema11, metadata11, cancelOrder);
6983
7273
  registerTool(
6984
7274
  server,
6985
- schema12,
6986
- metadata12,
6987
- createReturn
7275
+ schema11,
7276
+ metadata11,
7277
+ confirmPayment
6988
7278
  );
7279
+ registerTool(server, schema12, metadata12, cancelOrder);
6989
7280
  registerTool(
6990
7281
  server,
6991
7282
  schema13,
6992
7283
  metadata13,
6993
- updateReturn
7284
+ createReturn
6994
7285
  );
6995
7286
  registerTool(
6996
7287
  server,
6997
7288
  schema14,
6998
7289
  metadata14,
6999
- returnWithRefund
7290
+ updateReturn
7000
7291
  );
7001
- registerTool(server, schema15, metadata15, addCartItem);
7002
7292
  registerTool(
7003
7293
  server,
7004
- schema16,
7005
- metadata16,
7006
- updateCartItem
7294
+ schema15,
7295
+ metadata15,
7296
+ returnWithRefund
7007
7297
  );
7298
+ registerTool(server, schema16, metadata16, addCartItem);
7008
7299
  registerTool(
7009
7300
  server,
7010
7301
  schema17,
7011
7302
  metadata17,
7012
- removeCartItem
7303
+ updateCartItem
7013
7304
  );
7014
7305
  registerTool(
7015
7306
  server,
7016
7307
  schema18,
7017
7308
  metadata18,
7018
- applyDiscount
7309
+ removeCartItem
7019
7310
  );
7020
7311
  registerTool(
7021
7312
  server,
7022
7313
  schema19,
7023
7314
  metadata19,
7024
- removeDiscount
7315
+ applyDiscount
7025
7316
  );
7026
- registerTool(server, schema20, metadata20, clearCart);
7027
7317
  registerTool(
7028
7318
  server,
7029
- schema21,
7030
- metadata21,
7031
- validateDiscount
7319
+ schema20,
7320
+ metadata20,
7321
+ removeDiscount
7032
7322
  );
7323
+ registerTool(server, schema21, metadata21, clearCart);
7033
7324
  registerTool(
7034
7325
  server,
7035
7326
  schema22,
7036
7327
  metadata22,
7037
- calculateShipping
7328
+ validateDiscount
7038
7329
  );
7039
- registerTool(server, schema23, metadata23, stockCheck);
7040
7330
  registerTool(
7041
7331
  server,
7042
- schema24,
7043
- metadata24,
7044
- productDetail
7332
+ schema23,
7333
+ metadata23,
7334
+ calculateShipping
7045
7335
  );
7336
+ registerTool(server, schema24, metadata24, stockCheck);
7046
7337
  registerTool(
7047
7338
  server,
7048
7339
  schema25,
7049
7340
  metadata25,
7341
+ productDetail
7342
+ );
7343
+ registerTool(
7344
+ server,
7345
+ schema26,
7346
+ metadata26,
7050
7347
  productUpsert
7051
7348
  );
7052
7349
  }
7053
- registerTool(
7054
- server,
7055
- schema26,
7056
- metadata26,
7057
- getCollectionSchemaTool
7058
- );
7059
7350
  registerTool(
7060
7351
  server,
7061
7352
  schema27,
7062
7353
  metadata27,
7063
- handler
7354
+ getCollectionSchemaTool
7064
7355
  );
7065
7356
  registerTool(
7066
7357
  server,
7067
7358
  schema28,
7068
7359
  metadata28,
7069
- handler2
7360
+ handler
7070
7361
  );
7071
7362
  registerTool(
7072
7363
  server,
7073
7364
  schema29,
7074
7365
  metadata29,
7075
- listConfigurableFields
7366
+ handler2
7076
7367
  );
7077
7368
  registerTool(
7078
7369
  server,
7079
7370
  schema30,
7080
7371
  metadata30,
7081
- updateFieldConfig
7372
+ listConfigurableFields
7082
7373
  );
7083
7374
  registerTool(
7084
7375
  server,
7085
7376
  schema31,
7086
7377
  metadata31,
7087
- handler3
7378
+ updateFieldConfig
7088
7379
  );
7089
7380
  registerTool(
7090
7381
  server,
7091
7382
  schema32,
7092
7383
  metadata32,
7093
- handler4
7384
+ handler3
7094
7385
  );
7095
7386
  registerTool(
7096
7387
  server,
7097
7388
  schema33,
7098
7389
  metadata33,
7099
- handler5
7390
+ handler4
7100
7391
  );
7101
7392
  registerTool(
7102
7393
  server,
7103
7394
  schema34,
7104
7395
  metadata34,
7105
- handler6
7396
+ handler5
7106
7397
  );
7107
- registerPrompt(
7398
+ registerTool(
7108
7399
  server,
7109
7400
  schema35,
7110
7401
  metadata35,
7111
- sdkUsageGuide
7402
+ handler6
7112
7403
  );
7113
7404
  registerPrompt(
7114
7405
  server,
7115
7406
  schema36,
7116
7407
  metadata36,
7117
- collectionQueryHelp
7408
+ sdkUsageGuide
7118
7409
  );
7119
7410
  registerPrompt(
7120
7411
  server,
7121
7412
  schema37,
7122
7413
  metadata37,
7123
- orderFlowGuide
7414
+ collectionQueryHelp
7124
7415
  );
7125
7416
  registerPrompt(
7126
7417
  server,
7127
7418
  schema38,
7128
7419
  metadata38,
7420
+ orderFlowGuide
7421
+ );
7422
+ registerPrompt(
7423
+ server,
7424
+ schema39,
7425
+ metadata39,
7129
7426
  featureSetupGuide
7130
7427
  );
7131
7428
  registerStaticResource(
7132
7429
  server,
7133
7430
  mcpResourceUri("app-config"),
7134
- metadata39,
7431
+ metadata40,
7135
7432
  handler7
7136
7433
  );
7137
7434
  registerStaticResource(
7138
7435
  server,
7139
7436
  mcpResourceUri("collections-schema"),
7140
- metadata40,
7437
+ metadata41,
7141
7438
  handler8
7142
7439
  );
7143
7440
  registerStaticResource(
7144
7441
  server,
7145
7442
  mcpResourceUri("docs-getting-started"),
7146
- metadata41,
7443
+ metadata42,
7147
7444
  handler9
7148
7445
  );
7149
7446
  registerStaticResource(
7150
7447
  server,
7151
7448
  mcpResourceUri("docs-guides"),
7152
- metadata42,
7449
+ metadata43,
7153
7450
  handler10
7154
7451
  );
7155
7452
  registerStaticResource(
7156
7453
  server,
7157
7454
  mcpResourceUri("docs-api"),
7158
- metadata43,
7455
+ metadata44,
7159
7456
  handler11
7160
7457
  );
7161
7458
  registerStaticResource(
7162
7459
  server,
7163
7460
  mcpResourceUri("docs-query-builder"),
7164
- metadata44,
7461
+ metadata45,
7165
7462
  handler12
7166
7463
  );
7167
7464
  registerStaticResource(
7168
7465
  server,
7169
7466
  mcpResourceUri("docs-react-query"),
7170
- metadata45,
7467
+ metadata46,
7171
7468
  handler13
7172
7469
  );
7173
7470
  registerStaticResource(
7174
7471
  server,
7175
7472
  mcpResourceUri("docs-server-api"),
7176
- metadata46,
7473
+ metadata47,
7177
7474
  handler14
7178
7475
  );
7179
7476
  registerStaticResource(
7180
7477
  server,
7181
7478
  mcpResourceUri("docs-customer-auth"),
7182
- metadata47,
7479
+ metadata48,
7183
7480
  handler15
7184
7481
  );
7185
7482
  registerStaticResource(
7186
7483
  server,
7187
7484
  mcpResourceUri("docs-browser-vs-server"),
7188
- metadata48,
7485
+ metadata49,
7189
7486
  handler16
7190
7487
  );
7191
7488
  registerStaticResource(
7192
7489
  server,
7193
7490
  mcpResourceUri("docs-file-upload"),
7194
- metadata49,
7491
+ metadata50,
7195
7492
  handler17
7196
7493
  );
7197
7494
  registerStaticResource(
7198
7495
  server,
7199
7496
  mcpResourceUri("docs-webhook"),
7200
- metadata50,
7497
+ metadata51,
7201
7498
  handler18
7202
7499
  );
7203
7500
  registerStaticResource(
7204
7501
  server,
7205
7502
  mcpResourceUri("docs-product-detail"),
7206
- metadata51,
7503
+ metadata52,
7207
7504
  handler19
7208
7505
  );
7209
7506
  return server;
@@ -7224,4 +7521,4 @@ export {
7224
7521
  flushMcpTelemetrySummary,
7225
7522
  createServer
7226
7523
  };
7227
- //# sourceMappingURL=chunk-D72PPBDH.js.map
7524
+ //# sourceMappingURL=chunk-Y5GYUAK3.js.map