@patch-adams/plugin-feedback 1.0.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/index.cjs +1020 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +331 -0
- package/dist/index.d.ts +331 -0
- package/dist/index.js +1009 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { PatchAdamsPlugin } from '@patch-adams/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Issue subtype definition
|
|
6
|
+
*/
|
|
7
|
+
declare const IssueSubtypeSchema: z.ZodObject<{
|
|
8
|
+
/** Unique identifier for the subtype */
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
/** Display label for the subtype */
|
|
11
|
+
label: z.ZodString;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
}, {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Issue type definition with optional subtypes
|
|
21
|
+
*/
|
|
22
|
+
declare const IssueTypeSchema: z.ZodObject<{
|
|
23
|
+
/** Unique identifier for the issue type */
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
/** Display label for the issue type */
|
|
26
|
+
label: z.ZodString;
|
|
27
|
+
/** Optional subtypes that appear when this type is selected */
|
|
28
|
+
subtypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
/** Unique identifier for the subtype */
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
/** Display label for the subtype */
|
|
32
|
+
label: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}, {
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
}>, "many">>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
subtypes?: {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
id: string;
|
|
49
|
+
label: string;
|
|
50
|
+
subtypes?: {
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
}[] | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Metadata options - what to include with feedback submissions
|
|
57
|
+
*/
|
|
58
|
+
declare const MetadataOptionsSchema: z.ZodObject<{
|
|
59
|
+
/** Include the course ID from LRS bridge (if available) */
|
|
60
|
+
courseId: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
+
/** Include the current lesson/page ID (URL hash or pathname) */
|
|
62
|
+
lessonId: z.ZodDefault<z.ZodBoolean>;
|
|
63
|
+
/** Include the browser user agent */
|
|
64
|
+
userAgent: z.ZodDefault<z.ZodBoolean>;
|
|
65
|
+
/** Include timestamp of submission */
|
|
66
|
+
timestamp: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
+
/** Include the full current URL */
|
|
68
|
+
url: z.ZodDefault<z.ZodBoolean>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
courseId: boolean;
|
|
71
|
+
lessonId: boolean;
|
|
72
|
+
userAgent: boolean;
|
|
73
|
+
timestamp: boolean;
|
|
74
|
+
url: boolean;
|
|
75
|
+
}, {
|
|
76
|
+
courseId?: boolean | undefined;
|
|
77
|
+
lessonId?: boolean | undefined;
|
|
78
|
+
userAgent?: boolean | undefined;
|
|
79
|
+
timestamp?: boolean | undefined;
|
|
80
|
+
url?: boolean | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Default issue types if none are provided
|
|
84
|
+
*/
|
|
85
|
+
declare const DEFAULT_ISSUE_TYPES: z.infer<typeof IssueTypeSchema>[];
|
|
86
|
+
/**
|
|
87
|
+
* Full feedback plugin configuration schema
|
|
88
|
+
*/
|
|
89
|
+
declare const FeedbackConfigSchema: z.ZodObject<{
|
|
90
|
+
/** Whether the feedback plugin is enabled */
|
|
91
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
92
|
+
/** API endpoint URL for submitting feedback (optional - if not set, logs to console) */
|
|
93
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
94
|
+
/** HTTP method for the endpoint (default: POST) */
|
|
95
|
+
method: z.ZodDefault<z.ZodEnum<["POST", "PUT"]>>;
|
|
96
|
+
/** Additional headers to send with the request */
|
|
97
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
98
|
+
/** Position of the feedback tab (left or right side of screen) */
|
|
99
|
+
position: z.ZodDefault<z.ZodEnum<["left", "right"]>>;
|
|
100
|
+
/** Text displayed on the feedback tab */
|
|
101
|
+
tabText: z.ZodDefault<z.ZodString>;
|
|
102
|
+
/** Background color of the feedback tab */
|
|
103
|
+
tabColor: z.ZodDefault<z.ZodString>;
|
|
104
|
+
/** Text color of the feedback tab */
|
|
105
|
+
tabTextColor: z.ZodDefault<z.ZodString>;
|
|
106
|
+
/** Z-index for the feedback widget (default: 9999) */
|
|
107
|
+
zIndex: z.ZodDefault<z.ZodNumber>;
|
|
108
|
+
/** Show star rating field */
|
|
109
|
+
showRating: z.ZodDefault<z.ZodBoolean>;
|
|
110
|
+
/** Whether rating is required to submit */
|
|
111
|
+
ratingRequired: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
/** Number of stars in the rating (default: 5) */
|
|
113
|
+
ratingStars: z.ZodDefault<z.ZodNumber>;
|
|
114
|
+
/** Show issue type dropdown */
|
|
115
|
+
showIssueType: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
+
/** Whether issue type is required to submit */
|
|
117
|
+
issueTypeRequired: z.ZodDefault<z.ZodBoolean>;
|
|
118
|
+
/** Available issue types (uses defaults if not provided) */
|
|
119
|
+
issueTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
120
|
+
/** Unique identifier for the issue type */
|
|
121
|
+
id: z.ZodString;
|
|
122
|
+
/** Display label for the issue type */
|
|
123
|
+
label: z.ZodString;
|
|
124
|
+
/** Optional subtypes that appear when this type is selected */
|
|
125
|
+
subtypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
126
|
+
/** Unique identifier for the subtype */
|
|
127
|
+
id: z.ZodString;
|
|
128
|
+
/** Display label for the subtype */
|
|
129
|
+
label: z.ZodString;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
id: string;
|
|
132
|
+
label: string;
|
|
133
|
+
}, {
|
|
134
|
+
id: string;
|
|
135
|
+
label: string;
|
|
136
|
+
}>, "many">>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
id: string;
|
|
139
|
+
label: string;
|
|
140
|
+
subtypes?: {
|
|
141
|
+
id: string;
|
|
142
|
+
label: string;
|
|
143
|
+
}[] | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
id: string;
|
|
146
|
+
label: string;
|
|
147
|
+
subtypes?: {
|
|
148
|
+
id: string;
|
|
149
|
+
label: string;
|
|
150
|
+
}[] | undefined;
|
|
151
|
+
}>, "many">>;
|
|
152
|
+
/** Show comment textarea */
|
|
153
|
+
showComment: z.ZodDefault<z.ZodBoolean>;
|
|
154
|
+
/** Whether comment is required to submit */
|
|
155
|
+
commentRequired: z.ZodDefault<z.ZodBoolean>;
|
|
156
|
+
/** Maximum length for comments (default: 500) */
|
|
157
|
+
commentMaxLength: z.ZodDefault<z.ZodNumber>;
|
|
158
|
+
/** Placeholder text for comment field (uses translation if not set) */
|
|
159
|
+
commentPlaceholder: z.ZodOptional<z.ZodString>;
|
|
160
|
+
/** Locale for UI text (en or fr) */
|
|
161
|
+
locale: z.ZodDefault<z.ZodEnum<["en", "fr"]>>;
|
|
162
|
+
/** Custom translations (overrides built-in translations) */
|
|
163
|
+
translations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
164
|
+
/** What metadata to include with feedback submissions */
|
|
165
|
+
includeMetadata: z.ZodDefault<z.ZodObject<{
|
|
166
|
+
/** Include the course ID from LRS bridge (if available) */
|
|
167
|
+
courseId: z.ZodDefault<z.ZodBoolean>;
|
|
168
|
+
/** Include the current lesson/page ID (URL hash or pathname) */
|
|
169
|
+
lessonId: z.ZodDefault<z.ZodBoolean>;
|
|
170
|
+
/** Include the browser user agent */
|
|
171
|
+
userAgent: z.ZodDefault<z.ZodBoolean>;
|
|
172
|
+
/** Include timestamp of submission */
|
|
173
|
+
timestamp: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
/** Include the full current URL */
|
|
175
|
+
url: z.ZodDefault<z.ZodBoolean>;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
courseId: boolean;
|
|
178
|
+
lessonId: boolean;
|
|
179
|
+
userAgent: boolean;
|
|
180
|
+
timestamp: boolean;
|
|
181
|
+
url: boolean;
|
|
182
|
+
}, {
|
|
183
|
+
courseId?: boolean | undefined;
|
|
184
|
+
lessonId?: boolean | undefined;
|
|
185
|
+
userAgent?: boolean | undefined;
|
|
186
|
+
timestamp?: boolean | undefined;
|
|
187
|
+
url?: boolean | undefined;
|
|
188
|
+
}>>;
|
|
189
|
+
/** Auto-close modal after successful submission (default: true) */
|
|
190
|
+
autoClose: z.ZodDefault<z.ZodBoolean>;
|
|
191
|
+
/** Delay in ms before auto-closing after success (default: 2000) */
|
|
192
|
+
autoCloseDelay: z.ZodDefault<z.ZodNumber>;
|
|
193
|
+
/** Enable debug logging (default: false) */
|
|
194
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
enabled: boolean;
|
|
197
|
+
method: "POST" | "PUT";
|
|
198
|
+
position: "left" | "right";
|
|
199
|
+
tabText: string;
|
|
200
|
+
tabColor: string;
|
|
201
|
+
tabTextColor: string;
|
|
202
|
+
zIndex: number;
|
|
203
|
+
showRating: boolean;
|
|
204
|
+
ratingRequired: boolean;
|
|
205
|
+
ratingStars: number;
|
|
206
|
+
showIssueType: boolean;
|
|
207
|
+
issueTypeRequired: boolean;
|
|
208
|
+
showComment: boolean;
|
|
209
|
+
commentRequired: boolean;
|
|
210
|
+
commentMaxLength: number;
|
|
211
|
+
locale: "en" | "fr";
|
|
212
|
+
includeMetadata: {
|
|
213
|
+
courseId: boolean;
|
|
214
|
+
lessonId: boolean;
|
|
215
|
+
userAgent: boolean;
|
|
216
|
+
timestamp: boolean;
|
|
217
|
+
url: boolean;
|
|
218
|
+
};
|
|
219
|
+
autoClose: boolean;
|
|
220
|
+
autoCloseDelay: number;
|
|
221
|
+
debug: boolean;
|
|
222
|
+
endpoint?: string | undefined;
|
|
223
|
+
headers?: Record<string, string> | undefined;
|
|
224
|
+
issueTypes?: {
|
|
225
|
+
id: string;
|
|
226
|
+
label: string;
|
|
227
|
+
subtypes?: {
|
|
228
|
+
id: string;
|
|
229
|
+
label: string;
|
|
230
|
+
}[] | undefined;
|
|
231
|
+
}[] | undefined;
|
|
232
|
+
commentPlaceholder?: string | undefined;
|
|
233
|
+
translations?: Record<string, string> | undefined;
|
|
234
|
+
}, {
|
|
235
|
+
enabled?: boolean | undefined;
|
|
236
|
+
endpoint?: string | undefined;
|
|
237
|
+
method?: "POST" | "PUT" | undefined;
|
|
238
|
+
headers?: Record<string, string> | undefined;
|
|
239
|
+
position?: "left" | "right" | undefined;
|
|
240
|
+
tabText?: string | undefined;
|
|
241
|
+
tabColor?: string | undefined;
|
|
242
|
+
tabTextColor?: string | undefined;
|
|
243
|
+
zIndex?: number | undefined;
|
|
244
|
+
showRating?: boolean | undefined;
|
|
245
|
+
ratingRequired?: boolean | undefined;
|
|
246
|
+
ratingStars?: number | undefined;
|
|
247
|
+
showIssueType?: boolean | undefined;
|
|
248
|
+
issueTypeRequired?: boolean | undefined;
|
|
249
|
+
issueTypes?: {
|
|
250
|
+
id: string;
|
|
251
|
+
label: string;
|
|
252
|
+
subtypes?: {
|
|
253
|
+
id: string;
|
|
254
|
+
label: string;
|
|
255
|
+
}[] | undefined;
|
|
256
|
+
}[] | undefined;
|
|
257
|
+
showComment?: boolean | undefined;
|
|
258
|
+
commentRequired?: boolean | undefined;
|
|
259
|
+
commentMaxLength?: number | undefined;
|
|
260
|
+
commentPlaceholder?: string | undefined;
|
|
261
|
+
locale?: "en" | "fr" | undefined;
|
|
262
|
+
translations?: Record<string, string> | undefined;
|
|
263
|
+
includeMetadata?: {
|
|
264
|
+
courseId?: boolean | undefined;
|
|
265
|
+
lessonId?: boolean | undefined;
|
|
266
|
+
userAgent?: boolean | undefined;
|
|
267
|
+
timestamp?: boolean | undefined;
|
|
268
|
+
url?: boolean | undefined;
|
|
269
|
+
} | undefined;
|
|
270
|
+
autoClose?: boolean | undefined;
|
|
271
|
+
autoCloseDelay?: number | undefined;
|
|
272
|
+
debug?: boolean | undefined;
|
|
273
|
+
}>;
|
|
274
|
+
type FeedbackConfig = z.infer<typeof FeedbackConfigSchema>;
|
|
275
|
+
type IssueType = z.infer<typeof IssueTypeSchema>;
|
|
276
|
+
type IssueSubtype = z.infer<typeof IssueSubtypeSchema>;
|
|
277
|
+
type MetadataOptions = z.infer<typeof MetadataOptionsSchema>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Generate the feedback widget JavaScript code.
|
|
281
|
+
* This produces a self-contained IIFE that creates and manages the feedback widget.
|
|
282
|
+
*/
|
|
283
|
+
declare function generateFeedbackWidget(config: FeedbackConfig): string;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Generate the CSS styles for the feedback widget.
|
|
287
|
+
* Styles are scoped with #pa-feedback-container to avoid conflicts.
|
|
288
|
+
*/
|
|
289
|
+
declare function generateFeedbackStyles(config: FeedbackConfig): string;
|
|
290
|
+
|
|
291
|
+
interface Translations {
|
|
292
|
+
title: string;
|
|
293
|
+
ratingLabel: string;
|
|
294
|
+
issueTypeLabel: string;
|
|
295
|
+
selectIssueType: string;
|
|
296
|
+
subtypeLabel: string;
|
|
297
|
+
selectSubtype: string;
|
|
298
|
+
commentLabel: string;
|
|
299
|
+
commentPlaceholder: string;
|
|
300
|
+
submit: string;
|
|
301
|
+
submitting: string;
|
|
302
|
+
thankYou: string;
|
|
303
|
+
errorSubmitting: string;
|
|
304
|
+
errorRequired: string;
|
|
305
|
+
characterCount: string;
|
|
306
|
+
}
|
|
307
|
+
declare const translations: Record<string, Translations>;
|
|
308
|
+
declare function getTranslations(locale: string, overrides?: Record<string, string>): Translations;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @patch-adams/plugin-feedback
|
|
312
|
+
*
|
|
313
|
+
* Feedback widget plugin for Patch-Adams.
|
|
314
|
+
* Injects a customizable feedback form into patched Rise courses.
|
|
315
|
+
*
|
|
316
|
+
* Features:
|
|
317
|
+
* - Star rating
|
|
318
|
+
* - Issue type/subtype selection
|
|
319
|
+
* - Comment text area
|
|
320
|
+
* - Multi-language support (en/fr)
|
|
321
|
+
* - Customizable appearance
|
|
322
|
+
* - Automatic metadata collection
|
|
323
|
+
* - Configurable API endpoint
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Feedback plugin for Patch-Adams
|
|
328
|
+
*/
|
|
329
|
+
declare const feedbackPlugin: PatchAdamsPlugin<FeedbackConfig>;
|
|
330
|
+
|
|
331
|
+
export { DEFAULT_ISSUE_TYPES, type FeedbackConfig, FeedbackConfigSchema, type IssueSubtype, type IssueType, type MetadataOptions, type Translations, feedbackPlugin as default, feedbackPlugin, generateFeedbackStyles, generateFeedbackWidget, getTranslations, translations };
|