@01.software/cli 0.10.4 → 0.10.6

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.
@@ -1,6 +1,75 @@
1
1
  // src/server.ts
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
+ // src/resource-inventory.ts
5
+ var MCP_RESOURCE_INVENTORY = [
6
+ { uri: "config://app", label: "config", registeredName: "app-config" },
7
+ {
8
+ uri: "collections://schema",
9
+ label: "collections-schema",
10
+ registeredName: "collections-schema"
11
+ },
12
+ {
13
+ uri: "docs://sdk/getting-started",
14
+ label: "getting-started",
15
+ registeredName: "docs-getting-started"
16
+ },
17
+ { uri: "docs://sdk/guides", label: "guides", registeredName: "docs-guides" },
18
+ { uri: "docs://sdk/api", label: "api", registeredName: "docs-api" },
19
+ {
20
+ uri: "docs://sdk/query-builder",
21
+ label: "query-builder",
22
+ registeredName: "docs-query-builder"
23
+ },
24
+ {
25
+ uri: "docs://sdk/react-query",
26
+ label: "react-query",
27
+ registeredName: "docs-react-query"
28
+ },
29
+ {
30
+ uri: "docs://sdk/server-api",
31
+ label: "server-api",
32
+ registeredName: "docs-server-api"
33
+ },
34
+ {
35
+ uri: "docs://sdk/customer-auth",
36
+ label: "customer-auth",
37
+ registeredName: "docs-customer-auth"
38
+ },
39
+ {
40
+ uri: "docs://sdk/browser-vs-server",
41
+ label: "browser-vs-server",
42
+ registeredName: "docs-browser-vs-server"
43
+ },
44
+ {
45
+ uri: "docs://sdk/file-upload",
46
+ label: "file-upload",
47
+ registeredName: "docs-file-upload"
48
+ },
49
+ {
50
+ uri: "docs://sdk/webhook",
51
+ label: "webhook",
52
+ registeredName: "docs-webhook"
53
+ },
54
+ {
55
+ uri: "docs://sdk/product-detail",
56
+ label: "product-detail",
57
+ registeredName: "docs-product-detail"
58
+ }
59
+ ];
60
+ var MCP_RESOURCE_LABELS = MCP_RESOURCE_INVENTORY.map(
61
+ (resource) => resource.label
62
+ );
63
+ function mcpResourceUri(registeredName) {
64
+ const resource = MCP_RESOURCE_INVENTORY.find(
65
+ (entry) => entry.registeredName === registeredName
66
+ );
67
+ if (!resource) {
68
+ throw new Error(`Unknown MCP resource inventory entry: ${registeredName}`);
69
+ }
70
+ return resource.uri;
71
+ }
72
+
4
73
  // src/lib/request-context.ts
5
74
  import { AsyncLocalStorage } from "async_hooks";
6
75
  var requestContext = new AsyncLocalStorage();
@@ -88,9 +157,8 @@ var MCP_CONSOLE_SERVICE_AUDIENCE = "https://api.01.software/internal/mcp";
88
157
  var MCP_CONSOLE_SERVICE_SCOPE = "console:mcp_proxy";
89
158
  var MCP_SERVICE_TOKEN_LIFETIME_SECONDS = 60;
90
159
 
91
- // ../../packages/contracts/dist/index.js
160
+ // ../../packages/contracts/src/tenant/index.ts
92
161
  import { z } from "zod";
93
- import { z as z2 } from "zod";
94
162
  var tenantFieldConfigStateSchema = z.object({
95
163
  hiddenFields: z.array(z.string()),
96
164
  isHidden: z.boolean()
@@ -239,12 +307,47 @@ var collectionSchemaResponseSchema = z.object({
239
307
  fields: z.array(collectionFieldSchema)
240
308
  }).strict()
241
309
  }).strict();
310
+
311
+ // ../../packages/contracts/src/ecommerce/index.ts
312
+ import { z as z2 } from "zod";
242
313
  var transactionStatusSchema = z2.enum([
243
314
  "pending",
244
315
  "paid",
245
316
  "failed",
246
317
  "canceled"
247
318
  ]);
319
+ var entityIdSchema = z2.union([z2.string(), z2.number()]).transform(String);
320
+ var createOrderItemSchema = z2.object({
321
+ product: entityIdSchema,
322
+ variant: entityIdSchema,
323
+ option: entityIdSchema,
324
+ quantity: z2.number().int().positive("quantity must be a positive integer"),
325
+ unitPrice: z2.number().optional(),
326
+ totalPrice: z2.number().optional()
327
+ });
328
+ var createOrderSchema = z2.object({
329
+ pgPaymentId: z2.string().min(1).optional(),
330
+ orderNumber: z2.string().min(1, "orderNumber is required"),
331
+ customer: entityIdSchema.optional(),
332
+ customerSnapshot: z2.object({
333
+ name: z2.string().optional(),
334
+ email: z2.string().email("Invalid email format"),
335
+ phone: z2.string().optional()
336
+ }),
337
+ shippingAddress: z2.object({
338
+ postalCode: z2.string().optional(),
339
+ address: z2.string().optional(),
340
+ detailAddress: z2.string().optional(),
341
+ deliveryMessage: z2.string().optional(),
342
+ recipientName: z2.string().optional(),
343
+ phone: z2.string().optional()
344
+ }),
345
+ orderItems: z2.array(createOrderItemSchema).min(1, "At least one order item is required").max(100, "Maximum 100 items per order"),
346
+ totalAmount: z2.number().nonnegative("totalAmount must be non-negative"),
347
+ shippingAmount: z2.number().min(0).optional(),
348
+ discountCode: z2.string().optional()
349
+ });
350
+ var CreateOrderSchema = createOrderSchema;
248
351
  var updateTransactionSchema = z2.object({
249
352
  pgPaymentId: z2.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
250
353
  status: transactionStatusSchema.describe(
@@ -279,6 +382,7 @@ var confirmPaymentSchema = z2.object({
279
382
  ]).optional(),
280
383
  metadata: z2.record(z2.string(), z2.unknown()).optional()
281
384
  }).strict();
385
+ var ConfirmPaymentSchema = confirmPaymentSchema;
282
386
  var returnReasonSchema = z2.enum([
283
387
  "change_of_mind",
284
388
  "defective",
@@ -305,6 +409,8 @@ var returnWithRefundSchema = z2.object({
305
409
  refundReceiptUrl: z2.string().optional().describe("Refund receipt URL (optional)")
306
410
  }).strict();
307
411
  var ReturnWithRefundSchema = returnWithRefundSchema;
412
+
413
+ // ../../packages/contracts/src/mcp/index.ts
308
414
  var MCP_TOOL_CONTRACT = {
309
415
  "query-collection": {
310
416
  consoleRole: "tenant-viewer",
@@ -406,6 +512,11 @@ var MCP_TOOL_CONTRACT = {
406
512
  oauthScope: "mcp:write",
407
513
  readOnly: false
408
514
  },
515
+ "confirm-payment": {
516
+ consoleRole: "tenant-admin",
517
+ oauthScope: "mcp:write",
518
+ readOnly: false
519
+ },
409
520
  "update-order": {
410
521
  consoleRole: "tenant-admin",
411
522
  oauthScope: "mcp:write",
@@ -656,6 +767,14 @@ var TOOL_POLICY_MANIFEST = {
656
767
  consoleSurface: "POST /api/orders",
657
768
  annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
658
769
  },
770
+ "confirm-payment": {
771
+ category: "mutation-transaction",
772
+ oauthScope: MCP_SCOPES.write,
773
+ consoleRole: "tenant-admin",
774
+ consoleSurface: "POST /api/orders/confirm-payment",
775
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
776
+ exemptionReason: REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE
777
+ },
659
778
  "update-order": {
660
779
  category: "mutation-order",
661
780
  oauthScope: MCP_SCOPES.write,
@@ -749,7 +868,15 @@ var TOOL_POLICY_MANIFEST = {
749
868
  annotationPolicy: READ_ONLY_ANNOTATION
750
869
  }
751
870
  };
752
- function evaluateToolPolicy(toolName, scopes) {
871
+ var CONSOLE_ROLE_RANK = {
872
+ "tenant-viewer": 0,
873
+ "tenant-editor": 1,
874
+ "tenant-admin": 2
875
+ };
876
+ function hasRequiredConsoleRole(tenantRole, requiredRole) {
877
+ return CONSOLE_ROLE_RANK[tenantRole] >= CONSOLE_ROLE_RANK[requiredRole];
878
+ }
879
+ function evaluateToolPolicy(toolName, scopes, tenantRole) {
753
880
  if (!isMcpToolName(toolName)) {
754
881
  return {
755
882
  allowed: false,
@@ -765,6 +892,13 @@ function evaluateToolPolicy(toolName, scopes) {
765
892
  message: `Tool ${toolName} requires ${entry.oauthScope}`
766
893
  };
767
894
  }
895
+ if (!hasRequiredConsoleRole(tenantRole, entry.consoleRole)) {
896
+ return {
897
+ allowed: false,
898
+ reason: "insufficient_role",
899
+ message: `Tool ${toolName} requires ${entry.consoleRole}`
900
+ };
901
+ }
768
902
  return { allowed: true, entry };
769
903
  }
770
904
 
@@ -1257,25 +1391,7 @@ async function getOrder({
1257
1391
  }
1258
1392
 
1259
1393
  // src/tools/create-order.ts
1260
- import { z as z6 } from "zod";
1261
- var schema4 = {
1262
- pgPaymentId: z6.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
1263
- orderNumber: z6.string().min(1).describe("Unique order number (required)"),
1264
- customerSnapshot: z6.object({
1265
- name: z6.string().optional().describe("Customer name"),
1266
- email: z6.string().describe("Customer email (required)"),
1267
- phone: z6.string().optional().describe("Customer phone")
1268
- }).describe("Customer snapshot at time of order (required)"),
1269
- shippingAddress: z6.record(z6.string(), z6.unknown()).describe(
1270
- "Shipping address object (required). Fields: postalCode, address1, address2, deliveryMessage, recipientName, phone"
1271
- ),
1272
- orderItems: z6.array(z6.record(z6.string(), z6.unknown())).describe(
1273
- "Array of order item objects (required). Each: { product, variant, option, quantity, unitPrice?, totalPrice? }"
1274
- ),
1275
- totalAmount: z6.number().nonnegative().describe("Total order amount (required, min 0)"),
1276
- shippingAmount: z6.number().nonnegative().optional().describe("Shipping amount (optional, default 0)"),
1277
- discountCode: z6.string().optional().describe("Discount code to apply (optional)")
1278
- };
1394
+ var schema4 = CreateOrderSchema.shape;
1279
1395
  var metadata4 = {
1280
1396
  name: "create-order",
1281
1397
  description: "Create a new order with products and shipping information. Supports idempotency.",
@@ -1289,9 +1405,8 @@ var metadata4 = {
1289
1405
  async function createOrder(params) {
1290
1406
  try {
1291
1407
  const client = getClient();
1292
- const result = await client.commerce.orders.create(
1293
- params
1294
- );
1408
+ const parsed = CreateOrderSchema.parse(params);
1409
+ const result = await client.commerce.orders.create(parsed);
1295
1410
  return toolSuccess({ data: result });
1296
1411
  } catch (error) {
1297
1412
  return toolError(error);
@@ -1299,10 +1414,10 @@ async function createOrder(params) {
1299
1414
  }
1300
1415
 
1301
1416
  // src/tools/update-order.ts
1302
- import { z as z7 } from "zod";
1417
+ import { z as z6 } from "zod";
1303
1418
  var schema5 = {
1304
- orderNumber: z7.string().min(1).describe("Order number (required)"),
1305
- status: z7.enum([
1419
+ orderNumber: z6.string().min(1).describe("Order number (required)"),
1420
+ status: z6.enum([
1306
1421
  "pending",
1307
1422
  "paid",
1308
1423
  "failed",
@@ -1339,15 +1454,15 @@ async function updateOrder({
1339
1454
  }
1340
1455
 
1341
1456
  // src/tools/checkout.ts
1342
- import { z as z8 } from "zod";
1457
+ import { z as z7 } from "zod";
1343
1458
  var schema6 = {
1344
- cartId: z8.string().min(1).describe("Cart ID to convert to order (required)"),
1345
- pgPaymentId: z8.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
1346
- orderNumber: z8.string().min(1).describe("Unique order number (required)"),
1347
- customerSnapshot: z8.record(z8.string(), z8.unknown()).describe(
1459
+ cartId: z7.string().min(1).describe("Cart ID to convert to order (required)"),
1460
+ pgPaymentId: z7.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
1461
+ orderNumber: z7.string().min(1).describe("Unique order number (required)"),
1462
+ customerSnapshot: z7.record(z7.string(), z7.unknown()).describe(
1348
1463
  "Customer snapshot object (required). Fields: { name?, email, phone? }"
1349
1464
  ),
1350
- discountCode: z8.string().optional().describe("Discount code to apply (optional)")
1465
+ discountCode: z7.string().optional().describe("Discount code to apply (optional)")
1351
1466
  };
1352
1467
  var metadata6 = {
1353
1468
  name: "checkout",
@@ -1372,17 +1487,17 @@ async function checkout(params) {
1372
1487
  }
1373
1488
 
1374
1489
  // src/tools/create-fulfillment.ts
1375
- import { z as z9 } from "zod";
1490
+ import { z as z8 } from "zod";
1376
1491
  var schema7 = {
1377
- orderNumber: z9.string().min(1).describe("Order number (required)"),
1378
- carrier: z9.string().optional().describe("Shipping carrier name (optional)"),
1379
- trackingNumber: z9.string().optional().describe(
1492
+ orderNumber: z8.string().min(1).describe("Order number (required)"),
1493
+ carrier: z8.string().optional().describe("Shipping carrier name (optional)"),
1494
+ trackingNumber: z8.string().optional().describe(
1380
1495
  'Tracking number (optional). Setting carrier + tracking triggers "shipped" status'
1381
1496
  ),
1382
- items: z9.array(
1383
- z9.object({
1384
- orderItem: z9.string().min(1).describe("Order item ID"),
1385
- quantity: z9.number().int().positive().describe("Quantity to fulfill")
1497
+ items: z8.array(
1498
+ z8.object({
1499
+ orderItem: z8.string().min(1).describe("Order item ID"),
1500
+ quantity: z8.number().int().positive().describe("Quantity to fulfill")
1386
1501
  })
1387
1502
  ).describe("Array of items to fulfill (required)")
1388
1503
  };
@@ -1417,16 +1532,16 @@ async function createFulfillment({
1417
1532
  }
1418
1533
 
1419
1534
  // src/tools/update-fulfillment.ts
1420
- import { z as z10 } from "zod";
1535
+ import { z as z9 } from "zod";
1421
1536
  var schema8 = {
1422
- fulfillmentId: z10.string().min(1).describe("Fulfillment ID (required)"),
1423
- status: z10.enum(["packed", "shipped", "delivered", "failed"]).describe(
1537
+ fulfillmentId: z9.string().min(1).describe("Fulfillment ID (required)"),
1538
+ status: z9.enum(["packed", "shipped", "delivered", "failed"]).describe(
1424
1539
  "New fulfillment status (required). FSM: pending\u2192packed/shipped/failed, packed\u2192shipped/failed, shipped\u2192delivered/failed"
1425
1540
  ),
1426
- carrier: z10.string().optional().describe(
1541
+ carrier: z9.string().optional().describe(
1427
1542
  "Shipping carrier (optional, changeable only in pending/packed status)"
1428
1543
  ),
1429
- trackingNumber: z10.string().optional().describe(
1544
+ trackingNumber: z9.string().optional().describe(
1430
1545
  "Tracking number (optional, changeable only in pending/packed status)"
1431
1546
  )
1432
1547
  };
@@ -1497,21 +1612,44 @@ async function updateTransaction({
1497
1612
  }
1498
1613
  }
1499
1614
 
1615
+ // src/tools/confirm-payment.ts
1616
+ var schema10 = ConfirmPaymentSchema.shape;
1617
+ var metadata10 = {
1618
+ name: "confirm-payment",
1619
+ description: "Confirm a provider-verified ecommerce payment through the generic payment confirmation flow.",
1620
+ annotations: {
1621
+ title: "Confirm payment",
1622
+ readOnlyHint: false,
1623
+ destructiveHint: true,
1624
+ idempotentHint: true
1625
+ }
1626
+ };
1627
+ async function confirmPayment(params) {
1628
+ try {
1629
+ const client = getClient();
1630
+ const parsed = ConfirmPaymentSchema.parse(params);
1631
+ const result = await client.commerce.orders.confirmPayment(parsed);
1632
+ return toolSuccess({ data: result });
1633
+ } catch (error) {
1634
+ return toolError(error);
1635
+ }
1636
+ }
1637
+
1500
1638
  // src/tools/create-return.ts
1501
- import { z as z11 } from "zod";
1502
- var schema10 = {
1503
- orderNumber: z11.string().min(1).describe("Order number (required)"),
1504
- reason: z11.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
1505
- reasonDetail: z11.string().optional().describe("Detailed reason text (optional)"),
1506
- returnItems: z11.array(
1507
- z11.object({
1508
- orderItem: z11.string().min(1).describe("Order item ID"),
1509
- quantity: z11.number().int().positive().describe("Quantity to return")
1639
+ import { z as z10 } from "zod";
1640
+ var schema11 = {
1641
+ orderNumber: z10.string().min(1).describe("Order number (required)"),
1642
+ reason: z10.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
1643
+ reasonDetail: z10.string().optional().describe("Detailed reason text (optional)"),
1644
+ returnItems: z10.array(
1645
+ z10.object({
1646
+ orderItem: z10.string().min(1).describe("Order item ID"),
1647
+ quantity: z10.number().int().positive().describe("Quantity to return")
1510
1648
  })
1511
1649
  ).describe("Array of products to return (required)"),
1512
- refundAmount: z11.number().nonnegative().describe("Refund amount (required, min 0)")
1650
+ refundAmount: z10.number().nonnegative().describe("Refund amount (required, min 0)")
1513
1651
  };
1514
- var metadata10 = {
1652
+ var metadata11 = {
1515
1653
  name: "create-return",
1516
1654
  description: "Create a return request for an order. Only works for delivered/confirmed orders. Updates order status to return_requested.",
1517
1655
  annotations: {
@@ -1544,14 +1682,14 @@ async function createReturn({
1544
1682
  }
1545
1683
 
1546
1684
  // src/tools/update-return.ts
1547
- import { z as z12 } from "zod";
1548
- var schema11 = {
1549
- returnId: z12.string().min(1).describe("Return ID (required)"),
1550
- status: z12.enum(["processing", "approved", "rejected", "completed"]).describe(
1685
+ import { z as z11 } from "zod";
1686
+ var schema12 = {
1687
+ returnId: z11.string().min(1).describe("Return ID (required)"),
1688
+ status: z11.enum(["processing", "approved", "rejected", "completed"]).describe(
1551
1689
  "New return status (required). Valid transitions: requested\u2192processing/rejected, processing\u2192approved/rejected, approved\u2192completed"
1552
1690
  )
1553
1691
  };
1554
- var metadata11 = {
1692
+ var metadata12 = {
1555
1693
  name: "update-return",
1556
1694
  description: "Update return status with FSM validation. Restores inventory on completion, reverts order status on rejection.",
1557
1695
  annotations: {
@@ -1575,8 +1713,8 @@ async function updateReturn({
1575
1713
  }
1576
1714
 
1577
1715
  // src/tools/return-with-refund.ts
1578
- var schema12 = ReturnWithRefundSchema.shape;
1579
- var metadata12 = {
1716
+ var schema13 = ReturnWithRefundSchema.shape;
1717
+ var metadata13 = {
1580
1718
  name: "return-with-refund",
1581
1719
  description: "Combined return + refund operation. Creates return, restores stock, cancels transaction, updates order status.",
1582
1720
  annotations: {
@@ -1616,15 +1754,15 @@ async function returnWithRefund({
1616
1754
  }
1617
1755
 
1618
1756
  // src/tools/add-cart-item.ts
1619
- import { z as z13 } from "zod";
1620
- var schema13 = {
1621
- cartId: z13.string().min(1).describe("Cart ID (required)"),
1622
- product: z13.string().min(1).describe("Product ID (required)"),
1623
- variant: z13.string().min(1).describe("Product variant ID (required)"),
1624
- option: z13.string().min(1).describe("Product option ID (required)"),
1625
- quantity: z13.number().int().positive().describe("Quantity to add (required, positive integer)")
1757
+ import { z as z12 } from "zod";
1758
+ var schema14 = {
1759
+ cartId: z12.string().min(1).describe("Cart ID (required)"),
1760
+ product: z12.string().min(1).describe("Product ID (required)"),
1761
+ variant: z12.string().min(1).describe("Product variant ID (required)"),
1762
+ option: z12.string().min(1).describe("Product option ID (required)"),
1763
+ quantity: z12.number().int().positive().describe("Quantity to add (required, positive integer)")
1626
1764
  };
1627
- var metadata13 = {
1765
+ var metadata14 = {
1628
1766
  name: "add-cart-item",
1629
1767
  description: "Add a product to cart. Validates stock, merges quantity if item already exists, recalculates totals.",
1630
1768
  annotations: {
@@ -1657,12 +1795,12 @@ async function addCartItem({
1657
1795
  }
1658
1796
 
1659
1797
  // src/tools/update-cart-item.ts
1660
- import { z as z14 } from "zod";
1661
- var schema14 = {
1662
- cartItemId: z14.string().min(1).describe("Cart item ID (required)"),
1663
- quantity: z14.number().int().positive().describe("New quantity (required, positive integer)")
1798
+ import { z as z13 } from "zod";
1799
+ var schema15 = {
1800
+ cartItemId: z13.string().min(1).describe("Cart item ID (required)"),
1801
+ quantity: z13.number().int().positive().describe("New quantity (required, positive integer)")
1664
1802
  };
1665
- var metadata14 = {
1803
+ var metadata15 = {
1666
1804
  name: "update-cart-item",
1667
1805
  description: "Update cart item quantity. Validates stock availability, recalculates cart totals.",
1668
1806
  annotations: {
@@ -1686,11 +1824,11 @@ async function updateCartItem({
1686
1824
  }
1687
1825
 
1688
1826
  // src/tools/remove-cart-item.ts
1689
- import { z as z15 } from "zod";
1690
- var schema15 = {
1691
- cartItemId: z15.string().min(1).describe("Cart item ID to remove (required)")
1827
+ import { z as z14 } from "zod";
1828
+ var schema16 = {
1829
+ cartItemId: z14.string().min(1).describe("Cart item ID to remove (required)")
1692
1830
  };
1693
- var metadata15 = {
1831
+ var metadata16 = {
1694
1832
  name: "remove-cart-item",
1695
1833
  description: "Remove an item from cart. Recalculates cart totals after removal.",
1696
1834
  annotations: {
@@ -1713,12 +1851,12 @@ async function removeCartItem({
1713
1851
  }
1714
1852
 
1715
1853
  // src/tools/apply-discount.ts
1716
- import { z as z16 } from "zod";
1717
- var schema16 = {
1718
- cartId: z16.string().min(1).describe("Cart ID (required)"),
1719
- discountCode: z16.string().describe("Discount code to apply (required)")
1854
+ import { z as z15 } from "zod";
1855
+ var schema17 = {
1856
+ cartId: z15.string().min(1).describe("Cart ID (required)"),
1857
+ discountCode: z15.string().describe("Discount code to apply (required)")
1720
1858
  };
1721
- var metadata16 = {
1859
+ var metadata17 = {
1722
1860
  name: "apply-discount",
1723
1861
  description: "Apply a discount code to a cart. Validates the code, updates cart totals, and sets free shipping if applicable.",
1724
1862
  annotations: {
@@ -1742,11 +1880,11 @@ async function applyDiscount({
1742
1880
  }
1743
1881
 
1744
1882
  // src/tools/remove-discount.ts
1745
- import { z as z17 } from "zod";
1746
- var schema17 = {
1747
- cartId: z17.string().min(1).describe("Cart ID (required)")
1883
+ import { z as z16 } from "zod";
1884
+ var schema18 = {
1885
+ cartId: z16.string().min(1).describe("Cart ID (required)")
1748
1886
  };
1749
- var metadata17 = {
1887
+ var metadata18 = {
1750
1888
  name: "remove-discount",
1751
1889
  description: "Remove the applied discount code from a cart and recalculate totals.",
1752
1890
  annotations: {
@@ -1769,11 +1907,11 @@ async function removeDiscount({
1769
1907
  }
1770
1908
 
1771
1909
  // src/tools/clear-cart.ts
1772
- import { z as z18 } from "zod";
1773
- var schema18 = {
1774
- cartId: z18.string().min(1).describe("Cart ID (required)")
1910
+ import { z as z17 } from "zod";
1911
+ var schema19 = {
1912
+ cartId: z17.string().min(1).describe("Cart ID (required)")
1775
1913
  };
1776
- var metadata18 = {
1914
+ var metadata19 = {
1777
1915
  name: "clear-cart",
1778
1916
  description: "Remove all items from a cart, reset discount and amounts. Shipping fee is preserved.",
1779
1917
  annotations: {
@@ -1796,12 +1934,12 @@ async function clearCart({
1796
1934
  }
1797
1935
 
1798
1936
  // src/tools/validate-discount.ts
1799
- import { z as z19 } from "zod";
1800
- var schema19 = {
1801
- code: z19.string().describe("Discount code to validate (required)"),
1802
- orderAmount: z19.number().describe("Order amount for validation (required)")
1937
+ import { z as z18 } from "zod";
1938
+ var schema20 = {
1939
+ code: z18.string().describe("Discount code to validate (required)"),
1940
+ orderAmount: z18.number().describe("Order amount for validation (required)")
1803
1941
  };
1804
- var metadata19 = {
1942
+ var metadata20 = {
1805
1943
  name: "validate-discount",
1806
1944
  description: "Validate a discount code. Checks active status, date range, usage limits, minimum order amount, and calculates discount.",
1807
1945
  annotations: {
@@ -1828,13 +1966,13 @@ async function validateDiscount({
1828
1966
  }
1829
1967
 
1830
1968
  // src/tools/calculate-shipping.ts
1831
- import { z as z20 } from "zod";
1832
- var schema20 = {
1833
- shippingPolicyId: z20.string().optional().describe("Shipping policy ID (uses default policy if omitted)"),
1834
- orderAmount: z20.number().describe("Order amount for fee calculation (required)"),
1835
- postalCode: z20.string().optional().describe("Postal code for Jeju surcharge detection (63000-63644)")
1969
+ import { z as z19 } from "zod";
1970
+ var schema21 = {
1971
+ shippingPolicyId: z19.string().optional().describe("Shipping policy ID (uses default policy if omitted)"),
1972
+ orderAmount: z19.number().describe("Order amount for fee calculation (required)"),
1973
+ postalCode: z19.string().optional().describe("Postal code for Jeju surcharge detection (63000-63644)")
1836
1974
  };
1837
- var metadata20 = {
1975
+ var metadata21 = {
1838
1976
  name: "calculate-shipping",
1839
1977
  description: "Calculate shipping fee based on order amount and postal code. Supports free shipping threshold and Jeju surcharge.",
1840
1978
  annotations: {
@@ -1863,18 +2001,18 @@ async function calculateShipping({
1863
2001
  }
1864
2002
 
1865
2003
  // src/tools/stock-check.ts
1866
- import { z as z21 } from "zod";
1867
- var schema21 = {
1868
- items: z21.array(
1869
- z21.object({
1870
- variantId: z21.string().describe("Product variant ID"),
1871
- quantity: z21.number().int().positive().describe("Requested quantity")
2004
+ import { z as z20 } from "zod";
2005
+ var schema22 = {
2006
+ items: z20.array(
2007
+ z20.object({
2008
+ variantId: z20.string().describe("Product variant ID"),
2009
+ quantity: z20.number().int().positive().describe("Requested quantity")
1872
2010
  })
1873
2011
  ).describe(
1874
2012
  "Array of items to check stock for (required, max 100). Each: { variantId, quantity }"
1875
2013
  )
1876
2014
  };
1877
- var metadata21 = {
2015
+ var metadata22 = {
1878
2016
  name: "stock-check",
1879
2017
  description: "Batch check product option stock availability. Returns per-item availability and an allAvailable flag.",
1880
2018
  annotations: {
@@ -1897,12 +2035,12 @@ async function stockCheck({
1897
2035
  }
1898
2036
 
1899
2037
  // src/tools/product-detail.ts
1900
- import { z as z22 } from "zod";
1901
- var schema22 = {
1902
- slug: z22.string().optional().describe("Product slug (one of slug or id required)"),
1903
- id: z22.string().optional().describe("Product id (one of slug or id required)")
2038
+ import { z as z21 } from "zod";
2039
+ var schema23 = {
2040
+ slug: z21.string().optional().describe("Product slug (one of slug or id required)"),
2041
+ id: z21.string().optional().describe("Product id (one of slug or id required)")
1904
2042
  };
1905
- var metadata22 = {
2043
+ var metadata23 = {
1906
2044
  name: "product-detail",
1907
2045
  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 null if missing/unpublished/wrong tenant/feature disabled.",
1908
2046
  annotations: {
@@ -1930,66 +2068,66 @@ async function productDetail({
1930
2068
  }
1931
2069
 
1932
2070
  // src/tools/product-upsert.ts
1933
- import { z as z23 } from "zod";
1934
- var optionValueSchema = z23.object({
1935
- id: z23.string().optional().describe("Stable existing option-value ID for rename-safe updates"),
1936
- value: z23.string().describe("Display label (e.g. Black, S)"),
1937
- slug: z23.string().optional().describe(
2071
+ import { z as z22 } from "zod";
2072
+ var optionValueSchema = z22.object({
2073
+ id: z22.string().optional().describe("Stable existing option-value ID for rename-safe updates"),
2074
+ value: z22.string().describe("Display label (e.g. Black, S)"),
2075
+ slug: z22.string().optional().describe(
1938
2076
  "Optional compatibility value token. The server generates one from value on create when omitted; not canonical identity."
1939
2077
  ),
1940
- swatchColor: z23.string().nullable().optional(),
1941
- thumbnail: z23.string().nullable().optional(),
1942
- images: z23.array(z23.string()).optional(),
1943
- metadata: z23.unknown().optional()
2078
+ swatchColor: z22.string().nullable().optional(),
2079
+ thumbnail: z22.string().nullable().optional(),
2080
+ images: z22.array(z22.string()).optional(),
2081
+ metadata: z22.unknown().optional()
1944
2082
  });
1945
- var optionSchema = z23.object({
1946
- id: z23.string().optional().describe("Stable existing option ID for rename-safe updates"),
1947
- title: z23.string().describe("Option name (e.g. Color, Size)"),
1948
- slug: z23.string().optional().describe(
2083
+ var optionSchema = z22.object({
2084
+ id: z22.string().optional().describe("Stable existing option ID for rename-safe updates"),
2085
+ title: z22.string().describe("Option name (e.g. Color, Size)"),
2086
+ slug: z22.string().optional().describe(
1949
2087
  "Optional compatibility option token. The server generates one from title on create when omitted; not canonical identity."
1950
2088
  ),
1951
- values: z23.array(optionValueSchema).describe("Allowed option values")
2089
+ values: z22.array(optionValueSchema).describe("Allowed option values")
1952
2090
  });
1953
- var variantOptionValueSchema = z23.object({
1954
- valueSlug: z23.string().optional(),
1955
- valueId: z23.string().optional(),
1956
- value: z23.string().optional()
2091
+ var variantOptionValueSchema = z22.object({
2092
+ valueSlug: z22.string().optional(),
2093
+ valueId: z22.string().optional(),
2094
+ value: z22.string().optional()
1957
2095
  });
1958
- var variantSchema = z23.object({
1959
- id: z23.string().optional().describe("Existing variant ID for updates"),
1960
- optionValues: z23.union([
1961
- z23.record(z23.string(), z23.union([z23.string(), variantOptionValueSchema])),
1962
- z23.array(z23.string())
2096
+ var variantSchema = z22.object({
2097
+ id: z22.string().optional().describe("Existing variant ID for updates"),
2098
+ optionValues: z22.union([
2099
+ z22.record(z22.string(), z22.union([z22.string(), variantOptionValueSchema])),
2100
+ z22.array(z22.string())
1963
2101
  ]).optional().describe(
1964
2102
  "Option-value selection. Prefer stable option-value IDs, either as an array or object values using { valueId }. Slug maps and exact { OptionTitle: ValueLabel } maps remain compatibility-only and fail when labels are ambiguous."
1965
2103
  ),
1966
- sku: z23.string().nullable().optional(),
1967
- title: z23.string().nullable().optional(),
1968
- price: z23.number().nonnegative().describe("Selling price (KRW, min 0)"),
1969
- compareAtPrice: z23.number().nonnegative().nullable().optional(),
1970
- stock: z23.number().int().nonnegative().optional(),
1971
- isUnlimited: z23.boolean().optional(),
1972
- weight: z23.number().nonnegative().nullable().optional(),
1973
- requiresShipping: z23.boolean().optional(),
1974
- barcode: z23.string().nullable().optional(),
1975
- externalId: z23.string().nullable().optional(),
1976
- isActive: z23.boolean().optional(),
1977
- thumbnail: z23.string().nullable().optional(),
1978
- images: z23.array(z23.string()).optional(),
1979
- metadata: z23.unknown().optional()
2104
+ sku: z22.string().nullable().optional(),
2105
+ title: z22.string().nullable().optional(),
2106
+ price: z22.number().nonnegative().describe("Selling price (KRW, min 0)"),
2107
+ compareAtPrice: z22.number().nonnegative().nullable().optional(),
2108
+ stock: z22.number().int().nonnegative().optional(),
2109
+ isUnlimited: z22.boolean().optional(),
2110
+ weight: z22.number().nonnegative().nullable().optional(),
2111
+ requiresShipping: z22.boolean().optional(),
2112
+ barcode: z22.string().nullable().optional(),
2113
+ externalId: z22.string().nullable().optional(),
2114
+ isActive: z22.boolean().optional(),
2115
+ thumbnail: z22.string().nullable().optional(),
2116
+ images: z22.array(z22.string()).optional(),
2117
+ metadata: z22.unknown().optional()
1980
2118
  });
1981
- var schema23 = {
1982
- product: z23.record(z23.string(), z23.unknown()).describe(
2119
+ var schema24 = {
2120
+ product: z22.record(z22.string(), z22.unknown()).describe(
1983
2121
  "Product fields. Include `id` to update an existing product; omit for create (then `title` is required)."
1984
2122
  ),
1985
- options: z23.array(optionSchema).optional().describe(
2123
+ options: z22.array(optionSchema).optional().describe(
1986
2124
  "Option definitions. Include stable option/value IDs when updating or renaming existing rows. Slugs are optional compatibility metadata generated from title/value on create when omitted; omitted options on an existing product are deleted (with their values)."
1987
2125
  ),
1988
- variants: z23.array(variantSchema).optional().describe(
2126
+ variants: z22.array(variantSchema).optional().describe(
1989
2127
  "Variant rows. Prefer stable option-value IDs in optionValues. Slug/title maps are compatibility inputs. Omitted variants on an existing product are deleted, unless referenced by an active cart or non-terminal order \u2014 those are soft-deactivated (isActive: false)."
1990
2128
  )
1991
2129
  };
1992
- var metadata23 = {
2130
+ var metadata24 = {
1993
2131
  name: "product-upsert",
1994
2132
  description: "Atomically create or update a product together with its options, option-values, and variants in a single transaction. Mirrors Shopify productSet semantics. Any failure rolls back the entire write.",
1995
2133
  annotations: {
@@ -2026,8 +2164,8 @@ async function getCollectionSchema(collection) {
2026
2164
  }
2027
2165
 
2028
2166
  // src/tools/get-collection-schema.ts
2029
- var schema24 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
2030
- var metadata24 = {
2167
+ var schema25 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
2168
+ var metadata25 = {
2031
2169
  name: "get-collection-schema",
2032
2170
  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.",
2033
2171
  annotations: {
@@ -2078,8 +2216,8 @@ async function getTenantFeatureProgress(feature, includeEvidence = false) {
2078
2216
  }
2079
2217
 
2080
2218
  // src/tools/get-tenant-context.ts
2081
- var schema25 = tenantContextToolInputSchema.shape;
2082
- var metadata25 = {
2219
+ var schema26 = tenantContextToolInputSchema.shape;
2220
+ var metadata26 = {
2083
2221
  name: "get-tenant-context",
2084
2222
  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.",
2085
2223
  annotations: {
@@ -2156,8 +2294,8 @@ async function handler({
2156
2294
  }
2157
2295
 
2158
2296
  // src/tools/check-feature-progress.ts
2159
- var schema26 = tenantFeatureProgressInputSchema.shape;
2160
- var metadata26 = {
2297
+ var schema27 = tenantFeatureProgressInputSchema.shape;
2298
+ var metadata27 = {
2161
2299
  name: "check-feature-progress",
2162
2300
  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.",
2163
2301
  annotations: {
@@ -2180,7 +2318,7 @@ async function handler2({
2180
2318
  }
2181
2319
 
2182
2320
  // src/tools/list-configurable-fields.ts
2183
- import { z as z24 } from "zod";
2321
+ import { z as z23 } from "zod";
2184
2322
 
2185
2323
  // src/lib/field-config.ts
2186
2324
  async function fetchFieldConfigs() {
@@ -2203,12 +2341,12 @@ function invalidateFieldConfigCache() {
2203
2341
  }
2204
2342
 
2205
2343
  // src/tools/list-configurable-fields.ts
2206
- var schema27 = {
2207
- collection: z24.string().optional().describe(
2344
+ var schema28 = {
2345
+ collection: z23.string().optional().describe(
2208
2346
  "Filter by collection slug (optional \u2014 returns all if omitted). Use this filter to reduce response size when you know which collection to check."
2209
2347
  )
2210
2348
  };
2211
- var metadata27 = {
2349
+ var metadata28 = {
2212
2350
  name: "list-configurable-fields",
2213
2351
  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.",
2214
2352
  annotations: {
@@ -2239,17 +2377,17 @@ async function listConfigurableFields(params) {
2239
2377
  }
2240
2378
 
2241
2379
  // src/tools/update-field-config.ts
2242
- import { z as z25 } from "zod";
2243
- var schema28 = {
2244
- collection: z25.string().min(1).describe("Collection slug (required)"),
2245
- hiddenFields: z25.array(z25.string().min(1).max(200)).max(300).describe(
2380
+ import { z as z24 } from "zod";
2381
+ var schema29 = {
2382
+ collection: z24.string().min(1).describe("Collection slug (required)"),
2383
+ hiddenFields: z24.array(z24.string().min(1).max(200)).max(300).describe(
2246
2384
  "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."
2247
2385
  ),
2248
- isHidden: z25.boolean().optional().describe(
2386
+ isHidden: z24.boolean().optional().describe(
2249
2387
  "Hide the entire collection from Admin Panel (optional). When true, individual hiddenFields are irrelevant."
2250
2388
  )
2251
2389
  };
2252
- var metadata28 = {
2390
+ var metadata29 = {
2253
2391
  name: "update-field-config",
2254
2392
  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.",
2255
2393
  annotations: {
@@ -2277,7 +2415,7 @@ async function updateFieldConfig(params) {
2277
2415
  }
2278
2416
 
2279
2417
  // src/tools/sdk-get-recipe.ts
2280
- import { z as z26 } from "zod";
2418
+ import { z as z25 } from "zod";
2281
2419
 
2282
2420
  // src/lib/sdk-recipes.ts
2283
2421
  var recipes = {
@@ -2718,8 +2856,8 @@ function getRecipe(goal, runtime = "both") {
2718
2856
  }
2719
2857
 
2720
2858
  // src/tools/sdk-get-recipe.ts
2721
- var schema29 = {
2722
- goal: z26.enum([
2859
+ var schema30 = {
2860
+ goal: z25.enum([
2723
2861
  "fetch-list",
2724
2862
  "fetch-by-id",
2725
2863
  "create-item",
@@ -2731,11 +2869,11 @@ var schema29 = {
2731
2869
  "file-upload",
2732
2870
  "bulk-operations"
2733
2871
  ]).describe("What the user wants to accomplish"),
2734
- runtime: z26.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
2735
- collection: z26.string().optional().describe("Specific collection name if applicable"),
2736
- includeExample: z26.boolean().default(true).describe("Whether to include a full code example")
2872
+ runtime: z25.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
2873
+ collection: z25.string().optional().describe("Specific collection name if applicable"),
2874
+ includeExample: z25.boolean().default(true).describe("Whether to include a full code example")
2737
2875
  };
2738
- var metadata29 = {
2876
+ var metadata30 = {
2739
2877
  name: "sdk-get-recipe",
2740
2878
  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.",
2741
2879
  annotations: {
@@ -2778,7 +2916,7 @@ function handler3({
2778
2916
  }
2779
2917
 
2780
2918
  // src/tools/sdk-search-docs.ts
2781
- import { z as z27 } from "zod";
2919
+ import { z as z26 } from "zod";
2782
2920
 
2783
2921
  // src/lib/sdk-doc-index.ts
2784
2922
  var docIndex = [
@@ -2906,8 +3044,19 @@ var docIndex = [
2906
3044
  // Webhooks
2907
3045
  {
2908
3046
  title: "Webhooks",
2909
- keywords: ["webhook", "hmac", "signature", "WEBHOOK_SECRET", "server-to-server", "event"],
2910
- summary: "Tenant webhooks deliver server-to-server events such as password reset tokens. Signed with HMAC-SHA256 using PAYLOAD_SECRET.",
3047
+ keywords: [
3048
+ "webhook",
3049
+ "hmac",
3050
+ "signature",
3051
+ "WEBHOOK_SECRET",
3052
+ "server-to-server",
3053
+ "event",
3054
+ "order",
3055
+ "orderChanged",
3056
+ "collection.orderChanged",
3057
+ "isOrderChangedWebhookEvent"
3058
+ ],
3059
+ summary: "Tenant webhooks deliver signed server-to-server events via WEBHOOK_SECRET, including customer password reset and semantic order changes with collection.orderChanged / isOrderChangedWebhookEvent.",
2911
3060
  resourceUri: "docs://sdk/webhook"
2912
3061
  },
2913
3062
  // Order API
@@ -2953,11 +3102,11 @@ function searchDocs(query, limit = 5) {
2953
3102
  }
2954
3103
 
2955
3104
  // src/tools/sdk-search-docs.ts
2956
- var schema30 = {
2957
- query: z27.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
2958
- limit: z27.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
3105
+ var schema31 = {
3106
+ query: z26.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
3107
+ limit: z26.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
2959
3108
  };
2960
- var metadata30 = {
3109
+ var metadata31 = {
2961
3110
  name: "sdk-search-docs",
2962
3111
  description: "Search SDK documentation by keyword. Returns matching topics with summaries and resource links. Use when looking for specific SDK features or patterns.",
2963
3112
  annotations: {
@@ -2992,9 +3141,9 @@ function handler4({
2992
3141
  }
2993
3142
 
2994
3143
  // src/tools/sdk-get-auth-setup.ts
2995
- import { z as z28 } from "zod";
2996
- var schema31 = {
2997
- scenario: z28.enum([
3144
+ import { z as z27 } from "zod";
3145
+ var schema32 = {
3146
+ scenario: z27.enum([
2998
3147
  "browser-client",
2999
3148
  "server-client",
3000
3149
  "customer-auth",
@@ -3003,7 +3152,7 @@ var schema31 = {
3003
3152
  "webhook-verification"
3004
3153
  ]).describe("Authentication scenario")
3005
3154
  };
3006
- var metadata31 = {
3155
+ var metadata32 = {
3007
3156
  name: "sdk-get-auth-setup",
3008
3157
  description: "Get the current authentication setup for a specific scenario. Returns env var names, code snippets, and security notes.",
3009
3158
  annotations: {
@@ -3127,13 +3276,19 @@ export SOFTWARE_SECRET_KEY=sk01_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
3127
3276
  envVars: ["WEBHOOK_SECRET"],
3128
3277
  code: `import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
3129
3278
 
3279
+ function getWebhookSecret(): string {
3280
+ const secret = process.env.WEBHOOK_SECRET
3281
+ if (!secret) throw new Error('WEBHOOK_SECRET is required')
3282
+ return secret
3283
+ }
3284
+
3130
3285
  const customerAuthHandler = createCustomerAuthWebhookHandler({
3131
3286
  passwordReset: sendPasswordResetEmail,
3132
3287
  })
3133
3288
 
3134
3289
  export async function POST(request: Request) {
3135
3290
  return handleWebhook(request, customerAuthHandler, {
3136
- secret: process.env.WEBHOOK_SECRET!,
3291
+ secret: getWebhookSecret(),
3137
3292
  })
3138
3293
  }`,
3139
3294
  notes: [
@@ -3159,14 +3314,14 @@ function handler5({
3159
3314
  }
3160
3315
 
3161
3316
  // src/tools/sdk-get-collection-pattern.ts
3162
- import { z as z29 } from "zod";
3317
+ import { z as z28 } from "zod";
3163
3318
  import { COLLECTIONS, SERVER_COLLECTIONS as SERVER_COLLECTIONS4 } from "@01.software/sdk";
3164
- var schema32 = {
3165
- collection: z29.enum(SERVER_COLLECTIONS4).describe("Collection name"),
3166
- operation: z29.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
3167
- surface: z29.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
3319
+ var schema33 = {
3320
+ collection: z28.enum(SERVER_COLLECTIONS4).describe("Collection name"),
3321
+ operation: z28.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
3322
+ surface: z28.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
3168
3323
  };
3169
- var metadata32 = {
3324
+ var metadata33 = {
3170
3325
  name: "sdk-get-collection-pattern",
3171
3326
  description: "Get the recommended CRUD pattern for a specific collection. Returns code examples for the chosen API surface and operation type.",
3172
3327
  annotations: {
@@ -3362,14 +3517,14 @@ function handler6({
3362
3517
  }
3363
3518
 
3364
3519
  // src/prompts/sdk-usage-guide.ts
3365
- import { z as z30 } from "zod";
3366
- var schema33 = {
3367
- goal: z30.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
3368
- runtime: z30.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
3369
- surface: z30.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
3370
- collection: z30.string().optional().describe("Specific collection if relevant")
3520
+ import { z as z29 } from "zod";
3521
+ var schema34 = {
3522
+ goal: z29.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
3523
+ runtime: z29.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
3524
+ surface: z29.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
3525
+ collection: z29.string().optional().describe("Specific collection if relevant")
3371
3526
  };
3372
- var metadata33 = {
3527
+ var metadata34 = {
3373
3528
  name: "sdk-usage-guide",
3374
3529
  title: "SDK Usage Guide",
3375
3530
  description: "Provides guidance on how to perform a specific task using the 01.software SDK",
@@ -3540,14 +3695,14 @@ const { allAvailable } = await client.commerce.product.stockCheck({
3540
3695
  }
3541
3696
 
3542
3697
  // src/prompts/collection-query-help.ts
3543
- import { z as z31 } from "zod";
3698
+ import { z as z30 } from "zod";
3544
3699
  import { COLLECTIONS as COLLECTIONS2, SERVER_COLLECTIONS as SERVER_COLLECTIONS5 } from "@01.software/sdk";
3545
- var schema34 = {
3546
- collection: z31.enum(SERVER_COLLECTIONS5).describe("Collection name"),
3547
- operation: z31.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
3548
- filters: z31.string().optional().describe("Filter conditions (JSON string, optional)")
3700
+ var schema35 = {
3701
+ collection: z30.enum(SERVER_COLLECTIONS5).describe("Collection name"),
3702
+ operation: z30.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
3703
+ filters: z30.string().optional().describe("Filter conditions (JSON string, optional)")
3549
3704
  };
3550
- var metadata34 = {
3705
+ var metadata35 = {
3551
3706
  name: "collection-query-help",
3552
3707
  title: "Collection Query Help",
3553
3708
  description: "Provides guidance on how to write queries for a specific collection",
@@ -3644,16 +3799,16 @@ ${operation === "find" ? `- Use \`where\` option for filtering (Payload query sy
3644
3799
  }
3645
3800
 
3646
3801
  // src/prompts/order-flow-guide.ts
3647
- import { z as z32 } from "zod";
3648
- var schema35 = {
3649
- scenario: z32.enum([
3802
+ import { z as z31 } from "zod";
3803
+ var schema36 = {
3804
+ scenario: z31.enum([
3650
3805
  "simple-order",
3651
3806
  "cart-checkout",
3652
3807
  "return-refund",
3653
3808
  "fulfillment-tracking"
3654
3809
  ]).describe("Order flow scenario")
3655
3810
  };
3656
- var metadata35 = {
3811
+ var metadata36 = {
3657
3812
  name: "order-flow-guide",
3658
3813
  title: "Order Flow Guide",
3659
3814
  description: "Provides step-by-step guidance for ecommerce order flows including creation, checkout, returns, and fulfillment.",
@@ -3668,9 +3823,10 @@ var SCENARIOS = {
3668
3823
  - Provide: orderNumber, customerSnapshot (email required), shippingAddress, orderItems, totalAmount
3669
3824
  - Optional: pgPaymentId (omit for free orders), shippingAmount, discountCode
3670
3825
 
3671
- 2. **Payment Confirmation** \u2192 \`update-transaction\` tool
3672
- - Confirm provider payment with pgPaymentId, paymentKey, and amount
3673
- - Stock is automatically adjusted (stock -= qty, reservedStock += qty)
3826
+ 2. **Payment Confirmation** \u2192 ServerClient \`commerce.orders.confirmPayment()\`
3827
+ - Confirm provider payment with pgPaymentId, provider name, and amount
3828
+ - Successful confirmation transitions the order to \`paid\`
3829
+ - Paid orders reserve sellable quantity (reservedStock += qty); physical stock is decremented on delivery
3674
3830
 
3675
3831
  3. **Fulfillment** \u2192 \`create-fulfillment\` tool
3676
3832
  - Provide carrier + trackingNumber for shipped status
@@ -3690,18 +3846,20 @@ const client = createServerClient({
3690
3846
  const order = await client.commerce.orders.create({
3691
3847
  orderNumber: 'ORD-240101-001',
3692
3848
  customerSnapshot: { email: 'user@example.com', name: 'John' },
3693
- shippingAddress: { postalCode: '06000', address1: '123 Main St' },
3849
+ shippingAddress: { postalCode: '06000', address: '123 Main St' },
3694
3850
  orderItems: [{ product: 'prod-id', variant: 'var-id', option: 'opt-id', quantity: 2 }],
3695
3851
  totalAmount: 59800,
3696
3852
  pgPaymentId: 'pay_xxx' // omit for free orders
3697
3853
  })
3698
3854
 
3699
3855
  // 2. After payment confirmed by provider
3700
- await client.commerce.orders.updateTransaction({
3856
+ await client.commerce.orders.confirmPayment({
3857
+ orderNumber: 'ORD-240101-001',
3701
3858
  pgPaymentId: 'pay_xxx',
3702
- status: 'paid',
3703
- paymentKey: 'payment_key_xxx',
3704
- amount: 59800
3859
+ pgProvider: 'provider',
3860
+ amount: 59800,
3861
+ paymentMethod: 'card',
3862
+ confirmationSource: 'provider_api_confirm'
3705
3863
  })
3706
3864
 
3707
3865
  // 3. Ship items
@@ -3720,7 +3878,7 @@ await client.commerce.orders.createFulfillment({
3720
3878
  2. **Apply Discount** (optional) \u2192 \`apply-discount\` tool
3721
3879
  3. **Calculate Shipping** \u2192 \`calculate-shipping\` tool
3722
3880
  4. **Checkout** \u2192 \`checkout\` tool (converts cart to order)
3723
- 5. **Payment** \u2192 \`update-transaction\` for provider-verified paid transitions
3881
+ 5. **Payment** \u2192 ServerClient \`commerce.orders.confirmPayment()\` for provider-verified paid transitions
3724
3882
 
3725
3883
  ### Key Points
3726
3884
  - Cart has a customer linked \u2014 auto-copied to order on checkout
@@ -3833,14 +3991,14 @@ ${SCENARIOS[scenario] || "Unknown scenario."}
3833
3991
  - \`checkout\`
3834
3992
  - \`create-fulfillment\`, \`update-fulfillment\`
3835
3993
  - \`create-return\`, \`update-return\`, \`return-with-refund\`
3836
- - \`update-transaction\`
3994
+ - \`confirm-payment\`, \`update-transaction\`
3837
3995
  - \`validate-discount\`, \`calculate-shipping\``;
3838
3996
  }
3839
3997
 
3840
3998
  // src/prompts/feature-setup-guide.ts
3841
- import { z as z33 } from "zod";
3842
- var schema36 = {
3843
- feature: z33.enum([
3999
+ import { z as z32 } from "zod";
4000
+ var schema37 = {
4001
+ feature: z32.enum([
3844
4002
  "ecommerce",
3845
4003
  "customers",
3846
4004
  "articles",
@@ -3855,7 +4013,7 @@ var schema36 = {
3855
4013
  "community"
3856
4014
  ]).describe("Feature to get setup guide for")
3857
4015
  };
3858
- var metadata36 = {
4016
+ var metadata37 = {
3859
4017
  name: "feature-setup-guide",
3860
4018
  title: "Feature Setup Guide",
3861
4019
  description: "Setup checklist and remediation guide for a tenant feature. Load with check-feature-progress and get-tenant-context to diagnose setup gaps.",
@@ -3904,7 +4062,6 @@ customer-addresses
3904
4062
  ### Optional Collections
3905
4063
 
3906
4064
  - customer-groups \u2014 Console/server-scoped segmentation for VIP coupons and campaigns. Use \`createServerClient().collections.from('customer-groups')\`.
3907
- - customer-profile-lists \u2014 Public profile display/ranking lists for storefronts. Browser reads may use \`client.collections.from('customer-profile-lists')\`.
3908
4065
 
3909
4066
  ### Config
3910
4067
 
@@ -4045,7 +4202,9 @@ comments, reactions, bookmarks, reports, community-bans
4045
4202
 
4046
4203
  ### Optional Collections
4047
4204
 
4048
- post-categories, customer-profile-lists`
4205
+ post-categories, customer-profile-lists
4206
+
4207
+ - \`customer-profile-lists\` is Community-owned public profile curation. It composes \`customer-profiles\`, so effective Community access also requires Customers.`
4049
4208
  };
4050
4209
  function featureSetupGuide({
4051
4210
  feature
@@ -4062,7 +4221,7 @@ ${FEATURES[feature] || "Unknown feature."}
4062
4221
  }
4063
4222
 
4064
4223
  // src/resources/(config)/app.ts
4065
- var metadata37 = {
4224
+ var metadata38 = {
4066
4225
  name: "app-config",
4067
4226
  title: "Application Config",
4068
4227
  description: "01.software SDK and MCP server configuration information"
@@ -4106,7 +4265,7 @@ The hosted HTTP MCP endpoint at https://mcp.01.software/mcp exposes only these O
4106
4265
  - \`sdk-get-auth-setup\` - Get framework-specific auth setup guidance
4107
4266
  - \`sdk-get-collection-pattern\` - Get collection-specific usage patterns
4108
4267
 
4109
- ## Local CLI Stdio Surface (30)
4268
+ ## Local CLI Stdio Surface (33)
4110
4269
 
4111
4270
  For trusted local server-key workflows, start the stdio server:
4112
4271
 
@@ -4114,7 +4273,7 @@ For trusted local server-key workflows, start the stdio server:
4114
4273
  npx @01.software/cli mcp
4115
4274
  \`\`\`
4116
4275
 
4117
- Local stdio can expose generic read, order, return, cart, validation, stock, schema, tenant context, feature progress, field config, and guidance tools. Generic collection write tools (create/update/delete/update-many/delete-many) are intentionally absent on every transport; use the SDK server client for generic writes.
4276
+ Local stdio can expose generic read, order, payment confirmation, return, cart, validation, stock, schema, tenant context, feature progress, field config, and guidance tools. Generic collection write tools (create/update/delete/update-many/delete-many) are intentionally absent on every transport; use the SDK server client for generic writes.
4118
4277
 
4119
4278
  ## Rate Limits
4120
4279
 
@@ -4128,7 +4287,7 @@ Rate limits depend on your tenant plan:
4128
4287
 
4129
4288
  // src/resources/(collections)/schema.ts
4130
4289
  import { COLLECTIONS as COLLECTIONS3 } from "@01.software/sdk";
4131
- var metadata38 = {
4290
+ var metadata39 = {
4132
4291
  name: "collections-schema",
4133
4292
  title: "Collection Schema Info",
4134
4293
  description: "Available collections and their schema information"
@@ -4158,12 +4317,7 @@ var COLLECTIONS_BY_CATEGORY = {
4158
4317
  "shipping-policies",
4159
4318
  "shipping-zones"
4160
4319
  ],
4161
- Customers: [
4162
- "customers",
4163
- "customer-profiles",
4164
- "customer-profile-lists",
4165
- "customer-addresses"
4166
- ],
4320
+ Customers: ["customers", "customer-profiles", "customer-addresses"],
4167
4321
  Carts: ["carts", "cart-items"],
4168
4322
  Discounts: ["discounts"],
4169
4323
  Documents: ["documents", "document-categories", "document-types"],
@@ -4179,7 +4333,8 @@ var COLLECTIONS_BY_CATEGORY = {
4179
4333
  "reactions",
4180
4334
  "reaction-types",
4181
4335
  "bookmarks",
4182
- "post-categories"
4336
+ "post-categories",
4337
+ "customer-profile-lists"
4183
4338
  ],
4184
4339
  Playlists: [
4185
4340
  "playlists",
@@ -4269,7 +4424,7 @@ Total available collections: ${COLLECTIONS3.length}`;
4269
4424
  }
4270
4425
 
4271
4426
  // src/resources/(docs)/getting-started.ts
4272
- var metadata39 = {
4427
+ var metadata40 = {
4273
4428
  name: "docs-getting-started",
4274
4429
  title: "Getting Started",
4275
4430
  description: "01.software SDK getting started guide"
@@ -4330,7 +4485,7 @@ const result = await client.collections.from('products').find({
4330
4485
  }
4331
4486
 
4332
4487
  // src/resources/(docs)/guides.ts
4333
- var metadata40 = {
4488
+ var metadata41 = {
4334
4489
  name: "docs-guides",
4335
4490
  title: "Guides",
4336
4491
  description: "01.software SDK usage guides"
@@ -4543,7 +4698,7 @@ For more implementation guidance, see the [SDK Guide](/developers/sdk).`;
4543
4698
  }
4544
4699
 
4545
4700
  // src/resources/(docs)/api.ts
4546
- var metadata41 = {
4701
+ var metadata42 = {
4547
4702
  name: "docs-api",
4548
4703
  title: "API Reference",
4549
4704
  description: "01.software SDK API reference documentation"
@@ -4826,7 +4981,7 @@ For more details, see the [API documentation](/developers/api).`;
4826
4981
  }
4827
4982
 
4828
4983
  // src/resources/(docs)/query-builder.ts
4829
- var metadata42 = {
4984
+ var metadata43 = {
4830
4985
  name: "docs-query-builder",
4831
4986
  title: "Query Builder",
4832
4987
  description: "01.software SDK Query Builder API reference (client.collections.from)"
@@ -5020,7 +5175,7 @@ console.log(result.hasNextPage) // true
5020
5175
  }
5021
5176
 
5022
5177
  // src/resources/(docs)/react-query.ts
5023
- var metadata43 = {
5178
+ var metadata44 = {
5024
5179
  name: "docs-react-query",
5025
5180
  title: "React Query Hooks",
5026
5181
  description: "01.software SDK React Query hooks reference (@01.software/sdk/query)"
@@ -5252,7 +5407,7 @@ export function ProductList() {
5252
5407
  }
5253
5408
 
5254
5409
  // src/resources/(docs)/server-api.ts
5255
- var metadata44 = {
5410
+ var metadata45 = {
5256
5411
  name: "docs-server-api",
5257
5412
  title: "Server-side API",
5258
5413
  description: "01.software SDK server-side API reference (client.commerce) for orders, fulfillments, returns, carts, and validation"
@@ -5290,16 +5445,16 @@ const order = await client.commerce.orders.create({
5290
5445
  recipientName: 'John Doe',
5291
5446
  phone: '+821012345678',
5292
5447
  postalCode: '06234',
5293
- address1: '123 Main St',
5294
- address2: 'Apt 4B',
5448
+ address: '123 Main St',
5449
+ detailAddress: 'Apt 4B',
5295
5450
  deliveryMessage?: 'Leave at door',
5296
5451
  },
5297
5452
  orderItems: [
5298
- { product: 'product-id', variant: 'variant-id', option: 'option-id', quantity: 2, unitPrice: 29900 }
5453
+ { product: 'product-id', variant: 'variant-id', option: 'option-id', quantity: 2 }
5299
5454
  ],
5300
5455
  totalAmount: 59800,
5301
5456
  shippingAmount?: 3000,
5302
- pgPaymentId?: 'toss-payment-id', // omit for free orders
5457
+ pgPaymentId?: 'provider-payment-id', // omit for free orders
5303
5458
  })
5304
5459
  \`\`\`
5305
5460
 
@@ -5311,7 +5466,7 @@ const order = await client.commerce.orders.checkout({
5311
5466
  cartId: 'cart-id',
5312
5467
  orderNumber: 'ORD-20240101-0001',
5313
5468
  customerSnapshot: { name: 'John Doe', email: 'john@example.com' },
5314
- pgPaymentId?: 'toss-payment-id',
5469
+ pgPaymentId?: 'provider-payment-id',
5315
5470
  })
5316
5471
  \`\`\`
5317
5472
 
@@ -5404,24 +5559,45 @@ const result = await client.commerce.orders.returnWithRefund({
5404
5559
  { orderItem: 'order-item-id', quantity: 1 }
5405
5560
  ],
5406
5561
  refundAmount: 29900,
5407
- pgPaymentId: 'toss-payment-id', // required
5408
- paymentKey: 'toss-payment-key', // required for provider refund
5562
+ pgPaymentId: 'provider-payment-id', // required
5563
+ paymentKey: 'provider-payment-key', // required for provider refund
5409
5564
  refundReceiptUrl?: 'https://...',
5410
5565
  })
5411
5566
  \`\`\`
5412
5567
 
5413
5568
  ## Transaction API
5414
5569
 
5570
+ ### confirmPayment()
5571
+ Confirm a provider-verified payment and transition the order to paid. Verify the
5572
+ payment with the provider first, then call this endpoint with the provider name,
5573
+ amount, and an idempotency event ID when available.
5574
+
5575
+ \`\`\`typescript
5576
+ const result = await client.commerce.orders.confirmPayment({
5577
+ orderNumber: 'ORD-20240101-0001',
5578
+ pgPaymentId: 'provider-payment-id',
5579
+ pgProvider: 'provider-name',
5580
+ amount: 29900,
5581
+ currency: 'KRW',
5582
+ paymentMethod: 'card',
5583
+ providerStatus: 'PAID',
5584
+ providerEventId: 'provider-event-id',
5585
+ confirmationSource: 'provider_api_confirm',
5586
+ })
5587
+ \`\`\`
5588
+
5415
5589
  ### updateTransaction()
5416
- Confirm or annotate a transaction. Paid transitions require provider
5417
- verification; non-financial annotations can still update pending transactions.
5590
+ Lower-level transaction update path. Prefer \`confirmPayment()\` for normal paid
5591
+ transitions. Use this only for compatibility paths that still require direct
5592
+ transaction annotation after provider verification, or for non-paid pending
5593
+ transaction updates.
5418
5594
 
5419
5595
  \`\`\`typescript
5420
5596
  const tx = await client.commerce.orders.updateTransaction({
5421
- pgPaymentId: 'toss-payment-id',
5422
- status: 'paid', // pending | paid | failed | canceled
5423
- paymentKey: 'toss-payment-key', // required when status is paid
5424
- amount: 29900, // required when status is paid
5597
+ pgPaymentId: 'provider-payment-id',
5598
+ status: 'failed', // pending | paid | failed | canceled
5599
+ paymentMethod: 'card',
5600
+ receiptUrl: 'https://...',
5425
5601
  })
5426
5602
  \`\`\`
5427
5603
 
@@ -5514,7 +5690,7 @@ const result = await client.commerce.shipping.calculate({
5514
5690
  }
5515
5691
 
5516
5692
  // src/resources/(docs)/customer-auth.ts
5517
- var metadata45 = {
5693
+ var metadata46 = {
5518
5694
  name: "docs-customer-auth",
5519
5695
  title: "Customer Auth API",
5520
5696
  description: "01.software SDK Customer Auth API reference (client.customer)"
@@ -5692,7 +5868,7 @@ async function loadProfile() {
5692
5868
  }
5693
5869
 
5694
5870
  // src/resources/(docs)/browser-vs-server.ts
5695
- var metadata46 = {
5871
+ var metadata47 = {
5696
5872
  name: "docs-browser-vs-server",
5697
5873
  title: "Client vs ServerClient",
5698
5874
  description: "When to use Client (createClient) vs ServerClient (createServerClient) in the 01.software SDK"
@@ -5858,7 +6034,7 @@ export function ProductList() {
5858
6034
  }
5859
6035
 
5860
6036
  // src/resources/(docs)/file-upload.ts
5861
- var metadata47 = {
6037
+ var metadata48 = {
5862
6038
  name: "docs-file-upload",
5863
6039
  title: "File Upload",
5864
6040
  description: "01.software SDK file upload patterns using the images collection"
@@ -6009,7 +6185,7 @@ The platform stores files in Cloudflare R2 and serves via CDN (\`cdn.01.software
6009
6185
  }
6010
6186
 
6011
6187
  // src/resources/(docs)/webhook.ts
6012
- var metadata48 = {
6188
+ var metadata49 = {
6013
6189
  name: "docs-webhook",
6014
6190
  title: "Webhooks",
6015
6191
  description: "01.software SDK webhook verification and event handling"
@@ -6026,6 +6202,12 @@ Use the SDK \`handleWebhook\` helper to verify signatures. For customer auth eve
6026
6202
  \`\`\`typescript
6027
6203
  import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
6028
6204
 
6205
+ function getWebhookSecret(): string {
6206
+ const secret = process.env.WEBHOOK_SECRET
6207
+ if (!secret) throw new Error('WEBHOOK_SECRET is required')
6208
+ return secret
6209
+ }
6210
+
6029
6211
  const handler = createCustomerAuthWebhookHandler({
6030
6212
  passwordReset: async (data) => {
6031
6213
  await sendPasswordResetEmail(data)
@@ -6034,7 +6216,7 @@ const handler = createCustomerAuthWebhookHandler({
6034
6216
 
6035
6217
  export async function POST(request: Request) {
6036
6218
  return handleWebhook(request, handler, {
6037
- secret: process.env.WEBHOOK_SECRET!,
6219
+ secret: getWebhookSecret(),
6038
6220
  })
6039
6221
  }
6040
6222
  \`\`\`
@@ -6047,6 +6229,12 @@ export async function POST(request: Request) {
6047
6229
  // app/api/webhooks/route.ts
6048
6230
  import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
6049
6231
 
6232
+ function getWebhookSecret(): string {
6233
+ const secret = process.env.WEBHOOK_SECRET
6234
+ if (!secret) throw new Error('WEBHOOK_SECRET is required')
6235
+ return secret
6236
+ }
6237
+
6050
6238
  const customerAuthHandler = createCustomerAuthWebhookHandler({
6051
6239
  passwordReset: sendPasswordResetEmail,
6052
6240
  })
@@ -6057,7 +6245,7 @@ export async function POST(request: Request) {
6057
6245
 
6058
6246
  await customerAuthHandler(event)
6059
6247
  }, {
6060
- secret: process.env.WEBHOOK_SECRET!,
6248
+ secret: getWebhookSecret(),
6061
6249
  })
6062
6250
  }
6063
6251
  \`\`\`
@@ -6076,6 +6264,51 @@ All webhook events share this envelope:
6076
6264
 
6077
6265
  ## Event Types
6078
6266
 
6267
+ ### Collection Order Changed
6268
+
6269
+ Admin Panel manual ordering is delivered as a semantic collection update:
6270
+
6271
+ - \`operation\` remains \`"update"\` for compatibility.
6272
+ - \`eventType\` is \`"collection.orderChanged"\`.
6273
+ - \`change.scope\` identifies collection-level ordering versus join ordering.
6274
+ - SDK handlers should use \`isOrderChangedWebhookEvent()\` from \`@01.software/sdk/webhook\`.
6275
+ - Route on public semantics such as \`change.scope.collection\`, \`change.scope.field\`, and \`change.moved.id\`.
6276
+ - Do not branch on hidden Payload order fields or private backing collections; diagnostic fields may still be present.
6277
+ - Customer group member ordering is currently unsupported and does not emit a semantic order-change webhook.
6278
+
6279
+ \`\`\`typescript
6280
+ import { handleWebhook, isOrderChangedWebhookEvent } from '@01.software/sdk/webhook'
6281
+
6282
+ function getWebhookSecret(): string {
6283
+ const secret = process.env.WEBHOOK_SECRET
6284
+ if (!secret) throw new Error('WEBHOOK_SECRET is required')
6285
+ return secret
6286
+ }
6287
+
6288
+ export async function POST(request: Request) {
6289
+ return handleWebhook(
6290
+ request,
6291
+ async (event) => {
6292
+ if (isOrderChangedWebhookEvent(event)) {
6293
+ if (event.change.scope.kind === 'join') {
6294
+ console.log('Join order changed', {
6295
+ collection: event.change.scope.collection,
6296
+ field: event.change.scope.field,
6297
+ parentId: event.change.scope.id,
6298
+ movedCollection: event.change.moved.collection,
6299
+ movedId: event.change.moved.id,
6300
+ })
6301
+ }
6302
+ return
6303
+ }
6304
+
6305
+ console.log('Content changed', event.collection, event.operation)
6306
+ },
6307
+ { secret: getWebhookSecret() },
6308
+ )
6309
+ }
6310
+ \`\`\`
6311
+
6079
6312
  ### Customer Password Reset
6080
6313
 
6081
6314
  Dispatched when a customer calls \`client.customer.forgotPassword(email)\`.
@@ -6123,7 +6356,7 @@ Configure webhook URLs in the 01.software console under Tenant Settings > Webhoo
6123
6356
  }
6124
6357
 
6125
6358
  // src/resources/(docs)/product-detail.ts
6126
- var metadata49 = {
6359
+ var metadata50 = {
6127
6360
  name: "docs-product-detail",
6128
6361
  title: "Product Detail Helper",
6129
6362
  description: "01.software SDK commerce.product.detail helper guide"
@@ -6215,7 +6448,23 @@ Log \`client.lastRequestId\` against backend logs \u2014 the endpoint records th
6215
6448
 
6216
6449
  // src/server.ts
6217
6450
  var REGISTERED_TOOLS_BY_SERVER = /* @__PURE__ */ new WeakMap();
6218
- function registerTool(server, schema37, meta, handler20) {
6451
+ function hasToolPolicy(toolName) {
6452
+ return Object.prototype.hasOwnProperty.call(TOOL_POLICY_MANIFEST, toolName);
6453
+ }
6454
+ function runtimeAnnotationsFor(meta) {
6455
+ if (!hasToolPolicy(meta.name)) {
6456
+ throw new Error(`No tool-policy entry for registered MCP tool ${meta.name}`);
6457
+ }
6458
+ const policy = TOOL_POLICY_MANIFEST[meta.name];
6459
+ return {
6460
+ title: meta.annotations?.title,
6461
+ readOnlyHint: policy.annotationPolicy.readOnly,
6462
+ destructiveHint: policy.annotationPolicy.destructive,
6463
+ idempotentHint: policy.annotationPolicy.idempotent,
6464
+ openWorldHint: policy.annotationPolicy.openWorld
6465
+ };
6466
+ }
6467
+ function registerTool(server, schema38, meta, handler20) {
6219
6468
  let registered = REGISTERED_TOOLS_BY_SERVER.get(server);
6220
6469
  if (!registered) {
6221
6470
  registered = /* @__PURE__ */ new Set();
@@ -6226,16 +6475,20 @@ function registerTool(server, schema37, meta, handler20) {
6226
6475
  meta.name,
6227
6476
  {
6228
6477
  description: meta.description,
6229
- inputSchema: schema37,
6230
- annotations: meta.annotations
6478
+ inputSchema: schema38,
6479
+ annotations: runtimeAnnotationsFor(meta)
6231
6480
  },
6232
6481
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6233
6482
  async (params) => {
6234
6483
  const ctx = tenantAuthContext();
6235
6484
  if (ctx) {
6236
- const decision = evaluateToolPolicy(meta.name, ctx.scopes);
6485
+ const decision = evaluateToolPolicy(
6486
+ meta.name,
6487
+ ctx.scopes,
6488
+ ctx.tenantRole
6489
+ );
6237
6490
  if (!decision.allowed) {
6238
- const status = decision.reason === "insufficient_scope" ? 403 : 500;
6491
+ const status = decision.reason === "insufficient_scope" || decision.reason === "insufficient_role" ? 403 : 500;
6239
6492
  return {
6240
6493
  content: [
6241
6494
  {
@@ -6272,13 +6525,13 @@ function registerTool(server, schema37, meta, handler20) {
6272
6525
  }
6273
6526
  );
6274
6527
  }
6275
- function registerPrompt(server, schema37, meta, handler20) {
6528
+ function registerPrompt(server, schema38, meta, handler20) {
6276
6529
  server.registerPrompt(
6277
6530
  meta.name,
6278
6531
  {
6279
6532
  title: meta.title,
6280
6533
  description: meta.description,
6281
- argsSchema: schema37
6534
+ argsSchema: schema38
6282
6535
  },
6283
6536
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6284
6537
  (params) => ({
@@ -6350,211 +6603,232 @@ function createServer(options = {}) {
6350
6603
  server,
6351
6604
  schema10,
6352
6605
  metadata10,
6353
- createReturn
6606
+ confirmPayment
6354
6607
  );
6355
6608
  registerTool(
6356
6609
  server,
6357
6610
  schema11,
6358
6611
  metadata11,
6359
- updateReturn
6612
+ createReturn
6360
6613
  );
6361
6614
  registerTool(
6362
6615
  server,
6363
6616
  schema12,
6364
6617
  metadata12,
6365
- returnWithRefund
6618
+ updateReturn
6366
6619
  );
6367
- registerTool(server, schema13, metadata13, addCartItem);
6368
6620
  registerTool(
6369
6621
  server,
6370
- schema14,
6371
- metadata14,
6372
- updateCartItem
6622
+ schema13,
6623
+ metadata13,
6624
+ returnWithRefund
6373
6625
  );
6626
+ registerTool(server, schema14, metadata14, addCartItem);
6374
6627
  registerTool(
6375
6628
  server,
6376
6629
  schema15,
6377
6630
  metadata15,
6378
- removeCartItem
6631
+ updateCartItem
6379
6632
  );
6380
6633
  registerTool(
6381
6634
  server,
6382
6635
  schema16,
6383
6636
  metadata16,
6384
- applyDiscount
6637
+ removeCartItem
6385
6638
  );
6386
6639
  registerTool(
6387
6640
  server,
6388
6641
  schema17,
6389
6642
  metadata17,
6390
- removeDiscount
6643
+ applyDiscount
6391
6644
  );
6392
- registerTool(server, schema18, metadata18, clearCart);
6393
6645
  registerTool(
6394
6646
  server,
6395
- schema19,
6396
- metadata19,
6397
- validateDiscount
6647
+ schema18,
6648
+ metadata18,
6649
+ removeDiscount
6398
6650
  );
6651
+ registerTool(server, schema19, metadata19, clearCart);
6399
6652
  registerTool(
6400
6653
  server,
6401
6654
  schema20,
6402
6655
  metadata20,
6656
+ validateDiscount
6657
+ );
6658
+ registerTool(
6659
+ server,
6660
+ schema21,
6661
+ metadata21,
6403
6662
  calculateShipping
6404
6663
  );
6405
- registerTool(server, schema21, metadata21, stockCheck);
6406
- registerTool(server, schema22, metadata22, productDetail);
6664
+ registerTool(server, schema22, metadata22, stockCheck);
6407
6665
  registerTool(
6408
6666
  server,
6409
6667
  schema23,
6410
6668
  metadata23,
6669
+ productDetail
6670
+ );
6671
+ registerTool(
6672
+ server,
6673
+ schema24,
6674
+ metadata24,
6411
6675
  productUpsert
6412
6676
  );
6413
6677
  }
6414
- registerTool(
6415
- server,
6416
- schema24,
6417
- metadata24,
6418
- getCollectionSchemaTool
6419
- );
6420
6678
  registerTool(
6421
6679
  server,
6422
6680
  schema25,
6423
6681
  metadata25,
6424
- handler
6682
+ getCollectionSchemaTool
6425
6683
  );
6426
6684
  registerTool(
6427
6685
  server,
6428
6686
  schema26,
6429
6687
  metadata26,
6430
- handler2
6688
+ handler
6431
6689
  );
6432
6690
  registerTool(
6433
6691
  server,
6434
6692
  schema27,
6435
6693
  metadata27,
6436
- listConfigurableFields
6694
+ handler2
6437
6695
  );
6438
6696
  registerTool(
6439
6697
  server,
6440
6698
  schema28,
6441
6699
  metadata28,
6442
- updateFieldConfig
6700
+ listConfigurableFields
6443
6701
  );
6444
6702
  registerTool(
6445
6703
  server,
6446
6704
  schema29,
6447
6705
  metadata29,
6448
- handler3
6706
+ updateFieldConfig
6449
6707
  );
6450
6708
  registerTool(
6451
6709
  server,
6452
6710
  schema30,
6453
6711
  metadata30,
6454
- handler4
6712
+ handler3
6455
6713
  );
6456
6714
  registerTool(
6457
6715
  server,
6458
6716
  schema31,
6459
6717
  metadata31,
6460
- handler5
6718
+ handler4
6461
6719
  );
6462
6720
  registerTool(
6463
6721
  server,
6464
6722
  schema32,
6465
6723
  metadata32,
6466
- handler6
6724
+ handler5
6467
6725
  );
6468
- registerPrompt(
6726
+ registerTool(
6469
6727
  server,
6470
6728
  schema33,
6471
6729
  metadata33,
6472
- sdkUsageGuide
6730
+ handler6
6473
6731
  );
6474
6732
  registerPrompt(
6475
6733
  server,
6476
6734
  schema34,
6477
6735
  metadata34,
6478
- collectionQueryHelp
6736
+ sdkUsageGuide
6479
6737
  );
6480
6738
  registerPrompt(
6481
6739
  server,
6482
6740
  schema35,
6483
6741
  metadata35,
6484
- orderFlowGuide
6742
+ collectionQueryHelp
6485
6743
  );
6486
6744
  registerPrompt(
6487
6745
  server,
6488
6746
  schema36,
6489
6747
  metadata36,
6748
+ orderFlowGuide
6749
+ );
6750
+ registerPrompt(
6751
+ server,
6752
+ schema37,
6753
+ metadata37,
6490
6754
  featureSetupGuide
6491
6755
  );
6492
6756
  registerStaticResource(
6493
6757
  server,
6494
- "config://app",
6495
- metadata37,
6758
+ mcpResourceUri("app-config"),
6759
+ metadata38,
6496
6760
  handler7
6497
6761
  );
6498
6762
  registerStaticResource(
6499
6763
  server,
6500
- "collections://schema",
6501
- metadata38,
6764
+ mcpResourceUri("collections-schema"),
6765
+ metadata39,
6502
6766
  handler8
6503
6767
  );
6504
6768
  registerStaticResource(
6505
6769
  server,
6506
- "docs://sdk/getting-started",
6507
- metadata39,
6770
+ mcpResourceUri("docs-getting-started"),
6771
+ metadata40,
6508
6772
  handler9
6509
6773
  );
6510
- registerStaticResource(server, "docs://sdk/guides", metadata40, handler10);
6511
- registerStaticResource(server, "docs://sdk/api", metadata41, handler11);
6512
6774
  registerStaticResource(
6513
6775
  server,
6514
- "docs://sdk/query-builder",
6776
+ mcpResourceUri("docs-guides"),
6777
+ metadata41,
6778
+ handler10
6779
+ );
6780
+ registerStaticResource(
6781
+ server,
6782
+ mcpResourceUri("docs-api"),
6515
6783
  metadata42,
6516
- handler12
6784
+ handler11
6517
6785
  );
6518
6786
  registerStaticResource(
6519
6787
  server,
6520
- "docs://sdk/react-query",
6788
+ mcpResourceUri("docs-query-builder"),
6521
6789
  metadata43,
6522
- handler13
6790
+ handler12
6523
6791
  );
6524
6792
  registerStaticResource(
6525
6793
  server,
6526
- "docs://sdk/server-api",
6794
+ mcpResourceUri("docs-react-query"),
6527
6795
  metadata44,
6528
- handler14
6796
+ handler13
6529
6797
  );
6530
6798
  registerStaticResource(
6531
6799
  server,
6532
- "docs://sdk/customer-auth",
6800
+ mcpResourceUri("docs-server-api"),
6533
6801
  metadata45,
6534
- handler15
6802
+ handler14
6535
6803
  );
6536
6804
  registerStaticResource(
6537
6805
  server,
6538
- "docs://sdk/browser-vs-server",
6806
+ mcpResourceUri("docs-customer-auth"),
6539
6807
  metadata46,
6540
- handler16
6808
+ handler15
6541
6809
  );
6542
6810
  registerStaticResource(
6543
6811
  server,
6544
- "docs://sdk/file-upload",
6812
+ mcpResourceUri("docs-browser-vs-server"),
6545
6813
  metadata47,
6546
- handler17
6814
+ handler16
6547
6815
  );
6548
6816
  registerStaticResource(
6549
6817
  server,
6550
- "docs://sdk/webhook",
6818
+ mcpResourceUri("docs-file-upload"),
6551
6819
  metadata48,
6552
- handler18
6820
+ handler17
6553
6821
  );
6554
6822
  registerStaticResource(
6555
6823
  server,
6556
- "docs://sdk/product-detail",
6824
+ mcpResourceUri("docs-webhook"),
6557
6825
  metadata49,
6826
+ handler18
6827
+ );
6828
+ registerStaticResource(
6829
+ server,
6830
+ mcpResourceUri("docs-product-detail"),
6831
+ metadata50,
6558
6832
  handler19
6559
6833
  );
6560
6834
  return server;
@@ -6567,6 +6841,7 @@ export {
6567
6841
  MCP_TENANT_CLAIM,
6568
6842
  MCP_TENANT_ROLE_CLAIM,
6569
6843
  MCP_SCOPES,
6844
+ MCP_RESOURCE_LABELS,
6570
6845
  requestContext,
6571
6846
  mcpServicePublicJwks,
6572
6847
  createMcpTelemetrySummary,
@@ -6574,4 +6849,4 @@ export {
6574
6849
  flushMcpTelemetrySummary,
6575
6850
  createServer
6576
6851
  };
6577
- //# sourceMappingURL=chunk-F5VI4HQM.js.map
6852
+ //# sourceMappingURL=chunk-2ULP5WQH.js.map