@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.
package/dist/index.js CHANGED
@@ -7,7 +7,8 @@ import { Command } from "commander";
7
7
  // src/lib/client.ts
8
8
  import {
9
9
  CollectionClient,
10
- ServerCommerceClient
10
+ ServerCommerceClient,
11
+ TenantIntrospectionApi
11
12
  } from "@01.software/sdk/server";
12
13
 
13
14
  // src/lib/credentials.ts
@@ -497,6 +498,7 @@ function resolveClientOrThrow(apiKeyFlag) {
497
498
  void 0
498
499
  ),
499
500
  commerce: new ServerCommerceClient(serverOptions),
501
+ tenant: new TenantIntrospectionApi(serverOptions),
500
502
  publishableKey,
501
503
  secretKey
502
504
  };
@@ -1525,9 +1527,6 @@ ${loginUrl}`));
1525
1527
 
1526
1528
  // src/commands/schema.ts
1527
1529
  import { COLLECTIONS as COLLECTIONS2 } from "@01.software/sdk";
1528
- function getApiUrl() {
1529
- return (process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL || "https://api.01.software").replace(/\/$/, "");
1530
- }
1531
1530
  function registerSchemaCommands(program2, getClient2, getFormat2) {
1532
1531
  const schema = program2.command("schema").description("Collection schema introspection");
1533
1532
  schema.command("list").description("List available collections").action(() => {
@@ -1545,23 +1544,7 @@ function registerSchemaCommands(program2, getClient2, getFormat2) {
1545
1544
  throw new Error(`Unknown collection "${collection}". ${hint}`);
1546
1545
  }
1547
1546
  const client = getClient2();
1548
- const baseUrl = getApiUrl();
1549
- const url = `${baseUrl}/api/tenants/schema/${encodeURIComponent(collection)}`;
1550
- const response = await fetch(url, {
1551
- headers: {
1552
- "X-Publishable-Key": client.publishableKey,
1553
- Authorization: `Bearer ${client.secretKey}`
1554
- }
1555
- });
1556
- if (!response.ok) {
1557
- const body = await response.json().catch(() => ({ error: response.statusText }));
1558
- const err = new Error(
1559
- body.error || `HTTP ${response.status}`
1560
- );
1561
- Object.assign(err, { status: response.status });
1562
- throw err;
1563
- }
1564
- const result = await response.json();
1547
+ const result = await client.tenant.collectionSchema(collection);
1565
1548
  printResult(result, getFormat2());
1566
1549
  } catch (e) {
1567
1550
  exitWithError(e);
@@ -1569,9 +1552,8 @@ function registerSchemaCommands(program2, getClient2, getFormat2) {
1569
1552
  });
1570
1553
  }
1571
1554
 
1572
- // ../contracts/dist/index.js
1555
+ // ../contracts/src/tenant/index.ts
1573
1556
  import { z as z3 } from "zod";
1574
- import { z as z22 } from "zod";
1575
1557
  var tenantFieldConfigStateSchema = z3.object({
1576
1558
  hiddenFields: z3.array(z3.string()),
1577
1559
  isHidden: z3.boolean()
@@ -1715,238 +1697,8 @@ var collectionSchemaResponseSchema = z3.object({
1715
1697
  fields: z3.array(collectionFieldSchema)
1716
1698
  }).strict()
1717
1699
  }).strict();
1718
- var transactionStatusSchema = z22.enum([
1719
- "pending",
1720
- "paid",
1721
- "failed",
1722
- "canceled"
1723
- ]);
1724
- var updateTransactionSchema = z22.object({
1725
- pgPaymentId: z22.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
1726
- status: transactionStatusSchema.describe(
1727
- "New transaction status (required)"
1728
- ),
1729
- paymentMethod: z22.string().optional().describe("Payment method (optional)"),
1730
- receiptUrl: z22.string().optional().describe("Receipt URL (optional)"),
1731
- paymentKey: z22.string().min(1).optional().describe("Provider payment key for verified paid confirmation"),
1732
- amount: z22.number().int().positive().optional().describe("Provider-confirmed amount for verified paid confirmation")
1733
- }).strict();
1734
- var providerSlugSchema = z22.string().trim().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/, "pgProvider must be lowercase slug");
1735
- var confirmPaymentSchema = z22.object({
1736
- orderNumber: z22.string().min(1).optional(),
1737
- pgPaymentId: z22.string().min(1, "pgPaymentId is required").describe("Provider payment identifier stored on the transaction"),
1738
- pgProvider: providerSlugSchema.describe(
1739
- "Payment provider slug, e.g. toss, portone, stripe"
1740
- ),
1741
- pgOrderId: z22.string().min(1).optional(),
1742
- amount: z22.number().int().nonnegative("amount must be non-negative").describe("Provider-confirmed amount in minor units"),
1743
- currency: z22.string().min(1).optional(),
1744
- paymentMethod: z22.string().optional(),
1745
- receiptUrl: z22.string().url().optional(),
1746
- approvedAt: z22.string().optional(),
1747
- providerStatus: z22.string().optional(),
1748
- providerEventId: z22.string().min(1).optional(),
1749
- confirmationSource: z22.enum([
1750
- "provider_webhook",
1751
- "provider_lookup",
1752
- "provider_api_confirm",
1753
- "manual_server"
1754
- ]).optional(),
1755
- metadata: z22.record(z22.string(), z22.unknown()).optional()
1756
- }).strict();
1757
- var returnReasonSchema2 = z22.enum([
1758
- "change_of_mind",
1759
- "defective",
1760
- "wrong_delivery",
1761
- "damaged",
1762
- "other"
1763
- ]);
1764
- var restockActionSchema = z22.enum(["return_to_stock", "discard"]);
1765
- var returnWithRefundItemSchema = z22.object({
1766
- orderItem: z22.union([z22.string(), z22.number()]).transform(String),
1767
- quantity: z22.number().int().positive("quantity must be a positive integer"),
1768
- restockAction: restockActionSchema.default("return_to_stock"),
1769
- restockingFee: z22.number().min(0, "restockingFee must be non-negative").optional().describe("Restocking fee charged for this line (ADR 0005 \xA7Gap 1)")
1770
- }).strict();
1771
- var returnWithRefundSchema = z22.object({
1772
- orderNumber: z22.string().min(1, "orderNumber is required").describe("Order number (required)"),
1773
- reason: returnReasonSchema2.optional().describe("Return reason (optional)"),
1774
- reasonDetail: z22.string().optional().describe("Detailed reason text (optional)"),
1775
- returnItems: z22.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
1776
- refundAmount: z22.number().min(0, "refundAmount must be non-negative").describe("Refund amount (required, min 0)"),
1777
- returnShippingFee: z22.number().min(0, "returnShippingFee must be non-negative").optional().describe("Return shipping fee charged to the customer (ADR 0005 \xA7Gap 1)"),
1778
- pgPaymentId: z22.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
1779
- paymentKey: z22.string().min(1).optional().describe("Provider payment key for verified refund"),
1780
- refundReceiptUrl: z22.string().optional().describe("Refund receipt URL (optional)")
1781
- }).strict();
1782
- var MCP_TOOL_CONTRACT = {
1783
- "query-collection": {
1784
- consoleRole: "tenant-viewer",
1785
- oauthScope: "mcp:read",
1786
- readOnly: true
1787
- },
1788
- "get-collection-by-id": {
1789
- consoleRole: "tenant-viewer",
1790
- oauthScope: "mcp:read",
1791
- readOnly: true
1792
- },
1793
- "get-order": {
1794
- consoleRole: "tenant-viewer",
1795
- oauthScope: "mcp:read",
1796
- readOnly: true
1797
- },
1798
- "stock-check": {
1799
- consoleRole: "tenant-viewer",
1800
- oauthScope: "mcp:read",
1801
- readOnly: true
1802
- },
1803
- "product-detail": {
1804
- consoleRole: "tenant-viewer",
1805
- oauthScope: "mcp:read",
1806
- readOnly: true
1807
- },
1808
- "product-upsert": {
1809
- consoleRole: "tenant-admin",
1810
- oauthScope: "mcp:write",
1811
- readOnly: false
1812
- },
1813
- "validate-discount": {
1814
- consoleRole: "tenant-viewer",
1815
- oauthScope: "mcp:read",
1816
- readOnly: true
1817
- },
1818
- "calculate-shipping": {
1819
- consoleRole: "tenant-viewer",
1820
- oauthScope: "mcp:read",
1821
- readOnly: true
1822
- },
1823
- "get-collection-schema": {
1824
- consoleRole: "tenant-viewer",
1825
- oauthScope: "mcp:read",
1826
- readOnly: true
1827
- },
1828
- "list-configurable-fields": {
1829
- consoleRole: "tenant-viewer",
1830
- oauthScope: "mcp:read",
1831
- readOnly: true
1832
- },
1833
- "get-tenant-context": {
1834
- consoleRole: "tenant-viewer",
1835
- oauthScope: "mcp:read",
1836
- readOnly: true
1837
- },
1838
- "check-feature-progress": {
1839
- consoleRole: "tenant-viewer",
1840
- oauthScope: "mcp:read",
1841
- readOnly: true
1842
- },
1843
- "add-cart-item": {
1844
- consoleRole: "tenant-editor",
1845
- oauthScope: "mcp:write",
1846
- readOnly: false
1847
- },
1848
- "update-cart-item": {
1849
- consoleRole: "tenant-editor",
1850
- oauthScope: "mcp:write",
1851
- readOnly: false
1852
- },
1853
- "remove-cart-item": {
1854
- consoleRole: "tenant-editor",
1855
- oauthScope: "mcp:write",
1856
- readOnly: false
1857
- },
1858
- "clear-cart": {
1859
- consoleRole: "tenant-editor",
1860
- oauthScope: "mcp:write",
1861
- readOnly: false
1862
- },
1863
- "apply-discount": {
1864
- consoleRole: "tenant-editor",
1865
- oauthScope: "mcp:write",
1866
- readOnly: false
1867
- },
1868
- "remove-discount": {
1869
- consoleRole: "tenant-editor",
1870
- oauthScope: "mcp:write",
1871
- readOnly: false
1872
- },
1873
- checkout: {
1874
- consoleRole: "tenant-admin",
1875
- oauthScope: "mcp:write",
1876
- readOnly: false
1877
- },
1878
- "create-order": {
1879
- consoleRole: "tenant-admin",
1880
- oauthScope: "mcp:write",
1881
- readOnly: false
1882
- },
1883
- "update-order": {
1884
- consoleRole: "tenant-admin",
1885
- oauthScope: "mcp:write",
1886
- readOnly: false
1887
- },
1888
- "create-fulfillment": {
1889
- consoleRole: "tenant-admin",
1890
- oauthScope: "mcp:write",
1891
- readOnly: false
1892
- },
1893
- "update-fulfillment": {
1894
- consoleRole: "tenant-admin",
1895
- oauthScope: "mcp:write",
1896
- readOnly: false
1897
- },
1898
- "create-return": {
1899
- consoleRole: "tenant-admin",
1900
- oauthScope: "mcp:write",
1901
- readOnly: false
1902
- },
1903
- "update-return": {
1904
- consoleRole: "tenant-admin",
1905
- oauthScope: "mcp:write",
1906
- readOnly: false
1907
- },
1908
- "return-with-refund": {
1909
- consoleRole: "tenant-admin",
1910
- oauthScope: "mcp:write",
1911
- readOnly: false
1912
- },
1913
- "update-transaction": {
1914
- consoleRole: "tenant-admin",
1915
- oauthScope: "mcp:write",
1916
- readOnly: false
1917
- },
1918
- "update-field-config": {
1919
- consoleRole: "tenant-admin",
1920
- oauthScope: "mcp:write",
1921
- readOnly: false
1922
- },
1923
- "sdk-get-recipe": {
1924
- consoleRole: "tenant-viewer",
1925
- oauthScope: "mcp:read",
1926
- readOnly: true
1927
- },
1928
- "sdk-search-docs": {
1929
- consoleRole: "tenant-viewer",
1930
- oauthScope: "mcp:read",
1931
- readOnly: true
1932
- },
1933
- "sdk-get-auth-setup": {
1934
- consoleRole: "tenant-viewer",
1935
- oauthScope: "mcp:read",
1936
- readOnly: true
1937
- },
1938
- "sdk-get-collection-pattern": {
1939
- consoleRole: "tenant-viewer",
1940
- oauthScope: "mcp:read",
1941
- readOnly: true
1942
- }
1943
- };
1944
- var MCP_TOOL_NAMES = Object.keys(MCP_TOOL_CONTRACT);
1945
1700
 
1946
1701
  // src/commands/feature.ts
1947
- function getApiUrl2() {
1948
- return (process.env.SOFTWARE_API_URL || process.env.NEXT_PUBLIC_SOFTWARE_API_URL || "https://api.01.software").replace(/\/$/, "");
1949
- }
1950
1702
  function flattenProgress(progress) {
1951
1703
  return progress.groups.flatMap(
1952
1704
  (group) => group.items.map((item) => ({
@@ -1971,28 +1723,8 @@ function registerFeatureCommands(program2, getClient2, getFormat2) {
1971
1723
  tenantFeatureProgressInputSchema
1972
1724
  );
1973
1725
  const client = getClient2();
1974
- const baseUrl = getApiUrl2();
1975
- const search = new URLSearchParams({ feature: input.feature });
1976
- if (input.includeEvidence) search.set("includeEvidence", "true");
1977
- const response = await fetch(
1978
- `${baseUrl}/api/tenants/feature-progress?${search.toString()}`,
1979
- {
1980
- headers: {
1981
- "X-Publishable-Key": client.publishableKey,
1982
- Authorization: `Bearer ${client.secretKey}`
1983
- }
1984
- }
1985
- );
1986
- if (!response.ok) {
1987
- const body = await response.json().catch(() => ({ error: response.statusText }));
1988
- const err = new Error(
1989
- body.error || `HTTP ${response.status}`
1990
- );
1991
- Object.assign(err, { status: response.status });
1992
- throw err;
1993
- }
1994
1726
  const result = tenantFeatureProgressResponseSchema.parse(
1995
- await response.json()
1727
+ await client.tenant.featureProgress(input)
1996
1728
  );
1997
1729
  const format = getFormat2();
1998
1730
  printResult(