@40rty/ams-cli 0.5.18 → 0.5.19

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,6 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { cwd, fail, option, readConfig, storeBinding } from '../lib/context.mjs';
3
+ import { cwd, fail, flag, option, readConfig, storeBinding } from '../lib/context.mjs';
4
4
  import { call, request } from '../lib/credentials.mjs';
5
5
  import { resolveStorePage } from '../lib/store-page.mjs';
6
6
  import { displayName, titleCase } from './init.mjs';
@@ -74,9 +74,30 @@ export const ZERO_RESULTS_HINT = 'unpublished/dev stores are not in Shopify\'s g
74
74
  /** Where the agent's catalog search runs: Shopify's Global catalog (by shop id), or the store's own Storefront search. */
75
75
  const SEARCH_MODES = ['global', 'storefront'];
76
76
 
77
+ /**
78
+ * `forty connect --catalog` — bind the space to no store: Shopify's whole
79
+ * catalog through Shop's MCP server (`shopify-catalog`), for a marketplace
80
+ * space whose products come from every store. `--country` / `--currency` set
81
+ * the market prices and availability are read for (default US / USD).
82
+ */
83
+ async function connectCatalog(config) {
84
+ const country = option('country') === undefined ? 'US' : option('country').toUpperCase();
85
+ const currency = option('currency') === undefined ? 'USD' : option('currency').toUpperCase();
86
+ if (!/^[A-Z]{2}$/.test(country)) fail(`--country must be an ISO 3166-1 alpha-2 code like US (got "${country}")`);
87
+ if (!/^[A-Z]{3}$/.test(currency)) fail(`--currency must be an ISO 4217 code like USD (got "${currency}")`);
88
+ const platform = 'shopify-catalog';
89
+ const body = { platform, platformConfig: { platform, domain: 'mcp.shop.com', config: { marketCountry: country, currency } }, vertical: 'ecommerce' };
90
+ const result = await call(config.apiUrl, 'PUT', `/org/spaces/${config.spaceSlug}/storefront`, body);
91
+ console.log(`space "${result.slug}" is connected to the Shopify catalog — every store, market ${country}, prices in ${currency}`);
92
+ const probe = await probeSearch(config, 'backpack');
93
+ if (!probe.ok) console.warn(`\n!! WARNING: the agent's catalog search could not run (${probe.error})`);
94
+ else console.log(`search works: "${probe.query}" → ${probe.count} result(s): ${probe.titles.join(', ')}`);
95
+ }
96
+
77
97
  /** `forty connect` — attach this app's store to the space. What the space renders is not decided here. */
78
98
  export async function connect() {
79
99
  const config = await readConfig();
100
+ if (flag('catalog')) return connectCatalog(config);
80
101
  // `--from <storefront url>` reads the store's domain and its public Storefront
81
102
  // token off the page every visitor's browser already gets (./store-page.mjs).
82
103
  const from = option('from');
package/bin/forty.mjs CHANGED
@@ -19,7 +19,8 @@
19
19
  // forty connect attach this app's store to the space (`--from <store url>`
20
20
  // reads its public Storefront token off the live page;
21
21
  // `--search storefront` searches the store's own catalog
22
- // instead of Shopify's Global one)
22
+ // instead of Shopify's Global one; `--catalog` binds no
23
+ // store — every store on Shopify, through Shop)
23
24
  // forty origin add let a deployed site's origin call the api (CORS)
24
25
  // forty domain add serve the space on your own domain; prints the DNS records
25
26
  // forty feedback report a problem to the 40rty team