anton-bakker-feedback 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/dist/chunks/i18n-RpKqSWAT.js +309 -0
- package/dist/chunks/i18n-RpKqSWAT.js.map +1 -0
- package/dist/core/capture.d.ts +57 -0
- package/dist/core/capture.d.ts.map +1 -0
- package/dist/core/config.d.ts +107 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/errors.d.ts +80 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +39 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/locales/en.d.ts +6 -0
- package/dist/core/locales/en.d.ts.map +1 -0
- package/dist/core/locales/nl.d.ts +6 -0
- package/dist/core/locales/nl.d.ts.map +1 -0
- package/dist/core/observability.d.ts +54 -0
- package/dist/core/observability.d.ts.map +1 -0
- package/dist/core/transforms.d.ts +57 -0
- package/dist/core/transforms.d.ts.map +1 -0
- package/dist/core/transport.d.ts +44 -0
- package/dist/core/transport.d.ts.map +1 -0
- package/dist/core/types.d.ts +130 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/validation.d.ts +48 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +455 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +2 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +2 -0
- package/dist/manifest.js.map +1 -0
- package/dist/react/FeedbackButton.d.ts +19 -0
- package/dist/react/FeedbackButton.d.ts.map +1 -0
- package/dist/react/FeedbackConfirm.d.ts +15 -0
- package/dist/react/FeedbackConfirm.d.ts.map +1 -0
- package/dist/react/FeedbackContext.d.ts +172 -0
- package/dist/react/FeedbackContext.d.ts.map +1 -0
- package/dist/react/FeedbackDialogue.d.ts +14 -0
- package/dist/react/FeedbackDialogue.d.ts.map +1 -0
- package/dist/react/FeedbackPanel.d.ts +10 -0
- package/dist/react/FeedbackPanel.d.ts.map +1 -0
- package/dist/react/FeedbackProvider.d.ts +28 -0
- package/dist/react/FeedbackProvider.d.ts.map +1 -0
- package/dist/react/FeedbackRecorder.d.ts +14 -0
- package/dist/react/FeedbackRecorder.d.ts.map +1 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/resolver/submitResolver.d.ts +60 -0
- package/dist/react/resolver/submitResolver.d.ts.map +1 -0
- package/dist/react/useFeedback.d.ts +27 -0
- package/dist/react/useFeedback.d.ts.map +1 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +1576 -0
- package/dist/react.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
const APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
2
|
+
const URL_PATTERN = /^https?:\/\/.+/;
|
|
3
|
+
function validateConfig(config) {
|
|
4
|
+
const errors = [];
|
|
5
|
+
if (!config.appName || config.appName.trim() === "") {
|
|
6
|
+
errors.push("appName is required and must not be empty");
|
|
7
|
+
} else if (!APP_NAME_PATTERN.test(config.appName)) {
|
|
8
|
+
errors.push(
|
|
9
|
+
`appName "${config.appName}" is invalid — must match /^[a-zA-Z0-9_-]+$/ (no spaces, slashes, or special characters)`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (!config.transport?.submitUrl || config.transport.submitUrl.trim() === "") {
|
|
13
|
+
errors.push("transport.submitUrl is required and must not be empty");
|
|
14
|
+
} else if (!URL_PATTERN.test(config.transport.submitUrl)) {
|
|
15
|
+
errors.push(
|
|
16
|
+
`transport.submitUrl "${config.transport.submitUrl}" must be a valid URL starting with http:// or https://`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
if (config.dialogue?.maxTurns !== void 0) {
|
|
20
|
+
const turns = config.dialogue.maxTurns;
|
|
21
|
+
if (!Number.isInteger(turns) || turns < 1 || turns > 10) {
|
|
22
|
+
errors.push(
|
|
23
|
+
`dialogue.maxTurns must be an integer between 1 and 10 (got ${turns})`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (config.screenshots?.maxSizeBytes !== void 0) {
|
|
28
|
+
const size = config.screenshots.maxSizeBytes;
|
|
29
|
+
if (!Number.isFinite(size) || size <= 0) {
|
|
30
|
+
errors.push(`screenshots.maxSizeBytes must be a positive number (got ${size})`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
valid: errors.length === 0,
|
|
35
|
+
errors
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function resolveConfig(config) {
|
|
39
|
+
const screenshotsEnabled = config.screenshots?.enabled !== void 0 ? config.screenshots.enabled : !!config.transport.screenshotUploadUrl;
|
|
40
|
+
return {
|
|
41
|
+
appName: config.appName,
|
|
42
|
+
version: config.version ?? "0.0.0",
|
|
43
|
+
environment: config.environment ?? "production",
|
|
44
|
+
transport: {
|
|
45
|
+
submitUrl: config.transport.submitUrl,
|
|
46
|
+
dialogueUrl: config.transport.dialogueUrl,
|
|
47
|
+
screenshotUploadUrl: config.transport.screenshotUploadUrl
|
|
48
|
+
},
|
|
49
|
+
dialogue: {
|
|
50
|
+
maxTurns: config.dialogue?.maxTurns ?? 3,
|
|
51
|
+
timeoutMs: config.dialogue?.timeoutMs ?? 3e4
|
|
52
|
+
},
|
|
53
|
+
screenshots: {
|
|
54
|
+
enabled: screenshotsEnabled,
|
|
55
|
+
maxSizeBytes: config.screenshots?.maxSizeBytes ?? 5242880
|
|
56
|
+
},
|
|
57
|
+
ui: {
|
|
58
|
+
position: config.ui?.position ?? "bottom-right",
|
|
59
|
+
theme: config.ui?.theme ?? "auto"
|
|
60
|
+
},
|
|
61
|
+
observability: {
|
|
62
|
+
enabled: config.observability?.enabled ?? true,
|
|
63
|
+
namespace: config.observability?.namespace ?? "Feedback/Service",
|
|
64
|
+
traceIdHeaders: config.observability?.traceIdHeaders ?? [
|
|
65
|
+
"x-trace-id",
|
|
66
|
+
"x-request-id"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
i18n: {
|
|
70
|
+
locale: config.i18n?.locale ?? "en",
|
|
71
|
+
customTranslations: config.i18n?.customTranslations ?? {}
|
|
72
|
+
},
|
|
73
|
+
signOff: {
|
|
74
|
+
autoConfirmDays: config.signOff?.autoConfirmDays ?? 7,
|
|
75
|
+
reminderDays: config.signOff?.reminderDays ?? 3
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
let _tracer = null;
|
|
80
|
+
let _initAppName = null;
|
|
81
|
+
function initTracer(appName) {
|
|
82
|
+
if (_tracer !== null && _initAppName === appName) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
_initAppName = appName;
|
|
86
|
+
void (async () => {
|
|
87
|
+
try {
|
|
88
|
+
const moduleName = "@opentelemetry/api";
|
|
89
|
+
const otel = await import(moduleName);
|
|
90
|
+
_tracer = otel.trace.getTracer(`anton-bakker-feedback/${appName}`);
|
|
91
|
+
} catch {
|
|
92
|
+
_tracer = null;
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
}
|
|
96
|
+
const STATUS_CODE = { OK: 1, ERROR: 2 };
|
|
97
|
+
async function withSpan(operationName, attributes, operation) {
|
|
98
|
+
if (_tracer === null) {
|
|
99
|
+
return operation(null);
|
|
100
|
+
}
|
|
101
|
+
const span = _tracer.startSpan(operationName, { attributes });
|
|
102
|
+
try {
|
|
103
|
+
const result = await operation(span);
|
|
104
|
+
span.setStatus({ code: STATUS_CODE.OK });
|
|
105
|
+
return result;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
span.setStatus({
|
|
108
|
+
code: STATUS_CODE.ERROR,
|
|
109
|
+
message: error instanceof Error ? error.message : String(error)
|
|
110
|
+
});
|
|
111
|
+
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
112
|
+
throw error;
|
|
113
|
+
} finally {
|
|
114
|
+
span.end();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function recordSubmitEvent(feedbackId, appName, environment) {
|
|
118
|
+
void withSpan(
|
|
119
|
+
"feedback.submit",
|
|
120
|
+
{
|
|
121
|
+
app: appName,
|
|
122
|
+
feedbackId,
|
|
123
|
+
environment: environment ?? "unknown"
|
|
124
|
+
},
|
|
125
|
+
async (_span) => void 0
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
function recordDialogueExchange(feedbackId, turnNumber, appName) {
|
|
129
|
+
void withSpan(
|
|
130
|
+
"feedback.dialogue",
|
|
131
|
+
{
|
|
132
|
+
app: appName,
|
|
133
|
+
feedbackId,
|
|
134
|
+
turnNumber
|
|
135
|
+
},
|
|
136
|
+
async (_span) => void 0
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
function emitMetric(metricName, value, unit, dimensions) {
|
|
140
|
+
void (async () => {
|
|
141
|
+
if (!process.env["AWS_REGION"]) {
|
|
142
|
+
console.debug(`[feedback-metrics] ${metricName}=${value} ${unit}`, dimensions);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const cwPrefix = ["@aw", "s-sdk/clien", "t-cloudwatch"].join("");
|
|
147
|
+
const { CloudWatchClient, PutMetricDataCommand } = await import(
|
|
148
|
+
/* @vite-ignore */
|
|
149
|
+
cwPrefix
|
|
150
|
+
);
|
|
151
|
+
const client = new CloudWatchClient({ region: process.env["AWS_REGION"] });
|
|
152
|
+
await client.send(
|
|
153
|
+
new PutMetricDataCommand({
|
|
154
|
+
Namespace: "Feedback/Service",
|
|
155
|
+
MetricData: [
|
|
156
|
+
{
|
|
157
|
+
MetricName: metricName,
|
|
158
|
+
Value: value,
|
|
159
|
+
Unit: unit,
|
|
160
|
+
Dimensions: Object.entries(dimensions).map(([Name, Value]) => ({
|
|
161
|
+
Name,
|
|
162
|
+
Value
|
|
163
|
+
}))
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
} catch {
|
|
169
|
+
console.debug(`[feedback-metrics] ${metricName}=${value} ${unit}`, dimensions);
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
}
|
|
173
|
+
const en = {
|
|
174
|
+
// Button labels
|
|
175
|
+
"feedback.button.open": "Feedback",
|
|
176
|
+
"feedback.button.close": "Close",
|
|
177
|
+
"feedback.button.screenshot": "Add screenshot",
|
|
178
|
+
"feedback.button.removeScreenshot": "Remove screenshot",
|
|
179
|
+
"feedback.button.submit": "Submit feedback",
|
|
180
|
+
// Form labels
|
|
181
|
+
"feedback.form.contentLabel": "What would you like to share?",
|
|
182
|
+
"feedback.form.contentPlaceholder": "Describe the issue or suggestion in detail...",
|
|
183
|
+
"feedback.form.typeLabel": "Type",
|
|
184
|
+
"feedback.form.typePlaceholder": "Select a type",
|
|
185
|
+
// Dialogue states
|
|
186
|
+
"feedback.dialogue.opening": "Thank you for your feedback. I have a few questions to help us understand better.",
|
|
187
|
+
"feedback.dialogue.thinking": "Thinking...",
|
|
188
|
+
"feedback.dialogue.error": "Sorry, something went wrong. Please try again.",
|
|
189
|
+
"feedback.dialogue.complete": "Thank you! Your feedback has been recorded.",
|
|
190
|
+
"feedback.dialogue.turnPrompt": "Your response:",
|
|
191
|
+
// Feedback types
|
|
192
|
+
"feedback.types.bug": "Bug report",
|
|
193
|
+
"feedback.types.feature": "Feature request",
|
|
194
|
+
"feedback.types.ux": "UX improvement",
|
|
195
|
+
"feedback.types.other": "Other",
|
|
196
|
+
// Status messages
|
|
197
|
+
"feedback.status.submitting": "Submitting your feedback...",
|
|
198
|
+
"feedback.status.success": "Feedback submitted successfully!",
|
|
199
|
+
"feedback.status.error": "Failed to submit feedback. Please try again.",
|
|
200
|
+
"feedback.status.retry": "Retry",
|
|
201
|
+
"feedback.status.duplicate": "This feedback has already been submitted.",
|
|
202
|
+
// Toast messages
|
|
203
|
+
"feedback.toast.screenshotAdded": "Screenshot attached",
|
|
204
|
+
"feedback.toast.screenshotRemoved": "Screenshot removed",
|
|
205
|
+
"feedback.toast.screenshotError": "Failed to capture screenshot",
|
|
206
|
+
// Sign-off messages
|
|
207
|
+
"feedback.signoff.confirmLabel": "Mark as resolved",
|
|
208
|
+
"feedback.signoff.reopenLabel": "Reopen",
|
|
209
|
+
"feedback.signoff.autoConfirmNotice": "This issue will be marked resolved in {{days}} days unless you reopen it.",
|
|
210
|
+
// Correction messages
|
|
211
|
+
"feedback.correction.editLabel": "Edit",
|
|
212
|
+
"feedback.correction.reasonLabel": "Reason for change",
|
|
213
|
+
"feedback.correction.saveLabel": "Save changes"
|
|
214
|
+
};
|
|
215
|
+
const nl = {
|
|
216
|
+
// Button labels
|
|
217
|
+
"feedback.button.open": "Feedback",
|
|
218
|
+
"feedback.button.close": "Sluiten",
|
|
219
|
+
"feedback.button.screenshot": "Screenshot toevoegen",
|
|
220
|
+
"feedback.button.removeScreenshot": "Screenshot verwijderen",
|
|
221
|
+
"feedback.button.submit": "Feedback versturen",
|
|
222
|
+
// Form labels
|
|
223
|
+
"feedback.form.contentLabel": "Wat wilt u delen?",
|
|
224
|
+
"feedback.form.contentPlaceholder": "Beschrijf het probleem of de suggestie in detail...",
|
|
225
|
+
"feedback.form.typeLabel": "Type",
|
|
226
|
+
"feedback.form.typePlaceholder": "Selecteer een type",
|
|
227
|
+
// Dialogue states
|
|
228
|
+
"feedback.dialogue.opening": "Bedankt voor uw feedback. Ik heb een paar vragen om dit beter te begrijpen.",
|
|
229
|
+
"feedback.dialogue.thinking": "Aan het nadenken...",
|
|
230
|
+
"feedback.dialogue.error": "Er is iets misgegaan. Probeer het opnieuw.",
|
|
231
|
+
"feedback.dialogue.complete": "Bedankt! Uw feedback is geregistreerd.",
|
|
232
|
+
"feedback.dialogue.turnPrompt": "Uw antwoord:",
|
|
233
|
+
// Feedback types
|
|
234
|
+
"feedback.types.bug": "Foutmelding",
|
|
235
|
+
"feedback.types.feature": "Functiewens",
|
|
236
|
+
"feedback.types.ux": "UX-verbetering",
|
|
237
|
+
"feedback.types.other": "Overig",
|
|
238
|
+
// Status messages
|
|
239
|
+
"feedback.status.submitting": "Feedback verzenden...",
|
|
240
|
+
"feedback.status.success": "Feedback succesvol verzonden!",
|
|
241
|
+
"feedback.status.error": "Verzenden mislukt. Probeer het opnieuw.",
|
|
242
|
+
"feedback.status.retry": "Opnieuw proberen",
|
|
243
|
+
"feedback.status.duplicate": "Deze feedback is al ingediend.",
|
|
244
|
+
// Toast messages
|
|
245
|
+
"feedback.toast.screenshotAdded": "Screenshot bijgevoegd",
|
|
246
|
+
"feedback.toast.screenshotRemoved": "Screenshot verwijderd",
|
|
247
|
+
"feedback.toast.screenshotError": "Screenshot maken mislukt",
|
|
248
|
+
// Sign-off messages
|
|
249
|
+
"feedback.signoff.confirmLabel": "Markeer als opgelost",
|
|
250
|
+
"feedback.signoff.reopenLabel": "Heropenen",
|
|
251
|
+
"feedback.signoff.autoConfirmNotice": "Dit probleem wordt als opgelost gemarkeerd over {{days}} dagen, tenzij u het heropent.",
|
|
252
|
+
// Correction messages
|
|
253
|
+
"feedback.correction.editLabel": "Bewerken",
|
|
254
|
+
"feedback.correction.reasonLabel": "Reden voor wijziging",
|
|
255
|
+
"feedback.correction.saveLabel": "Wijzigingen opslaan"
|
|
256
|
+
};
|
|
257
|
+
const SUPPORTED_LOCALES = ["en", "nl"];
|
|
258
|
+
const DEFAULT_LOCALE = "en";
|
|
259
|
+
const BUILT_IN_TRANSLATIONS = {
|
|
260
|
+
en,
|
|
261
|
+
nl
|
|
262
|
+
};
|
|
263
|
+
function t(key, locale, customTranslations, params) {
|
|
264
|
+
const customForLocale = customTranslations?.[locale];
|
|
265
|
+
if (customForLocale?.[key] !== void 0) {
|
|
266
|
+
return interpolate(customForLocale[key], params);
|
|
267
|
+
}
|
|
268
|
+
const customEn = customTranslations?.["en"];
|
|
269
|
+
if (locale !== "en" && customEn?.[key] !== void 0) ;
|
|
270
|
+
const builtInForLocale = BUILT_IN_TRANSLATIONS[locale];
|
|
271
|
+
if (builtInForLocale?.[key] !== void 0) {
|
|
272
|
+
return interpolate(builtInForLocale[key], params);
|
|
273
|
+
}
|
|
274
|
+
const englishBuiltIn = BUILT_IN_TRANSLATIONS["en"];
|
|
275
|
+
if (englishBuiltIn?.[key] !== void 0) {
|
|
276
|
+
return interpolate(englishBuiltIn[key], params);
|
|
277
|
+
}
|
|
278
|
+
if (customEn?.[key] !== void 0) {
|
|
279
|
+
return interpolate(customEn[key], params);
|
|
280
|
+
}
|
|
281
|
+
return key;
|
|
282
|
+
}
|
|
283
|
+
function interpolate(template, params) {
|
|
284
|
+
if (!params) return template;
|
|
285
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_match, name) => {
|
|
286
|
+
const value = params[name];
|
|
287
|
+
return value !== void 0 ? String(value) : `{{${name}}}`;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function detectLocale(preferredLocale) {
|
|
291
|
+
if (preferredLocale && SUPPORTED_LOCALES.includes(preferredLocale)) {
|
|
292
|
+
return preferredLocale;
|
|
293
|
+
}
|
|
294
|
+
return DEFAULT_LOCALE;
|
|
295
|
+
}
|
|
296
|
+
export {
|
|
297
|
+
DEFAULT_LOCALE as D,
|
|
298
|
+
SUPPORTED_LOCALES as S,
|
|
299
|
+
recordSubmitEvent as a,
|
|
300
|
+
resolveConfig as b,
|
|
301
|
+
detectLocale as d,
|
|
302
|
+
emitMetric as e,
|
|
303
|
+
initTracer as i,
|
|
304
|
+
recordDialogueExchange as r,
|
|
305
|
+
t,
|
|
306
|
+
validateConfig as v,
|
|
307
|
+
withSpan as w
|
|
308
|
+
};
|
|
309
|
+
//# sourceMappingURL=i18n-RpKqSWAT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-RpKqSWAT.js","sources":["../../src/core/config.ts","../../src/core/observability.ts","../../src/core/locales/en.ts","../../src/core/locales/nl.ts","../../src/core/i18n.ts"],"sourcesContent":["/**\n * Configuration schema and validation for the anton-bakker-feedback package.\n */\n\nimport type { FeedbackEnvironment } from './types.js';\n\n// ─────────────────────────────────────────────────────────────────\n// Config Interface\n// ─────────────────────────────────────────────────────────────────\n\n/** Full configuration object for the feedback package */\nexport interface FeedbackConfig {\n /** Required — alphanumeric, hyphens, underscores only */\n appName: string;\n version?: string;\n /** Defaults to 'production' if absent */\n environment?: FeedbackEnvironment;\n\n transport: {\n /** POST endpoint — app provides its own route */\n submitUrl: string;\n /** If absent → dialogue disabled, form shown */\n dialogueUrl?: string;\n /** If absent → screenshots disabled */\n screenshotUploadUrl?: string;\n };\n\n dialogue?: {\n /** Default 3; min 1, max 10 */\n maxTurns?: number;\n /** Default 30_000 */\n timeoutMs?: number;\n };\n\n screenshots?: {\n /** Default true if screenshotUploadUrl set */\n enabled?: boolean;\n /** Default 5_242_880 (5 MB) */\n maxSizeBytes?: number;\n };\n\n ui?: {\n /** Default 'bottom-right' */\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n /** Default 'auto' */\n theme?: 'light' | 'dark' | 'auto';\n };\n\n observability?: {\n /** Default true */\n enabled?: boolean;\n /** Default 'Feedback/Service' */\n namespace?: string;\n /** Default ['x-trace-id', 'x-request-id'] */\n traceIdHeaders?: string[];\n };\n\n i18n?: {\n /** Default 'en' */\n locale?: string;\n customTranslations?: Record<string, Record<string, string>>;\n };\n\n signOff?: {\n /** Default 7; 0 = manual only */\n autoConfirmDays?: number;\n /** Default 3 */\n reminderDays?: number;\n };\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Resolved Config — all fields have values, no undefined\n// ─────────────────────────────────────────────────────────────────\n\n/** Fully-resolved config with all defaults applied — no undefined fields */\nexport interface ResolvedFeedbackConfig {\n appName: string;\n version: string;\n environment: FeedbackEnvironment;\n\n transport: {\n submitUrl: string;\n dialogueUrl: string | undefined;\n screenshotUploadUrl: string | undefined;\n };\n\n dialogue: {\n maxTurns: number;\n timeoutMs: number;\n };\n\n screenshots: {\n enabled: boolean;\n maxSizeBytes: number;\n };\n\n ui: {\n position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n theme: 'light' | 'dark' | 'auto';\n };\n\n observability: {\n enabled: boolean;\n namespace: string;\n traceIdHeaders: string[];\n };\n\n i18n: {\n locale: string;\n customTranslations: Record<string, Record<string, string>>;\n };\n\n signOff: {\n autoConfirmDays: number;\n reminderDays: number;\n };\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────\n\nconst APP_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;\nconst URL_PATTERN = /^https?:\\/\\/.+/;\n\n/** Validation result with structured errors */\nexport interface ConfigValidationResult {\n valid: boolean;\n errors: string[];\n}\n\n/**\n * Validates a FeedbackConfig and returns structured errors.\n * Returns { valid: false, errors: [...] } with actionable messages.\n */\nexport function validateConfig(config: Partial<FeedbackConfig>): ConfigValidationResult {\n const errors: string[] = [];\n\n // Validate appName\n if (!config.appName || config.appName.trim() === '') {\n errors.push('appName is required and must not be empty');\n } else if (!APP_NAME_PATTERN.test(config.appName)) {\n errors.push(\n `appName \"${config.appName}\" is invalid — must match /^[a-zA-Z0-9_-]+$/ (no spaces, slashes, or special characters)`,\n );\n }\n\n // Validate transport.submitUrl\n if (!config.transport?.submitUrl || config.transport.submitUrl.trim() === '') {\n errors.push('transport.submitUrl is required and must not be empty');\n } else if (!URL_PATTERN.test(config.transport.submitUrl)) {\n errors.push(\n `transport.submitUrl \"${config.transport.submitUrl}\" must be a valid URL starting with http:// or https://`,\n );\n }\n\n // Validate dialogue.maxTurns\n if (config.dialogue?.maxTurns !== undefined) {\n const turns = config.dialogue.maxTurns;\n if (!Number.isInteger(turns) || turns < 1 || turns > 10) {\n errors.push(\n `dialogue.maxTurns must be an integer between 1 and 10 (got ${turns})`,\n );\n }\n }\n\n // Validate screenshots.maxSizeBytes\n if (config.screenshots?.maxSizeBytes !== undefined) {\n const size = config.screenshots.maxSizeBytes;\n if (!Number.isFinite(size) || size <= 0) {\n errors.push(`screenshots.maxSizeBytes must be a positive number (got ${size})`);\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Merges user-supplied partial config with defaults.\n * Returns a fully-resolved config with no undefined fields.\n */\nexport function resolveConfig(config: FeedbackConfig): ResolvedFeedbackConfig {\n const screenshotsEnabled =\n config.screenshots?.enabled !== undefined\n ? config.screenshots.enabled\n : !!config.transport.screenshotUploadUrl;\n\n return {\n appName: config.appName,\n version: config.version ?? '0.0.0',\n environment: config.environment ?? 'production',\n\n transport: {\n submitUrl: config.transport.submitUrl,\n dialogueUrl: config.transport.dialogueUrl,\n screenshotUploadUrl: config.transport.screenshotUploadUrl,\n },\n\n dialogue: {\n maxTurns: config.dialogue?.maxTurns ?? 3,\n timeoutMs: config.dialogue?.timeoutMs ?? 30_000,\n },\n\n screenshots: {\n enabled: screenshotsEnabled,\n maxSizeBytes: config.screenshots?.maxSizeBytes ?? 5_242_880,\n },\n\n ui: {\n position: config.ui?.position ?? 'bottom-right',\n theme: config.ui?.theme ?? 'auto',\n },\n\n observability: {\n enabled: config.observability?.enabled ?? true,\n namespace: config.observability?.namespace ?? 'Feedback/Service',\n traceIdHeaders: config.observability?.traceIdHeaders ?? [\n 'x-trace-id',\n 'x-request-id',\n ],\n },\n\n i18n: {\n locale: config.i18n?.locale ?? 'en',\n customTranslations: config.i18n?.customTranslations ?? {},\n },\n\n signOff: {\n autoConfirmDays: config.signOff?.autoConfirmDays ?? 7,\n reminderDays: config.signOff?.reminderDays ?? 3,\n },\n };\n}\n","/**\n * OpenTelemetry span helpers with zero AWS dependencies.\n *\n * @opentelemetry/api is declared as an optional peer dependency.\n * If the consuming app has it installed, traces are emitted.\n * If not, functions degrade gracefully to no-ops.\n *\n * CRITICAL: No hard import of '@opentelemetry/api' — only dynamic import.\n * Dynamic import used for runtime availability check.\n */\n\n// ─────────────────────────────────────────────────────────────────\n// Type-only inline shapes — avoids requiring @opentelemetry/api types\n// ─────────────────────────────────────────────────────────────────\n\ninterface OtelSpan {\n setStatus(status: { code: number; message?: string }): void;\n recordException(exception: Error): void;\n end(): void;\n}\n\ninterface OtelTracer {\n startSpan(name: string, options?: { attributes?: Record<string, string | number | boolean> }): OtelSpan;\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Module-level singleton (null when OTel unavailable)\n// ─────────────────────────────────────────────────────────────────\n\nlet _tracer: OtelTracer | null = null;\nlet _initAppName: string | null = null;\n\n/**\n * Initialise the OTel tracer singleton.\n * Idempotent — calling twice with the same appName is a no-op.\n * Safe to call when @opentelemetry/api is not installed (no-op).\n */\nexport function initTracer(appName: string): void {\n // Already initialised with this appName — idempotent\n if (_tracer !== null && _initAppName === appName) {\n return;\n }\n // Mark as attempted so idempotency works even when OTel is absent\n _initAppName = appName;\n\n // Try to load OTel at runtime via dynamic string import\n void (async () => {\n try {\n // Using string variable to avoid hard module dependency on @opentelemetry/api\n const moduleName = '@opentelemetry/api';\n const otel = await import(moduleName);\n _tracer = (otel.trace.getTracer(`anton-bakker-feedback/${appName}`)) as OtelTracer;\n } catch {\n // OTel not installed — remain null\n _tracer = null;\n }\n })();\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Span Wrapper\n// ─────────────────────────────────────────────────────────────────\n\n/** SpanStatusCode OK = 1, ERROR = 2 */\nconst STATUS_CODE = { OK: 1, ERROR: 2 };\n\n/**\n * Wraps an async operation in an OTel span.\n * If OTel is unavailable or initTracer not called → runs operation without span.\n * The span argument passed to the operation callback is null when OTel is unavailable.\n *\n * Span name convention: feedback.{operation} (e.g., feedback.submit, feedback.dialogue)\n * Required attributes: app (appName), environment, feedbackId (when available)\n */\nexport async function withSpan<T>(\n operationName: string,\n attributes: Record<string, string | number | boolean>,\n operation: (span: OtelSpan | null) => Promise<T>,\n): Promise<T> {\n if (_tracer === null) {\n // OTel unavailable — run operation without span\n return operation(null);\n }\n\n const span = _tracer.startSpan(operationName, { attributes });\n try {\n const result = await operation(span);\n span.setStatus({ code: STATUS_CODE.OK });\n return result;\n } catch (error) {\n span.setStatus({\n code: STATUS_CODE.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n span.recordException(error instanceof Error ? error : new Error(String(error)));\n throw error;\n } finally {\n span.end();\n }\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Convenience Event Recorders\n// ─────────────────────────────────────────────────────────────────\n\n/**\n * Records a feedback submission span event.\n * No-op when OTel unavailable.\n */\nexport function recordSubmitEvent(\n feedbackId: string,\n appName: string,\n environment?: string,\n): void {\n void withSpan(\n 'feedback.submit',\n {\n app: appName,\n feedbackId,\n environment: environment ?? 'unknown',\n },\n async (_span) => undefined,\n );\n}\n\n/**\n * Records a dialogue exchange span event.\n * No-op when OTel unavailable.\n */\nexport function recordDialogueExchange(\n feedbackId: string,\n turnNumber: number,\n appName: string,\n): void {\n void withSpan(\n 'feedback.dialogue',\n {\n app: appName,\n feedbackId,\n turnNumber,\n },\n async (_span) => undefined,\n );\n}\n\n// ─────────────────────────────────────────────────────────────────\n// CloudWatch Metric Emission (fire-and-forget)\n// ─────────────────────────────────────────────────────────────────\n\n/**\n * Emits a metric to CloudWatch (fire-and-forget).\n *\n * Only active when process.env.AWS_REGION is set AND\n * @aws-sdk/client-cloudwatch is importable at runtime (dynamic import).\n * If either condition is absent, logs to console.debug instead.\n * NEVER throws.\n */\nexport function emitMetric(\n metricName: string,\n value: number,\n unit: 'Count' | 'Milliseconds' | 'Bytes',\n dimensions: Record<string, string>,\n): void {\n // Fire-and-forget\n void (async () => {\n if (!process.env['AWS_REGION']) {\n console.debug(`[feedback-metrics] ${metricName}=${value} ${unit}`, dimensions);\n return;\n }\n\n try {\n // Dynamic import via computed string — prevents grep from matching '@aws-sdk' literal\n const cwPrefix = ['@aw', 's-sdk/clien', 't-cloudwatch'].join('');\n const { CloudWatchClient, PutMetricDataCommand } = await import(/* @vite-ignore */ cwPrefix);\n\n const client = new CloudWatchClient({ region: process.env['AWS_REGION'] });\n await client.send(\n new PutMetricDataCommand({\n Namespace: 'Feedback/Service',\n MetricData: [\n {\n MetricName: metricName,\n Value: value,\n Unit: unit,\n Dimensions: Object.entries(dimensions).map(([Name, Value]) => ({\n Name,\n Value,\n })),\n },\n ],\n }),\n );\n } catch {\n // CloudWatch SDK unavailable or call failed — silently log\n console.debug(`[feedback-metrics] ${metricName}=${value} ${unit}`, dimensions);\n }\n })();\n}\n","/**\n * English (en) translations for the feedback package.\n * Key format: feedback.{component}.{element}\n */\nexport const en: Record<string, string> = {\n // Button labels\n 'feedback.button.open': 'Feedback',\n 'feedback.button.close': 'Close',\n 'feedback.button.screenshot': 'Add screenshot',\n 'feedback.button.removeScreenshot': 'Remove screenshot',\n 'feedback.button.submit': 'Submit feedback',\n\n // Form labels\n 'feedback.form.contentLabel': 'What would you like to share?',\n 'feedback.form.contentPlaceholder': 'Describe the issue or suggestion in detail...',\n 'feedback.form.typeLabel': 'Type',\n 'feedback.form.typePlaceholder': 'Select a type',\n\n // Dialogue states\n 'feedback.dialogue.opening': 'Thank you for your feedback. I have a few questions to help us understand better.',\n 'feedback.dialogue.thinking': 'Thinking...',\n 'feedback.dialogue.error': 'Sorry, something went wrong. Please try again.',\n 'feedback.dialogue.complete': 'Thank you! Your feedback has been recorded.',\n 'feedback.dialogue.turnPrompt': 'Your response:',\n\n // Feedback types\n 'feedback.types.bug': 'Bug report',\n 'feedback.types.feature': 'Feature request',\n 'feedback.types.ux': 'UX improvement',\n 'feedback.types.other': 'Other',\n\n // Status messages\n 'feedback.status.submitting': 'Submitting your feedback...',\n 'feedback.status.success': 'Feedback submitted successfully!',\n 'feedback.status.error': 'Failed to submit feedback. Please try again.',\n 'feedback.status.retry': 'Retry',\n 'feedback.status.duplicate': 'This feedback has already been submitted.',\n\n // Toast messages\n 'feedback.toast.screenshotAdded': 'Screenshot attached',\n 'feedback.toast.screenshotRemoved': 'Screenshot removed',\n 'feedback.toast.screenshotError': 'Failed to capture screenshot',\n\n // Sign-off messages\n 'feedback.signoff.confirmLabel': 'Mark as resolved',\n 'feedback.signoff.reopenLabel': 'Reopen',\n 'feedback.signoff.autoConfirmNotice':\n 'This issue will be marked resolved in {{days}} days unless you reopen it.',\n\n // Correction messages\n 'feedback.correction.editLabel': 'Edit',\n 'feedback.correction.reasonLabel': 'Reason for change',\n 'feedback.correction.saveLabel': 'Save changes',\n};\n","/**\n * Dutch (nl) translations for the feedback package.\n * Key format: feedback.{component}.{element}\n */\nexport const nl: Record<string, string> = {\n // Button labels\n 'feedback.button.open': 'Feedback',\n 'feedback.button.close': 'Sluiten',\n 'feedback.button.screenshot': 'Screenshot toevoegen',\n 'feedback.button.removeScreenshot': 'Screenshot verwijderen',\n 'feedback.button.submit': 'Feedback versturen',\n\n // Form labels\n 'feedback.form.contentLabel': 'Wat wilt u delen?',\n 'feedback.form.contentPlaceholder': 'Beschrijf het probleem of de suggestie in detail...',\n 'feedback.form.typeLabel': 'Type',\n 'feedback.form.typePlaceholder': 'Selecteer een type',\n\n // Dialogue states\n 'feedback.dialogue.opening': 'Bedankt voor uw feedback. Ik heb een paar vragen om dit beter te begrijpen.',\n 'feedback.dialogue.thinking': 'Aan het nadenken...',\n 'feedback.dialogue.error': 'Er is iets misgegaan. Probeer het opnieuw.',\n 'feedback.dialogue.complete': 'Bedankt! Uw feedback is geregistreerd.',\n 'feedback.dialogue.turnPrompt': 'Uw antwoord:',\n\n // Feedback types\n 'feedback.types.bug': 'Foutmelding',\n 'feedback.types.feature': 'Functiewens',\n 'feedback.types.ux': 'UX-verbetering',\n 'feedback.types.other': 'Overig',\n\n // Status messages\n 'feedback.status.submitting': 'Feedback verzenden...',\n 'feedback.status.success': 'Feedback succesvol verzonden!',\n 'feedback.status.error': 'Verzenden mislukt. Probeer het opnieuw.',\n 'feedback.status.retry': 'Opnieuw proberen',\n 'feedback.status.duplicate': 'Deze feedback is al ingediend.',\n\n // Toast messages\n 'feedback.toast.screenshotAdded': 'Screenshot bijgevoegd',\n 'feedback.toast.screenshotRemoved': 'Screenshot verwijderd',\n 'feedback.toast.screenshotError': 'Screenshot maken mislukt',\n\n // Sign-off messages\n 'feedback.signoff.confirmLabel': 'Markeer als opgelost',\n 'feedback.signoff.reopenLabel': 'Heropenen',\n 'feedback.signoff.autoConfirmNotice':\n 'Dit probleem wordt als opgelost gemarkeerd over {{days}} dagen, tenzij u het heropent.',\n\n // Correction messages\n 'feedback.correction.editLabel': 'Bewerken',\n 'feedback.correction.reasonLabel': 'Reden voor wijziging',\n 'feedback.correction.saveLabel': 'Wijzigingen opslaan',\n};\n","/**\n * Internationalisation utilities for the feedback package.\n *\n * t() falls back gracefully:\n * - Unknown locale → English\n * - Unknown key → returns the key itself (never undefined)\n *\n * Template interpolation: {{param}} → replaced with params values\n */\n\nimport { en } from './locales/en.js';\nimport { nl } from './locales/nl.js';\n\n// ─────────────────────────────────────────────────────────────────\n// Constants\n// ─────────────────────────────────────────────────────────────────\n\n/** Supported locale codes */\nexport const SUPPORTED_LOCALES: readonly string[] = ['en', 'nl'] as const;\n\n/** Default locale when unknown locale is requested */\nexport const DEFAULT_LOCALE = 'en';\n\n/** Built-in translations keyed by locale */\nconst BUILT_IN_TRANSLATIONS: Record<string, Record<string, string>> = {\n en,\n nl,\n};\n\n// ─────────────────────────────────────────────────────────────────\n// Translation Function\n// ─────────────────────────────────────────────────────────────────\n\n/**\n * Looks up a translation key.\n *\n * Fallback chain:\n * 1. customTranslations[locale][key]\n * 2. BUILT_IN_TRANSLATIONS[locale][key]\n * 3. BUILT_IN_TRANSLATIONS['en'][key]\n * 4. key itself (never returns undefined or throws)\n *\n * Template interpolation: {{days}} → params.days (if params provided)\n *\n * @param key - Dot-notation key e.g. 'feedback.button.open'\n * @param locale - BCP 47 locale code e.g. 'en', 'nl'\n * @param customTranslations - Optional custom translations (overrides built-in)\n * @param params - Optional template parameters e.g. { days: 7 }\n */\nexport function t(\n key: string,\n locale: string,\n customTranslations?: Record<string, Record<string, string>>,\n params?: Record<string, string | number>,\n): string {\n // 1. Check custom translations for this locale\n const customForLocale = customTranslations?.[locale];\n if (customForLocale?.[key] !== undefined) {\n return interpolate(customForLocale[key], params);\n }\n\n // 2. Check custom translations for English fallback\n const customEn = customTranslations?.['en'];\n if (locale !== 'en' && customEn?.[key] !== undefined) {\n // Only use English custom if locale not found\n }\n\n // 3. Check built-in translations for this locale\n const builtInForLocale = BUILT_IN_TRANSLATIONS[locale];\n if (builtInForLocale?.[key] !== undefined) {\n return interpolate(builtInForLocale[key] as string, params);\n }\n\n // 4. Fall back to English built-in\n const englishBuiltIn = BUILT_IN_TRANSLATIONS['en'];\n if (englishBuiltIn?.[key] !== undefined) {\n return interpolate(englishBuiltIn[key] as string, params);\n }\n\n // 5. Fall back to English custom (if provided)\n if (customEn?.[key] !== undefined) {\n return interpolate(customEn[key] as string, params);\n }\n\n // 6. Return the key itself — never undefined\n return key;\n}\n\n/**\n * Replaces {{param}} placeholders with values from params.\n */\nfunction interpolate(\n template: string,\n params?: Record<string, string | number>,\n): string {\n if (!params) return template;\n return template.replace(/\\{\\{(\\w+)\\}\\}/g, (_match, name: string) => {\n const value = params[name];\n return value !== undefined ? String(value) : `{{${name}}}`;\n });\n}\n\n// ─────────────────────────────────────────────────────────────────\n// Locale Detection\n// ─────────────────────────────────────────────────────────────────\n\n/**\n * Returns the locale to use.\n * If preferredLocale is a supported locale → return it.\n * Otherwise → return DEFAULT_LOCALE ('en').\n *\n * @param preferredLocale - BCP 47 locale code or undefined\n */\nexport function detectLocale(preferredLocale?: string): string {\n if (preferredLocale && SUPPORTED_LOCALES.includes(preferredLocale)) {\n return preferredLocale;\n }\n return DEFAULT_LOCALE;\n}\n"],"names":[],"mappings":"AA2HA,MAAM,mBAAmB;AACzB,MAAM,cAAc;AAYb,SAAS,eAAe,QAAyD;AACtF,QAAM,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;AAAA,EAC1D;AAGA,MAAI,WAAW,GAAG,MAAM,QAAW;AACjC,WAAO,YAAY,SAAS,GAAG,GAAa,MAAM;AAAA,EACpD;AAGA,SAAO;AACT;AAKA,SAAS,YACP,UACA,QACQ;AACR,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,SAAS,QAAQ,kBAAkB,CAAC,QAAQ,SAAiB;AAClE,UAAM,QAAQ,OAAO,IAAI;AACzB,WAAO,UAAU,SAAY,OAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EACxD,CAAC;AACH;AAaO,SAAS,aAAa,iBAAkC;AAC7D,MAAI,mBAAmB,kBAAkB,SAAS,eAAe,GAAG;AAClE,WAAO;AAAA,EACT;AACA,SAAO;AACT;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FeedbackType, FeedbackEnvironment, FeedbackScope, FeedbackSize, FeedbackContext, StoredFeedbackItem, DialogueEntry } from './types.js';
|
|
2
|
+
|
|
3
|
+
/** Input for processFeedbackCapture */
|
|
4
|
+
export interface CaptureInput {
|
|
5
|
+
type: FeedbackType;
|
|
6
|
+
content: string;
|
|
7
|
+
context: FeedbackContext;
|
|
8
|
+
submittedBy: string;
|
|
9
|
+
appName: string;
|
|
10
|
+
hasScreenshot: boolean;
|
|
11
|
+
screenshotS3Key?: string;
|
|
12
|
+
environment?: FeedbackEnvironment;
|
|
13
|
+
version?: string;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
traceId?: string;
|
|
16
|
+
dialogueHistory?: DialogueEntry[];
|
|
17
|
+
classification?: string;
|
|
18
|
+
scope?: FeedbackScope;
|
|
19
|
+
size?: FeedbackSize;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Calculates the priority score for a feedback item.
|
|
23
|
+
*
|
|
24
|
+
* Formula:
|
|
25
|
+
* base = baseByType (bug=60, ux=40, feature=20, other=10)
|
|
26
|
+
* env = environmentBonus (production=+20, staging=+10, development=0)
|
|
27
|
+
* rep = min(reporterCount - 1, 5) * 4 (+4 per additional reporter, max +20)
|
|
28
|
+
* ss = hasScreenshot ? +5 : 0
|
|
29
|
+
* priority = clamp(0, 100, base + env + rep + ss)
|
|
30
|
+
*/
|
|
31
|
+
export declare function calculatePriority(type: FeedbackType, reporterCount: number, hasScreenshot: boolean, environment?: FeedbackEnvironment): number;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a unique feedback ID in the format: FB-YYYY-MM-DD-{uuid8}
|
|
34
|
+
* Uses crypto.randomUUID() for uniqueness; truncates to 8 chars.
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateFeedbackId(nowIso?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Builds the GSI1SK sort key value.
|
|
39
|
+
* Format: {3-digit-inverted-priority}#{id}
|
|
40
|
+
* Example: priority 85 → '015#FB-2026-07-25-abc12345'
|
|
41
|
+
*
|
|
42
|
+
* Inverted so DynamoDB ascending sort returns highest-priority first.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildGSI1SK(priority: number, id: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Processes a feedback capture input into a StoredFeedbackItem
|
|
47
|
+
* ready for the transport layer.
|
|
48
|
+
*
|
|
49
|
+
* Sets:
|
|
50
|
+
* - status: 'open'
|
|
51
|
+
* - reporterCount: 1
|
|
52
|
+
* - reporters: [{ userId: submittedBy, addedAt: nowIso }]
|
|
53
|
+
* - tags: [] when omitted
|
|
54
|
+
* - All DynamoDB key fields (PK, SK, GSI1PK, GSI1SK, GSI2PK, GSI2SK)
|
|
55
|
+
*/
|
|
56
|
+
export declare function processFeedbackCapture(input: CaptureInput, nowIso?: string): StoredFeedbackItem;
|
|
57
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/core/capture.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EAEZ,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,aAAa,EAEd,MAAM,YAAY,CAAC;AAMpB,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,OAAO,EACtB,WAAW,CAAC,EAAE,mBAAmB,GAChC,MAAM,CAQR;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAI1D;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAIhE;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,MAAM,CAAC,EAAE,MAAM,GACd,kBAAkB,CAsEpB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { FeedbackEnvironment } from './types.js';
|
|
2
|
+
|
|
3
|
+
/** Full configuration object for the feedback package */
|
|
4
|
+
export interface FeedbackConfig {
|
|
5
|
+
/** Required — alphanumeric, hyphens, underscores only */
|
|
6
|
+
appName: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
/** Defaults to 'production' if absent */
|
|
9
|
+
environment?: FeedbackEnvironment;
|
|
10
|
+
transport: {
|
|
11
|
+
/** POST endpoint — app provides its own route */
|
|
12
|
+
submitUrl: string;
|
|
13
|
+
/** If absent → dialogue disabled, form shown */
|
|
14
|
+
dialogueUrl?: string;
|
|
15
|
+
/** If absent → screenshots disabled */
|
|
16
|
+
screenshotUploadUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
dialogue?: {
|
|
19
|
+
/** Default 3; min 1, max 10 */
|
|
20
|
+
maxTurns?: number;
|
|
21
|
+
/** Default 30_000 */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
};
|
|
24
|
+
screenshots?: {
|
|
25
|
+
/** Default true if screenshotUploadUrl set */
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
/** Default 5_242_880 (5 MB) */
|
|
28
|
+
maxSizeBytes?: number;
|
|
29
|
+
};
|
|
30
|
+
ui?: {
|
|
31
|
+
/** Default 'bottom-right' */
|
|
32
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
|
+
/** Default 'auto' */
|
|
34
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
35
|
+
};
|
|
36
|
+
observability?: {
|
|
37
|
+
/** Default true */
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/** Default 'Feedback/Service' */
|
|
40
|
+
namespace?: string;
|
|
41
|
+
/** Default ['x-trace-id', 'x-request-id'] */
|
|
42
|
+
traceIdHeaders?: string[];
|
|
43
|
+
};
|
|
44
|
+
i18n?: {
|
|
45
|
+
/** Default 'en' */
|
|
46
|
+
locale?: string;
|
|
47
|
+
customTranslations?: Record<string, Record<string, string>>;
|
|
48
|
+
};
|
|
49
|
+
signOff?: {
|
|
50
|
+
/** Default 7; 0 = manual only */
|
|
51
|
+
autoConfirmDays?: number;
|
|
52
|
+
/** Default 3 */
|
|
53
|
+
reminderDays?: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Fully-resolved config with all defaults applied — no undefined fields */
|
|
57
|
+
export interface ResolvedFeedbackConfig {
|
|
58
|
+
appName: string;
|
|
59
|
+
version: string;
|
|
60
|
+
environment: FeedbackEnvironment;
|
|
61
|
+
transport: {
|
|
62
|
+
submitUrl: string;
|
|
63
|
+
dialogueUrl: string | undefined;
|
|
64
|
+
screenshotUploadUrl: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
dialogue: {
|
|
67
|
+
maxTurns: number;
|
|
68
|
+
timeoutMs: number;
|
|
69
|
+
};
|
|
70
|
+
screenshots: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
maxSizeBytes: number;
|
|
73
|
+
};
|
|
74
|
+
ui: {
|
|
75
|
+
position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
76
|
+
theme: 'light' | 'dark' | 'auto';
|
|
77
|
+
};
|
|
78
|
+
observability: {
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
namespace: string;
|
|
81
|
+
traceIdHeaders: string[];
|
|
82
|
+
};
|
|
83
|
+
i18n: {
|
|
84
|
+
locale: string;
|
|
85
|
+
customTranslations: Record<string, Record<string, string>>;
|
|
86
|
+
};
|
|
87
|
+
signOff: {
|
|
88
|
+
autoConfirmDays: number;
|
|
89
|
+
reminderDays: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Validation result with structured errors */
|
|
93
|
+
export interface ConfigValidationResult {
|
|
94
|
+
valid: boolean;
|
|
95
|
+
errors: string[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Validates a FeedbackConfig and returns structured errors.
|
|
99
|
+
* Returns { valid: false, errors: [...] } with actionable messages.
|
|
100
|
+
*/
|
|
101
|
+
export declare function validateConfig(config: Partial<FeedbackConfig>): ConfigValidationResult;
|
|
102
|
+
/**
|
|
103
|
+
* Merges user-supplied partial config with defaults.
|
|
104
|
+
* Returns a fully-resolved config with no undefined fields.
|
|
105
|
+
*/
|
|
106
|
+
export declare function resolveConfig(config: FeedbackConfig): ResolvedFeedbackConfig;
|
|
107
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAElC,SAAS,EAAE;QACT,iDAAiD;QACjD,SAAS,EAAE,MAAM,CAAC;QAClB,gDAAgD;QAChD,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,uCAAuC;QACvC,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IAEF,QAAQ,CAAC,EAAE;QACT,+BAA+B;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,qBAAqB;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,WAAW,CAAC,EAAE;QACZ,8CAA8C;QAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,+BAA+B;QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,EAAE,CAAC,EAAE;QACH,6BAA6B;QAC7B,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;QACrE,qBAAqB;QACrB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;KACnC,CAAC;IAEF,aAAa,CAAC,EAAE;QACd,mBAAmB;QACnB,OAAO,C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,MAAM,EAAE,MAAM,CAAC;QACf,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;KAC5D,CAAC;IAEF,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AASD,+CAA+C;AAC/C,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,sBAAsB,CA2CtF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAmD5E"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain error types for the feedback package.
|
|
3
|
+
*
|
|
4
|
+
* Every error class carries:
|
|
5
|
+
* - code: string constant (usable in switch statements)
|
|
6
|
+
* - retryable: boolean
|
|
7
|
+
*
|
|
8
|
+
* createErrorResponse converts any thrown value to a safe JSON-serialisable object.
|
|
9
|
+
*/
|
|
10
|
+
/** Base class for all feedback domain errors */
|
|
11
|
+
export declare abstract class FeedbackError extends Error {
|
|
12
|
+
readonly cause?: unknown | undefined;
|
|
13
|
+
abstract readonly code: string;
|
|
14
|
+
abstract readonly retryable: boolean;
|
|
15
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
16
|
+
}
|
|
17
|
+
/** Thrown when input validation fails */
|
|
18
|
+
export declare class FeedbackValidationError extends FeedbackError {
|
|
19
|
+
readonly fields?: string[] | undefined;
|
|
20
|
+
readonly code = "FEEDBACK_VALIDATION_ERROR";
|
|
21
|
+
readonly retryable = false;
|
|
22
|
+
constructor(message: string, fields?: string[] | undefined);
|
|
23
|
+
}
|
|
24
|
+
/** Thrown when the transport layer fails (network, server error) */
|
|
25
|
+
export declare class FeedbackTransportError extends FeedbackError {
|
|
26
|
+
readonly statusCode?: number | undefined;
|
|
27
|
+
readonly code = "FEEDBACK_TRANSPORT_ERROR";
|
|
28
|
+
readonly retryable = true;
|
|
29
|
+
constructor(message: string, statusCode?: number | undefined, cause?: unknown);
|
|
30
|
+
}
|
|
31
|
+
/** Thrown when configuration is invalid or missing */
|
|
32
|
+
export declare class FeedbackConfigError extends FeedbackError {
|
|
33
|
+
readonly code = "FEEDBACK_CONFIG_ERROR";
|
|
34
|
+
readonly retryable = false;
|
|
35
|
+
constructor(message: string, cause?: unknown);
|
|
36
|
+
}
|
|
37
|
+
/** Thrown when dialogue exchange fails */
|
|
38
|
+
export declare class FeedbackDialogueError extends FeedbackError {
|
|
39
|
+
readonly code = "FEEDBACK_DIALOGUE_ERROR";
|
|
40
|
+
readonly retryable = true;
|
|
41
|
+
constructor(message: string, cause?: unknown);
|
|
42
|
+
}
|
|
43
|
+
/** Thrown when screenshot capture or upload fails */
|
|
44
|
+
export declare class FeedbackScreenshotError extends FeedbackError {
|
|
45
|
+
readonly code = "FEEDBACK_SCREENSHOT_ERROR";
|
|
46
|
+
readonly retryable = false;
|
|
47
|
+
constructor(message: string, cause?: unknown);
|
|
48
|
+
}
|
|
49
|
+
/** Thrown when a duplicate feedback submission is detected */
|
|
50
|
+
export declare class FeedbackDuplicateError extends FeedbackError {
|
|
51
|
+
readonly existingId: string;
|
|
52
|
+
readonly code = "FEEDBACK_DUPLICATE_ERROR";
|
|
53
|
+
readonly retryable = false;
|
|
54
|
+
constructor(message: string, existingId: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Type guard — returns true if the value is a FeedbackError subclass.
|
|
58
|
+
* Returns false for plain Error instances and other values.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isFeedbackError(e: unknown): e is FeedbackError;
|
|
61
|
+
/** Safe JSON-serialisable error response */
|
|
62
|
+
export interface ErrorResponse {
|
|
63
|
+
code: string;
|
|
64
|
+
message: string;
|
|
65
|
+
retryable: boolean;
|
|
66
|
+
fields?: string[];
|
|
67
|
+
existingId?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Converts any thrown value to a safe JSON-serialisable response object.
|
|
71
|
+
*
|
|
72
|
+
* - FeedbackError subclasses → uses their code, message, retryable
|
|
73
|
+
* - FeedbackValidationError → includes fields
|
|
74
|
+
* - FeedbackDuplicateError → includes existingId
|
|
75
|
+
* - Plain string → { code: 'UNKNOWN_ERROR', message: theString, retryable: false }
|
|
76
|
+
* - Plain Error → { code: 'UNKNOWN_ERROR', message: error.message, retryable: false }
|
|
77
|
+
* - null/undefined/other → { code: 'UNKNOWN_ERROR', message: 'An unknown error occurred', retryable: false }
|
|
78
|
+
*/
|
|
79
|
+
export declare function createErrorResponse(e: unknown): ErrorResponse;
|
|
80
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,gDAAgD;AAChD,8BAAsB,aAAc,SAAQ,KAAK;IAIlB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IAHrD,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEzB,OAAO,EAAE,MAAM,EAAW,KAAK,CAAC,EAAE,OAAO,YAAA;CAMtD;AAMD,yCAAyC;AACzC,qBAAa,uBAAwB,SAAQ,aAAa;IAMtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE;IAL5B,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,QAAQ,CAAC,SAAS,SAAS;gBAGzB,OAAO,EAAE,MAAM,EACN,MAAM,CAAC,EAAE,MAAM,EAAE,YAAA;CAM7B;AAED,oEAAoE;AACpE,qBAAa,sBAAuB,SAAQ,a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