@burdenoff/microfe-healthybowl 2026.812.22 → 2026.813.2
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.
|
@@ -13,7 +13,7 @@ function d(e) {
|
|
|
13
13
|
}
|
|
14
14
|
function f(e) {
|
|
15
15
|
let t = e.toLowerCase();
|
|
16
|
-
return t.includes("harvest") ? /* @__PURE__ */ l(r, { className: "h-4 w-4" }) : t.includes("process") || t.includes("wash") ? /* @__PURE__ */ l(n, { className: "h-4 w-4" }) : t.includes("pack") ? /* @__PURE__ */ l(a, { className: "h-4 w-4" }) : t.includes("ship") || t.includes("transit") || t.includes("deliver") ? /* @__PURE__ */ l(s, { className: "h-4 w-4" }) : /* @__PURE__ */ l(o, { className: "h-4 w-4" });
|
|
16
|
+
return t.includes("harvest") ? /* @__PURE__ */ l(r, { className: "h-4 w-4" }) : t.includes("process") || t.includes("wash") ? /* @__PURE__ */ l(n, { className: "h-4 w-4" }) : t.includes("pack") ? /* @__PURE__ */ l(a, { className: "h-4 w-4" }) : t.includes("ship") || t.includes("transit") || t.includes("deliver") || t.includes("dispatch") ? /* @__PURE__ */ l(s, { className: "h-4 w-4" }) : /* @__PURE__ */ l(o, { className: "h-4 w-4" });
|
|
17
17
|
}
|
|
18
18
|
function p(e) {
|
|
19
19
|
let t = [];
|
|
@@ -24,7 +24,7 @@ function p(e) {
|
|
|
24
24
|
icon: /* @__PURE__ */ l(o, { className: "h-4 w-4" })
|
|
25
25
|
});
|
|
26
26
|
let n = d(e.harvestDate);
|
|
27
|
-
n && t.push({
|
|
27
|
+
n && !e.supplyChainSteps.some((e) => e.step.toLowerCase().includes("harvest")) && t.push({
|
|
28
28
|
key: "harvested",
|
|
29
29
|
title: "Harvested",
|
|
30
30
|
detail: n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicTraceJourney.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceJourney.tsx"],"sourcesContent":["/**\n * \"Your food's journey\" — the branded, read-only page a shopper sees after scanning (mockup 3).\n *\n * Renders only what the server chose to send. Every field is optional because the farmer can hide\n * any of them in Trace Portal settings, and a missing field is simply absent — never faked, never\n * back-filled with a placeholder date or a generic farm name.\n */\nimport { AlertOctagon, BadgeCheck, Leaf, MapPin, Package, Sprout, Truck, Droplets } from 'lucide-react';\nimport type { ReactNode } from 'react';\n\nexport interface PublicTraceStep {\n step: string;\n location: string | null;\n date: string | null;\n verified: boolean;\n}\n\nexport interface PublicTraceBatch {\n batchCode: string;\n product: string;\n origin: string | null;\n harvestDate: string | null;\n processingDate: string | null;\n packagingDate: string | null;\n expiryDate: string | null;\n certifications: string[];\n publishedAt: string;\n publicSlug: string;\n /** BOFF-6044: true when this batch has been recalled. Drives the recall notice below. */\n recalled: boolean;\n /** The grower's public-safe recall reason, when supplied. */\n recallNotice: string | null;\n supplyChainSteps: PublicTraceStep[];\n portal: { tagline: string | null; showVerifiedOrganicBanner: boolean };\n}\n\n/** `2026-06-12T00:00:00.000Z` → `12 Jun 2026`. Returns null for anything unparseable. */\nfunction formatDay(iso: string | null): string | null {\n if (!iso) return null;\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'UTC' });\n}\n\n/** Pick an icon from the step name, falling back to a neutral marker. */\nfunction stepIcon(step: string): ReactNode {\n const name = step.toLowerCase();\n if (name.includes('harvest')) return <Leaf className=\"h-4 w-4\" />;\n if (name.includes('process') || name.includes('wash')) return <Droplets className=\"h-4 w-4\" />;\n if (name.includes('pack')) return <Package className=\"h-4 w-4\" />;\n if (name.includes('ship') || name.includes('transit') || name.includes('deliver'))\n return <Truck className=\"h-4 w-4\" />;\n return <Sprout className=\"h-4 w-4\" />;\n}\n\ninterface JourneyEntry {\n key: string;\n title: string;\n detail: string | null;\n icon: ReactNode;\n}\n\n/**\n * Build the vertical timeline. The origin and harvest date are surfaced as their own legs (they\n * are the two things a shopper actually cares about), then the recorded supply-chain steps follow\n * in the order the farmer entered them.\n */\nfunction buildJourney(batch: PublicTraceBatch): JourneyEntry[] {\n const entries: JourneyEntry[] = [];\n\n if (batch.origin) {\n entries.push({ key: 'grown', title: 'Grown', detail: batch.origin, icon: <Sprout className=\"h-4 w-4\" /> });\n }\n const harvested = formatDay(batch.harvestDate);\n if (harvested) {\n entries.push({ key: 'harvested', title: 'Harvested', detail: harvested, icon: <Leaf className=\"h-4 w-4\" /> });\n }\n\n batch.supplyChainSteps.forEach((step, index) => {\n const parts = [step.location, formatDay(step.date) ?? step.date].filter(Boolean) as string[];\n entries.push({\n key: `step-${index}-${step.step}`,\n title: step.step,\n detail: parts.length ? parts.join(' · ') : null,\n icon: stepIcon(step.step),\n });\n });\n\n // Only add a packaging leg when it isn't already told by a supply-chain step.\n const packaged = formatDay(batch.packagingDate);\n if (packaged && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('pack'))) {\n entries.push({ key: 'packed', title: 'Packed', detail: packaged, icon: <Package className=\"h-4 w-4\" /> });\n }\n\n return entries;\n}\n\nexport const PublicTraceJourney = ({ batch }: { batch: PublicTraceBatch }) => {\n const journey = buildJourney(batch);\n const bestBefore = formatDay(batch.expiryDate);\n\n return (\n <main className=\"min-h-screen bg-bg-canvas pb-12\" data-testid=\"public-trace-page\">\n <header className=\"bg-accent-teal/10 px-4 pb-10 pt-8 text-center\">\n <div className=\"mx-auto flex max-w-lg items-center justify-center gap-2\">\n <Leaf className=\"h-6 w-6 text-accent-teal\" aria-hidden />\n <span className=\"text-lg font-semibold text-text-primary\">HealthyBowl</span>\n </div>\n <h1 className=\"mt-5 text-2xl font-bold text-text-primary sm:text-3xl\">Your food’s journey</h1>\n <p className=\"mt-1 text-sm text-text-secondary\" data-testid=\"public-trace-subtitle\">\n {batch.product} · Batch {batch.batchCode}\n </p>\n {batch.portal.tagline ? (\n <p className=\"mx-auto mt-3 max-w-md text-sm italic text-text-secondary\">{batch.portal.tagline}</p>\n ) : null}\n </header>\n\n <div className=\"mx-auto -mt-6 max-w-lg px-4\">\n {batch.recalled ? (\n <section\n className=\"mb-4 rounded-xl border border-status-error-border bg-status-error-bg p-4 shadow-sm\"\n data-testid=\"public-trace-recall-notice\"\n role=\"alert\"\n >\n <div className=\"flex items-start gap-3\">\n <AlertOctagon className=\"mt-0.5 h-6 w-6 shrink-0 text-status-error-text\" aria-hidden />\n <div>\n <p className=\"text-base font-bold text-status-error-text\">This product has been recalled</p>\n <p className=\"mt-1 text-sm text-text-primary\">\n {batch.recallNotice\n ? batch.recallNotice\n : 'The grower has recalled this batch. Do not consume it, and contact your point of purchase.'}\n </p>\n </div>\n </div>\n </section>\n ) : null}\n\n {/*\n When recalled, we deliberately show ONLY the recall notice above — never the clean\n farm-to-fork journey, origin card, certifications, best-before, or the \"Verified Organic\"\n banner. Rendering that reassuring content under a recall is exactly the mis-serving this\n feature exists to prevent (defence-in-depth: the server already suppresses it too).\n */}\n {!batch.recalled ? (\n <>\n {batch.origin ? (\n <section className=\"rounded-xl border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"flex items-start gap-3\">\n <MapPin className=\"mt-0.5 h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <div>\n <p className=\"text-sm font-semibold text-text-primary\" data-testid=\"public-trace-origin\">\n {batch.origin}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">Farm origin recorded by the grower</p>\n </div>\n </div>\n </section>\n ) : null}\n\n {batch.portal.showVerifiedOrganicBanner ? (\n <section\n className=\"mt-4 flex items-center gap-3 rounded-xl border border-accent-teal/30 bg-accent-teal/10 p-4\"\n data-testid=\"public-trace-verified-banner\"\n >\n <BadgeCheck className=\"h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <p className=\"text-sm font-medium text-text-primary\">Verified Organic</p>\n </section>\n ) : null}\n\n {journey.length > 0 ? (\n <section className=\"mt-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Friendly journey</h2>\n <ol className=\"mt-3 space-y-1\" data-testid=\"public-trace-journey\">\n {journey.map((entry, index) => (\n <li key={entry.key} className=\"flex gap-3\">\n <div className=\"flex flex-col items-center\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent-teal/15 text-accent-teal\">\n {entry.icon}\n </span>\n {index < journey.length - 1 ? <span className=\"my-1 w-px flex-1 bg-accent-teal/30\" /> : null}\n </div>\n <div className=\"pb-5 pt-1.5\">\n <p className=\"text-sm font-semibold text-text-primary\">{entry.title}</p>\n {entry.detail ? <p className=\"mt-0.5 text-sm text-text-secondary\">{entry.detail}</p> : null}\n </div>\n </li>\n ))}\n </ol>\n </section>\n ) : (\n <p className=\"mt-6 text-sm text-text-secondary\">\n This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn’t\n logged them.\n </p>\n )}\n\n {batch.certifications.length > 0 ? (\n <section className=\"mt-4\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Certifications</h2>\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\" data-testid=\"public-trace-certifications\">\n {batch.certifications.map((certification) => (\n <div\n key={certification}\n className=\"flex items-center gap-2 rounded-xl bg-accent-teal/10 px-3 py-3 text-sm font-medium text-text-primary\"\n >\n <BadgeCheck className=\"h-4 w-4 shrink-0 text-accent-teal\" aria-hidden />\n {certification}\n </div>\n ))}\n </div>\n </section>\n ) : null}\n\n {bestBefore ? (\n <p className=\"mt-6 text-center text-sm text-text-secondary\" data-testid=\"public-trace-best-before\">\n Best before: {bestBefore}\n </p>\n ) : null}\n </>\n ) : null}\n\n <footer className=\"mt-10 border-t border-border-subtle pt-5 text-center text-xs text-text-secondary\">\n <p>\n Verified by HealthyBowl ·{' '}\n <a href=\"https://gethealthybowl.com\" className=\"underline hover:text-text-primary\">\n gethealthybowl.com\n </a>\n </p>\n <p className=\"mt-1\">Organic. Traceable. Trusted.</p>\n </footer>\n </div>\n </main>\n );\n};\n"],"mappings":";;;A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,GAAG,KACnF;WACH;UAXI,EAAM,IAWV,CACL;OACC,CAAA,CACG;UAEV,kBAAC,KAAD;MAAG,WAAU;gBAAmC;MAG5C,CAAA;KAGL,EAAM,eAAe,SAAS,IAC7B,kBAAC,WAAD;MAAS,WAAU;gBAAnB,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAoE;OAAmB,CAAA,EACrG,kBAAC,OAAD;OAAK,WAAU;OAAiC,eAAY;iBACzD,EAAM,eAAe,KAAK,MACzB,kBAAC,OAAD;QAEE,WAAU;kBAFZ,CAIE,kBAAC,GAAD;SAAY,WAAU;SAAoC,eAAA;SAAc,CAAA,EACvE,EACG;UALC,EAKD,CACN;OACE,CAAA,CACE;UACR;KAEH,IACC,kBAAC,KAAD;MAAG,WAAU;MAA+C,eAAY;gBAAxE,CAAmG,iBACnF,EACZ;UACF;KACH,EAAA,CAAA;IAGL,kBAAC,UAAD;KAAQ,WAAU;eAAlB,CACE,kBAAC,KAAD,EAAA,UAAA;MAAG;MACyB;MAC1B,kBAAC,KAAD;OAAG,MAAK;OAA6B,WAAU;iBAAoC;OAE/E,CAAA;MACF,EAAA,CAAA,EACJ,kBAAC,KAAD;MAAG,WAAU;gBAAO;MAAgC,CAAA,CAC7C;;IACL;KACD"}
|
|
1
|
+
{"version":3,"file":"PublicTraceJourney.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceJourney.tsx"],"sourcesContent":["/**\n * \"Your food's journey\" — the branded, read-only page a shopper sees after scanning (mockup 3).\n *\n * Renders only what the server chose to send. Every field is optional because the farmer can hide\n * any of them in Trace Portal settings, and a missing field is simply absent — never faked, never\n * back-filled with a placeholder date or a generic farm name.\n */\nimport { AlertOctagon, BadgeCheck, Leaf, MapPin, Package, Sprout, Truck, Droplets } from 'lucide-react';\nimport type { ReactNode } from 'react';\n\nexport interface PublicTraceStep {\n step: string;\n location: string | null;\n date: string | null;\n verified: boolean;\n}\n\nexport interface PublicTraceBatch {\n batchCode: string;\n product: string;\n origin: string | null;\n harvestDate: string | null;\n processingDate: string | null;\n packagingDate: string | null;\n expiryDate: string | null;\n certifications: string[];\n publishedAt: string;\n publicSlug: string;\n /** BOFF-6044: true when this batch has been recalled. Drives the recall notice below. */\n recalled: boolean;\n /** The grower's public-safe recall reason, when supplied. */\n recallNotice: string | null;\n supplyChainSteps: PublicTraceStep[];\n portal: { tagline: string | null; showVerifiedOrganicBanner: boolean };\n}\n\n/** `2026-06-12T00:00:00.000Z` → `12 Jun 2026`. Returns null for anything unparseable. */\nfunction formatDay(iso: string | null): string | null {\n if (!iso) return null;\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'UTC' });\n}\n\n/** Pick an icon from the step name, falling back to a neutral marker. Exported for unit testing. */\nexport function stepIcon(step: string): ReactNode {\n const name = step.toLowerCase();\n if (name.includes('harvest')) return <Leaf className=\"h-4 w-4\" />;\n if (name.includes('process') || name.includes('wash')) return <Droplets className=\"h-4 w-4\" />;\n if (name.includes('pack')) return <Package className=\"h-4 w-4\" />;\n if (name.includes('ship') || name.includes('transit') || name.includes('deliver') || name.includes('dispatch'))\n return <Truck className=\"h-4 w-4\" />;\n return <Sprout className=\"h-4 w-4\" />;\n}\n\ninterface JourneyEntry {\n key: string;\n title: string;\n detail: string | null;\n icon: ReactNode;\n}\n\n/**\n * Build the vertical timeline. The origin and harvest date are surfaced as their own legs (they\n * are the two things a shopper actually cares about), then the recorded supply-chain steps follow\n * in the order the farmer entered them.\n *\n * BOFF-6102: `supplyChainSteps` now carries the real appended ledger (BOFF-6155) once a batch has\n * events, so a HARVESTED event and a PACKED event can duplicate the synthetic harvest/pack legs\n * below — both are guarded to skip the synthetic leg when a matching step is already present.\n */\nexport function buildJourney(batch: PublicTraceBatch): JourneyEntry[] {\n const entries: JourneyEntry[] = [];\n\n if (batch.origin) {\n entries.push({ key: 'grown', title: 'Grown', detail: batch.origin, icon: <Sprout className=\"h-4 w-4\" /> });\n }\n // Only add the synthetic harvest leg when it isn't already told by a supply-chain step — a\n // real appended HARVESTED ledger event (BOFF-6155) would otherwise duplicate this leg.\n const harvested = formatDay(batch.harvestDate);\n if (harvested && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('harvest'))) {\n entries.push({ key: 'harvested', title: 'Harvested', detail: harvested, icon: <Leaf className=\"h-4 w-4\" /> });\n }\n\n batch.supplyChainSteps.forEach((step, index) => {\n const parts = [step.location, formatDay(step.date) ?? step.date].filter(Boolean) as string[];\n entries.push({\n key: `step-${index}-${step.step}`,\n title: step.step,\n detail: parts.length ? parts.join(' · ') : null,\n icon: stepIcon(step.step),\n });\n });\n\n // Only add a packaging leg when it isn't already told by a supply-chain step.\n const packaged = formatDay(batch.packagingDate);\n if (packaged && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('pack'))) {\n entries.push({ key: 'packed', title: 'Packed', detail: packaged, icon: <Package className=\"h-4 w-4\" /> });\n }\n\n return entries;\n}\n\nexport const PublicTraceJourney = ({ batch }: { batch: PublicTraceBatch }) => {\n const journey = buildJourney(batch);\n const bestBefore = formatDay(batch.expiryDate);\n\n return (\n <main className=\"min-h-screen bg-bg-canvas pb-12\" data-testid=\"public-trace-page\">\n <header className=\"bg-accent-teal/10 px-4 pb-10 pt-8 text-center\">\n <div className=\"mx-auto flex max-w-lg items-center justify-center gap-2\">\n <Leaf className=\"h-6 w-6 text-accent-teal\" aria-hidden />\n <span className=\"text-lg font-semibold text-text-primary\">HealthyBowl</span>\n </div>\n <h1 className=\"mt-5 text-2xl font-bold text-text-primary sm:text-3xl\">Your food’s journey</h1>\n <p className=\"mt-1 text-sm text-text-secondary\" data-testid=\"public-trace-subtitle\">\n {batch.product} · Batch {batch.batchCode}\n </p>\n {batch.portal.tagline ? (\n <p className=\"mx-auto mt-3 max-w-md text-sm italic text-text-secondary\">{batch.portal.tagline}</p>\n ) : null}\n </header>\n\n <div className=\"mx-auto -mt-6 max-w-lg px-4\">\n {batch.recalled ? (\n <section\n className=\"mb-4 rounded-xl border border-status-error-border bg-status-error-bg p-4 shadow-sm\"\n data-testid=\"public-trace-recall-notice\"\n role=\"alert\"\n >\n <div className=\"flex items-start gap-3\">\n <AlertOctagon className=\"mt-0.5 h-6 w-6 shrink-0 text-status-error-text\" aria-hidden />\n <div>\n <p className=\"text-base font-bold text-status-error-text\">This product has been recalled</p>\n <p className=\"mt-1 text-sm text-text-primary\">\n {batch.recallNotice\n ? batch.recallNotice\n : 'The grower has recalled this batch. Do not consume it, and contact your point of purchase.'}\n </p>\n </div>\n </div>\n </section>\n ) : null}\n\n {/*\n When recalled, we deliberately show ONLY the recall notice above — never the clean\n farm-to-fork journey, origin card, certifications, best-before, or the \"Verified Organic\"\n banner. Rendering that reassuring content under a recall is exactly the mis-serving this\n feature exists to prevent (defence-in-depth: the server already suppresses it too).\n */}\n {!batch.recalled ? (\n <>\n {batch.origin ? (\n <section className=\"rounded-xl border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"flex items-start gap-3\">\n <MapPin className=\"mt-0.5 h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <div>\n <p className=\"text-sm font-semibold text-text-primary\" data-testid=\"public-trace-origin\">\n {batch.origin}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">Farm origin recorded by the grower</p>\n </div>\n </div>\n </section>\n ) : null}\n\n {batch.portal.showVerifiedOrganicBanner ? (\n <section\n className=\"mt-4 flex items-center gap-3 rounded-xl border border-accent-teal/30 bg-accent-teal/10 p-4\"\n data-testid=\"public-trace-verified-banner\"\n >\n <BadgeCheck className=\"h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <p className=\"text-sm font-medium text-text-primary\">Verified Organic</p>\n </section>\n ) : null}\n\n {journey.length > 0 ? (\n <section className=\"mt-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Friendly journey</h2>\n <ol className=\"mt-3 space-y-1\" data-testid=\"public-trace-journey\">\n {journey.map((entry, index) => (\n <li key={entry.key} className=\"flex gap-3\">\n <div className=\"flex flex-col items-center\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent-teal/15 text-accent-teal\">\n {entry.icon}\n </span>\n {index < journey.length - 1 ? <span className=\"my-1 w-px flex-1 bg-accent-teal/30\" /> : null}\n </div>\n <div className=\"pb-5 pt-1.5\">\n <p className=\"text-sm font-semibold text-text-primary\">{entry.title}</p>\n {entry.detail ? <p className=\"mt-0.5 text-sm text-text-secondary\">{entry.detail}</p> : null}\n </div>\n </li>\n ))}\n </ol>\n </section>\n ) : (\n <p className=\"mt-6 text-sm text-text-secondary\">\n This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn’t\n logged them.\n </p>\n )}\n\n {batch.certifications.length > 0 ? (\n <section className=\"mt-4\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Certifications</h2>\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\" data-testid=\"public-trace-certifications\">\n {batch.certifications.map((certification) => (\n <div\n key={certification}\n className=\"flex items-center gap-2 rounded-xl bg-accent-teal/10 px-3 py-3 text-sm font-medium text-text-primary\"\n >\n <BadgeCheck className=\"h-4 w-4 shrink-0 text-accent-teal\" aria-hidden />\n {certification}\n </div>\n ))}\n </div>\n </section>\n ) : null}\n\n {bestBefore ? (\n <p className=\"mt-6 text-center text-sm text-text-secondary\" data-testid=\"public-trace-best-before\">\n Best before: {bestBefore}\n </p>\n ) : null}\n </>\n ) : null}\n\n <footer className=\"mt-10 border-t border-border-subtle pt-5 text-center text-xs text-text-secondary\">\n <p>\n Verified by HealthyBowl ·{' '}\n <a href=\"https://gethealthybowl.com\" className=\"underline hover:text-text-primary\">\n gethealthybowl.com\n </a>\n </p>\n <p className=\"mt-1\">Organic. Traceable. Trusted.</p>\n </footer>\n </div>\n </main>\n );\n};\n"],"mappings":";;;AAqCA,SAAS,EAAU,GAAmC;AACpD,KAAI,CAAC,EAAK,QAAO;CACjB,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AAC,KAAD;UAAG,WAAU;oBAAsC,EAAM;UAAW,CAAA,GAAG,KACnF;WACH;UAXI,EAAM,IAWV,CACL;OACC,CAAA,CACG;UAEV,kBAAC,KAAD;MAAG,WAAU;gBAAmC;MAG5C,CAAA;KAGL,EAAM,eAAe,SAAS,IAC7B,kBAAC,WAAD;MAAS,WAAU;gBAAnB,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAoE;OAAmB,CAAA,EACrG,kBAAC,OAAD;OAAK,WAAU;OAAiC,eAAY;iBACzD,EAAM,eAAe,KAAK,MACzB,kBAAC,OAAD;QAEE,WAAU;kBAFZ,CAIE,kBAAC,GAAD;SAAY,WAAU;SAAoC,eAAA;SAAc,CAAA,EACvE,EACG;UALC,EAKD,CACN;OACE,CAAA,CACE;UACR;KAEH,IACC,kBAAC,KAAD;MAAG,WAAU;MAA+C,eAAY;gBAAxE,CAAmG,iBACnF,EACZ;UACF;KACH,EAAA,CAAA;IAGL,kBAAC,UAAD;KAAQ,WAAU;eAAlB,CACE,kBAAC,KAAD,EAAA,UAAA;MAAG;MACyB;MAC1B,kBAAC,KAAD;OAAG,MAAK;OAA6B,WAAU;iBAAoC;OAE/E,CAAA;MACF,EAAA,CAAA,EACJ,kBAAC,KAAD;MAAG,WAAU;gBAAO;MAAgC,CAAA,CAC7C;;IACL;KACD"}
|
package/dist/utils/quotaUtils.js
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
//#region src/utils/quotaUtils.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return e?.some((e) => e.extensions?.code === "QUOTA_EXHAUSTED" || e.extensions?.errorCode === "QUOTA_EXHAUSTED" || e.message?.includes("QUOTA_EXHAUSTED")) ?? !1;
|
|
4
|
-
}
|
|
5
|
-
function t(e, t) {
|
|
2
|
+
function e(e, t) {
|
|
6
3
|
if (!e || typeof e != "object") return;
|
|
7
4
|
let n = e[t];
|
|
8
5
|
return Array.isArray(n) ? n : void 0;
|
|
9
6
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
function t(e) {
|
|
8
|
+
let t = i(e);
|
|
9
|
+
return t ? t === "exhausted" : e instanceof Error && e.message.toLowerCase().includes("quota exhausted");
|
|
10
|
+
}
|
|
11
|
+
var n = {
|
|
12
|
+
QUOTA_EXHAUSTED: "exhausted",
|
|
13
|
+
QUOTA_NOT_PROVISIONED: "not-provisioned"
|
|
14
|
+
};
|
|
15
|
+
function r(t) {
|
|
16
|
+
if (!t || typeof t != "object") return [];
|
|
17
|
+
let r = [
|
|
18
|
+
t,
|
|
19
|
+
t.result,
|
|
20
|
+
t.networkError
|
|
21
|
+
], i = [];
|
|
22
|
+
for (let t of r) for (let n of e(t, "errors") ?? []) n.extensions?.code && i.push(n.extensions.code), n.extensions?.errorCode && i.push(n.extensions.errorCode);
|
|
23
|
+
let a = t.bodyText, o = t instanceof Error ? t.message : void 0;
|
|
24
|
+
for (let e of [a, o]) if (typeof e == "string") for (let t of Object.keys(n)) e.includes(t) && i.push(t);
|
|
25
|
+
return i;
|
|
26
|
+
}
|
|
27
|
+
function i(e) {
|
|
28
|
+
let t = r(e);
|
|
29
|
+
if (t.includes("QUOTA_NOT_PROVISIONED")) return "not-provisioned";
|
|
30
|
+
if (t.includes("QUOTA_EXHAUSTED")) return "exhausted";
|
|
31
|
+
let n = e?.statusCode;
|
|
32
|
+
return typeof n == "number" && n === 429 ? "exhausted" : null;
|
|
19
33
|
}
|
|
20
|
-
var
|
|
34
|
+
var a = "healthybowl:quota-exhausted";
|
|
21
35
|
//#endregion
|
|
22
|
-
export {
|
|
36
|
+
export { a as QUOTA_EXHAUSTED_EVENT, t as isQuotaExhaustedError };
|
|
23
37
|
|
|
24
38
|
//# sourceMappingURL=quotaUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotaUtils.js","names":[],"sources":["../../src/utils/quotaUtils.ts"],"sourcesContent":["/**\n * Quota-error detection for the assistant's raw-fetch transport.\n *\n * The assistant talks to the wspace gateway over `fetch` (not Apollo), so it\n * can't rely on the Apollo error link. `isQuotaExhaustedError` inspects the\n * thrown error for the gateway's 429 / QUOTA_EXHAUSTED signal across the shapes\n * `executeSandboxGraphQL` surfaces (Error.message, `.statusCode`, `.result`).\n *\n * Only the assistant's two quota walls are modelled: `sandbox` (the\n * sandboxes-created @usage limit hit during provisioning) and `ai-credits`\n * (per-token budget).\n */\n\ntype GraphQLErrorLike = {\n message?: string;\n extensions?: {\n code?: string;\n errorCode?: string;\n };\n};\n\nfunction
|
|
1
|
+
{"version":3,"file":"quotaUtils.js","names":[],"sources":["../../src/utils/quotaUtils.ts"],"sourcesContent":["/**\n * Quota-error detection for the assistant's raw-fetch transport.\n *\n * The assistant talks to the wspace gateway over `fetch` (not Apollo), so it\n * can't rely on the Apollo error link. `isQuotaExhaustedError` inspects the\n * thrown error for the gateway's 429 / QUOTA_EXHAUSTED signal across the shapes\n * `executeSandboxGraphQL` surfaces (Error.message, `.statusCode`, `.result`).\n *\n * Only the assistant's two quota walls are modelled: `sandbox` (the\n * sandboxes-created @usage limit hit during provisioning) and `ai-credits`\n * (per-token budget).\n */\n\ntype GraphQLErrorLike = {\n message?: string;\n extensions?: {\n code?: string;\n errorCode?: string;\n };\n};\n\nfunction arrayOfErrorsAt(host: object | undefined, key: 'errors'): GraphQLErrorLike[] | undefined {\n if (!host || typeof host !== 'object') return undefined;\n const value = (host as Record<string, unknown>)[key];\n return Array.isArray(value) ? (value as GraphQLErrorLike[]) : undefined;\n}\n\n/**\n * Whether this error is an EXHAUSTED quota specifically.\n *\n * ★ BOFF-6302 — this used to match any HTTP 429, and a workspace with no assignment row is refused\n * `429 QUOTA_NOT_PROVISIONED`. That is not exhaustion: the farmer has not used anything up, their\n * plan was never granted, and \"you have reached your limit\" sends them to buy an upgrade that would\n * not unblock them. {@link classifyQuotaError} now owns the distinction and this delegates to it.\n */\nexport function isQuotaExhaustedError(error: unknown): boolean {\n const refusal = classifyQuotaError(error);\n if (refusal) return refusal === 'exhausted';\n\n // The one shape the classifier deliberately does not match: prose with no code in it. Kept for the\n // assistant's raw-fetch transport, which can surface a bare \"quota exhausted\" string.\n return error instanceof Error && error.message.toLowerCase().includes('quota exhausted');\n}\n\n/**\n * The two ways the gateway refuses a metered mutation. They are NOT the same thing and must not be\n * shown to a farmer with the same words (BOFF-6302).\n *\n * - `exhausted` — the workspace has the quota and has used it up. Deleting something, or upgrading,\n * fixes it. Actionable by the user.\n * - `not-provisioned` — the workspace has **no assignment row for that quota at all**, so the\n * gateway fails closed. Nothing the user does fixes it: they have not hit a limit, their plan was\n * never granted. Measured in prod 2026-08-13, this is why `createHealthyBowlFarm` returns\n * `429 QUOTA_NOT_PROVISIONED` on several workspaces — the core create path is simply dead there.\n *\n * ★ Keyed on `extensions.code`, never on the HTTP status or the message text. Both refusals are\n * `429`, so status alone cannot tell them apart — which is exactly how \"no active subscription\n * covers this\" would otherwise be reported to a farmer as \"you have reached your limit\".\n */\nexport type QuotaRefusal = 'exhausted' | 'not-provisioned';\n\nconst REFUSAL_BY_CODE: Record<string, QuotaRefusal> = {\n QUOTA_EXHAUSTED: 'exhausted',\n QUOTA_NOT_PROVISIONED: 'not-provisioned',\n};\n\n/** Every `extensions.code` reachable on an error, across the shapes Apollo and raw-fetch produce. */\nfunction codesIn(error: unknown): string[] {\n if (!error || typeof error !== 'object') return [];\n const hosts = [\n error as object,\n (error as { result?: object }).result,\n (error as { networkError?: object }).networkError,\n ];\n const codes: string[] = [];\n for (const host of hosts) {\n for (const e of arrayOfErrorsAt(host, 'errors') ?? []) {\n if (e.extensions?.code) codes.push(e.extensions.code);\n if (e.extensions?.errorCode) codes.push(e.extensions.errorCode);\n }\n }\n const bodyText = (error as { bodyText?: unknown }).bodyText;\n const message = error instanceof Error ? error.message : undefined;\n for (const text of [bodyText, message]) {\n if (typeof text !== 'string') continue;\n for (const code of Object.keys(REFUSAL_BY_CODE)) if (text.includes(code)) codes.push(code);\n }\n return codes;\n}\n\n/**\n * Which refusal this is, or null when the error is not a quota wall at all.\n *\n * `not-provisioned` wins when both appear: it is the more specific and the more serious of the two,\n * and telling someone to upgrade when their plan was never granted sends them to buy something that\n * would not help.\n */\nexport function classifyQuotaError(error: unknown): QuotaRefusal | null {\n const codes = codesIn(error);\n if (codes.includes('QUOTA_NOT_PROVISIONED')) return 'not-provisioned';\n if (codes.includes('QUOTA_EXHAUSTED')) return 'exhausted';\n // A bare 429 with no discernible code: the assistant's raw-fetch transport can surface one, and\n // exhaustion is the likelier cause. Deliberately last, so an explicit code always wins.\n const statusCode = (error as { statusCode?: unknown } | null)?.statusCode;\n if (typeof statusCode === 'number' && statusCode === 429) return 'exhausted';\n return null;\n}\n\nexport type QuotaKind = 'sandbox' | 'ai-credits' | 'generic';\n\n// Event the assistant dispatches on a quota wall. HealthyBowl does not yet\n// mount a listener (the chat area also surfaces the wall inline), so this is a\n// best-effort hook for a future upgrade dialog.\nexport const QUOTA_EXHAUSTED_EVENT = 'healthybowl:quota-exhausted';\n\nexport interface QuotaExhaustedEventDetail {\n kind: QuotaKind;\n message?: string;\n operationName?: string | null;\n}\n"],"mappings":";AAqBA,SAAS,EAAgB,GAA0B,GAA+C;AAChG,KAAI,CAAC,KAAQ,OAAO,KAAS,SAAU;CACvC,IAAM,IAAS,EAAiC;AAChD,QAAO,MAAM,QAAQ,EAAM,GAAI,IAA+B,KAAA;;AAWhE,SAAgB,EAAsB,GAAyB;CAC7D,IAAM,IAAU,EAAmB,EAAM;AAKzC,QAJI,IAAgB,MAAY,cAIzB,aAAiB,SAAS,EAAM,QAAQ,aAAa,CAAC,SAAS,kBAAkB;;AAoB1F,IAAM,IAAgD;CACpD,iBAAiB;CACjB,uBAAuB;CACxB;AAGD,SAAS,EAAQ,GAA0B;AACzC,KAAI,CAAC,KAAS,OAAO,KAAU,SAAU,QAAO,EAAE;CAClD,IAAM,IAAQ;EACZ;EAC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