@verbumia/feedback 0.2.7 → 0.2.8

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.
Files changed (37) hide show
  1. package/dist/chunk-EKU6NNWI.js +40 -0
  2. package/dist/chunk-EKU6NNWI.js.map +1 -0
  3. package/dist/{chunk-7KWEI55W.js → chunk-EMGN6MR4.js} +26 -1
  4. package/dist/chunk-EMGN6MR4.js.map +1 -0
  5. package/dist/{client-D83qhH0O.d.cts → client-CnEK_2SD.d.cts} +41 -0
  6. package/dist/{client-D83qhH0O.d.ts → client-CnEK_2SD.d.ts} +41 -0
  7. package/dist/core/index.cjs +25 -0
  8. package/dist/core/index.cjs.map +1 -1
  9. package/dist/core/index.d.cts +2 -2
  10. package/dist/core/index.d.ts +2 -2
  11. package/dist/core/index.js +1 -1
  12. package/dist/{keys-D4oJtn64.d.cts → keys-2_T5bDpX.d.cts} +1 -1
  13. package/dist/{keys-BpVB1kcI.d.ts → keys-eHc_lx5v.d.ts} +1 -1
  14. package/dist/native/index.cjs +155 -25
  15. package/dist/native/index.cjs.map +1 -1
  16. package/dist/native/index.d.cts +3 -3
  17. package/dist/native/index.d.ts +3 -3
  18. package/dist/native/index.js +99 -27
  19. package/dist/native/index.js.map +1 -1
  20. package/dist/react/index.cjs +157 -18
  21. package/dist/react/index.cjs.map +1 -1
  22. package/dist/react/index.d.cts +3 -3
  23. package/dist/react/index.d.ts +3 -3
  24. package/dist/react/index.js +101 -20
  25. package/dist/react/index.js.map +1 -1
  26. package/dist/svelte/index.cjs +25 -0
  27. package/dist/svelte/index.cjs.map +1 -1
  28. package/dist/svelte/index.d.cts +2 -2
  29. package/dist/svelte/index.d.ts +2 -2
  30. package/dist/svelte/index.js +1 -1
  31. package/dist/vue/index.cjs +25 -0
  32. package/dist/vue/index.cjs.map +1 -1
  33. package/dist/vue/index.d.cts +2 -2
  34. package/dist/vue/index.d.ts +2 -2
  35. package/dist/vue/index.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-7KWEI55W.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ // src/core/locales.ts
2
+ var MESSAGES = {
3
+ en: {
4
+ showOriginal: "Show original",
5
+ submitSuggestion: "Submit a suggestion",
6
+ updateMySuggestion: "Update my suggestion"
7
+ },
8
+ fr: {
9
+ showOriginal: "Voir l'original",
10
+ submitSuggestion: "Soumettre une suggestion",
11
+ updateMySuggestion: "Mettre \xE0 jour ma suggestion"
12
+ },
13
+ es: {
14
+ showOriginal: "Ver el original",
15
+ submitSuggestion: "Enviar una sugerencia",
16
+ updateMySuggestion: "Actualizar mi sugerencia"
17
+ },
18
+ de: {
19
+ showOriginal: "Original anzeigen",
20
+ submitSuggestion: "Vorschlag einreichen",
21
+ updateMySuggestion: "Meinen Vorschlag aktualisieren"
22
+ }
23
+ };
24
+ function t(locale, key) {
25
+ if (locale) {
26
+ const exact = MESSAGES[locale];
27
+ if (exact) return exact[key];
28
+ const base = locale.split("-")[0];
29
+ if (base) {
30
+ const baseMsgs = MESSAGES[base];
31
+ if (baseMsgs) return baseMsgs[key];
32
+ }
33
+ }
34
+ return MESSAGES.en[key];
35
+ }
36
+
37
+ export {
38
+ t
39
+ };
40
+ //# sourceMappingURL=chunk-EKU6NNWI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/locales.ts"],"sourcesContent":["/**\n * 0.2.8 — SDK-bundled UI labels.\n *\n * Verbumia's own SDK ships strings the panel renders in the user's\n * locale (NO Verbumia self-i18n cycle — the SDK pre-bundles every\n * locale it supports so a fresh install works offline and without any\n * extra namespace setup). Minimum coverage per master's task 849 spec:\n * `en`, `fr`, `es`. Other locales are added here as they are needed —\n * `de` is included opportunistically since the task description listed\n * it as an example.\n *\n * Resolution falls back: full locale (e.g. `fr-CA`) → base (`fr`) →\n * `en`. Never throws on an unknown key — TypeScript prevents that at\n * compile time via the `LocaleKey` union.\n */\n\n/** The set of UI keys the panel resolves through this module. Add a\n * key here AND in every locale block below — the type machinery makes\n * a missing translation a compile error in strict mode. */\nexport type LocaleKey =\n | \"showOriginal\"\n | \"submitSuggestion\"\n | \"updateMySuggestion\";\n\ntype LocaleStrings = { [K in LocaleKey]: string };\n\nconst MESSAGES: Record<string, LocaleStrings> = {\n en: {\n showOriginal: \"Show original\",\n submitSuggestion: \"Submit a suggestion\",\n updateMySuggestion: \"Update my suggestion\",\n },\n fr: {\n showOriginal: \"Voir l'original\",\n submitSuggestion: \"Soumettre une suggestion\",\n updateMySuggestion: \"Mettre à jour ma suggestion\",\n },\n es: {\n showOriginal: \"Ver el original\",\n submitSuggestion: \"Enviar una sugerencia\",\n updateMySuggestion: \"Actualizar mi sugerencia\",\n },\n de: {\n showOriginal: \"Original anzeigen\",\n submitSuggestion: \"Vorschlag einreichen\",\n updateMySuggestion: \"Meinen Vorschlag aktualisieren\",\n },\n};\n\n/**\n * Resolve `key` in `locale`, falling back to the base locale (`fr-CA`\n * → `fr`) and finally `en`. `locale` is the BCP-47 the host has\n * configured on the i18n provider (== `FeedbackClient.language` /\n * `cfg.language`); the panel passes it down.\n *\n * Pure, synchronous, allocation-free — safe to call inline in render.\n */\nexport function t(locale: string | undefined, key: LocaleKey): string {\n if (locale) {\n const exact = MESSAGES[locale];\n if (exact) return exact[key];\n const base = locale.split(\"-\")[0];\n if (base) {\n const baseMsgs = MESSAGES[base];\n if (baseMsgs) return baseMsgs[key];\n }\n }\n // `en` is guaranteed to exist (declared above), but TS's index-signature\n // typing returns `T | undefined` from a Record<string, …> lookup. The\n // non-null assertion is safe + cheaper than a runtime check.\n return MESSAGES.en![key];\n}\n"],"mappings":";AA0BA,IAAM,WAA0C;AAAA,EAC9C,IAAI;AAAA,IACF,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,EACtB;AAAA,EACA,IAAI;AAAA,IACF,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,EACtB;AACF;AAUO,SAAS,EAAE,QAA4B,KAAwB;AACpE,MAAI,QAAQ;AACV,UAAM,QAAQ,SAAS,MAAM;AAC7B,QAAI,MAAO,QAAO,MAAM,GAAG;AAC3B,UAAM,OAAO,OAAO,MAAM,GAAG,EAAE,CAAC;AAChC,QAAI,MAAM;AACR,YAAM,WAAW,SAAS,IAAI;AAC9B,UAAI,SAAU,QAAO,SAAS,GAAG;AAAA,IACnC;AAAA,EACF;AAIA,SAAO,SAAS,GAAI,GAAG;AACzB;","names":[]}
@@ -227,6 +227,31 @@ var FeedbackClient = class {
227
227
  suggest(payload) {
228
228
  this.enqueue({ kind: "suggestion", payload });
229
229
  }
230
+ /**
231
+ * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,
232
+ * deploy `45190c8`). Used by the panel's edit-mode editor when the
233
+ * end-user already has a pending suggestion for a string (the
234
+ * `FeedbackString.my_suggestion.id` from a prior submit). Submits
235
+ * synchronously rather than going through the rating/suggestion
236
+ * batch queue — the host triggered an explicit edit, not a passive
237
+ * rating, so we want the round-trip to surface before the panel
238
+ * closes. Best-effort failures bubble; the caller catches and
239
+ * shows an error row in the panel.
240
+ *
241
+ * Wire body: `{ text: string }` (backend probe confirmed). NOT the
242
+ * legacy `{ suggested_text }` of the batched POST path.
243
+ */
244
+ async editSuggestion(id, text) {
245
+ if (!id) throw new FeedbackError("editSuggestion: id is required");
246
+ const trimmed = (text ?? "").trim();
247
+ if (!trimmed) throw new FeedbackError("editSuggestion: text is required");
248
+ const res = await this.authed(`/v1/feedback/suggestions/${encodeURIComponent(id)}`, {
249
+ method: "PATCH",
250
+ headers: { "Content-Type": "application/json" },
251
+ body: JSON.stringify({ text: trimmed })
252
+ });
253
+ if (!res.ok) throw await this.problem(res, "failed to update suggestion");
254
+ }
230
255
  enqueue(item) {
231
256
  this.queue.push(item);
232
257
  if (this.queue.length >= this.cfg.maxBatch) {
@@ -328,4 +353,4 @@ export {
328
353
  resolveKeys,
329
354
  filterByNamespace
330
355
  };
331
- //# sourceMappingURL=chunk-7KWEI55W.js.map
356
+ //# sourceMappingURL=chunk-EMGN6MR4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/types.ts","../src/core/tos.ts","../src/core/client.ts","../src/core/keys.ts"],"sourcesContent":["/**\n * Wire types for the Verbumia End-User Translation Evaluation API.\n * Canonical reference: ./CONTRACT.md (frozen). Backend task 591.\n */\n\nexport interface FeedbackConfig {\n /** API base, no trailing slash needed. e.g. https://api.verbumia.dev */\n apiBase: string;\n /** Public project UUID the widget targets. */\n projectId: string;\n /**\n * sessionId / grouping_key is MINTED SERVER-SIDE by the Verbumia\n * backend at POST /v1/feedback/tos and returned in the token bundle\n * (`TokenBundle.grouping_key`). The widget receives + sends it; it\n * MUST NOT self-generate it. There is intentionally no client config\n * field for it.\n */\n /**\n * NOTE: there is intentionally NO `tosVersion` field. The ToS version\n * is a BUILD-TIME constant baked into @verbumia/feedback at release\n * (`SDK_TOS_VERSION`, task 616) — integrators do not set it; the SDK\n * sends it automatically.\n */\n /** Optional opaque end-user id; server generates one when absent. */\n endUserId?: string;\n /** BCP-47 language the widget rates strings in (e.g. \"fr\"). */\n language: string;\n /** Optional locale tag stored for analytics. */\n locale?: string;\n /** Debounce window (ms) before a queued batch is flushed. Default 1500. */\n flushDebounceMs?: number;\n /** Max queued items before an immediate flush. Default 20. */\n maxBatch?: number;\n /** Injected fetch (tests / RN polyfills). Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n /**\n * 0.2.7 — host's project API key (`vrb_live_…`, scope `project:read`).\n * When set, the client can call addon-state at setup time (BEFORE\n * the end-user accepts ToS) using `Authorization: ApiKey …` — mirrors\n * the existing scheme used by the i18n SDK's dev-env loaders. When\n * unset, addon-state is deferred until the user's session bearer is\n * minted via `acceptTos()`.\n */\n apiKey?: string;\n /**\n * #806 / 0.2.7 — when `false`, the client must NOT silently call\n * `POST /v1/feedback/tos` to bootstrap a session on the user's behalf.\n * Set by the plugin when the host opts into `tos: \"skip\"` (the host\n * promises to handle consent externally via `controller.acceptTos()`).\n * `authed()` then throws `FeedbackError(\"not consented\")` instead of\n * auto-accepting — the panel surfaces the existing error state.\n * Default `true` preserves all pre-0.2.7 behaviour.\n */\n autoAcceptTos?: boolean;\n}\n\nexport interface TokenBundle {\n access_token: string;\n token_type: \"Bearer\";\n expires_in: number;\n refresh_token: string;\n refresh_expires_in: number;\n end_user_id: string;\n tos_version: string;\n grouping_key: string;\n}\n\nexport interface FeedbackString {\n namespace: string;\n key: string;\n key_uuid: string;\n language_uuid: string;\n value: string;\n translation_hash: string;\n avg_stars: number | null;\n ratings_count: number;\n my_rating: number | null;\n /**\n * 0.2.8 — backend deploy `45190c8` (task 846) adds source-language\n * fields so the panel can render the source-locale text alongside\n * the target-locale text when the user toggles \"Show original\".\n *\n * - `source_text`: the source-locale rendering for this key\n * (== `value` whenever `source_locale === language` — the panel\n * uses that equality to hide the source row and avoid\n * duplication on a single-language project).\n * - `source_locale`: BCP-47 of the source.\n * - `my_suggestion`: the end-user's pending suggestion for this\n * key in this language (or `null`). Pre-fills the suggestion\n * editor + flips the submit path from POST → PATCH.\n */\n source_text: string;\n source_locale: string;\n my_suggestion: MySuggestion | null;\n}\n\n/** 0.2.8 — end-user's pending suggestion for one (key, language).\n * Returned inline on `FeedbackString` so the panel can render an\n * edit-mode editor without a second round-trip. */\nexport interface MySuggestion {\n /** Suggestion UUID; passed to `PATCH /v1/feedback/suggestions/{id}` to\n * update the text. */\n id: string;\n text: string;\n}\n\nexport interface StringsResponse {\n project_id: string;\n language: string;\n strings: FeedbackString[];\n}\n\n/**\n * 0.2.7 — addon state for a project, returned by\n * `GET /v1/projects/{projectId}/feedback-addon/state`. Drives the\n * controller surface (`isActive`, `enabledLanguages`, `sku`,\n * `languagesLimit`) so the host can hide its own CTA on Starter +\n * narrow the widget to enabled languages.\n *\n * Backend contract (camelCase aliases, populate_by_name=true on the\n * server schema, confirmed against backend task 836 SHA d78b939 + the\n * follow-up PR that extends the auth surface to accept project API\n * keys with `project:read` scope):\n * - `isActive`: org.feedback_addon.active\n * - `sku`: the SKU code, or `null` if no active SKU\n * - `enabledLanguages`: the project's allow-list, or literal `\"all\"`\n * when sku === `\"feedback_unlimited\"`; an empty array when no SKU\n * - `languagesLimit`: hard cap for Starter (3), null otherwise\n */\nexport interface FeedbackAddonState {\n isActive: boolean;\n sku: \"feedback_starter\" | \"feedback_unlimited\" | null;\n enabledLanguages: string[] | \"all\";\n languagesLimit: number | null;\n}\n\n/** A 5-star rating queued for a rendered string variant. */\nexport interface RatingInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n stars: number; // 1..5\n}\n\n/** A suggested alternative translation queued for moderation. */\nexport interface SuggestionInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n suggested_text: string;\n comment?: string;\n}\n\nexport interface BatchResponse {\n accepted: number;\n rejected: number;\n items: Array<Record<string, unknown>>;\n}\n\n/** A key the host app declares as on-screen. */\nexport interface DeclaredKey {\n namespace: string;\n key: string;\n}\n\nexport class FeedbackError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly code?: string,\n ) {\n super(message);\n this.name = \"FeedbackError\";\n }\n}\n","/**\n * BUILD-TIME ToS version constant (task 616, human decision option B).\n *\n * This is baked into the @verbumia/feedback PACKAGE at release. It is\n * NOT an integrator-set config field and NOT server-driven: a stale\n * (e.g. native) app must record consent to the ToS version IT shipped\n * and displayed, for legal correctness — never backend-latest.\n *\n * Releasing a ToS-TEXT change ⇒ bump this constant + cut a new\n * @verbumia/feedback release (per the human/real-CI publish handoff).\n * The backend accepts any version in its acceptable set and records it.\n */\nexport const SDK_TOS_VERSION = \"2026-05-18\";\n","/**\n * Framework-agnostic Verbumia feedback client.\n *\n * Responsibilities:\n * - versioned-ToS acceptance -> scoped end-user JWT bootstrap\n * - transparent access-token refresh (rotating refresh token)\n * - fetch on-screen strings for the widget\n * - debounced + size-capped batched POST of ratings / suggestions,\n * mirroring the missing-handler transport contract (ltm 280):\n * best-effort, never throws into the host app render path.\n *\n * The React and React Native entry points are thin UI shells over this.\n */\n\nimport {\n type BatchResponse,\n type FeedbackAddonState,\n type FeedbackConfig,\n FeedbackError,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\nimport { SDK_TOS_VERSION } from \"./tos\";\n\nconst SDK_LIB = \"@verbumia/feedback\";\nconst SDK_VER = \"0.2.0\";\n\ntype QueueItem =\n | { kind: \"rating\"; payload: RatingInput }\n | { kind: \"suggestion\"; payload: SuggestionInput };\n\nexport class FeedbackClient {\n private cfg: Required<\n Pick<FeedbackConfig, \"flushDebounceMs\" | \"maxBatch\">\n > &\n FeedbackConfig;\n private fetchImpl: typeof fetch;\n private tokens: TokenBundle | null = null;\n private queue: QueueItem[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private bootstrapping: Promise<TokenBundle> | null = null;\n\n constructor(config: FeedbackConfig) {\n this.cfg = {\n flushDebounceMs: 1500,\n maxBatch: 20,\n ...config,\n };\n const f = config.fetchImpl ?? globalThis.fetch;\n if (!f) {\n throw new FeedbackError(\n \"no fetch implementation available; pass config.fetchImpl\",\n );\n }\n this.fetchImpl = f.bind(globalThis);\n }\n\n private base(): string {\n return this.cfg.apiBase.replace(/\\/+$/, \"\");\n }\n\n get endUserId(): string | undefined {\n return this.tokens?.end_user_id ?? this.cfg.endUserId;\n }\n\n get hasConsented(): boolean {\n return this.tokens !== null;\n }\n\n /** Alias of `hasConsented` exposed under the 0.2.7 naming used by the\n * `controller.hasAcceptedTos` getter (the SDK's built-in modal and a\n * host's external ToS page share the same persisted token bundle, so\n * both flip this boolean once a session is bootstrapped). */\n get hasAcceptedTos(): boolean {\n return this.tokens !== null;\n }\n\n /** Server-minted sessionId / grouping_key (from the token bundle).\n * Available only after `acceptTos()`; never client-generated. */\n get sessionId(): string | undefined {\n return this.tokens?.grouping_key;\n }\n\n /**\n * 0.2.7 — `GET /v1/projects/{projectId}/feedback-addon/state`.\n *\n * Auth selection (matches backend's dual-acceptance after task 836's\n * follow-up PR — see CONTRACT note in the response type):\n * - If `cfg.apiKey` is set → `Authorization: ApiKey <key>` (so the\n * plugin can fetch state at `setup()` time, before the user has\n * accepted ToS).\n * - Else if a user-session bundle exists → `Authorization: Bearer\n * <access_token>` (the deferred-after-acceptTos path).\n * - Else → throw `FeedbackError(\"addon state requires apiKey or\n * acceptTos\")`. The plugin's setup catches and surfaces a\n * console.warn the first time, then re-attempts on the\n * bundle-mint that follows `acceptTos()`.\n *\n * Best-effort: a transport error returns `null` instead of throwing,\n * so the controller's `isActive` falls back to whatever was last\n * known (or its initial value) without flipping the host's CTA into\n * an inconsistent state on a transient blip.\n */\n async getAddonState(): Promise<FeedbackAddonState | null> {\n let auth: string | undefined;\n if (this.cfg.apiKey) {\n auth = `ApiKey ${this.cfg.apiKey}`;\n } else if (this.tokens) {\n auth = `Bearer ${this.tokens.access_token}`;\n } else {\n throw new FeedbackError(\n \"addon state requires apiKey or acceptTos\",\n );\n }\n const url = `${this.base()}/v1/projects/${this.cfg.projectId}/feedback-addon/state`;\n try {\n const res = await this.fetchImpl(url, {\n method: \"GET\",\n headers: { Authorization: auth },\n });\n if (!res.ok) return null;\n return (await res.json()) as FeedbackAddonState;\n } catch {\n return null;\n }\n }\n\n /** BCP-47 language the widget is rating strings in. */\n get language(): string {\n return this.cfg.language;\n }\n\n /**\n * Re-target the widget's working language at runtime (#806 SeedSower\n * lang-change propagation). Subsequent `getStrings` / `rate` /\n * `suggest` use the new language without rebuilding the client. The\n * server-minted ToS bundle has no `locale` field, so a language flip\n * does NOT invalidate consent — only the next `?language=` query\n * needs updating. The i18n provider plugin (feedback ≥0.2.6)\n * subscribes to `@verbumia/react-i18next` ≥1.0.5's\n * `VerbumiaPluginContext.onLanguageChange` and calls this on every\n * runtime language change so the host never has to wire it manually.\n */\n setLanguage(lang: string): void {\n if (typeof lang !== \"string\" || lang.length === 0) return;\n if (lang === this.cfg.language) return;\n this.cfg = { ...this.cfg, language: lang };\n }\n\n /** ToS version the end user is asked to accept — the SDK's\n * build-time constant (task 616). NOT integrator/server set. */\n get tosVersion(): string {\n return SDK_TOS_VERSION;\n }\n\n /**\n * Accept the ToS and bootstrap a scoped token. Idempotent: a second call\n * returns the in-flight / existing bundle rather than re-accepting.\n */\n async acceptTos(): Promise<TokenBundle> {\n if (this.tokens) return this.tokens;\n if (this.bootstrapping) return this.bootstrapping;\n this.bootstrapping = (async () => {\n const res = await this.fetchImpl(`${this.base()}/v1/feedback/tos`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n // NO grouping_key: server-minted (task 599). It comes back in\n // the token bundle and is bound into the JWT server-side.\n project_id: this.cfg.projectId,\n end_user_id: this.cfg.endUserId,\n tos_version: SDK_TOS_VERSION,\n locale: this.cfg.locale,\n }),\n });\n if (!res.ok) throw await this.problem(res, \"tos acceptance failed\");\n this.tokens = (await res.json()) as TokenBundle;\n return this.tokens;\n })();\n try {\n return await this.bootstrapping;\n } finally {\n this.bootstrapping = null;\n }\n }\n\n private async refresh(): Promise<void> {\n if (!this.tokens) throw new FeedbackError(\"not consented\");\n const res = await this.fetchImpl(\n `${this.base()}/v1/feedback/token/refresh`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ refresh_token: this.tokens.refresh_token }),\n },\n );\n if (!res.ok) {\n this.tokens = null; // force a fresh ToS step\n throw await this.problem(res, \"token refresh failed\");\n }\n this.tokens = (await res.json()) as TokenBundle;\n }\n\n /** Authenticated fetch with a single transparent refresh-on-401 retry.\n * When `cfg.autoAcceptTos === false` (the plugin's `tos: \"skip\"` opt-in\n * / 0.2.7) and no token has been minted yet, throws a `not consented`\n * error instead of silently calling `acceptTos()` — the host promises\n * to handle consent externally via `controller.acceptTos()`. */\n private async authed(\n path: string,\n init: RequestInit,\n retry = true,\n ): Promise<Response> {\n if (!this.tokens) {\n if (this.cfg.autoAcceptTos === false) {\n throw new FeedbackError(\"not consented\");\n }\n await this.acceptTos();\n }\n const res = await this.fetchImpl(`${this.base()}${path}`, {\n ...init,\n headers: {\n ...(init.headers ?? {}),\n Authorization: `Bearer ${this.tokens!.access_token}`,\n },\n });\n if (res.status === 401 && retry) {\n await this.refresh();\n return this.authed(path, init, false);\n }\n return res;\n }\n\n /** Strings rendered on the current view, with this end user's prior rating. */\n async getStrings(opts?: {\n keys?: Array<{ namespace: string; key: string }>;\n namespace?: string;\n limit?: number;\n }): Promise<StringsResponse> {\n // #806 SeedSower P1 (Hermes URLSearchParams polyfill): React Native's\n // bundled URLSearchParams implements ONLY the constructor + toString().\n // `.set` / `.get` / `.append` / `.delete` / `.has` / `.entries` /\n // `.forEach` / `.keys` / `.values` / the iterator all throw on Hermes\n // (documented RN limitation since ~0.50, refused for bundle-size).\n // Build a plain Record<string, string> first, then pass to the\n // constructor — that variant is supported on Node + browser + Hermes\n // + JSC, and produces the same query string. NO mutation after\n // construction anywhere in the SDK.\n const params: Record<string, string> = { language: this.cfg.language };\n if (opts?.keys?.length) {\n params.keys = opts.keys.map((k) => `${k.namespace}:${k.key}`).join(\",\");\n }\n if (opts?.namespace) params.namespace = opts.namespace;\n if (opts?.limit) params.limit = String(opts.limit);\n const qs = new URLSearchParams(params);\n const res = await this.authed(`/v1/feedback/strings?${qs.toString()}`, {\n method: \"GET\",\n });\n if (!res.ok) throw await this.problem(res, \"failed to load strings\");\n return (await res.json()) as StringsResponse;\n }\n\n /** Queue a rating; flushed on debounce or when the batch fills. */\n rate(payload: RatingInput): void {\n this.enqueue({ kind: \"rating\", payload });\n }\n\n /** Queue a suggestion; flushed on debounce or when the batch fills. */\n suggest(payload: SuggestionInput): void {\n this.enqueue({ kind: \"suggestion\", payload });\n }\n\n /**\n * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,\n * deploy `45190c8`). Used by the panel's edit-mode editor when the\n * end-user already has a pending suggestion for a string (the\n * `FeedbackString.my_suggestion.id` from a prior submit). Submits\n * synchronously rather than going through the rating/suggestion\n * batch queue — the host triggered an explicit edit, not a passive\n * rating, so we want the round-trip to surface before the panel\n * closes. Best-effort failures bubble; the caller catches and\n * shows an error row in the panel.\n *\n * Wire body: `{ text: string }` (backend probe confirmed). NOT the\n * legacy `{ suggested_text }` of the batched POST path.\n */\n async editSuggestion(id: string, text: string): Promise<void> {\n if (!id) throw new FeedbackError(\"editSuggestion: id is required\");\n const trimmed = (text ?? \"\").trim();\n if (!trimmed) throw new FeedbackError(\"editSuggestion: text is required\");\n const res = await this.authed(`/v1/feedback/suggestions/${encodeURIComponent(id)}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ text: trimmed }),\n });\n if (!res.ok) throw await this.problem(res, \"failed to update suggestion\");\n }\n\n private enqueue(item: QueueItem): void {\n this.queue.push(item);\n if (this.queue.length >= this.cfg.maxBatch) {\n void this.flush();\n return;\n }\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => void this.flush(), this.cfg.flushDebounceMs);\n }\n\n /**\n * Flush queued items. Best-effort: a transport/auth failure re-queues the\n * batch once and swallows the error so the host app never sees a throw.\n */\n async flush(): Promise<void> {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (!this.queue.length) return;\n const batch = this.queue;\n this.queue = [];\n const ratings = batch\n .filter((b) => b.kind === \"rating\")\n .map((b) => b.payload as RatingInput);\n const suggestions = batch\n .filter((b) => b.kind === \"suggestion\")\n .map((b) => b.payload as SuggestionInput);\n try {\n if (ratings.length) {\n await this.postBatch(\"/v1/feedback/ratings\", { ratings });\n }\n if (suggestions.length) {\n await this.postBatch(\"/v1/feedback/suggestions\", { suggestions });\n }\n } catch {\n // Re-queue once; feedback must never break the host app.\n this.queue.unshift(...batch);\n }\n }\n\n private async postBatch(\n path: string,\n body: unknown,\n ): Promise<BatchResponse> {\n const res = await this.authed(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-SDK\": `${SDK_LIB}@${SDK_VER}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await this.problem(res, \"batch post failed\");\n return (await res.json()) as BatchResponse;\n }\n\n private async problem(res: Response, fallback: string): Promise<FeedbackError> {\n let code: string | undefined;\n let detail = fallback;\n try {\n const body = (await res.json()) as { code?: string; detail?: string };\n code = body.code;\n if (body.detail) detail = body.detail;\n } catch {\n /* non-JSON body */\n }\n return new FeedbackError(detail, res.status, code);\n }\n}\n","/**\n * On-screen key discovery.\n *\n * Preferred source: the `@verbumia/*-i18n` SDK exposes a lightweight key\n * registry of keys it has rendered. When that registry is present on the\n * global (the i18n SDK publishes `globalThis.__verbumia_key_registry__`),\n * we read the keys touched on the current view. Otherwise the host app\n * passes an explicit `keys` list — the always-available fallback.\n *\n * The registry contract is intentionally tiny so any framework port of the\n * i18n SDK can implement it without depending on this package.\n */\n\nimport type { DeclaredKey } from \"./types\";\n\nconst REGISTRY_GLOBAL = \"__verbumia_key_registry__\";\n\ninterface KeyRegistry {\n /** Returns the keys rendered since the last `reset()` (or ever). */\n snapshot(): DeclaredKey[];\n reset?(): void;\n}\n\nfunction getRegistry(): KeyRegistry | null {\n const g = globalThis as Record<string, unknown>;\n const reg = g[REGISTRY_GLOBAL];\n if (\n reg &&\n typeof (reg as KeyRegistry).snapshot === \"function\"\n ) {\n return reg as KeyRegistry;\n }\n return null;\n}\n\n/** True when a compatible `@verbumia/*-i18n` registry is detectable. */\nexport function hasKeyRegistry(): boolean {\n return getRegistry() !== null;\n}\n\n/**\n * Resolve the on-screen keys: explicit `keys` prop always wins (it is the\n * customer's authoritative declaration); otherwise fall back to the i18n\n * registry snapshot; otherwise an empty list (widget shows \"no strings\").\n *\n * Optional `namespace` filter (task 618, CONTRACT v6 — ADDITIVE): when\n * set (a single namespace or a list), the resolved set is narrowed to\n * keys whose `namespace` is in the filter. The filter is applied AFTER\n * resolution, so it composes with v5 rendered-scoping as\n * `rendered ∩ namespace`. UNSET / empty ⇒ unchanged v5 behaviour (all\n * resolved keys). Backward-compatible: `resolveKeys(keys)` is unaffected.\n */\nexport function resolveKeys(\n explicit?: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const base =\n explicit && explicit.length\n ? dedupe(explicit)\n : getRegistry()\n ? dedupe(getRegistry()!.snapshot())\n : [];\n return filterByNamespace(base, namespace);\n}\n\n/** Narrow keys to those whose namespace is in `namespace`. An undefined\n * filter, an empty string, or an empty list means \"no filter\" (the\n * additive default — identical to v5). Exported so non-panel callers\n * (e.g. a custom /core integration) can apply the same semantics. */\nexport function filterByNamespace(\n keys: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const list = (Array.isArray(namespace) ? namespace : namespace ? [namespace] : [])\n .map((n) => n.trim())\n .filter(Boolean);\n if (!list.length) return keys;\n const allow = new Set(list);\n return keys.filter((k) => allow.has(k.namespace));\n}\n\nfunction dedupe(keys: DeclaredKey[]): DeclaredKey[] {\n const seen = new Set<string>();\n const out: DeclaredKey[] = [];\n for (const k of keys) {\n const id = `${k.namespace}:${k.key}`;\n if (!seen.has(id)) {\n seen.add(id);\n out.push(k);\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;AAuKO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,QACA,MACT;AACA,UAAM,OAAO;AAHJ;AACA;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EALW;AAAA,EACA;AAKb;;;ACpKO,IAAM,kBAAkB;;;ACc/B,IAAM,UAAU;AAChB,IAAM,UAAU;AAMT,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAIA;AAAA,EACA,SAA6B;AAAA,EAC7B,QAAqB,CAAC;AAAA,EACtB,QAA8C;AAAA,EAC9C,gBAA6C;AAAA,EAErD,YAAY,QAAwB;AACl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O,KAAK;AACZ,UAAI,KAAK,OAAQ,UAAS,KAAK;AAAA,IACjC,QAAQ;AAAA,IAER;AACA,WAAO,IAAI,cAAc,QAAQ,IAAI,QAAQ,IAAI;AAAA,EACnD;AACF;;;AC/VA,IAAM,kBAAkB;AAQxB,SAAS,cAAkC;AACzC,QAAM,IAAI;AACV,QAAM,MAAM,EAAE,eAAe;AAC7B,MACE,OACA,OAAQ,IAAoB,aAAa,YACzC;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,iBAA0B;AACxC,SAAO,YAAY,MAAM;AAC3B;AAcO,SAAS,YACd,UACA,WACe;AACf,QAAM,OACJ,YAAY,SAAS,SACjB,OAAO,QAAQ,IACf,YAAY,IACV,OAAO,YAAY,EAAG,SAAS,CAAC,IAChC,CAAC;AACT,SAAO,kBAAkB,MAAM,SAAS;AAC1C;AAMO,SAAS,kBACd,MACA,WACe;AACf,QAAM,QAAQ,MAAM,QAAQ,SAAS,IAAI,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,GAC7E,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACjB,MAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO,KAAK,OAAO,CAAC,MAAM,MAAM,IAAI,EAAE,SAAS,CAAC;AAClD;AAEA,SAAS,OAAO,MAAoC;AAClD,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,MAAqB,CAAC;AAC5B,aAAW,KAAK,MAAM;AACpB,UAAM,KAAK,GAAG,EAAE,SAAS,IAAI,EAAE,GAAG;AAClC,QAAI,CAAC,KAAK,IAAI,EAAE,GAAG;AACjB,WAAK,IAAI,EAAE;AACX,UAAI,KAAK,CAAC;AAAA,IACZ;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -72,6 +72,32 @@ interface FeedbackString {
72
72
  avg_stars: number | null;
73
73
  ratings_count: number;
74
74
  my_rating: number | null;
75
+ /**
76
+ * 0.2.8 — backend deploy `45190c8` (task 846) adds source-language
77
+ * fields so the panel can render the source-locale text alongside
78
+ * the target-locale text when the user toggles "Show original".
79
+ *
80
+ * - `source_text`: the source-locale rendering for this key
81
+ * (== `value` whenever `source_locale === language` — the panel
82
+ * uses that equality to hide the source row and avoid
83
+ * duplication on a single-language project).
84
+ * - `source_locale`: BCP-47 of the source.
85
+ * - `my_suggestion`: the end-user's pending suggestion for this
86
+ * key in this language (or `null`). Pre-fills the suggestion
87
+ * editor + flips the submit path from POST → PATCH.
88
+ */
89
+ source_text: string;
90
+ source_locale: string;
91
+ my_suggestion: MySuggestion | null;
92
+ }
93
+ /** 0.2.8 — end-user's pending suggestion for one (key, language).
94
+ * Returned inline on `FeedbackString` so the panel can render an
95
+ * edit-mode editor without a second round-trip. */
96
+ interface MySuggestion {
97
+ /** Suggestion UUID; passed to `PATCH /v1/feedback/suggestions/{id}` to
98
+ * update the text. */
99
+ id: string;
100
+ text: string;
75
101
  }
76
102
  interface StringsResponse {
77
103
  project_id: string;
@@ -230,6 +256,21 @@ declare class FeedbackClient {
230
256
  rate(payload: RatingInput): void;
231
257
  /** Queue a suggestion; flushed on debounce or when the batch fills. */
232
258
  suggest(payload: SuggestionInput): void;
259
+ /**
260
+ * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,
261
+ * deploy `45190c8`). Used by the panel's edit-mode editor when the
262
+ * end-user already has a pending suggestion for a string (the
263
+ * `FeedbackString.my_suggestion.id` from a prior submit). Submits
264
+ * synchronously rather than going through the rating/suggestion
265
+ * batch queue — the host triggered an explicit edit, not a passive
266
+ * rating, so we want the round-trip to surface before the panel
267
+ * closes. Best-effort failures bubble; the caller catches and
268
+ * shows an error row in the panel.
269
+ *
270
+ * Wire body: `{ text: string }` (backend probe confirmed). NOT the
271
+ * legacy `{ suggested_text }` of the batched POST path.
272
+ */
273
+ editSuggestion(id: string, text: string): Promise<void>;
233
274
  private enqueue;
234
275
  /**
235
276
  * Flush queued items. Best-effort: a transport/auth failure re-queues the
@@ -72,6 +72,32 @@ interface FeedbackString {
72
72
  avg_stars: number | null;
73
73
  ratings_count: number;
74
74
  my_rating: number | null;
75
+ /**
76
+ * 0.2.8 — backend deploy `45190c8` (task 846) adds source-language
77
+ * fields so the panel can render the source-locale text alongside
78
+ * the target-locale text when the user toggles "Show original".
79
+ *
80
+ * - `source_text`: the source-locale rendering for this key
81
+ * (== `value` whenever `source_locale === language` — the panel
82
+ * uses that equality to hide the source row and avoid
83
+ * duplication on a single-language project).
84
+ * - `source_locale`: BCP-47 of the source.
85
+ * - `my_suggestion`: the end-user's pending suggestion for this
86
+ * key in this language (or `null`). Pre-fills the suggestion
87
+ * editor + flips the submit path from POST → PATCH.
88
+ */
89
+ source_text: string;
90
+ source_locale: string;
91
+ my_suggestion: MySuggestion | null;
92
+ }
93
+ /** 0.2.8 — end-user's pending suggestion for one (key, language).
94
+ * Returned inline on `FeedbackString` so the panel can render an
95
+ * edit-mode editor without a second round-trip. */
96
+ interface MySuggestion {
97
+ /** Suggestion UUID; passed to `PATCH /v1/feedback/suggestions/{id}` to
98
+ * update the text. */
99
+ id: string;
100
+ text: string;
75
101
  }
76
102
  interface StringsResponse {
77
103
  project_id: string;
@@ -230,6 +256,21 @@ declare class FeedbackClient {
230
256
  rate(payload: RatingInput): void;
231
257
  /** Queue a suggestion; flushed on debounce or when the batch fills. */
232
258
  suggest(payload: SuggestionInput): void;
259
+ /**
260
+ * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,
261
+ * deploy `45190c8`). Used by the panel's edit-mode editor when the
262
+ * end-user already has a pending suggestion for a string (the
263
+ * `FeedbackString.my_suggestion.id` from a prior submit). Submits
264
+ * synchronously rather than going through the rating/suggestion
265
+ * batch queue — the host triggered an explicit edit, not a passive
266
+ * rating, so we want the round-trip to surface before the panel
267
+ * closes. Best-effort failures bubble; the caller catches and
268
+ * shows an error row in the panel.
269
+ *
270
+ * Wire body: `{ text: string }` (backend probe confirmed). NOT the
271
+ * legacy `{ suggested_text }` of the batched POST path.
272
+ */
273
+ editSuggestion(id: string, text: string): Promise<void>;
233
274
  private enqueue;
234
275
  /**
235
276
  * Flush queued items. Best-effort: a transport/auth failure re-queues the
@@ -251,6 +251,31 @@ var FeedbackClient = class {
251
251
  suggest(payload) {
252
252
  this.enqueue({ kind: "suggestion", payload });
253
253
  }
254
+ /**
255
+ * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,
256
+ * deploy `45190c8`). Used by the panel's edit-mode editor when the
257
+ * end-user already has a pending suggestion for a string (the
258
+ * `FeedbackString.my_suggestion.id` from a prior submit). Submits
259
+ * synchronously rather than going through the rating/suggestion
260
+ * batch queue — the host triggered an explicit edit, not a passive
261
+ * rating, so we want the round-trip to surface before the panel
262
+ * closes. Best-effort failures bubble; the caller catches and
263
+ * shows an error row in the panel.
264
+ *
265
+ * Wire body: `{ text: string }` (backend probe confirmed). NOT the
266
+ * legacy `{ suggested_text }` of the batched POST path.
267
+ */
268
+ async editSuggestion(id, text) {
269
+ if (!id) throw new FeedbackError("editSuggestion: id is required");
270
+ const trimmed = (text ?? "").trim();
271
+ if (!trimmed) throw new FeedbackError("editSuggestion: text is required");
272
+ const res = await this.authed(`/v1/feedback/suggestions/${encodeURIComponent(id)}`, {
273
+ method: "PATCH",
274
+ headers: { "Content-Type": "application/json" },
275
+ body: JSON.stringify({ text: trimmed })
276
+ });
277
+ if (!res.ok) throw await this.problem(res, "failed to update suggestion");
278
+ }
254
279
  enqueue(item) {
255
280
  this.queue.push(item);
256
281
  if (this.queue.length >= this.cfg.maxBatch) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/index.ts","../../src/core/types.ts","../../src/core/tos.ts","../../src/core/client.ts","../../src/core/keys.ts"],"sourcesContent":["export { FeedbackClient } from \"./client\";\nexport { SDK_TOS_VERSION } from \"./tos\";\nexport { filterByNamespace, hasKeyRegistry, resolveKeys } from \"./keys\";\nexport {\n type BatchResponse,\n type DeclaredKey,\n type FeedbackConfig,\n FeedbackError,\n type FeedbackString,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\n","/**\n * Wire types for the Verbumia End-User Translation Evaluation API.\n * Canonical reference: ./CONTRACT.md (frozen). Backend task 591.\n */\n\nexport interface FeedbackConfig {\n /** API base, no trailing slash needed. e.g. https://api.verbumia.dev */\n apiBase: string;\n /** Public project UUID the widget targets. */\n projectId: string;\n /**\n * sessionId / grouping_key is MINTED SERVER-SIDE by the Verbumia\n * backend at POST /v1/feedback/tos and returned in the token bundle\n * (`TokenBundle.grouping_key`). The widget receives + sends it; it\n * MUST NOT self-generate it. There is intentionally no client config\n * field for it.\n */\n /**\n * NOTE: there is intentionally NO `tosVersion` field. The ToS version\n * is a BUILD-TIME constant baked into @verbumia/feedback at release\n * (`SDK_TOS_VERSION`, task 616) — integrators do not set it; the SDK\n * sends it automatically.\n */\n /** Optional opaque end-user id; server generates one when absent. */\n endUserId?: string;\n /** BCP-47 language the widget rates strings in (e.g. \"fr\"). */\n language: string;\n /** Optional locale tag stored for analytics. */\n locale?: string;\n /** Debounce window (ms) before a queued batch is flushed. Default 1500. */\n flushDebounceMs?: number;\n /** Max queued items before an immediate flush. Default 20. */\n maxBatch?: number;\n /** Injected fetch (tests / RN polyfills). Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n /**\n * 0.2.7 — host's project API key (`vrb_live_…`, scope `project:read`).\n * When set, the client can call addon-state at setup time (BEFORE\n * the end-user accepts ToS) using `Authorization: ApiKey …` — mirrors\n * the existing scheme used by the i18n SDK's dev-env loaders. When\n * unset, addon-state is deferred until the user's session bearer is\n * minted via `acceptTos()`.\n */\n apiKey?: string;\n /**\n * #806 / 0.2.7 — when `false`, the client must NOT silently call\n * `POST /v1/feedback/tos` to bootstrap a session on the user's behalf.\n * Set by the plugin when the host opts into `tos: \"skip\"` (the host\n * promises to handle consent externally via `controller.acceptTos()`).\n * `authed()` then throws `FeedbackError(\"not consented\")` instead of\n * auto-accepting — the panel surfaces the existing error state.\n * Default `true` preserves all pre-0.2.7 behaviour.\n */\n autoAcceptTos?: boolean;\n}\n\nexport interface TokenBundle {\n access_token: string;\n token_type: \"Bearer\";\n expires_in: number;\n refresh_token: string;\n refresh_expires_in: number;\n end_user_id: string;\n tos_version: string;\n grouping_key: string;\n}\n\nexport interface FeedbackString {\n namespace: string;\n key: string;\n key_uuid: string;\n language_uuid: string;\n value: string;\n translation_hash: string;\n avg_stars: number | null;\n ratings_count: number;\n my_rating: number | null;\n}\n\nexport interface StringsResponse {\n project_id: string;\n language: string;\n strings: FeedbackString[];\n}\n\n/**\n * 0.2.7 — addon state for a project, returned by\n * `GET /v1/projects/{projectId}/feedback-addon/state`. Drives the\n * controller surface (`isActive`, `enabledLanguages`, `sku`,\n * `languagesLimit`) so the host can hide its own CTA on Starter +\n * narrow the widget to enabled languages.\n *\n * Backend contract (camelCase aliases, populate_by_name=true on the\n * server schema, confirmed against backend task 836 SHA d78b939 + the\n * follow-up PR that extends the auth surface to accept project API\n * keys with `project:read` scope):\n * - `isActive`: org.feedback_addon.active\n * - `sku`: the SKU code, or `null` if no active SKU\n * - `enabledLanguages`: the project's allow-list, or literal `\"all\"`\n * when sku === `\"feedback_unlimited\"`; an empty array when no SKU\n * - `languagesLimit`: hard cap for Starter (3), null otherwise\n */\nexport interface FeedbackAddonState {\n isActive: boolean;\n sku: \"feedback_starter\" | \"feedback_unlimited\" | null;\n enabledLanguages: string[] | \"all\";\n languagesLimit: number | null;\n}\n\n/** A 5-star rating queued for a rendered string variant. */\nexport interface RatingInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n stars: number; // 1..5\n}\n\n/** A suggested alternative translation queued for moderation. */\nexport interface SuggestionInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n suggested_text: string;\n comment?: string;\n}\n\nexport interface BatchResponse {\n accepted: number;\n rejected: number;\n items: Array<Record<string, unknown>>;\n}\n\n/** A key the host app declares as on-screen. */\nexport interface DeclaredKey {\n namespace: string;\n key: string;\n}\n\nexport class FeedbackError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly code?: string,\n ) {\n super(message);\n this.name = \"FeedbackError\";\n }\n}\n","/**\n * BUILD-TIME ToS version constant (task 616, human decision option B).\n *\n * This is baked into the @verbumia/feedback PACKAGE at release. It is\n * NOT an integrator-set config field and NOT server-driven: a stale\n * (e.g. native) app must record consent to the ToS version IT shipped\n * and displayed, for legal correctness — never backend-latest.\n *\n * Releasing a ToS-TEXT change ⇒ bump this constant + cut a new\n * @verbumia/feedback release (per the human/real-CI publish handoff).\n * The backend accepts any version in its acceptable set and records it.\n */\nexport const SDK_TOS_VERSION = \"2026-05-18\";\n","/**\n * Framework-agnostic Verbumia feedback client.\n *\n * Responsibilities:\n * - versioned-ToS acceptance -> scoped end-user JWT bootstrap\n * - transparent access-token refresh (rotating refresh token)\n * - fetch on-screen strings for the widget\n * - debounced + size-capped batched POST of ratings / suggestions,\n * mirroring the missing-handler transport contract (ltm 280):\n * best-effort, never throws into the host app render path.\n *\n * The React and React Native entry points are thin UI shells over this.\n */\n\nimport {\n type BatchResponse,\n type FeedbackAddonState,\n type FeedbackConfig,\n FeedbackError,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\nimport { SDK_TOS_VERSION } from \"./tos\";\n\nconst SDK_LIB = \"@verbumia/feedback\";\nconst SDK_VER = \"0.2.0\";\n\ntype QueueItem =\n | { kind: \"rating\"; payload: RatingInput }\n | { kind: \"suggestion\"; payload: SuggestionInput };\n\nexport class FeedbackClient {\n private cfg: Required<\n Pick<FeedbackConfig, \"flushDebounceMs\" | \"maxBatch\">\n > &\n FeedbackConfig;\n private fetchImpl: typeof fetch;\n private tokens: TokenBundle | null = null;\n private queue: QueueItem[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private bootstrapping: Promise<TokenBundle> | null = null;\n\n constructor(config: FeedbackConfig) {\n this.cfg = {\n flushDebounceMs: 1500,\n maxBatch: 20,\n ...config,\n };\n const f = config.fetchImpl ?? globalThis.fetch;\n if (!f) {\n throw new FeedbackError(\n \"no fetch implementation available; pass config.fetchImpl\",\n );\n }\n this.fetchImpl = f.bind(globalThis);\n }\n\n private base(): string {\n return this.cfg.apiBase.replace(/\\/+$/, \"\");\n }\n\n get endUserId(): string | undefined {\n return this.tokens?.end_user_id ?? this.cfg.endUserId;\n }\n\n get hasConsented(): boolean {\n return this.tokens !== null;\n }\n\n /** Alias of `hasConsented` exposed under the 0.2.7 naming used by the\n * `controller.hasAcceptedTos` getter (the SDK's built-in modal and a\n * host's external ToS page share the same persisted token bundle, so\n * both flip this boolean once a session is bootstrapped). */\n get hasAcceptedTos(): boolean {\n return this.tokens !== null;\n }\n\n /** Server-minted sessionId / grouping_key (from the token bundle).\n * Available only after `acceptTos()`; never client-generated. */\n get sessionId(): string | undefined {\n return this.tokens?.grouping_key;\n }\n\n /**\n * 0.2.7 — `GET /v1/projects/{projectId}/feedback-addon/state`.\n *\n * Auth selection (matches backend's dual-acceptance after task 836's\n * follow-up PR — see CONTRACT note in the response type):\n * - If `cfg.apiKey` is set → `Authorization: ApiKey <key>` (so the\n * plugin can fetch state at `setup()` time, before the user has\n * accepted ToS).\n * - Else if a user-session bundle exists → `Authorization: Bearer\n * <access_token>` (the deferred-after-acceptTos path).\n * - Else → throw `FeedbackError(\"addon state requires apiKey or\n * acceptTos\")`. The plugin's setup catches and surfaces a\n * console.warn the first time, then re-attempts on the\n * bundle-mint that follows `acceptTos()`.\n *\n * Best-effort: a transport error returns `null` instead of throwing,\n * so the controller's `isActive` falls back to whatever was last\n * known (or its initial value) without flipping the host's CTA into\n * an inconsistent state on a transient blip.\n */\n async getAddonState(): Promise<FeedbackAddonState | null> {\n let auth: string | undefined;\n if (this.cfg.apiKey) {\n auth = `ApiKey ${this.cfg.apiKey}`;\n } else if (this.tokens) {\n auth = `Bearer ${this.tokens.access_token}`;\n } else {\n throw new FeedbackError(\n \"addon state requires apiKey or acceptTos\",\n );\n }\n const url = `${this.base()}/v1/projects/${this.cfg.projectId}/feedback-addon/state`;\n try {\n const res = await this.fetchImpl(url, {\n method: \"GET\",\n headers: { Authorization: auth },\n });\n if (!res.ok) return null;\n return (await res.json()) as FeedbackAddonState;\n } catch {\n return null;\n }\n }\n\n /** BCP-47 language the widget is rating strings in. */\n get language(): string {\n return this.cfg.language;\n }\n\n /**\n * Re-target the widget's working language at runtime (#806 SeedSower\n * lang-change propagation). Subsequent `getStrings` / `rate` /\n * `suggest` use the new language without rebuilding the client. The\n * server-minted ToS bundle has no `locale` field, so a language flip\n * does NOT invalidate consent — only the next `?language=` query\n * needs updating. The i18n provider plugin (feedback ≥0.2.6)\n * subscribes to `@verbumia/react-i18next` ≥1.0.5's\n * `VerbumiaPluginContext.onLanguageChange` and calls this on every\n * runtime language change so the host never has to wire it manually.\n */\n setLanguage(lang: string): void {\n if (typeof lang !== \"string\" || lang.length === 0) return;\n if (lang === this.cfg.language) return;\n this.cfg = { ...this.cfg, language: lang };\n }\n\n /** ToS version the end user is asked to accept — the SDK's\n * build-time constant (task 616). NOT integrator/server set. */\n get tosVersion(): string {\n return SDK_TOS_VERSION;\n }\n\n /**\n * Accept the ToS and bootstrap a scoped token. Idempotent: a second call\n * returns the in-flight / existing bundle rather than re-accepting.\n */\n async acceptTos(): Promise<TokenBundle> {\n if (this.tokens) return this.tokens;\n if (this.bootstrapping) return this.bootstrapping;\n this.bootstrapping = (async () => {\n const res = await this.fetchImpl(`${this.base()}/v1/feedback/tos`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n // NO grouping_key: server-minted (task 599). It comes back in\n // the token bundle and is bound into the JWT server-side.\n project_id: this.cfg.projectId,\n end_user_id: this.cfg.endUserId,\n tos_version: SDK_TOS_VERSION,\n locale: this.cfg.locale,\n }),\n });\n if (!res.ok) throw await this.problem(res, \"tos acceptance failed\");\n this.tokens = (await res.json()) as TokenBundle;\n return this.tokens;\n })();\n try {\n return await this.bootstrapping;\n } finally {\n this.bootstrapping = null;\n }\n }\n\n private async refresh(): Promise<void> {\n if (!this.tokens) throw new FeedbackError(\"not consented\");\n const res = await this.fetchImpl(\n `${this.base()}/v1/feedback/token/refresh`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ refresh_token: this.tokens.refresh_token }),\n },\n );\n if (!res.ok) {\n this.tokens = null; // force a fresh ToS step\n throw await this.problem(res, \"token refresh failed\");\n }\n this.tokens = (await res.json()) as TokenBundle;\n }\n\n /** Authenticated fetch with a single transparent refresh-on-401 retry.\n * When `cfg.autoAcceptTos === false` (the plugin's `tos: \"skip\"` opt-in\n * / 0.2.7) and no token has been minted yet, throws a `not consented`\n * error instead of silently calling `acceptTos()` — the host promises\n * to handle consent externally via `controller.acceptTos()`. */\n private async authed(\n path: string,\n init: RequestInit,\n retry = true,\n ): Promise<Response> {\n if (!this.tokens) {\n if (this.cfg.autoAcceptTos === false) {\n throw new FeedbackError(\"not consented\");\n }\n await this.acceptTos();\n }\n const res = await this.fetchImpl(`${this.base()}${path}`, {\n ...init,\n headers: {\n ...(init.headers ?? {}),\n Authorization: `Bearer ${this.tokens!.access_token}`,\n },\n });\n if (res.status === 401 && retry) {\n await this.refresh();\n return this.authed(path, init, false);\n }\n return res;\n }\n\n /** Strings rendered on the current view, with this end user's prior rating. */\n async getStrings(opts?: {\n keys?: Array<{ namespace: string; key: string }>;\n namespace?: string;\n limit?: number;\n }): Promise<StringsResponse> {\n // #806 SeedSower P1 (Hermes URLSearchParams polyfill): React Native's\n // bundled URLSearchParams implements ONLY the constructor + toString().\n // `.set` / `.get` / `.append` / `.delete` / `.has` / `.entries` /\n // `.forEach` / `.keys` / `.values` / the iterator all throw on Hermes\n // (documented RN limitation since ~0.50, refused for bundle-size).\n // Build a plain Record<string, string> first, then pass to the\n // constructor — that variant is supported on Node + browser + Hermes\n // + JSC, and produces the same query string. NO mutation after\n // construction anywhere in the SDK.\n const params: Record<string, string> = { language: this.cfg.language };\n if (opts?.keys?.length) {\n params.keys = opts.keys.map((k) => `${k.namespace}:${k.key}`).join(\",\");\n }\n if (opts?.namespace) params.namespace = opts.namespace;\n if (opts?.limit) params.limit = String(opts.limit);\n const qs = new URLSearchParams(params);\n const res = await this.authed(`/v1/feedback/strings?${qs.toString()}`, {\n method: \"GET\",\n });\n if (!res.ok) throw await this.problem(res, \"failed to load strings\");\n return (await res.json()) as StringsResponse;\n }\n\n /** Queue a rating; flushed on debounce or when the batch fills. */\n rate(payload: RatingInput): void {\n this.enqueue({ kind: \"rating\", payload });\n }\n\n /** Queue a suggestion; flushed on debounce or when the batch fills. */\n suggest(payload: SuggestionInput): void {\n this.enqueue({ kind: \"suggestion\", payload });\n }\n\n private enqueue(item: QueueItem): void {\n this.queue.push(item);\n if (this.queue.length >= this.cfg.maxBatch) {\n void this.flush();\n return;\n }\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => void this.flush(), this.cfg.flushDebounceMs);\n }\n\n /**\n * Flush queued items. Best-effort: a transport/auth failure re-queues the\n * batch once and swallows the error so the host app never sees a throw.\n */\n async flush(): Promise<void> {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (!this.queue.length) return;\n const batch = this.queue;\n this.queue = [];\n const ratings = batch\n .filter((b) => b.kind === \"rating\")\n .map((b) => b.payload as RatingInput);\n const suggestions = batch\n .filter((b) => b.kind === \"suggestion\")\n .map((b) => b.payload as SuggestionInput);\n try {\n if (ratings.length) {\n await this.postBatch(\"/v1/feedback/ratings\", { ratings });\n }\n if (suggestions.length) {\n await this.postBatch(\"/v1/feedback/suggestions\", { suggestions });\n }\n } catch {\n // Re-queue once; feedback must never break the host app.\n this.queue.unshift(...batch);\n }\n }\n\n private async postBatch(\n path: string,\n body: unknown,\n ): Promise<BatchResponse> {\n const res = await this.authed(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-SDK\": `${SDK_LIB}@${SDK_VER}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await this.problem(res, \"batch post failed\");\n return (await res.json()) as BatchResponse;\n }\n\n private async problem(res: Response, fallback: string): Promise<FeedbackError> {\n let code: string | undefined;\n let detail = fallback;\n try {\n const body = (await res.json()) as { code?: string; detail?: string };\n code = body.code;\n if (body.detail) detail = body.detail;\n } catch {\n /* non-JSON body */\n }\n return new FeedbackError(detail, res.status, code);\n }\n}\n","/**\n * On-screen key discovery.\n *\n * Preferred source: the `@verbumia/*-i18n` SDK exposes a lightweight key\n * registry of keys it has rendered. When that registry is present on the\n * global (the i18n SDK publishes `globalThis.__verbumia_key_registry__`),\n * we read the keys touched on the current view. Otherwise the host app\n * passes an explicit `keys` list — the always-available fallback.\n *\n * The registry contract is intentionally tiny so any framework port of the\n * i18n SDK can implement it without depending on this package.\n */\n\nimport type { DeclaredKey } from \"./types\";\n\nconst REGISTRY_GLOBAL = \"__verbumia_key_registry__\";\n\ninterface KeyRegistry {\n /** Returns the keys rendered since the last `reset()` (or ever). */\n snapshot(): DeclaredKey[];\n reset?(): void;\n}\n\nfunction getRegistry(): KeyRegistry | null {\n const g = globalThis as Record<string, unknown>;\n const reg = g[REGISTRY_GLOBAL];\n if (\n reg &&\n typeof (reg as KeyRegistry).snapshot === \"function\"\n ) {\n return reg as KeyRegistry;\n }\n return null;\n}\n\n/** True when a compatible `@verbumia/*-i18n` registry is detectable. */\nexport function hasKeyRegistry(): boolean {\n return getRegistry() !== null;\n}\n\n/**\n * Resolve the on-screen keys: explicit `keys` prop always wins (it is the\n * customer's authoritative declaration); otherwise fall back to the i18n\n * registry snapshot; otherwise an empty list (widget shows \"no strings\").\n *\n * Optional `namespace` filter (task 618, CONTRACT v6 — ADDITIVE): when\n * set (a single namespace or a list), the resolved set is narrowed to\n * keys whose `namespace` is in the filter. The filter is applied AFTER\n * resolution, so it composes with v5 rendered-scoping as\n * `rendered ∩ namespace`. UNSET / empty ⇒ unchanged v5 behaviour (all\n * resolved keys). Backward-compatible: `resolveKeys(keys)` is unaffected.\n */\nexport function resolveKeys(\n explicit?: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const base =\n explicit && explicit.length\n ? dedupe(explicit)\n : getRegistry()\n ? dedupe(getRegistry()!.snapshot())\n : [];\n return filterByNamespace(base, namespace);\n}\n\n/** Narrow keys to those whose namespace is in `namespace`. An undefined\n * filter, an empty string, or an empty list means \"no filter\" (the\n * additive default — identical to v5). Exported so non-panel callers\n * (e.g. a custom /core integration) can apply the same semantics. */\nexport function filterByNamespace(\n keys: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const list = (Array.isArray(namespace) ? namespace : namespace ? [namespace] : [])\n .map((n) => n.trim())\n .filter(Boolean);\n if (!list.length) return keys;\n const allow = new Set(list);\n return keys.filter((k) => allow.has(k.namespace));\n}\n\nfunction dedupe(keys: DeclaredKey[]): DeclaredKey[] {\n const seen = new Set<string>();\n const out: DeclaredKey[] = [];\n for (const k of keys) {\n const id = `${k.namespace}:${k.key}`;\n if (!seen.has(id)) {\n seen.add(id);\n out.push(k);\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4IO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,QACA,MACT;AACA,UAAM,OAAO;AAHJ;AACA;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EALW;AAAA,EACA;AAKb;;;ACzIO,IAAM,kBAAkB;;;ACc/B,IAAM,UAAU;AAChB,IAAM,UAAU;AAMT,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAIA;AAAA,EACA,SAA6B;AAAA,EAC7B,QAAqB,CAAC;AAAA,EACtB,QAA8C;AAAA,EAC9C,gBAA6C;AAAA,EAErD,YAAY,QAAwB;AAClC,SAAK,MAAM;AAAA,MACT,iBAAiB;AAAA,MACjB,UA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AAS,IAAI,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,GAC7E,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACjB,MAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO,KAAK,OAAO,CAAC,MAAM,MAAM,IAAI,EAAE,SAAS,CAAC;AAClD;AAEA,SAAS,OAAO,MAAoC;AAClD,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,MAAqB,CAAC;AAC5B,aAAW,KAAK,MAAM;AACpB,UAAM,KAAK,GAAG,EAAE,SAAS,IAAI,EAAE,GAAG;AAClC,QAAI,CAAC,KAAK,IAAI,EAAE,GAAG;AACjB,WAAK,IAAI,EAAE;AACX,UAAI,KAAK,CAAC;AAAA,IACZ;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/core/index.ts","../../src/core/types.ts","../../src/core/tos.ts","../../src/core/client.ts","../../src/core/keys.ts"],"sourcesContent":["export { FeedbackClient } from \"./client\";\nexport { SDK_TOS_VERSION } from \"./tos\";\nexport { filterByNamespace, hasKeyRegistry, resolveKeys } from \"./keys\";\nexport {\n type BatchResponse,\n type DeclaredKey,\n type FeedbackConfig,\n FeedbackError,\n type FeedbackString,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\n","/**\n * Wire types for the Verbumia End-User Translation Evaluation API.\n * Canonical reference: ./CONTRACT.md (frozen). Backend task 591.\n */\n\nexport interface FeedbackConfig {\n /** API base, no trailing slash needed. e.g. https://api.verbumia.dev */\n apiBase: string;\n /** Public project UUID the widget targets. */\n projectId: string;\n /**\n * sessionId / grouping_key is MINTED SERVER-SIDE by the Verbumia\n * backend at POST /v1/feedback/tos and returned in the token bundle\n * (`TokenBundle.grouping_key`). The widget receives + sends it; it\n * MUST NOT self-generate it. There is intentionally no client config\n * field for it.\n */\n /**\n * NOTE: there is intentionally NO `tosVersion` field. The ToS version\n * is a BUILD-TIME constant baked into @verbumia/feedback at release\n * (`SDK_TOS_VERSION`, task 616) — integrators do not set it; the SDK\n * sends it automatically.\n */\n /** Optional opaque end-user id; server generates one when absent. */\n endUserId?: string;\n /** BCP-47 language the widget rates strings in (e.g. \"fr\"). */\n language: string;\n /** Optional locale tag stored for analytics. */\n locale?: string;\n /** Debounce window (ms) before a queued batch is flushed. Default 1500. */\n flushDebounceMs?: number;\n /** Max queued items before an immediate flush. Default 20. */\n maxBatch?: number;\n /** Injected fetch (tests / RN polyfills). Defaults to global fetch. */\n fetchImpl?: typeof fetch;\n /**\n * 0.2.7 — host's project API key (`vrb_live_…`, scope `project:read`).\n * When set, the client can call addon-state at setup time (BEFORE\n * the end-user accepts ToS) using `Authorization: ApiKey …` — mirrors\n * the existing scheme used by the i18n SDK's dev-env loaders. When\n * unset, addon-state is deferred until the user's session bearer is\n * minted via `acceptTos()`.\n */\n apiKey?: string;\n /**\n * #806 / 0.2.7 — when `false`, the client must NOT silently call\n * `POST /v1/feedback/tos` to bootstrap a session on the user's behalf.\n * Set by the plugin when the host opts into `tos: \"skip\"` (the host\n * promises to handle consent externally via `controller.acceptTos()`).\n * `authed()` then throws `FeedbackError(\"not consented\")` instead of\n * auto-accepting — the panel surfaces the existing error state.\n * Default `true` preserves all pre-0.2.7 behaviour.\n */\n autoAcceptTos?: boolean;\n}\n\nexport interface TokenBundle {\n access_token: string;\n token_type: \"Bearer\";\n expires_in: number;\n refresh_token: string;\n refresh_expires_in: number;\n end_user_id: string;\n tos_version: string;\n grouping_key: string;\n}\n\nexport interface FeedbackString {\n namespace: string;\n key: string;\n key_uuid: string;\n language_uuid: string;\n value: string;\n translation_hash: string;\n avg_stars: number | null;\n ratings_count: number;\n my_rating: number | null;\n /**\n * 0.2.8 — backend deploy `45190c8` (task 846) adds source-language\n * fields so the panel can render the source-locale text alongside\n * the target-locale text when the user toggles \"Show original\".\n *\n * - `source_text`: the source-locale rendering for this key\n * (== `value` whenever `source_locale === language` — the panel\n * uses that equality to hide the source row and avoid\n * duplication on a single-language project).\n * - `source_locale`: BCP-47 of the source.\n * - `my_suggestion`: the end-user's pending suggestion for this\n * key in this language (or `null`). Pre-fills the suggestion\n * editor + flips the submit path from POST → PATCH.\n */\n source_text: string;\n source_locale: string;\n my_suggestion: MySuggestion | null;\n}\n\n/** 0.2.8 — end-user's pending suggestion for one (key, language).\n * Returned inline on `FeedbackString` so the panel can render an\n * edit-mode editor without a second round-trip. */\nexport interface MySuggestion {\n /** Suggestion UUID; passed to `PATCH /v1/feedback/suggestions/{id}` to\n * update the text. */\n id: string;\n text: string;\n}\n\nexport interface StringsResponse {\n project_id: string;\n language: string;\n strings: FeedbackString[];\n}\n\n/**\n * 0.2.7 — addon state for a project, returned by\n * `GET /v1/projects/{projectId}/feedback-addon/state`. Drives the\n * controller surface (`isActive`, `enabledLanguages`, `sku`,\n * `languagesLimit`) so the host can hide its own CTA on Starter +\n * narrow the widget to enabled languages.\n *\n * Backend contract (camelCase aliases, populate_by_name=true on the\n * server schema, confirmed against backend task 836 SHA d78b939 + the\n * follow-up PR that extends the auth surface to accept project API\n * keys with `project:read` scope):\n * - `isActive`: org.feedback_addon.active\n * - `sku`: the SKU code, or `null` if no active SKU\n * - `enabledLanguages`: the project's allow-list, or literal `\"all\"`\n * when sku === `\"feedback_unlimited\"`; an empty array when no SKU\n * - `languagesLimit`: hard cap for Starter (3), null otherwise\n */\nexport interface FeedbackAddonState {\n isActive: boolean;\n sku: \"feedback_starter\" | \"feedback_unlimited\" | null;\n enabledLanguages: string[] | \"all\";\n languagesLimit: number | null;\n}\n\n/** A 5-star rating queued for a rendered string variant. */\nexport interface RatingInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n stars: number; // 1..5\n}\n\n/** A suggested alternative translation queued for moderation. */\nexport interface SuggestionInput {\n namespace: string;\n key: string;\n language: string;\n translation_hash: string;\n suggested_text: string;\n comment?: string;\n}\n\nexport interface BatchResponse {\n accepted: number;\n rejected: number;\n items: Array<Record<string, unknown>>;\n}\n\n/** A key the host app declares as on-screen. */\nexport interface DeclaredKey {\n namespace: string;\n key: string;\n}\n\nexport class FeedbackError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly code?: string,\n ) {\n super(message);\n this.name = \"FeedbackError\";\n }\n}\n","/**\n * BUILD-TIME ToS version constant (task 616, human decision option B).\n *\n * This is baked into the @verbumia/feedback PACKAGE at release. It is\n * NOT an integrator-set config field and NOT server-driven: a stale\n * (e.g. native) app must record consent to the ToS version IT shipped\n * and displayed, for legal correctness — never backend-latest.\n *\n * Releasing a ToS-TEXT change ⇒ bump this constant + cut a new\n * @verbumia/feedback release (per the human/real-CI publish handoff).\n * The backend accepts any version in its acceptable set and records it.\n */\nexport const SDK_TOS_VERSION = \"2026-05-18\";\n","/**\n * Framework-agnostic Verbumia feedback client.\n *\n * Responsibilities:\n * - versioned-ToS acceptance -> scoped end-user JWT bootstrap\n * - transparent access-token refresh (rotating refresh token)\n * - fetch on-screen strings for the widget\n * - debounced + size-capped batched POST of ratings / suggestions,\n * mirroring the missing-handler transport contract (ltm 280):\n * best-effort, never throws into the host app render path.\n *\n * The React and React Native entry points are thin UI shells over this.\n */\n\nimport {\n type BatchResponse,\n type FeedbackAddonState,\n type FeedbackConfig,\n FeedbackError,\n type RatingInput,\n type StringsResponse,\n type SuggestionInput,\n type TokenBundle,\n} from \"./types\";\nimport { SDK_TOS_VERSION } from \"./tos\";\n\nconst SDK_LIB = \"@verbumia/feedback\";\nconst SDK_VER = \"0.2.0\";\n\ntype QueueItem =\n | { kind: \"rating\"; payload: RatingInput }\n | { kind: \"suggestion\"; payload: SuggestionInput };\n\nexport class FeedbackClient {\n private cfg: Required<\n Pick<FeedbackConfig, \"flushDebounceMs\" | \"maxBatch\">\n > &\n FeedbackConfig;\n private fetchImpl: typeof fetch;\n private tokens: TokenBundle | null = null;\n private queue: QueueItem[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private bootstrapping: Promise<TokenBundle> | null = null;\n\n constructor(config: FeedbackConfig) {\n this.cfg = {\n flushDebounceMs: 1500,\n maxBatch: 20,\n ...config,\n };\n const f = config.fetchImpl ?? globalThis.fetch;\n if (!f) {\n throw new FeedbackError(\n \"no fetch implementation available; pass config.fetchImpl\",\n );\n }\n this.fetchImpl = f.bind(globalThis);\n }\n\n private base(): string {\n return this.cfg.apiBase.replace(/\\/+$/, \"\");\n }\n\n get endUserId(): string | undefined {\n return this.tokens?.end_user_id ?? this.cfg.endUserId;\n }\n\n get hasConsented(): boolean {\n return this.tokens !== null;\n }\n\n /** Alias of `hasConsented` exposed under the 0.2.7 naming used by the\n * `controller.hasAcceptedTos` getter (the SDK's built-in modal and a\n * host's external ToS page share the same persisted token bundle, so\n * both flip this boolean once a session is bootstrapped). */\n get hasAcceptedTos(): boolean {\n return this.tokens !== null;\n }\n\n /** Server-minted sessionId / grouping_key (from the token bundle).\n * Available only after `acceptTos()`; never client-generated. */\n get sessionId(): string | undefined {\n return this.tokens?.grouping_key;\n }\n\n /**\n * 0.2.7 — `GET /v1/projects/{projectId}/feedback-addon/state`.\n *\n * Auth selection (matches backend's dual-acceptance after task 836's\n * follow-up PR — see CONTRACT note in the response type):\n * - If `cfg.apiKey` is set → `Authorization: ApiKey <key>` (so the\n * plugin can fetch state at `setup()` time, before the user has\n * accepted ToS).\n * - Else if a user-session bundle exists → `Authorization: Bearer\n * <access_token>` (the deferred-after-acceptTos path).\n * - Else → throw `FeedbackError(\"addon state requires apiKey or\n * acceptTos\")`. The plugin's setup catches and surfaces a\n * console.warn the first time, then re-attempts on the\n * bundle-mint that follows `acceptTos()`.\n *\n * Best-effort: a transport error returns `null` instead of throwing,\n * so the controller's `isActive` falls back to whatever was last\n * known (or its initial value) without flipping the host's CTA into\n * an inconsistent state on a transient blip.\n */\n async getAddonState(): Promise<FeedbackAddonState | null> {\n let auth: string | undefined;\n if (this.cfg.apiKey) {\n auth = `ApiKey ${this.cfg.apiKey}`;\n } else if (this.tokens) {\n auth = `Bearer ${this.tokens.access_token}`;\n } else {\n throw new FeedbackError(\n \"addon state requires apiKey or acceptTos\",\n );\n }\n const url = `${this.base()}/v1/projects/${this.cfg.projectId}/feedback-addon/state`;\n try {\n const res = await this.fetchImpl(url, {\n method: \"GET\",\n headers: { Authorization: auth },\n });\n if (!res.ok) return null;\n return (await res.json()) as FeedbackAddonState;\n } catch {\n return null;\n }\n }\n\n /** BCP-47 language the widget is rating strings in. */\n get language(): string {\n return this.cfg.language;\n }\n\n /**\n * Re-target the widget's working language at runtime (#806 SeedSower\n * lang-change propagation). Subsequent `getStrings` / `rate` /\n * `suggest` use the new language without rebuilding the client. The\n * server-minted ToS bundle has no `locale` field, so a language flip\n * does NOT invalidate consent — only the next `?language=` query\n * needs updating. The i18n provider plugin (feedback ≥0.2.6)\n * subscribes to `@verbumia/react-i18next` ≥1.0.5's\n * `VerbumiaPluginContext.onLanguageChange` and calls this on every\n * runtime language change so the host never has to wire it manually.\n */\n setLanguage(lang: string): void {\n if (typeof lang !== \"string\" || lang.length === 0) return;\n if (lang === this.cfg.language) return;\n this.cfg = { ...this.cfg, language: lang };\n }\n\n /** ToS version the end user is asked to accept — the SDK's\n * build-time constant (task 616). NOT integrator/server set. */\n get tosVersion(): string {\n return SDK_TOS_VERSION;\n }\n\n /**\n * Accept the ToS and bootstrap a scoped token. Idempotent: a second call\n * returns the in-flight / existing bundle rather than re-accepting.\n */\n async acceptTos(): Promise<TokenBundle> {\n if (this.tokens) return this.tokens;\n if (this.bootstrapping) return this.bootstrapping;\n this.bootstrapping = (async () => {\n const res = await this.fetchImpl(`${this.base()}/v1/feedback/tos`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n // NO grouping_key: server-minted (task 599). It comes back in\n // the token bundle and is bound into the JWT server-side.\n project_id: this.cfg.projectId,\n end_user_id: this.cfg.endUserId,\n tos_version: SDK_TOS_VERSION,\n locale: this.cfg.locale,\n }),\n });\n if (!res.ok) throw await this.problem(res, \"tos acceptance failed\");\n this.tokens = (await res.json()) as TokenBundle;\n return this.tokens;\n })();\n try {\n return await this.bootstrapping;\n } finally {\n this.bootstrapping = null;\n }\n }\n\n private async refresh(): Promise<void> {\n if (!this.tokens) throw new FeedbackError(\"not consented\");\n const res = await this.fetchImpl(\n `${this.base()}/v1/feedback/token/refresh`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ refresh_token: this.tokens.refresh_token }),\n },\n );\n if (!res.ok) {\n this.tokens = null; // force a fresh ToS step\n throw await this.problem(res, \"token refresh failed\");\n }\n this.tokens = (await res.json()) as TokenBundle;\n }\n\n /** Authenticated fetch with a single transparent refresh-on-401 retry.\n * When `cfg.autoAcceptTos === false` (the plugin's `tos: \"skip\"` opt-in\n * / 0.2.7) and no token has been minted yet, throws a `not consented`\n * error instead of silently calling `acceptTos()` — the host promises\n * to handle consent externally via `controller.acceptTos()`. */\n private async authed(\n path: string,\n init: RequestInit,\n retry = true,\n ): Promise<Response> {\n if (!this.tokens) {\n if (this.cfg.autoAcceptTos === false) {\n throw new FeedbackError(\"not consented\");\n }\n await this.acceptTos();\n }\n const res = await this.fetchImpl(`${this.base()}${path}`, {\n ...init,\n headers: {\n ...(init.headers ?? {}),\n Authorization: `Bearer ${this.tokens!.access_token}`,\n },\n });\n if (res.status === 401 && retry) {\n await this.refresh();\n return this.authed(path, init, false);\n }\n return res;\n }\n\n /** Strings rendered on the current view, with this end user's prior rating. */\n async getStrings(opts?: {\n keys?: Array<{ namespace: string; key: string }>;\n namespace?: string;\n limit?: number;\n }): Promise<StringsResponse> {\n // #806 SeedSower P1 (Hermes URLSearchParams polyfill): React Native's\n // bundled URLSearchParams implements ONLY the constructor + toString().\n // `.set` / `.get` / `.append` / `.delete` / `.has` / `.entries` /\n // `.forEach` / `.keys` / `.values` / the iterator all throw on Hermes\n // (documented RN limitation since ~0.50, refused for bundle-size).\n // Build a plain Record<string, string> first, then pass to the\n // constructor — that variant is supported on Node + browser + Hermes\n // + JSC, and produces the same query string. NO mutation after\n // construction anywhere in the SDK.\n const params: Record<string, string> = { language: this.cfg.language };\n if (opts?.keys?.length) {\n params.keys = opts.keys.map((k) => `${k.namespace}:${k.key}`).join(\",\");\n }\n if (opts?.namespace) params.namespace = opts.namespace;\n if (opts?.limit) params.limit = String(opts.limit);\n const qs = new URLSearchParams(params);\n const res = await this.authed(`/v1/feedback/strings?${qs.toString()}`, {\n method: \"GET\",\n });\n if (!res.ok) throw await this.problem(res, \"failed to load strings\");\n return (await res.json()) as StringsResponse;\n }\n\n /** Queue a rating; flushed on debounce or when the batch fills. */\n rate(payload: RatingInput): void {\n this.enqueue({ kind: \"rating\", payload });\n }\n\n /** Queue a suggestion; flushed on debounce or when the batch fills. */\n suggest(payload: SuggestionInput): void {\n this.enqueue({ kind: \"suggestion\", payload });\n }\n\n /**\n * 0.2.8 — `PATCH /v1/feedback/suggestions/{id}` (backend task 847,\n * deploy `45190c8`). Used by the panel's edit-mode editor when the\n * end-user already has a pending suggestion for a string (the\n * `FeedbackString.my_suggestion.id` from a prior submit). Submits\n * synchronously rather than going through the rating/suggestion\n * batch queue — the host triggered an explicit edit, not a passive\n * rating, so we want the round-trip to surface before the panel\n * closes. Best-effort failures bubble; the caller catches and\n * shows an error row in the panel.\n *\n * Wire body: `{ text: string }` (backend probe confirmed). NOT the\n * legacy `{ suggested_text }` of the batched POST path.\n */\n async editSuggestion(id: string, text: string): Promise<void> {\n if (!id) throw new FeedbackError(\"editSuggestion: id is required\");\n const trimmed = (text ?? \"\").trim();\n if (!trimmed) throw new FeedbackError(\"editSuggestion: text is required\");\n const res = await this.authed(`/v1/feedback/suggestions/${encodeURIComponent(id)}`, {\n method: \"PATCH\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ text: trimmed }),\n });\n if (!res.ok) throw await this.problem(res, \"failed to update suggestion\");\n }\n\n private enqueue(item: QueueItem): void {\n this.queue.push(item);\n if (this.queue.length >= this.cfg.maxBatch) {\n void this.flush();\n return;\n }\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => void this.flush(), this.cfg.flushDebounceMs);\n }\n\n /**\n * Flush queued items. Best-effort: a transport/auth failure re-queues the\n * batch once and swallows the error so the host app never sees a throw.\n */\n async flush(): Promise<void> {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (!this.queue.length) return;\n const batch = this.queue;\n this.queue = [];\n const ratings = batch\n .filter((b) => b.kind === \"rating\")\n .map((b) => b.payload as RatingInput);\n const suggestions = batch\n .filter((b) => b.kind === \"suggestion\")\n .map((b) => b.payload as SuggestionInput);\n try {\n if (ratings.length) {\n await this.postBatch(\"/v1/feedback/ratings\", { ratings });\n }\n if (suggestions.length) {\n await this.postBatch(\"/v1/feedback/suggestions\", { suggestions });\n }\n } catch {\n // Re-queue once; feedback must never break the host app.\n this.queue.unshift(...batch);\n }\n }\n\n private async postBatch(\n path: string,\n body: unknown,\n ): Promise<BatchResponse> {\n const res = await this.authed(path, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-SDK\": `${SDK_LIB}@${SDK_VER}` },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw await this.problem(res, \"batch post failed\");\n return (await res.json()) as BatchResponse;\n }\n\n private async problem(res: Response, fallback: string): Promise<FeedbackError> {\n let code: string | undefined;\n let detail = fallback;\n try {\n const body = (await res.json()) as { code?: string; detail?: string };\n code = body.code;\n if (body.detail) detail = body.detail;\n } catch {\n /* non-JSON body */\n }\n return new FeedbackError(detail, res.status, code);\n }\n}\n","/**\n * On-screen key discovery.\n *\n * Preferred source: the `@verbumia/*-i18n` SDK exposes a lightweight key\n * registry of keys it has rendered. When that registry is present on the\n * global (the i18n SDK publishes `globalThis.__verbumia_key_registry__`),\n * we read the keys touched on the current view. Otherwise the host app\n * passes an explicit `keys` list — the always-available fallback.\n *\n * The registry contract is intentionally tiny so any framework port of the\n * i18n SDK can implement it without depending on this package.\n */\n\nimport type { DeclaredKey } from \"./types\";\n\nconst REGISTRY_GLOBAL = \"__verbumia_key_registry__\";\n\ninterface KeyRegistry {\n /** Returns the keys rendered since the last `reset()` (or ever). */\n snapshot(): DeclaredKey[];\n reset?(): void;\n}\n\nfunction getRegistry(): KeyRegistry | null {\n const g = globalThis as Record<string, unknown>;\n const reg = g[REGISTRY_GLOBAL];\n if (\n reg &&\n typeof (reg as KeyRegistry).snapshot === \"function\"\n ) {\n return reg as KeyRegistry;\n }\n return null;\n}\n\n/** True when a compatible `@verbumia/*-i18n` registry is detectable. */\nexport function hasKeyRegistry(): boolean {\n return getRegistry() !== null;\n}\n\n/**\n * Resolve the on-screen keys: explicit `keys` prop always wins (it is the\n * customer's authoritative declaration); otherwise fall back to the i18n\n * registry snapshot; otherwise an empty list (widget shows \"no strings\").\n *\n * Optional `namespace` filter (task 618, CONTRACT v6 — ADDITIVE): when\n * set (a single namespace or a list), the resolved set is narrowed to\n * keys whose `namespace` is in the filter. The filter is applied AFTER\n * resolution, so it composes with v5 rendered-scoping as\n * `rendered ∩ namespace`. UNSET / empty ⇒ unchanged v5 behaviour (all\n * resolved keys). Backward-compatible: `resolveKeys(keys)` is unaffected.\n */\nexport function resolveKeys(\n explicit?: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const base =\n explicit && explicit.length\n ? dedupe(explicit)\n : getRegistry()\n ? dedupe(getRegistry()!.snapshot())\n : [];\n return filterByNamespace(base, namespace);\n}\n\n/** Narrow keys to those whose namespace is in `namespace`. An undefined\n * filter, an empty string, or an empty list means \"no filter\" (the\n * additive default — identical to v5). Exported so non-panel callers\n * (e.g. a custom /core integration) can apply the same semantics. */\nexport function filterByNamespace(\n keys: DeclaredKey[],\n namespace?: string | string[],\n): DeclaredKey[] {\n const list = (Array.isArray(namespace) ? namespace : namespace ? [namespace] : [])\n .map((n) => n.trim())\n .filter(Boolean);\n if (!list.length) return keys;\n const allow = new Set(list);\n return keys.filter((k) => allow.has(k.namespace));\n}\n\nfunction dedupe(keys: DeclaredKey[]): DeclaredKey[] {\n const seen = new Set<string>();\n const out: DeclaredKey[] = [];\n for (const k of keys) {\n const id = `${k.namespace}:${k.key}`;\n if (!seen.has(id)) {\n seen.add(id);\n out.push(k);\n }\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACuKO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACS,QACA,MACT;AACA,UAAM,OAAO;AAHJ;AACA;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EALW;AAAA,EACA;AAKb;;;ACpKO,IAAM,kBAAkB;;;ACc/B,IAAM,UAAU;AAChB,IAAM,UAAU;AAMT,IAAM,iBAAN,MAAqB;AAAA,EAClB;AAAA,EAIA;AAAA,EACA,SAA6B;AAAA,EAC7B,QAAqB,CAAC;AAAA,EACtB,QAA8C;AAAA,EAC9C,gBAA6C;AAAA,EAErD,YAAY,QAAwB;AAClC,SAAK,MAAM;AAAA,MACT,iBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,GAAG;AAAA,IACL;AACA,UAAM,IAAI,OAAO,aAAa,WAAW;AACzC,QAAI,CAAC,GAAG;AACN,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,SAAK,YAAY,EAAE,KAAK,UAAU;AAAA,EACpC;AAAA,EAEQ,OAAe;AACrB,WAAO,KAAK,IAAI,QAAQ,QAAQ,QAAQ,EAAE;AAAA,EAC5C;AAAA,EAEA,IAAI,YAAgC;AAClC,WAAO,KAAK,QAAQ,eAAe,KAAK,IAAI;AAAA,EAC9C;AAAA,EAEA,IAAI,eAAwB;AAC1B,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAA0B;AAC5B,WAAO,KAAK,WAAW;AAAA,EACzB;AAAA;AAAA;AAAA,EAIA,IAAI,YAAg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M,QAAQ,SAAS,IAAI,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,GAC7E,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACjB,MAAI,CAAC,KAAK,OAAQ,QAAO;AACzB,QAAM,QAAQ,IAAI,IAAI,IAAI;AAC1B,SAAO,KAAK,OAAO,CAAC,MAAM,MAAM,IAAI,EAAE,SAAS,CAAC;AAClD;AAEA,SAAS,OAAO,MAAoC;AAClD,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,MAAqB,CAAC;AAC5B,aAAW,KAAK,MAAM;AACpB,UAAM,KAAK,GAAG,EAAE,SAAS,IAAI,EAAE,GAAG;AAClC,QAAI,CAAC,KAAK,IAAI,EAAE,GAAG;AACjB,WAAK,IAAI,EAAE;AACX,UAAI,KAAK,CAAC;AAAA,IACZ;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,5 +1,5 @@
1
- export { B as BatchResponse, D as DeclaredKey, F as FeedbackClient, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-D83qhH0O.cjs';
2
- export { f as filterByNamespace, h as hasKeyRegistry, r as resolveKeys } from '../keys-D4oJtn64.cjs';
1
+ export { B as BatchResponse, D as DeclaredKey, F as FeedbackClient, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-CnEK_2SD.cjs';
2
+ export { f as filterByNamespace, h as hasKeyRegistry, r as resolveKeys } from '../keys-2_T5bDpX.cjs';
3
3
 
4
4
  /**
5
5
  * BUILD-TIME ToS version constant (task 616, human decision option B).
@@ -1,5 +1,5 @@
1
- export { B as BatchResponse, D as DeclaredKey, F as FeedbackClient, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-D83qhH0O.js';
2
- export { f as filterByNamespace, h as hasKeyRegistry, r as resolveKeys } from '../keys-BpVB1kcI.js';
1
+ export { B as BatchResponse, D as DeclaredKey, F as FeedbackClient, a as FeedbackConfig, b as FeedbackError, c as FeedbackString, R as RatingInput, S as StringsResponse, d as SuggestionInput, T as TokenBundle } from '../client-CnEK_2SD.js';
2
+ export { f as filterByNamespace, h as hasKeyRegistry, r as resolveKeys } from '../keys-eHc_lx5v.js';
3
3
 
4
4
  /**
5
5
  * BUILD-TIME ToS version constant (task 616, human decision option B).
@@ -6,7 +6,7 @@ import {
6
6
  filterByNamespace,
7
7
  hasKeyRegistry,
8
8
  resolveKeys
9
- } from "../chunk-7KWEI55W.js";
9
+ } from "../chunk-EMGN6MR4.js";
10
10
  export {
11
11
  FeedbackClient,
12
12
  FeedbackError,
@@ -1,4 +1,4 @@
1
- import { D as DeclaredKey } from './client-D83qhH0O.cjs';
1
+ import { D as DeclaredKey } from './client-CnEK_2SD.cjs';
2
2
 
3
3
  /**
4
4
  * On-screen key discovery.
@@ -1,4 +1,4 @@
1
- import { D as DeclaredKey } from './client-D83qhH0O.js';
1
+ import { D as DeclaredKey } from './client-CnEK_2SD.js';
2
2
 
3
3
  /**
4
4
  * On-screen key discovery.