@vicket/create-support 1.1.1

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.
Files changed (55) hide show
  1. package/README.md +52 -0
  2. package/bin/create-vicket-support.js +389 -0
  3. package/package.json +18 -0
  4. package/templates/next/src/app/api/vicket/[...path]/route.ts +59 -0
  5. package/templates/next/src/app/components/vicket/TicketDialog.tsx +514 -0
  6. package/templates/next/src/app/support/page.tsx +358 -0
  7. package/templates/next/src/app/ticket/page.tsx +483 -0
  8. package/templates/next/src/app/utils/vicket/api.ts +149 -0
  9. package/templates/next/src/app/utils/vicket/types.ts +85 -0
  10. package/templates/next/src/app/utils/vicket/utils.ts +49 -0
  11. package/templates/next/src/app/vicket.css +1325 -0
  12. package/templates/nuxt/app/assets/css/vicket.css +1325 -0
  13. package/templates/nuxt/app/components/VicketTicketDialog.vue +499 -0
  14. package/templates/nuxt/app/composables/useVicket.ts +274 -0
  15. package/templates/nuxt/app/pages/support.vue +303 -0
  16. package/templates/nuxt/app/pages/ticket.vue +434 -0
  17. package/templates/nuxt/server/api/vicket/[...path].ts +85 -0
  18. package/templates/sveltekit/src/lib/vicket/TicketDialog.svelte +459 -0
  19. package/templates/sveltekit/src/lib/vicket/api.ts +162 -0
  20. package/templates/sveltekit/src/lib/vicket/types.ts +87 -0
  21. package/templates/sveltekit/src/lib/vicket/utils.ts +55 -0
  22. package/templates/sveltekit/src/lib/vicket.css +1325 -0
  23. package/templates/sveltekit/src/routes/api/vicket/[...path]/+server.ts +77 -0
  24. package/templates/sveltekit/src/routes/support/+page.svelte +316 -0
  25. package/templates/sveltekit/src/routes/ticket/+page.svelte +418 -0
  26. package/templates-tailwind/next/src/app/api/vicket/init/route.ts +24 -0
  27. package/templates-tailwind/next/src/app/api/vicket/messages/route.ts +36 -0
  28. package/templates-tailwind/next/src/app/api/vicket/thread/route.ts +27 -0
  29. package/templates-tailwind/next/src/app/api/vicket/tickets/route.ts +37 -0
  30. package/templates-tailwind/next/src/app/support/page.tsx +5 -0
  31. package/templates-tailwind/next/src/app/ticket/page.tsx +10 -0
  32. package/templates-tailwind/next/src/components/vicket/support-page.tsx +359 -0
  33. package/templates-tailwind/next/src/components/vicket/ticket-dialog.tsx +306 -0
  34. package/templates-tailwind/next/src/components/vicket/ticket-page.tsx +425 -0
  35. package/templates-tailwind/next/src/lib/vicket.ts +257 -0
  36. package/templates-tailwind/nuxt/app/components/VicketSupportPage.vue +317 -0
  37. package/templates-tailwind/nuxt/app/components/VicketTicketDialog.vue +444 -0
  38. package/templates-tailwind/nuxt/app/components/VicketTicketPage.vue +449 -0
  39. package/templates-tailwind/nuxt/app/composables/use-vicket.ts +249 -0
  40. package/templates-tailwind/nuxt/app/pages/support.vue +3 -0
  41. package/templates-tailwind/nuxt/app/pages/ticket.vue +3 -0
  42. package/templates-tailwind/nuxt/server/api/vicket/init.get.ts +22 -0
  43. package/templates-tailwind/nuxt/server/api/vicket/messages.post.ts +56 -0
  44. package/templates-tailwind/nuxt/server/api/vicket/thread.get.ts +26 -0
  45. package/templates-tailwind/nuxt/server/api/vicket/tickets.post.ts +53 -0
  46. package/templates-tailwind/sveltekit/src/lib/vicket/SupportPage.svelte +395 -0
  47. package/templates-tailwind/sveltekit/src/lib/vicket/TicketDialog.svelte +406 -0
  48. package/templates-tailwind/sveltekit/src/lib/vicket/TicketPage.svelte +465 -0
  49. package/templates-tailwind/sveltekit/src/lib/vicket/index.ts +257 -0
  50. package/templates-tailwind/sveltekit/src/routes/api/vicket/init/+server.ts +22 -0
  51. package/templates-tailwind/sveltekit/src/routes/api/vicket/messages/+server.ts +40 -0
  52. package/templates-tailwind/sveltekit/src/routes/api/vicket/thread/+server.ts +25 -0
  53. package/templates-tailwind/sveltekit/src/routes/api/vicket/tickets/+server.ts +37 -0
  54. package/templates-tailwind/sveltekit/src/routes/support/+page.svelte +5 -0
  55. package/templates-tailwind/sveltekit/src/routes/ticket/+page.svelte +5 -0
@@ -0,0 +1,85 @@
1
+ /* ---------------------------------------------- */
2
+ /* Shared types for Vicket support pages */
3
+ /* ---------------------------------------------- */
4
+
5
+ export type TemplateOption = {
6
+ id: string;
7
+ label: string;
8
+ value: string;
9
+ };
10
+
11
+ export type TemplateQuestion = {
12
+ id: string;
13
+ label: string;
14
+ type: "TEXT" | "TEXTAREA" | "SELECT" | "CHECKBOX" | "DATE" | "FILE";
15
+ required: boolean;
16
+ order: number;
17
+ options?: TemplateOption[];
18
+ };
19
+
20
+ export type Template = {
21
+ id: string;
22
+ name: string;
23
+ description: string;
24
+ questions: TemplateQuestion[];
25
+ };
26
+
27
+ export type Article = {
28
+ id: string;
29
+ title: string;
30
+ slug: string;
31
+ content: string;
32
+ };
33
+
34
+ export type Faq = {
35
+ id: string;
36
+ question: string;
37
+ answer: string;
38
+ };
39
+
40
+ export type SupportInitResponse = {
41
+ success: boolean;
42
+ data?: {
43
+ website?: { name?: string };
44
+ templates: Template[];
45
+ articles?: Article[];
46
+ faqs?: Faq[];
47
+ };
48
+ error?: string;
49
+ };
50
+
51
+ export type FormValues = {
52
+ email: string;
53
+ title: string;
54
+ answers: Record<string, unknown>;
55
+ };
56
+
57
+ export type Attachment = {
58
+ id: string;
59
+ original_filename: string;
60
+ url: string;
61
+ };
62
+
63
+ export type Message = {
64
+ id: string;
65
+ content: string;
66
+ author_type: "reporter" | "user" | "system";
67
+ created_at: string;
68
+ attachments?: Attachment[];
69
+ };
70
+
71
+ export type TicketAnswer = {
72
+ id: string;
73
+ question_label: string;
74
+ answer: string;
75
+ attachments?: Attachment[];
76
+ };
77
+
78
+ export type TicketThread = {
79
+ id: string;
80
+ title: string;
81
+ status?: { label: string };
82
+ priority?: { label: string };
83
+ messages: Message[];
84
+ answers?: TicketAnswer[];
85
+ };
@@ -0,0 +1,49 @@
1
+ /* ---------------------------------------------- */
2
+ /* Shared utility functions for Vicket pages */
3
+ /* ---------------------------------------------- */
4
+
5
+ export function cn(...classes: (string | false | null | undefined)[]): string {
6
+ return classes.filter(Boolean).join(" ");
7
+ }
8
+
9
+ export function stripHtml(html: string): string {
10
+ return html.replace(/<[^>]*>/g, "");
11
+ }
12
+
13
+ export function sanitizeHtml(html: string): string {
14
+ return html
15
+ .replace(/<script[\s\S]*?<\/script>/gi, "")
16
+ .replace(/\son\w+="[^"]*"/gi, "")
17
+ .replace(/\son\w+='[^']*'/gi, "")
18
+ .replace(/href\s*=\s*"javascript:[^"]*"/gi, 'href="#"')
19
+ .replace(/href\s*=\s*'javascript:[^']*'/gi, "href='#'");
20
+ }
21
+
22
+ export function formatDate(iso: string): string {
23
+ try {
24
+ return new Intl.DateTimeFormat("en", {
25
+ month: "short",
26
+ day: "numeric",
27
+ hour: "numeric",
28
+ minute: "2-digit",
29
+ }).format(new Date(iso));
30
+ } catch {
31
+ return iso;
32
+ }
33
+ }
34
+
35
+ export function isFileAnswer(answer: string): boolean {
36
+ return answer?.includes("__isFile:true") || answer?.includes("map[__isFile");
37
+ }
38
+
39
+ export function formatAnswerText(value: string): string {
40
+ if (!value) return "";
41
+
42
+ const trimmed = value.trim();
43
+ if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
44
+ const rawItems = trimmed.slice(1, -1).trim();
45
+ return rawItems.length > 0 ? rawItems.split(/\s+/).join(", ") : "";
46
+ }
47
+
48
+ return value;
49
+ }