@tokenoftrust/cli 6.14.4 → 6.14.5
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/package.json +1 -1
- package/src/commands/catalog.mjs +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "6.14.
|
|
3
|
+
"version": "6.14.5",
|
|
4
4
|
"description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Token of Trust",
|
package/src/commands/catalog.mjs
CHANGED
|
@@ -134,9 +134,25 @@ async function seedStock(ctx, preset, now, deps) {
|
|
|
134
134
|
if (!ctx.tenant) return { ok: false, error: "the checkout names no tenant" };
|
|
135
135
|
const transport = await resolveTransport({ tenant: ctx.tenant, env, fetchImpl, storefrontUrl: env.TOT_STOREFRONT_URL || null });
|
|
136
136
|
if (!transport.ok) return { ok: false, error: transport.message, hint: transport.hint };
|
|
137
|
+
const base = String(transport.base).replace(/\/+$/, "");
|
|
138
|
+
// A viewer session alone routes to the live stage, which the seed refuses. The shared preview
|
|
139
|
+
// token routes the request to the preview stage.
|
|
140
|
+
let previewToken;
|
|
141
|
+
try {
|
|
142
|
+
const minted = await fetchImpl(`${base}/api/preview/token`, {
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: { ...transport.authHeaders, "content-type": "application/json" },
|
|
145
|
+
body: JSON.stringify({ tenant: ctx.tenant }),
|
|
146
|
+
});
|
|
147
|
+
const data = minted.status === 200 ? await minted.json() : null;
|
|
148
|
+
if (typeof data?.token !== "string") return { ok: false, error: `no preview token (HTTP ${minted.status})` };
|
|
149
|
+
previewToken = data.token;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
return { ok: false, error: e?.message || "the preview token request failed" };
|
|
152
|
+
}
|
|
137
153
|
let response;
|
|
138
154
|
try {
|
|
139
|
-
response = await fetchImpl(`${
|
|
155
|
+
response = await fetchImpl(`${base}/api/admin/inventory/source-on-hand?__preview=${encodeURIComponent(previewToken)}`, {
|
|
140
156
|
method: "POST",
|
|
141
157
|
redirect: "manual",
|
|
142
158
|
headers: { ...transport.authHeaders, "content-type": "application/json" },
|