@wral/report-it 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
+ | `facts-api` | attribute | — | api-user-facts v1 base (e.g. `https://api.wral.com/user-facts/v1`). Unset, a new account is never offered to save its details |
39
40
  | `flow` | attribute | — | Open one form directly by its `formId` (e.g. `investigates`). The host page's `?flow=<formId>` does the same; the attribute wins |
40
41
 
41
42
  Styling hooks: design tokens are read as `var(--wral-…, fallback)` with
@@ -56,7 +57,7 @@ column width (default 680px).
56
57
  `POST /v1/uploads` (Bearer) → presigned S3 PUTs with per-file
57
58
  progress and retry (expired presigns re-mint per file) →
58
59
  `PUT /v1/requests/{requestId}` (idempotent — retries return the same
59
- reference) → confirmation + behind-the-scenes journey.
60
+ reference) → confirmation.
60
61
 
61
62
  ### Hand-offs, unlisted forms and deep links (DEV-1305)
62
63
 
@@ -96,6 +97,24 @@ yields to the link.
96
97
  `requiredIf: "media"` the checkbox appears only once a file is
97
98
  attached, is required only then, and is not sent without files.
98
99
 
100
+ ### Saving details to a new account
101
+
102
+ Off unless the host sets `facts-api` to an api-user-facts v1 base, e.g.
103
+ `<wral-report-it api="…" facts-api="https://api.wral.com/user-facts/v1">`.
104
+ With it set, when the sign-in card created the viewer's My WRAL account
105
+ on this page load, a successful submit adds one more step before the
106
+ confirmation: an offer to save their answers as user facts (the store
107
+ the audience dashboard reads). The confirmation shows only after
108
+ **Save to my account** succeeds or **No thanks**.
109
+ Only the `name` field (as `preferred_name`, at most 100 characters) and
110
+ the `postal-code` field (as `zipcode`, first five digits) are saved,
111
+ matched by `autocomplete` (`src/lib/user-facts.mjs`). Nothing is saved
112
+ without the viewer's click, for an existing account, or for an anonymous
113
+ report. A save clears the dashboard's `wral_user_facts` cache. A reload
114
+ between sign-in and submit drops the offer. In the demo,
115
+ `?demoexisting=1` makes accounts existing and `?demofactsfail=1` fails
116
+ the first save.
117
+
99
118
  ### Skipping the account (DEV-1270)
100
119
 
101
120
  The sign-in card files its alternatives under a collapsed **"Other ways
@@ -181,6 +200,25 @@ Repo variables: `NPM_TOKEN`, `AWS_ACCESS_KEY_ID`,
181
200
  `S3_BUCKET=cdn.wral.com`, `S3_PREFIX=@wral/report-it`,
182
201
  `AWS_DISTRIBUTION_ID`.
183
202
 
203
+ ## Staging pages
204
+
205
+ Both load the component from the CDN `latest` alias, so a release reaches
206
+ them without a republish. Each is a staging.wral.com publication whose
207
+ template is an HTML asset in the editorial DAM (`content: {}`,
208
+ `template: {"$ref": "https://assets.wral.com/<asset id>"}`):
209
+
210
+ | Page | api-forms stage | DAM asset |
211
+ | --- | --- | --- |
212
+ | [/test/report-it/](https://staging.wral.com/test/report-it/) | prod (`/forms`): real desk lists and the Studio queue | `39c268dd-06eb-46f9-a6bf-74d04af45bae`, i.e. `pages/report-it.html` as of DEV-1300 |
213
+ | [/test/report-it-dev/](https://staging.wral.com/test/report-it-dev/) | dev (`/dev/forms`): the `ReportIt_Dev` list and the dev content stage | `3c78d978-bcd3-44f9-9906-c417db80de14`, the same page before DEV-1300 (only the `api` attribute and its comment differ) |
214
+
215
+ To change a page:
216
+ 1. Upload the new HTML as a new asset. Use `POST https://api.wral.com/dam/v1/asset/<new uuid>/upload-url` with `dam:write`, then PUT the file with `Content-Type: text/html`.
217
+ 2. `POST https://api.wral.com/publisher/v1/publications` with `publisher:write`, sending `{site, path, content: {}, template: {"$ref": …}, metadata: {httpStatusCode: 200}}`.
218
+ 3. Invalidate the path on CloudFront distribution `E2PUK7RNR73BP4`, because the page is cached for about 6 h.
219
+
220
+ Leave the previous asset in place. Republishing with its `$ref` is the rollback.
221
+
184
222
  ## Notes
185
223
 
186
224
  - `wral-code-input` + helpers are copied from
@@ -192,5 +230,3 @@ Repo variables: `NPM_TOKEN`, `AWS_ACCESS_KEY_ID`,
192
230
  prefers `field.counties` if a form document ever ships it.
193
231
  - Required `location` fields need a county or a written place — one
194
232
  notch stricter than the server schema, deliberately.
195
- - `routing.state: "failed"` on a successful submission renders honest
196
- "delivery being retried" journey copy, never fake delivery.
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-BZTBgLk3.js";
2
+ import { W as i, a as r, b as a } from "./wral-code-input-BA1oCHMu.js";
3
3
  typeof window < "u" && !window.AmazonCognitoIdentity && (window.AmazonCognitoIdentity = n);
4
4
  const d = {
5
5
  "wral-report-it": a,