@01.software/cli 0.10.1 → 0.10.3

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.
@@ -74,7 +74,7 @@ function parseJsonWhere(where) {
74
74
  }
75
75
  }
76
76
 
77
- // ../../packages/auth-contracts/dist/index.js
77
+ // ../../packages/auth-contracts/src/index.ts
78
78
  var MCP_RESOURCE_AUDIENCE = "https://mcp.01.software/mcp";
79
79
  var MCP_OAUTH_ISSUER = "https://01.software";
80
80
  var MCP_PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource/mcp";
@@ -292,7 +292,8 @@ var restockActionSchema = z2.enum(["return_to_stock", "discard"]);
292
292
  var returnWithRefundItemSchema = z2.object({
293
293
  orderItem: z2.union([z2.string(), z2.number()]).transform(String),
294
294
  quantity: z2.number().int().positive("quantity must be a positive integer"),
295
- restockAction: restockActionSchema.default("return_to_stock")
295
+ restockAction: restockActionSchema.default("return_to_stock"),
296
+ restockingFee: z2.number().min(0, "restockingFee must be non-negative").optional().describe("Restocking fee charged for this line (ADR 0005 \xA7Gap 1)")
296
297
  }).strict();
297
298
  var returnWithRefundSchema = z2.object({
298
299
  orderNumber: z2.string().min(1, "orderNumber is required").describe("Order number (required)"),
@@ -300,6 +301,7 @@ var returnWithRefundSchema = z2.object({
300
301
  reasonDetail: z2.string().optional().describe("Detailed reason text (optional)"),
301
302
  returnItems: z2.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
302
303
  refundAmount: z2.number().min(0, "refundAmount must be non-negative").describe("Refund amount (required, min 0)"),
304
+ returnShippingFee: z2.number().min(0, "returnShippingFee must be non-negative").optional().describe("Return shipping fee charged to the customer (ADR 0005 \xA7Gap 1)"),
303
305
  pgPaymentId: z2.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
304
306
  paymentKey: z2.string().min(1).optional().describe("Provider payment key for verified refund"),
305
307
  refundReceiptUrl: z2.string().optional().describe("Refund receipt URL (optional)")
@@ -328,6 +330,16 @@ var MCP_TOOL_CONTRACT = {
328
330
  oauthScope: "mcp:read",
329
331
  readOnly: true
330
332
  },
333
+ "product-detail": {
334
+ consoleRole: "tenant-viewer",
335
+ oauthScope: "mcp:read",
336
+ readOnly: true
337
+ },
338
+ "product-upsert": {
339
+ consoleRole: "tenant-admin",
340
+ oauthScope: "mcp:write",
341
+ readOnly: false
342
+ },
331
343
  "validate-discount": {
332
344
  consoleRole: "tenant-viewer",
333
345
  oauthScope: "mcp:read",
@@ -527,6 +539,21 @@ var TOOL_POLICY_MANIFEST = {
527
539
  consoleSurface: "GET /api/products/{id}/stock",
528
540
  annotationPolicy: READ_ONLY_ANNOTATION
529
541
  },
542
+ "product-detail": {
543
+ category: "read-only-collection",
544
+ oauthScope: MCP_SCOPES.read,
545
+ consoleRole: "tenant-viewer",
546
+ consoleSurface: "GET /api/products/detail",
547
+ annotationPolicy: READ_ONLY_ANNOTATION
548
+ },
549
+ "product-upsert": {
550
+ category: "mutation-product",
551
+ oauthScope: MCP_SCOPES.write,
552
+ consoleRole: "tenant-admin",
553
+ consoleSurface: "POST /api/products/upsert",
554
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
555
+ exemptionReason: REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE
556
+ },
530
557
  "validate-discount": {
531
558
  category: "read-only-collection",
532
559
  oauthScope: MCP_SCOPES.read,
@@ -880,9 +907,12 @@ function signMcpServiceToken(context) {
880
907
  }
881
908
 
882
909
  // src/lib/console-api.ts
883
- var BASE_URL = process.env.SOFTWARE_API_URL || "http://localhost:3000";
910
+ var DEFAULT_API_URL = "https://api.01.software";
884
911
  var TIMEOUT_MS = 5e3;
885
912
  var MISSING_HTTP_AUTH_CONTEXT_ERROR = "MCP HTTP requests require a validated OAuth tenant context before tool execution.";
913
+ function resolveConsoleApiUrl() {
914
+ return (process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL || DEFAULT_API_URL).replace(/\/$/, "");
915
+ }
886
916
  function resolveAuthHeaderContext() {
887
917
  const oauthContext = tenantAuthContext();
888
918
  if (oauthContext) {
@@ -932,7 +962,7 @@ async function consoleGet(path, apiKey) {
932
962
  const controller = new AbortController();
933
963
  const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
934
964
  try {
935
- const res = await fetch(`${BASE_URL}${path}`, {
965
+ const res = await fetch(`${resolveConsoleApiUrl()}${path}`, {
936
966
  headers: authHeaders,
937
967
  signal: controller.signal
938
968
  });
@@ -951,7 +981,7 @@ async function consolePost(path, body, apiKey) {
951
981
  const controller = new AbortController();
952
982
  const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
953
983
  try {
954
- const res = await fetch(`${BASE_URL}${path}`, {
984
+ const res = await fetch(`${resolveConsoleApiUrl()}${path}`, {
955
985
  method: "POST",
956
986
  headers: { ...authHeaders, "Content-Type": "application/json" },
957
987
  body: JSON.stringify(body),
@@ -972,7 +1002,7 @@ async function consolePostTelemetry(path, body, apiKey) {
972
1002
  const controller = new AbortController();
973
1003
  const timeoutId = setTimeout(() => controller.abort(), TIMEOUT_MS);
974
1004
  try {
975
- const res = await fetch(`${BASE_URL}${path}`, {
1005
+ const res = await fetch(`${resolveConsoleApiUrl()}${path}`, {
976
1006
  method: "POST",
977
1007
  headers: { ...authHeaders, "Content-Type": "application/json" },
978
1008
  body: JSON.stringify(body),
@@ -1870,6 +1900,118 @@ async function stockCheck({
1870
1900
  }
1871
1901
  }
1872
1902
 
1903
+ // src/tools/product-detail.ts
1904
+ import { z as z22 } from "zod";
1905
+ var schema22 = {
1906
+ slug: z22.string().optional().describe("Product slug (one of slug or id required)"),
1907
+ id: z22.string().optional().describe("Product id (one of slug or id required)")
1908
+ };
1909
+ var metadata22 = {
1910
+ name: "product-detail",
1911
+ 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.",
1912
+ annotations: {
1913
+ title: "Get product detail",
1914
+ readOnlyHint: true,
1915
+ destructiveHint: false,
1916
+ idempotentHint: true
1917
+ }
1918
+ };
1919
+ async function productDetail({
1920
+ slug,
1921
+ id
1922
+ }) {
1923
+ try {
1924
+ if (Boolean(slug) === Boolean(id)) {
1925
+ return toolError(new Error("Provide exactly one of slug or id"));
1926
+ }
1927
+ const client = getClient();
1928
+ const params = slug ? { slug } : { id };
1929
+ const result = await client.commerce.product.detail(params);
1930
+ return toolSuccess({ data: result });
1931
+ } catch (error) {
1932
+ return toolError(error);
1933
+ }
1934
+ }
1935
+
1936
+ // src/tools/product-upsert.ts
1937
+ import { z as z23 } from "zod";
1938
+ var optionValueSchema = z23.object({
1939
+ id: z23.string().optional().describe("Existing option-value ID for updates"),
1940
+ value: z23.string().describe("Display label (e.g. Black, S)"),
1941
+ slug: z23.string().optional().describe("Canonical value token used in variant maps and URLs"),
1942
+ swatchColor: z23.string().nullable().optional(),
1943
+ thumbnail: z23.string().nullable().optional(),
1944
+ images: z23.array(z23.string()).optional(),
1945
+ metadata: z23.unknown().optional()
1946
+ });
1947
+ var optionSchema = z23.object({
1948
+ id: z23.string().optional().describe("Existing option ID for updates"),
1949
+ title: z23.string().describe("Option name (e.g. Color, Size)"),
1950
+ slug: z23.string().optional().describe("Canonical option token used in variant maps and URLs"),
1951
+ values: z23.array(optionValueSchema).describe("Allowed option values")
1952
+ });
1953
+ var variantOptionValueSchema = z23.object({
1954
+ valueSlug: z23.string().optional(),
1955
+ valueId: z23.string().optional(),
1956
+ value: z23.string().optional()
1957
+ });
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())
1963
+ ]).optional().describe(
1964
+ "Option-value selection. Prefer canonical { optionSlug: valueSlug } maps. Object values may use { valueSlug, valueId, value }. Exact { OptionTitle: ValueLabel } maps remain compatibility-only and fail when labels are ambiguous. Arrays of option-value IDs are also accepted."
1965
+ ),
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()
1980
+ });
1981
+ var schema23 = {
1982
+ product: z23.record(z23.string(), z23.unknown()).describe(
1983
+ "Product fields. Include `id` to update an existing product; omit for create (then `title` is required)."
1984
+ ),
1985
+ options: z23.array(optionSchema).optional().describe(
1986
+ "Option definitions. Prefer explicit option slug and value slugs. Omitted options on an existing product are deleted (with their values)."
1987
+ ),
1988
+ variants: z23.array(variantSchema).optional().describe(
1989
+ "Variant rows. Prefer canonical { optionSlug: valueSlug } optionValues maps. 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
+ )
1991
+ };
1992
+ var metadata23 = {
1993
+ name: "product-upsert",
1994
+ 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
+ annotations: {
1996
+ title: "Upsert product (atomic)",
1997
+ readOnlyHint: false,
1998
+ destructiveHint: true,
1999
+ idempotentHint: true,
2000
+ openWorldHint: false
2001
+ }
2002
+ };
2003
+ async function productUpsert(params) {
2004
+ try {
2005
+ const client = getClient();
2006
+ const result = await client.commerce.product.upsert(
2007
+ params
2008
+ );
2009
+ return toolSuccess({ data: result });
2010
+ } catch (error) {
2011
+ return toolError(error);
2012
+ }
2013
+ }
2014
+
1873
2015
  // src/tools/get-collection-schema.ts
1874
2016
  import { SERVER_COLLECTIONS as SERVER_COLLECTIONS3 } from "@01.software/sdk";
1875
2017
 
@@ -1884,8 +2026,8 @@ async function getCollectionSchema(collection) {
1884
2026
  }
1885
2027
 
1886
2028
  // src/tools/get-collection-schema.ts
1887
- var schema22 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
1888
- var metadata22 = {
2029
+ var schema24 = createCollectionSchemaToolInputSchema(SERVER_COLLECTIONS3).shape;
2030
+ var metadata24 = {
1889
2031
  name: "get-collection-schema",
1890
2032
  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.",
1891
2033
  annotations: {
@@ -1936,8 +2078,8 @@ async function getTenantFeatureProgress(feature, includeEvidence = false) {
1936
2078
  }
1937
2079
 
1938
2080
  // src/tools/get-tenant-context.ts
1939
- var schema23 = tenantContextToolInputSchema.shape;
1940
- var metadata23 = {
2081
+ var schema25 = tenantContextToolInputSchema.shape;
2082
+ var metadata25 = {
1941
2083
  name: "get-tenant-context",
1942
2084
  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.",
1943
2085
  annotations: {
@@ -2014,8 +2156,8 @@ async function handler({
2014
2156
  }
2015
2157
 
2016
2158
  // src/tools/check-feature-progress.ts
2017
- var schema24 = tenantFeatureProgressInputSchema.shape;
2018
- var metadata24 = {
2159
+ var schema26 = tenantFeatureProgressInputSchema.shape;
2160
+ var metadata26 = {
2019
2161
  name: "check-feature-progress",
2020
2162
  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.",
2021
2163
  annotations: {
@@ -2038,7 +2180,7 @@ async function handler2({
2038
2180
  }
2039
2181
 
2040
2182
  // src/tools/list-configurable-fields.ts
2041
- import { z as z22 } from "zod";
2183
+ import { z as z24 } from "zod";
2042
2184
 
2043
2185
  // src/lib/field-config.ts
2044
2186
  async function fetchFieldConfigs() {
@@ -2061,12 +2203,12 @@ function invalidateFieldConfigCache() {
2061
2203
  }
2062
2204
 
2063
2205
  // src/tools/list-configurable-fields.ts
2064
- var schema25 = {
2065
- collection: z22.string().optional().describe(
2206
+ var schema27 = {
2207
+ collection: z24.string().optional().describe(
2066
2208
  "Filter by collection slug (optional \u2014 returns all if omitted). Use this filter to reduce response size when you know which collection to check."
2067
2209
  )
2068
2210
  };
2069
- var metadata25 = {
2211
+ var metadata27 = {
2070
2212
  name: "list-configurable-fields",
2071
2213
  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.",
2072
2214
  annotations: {
@@ -2097,17 +2239,17 @@ async function listConfigurableFields(params) {
2097
2239
  }
2098
2240
 
2099
2241
  // src/tools/update-field-config.ts
2100
- import { z as z23 } from "zod";
2101
- var schema26 = {
2102
- collection: z23.string().min(1).describe("Collection slug (required)"),
2103
- hiddenFields: z23.array(z23.string().min(1).max(200)).max(300).describe(
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(
2104
2246
  "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."
2105
2247
  ),
2106
- isHidden: z23.boolean().optional().describe(
2248
+ isHidden: z25.boolean().optional().describe(
2107
2249
  "Hide the entire collection from Admin Panel (optional). When true, individual hiddenFields are irrelevant."
2108
2250
  )
2109
2251
  };
2110
- var metadata26 = {
2252
+ var metadata28 = {
2111
2253
  name: "update-field-config",
2112
2254
  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.",
2113
2255
  annotations: {
@@ -2135,7 +2277,7 @@ async function updateFieldConfig(params) {
2135
2277
  }
2136
2278
 
2137
2279
  // src/tools/sdk-get-recipe.ts
2138
- import { z as z24 } from "zod";
2280
+ import { z as z26 } from "zod";
2139
2281
 
2140
2282
  // src/lib/sdk-recipes.ts
2141
2283
  var recipes = {
@@ -2567,8 +2709,8 @@ function getRecipe(goal, runtime = "both") {
2567
2709
  }
2568
2710
 
2569
2711
  // src/tools/sdk-get-recipe.ts
2570
- var schema27 = {
2571
- goal: z24.enum([
2712
+ var schema29 = {
2713
+ goal: z26.enum([
2572
2714
  "fetch-list",
2573
2715
  "fetch-by-id",
2574
2716
  "create-item",
@@ -2580,11 +2722,11 @@ var schema27 = {
2580
2722
  "file-upload",
2581
2723
  "bulk-operations"
2582
2724
  ]).describe("What the user wants to accomplish"),
2583
- runtime: z24.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
2584
- collection: z24.string().optional().describe("Specific collection name if applicable"),
2585
- includeExample: z24.boolean().default(true).describe("Whether to include a full code example")
2725
+ runtime: z26.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
2726
+ collection: z26.string().optional().describe("Specific collection name if applicable"),
2727
+ includeExample: z26.boolean().default(true).describe("Whether to include a full code example")
2586
2728
  };
2587
- var metadata27 = {
2729
+ var metadata29 = {
2588
2730
  name: "sdk-get-recipe",
2589
2731
  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.",
2590
2732
  annotations: {
@@ -2627,7 +2769,7 @@ function handler3({
2627
2769
  }
2628
2770
 
2629
2771
  // src/tools/sdk-search-docs.ts
2630
- import { z as z25 } from "zod";
2772
+ import { z as z27 } from "zod";
2631
2773
 
2632
2774
  // src/lib/sdk-doc-index.ts
2633
2775
  var docIndex = [
@@ -2802,11 +2944,11 @@ function searchDocs(query, limit = 5) {
2802
2944
  }
2803
2945
 
2804
2946
  // src/tools/sdk-search-docs.ts
2805
- var schema28 = {
2806
- query: z25.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
2807
- limit: z25.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
2947
+ var schema30 = {
2948
+ query: z27.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
2949
+ limit: z27.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
2808
2950
  };
2809
- var metadata28 = {
2951
+ var metadata30 = {
2810
2952
  name: "sdk-search-docs",
2811
2953
  description: "Search SDK documentation by keyword. Returns matching topics with summaries and resource links. Use when looking for specific SDK features or patterns.",
2812
2954
  annotations: {
@@ -2841,9 +2983,9 @@ function handler4({
2841
2983
  }
2842
2984
 
2843
2985
  // src/tools/sdk-get-auth-setup.ts
2844
- import { z as z26 } from "zod";
2845
- var schema29 = {
2846
- scenario: z26.enum([
2986
+ import { z as z28 } from "zod";
2987
+ var schema31 = {
2988
+ scenario: z28.enum([
2847
2989
  "browser-client",
2848
2990
  "server-client",
2849
2991
  "customer-auth",
@@ -2852,7 +2994,7 @@ var schema29 = {
2852
2994
  "webhook-verification"
2853
2995
  ]).describe("Authentication scenario")
2854
2996
  };
2855
- var metadata29 = {
2997
+ var metadata31 = {
2856
2998
  name: "sdk-get-auth-setup",
2857
2999
  description: "Get the current authentication setup for a specific scenario. Returns env var names, code snippets, and security notes.",
2858
3000
  annotations: {
@@ -3006,14 +3148,14 @@ function handler5({
3006
3148
  }
3007
3149
 
3008
3150
  // src/tools/sdk-get-collection-pattern.ts
3009
- import { z as z27 } from "zod";
3151
+ import { z as z29 } from "zod";
3010
3152
  import { COLLECTIONS, SERVER_COLLECTIONS as SERVER_COLLECTIONS4 } from "@01.software/sdk";
3011
- var schema30 = {
3012
- collection: z27.enum(SERVER_COLLECTIONS4).describe("Collection name"),
3013
- operation: z27.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
3014
- surface: z27.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
3153
+ var schema32 = {
3154
+ collection: z29.enum(SERVER_COLLECTIONS4).describe("Collection name"),
3155
+ operation: z29.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
3156
+ surface: z29.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
3015
3157
  };
3016
- var metadata30 = {
3158
+ var metadata32 = {
3017
3159
  name: "sdk-get-collection-pattern",
3018
3160
  description: "Get the recommended CRUD pattern for a specific collection. Returns code examples for the chosen API surface and operation type.",
3019
3161
  annotations: {
@@ -3214,14 +3356,14 @@ function handler6({
3214
3356
  }
3215
3357
 
3216
3358
  // src/prompts/sdk-usage-guide.ts
3217
- import { z as z28 } from "zod";
3218
- var schema31 = {
3219
- goal: z28.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
3220
- runtime: z28.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
3221
- surface: z28.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
3222
- collection: z28.string().optional().describe("Specific collection if relevant")
3359
+ import { z as z30 } from "zod";
3360
+ var schema33 = {
3361
+ goal: z30.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
3362
+ runtime: z30.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
3363
+ surface: z30.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
3364
+ collection: z30.string().optional().describe("Specific collection if relevant")
3223
3365
  };
3224
- var metadata31 = {
3366
+ var metadata33 = {
3225
3367
  name: "sdk-usage-guide",
3226
3368
  title: "SDK Usage Guide",
3227
3369
  description: "Provides guidance on how to perform a specific task using the 01.software SDK",
@@ -3354,18 +3496,44 @@ const client = createServerClient({
3354
3496
  })
3355
3497
  \`\`\`
3356
3498
 
3357
- You can perform the "${goal}" task by following the patterns above.`;
3499
+ You can perform the "${goal}" task by following the patterns above.
3500
+
3501
+ ## Common recipes
3502
+
3503
+ ### Product detail page (slug-based)
3504
+
3505
+ \`\`\`typescript
3506
+ const product = await client.commerce.product.detail({ slug })
3507
+ if (!product) return notFound()
3508
+ // product: { product, variants, options, brand, categories, tags, images, videos, listing }
3509
+ \`\`\`
3510
+
3511
+ For React: \`const { data } = client.query.useProductDetailBySlug(slug)\`.
3512
+
3513
+ ### Product listing (grouped)
3514
+
3515
+ \`\`\`typescript
3516
+ const { docs } = await client.commerce.product.listingGroups({ productIds })
3517
+ \`\`\`
3518
+
3519
+ ### Stock check before adding to cart
3520
+
3521
+ \`\`\`typescript
3522
+ const { allAvailable } = await client.commerce.product.stockCheck({
3523
+ items: [{ variantId, quantity }],
3524
+ })
3525
+ \`\`\``;
3358
3526
  }
3359
3527
 
3360
3528
  // src/prompts/collection-query-help.ts
3361
- import { z as z29 } from "zod";
3529
+ import { z as z31 } from "zod";
3362
3530
  import { COLLECTIONS as COLLECTIONS2, SERVER_COLLECTIONS as SERVER_COLLECTIONS5 } from "@01.software/sdk";
3363
- var schema32 = {
3364
- collection: z29.enum(SERVER_COLLECTIONS5).describe("Collection name"),
3365
- operation: z29.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
3366
- filters: z29.string().optional().describe("Filter conditions (JSON string, optional)")
3531
+ var schema34 = {
3532
+ collection: z31.enum(SERVER_COLLECTIONS5).describe("Collection name"),
3533
+ operation: z31.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
3534
+ filters: z31.string().optional().describe("Filter conditions (JSON string, optional)")
3367
3535
  };
3368
- var metadata32 = {
3536
+ var metadata34 = {
3369
3537
  name: "collection-query-help",
3370
3538
  title: "Collection Query Help",
3371
3539
  description: "Provides guidance on how to write queries for a specific collection",
@@ -3457,16 +3625,16 @@ ${operation === "find" ? `- Use \`where\` option for filtering (Payload query sy
3457
3625
  }
3458
3626
 
3459
3627
  // src/prompts/order-flow-guide.ts
3460
- import { z as z30 } from "zod";
3461
- var schema33 = {
3462
- scenario: z30.enum([
3628
+ import { z as z32 } from "zod";
3629
+ var schema35 = {
3630
+ scenario: z32.enum([
3463
3631
  "simple-order",
3464
3632
  "cart-checkout",
3465
3633
  "return-refund",
3466
3634
  "fulfillment-tracking"
3467
3635
  ]).describe("Order flow scenario")
3468
3636
  };
3469
- var metadata33 = {
3637
+ var metadata35 = {
3470
3638
  name: "order-flow-guide",
3471
3639
  title: "Order Flow Guide",
3472
3640
  description: "Provides step-by-step guidance for ecommerce order flows including creation, checkout, returns, and fulfillment.",
@@ -3651,9 +3819,9 @@ ${SCENARIOS[scenario] || "Unknown scenario."}
3651
3819
  }
3652
3820
 
3653
3821
  // src/prompts/feature-setup-guide.ts
3654
- import { z as z31 } from "zod";
3655
- var schema34 = {
3656
- feature: z31.enum([
3822
+ import { z as z33 } from "zod";
3823
+ var schema36 = {
3824
+ feature: z33.enum([
3657
3825
  "ecommerce",
3658
3826
  "customers",
3659
3827
  "articles",
@@ -3668,7 +3836,7 @@ var schema34 = {
3668
3836
  "community"
3669
3837
  ]).describe("Feature to get setup guide for")
3670
3838
  };
3671
- var metadata34 = {
3839
+ var metadata36 = {
3672
3840
  name: "feature-setup-guide",
3673
3841
  title: "Feature Setup Guide",
3674
3842
  description: "Setup checklist and remediation guide for a tenant feature. Load with check-feature-progress and get-tenant-context to diagnose setup gaps.",
@@ -3875,7 +4043,7 @@ ${FEATURES[feature] || "Unknown feature."}
3875
4043
  }
3876
4044
 
3877
4045
  // src/resources/(config)/app.ts
3878
- var metadata35 = {
4046
+ var metadata37 = {
3879
4047
  name: "app-config",
3880
4048
  title: "Application Config",
3881
4049
  description: "01.software SDK and MCP server configuration information"
@@ -3941,7 +4109,7 @@ Rate limits depend on your tenant plan:
3941
4109
 
3942
4110
  // src/resources/(collections)/schema.ts
3943
4111
  import { COLLECTIONS as COLLECTIONS3 } from "@01.software/sdk";
3944
- var metadata36 = {
4112
+ var metadata38 = {
3945
4113
  name: "collections-schema",
3946
4114
  title: "Collection Schema Info",
3947
4115
  description: "Available collections and their schema information"
@@ -3965,7 +4133,12 @@ var COLLECTIONS_BY_CATEGORY = {
3965
4133
  "fulfillments",
3966
4134
  "fulfillment-items"
3967
4135
  ],
3968
- "Shipping & Returns": ["returns", "return-items", "shipping-policies"],
4136
+ "Shipping & Returns": [
4137
+ "returns",
4138
+ "return-items",
4139
+ "shipping-policies",
4140
+ "shipping-zones"
4141
+ ],
3969
4142
  Customers: [
3970
4143
  "customers",
3971
4144
  "customer-profiles",
@@ -3973,7 +4146,7 @@ var COLLECTIONS_BY_CATEGORY = {
3973
4146
  "customer-addresses"
3974
4147
  ],
3975
4148
  Carts: ["carts", "cart-items"],
3976
- "Discounts & Promotions": ["discounts", "promotions"],
4149
+ Discounts: ["discounts"],
3977
4150
  Documents: ["documents", "document-categories", "document-types"],
3978
4151
  Articles: [
3979
4152
  "articles",
@@ -3987,9 +4160,7 @@ var COLLECTIONS_BY_CATEGORY = {
3987
4160
  "reactions",
3988
4161
  "reaction-types",
3989
4162
  "bookmarks",
3990
- "post-categories",
3991
- "reports",
3992
- "community-bans"
4163
+ "post-categories"
3993
4164
  ],
3994
4165
  Playlists: [
3995
4166
  "playlists",
@@ -4079,7 +4250,7 @@ Total available collections: ${COLLECTIONS3.length}`;
4079
4250
  }
4080
4251
 
4081
4252
  // src/resources/(docs)/getting-started.ts
4082
- var metadata37 = {
4253
+ var metadata39 = {
4083
4254
  name: "docs-getting-started",
4084
4255
  title: "Getting Started",
4085
4256
  description: "01.software SDK getting started guide"
@@ -4124,7 +4295,7 @@ const result = await client.collections.from('products').find({
4124
4295
  }
4125
4296
 
4126
4297
  // src/resources/(docs)/guides.ts
4127
- var metadata38 = {
4298
+ var metadata40 = {
4128
4299
  name: "docs-guides",
4129
4300
  title: "Guides",
4130
4301
  description: "01.software SDK usage guides"
@@ -4335,7 +4506,7 @@ For more implementation guidance, see the [SDK Guide](/developers/sdk).`;
4335
4506
  }
4336
4507
 
4337
4508
  // src/resources/(docs)/api.ts
4338
- var metadata39 = {
4509
+ var metadata41 = {
4339
4510
  name: "docs-api",
4340
4511
  title: "API Reference",
4341
4512
  description: "01.software SDK API reference documentation"
@@ -4621,7 +4792,7 @@ For more details, see the [API documentation](/developers/api).`;
4621
4792
  }
4622
4793
 
4623
4794
  // src/resources/(docs)/query-builder.ts
4624
- var metadata40 = {
4795
+ var metadata42 = {
4625
4796
  name: "docs-query-builder",
4626
4797
  title: "Query Builder",
4627
4798
  description: "01.software SDK Query Builder API reference (client.collections.from)"
@@ -4815,7 +4986,7 @@ console.log(result.hasNextPage) // true
4815
4986
  }
4816
4987
 
4817
4988
  // src/resources/(docs)/react-query.ts
4818
- var metadata41 = {
4989
+ var metadata43 = {
4819
4990
  name: "docs-react-query",
4820
4991
  title: "React Query Hooks",
4821
4992
  description: "01.software SDK React Query hooks reference (client.query)"
@@ -5063,7 +5234,7 @@ export function ProductList() {
5063
5234
  }
5064
5235
 
5065
5236
  // src/resources/(docs)/server-api.ts
5066
- var metadata42 = {
5237
+ var metadata44 = {
5067
5238
  name: "docs-server-api",
5068
5239
  title: "Server-side API",
5069
5240
  description: "01.software SDK server-side API reference (client.commerce) for orders, fulfillments, returns, carts, and validation"
@@ -5325,7 +5496,7 @@ const result = await client.commerce.shipping.calculate({
5325
5496
  }
5326
5497
 
5327
5498
  // src/resources/(docs)/customer-auth.ts
5328
- var metadata43 = {
5499
+ var metadata45 = {
5329
5500
  name: "docs-customer-auth",
5330
5501
  title: "Customer Auth API",
5331
5502
  description: "01.software SDK Customer Auth API reference (client.customer)"
@@ -5503,7 +5674,7 @@ async function loadProfile() {
5503
5674
  }
5504
5675
 
5505
5676
  // src/resources/(docs)/browser-vs-server.ts
5506
- var metadata44 = {
5677
+ var metadata46 = {
5507
5678
  name: "docs-browser-vs-server",
5508
5679
  title: "Client vs ServerClient",
5509
5680
  description: "When to use Client (createClient) vs ServerClient (createServerClient) in the 01.software SDK"
@@ -5662,7 +5833,7 @@ export function ProductList() {
5662
5833
  }
5663
5834
 
5664
5835
  // src/resources/(docs)/file-upload.ts
5665
- var metadata45 = {
5836
+ var metadata47 = {
5666
5837
  name: "docs-file-upload",
5667
5838
  title: "File Upload",
5668
5839
  description: "01.software SDK file upload patterns using the images collection"
@@ -5813,7 +5984,7 @@ The platform stores files in Cloudflare R2 and serves via CDN (\`cdn.01.software
5813
5984
  }
5814
5985
 
5815
5986
  // src/resources/(docs)/webhook.ts
5816
- var metadata46 = {
5987
+ var metadata48 = {
5817
5988
  name: "docs-webhook",
5818
5989
  title: "Webhooks",
5819
5990
  description: "01.software SDK webhook verification and event handling"
@@ -5926,9 +6097,91 @@ Failed webhook deliveries are queued with automatic retries. Ensure your handler
5926
6097
  Configure webhook URLs in the 01.software console under Tenant Settings > Webhooks. Multiple URLs can be registered; all receive every event.`;
5927
6098
  }
5928
6099
 
6100
+ // src/resources/(docs)/product-detail.ts
6101
+ var metadata49 = {
6102
+ name: "docs-product-detail",
6103
+ title: "Product Detail Helper",
6104
+ description: "01.software SDK commerce.product.detail helper guide"
6105
+ };
6106
+ function handler19() {
6107
+ return `# Product Detail Helper
6108
+
6109
+ ## When to use the helper vs the raw query builder
6110
+
6111
+ Use \`client.commerce.product.detail({ slug | id })\` when you need a full product detail page payload in one call. The helper folds the Payload query, access policy, and response shaping (variants, options, option value slugs/media, brand, categories, tags, images, videos, listing rollup) into a single call.
6112
+
6113
+ Use \`client.collections.from('products').find(...)\` (escape hatch) when you need bulk reads, custom filter combinations, or fields outside the helper response shape.
6114
+
6115
+ ## Single-call example
6116
+
6117
+ \`\`\`typescript
6118
+ import { createClient, resolveProductSelection } from '@01.software/sdk'
6119
+
6120
+ const client = createClient({
6121
+ publishableKey: process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY!,
6122
+ })
6123
+
6124
+ const detail = await client.commerce.product.detail({ slug: 'my-product' })
6125
+ if (!detail) return notFound()
6126
+ const selection = resolveProductSelection(detail, {
6127
+ search: '?opt.color=black&opt.size=large',
6128
+ })
6129
+ // selection.selectedVariant, selection.price, selection.stock, selection.media
6130
+ \`\`\`
6131
+
6132
+ ## URL round-trip
6133
+
6134
+ Use the SDK codec for one canonical selection URL format: \`opt.<optionSlug>=<valueSlug>\`. Option and value slugs are the stable public tokens exposed by product detail.
6135
+
6136
+ \`\`\`typescript
6137
+ import { createProductSelectionCodec } from '@01.software/sdk'
6138
+
6139
+ const codec = createProductSelectionCodec(detail)
6140
+ const selection = codec.parse('?opt.color=black')
6141
+ const href = codec.stringify(selection)
6142
+ \`\`\`
6143
+
6144
+ Value-slug-only URLs such as \`?black\` or \`?color=black\` are rejected because option titles are not stable identifiers.
6145
+
6146
+ ## React Query hook variant
6147
+
6148
+ \`\`\`typescript
6149
+ const { data: detail, isLoading } = client.query.useProductDetailBySlug(slug)
6150
+ \`\`\`
6151
+
6152
+ Cache invalidates automatically when any of 10 detail-relevant collections is mutated through SDK mutation hooks.
6153
+
6154
+ ## SSG / Server Component snippet
6155
+
6156
+ \`\`\`tsx
6157
+ // app/products/[slug]/page.tsx
6158
+ import { createClient } from '@01.software/sdk'
6159
+ import { notFound } from 'next/navigation'
6160
+
6161
+ export const revalidate = 60
6162
+
6163
+ export default async function ProductPage({ params }: { params: { slug: string } }) {
6164
+ const client = createClient({
6165
+ publishableKey: process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY!,
6166
+ })
6167
+ const detail = await client.commerce.product.detail({ slug: params.slug })
6168
+ if (!detail) return notFound()
6169
+ return <ProductView detail={detail} />
6170
+ }
6171
+ \`\`\`
6172
+
6173
+ ## The \`null\` return contract
6174
+
6175
+ The endpoint returns 404 for \`not_found\`, \`not_published\`, \`tenant_mismatch\`, or \`feature_disabled\`. The SDK collapses all 404s to \`null\` so consumer UIs render one "not available" path.
6176
+
6177
+ ## Backend correlation
6178
+
6179
+ Log \`client.lastRequestId\` against backend logs \u2014 the endpoint records the exact 404 code alongside the request ID.`;
6180
+ }
6181
+
5929
6182
  // src/server.ts
5930
6183
  var REGISTERED_TOOLS_BY_SERVER = /* @__PURE__ */ new WeakMap();
5931
- function registerTool(server, schema35, meta, handler19) {
6184
+ function registerTool(server, schema37, meta, handler20) {
5932
6185
  let registered = REGISTERED_TOOLS_BY_SERVER.get(server);
5933
6186
  if (!registered) {
5934
6187
  registered = /* @__PURE__ */ new Set();
@@ -5939,7 +6192,7 @@ function registerTool(server, schema35, meta, handler19) {
5939
6192
  meta.name,
5940
6193
  {
5941
6194
  description: meta.description,
5942
- inputSchema: schema35,
6195
+ inputSchema: schema37,
5943
6196
  annotations: meta.annotations
5944
6197
  },
5945
6198
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -5968,7 +6221,7 @@ function registerTool(server, schema35, meta, handler19) {
5968
6221
  const summary = activeSummary ?? ownSummary;
5969
6222
  let result = null;
5970
6223
  try {
5971
- result = await handler19(params);
6224
+ result = await handler20(params);
5972
6225
  return { content: [{ type: "text", text: result }] };
5973
6226
  } finally {
5974
6227
  if (summary) {
@@ -5985,26 +6238,26 @@ function registerTool(server, schema35, meta, handler19) {
5985
6238
  }
5986
6239
  );
5987
6240
  }
5988
- function registerPrompt(server, schema35, meta, handler19) {
6241
+ function registerPrompt(server, schema37, meta, handler20) {
5989
6242
  server.registerPrompt(
5990
6243
  meta.name,
5991
6244
  {
5992
6245
  title: meta.title,
5993
6246
  description: meta.description,
5994
- argsSchema: schema35
6247
+ argsSchema: schema37
5995
6248
  },
5996
6249
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5997
6250
  (params) => ({
5998
6251
  messages: [
5999
6252
  {
6000
6253
  role: meta.role ?? "assistant",
6001
- content: { type: "text", text: handler19(params) }
6254
+ content: { type: "text", text: handler20(params) }
6002
6255
  }
6003
6256
  ]
6004
6257
  })
6005
6258
  );
6006
6259
  }
6007
- function registerStaticResource(server, uri, meta, handler19) {
6260
+ function registerStaticResource(server, uri, meta, handler20) {
6008
6261
  server.registerResource(
6009
6262
  meta.name,
6010
6263
  uri,
@@ -6014,7 +6267,7 @@ function registerStaticResource(server, uri, meta, handler19) {
6014
6267
  mimeType: meta.mimeType ?? "text/plain"
6015
6268
  },
6016
6269
  async (url) => ({
6017
- contents: [{ uri: url.href, text: handler19() }]
6270
+ contents: [{ uri: url.href, text: handler20() }]
6018
6271
  })
6019
6272
  );
6020
6273
  }
@@ -6116,147 +6369,160 @@ function createServer(options = {}) {
6116
6369
  calculateShipping
6117
6370
  );
6118
6371
  registerTool(server, schema21, metadata21, stockCheck);
6372
+ registerTool(server, schema22, metadata22, productDetail);
6373
+ registerTool(
6374
+ server,
6375
+ schema23,
6376
+ metadata23,
6377
+ productUpsert
6378
+ );
6119
6379
  }
6120
- registerTool(
6121
- server,
6122
- schema22,
6123
- metadata22,
6124
- getCollectionSchemaTool
6125
- );
6126
- registerTool(
6127
- server,
6128
- schema23,
6129
- metadata23,
6130
- handler
6131
- );
6132
6380
  registerTool(
6133
6381
  server,
6134
6382
  schema24,
6135
6383
  metadata24,
6136
- handler2
6384
+ getCollectionSchemaTool
6137
6385
  );
6138
6386
  registerTool(
6139
6387
  server,
6140
6388
  schema25,
6141
6389
  metadata25,
6142
- listConfigurableFields
6390
+ handler
6143
6391
  );
6144
6392
  registerTool(
6145
6393
  server,
6146
6394
  schema26,
6147
6395
  metadata26,
6148
- updateFieldConfig
6396
+ handler2
6149
6397
  );
6150
6398
  registerTool(
6151
6399
  server,
6152
6400
  schema27,
6153
6401
  metadata27,
6154
- handler3
6402
+ listConfigurableFields
6155
6403
  );
6156
6404
  registerTool(
6157
6405
  server,
6158
6406
  schema28,
6159
6407
  metadata28,
6160
- handler4
6408
+ updateFieldConfig
6161
6409
  );
6162
6410
  registerTool(
6163
6411
  server,
6164
6412
  schema29,
6165
6413
  metadata29,
6166
- handler5
6414
+ handler3
6167
6415
  );
6168
6416
  registerTool(
6169
6417
  server,
6170
6418
  schema30,
6171
6419
  metadata30,
6172
- handler6
6420
+ handler4
6173
6421
  );
6174
- registerPrompt(
6422
+ registerTool(
6175
6423
  server,
6176
6424
  schema31,
6177
6425
  metadata31,
6178
- sdkUsageGuide
6426
+ handler5
6179
6427
  );
6180
- registerPrompt(
6428
+ registerTool(
6181
6429
  server,
6182
6430
  schema32,
6183
6431
  metadata32,
6184
- collectionQueryHelp
6432
+ handler6
6185
6433
  );
6186
6434
  registerPrompt(
6187
6435
  server,
6188
6436
  schema33,
6189
6437
  metadata33,
6190
- orderFlowGuide
6438
+ sdkUsageGuide
6191
6439
  );
6192
6440
  registerPrompt(
6193
6441
  server,
6194
6442
  schema34,
6195
6443
  metadata34,
6444
+ collectionQueryHelp
6445
+ );
6446
+ registerPrompt(
6447
+ server,
6448
+ schema35,
6449
+ metadata35,
6450
+ orderFlowGuide
6451
+ );
6452
+ registerPrompt(
6453
+ server,
6454
+ schema36,
6455
+ metadata36,
6196
6456
  featureSetupGuide
6197
6457
  );
6198
6458
  registerStaticResource(
6199
6459
  server,
6200
6460
  "config://app",
6201
- metadata35,
6461
+ metadata37,
6202
6462
  handler7
6203
6463
  );
6204
6464
  registerStaticResource(
6205
6465
  server,
6206
6466
  "collections://schema",
6207
- metadata36,
6467
+ metadata38,
6208
6468
  handler8
6209
6469
  );
6210
6470
  registerStaticResource(
6211
6471
  server,
6212
6472
  "docs://sdk/getting-started",
6213
- metadata37,
6473
+ metadata39,
6214
6474
  handler9
6215
6475
  );
6216
- registerStaticResource(server, "docs://sdk/guides", metadata38, handler10);
6217
- registerStaticResource(server, "docs://sdk/api", metadata39, handler11);
6476
+ registerStaticResource(server, "docs://sdk/guides", metadata40, handler10);
6477
+ registerStaticResource(server, "docs://sdk/api", metadata41, handler11);
6218
6478
  registerStaticResource(
6219
6479
  server,
6220
6480
  "docs://sdk/query-builder",
6221
- metadata40,
6481
+ metadata42,
6222
6482
  handler12
6223
6483
  );
6224
6484
  registerStaticResource(
6225
6485
  server,
6226
6486
  "docs://sdk/react-query",
6227
- metadata41,
6487
+ metadata43,
6228
6488
  handler13
6229
6489
  );
6230
6490
  registerStaticResource(
6231
6491
  server,
6232
6492
  "docs://sdk/server-api",
6233
- metadata42,
6493
+ metadata44,
6234
6494
  handler14
6235
6495
  );
6236
6496
  registerStaticResource(
6237
6497
  server,
6238
6498
  "docs://sdk/customer-auth",
6239
- metadata43,
6499
+ metadata45,
6240
6500
  handler15
6241
6501
  );
6242
6502
  registerStaticResource(
6243
6503
  server,
6244
6504
  "docs://sdk/browser-vs-server",
6245
- metadata44,
6505
+ metadata46,
6246
6506
  handler16
6247
6507
  );
6248
6508
  registerStaticResource(
6249
6509
  server,
6250
6510
  "docs://sdk/file-upload",
6251
- metadata45,
6511
+ metadata47,
6252
6512
  handler17
6253
6513
  );
6254
6514
  registerStaticResource(
6255
6515
  server,
6256
6516
  "docs://sdk/webhook",
6257
- metadata46,
6517
+ metadata48,
6258
6518
  handler18
6259
6519
  );
6520
+ registerStaticResource(
6521
+ server,
6522
+ "docs://sdk/product-detail",
6523
+ metadata49,
6524
+ handler19
6525
+ );
6260
6526
  return server;
6261
6527
  }
6262
6528
 
@@ -6274,4 +6540,4 @@ export {
6274
6540
  flushMcpTelemetrySummary,
6275
6541
  createServer
6276
6542
  };
6277
- //# sourceMappingURL=chunk-2ECTVUKU.js.map
6543
+ //# sourceMappingURL=chunk-VSMPWKVX.js.map