@tokenoftrust/storefront-runner 7.6.18 → 7.6.20

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.
@@ -42,26 +42,27 @@ const cliInstallSpec = cliVersion ? `@tokenoftrust/cli@${cliVersion}` : "@tokeno
42
42
 
43
43
  // The commit THIS build was cut from, baked in at BUILD time so /health can report
44
44
  // exactly which code is live (see src/lib/observability/shared/health.ts + src/middleware). Prefer a CI-
45
- // provided SHA (Workers Builds / GitHub Actions / CF Pages) so the value is right even
46
- // when the build runs from a shallow/detached checkout; fall back to `git rev-parse`
47
- // for local deploys. deploy.sh's source guard pins HEAD to origin/<deploySourceBranch>,
48
- // so on a clean deploy this SHA equals the pushed umbrella tip. Never throws — a build
49
- // with no git context reports "unknown" rather than failing.
45
+ // Resolve the build's commit SHA: explicit GIT_SHA override first, then the actual
46
+ // checked-out git HEAD (works on shallow, detached, fast-forwarded, and auto-bumped
47
+ // checkouts), falling back to CI trigger env vars only when `.git` is unavailable.
48
+ // Never throws — a build with no git context reports "unknown" rather than failing.
50
49
  const gitSha = (() => {
51
- const fromEnv =
52
- process.env.GIT_SHA ||
53
- process.env.WORKERS_CI_COMMIT_SHA ||
54
- process.env.CF_PAGES_COMMIT_SHA ||
55
- process.env.GITHUB_SHA;
56
- if (fromEnv) return fromEnv.trim();
50
+ if (process.env.GIT_SHA?.trim()) return process.env.GIT_SHA.trim();
57
51
  try {
58
- return execFileSync("git", ["rev-parse", "HEAD"], {
52
+ const head = execFileSync("git", ["rev-parse", "HEAD"], {
59
53
  cwd: fileURLToPath(new URL(".", import.meta.url)),
60
54
  encoding: "utf8",
61
55
  }).trim();
56
+ if (head) return head;
62
57
  } catch {
63
- return "unknown";
58
+ /* fall back to CI env when building outside a git checkout */
64
59
  }
60
+ const fromCiEnv =
61
+ process.env.WORKERS_CI_COMMIT_SHA ||
62
+ process.env.CF_PAGES_COMMIT_SHA ||
63
+ process.env.GITHUB_SHA;
64
+ if (fromCiEnv?.trim()) return fromCiEnv.trim();
65
+ return "unknown";
65
66
  })();
66
67
 
67
68
  import preact from "@astrojs/preact";
@@ -82,6 +82,14 @@ interface CloudflareEnv {
82
82
  * shipped to the browser). Absent -> the Orders route reports `not_provisioned`.
83
83
  */
84
84
  FOXY_ORDER_API_KEY?: string;
85
+ /** Optional JSON retention override (`parseRetentionPolicy`). */
86
+ CONTACT_VAULT_RETENTION_CONFIG?: string;
87
+ /** Positive integer clock divisor for preview contact retention (default 120 -> 2-week spread). */
88
+ CONTACT_VAULT_PREVIEW_TIME_SCALE?: string;
89
+ /** Positive integer hour cutoff for preview contact retention and whole-row delete (default 336 = 14 days). */
90
+ CONTACT_VAULT_PREVIEW_CUTOFF_HOURS?: string;
91
+ /** Optional JSON map of tenantId -> `{ timeScale?, cutoffHours? | cutoffDays? }` preview overrides. */
92
+ CONTACT_VAULT_PREVIEW_TENANTS?: string;
85
93
  }
86
94
 
87
95
  declare global {
@@ -25,6 +25,8 @@ interface Props {
25
25
  const { section, index = 0 } = Astro.props;
26
26
  const { apiBasePath } = Astro.locals;
27
27
  const endpoint = withBase(apiBasePath ?? "", "/api/contact/bulk-quote");
28
+ // Rendered so the publish validator sees the page's dependency on the token route too.
29
+ const tokenEndpoint = withBase(apiBasePath ?? "", "/api/contact/token");
28
30
  const id = `bulk-quote-form-${index}`;
29
31
  const L = BULK_QUOTE_LIMITS;
30
32
  const declared: readonly string[] = Array.isArray(section.units) ? section.units : [];
@@ -37,6 +39,7 @@ const successMessage = section.successMessage ?? "Thanks. We received your quote
37
39
  class="bulk-quote"
38
40
  data-bulk-quote-form
39
41
  data-endpoint={endpoint}
42
+ data-token-endpoint={tokenEndpoint}
40
43
  data-success={successMessage}
41
44
  data-max-items={L.lineItems}
42
45
  aria-labelledby={section.heading ? `${id}-heading` : undefined}
@@ -225,6 +228,7 @@ const successMessage = section.successMessage ?? "Thanks. We received your quote
225
228
  too_large: "That request is too large. Shorten it and try again.",
226
229
  };
227
230
  const GENERIC = "Something went wrong. Your entries are still here; try again.";
231
+ const PREVIEW = "Quote requests are off in preview. Your request was checked but not sent.";
228
232
  const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
229
233
  type Control = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
230
234
 
@@ -236,7 +240,7 @@ const successMessage = section.successMessage ?? "Thanks. We received your quote
236
240
  const add = root.querySelector<HTMLButtonElement>("[data-bulk-quote-add]");
237
241
  const row = root.querySelector<HTMLTemplateElement>("[data-bulk-quote-row]");
238
242
  const endpoint = root.dataset.endpoint;
239
- if (!form || !status || !ref || !list || !add || !row || !endpoint) return;
243
+ if (!form || !status || !ref || !list || !add || !row || !endpoint || !root.dataset.tokenEndpoint) return;
240
244
  const maxItems = Number(root.dataset.maxItems) || 25;
241
245
  // The wire contract appends /api/contact/... itself; hand it the api base.
242
246
  const apiBase = endpoint.replace(/\/api\/contact\/bulk-quote$/, "");
@@ -367,6 +371,12 @@ const successMessage = section.successMessage ?? "Thanks. We received your quote
367
371
  ...optional("notes"),
368
372
  company: top("company")?.value ?? "",
369
373
  });
374
+ if (result.body.ok && "preview" in result.body) {
375
+ token = null;
376
+ say(PREVIEW, "ok");
377
+ loadToken().catch(() => {});
378
+ return;
379
+ }
370
380
  if (result.body.ok) {
371
381
  const quoteId = result.body.quoteId;
372
382
  form.reset();
@@ -301,7 +301,9 @@ export function isBypassPrivilegedPath(pathname: string): boolean {
301
301
  * tenant's own pages whose route has NO effect on a store that is not public. A
302
302
  * reviewer on a copy-preview link submits them and gets the route's own answer
303
303
  * instead of the holding page; the route reads `locals.storeNotPublic` and records
304
- * nothing (the footer/homepage newsletter form confirms "off in preview").
304
+ * nothing (the footer/homepage newsletter form confirms "off in preview", the bulk
305
+ * quote form answers `preview: true`). `/api/contact/token` only signs a submit token
306
+ * and writes nothing, so the bulk quote form can be exercised end to end in preview.
305
307
  *
306
308
  * The preview feedback bridge (`/api/preview/feedback` and its `/context` renewal) is the
307
309
  * one member with an effect: it forwards a reviewer's anonymous annotation to tot-mcp and
@@ -319,6 +321,8 @@ export function isBypassPrivilegedPath(pathname: string): boolean {
319
321
  * Exact paths, in BOTH addressing forms (the gate sees the PRE-STRIP path).
320
322
  */
321
323
  export const PREVIEW_VISITOR_API_PATHS = [
324
+ "/api/contact/bulk-quote",
325
+ "/api/contact/token",
322
326
  "/api/newsletter",
323
327
  "/api/preview/feedback",
324
328
  "/api/preview/feedback/context",
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * HOW IT GETS HERE. Workers have no filesystem/git at runtime, so the SHA is
11
11
  * baked in at BUILD time: astro.config.mjs's Vite `define` replaces the
12
- * `__GIT_SHA__` token with a string literal of the build's commit (CI-provided
13
- * `GIT_SHA`/`WORKERS_CI_COMMIT_SHA`/`GITHUB_SHA`, else local `git rev-parse`,
12
+ * `__GIT_SHA__` token with a string literal of the build's commit (`GIT_SHA`,
13
+ * else `git rev-parse HEAD`, else CI fallback `WORKERS_CI_COMMIT_SHA`/`GITHUB_SHA`,
14
14
  * else "unknown"). This is the SAME source /health already reports (lib/observability/shared/health.ts)
15
15
  * — we read it through the identical `typeof` guard so both agree by construction,
16
16
  * and so the value is safe under vitest (where the define isn't applied → "unknown").
@@ -471,6 +471,8 @@ export type BulkQuoteErrorCode =
471
471
 
472
472
  export type BulkQuoteSubmitResponse =
473
473
  | { ok: true; quoteId: string }
474
+ /** The store is not public (a preview): the request passed every check and nothing was stored. */
475
+ | { ok: true; preview: true }
474
476
  | { ok: false; error: BulkQuoteErrorCode; field?: BulkQuoteField; index?: number };
475
477
 
476
478
  export interface BulkQuoteClientResult {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.6.18",
3
+ "version": "7.6.20",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",