@wral/report-it 0.1.2 → 0.1.4
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 +40 -1
- package/dist/define.mjs +1 -1
- package/dist/define.standalone.js +1290 -1111
- package/dist/index.mjs +94 -80
- package/dist/{wral-code-input-CC2ZCxcs.js → wral-code-input-DCemMj53.js} +650 -471
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { W as
|
|
2
|
-
const
|
|
3
|
-
formId:
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
6
|
-
flowVersion:
|
|
7
|
-
order:
|
|
8
|
-
enabled:
|
|
9
|
-
start:
|
|
10
|
-
budget:
|
|
11
|
-
nodes:
|
|
12
|
-
},
|
|
13
|
-
formId:
|
|
14
|
-
title:
|
|
15
|
-
description:
|
|
16
|
-
flowVersion:
|
|
17
|
-
order:
|
|
18
|
-
enabled:
|
|
19
|
-
start:
|
|
20
|
-
budget:
|
|
21
|
-
nodes:
|
|
22
|
-
},
|
|
1
|
+
import { W as j, b as K, a as z, c as G, d as J, e as Q } from "./wral-code-input-DCemMj53.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
|
-
},
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
let
|
|
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
|
-
|
|
73
|
-
return `RI-${
|
|
72
|
+
c += g[Math.floor(Math.random() * g.length)];
|
|
73
|
+
return `RI-${m}-${c}`;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
const
|
|
77
|
-
let
|
|
78
|
-
const
|
|
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(
|
|
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
|
|
89
|
-
createUploads: async ({ formId: e, files:
|
|
90
|
-
await
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
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 ${
|
|
94
|
+
throw t.status = 400, t.body = [{ message: `This form accepts at most ${n.maxFiles} files` }], t;
|
|
95
95
|
}
|
|
96
|
-
return
|
|
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:
|
|
107
|
+
uploadFile: ({ file: e, onProgress: o = () => {
|
|
108
108
|
} }) => {
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
let
|
|
109
|
+
y += 1;
|
|
110
|
+
const l = y;
|
|
111
|
+
let n = !1;
|
|
112
112
|
return { promise: (async () => {
|
|
113
|
-
const
|
|
114
|
-
for (let
|
|
115
|
-
if (await
|
|
116
|
-
const
|
|
117
|
-
throw
|
|
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 (
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
throw
|
|
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
|
-
|
|
124
|
+
o({ loaded: r * u / 4, total: r });
|
|
125
125
|
}
|
|
126
126
|
return { status: 200 };
|
|
127
127
|
})(), abort: () => {
|
|
128
|
-
|
|
128
|
+
n = !0;
|
|
129
129
|
} };
|
|
130
130
|
},
|
|
131
|
-
putRequest: async (e,
|
|
132
|
-
if (await
|
|
133
|
-
const
|
|
134
|
-
throw
|
|
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 (
|
|
137
|
-
return
|
|
138
|
-
const
|
|
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:
|
|
141
|
-
confirmation:
|
|
142
|
-
routing: { destination:
|
|
140
|
+
reference: U(),
|
|
141
|
+
confirmation: n?.confirmation || { title: "Report received.", body: "" },
|
|
142
|
+
routing: { destination: n?.route || "email:general", state: "delivered" }
|
|
143
143
|
};
|
|
144
|
-
return
|
|
144
|
+
return p.set(e, t), t;
|
|
145
145
|
},
|
|
146
146
|
// ── auth surface ────────────────────────────────────────────
|
|
147
|
-
isAuthenticated: async () =>
|
|
148
|
-
signedInEmail: () =>
|
|
149
|
-
sendCode: async (e) => (await
|
|
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
|
|
151
|
+
if (await a(), !/^\d{6}$/.test(e))
|
|
152
152
|
throw new Error("Please enter the 6-digit code.");
|
|
153
|
-
return
|
|
153
|
+
return i.verified = !0, { success: !0 };
|
|
154
154
|
},
|
|
155
155
|
signOut: () => {
|
|
156
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
};
|