@wral/report-it 0.1.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 +110 -0
- package/dist/define.mjs +18 -0
- package/dist/define.standalone.js +5810 -0
- package/dist/index.mjs +168 -0
- package/dist/wral-code-input-CS9ASu8g.js +1945 -0
- package/package.json +41 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { W as U, b as M, a as V, c as H, d as j, e as K } from "./wral-code-input-CS9ASu8g.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 = {
|
|
23
|
+
formId: "demo-redirect",
|
|
24
|
+
title: "Demo: a redirect path",
|
|
25
|
+
description: "Demonstrates the redirect dead-end card.",
|
|
26
|
+
flowVersion: "demo.1",
|
|
27
|
+
order: 99,
|
|
28
|
+
enabled: !0,
|
|
29
|
+
start: "kind",
|
|
30
|
+
budget: { maxFiles: 0, maxFileBytes: 0, allowedTypes: [] },
|
|
31
|
+
nodes: [
|
|
32
|
+
{
|
|
33
|
+
id: "kind",
|
|
34
|
+
type: "choice",
|
|
35
|
+
prompt: "Which path?",
|
|
36
|
+
options: [
|
|
37
|
+
{ id: "away", label: "The redirect", next: "away_redirect" },
|
|
38
|
+
{ id: "submit", label: "A submittable path", next: "detail" }
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "away_redirect",
|
|
43
|
+
type: "redirect",
|
|
44
|
+
redirect: {
|
|
45
|
+
title: "This request uses a dedicated form",
|
|
46
|
+
body: "In production this button opens that form; nothing is collected here.",
|
|
47
|
+
url: "https://www.wral.com/"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "detail",
|
|
52
|
+
type: "collect",
|
|
53
|
+
prompt: "Say anything.",
|
|
54
|
+
next: "verify",
|
|
55
|
+
fields: [
|
|
56
|
+
{ key: "description", kind: "textarea", label: "Your note", required: !0, maxLength: 500 }
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{ id: "verify", type: "gate", next: "submit" },
|
|
60
|
+
{
|
|
61
|
+
id: "submit",
|
|
62
|
+
type: "terminal",
|
|
63
|
+
route: "email:general",
|
|
64
|
+
confirmation: { title: "Thanks!", body: "This demo submission went nowhere." }
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}, y = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
68
|
+
function E() {
|
|
69
|
+
const u = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
70
|
+
let n = "";
|
|
71
|
+
for (let s = 0; s < 5; s++)
|
|
72
|
+
n += y[Math.floor(Math.random() * y.length)];
|
|
73
|
+
return `RI-${u}-${n}`;
|
|
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 = () => {
|
|
79
|
+
try {
|
|
80
|
+
return new URLSearchParams(globalThis.location?.search || "").get("demofail") === "1";
|
|
81
|
+
} catch {
|
|
82
|
+
return !1;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
demo: !0,
|
|
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)) {
|
|
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;
|
|
95
|
+
}
|
|
96
|
+
return r.map(() => {
|
|
97
|
+
const t = crypto.randomUUID();
|
|
98
|
+
return {
|
|
99
|
+
assetId: t,
|
|
100
|
+
url: `demo:${t}`,
|
|
101
|
+
method: "PUT",
|
|
102
|
+
expires: new Date(Date.now() + 6e5).toISOString(),
|
|
103
|
+
assetUrl: `https://report-it.assets.wral.com/${t}`
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
uploadFile: ({ file: e, onProgress: r = () => {
|
|
108
|
+
} }) => {
|
|
109
|
+
p += 1;
|
|
110
|
+
const m = p;
|
|
111
|
+
let i = !1;
|
|
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;
|
|
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;
|
|
123
|
+
}
|
|
124
|
+
r({ loaded: o * c / 4, total: o });
|
|
125
|
+
}
|
|
126
|
+
return { status: 200 };
|
|
127
|
+
})(), abort: () => {
|
|
128
|
+
i = !0;
|
|
129
|
+
} };
|
|
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;
|
|
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 = {
|
|
139
|
+
requestId: e,
|
|
140
|
+
reference: E(),
|
|
141
|
+
confirmation: i?.confirmation || { title: "Report received.", body: "" },
|
|
142
|
+
routing: { destination: i?.route || "email:general", state: "delivered" }
|
|
143
|
+
};
|
|
144
|
+
return s.set(e, t), t;
|
|
145
|
+
},
|
|
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 }),
|
|
150
|
+
verifyCode: async (e) => {
|
|
151
|
+
if (await d(), !/^\d{6}$/.test(e))
|
|
152
|
+
throw new Error("Please enter the 6-digit code.");
|
|
153
|
+
return a.verified = !0, { success: !0 };
|
|
154
|
+
},
|
|
155
|
+
signOut: () => {
|
|
156
|
+
a = { email: null, verified: !1 };
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
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
|
|
168
|
+
};
|