@wral/report-it 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,6 +36,7 @@ Keep this first in the host page's `<head>`:
36
36
  | --- | --- | --- | --- |
37
37
  | `api` | attribute | `https://api.wral.com/forms` | api-forms base URL (dev: `https://api.wral.com/dev/forms`) |
38
38
  | `client` | property | — | Full I/O surface override (API + auth); wins over `api`. See `src/demo/demo-client.mjs` for the shape |
39
+ | `flow` | attribute | — | Open one form directly by its `formId` (e.g. `investigates`). The host page's `?flow=<formId>` does the same; the attribute wins |
39
40
 
40
41
  Styling hooks: design tokens are read as `var(--wral-…, fallback)` with
41
42
  prototype-accurate fallbacks, so the component renders correctly with no
@@ -44,7 +45,8 @@ column width (default 680px).
44
45
 
45
46
  ## How a submission flows
46
47
 
47
- 1. `GET {api}/v1/forms` (public) — one button per published form.
48
+ 1. `GET {api}/v1/forms` (public) — one button per published form
49
+ (forms with `listed: false` are served but not shown; see below).
48
50
  2. The chosen form's tree walks client-side: `choice` chips, `collect`
49
51
  cards (text/textarea/url/datetime/location/media/consent/select),
50
52
  the `gate` (My WRAL email + one-time code — skipped with a
@@ -56,6 +58,44 @@ column width (default 680px).
56
58
  `PUT /v1/requests/{requestId}` (idempotent — retries return the same
57
59
  reference) → confirmation + behind-the-scenes journey.
58
60
 
61
+ ### Hand-offs, unlisted forms and deep links (DEV-1305)
62
+
63
+ A choice option may carry `form` (and optionally `path`) instead of
64
+ `next`: choosing it switches to that form document and replays the
65
+ `path` choice steps there first. News → "5 On Your Side" lands on the
66
+ consumer form's complaint card, past its own "5 On Your Side or
67
+ Investigates?" question. The submission is made against the target
68
+ form, with the preset steps at the head of its `path`; a path through
69
+ a hand-off option itself is never sent (the API rejects one).
70
+
71
+ The form the viewer came from is kept as an origin (`src/lib/handoff.mjs`),
72
+ persisted with the draft: the transcript reads as one conversation, a
73
+ reload rebuilds it, and **Back** from the first card after a hand-off
74
+ returns to the choice that made it, skipping the preset steps. A
75
+ hand-off to a form that is not loaded shows the load-error notice and
76
+ stays put.
77
+
78
+ An unlisted form (`listed: false`, e.g. `investigates`) is fetched with
79
+ the rest and reachable by hand-off or deep link, just not offered on the
80
+ entry screen. `?flow=<formId>` on the host page (or the `flow`
81
+ attribute) opens a form directly; a draft for that form (or one handed
82
+ off to or from it) resumes instead, and a draft for any other form
83
+ yields to the link.
84
+
85
+ ### Fields
86
+
87
+ - `text` fields pass `inputMode` and `autocomplete` from the form
88
+ document through to the input, and each collect card is a real
89
+ `<form autocomplete="on">`, so the browser can fill name, phone,
90
+ address and zip from the viewer's saved details. Nothing is prefilled
91
+ from My WRAL or stored anywhere else. (Autofill inside shadow DOM
92
+ varies by browser — verify on iOS Safari and Android Chrome.)
93
+ - A `text` field's `pattern` is checked before submit the way the
94
+ server checks it (a zip gets its own message).
95
+ - `consent` copy comes from the field's `text`. With
96
+ `requiredIf: "media"` the checkbox appears only once a file is
97
+ attached, is required only then, and is not sent without files.
98
+
59
99
  ### Skipping the account (DEV-1270)
60
100
 
61
101
  The sign-in card files its alternatives under a collapsed **"Other ways
@@ -92,7 +132,11 @@ in place instead of opening the sign-in card.
92
132
 
93
133
  Auth uses `@wral/sdk-auth-audience` directly (`sendCode`/`verifyCode`);
94
134
  `requireAuth`/`authFetch` are deliberately avoided — their 401 paths
95
- redirect to `/login/`, which would destroy an unsubmitted form. A 401
135
+ redirect to `/login/`, which would destroy an unsubmitted form. The
136
+ bearer on uploads and submit is the viewer's Cognito **ID token** (not
137
+ the access token the SDK's `getAuthHeaders` sends): same `sub`, but it
138
+ also carries the verified `email`, which api-forms writes onto the
139
+ record beside the account id (`src/lib/id-token.mjs`). A 401
96
140
  mid-submit re-opens the gate in place and resumes where it parked.
97
141
 
98
142
  ## Drafts
@@ -115,7 +159,10 @@ npm run dev # vite harness at http://localhost:5173
115
159
 
116
160
  The harness runs against the live dev API by default (real My WRAL
117
161
  login — your email receives a real code) or fully offline with the
118
- in-memory demo client (any email, any six digits). Append
162
+ in-memory demo client (any email, any six digits). The demo client
163
+ serves the form documents in `src/demo/fixtures/` (copies of api-forms'
164
+ seeds), so hand-offs, `?flow=investigates` and the files-only consent
165
+ all work offline. Append
119
166
  `?demofail=1` to make the second upload fail once and exercise the
120
167
  retry UX. The **Anonymous route** checkbox (demo mode only, also
121
168
  settable with `?anon=1`) makes the demo client advertise anonymous
package/dist/define.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as n from "amazon-cognito-identity-js";
2
- import { W as i, a as r, b as a } from "./wral-code-input-DCemMj53.js";
2
+ import { W as i, a as r, b as a } from "./wral-code-input-BZTBgLk3.js";
3
3
  typeof window < "u" && !window.AmazonCognitoIdentity && (window.AmazonCognitoIdentity = n);
4
4
  const d = {
5
5
  "wral-report-it": a,