@burdenoff/microfe-healthybowl 2026.812.22 → 2026.813.1

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,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 n(n) {
11
- if (n instanceof Error && (n.message.includes("QUOTA_EXHAUSTED") || n.message.toLowerCase().includes("quota exhausted"))) return !0;
12
- if (!n || typeof n != "object") return !1;
13
- let r = n.statusCode;
14
- if (typeof r == "number" && r === 429) return !0;
15
- let i = n.bodyText;
16
- if (typeof i == "string" && i.includes("QUOTA_EXHAUSTED") || e(t(n, "errors"))) return !0;
17
- let a = n.result;
18
- return !!e(t(a, "errors"));
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 r = "healthybowl:quota-exhausted";
34
+ var a = "healthybowl:quota-exhausted";
21
35
  //#endregion
22
- export { r as QUOTA_EXHAUSTED_EVENT, n as isQuotaExhaustedError };
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 hasQuotaCode(errors: GraphQLErrorLike[] | undefined): boolean {\n return (\n errors?.some(\n (error) =>\n error.extensions?.code === 'QUOTA_EXHAUSTED' ||\n error.extensions?.errorCode === 'QUOTA_EXHAUSTED' ||\n error.message?.includes('QUOTA_EXHAUSTED')\n ) ?? false\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\nexport function isQuotaExhaustedError(error: unknown): boolean {\n if (\n error instanceof Error &&\n (error.message.includes('QUOTA_EXHAUSTED') || error.message.toLowerCase().includes('quota exhausted'))\n ) {\n return true;\n }\n\n if (!error || typeof error !== 'object') return false;\n\n // The wspace gateway short-circuits an @usage limit with statusCode 429 +\n // errors[].extensions.code = QUOTA_EXHAUSTED. executeSandboxGraphQL preserves\n // both on the thrown Error (`.statusCode`, `.result`).\n const statusCode = (error as { statusCode?: unknown }).statusCode;\n if (typeof statusCode === 'number' && statusCode === 429) return true;\n\n const bodyText = (error as { bodyText?: unknown }).bodyText;\n if (typeof bodyText === 'string' && bodyText.includes('QUOTA_EXHAUSTED')) return true;\n\n if (hasQuotaCode(arrayOfErrorsAt(error as object, 'errors'))) return true;\n\n const result = (error as { result?: unknown }).result;\n if (hasQuotaCode(arrayOfErrorsAt(result as object, 'errors'))) return true;\n\n return false;\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,EAAa,GAAiD;AACrE,QACE,GAAQ,MACL,MACC,EAAM,YAAY,SAAS,qBAC3B,EAAM,YAAY,cAAc,qBAChC,EAAM,SAAS,SAAS,kBAAkB,CAC7C,IAAI;;AAIT,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;;AAGhE,SAAgB,EAAsB,GAAyB;AAC7D,KACE,aAAiB,UAChB,EAAM,QAAQ,SAAS,kBAAkB,IAAI,EAAM,QAAQ,aAAa,CAAC,SAAS,kBAAkB,EAErG,QAAO;AAGT,KAAI,CAAC,KAAS,OAAO,KAAU,SAAU,QAAO;CAKhD,IAAM,IAAc,EAAmC;AACvD,KAAI,OAAO,KAAe,YAAY,MAAe,IAAK,QAAO;CAEjE,IAAM,IAAY,EAAiC;AAGnD,KAFI,OAAO,KAAa,YAAY,EAAS,SAAS,kBAAkB,IAEpE,EAAa,EAAgB,GAAiB,SAAS,CAAC,CAAE,QAAO;CAErE,IAAM,IAAU,EAA+B;AAG/C,QAFA,EAAI,EAAa,EAAgB,GAAkB,SAAS,CAAC;;AAU/D,IAAa,IAAwB"}
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;EACC,EAA8B;EAC9B,EAAoC;EACtC,EACK,IAAkB,EAAE;AAC1B,MAAK,IAAM,KAAQ,EACjB,MAAK,IAAM,KAAK,EAAgB,GAAM,SAAS,IAAI,EAAE,CAEnD,CADI,EAAE,YAAY,QAAM,EAAM,KAAK,EAAE,WAAW,KAAK,EACjD,EAAE,YAAY,aAAW,EAAM,KAAK,EAAE,WAAW,UAAU;CAGnE,IAAM,IAAY,EAAiC,UAC7C,IAAU,aAAiB,QAAQ,EAAM,UAAU,KAAA;AACzD,MAAK,IAAM,KAAQ,CAAC,GAAU,EAAQ,CAChC,YAAO,KAAS,SACpB,MAAK,IAAM,KAAQ,OAAO,KAAK,EAAgB,CAAE,CAAI,EAAK,SAAS,EAAK,IAAE,EAAM,KAAK,EAAK;AAE5F,QAAO;;AAUT,SAAgB,EAAmB,GAAqC;CACtE,IAAM,IAAQ,EAAQ,EAAM;AAC5B,KAAI,EAAM,SAAS,wBAAwB,CAAE,QAAO;AACpD,KAAI,EAAM,SAAS,kBAAkB,CAAE,QAAO;CAG9C,IAAM,IAAc,GAA2C;AAE/D,QADI,OAAO,KAAe,YAAY,MAAe,MAAY,cAC1D;;AAQT,IAAa,IAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.812.22",
3
+ "version": "2026.813.1",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [