@wral/report-it 0.1.2 → 0.1.3

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/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
- import { W as U, b as M, a as V, c as H, d as j, e as K } from "./wral-code-input-CC2ZCxcs.js";
2
- const b = "weather", w = "Weather photo or report", g = "Weather reports routed to the weather desk queue; meteorologists are emailed. Severe weather flags urgent.", k = "2026-08-18.1", x = 1, v = !0, q = "weather_type", W = { maxFiles: 5, maxFileBytes: 524288e3, allowedTypes: ["image/jpeg", "image/png", "image/heic", "image/webp", "video/mp4", "video/quicktime"] }, _ = [{ id: "weather_type", type: "choice", prompt: "What kind of weather?", options: [{ id: "severe", label: "Tornado, flooding or hail", flags: ["urgent"], next: "weather_detail" }, { id: "winter", label: "Snow, ice or wind damage", flags: ["moderate"], next: "weather_detail" }, { id: "photo", label: "A photo, nothing severe", next: "weather_detail" }] }, { id: "weather_detail", type: "collect", prompt: "Where and when?", next: "verify", fields: [{ key: "location", kind: "location", label: "Where was this?", required: !0 }, { key: "observedAt", kind: "datetime", label: "When did you see it?" }, { key: "description", kind: "textarea", label: "What did you see?", required: !0, maxLength: 1e3 }, { key: "media", kind: "media", label: "Photos or video" }, { key: "rights", kind: "consent", label: "Rights confirmation", required: !0 }] }, { id: "verify", type: "gate", next: "submit" }, { id: "submit", type: "terminal", route: "studio+email:weather", confirmation: { title: "Sent to the WRAL weather team.", body: "Your report goes to the weather desk queue and the meteorologists are emailed.", urgentNote: "Severe weather reports are pinned to the top of the queue." } }], T = {
3
- formId: b,
4
- title: w,
5
- description: g,
6
- flowVersion: k,
7
- order: x,
8
- enabled: v,
9
- start: q,
10
- budget: W,
11
- nodes: _
12
- }, S = "consumer", C = "Consumer complaint", I = "Consumer complaints routed to the 5 On Your Side queue; the consumer team is emailed.", R = "2026-08-18.1", $ = 3, F = !0, Y = "consumer_company_q", D = { maxFiles: 5, maxFileBytes: 26214400, allowedTypes: ["image/jpeg", "image/png", "image/heic", "image/webp", "application/pdf"] }, O = [{ id: "consumer_company_q", type: "choice", prompt: "Is your complaint about a company or business?", help: "This goes to the 5 On Your Side consumer team.", options: [{ id: "companyyes", label: "Yes, a company or business", next: "consumer_company" }, { id: "companyno", label: "No, something else", next: "consumer_detail" }] }, { id: "consumer_company", type: "collect", prompt: "Tell us about the company.", next: "consumer_detail", fields: [{ key: "company", kind: "text", label: "Company name", required: !0 }, { key: "companysite", kind: "url", label: "Company website or social media" }, { key: "inbusiness", kind: "select", label: "Is the company still in business?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }, { id: "notsure", label: "Not sure" }] }, { key: "companyphone", kind: "text", label: "Company phone" }] }, { id: "consumer_detail", type: "collect", prompt: "What happened?", next: "consumer_resolution", fields: [{ key: "description", kind: "textarea", label: "Describe your complaint", required: !0, maxLength: 5e3 }, { key: "observedAt", kind: "datetime", label: "When did this happen?" }, { key: "media", kind: "media", label: "Receipts, photos or documents" }] }, { id: "consumer_resolution", type: "collect", prompt: "What has happened since?", help: "These answers help the team decide whether they can take your case.", next: "verify", fields: [{ key: "tried", kind: "textarea", label: "What have you done to try to resolve it?", required: !0, maxLength: 5e3 }, { key: "legal", kind: "select", label: "Have you pursued legal action or consulted an attorney?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }] }, { key: "agency", kind: "select", label: "Have you filed with another agency or the Better Business Bureau?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }] }, { key: "fair", kind: "textarea", label: "What result do you think is fair?", required: !0, maxLength: 5e3 }, { key: "phone", kind: "text", label: "Daytime phone number", required: !0 }] }, { id: "verify", type: "gate", next: "submit" }, { id: "submit", type: "terminal", route: "studio+email:consumer", confirmation: { title: "Sent to 5 On Your Side.", body: "Your complaint goes to the 5 On Your Side consumer team. They read every complaint and follow up by phone on the ones they pursue." } }], A = {
13
- formId: S,
14
- title: C,
15
- description: I,
16
- flowVersion: R,
17
- order: $,
18
- enabled: F,
19
- start: Y,
20
- budget: D,
21
- nodes: O
22
- }, B = {
1
+ import { W as j, b as K, a as z, c as G, d as J, e as Q } from "./wral-code-input-DM3AfzRM.js";
2
+ const x = "weather", v = "Weather photo or report", q = "Weather reports routed to the weather desk queue; meteorologists are emailed. Severe weather flags urgent.", S = "2026-08-18.1", W = 1, _ = !0, C = "weather_type", T = { maxFiles: 5, maxFileBytes: 524288e3, allowedTypes: ["image/jpeg", "image/png", "image/heic", "image/webp", "video/mp4", "video/quicktime"] }, I = [{ id: "weather_type", type: "choice", prompt: "What kind of weather?", options: [{ id: "severe", label: "Tornado, flooding or hail", flags: ["urgent"], next: "weather_detail" }, { id: "winter", label: "Snow, ice or wind damage", flags: ["moderate"], next: "weather_detail" }, { id: "photo", label: "A photo, nothing severe", next: "weather_detail" }] }, { id: "weather_detail", type: "collect", prompt: "Where and when?", next: "verify", fields: [{ key: "location", kind: "location", label: "Where was this?", required: !0 }, { key: "observedAt", kind: "datetime", label: "When did you see it?" }, { key: "description", kind: "textarea", label: "What did you see?", required: !0, maxLength: 1e3 }, { key: "media", kind: "media", label: "Photos or video" }, { key: "rights", kind: "consent", label: "Rights confirmation", required: !0 }] }, { id: "verify", type: "gate", next: "submit" }, { id: "submit", type: "terminal", route: "studio+email:weather", confirmation: { title: "Sent to the WRAL weather team.", body: "Your report goes to the weather desk queue and the meteorologists are emailed.", urgentNote: "Severe weather reports are pinned to the top of the queue." } }], R = {
3
+ formId: x,
4
+ title: v,
5
+ description: q,
6
+ flowVersion: S,
7
+ order: W,
8
+ enabled: _,
9
+ start: C,
10
+ budget: T,
11
+ nodes: I
12
+ }, $ = "consumer", F = "Consumer complaint", Y = "Consumer complaints routed to the 5 On Your Side queue; the consumer team is emailed.", A = "2026-08-18.1", D = 3, O = !0, E = "consumer_company_q", B = { maxFiles: 5, maxFileBytes: 26214400, allowedTypes: ["image/jpeg", "image/png", "image/heic", "image/webp", "application/pdf"] }, L = [{ id: "consumer_company_q", type: "choice", prompt: "Is your complaint about a company or business?", help: "This goes to the 5 On Your Side consumer team.", options: [{ id: "companyyes", label: "Yes, a company or business", next: "consumer_company" }, { id: "companyno", label: "No, something else", next: "consumer_detail" }] }, { id: "consumer_company", type: "collect", prompt: "Tell us about the company.", next: "consumer_detail", fields: [{ key: "company", kind: "text", label: "Company name", required: !0 }, { key: "companysite", kind: "url", label: "Company website or social media" }, { key: "inbusiness", kind: "select", label: "Is the company still in business?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }, { id: "notsure", label: "Not sure" }] }, { key: "companyphone", kind: "text", label: "Company phone" }] }, { id: "consumer_detail", type: "collect", prompt: "What happened?", next: "consumer_resolution", fields: [{ key: "description", kind: "textarea", label: "Describe your complaint", required: !0, maxLength: 5e3 }, { key: "observedAt", kind: "datetime", label: "When did this happen?" }, { key: "media", kind: "media", label: "Receipts, photos or documents" }] }, { id: "consumer_resolution", type: "collect", prompt: "What has happened since?", help: "These answers help the team decide whether they can take your case.", next: "verify", fields: [{ key: "tried", kind: "textarea", label: "What have you done to try to resolve it?", required: !0, maxLength: 5e3 }, { key: "legal", kind: "select", label: "Have you pursued legal action or consulted an attorney?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }] }, { key: "agency", kind: "select", label: "Have you filed with another agency or the Better Business Bureau?", required: !0, options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }] }, { key: "fair", kind: "textarea", label: "What result do you think is fair?", required: !0, maxLength: 5e3 }, { key: "phone", kind: "text", label: "Daytime phone number", required: !0 }] }, { id: "verify", type: "gate", next: "submit" }, { id: "submit", type: "terminal", route: "studio+email:consumer", confirmation: { title: "Sent to 5 On Your Side.", body: "Your complaint goes to the 5 On Your Side consumer team. They read every complaint and follow up by phone on the ones they pursue." } }], N = {
13
+ formId: $,
14
+ title: F,
15
+ description: Y,
16
+ flowVersion: A,
17
+ order: D,
18
+ enabled: O,
19
+ start: E,
20
+ budget: B,
21
+ nodes: L
22
+ }, P = {
23
23
  formId: "demo-redirect",
24
24
  title: "Demo: a redirect path",
25
25
  description: "Demonstrates the redirect dead-end card.",
@@ -64,36 +64,36 @@ const b = "weather", w = "Weather photo or report", g = "Weather reports routed
64
64
  confirmation: { title: "Thanks!", body: "This demo submission went nowhere." }
65
65
  }
66
66
  ]
67
- }, y = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
68
- function E() {
69
- const u = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
70
- let n = "";
67
+ }, g = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
68
+ function U() {
69
+ const m = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
70
+ let c = "";
71
71
  for (let s = 0; s < 5; s++)
72
- n += y[Math.floor(Math.random() * y.length)];
73
- return `RI-${u}-${n}`;
72
+ c += g[Math.floor(Math.random() * g.length)];
73
+ return `RI-${m}-${c}`;
74
74
  }
75
- function L({ latency: u = 250 } = {}) {
76
- const n = [T, A, B], s = /* @__PURE__ */ new Map();
77
- let p = 0, h = !1, a = { email: null, verified: !1 };
78
- const d = (e = u) => new Promise((r) => setTimeout(r, e)), f = () => {
75
+ function M({ latency: m = 250, anonymous: c = null } = {}) {
76
+ const s = [R, N, P], p = /* @__PURE__ */ new Map();
77
+ let y = 0, b = !1, i = { email: null, verified: !1 }, h = null;
78
+ const a = (e = m) => new Promise((o) => setTimeout(o, e)), f = (e) => {
79
79
  try {
80
- return new URLSearchParams(globalThis.location?.search || "").get("demofail") === "1";
80
+ return new URLSearchParams(globalThis.location?.search || "").get(e) === "1";
81
81
  } catch {
82
82
  return !1;
83
83
  }
84
- };
84
+ }, k = () => f("demofail"), w = c === null ? f("anon") : !!c;
85
85
  return {
86
86
  demo: !0,
87
87
  // ── api surface ─────────────────────────────────────────────
88
- listForms: async () => (await d(), n),
89
- createUploads: async ({ formId: e, files: r }) => {
90
- await d();
91
- const i = n.find((t) => t.formId === e)?.budget || {};
92
- if (r.length > (i.maxFiles ?? 5)) {
88
+ listForms: async () => (await a(), s),
89
+ createUploads: async ({ formId: e, files: o }) => {
90
+ await a();
91
+ const n = s.find((t) => t.formId === e)?.budget || {};
92
+ if (o.length > (n.maxFiles ?? 5)) {
93
93
  const t = new Error("demo: too many files");
94
- throw t.status = 400, t.body = [{ message: `This form accepts at most ${i.maxFiles} files` }], t;
94
+ throw t.status = 400, t.body = [{ message: `This form accepts at most ${n.maxFiles} files` }], t;
95
95
  }
96
- return r.map(() => {
96
+ return o.map(() => {
97
97
  const t = crypto.randomUUID();
98
98
  return {
99
99
  assetId: t,
@@ -104,65 +104,79 @@ function L({ latency: u = 250 } = {}) {
104
104
  };
105
105
  });
106
106
  },
107
- uploadFile: ({ file: e, onProgress: r = () => {
107
+ uploadFile: ({ file: e, onProgress: o = () => {
108
108
  } }) => {
109
- p += 1;
110
- const m = p;
111
- let i = !1;
109
+ y += 1;
110
+ const l = y;
111
+ let n = !1;
112
112
  return { promise: (async () => {
113
- const o = e.size || 1;
114
- for (let c = 1; c <= 4; c++) {
115
- if (await d(300), i) {
116
- const l = new Error("aborted");
117
- throw l.status = 0, l.body = { aborted: !0 }, l;
113
+ const r = e.size || 1;
114
+ for (let u = 1; u <= 4; u++) {
115
+ if (await a(300), n) {
116
+ const d = new Error("aborted");
117
+ throw d.status = 0, d.body = { aborted: !0 }, d;
118
118
  }
119
- if (f() && m === 2 && !h && c === 2) {
120
- h = !0;
121
- const l = new Error("demo: simulated upload failure");
122
- throw l.status = 0, l;
119
+ if (k() && l === 2 && !b && u === 2) {
120
+ b = !0;
121
+ const d = new Error("demo: simulated upload failure");
122
+ throw d.status = 0, d;
123
123
  }
124
- r({ loaded: o * c / 4, total: o });
124
+ o({ loaded: r * u / 4, total: r });
125
125
  }
126
126
  return { status: 200 };
127
127
  })(), abort: () => {
128
- i = !0;
128
+ n = !0;
129
129
  } };
130
130
  },
131
- putRequest: async (e, r) => {
132
- if (await d(), !a.verified) {
133
- const o = new Error("demo: not signed in");
134
- throw o.status = 401, o;
131
+ putRequest: async (e, o) => {
132
+ if (await a(), !i.verified && h?.requestId !== e) {
133
+ const r = new Error("demo: not signed in");
134
+ throw r.status = 401, r;
135
135
  }
136
- if (s.has(e))
137
- return s.get(e);
138
- const i = (n.find((o) => o.formId === r.formId)?.nodes || []).find((o) => o.type === "terminal"), t = {
136
+ if (p.has(e))
137
+ return p.get(e);
138
+ const n = (s.find((r) => r.formId === o.formId)?.nodes || []).find((r) => r.type === "terminal"), t = {
139
139
  requestId: e,
140
- reference: E(),
141
- confirmation: i?.confirmation || { title: "Report received.", body: "" },
142
- routing: { destination: i?.route || "email:general", state: "delivered" }
140
+ reference: U(),
141
+ confirmation: n?.confirmation || { title: "Report received.", body: "" },
142
+ routing: { destination: n?.route || "email:general", state: "delivered" }
143
143
  };
144
- return s.set(e, t), t;
144
+ return p.set(e, t), t;
145
145
  },
146
146
  // ── auth surface ────────────────────────────────────────────
147
- isAuthenticated: async () => a.verified,
148
- signedInEmail: () => a.verified ? a.email : null,
149
- sendCode: async (e) => (await d(), a = { email: e, verified: !1 }, { challengeRequired: !0 }),
147
+ isAuthenticated: async () => i.verified,
148
+ signedInEmail: () => i.verified ? i.email : null,
149
+ sendCode: async (e) => (await a(), i = { email: e, verified: !1 }, { challengeRequired: !0 }),
150
150
  verifyCode: async (e) => {
151
- if (await d(), !/^\d{6}$/.test(e))
151
+ if (await a(), !/^\d{6}$/.test(e))
152
152
  throw new Error("Please enter the 6-digit code.");
153
- return a.verified = !0, { success: !0 };
153
+ return i.verified = !0, { success: !0 };
154
154
  },
155
155
  signOut: () => {
156
- a = { email: null, verified: !1 };
156
+ i = { email: null, verified: !1 };
157
+ },
158
+ // ── anonymous surface (DEV-1270) ────────────────────────────
159
+ // The component reads this the way it reads a real server's
160
+ // GET /v1/forms block: dark unless advertised.
161
+ anonymousCapability: () => ({ enabled: w, humanCheck: null }),
162
+ createAnonSession: async ({ formId: e, requestId: o }) => {
163
+ if (await a(), !w) {
164
+ const l = new Error("demo: anonymous submission is not available");
165
+ throw l.status = 404, l;
166
+ }
167
+ return h = { formId: e, requestId: o }, { expiresIn: 900 };
168
+ },
169
+ endAnonSession: () => {
170
+ h = null;
157
171
  }
158
172
  };
159
173
  }
160
174
  export {
161
- U as WralCodeInput,
162
- M as WralReportIt,
163
- V as WralReportMedia,
164
- H as createAuthAdapter,
165
- j as createClient,
166
- L as createDemoClient,
167
- K as createRealClient
175
+ j as WralCodeInput,
176
+ K as WralReportIt,
177
+ z as WralReportMedia,
178
+ G as createAuthAdapter,
179
+ J as createClient,
180
+ M as createDemoClient,
181
+ Q as createRealClient
168
182
  };