@escalated-dev/escalated 0.7.0 → 0.8.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.
Files changed (181) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +36 -1
  3. package/package.json +16 -7
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -55
  6. package/src/components/ActivityTimeline.vue +83 -83
  7. package/src/components/AdminDashboard.stories.js +1423 -1095
  8. package/src/components/AgentLoadIndicator.stories.js +37 -37
  9. package/src/components/AgentLoadIndicator.vue +49 -49
  10. package/src/components/AgentPerformanceCard.vue +44 -44
  11. package/src/components/ArticleEditor.vue +82 -82
  12. package/src/components/AssigneeSelect.vue +37 -37
  13. package/src/components/AttachmentList.vue +13 -1
  14. package/src/components/AuditLogEntry.vue +95 -95
  15. package/src/components/BulkActionBar.vue +166 -166
  16. package/src/components/CategoryTree.vue +89 -89
  17. package/src/components/ChartWidget.vue +46 -46
  18. package/src/components/ChatActionBar.vue +226 -0
  19. package/src/components/ChatBubble.vue +162 -0
  20. package/src/components/ChatComposer.vue +308 -0
  21. package/src/components/ChatQueue.vue +222 -0
  22. package/src/components/ChatThread.vue +197 -0
  23. package/src/components/CollisionWarning.stories.js +30 -30
  24. package/src/components/CollisionWarning.vue +68 -68
  25. package/src/components/ConditionalFieldRules.vue +135 -135
  26. package/src/components/ContextPanel.vue +66 -66
  27. package/src/components/ContextPanelSection.vue +65 -65
  28. package/src/components/CustomFieldRenderer.vue +159 -159
  29. package/src/components/EscalatedLayout.vue +35 -6
  30. package/src/components/FileDropzone.vue +57 -57
  31. package/src/components/FollowButton.stories.js +30 -30
  32. package/src/components/FollowButton.vue +88 -88
  33. package/src/components/KeyboardShortcutHelp.vue +213 -213
  34. package/src/components/KnowledgePanel.vue +122 -122
  35. package/src/components/KpiCard.stories.js +32 -32
  36. package/src/components/KpiCard.vue +88 -88
  37. package/src/components/MacroDropdown.vue +150 -150
  38. package/src/components/MentionDropdown.vue +154 -0
  39. package/src/components/MetricComparison.vue +89 -0
  40. package/src/components/PercentileChart.vue +67 -0
  41. package/src/components/PeriodSelector.vue +98 -0
  42. package/src/components/PermissionMatrix.vue +107 -107
  43. package/src/components/PinnedNotes.vue +129 -129
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +46 -2
  46. package/src/components/PriorityBadge.stories.js +33 -33
  47. package/src/components/PriorityBadge.vue +46 -46
  48. package/src/components/ReplyComposer.vue +81 -18
  49. package/src/components/ReplyThread.vue +40 -2
  50. package/src/components/ReportChart.vue +395 -0
  51. package/src/components/ReportExportButton.vue +108 -0
  52. package/src/components/SatisfactionRating.vue +180 -180
  53. package/src/components/SaveViewDialog.vue +172 -0
  54. package/src/components/SavedViewSidebar.vue +208 -0
  55. package/src/components/ScheduleEditor.vue +104 -104
  56. package/src/components/SideConversation.vue +165 -165
  57. package/src/components/SideConversationList.vue +147 -147
  58. package/src/components/SkillTagManager.vue +83 -79
  59. package/src/components/SlaComplianceChart.vue +46 -53
  60. package/src/components/SlaTimer.stories.js +35 -35
  61. package/src/components/SlaTimer.vue +62 -62
  62. package/src/components/SnoozeButton.vue +247 -0
  63. package/src/components/StatsCard.stories.js +24 -24
  64. package/src/components/StatsCard.vue +58 -58
  65. package/src/components/StatusBadge.stories.js +53 -53
  66. package/src/components/StatusBadge.vue +78 -78
  67. package/src/components/TagSelect.vue +84 -84
  68. package/src/components/TicketFilters.vue +270 -225
  69. package/src/components/TicketLinkPanel.vue +193 -193
  70. package/src/components/TicketList.vue +655 -594
  71. package/src/components/TicketMergeDialog.vue +157 -157
  72. package/src/components/TicketSplitDialog.vue +98 -0
  73. package/src/components/TotpInput.stories.js +9 -9
  74. package/src/components/TotpInput.vue +81 -81
  75. package/src/components/TwoFactorSetup.vue +113 -113
  76. package/src/components/VariableTokenInput.vue +111 -0
  77. package/src/components/WorkflowActionConfig.vue +287 -0
  78. package/src/components/WorkflowActionList.vue +350 -0
  79. package/src/components/WorkflowConditionBuilder.vue +265 -0
  80. package/src/components/WorkflowTriggerSelector.vue +125 -0
  81. package/src/composables/useChat.js +187 -0
  82. package/src/composables/useI18n.js +30 -8
  83. package/src/composables/useKeyboardShortcuts.js +46 -46
  84. package/src/composables/useMentions.js +134 -0
  85. package/src/composables/usePluginExtensions.js +159 -159
  86. package/src/composables/usePluginHooks.js +65 -65
  87. package/src/composables/useRealtime.js +182 -0
  88. package/src/defineEscalatedPlugin.js +76 -76
  89. package/src/index.js +84 -72
  90. package/src/locales/README.md +13 -0
  91. package/src/locales/ar.json +727 -0
  92. package/src/locales/de.json +678 -430
  93. package/src/locales/en.json +717 -455
  94. package/src/locales/es.json +679 -430
  95. package/src/locales/fr.json +680 -431
  96. package/src/locales/index.js +12 -2
  97. package/src/locales/it.json +727 -0
  98. package/src/locales/ja.json +727 -0
  99. package/src/locales/ko.json +727 -0
  100. package/src/locales/nl.json +727 -0
  101. package/src/locales/pl.json +727 -0
  102. package/src/locales/pt-BR.json +727 -0
  103. package/src/locales/ru.json +727 -0
  104. package/src/locales/tr.json +727 -0
  105. package/src/locales/zh-CN.json +727 -0
  106. package/src/pages/Admin/ApiTokens/Index.vue +381 -381
  107. package/src/pages/Admin/AuditLog/Index.vue +154 -154
  108. package/src/pages/Admin/BusinessHours/Form.vue +172 -172
  109. package/src/pages/Admin/BusinessHours/Index.vue +113 -113
  110. package/src/pages/Admin/CannedResponses/Index.vue +127 -127
  111. package/src/pages/Admin/Capacity/Index.vue +134 -134
  112. package/src/pages/Admin/CustomFields/Form.vue +195 -195
  113. package/src/pages/Admin/CustomFields/Index.vue +134 -134
  114. package/src/pages/Admin/CustomObjects/Form.vue +202 -202
  115. package/src/pages/Admin/CustomObjects/Index.vue +127 -127
  116. package/src/pages/Admin/CustomObjects/Records.vue +228 -228
  117. package/src/pages/Admin/Departments/Form.vue +75 -75
  118. package/src/pages/Admin/Departments/Index.vue +110 -109
  119. package/src/pages/Admin/EscalationRules/Form.vue +157 -157
  120. package/src/pages/Admin/EscalationRules/Index.vue +178 -178
  121. package/src/pages/Admin/Import/Connect.vue +0 -1
  122. package/src/pages/Admin/Import/Index.vue +1 -1
  123. package/src/pages/Admin/Import/Progress.vue +1 -1
  124. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -142
  125. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -195
  126. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -193
  127. package/src/pages/Admin/Macros/Index.vue +448 -448
  128. package/src/pages/Admin/Plugins/Index.vue +327 -327
  129. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  130. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -115
  131. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  132. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  133. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  134. package/src/pages/Admin/Reports/CsatReport.vue +127 -127
  135. package/src/pages/Admin/Reports/Dashboard.vue +36 -21
  136. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  137. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  138. package/src/pages/Admin/Reports/SlaReport.vue +162 -166
  139. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  140. package/src/pages/Admin/Reports.vue +206 -206
  141. package/src/pages/Admin/Roles/Form.vue +71 -71
  142. package/src/pages/Admin/Roles/Index.vue +122 -122
  143. package/src/pages/Admin/Settings/CsatSettings.vue +165 -165
  144. package/src/pages/Admin/Settings/DataRetention.vue +182 -182
  145. package/src/pages/Admin/Settings/EmailSettings.vue +243 -243
  146. package/src/pages/Admin/Settings/Sandbox.vue +135 -135
  147. package/src/pages/Admin/Settings/SsoSettings.vue +218 -218
  148. package/src/pages/Admin/Settings/TwoFactor.vue +110 -110
  149. package/src/pages/Admin/Settings.vue +1008 -468
  150. package/src/pages/Admin/Skills/Form.vue +193 -53
  151. package/src/pages/Admin/Skills/Index.vue +105 -94
  152. package/src/pages/Admin/SlaPolicies/Form.vue +118 -118
  153. package/src/pages/Admin/SlaPolicies/Index.vue +121 -120
  154. package/src/pages/Admin/Statuses/Form.vue +114 -114
  155. package/src/pages/Admin/Statuses/Index.vue +153 -153
  156. package/src/pages/Admin/Tags/Index.vue +191 -191
  157. package/src/pages/Admin/Tickets/Index.vue +126 -91
  158. package/src/pages/Admin/Tickets/Show.vue +29 -0
  159. package/src/pages/Admin/Users/Index.vue +145 -0
  160. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -120
  161. package/src/pages/Admin/Webhooks/Form.vue +110 -110
  162. package/src/pages/Admin/Webhooks/Index.vue +136 -136
  163. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  164. package/src/pages/Admin/Workflows/Index.vue +235 -0
  165. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  166. package/src/pages/Agent/TicketIndex.vue +112 -88
  167. package/src/pages/Agent/TicketShow.vue +192 -60
  168. package/src/pages/Customer/Create.vue +1 -1
  169. package/src/pages/Customer/Index.vue +26 -1
  170. package/src/pages/Customer/KnowledgeBase/Article.vue +4 -2
  171. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -151
  172. package/src/pages/Customer/Show.vue +69 -63
  173. package/src/pages/Guest/Create.vue +40 -15
  174. package/src/pages/Guest/Show.vue +124 -93
  175. package/src/plugin.js +26 -1
  176. package/src/utils/mentionHighlight.js +24 -0
  177. package/src/utils/sanitizeHtml.js +78 -64
  178. package/src/widget/EscalatedWidget.vue +804 -0
  179. package/src/widget/index.js +254 -0
  180. package/src/pages/Admin/Automations/Form.vue +0 -184
  181. package/src/pages/Admin/Automations/Index.vue +0 -129
@@ -1,159 +1,159 @@
1
- import { computed } from 'vue';
2
- import { usePage } from '@inertiajs/vue3';
3
-
4
- /**
5
- * Composable for reading plugin extensions from Inertia shared props.
6
- *
7
- * The Laravel backend (escalated-laravel) shares plugin UI extensions via
8
- * `$page.props.escalated.plugins`, which contains:
9
- * - menuItems: Array of navigation items injected by plugins
10
- * - dashboardWidgets: Array of widget definitions for the agent dashboard
11
- * - pageComponents: Object mapping slot names to arrays of component definitions
12
- *
13
- * @returns {Object} Plugin extension data and helper functions
14
- */
15
- export function usePluginExtensions() {
16
- const page = usePage();
17
-
18
- const pluginData = computed(() => page.props?.escalated?.plugins || {});
19
-
20
- /**
21
- * Menu items injected by plugins, sorted by position.
22
- * Each item: { label, route, icon, position, permission, badge, submenu }
23
- */
24
- const menuItems = computed(() => {
25
- const items = pluginData.value.menuItems || [];
26
- return [...items].sort((a, b) => (a.position || 100) - (b.position || 100));
27
- });
28
-
29
- /**
30
- * Dashboard widgets injected by plugins, sorted by position.
31
- * Each widget: { id, title, component, plugin, data, position, width }
32
- */
33
- const dashboardWidgets = computed(() => {
34
- const widgets = pluginData.value.dashboardWidgets || [];
35
- return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
36
- });
37
-
38
- /**
39
- * Ticket actions injected by plugins (e.g., "Escalate to Jira", "Send Approval").
40
- * Each action: { id, label, icon, handler, position, permission, context }
41
- * context: 'agent' | 'admin' | 'both'
42
- */
43
- const ticketActions = computed(() => {
44
- const actions = pluginData.value.ticketActions || [];
45
- return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
46
- });
47
-
48
- /**
49
- * Sidebar panels injected by plugins for the ticket detail context panel.
50
- * Each panel: { id, title, component, plugin, position, collapsed, icon }
51
- */
52
- const sidebarPanels = computed(() => {
53
- const panels = pluginData.value.sidebarPanels || [];
54
- return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
55
- });
56
-
57
- /**
58
- * Custom ticket fields injected by plugins for ticket creation/edit forms.
59
- * Each field: { id, label, type, name, options, required, position, plugin }
60
- * type: 'text' | 'textarea' | 'select' | 'checkbox' | 'date' | 'number'
61
- */
62
- const ticketFields = computed(() => {
63
- const fields = pluginData.value.ticketFields || [];
64
- return [...fields].sort((a, b) => (a.position || 100) - (b.position || 100));
65
- });
66
-
67
- /**
68
- * Reply composer actions injected by plugins (e.g., "AI Suggest", "Insert KB Article").
69
- * Each action: { id, label, icon, handler, component, plugin, position }
70
- */
71
- const composerActions = computed(() => {
72
- const actions = pluginData.value.composerActions || [];
73
- return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
74
- });
75
-
76
- /**
77
- * Report widgets injected by plugins for the admin reports page.
78
- * Each widget: { id, title, component, plugin, data, position, width }
79
- */
80
- const reportWidgets = computed(() => {
81
- const widgets = pluginData.value.reportWidgets || [];
82
- return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
83
- });
84
-
85
- /**
86
- * Settings panels injected by plugins for the admin settings page.
87
- * Each panel: { id, title, component, plugin, position, icon }
88
- */
89
- const settingsPanels = computed(() => {
90
- const panels = pluginData.value.settingsPanels || [];
91
- return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
92
- });
93
-
94
- /**
95
- * Notification channels registered by plugins (e.g., Slack, SMS, WhatsApp).
96
- * Each channel: { id, label, icon, plugin, configComponent }
97
- */
98
- const notificationChannels = computed(() => {
99
- const channels = pluginData.value.notificationChannels || [];
100
- return [...channels].sort((a, b) => (a.position || 100) - (b.position || 100));
101
- });
102
-
103
- /**
104
- * Custom ticket list columns injected by plugins.
105
- * Each column: { id, label, key, component, plugin, position, width }
106
- */
107
- const ticketListColumns = computed(() => {
108
- const columns = pluginData.value.ticketListColumns || [];
109
- return [...columns].sort((a, b) => (a.position || 100) - (b.position || 100));
110
- });
111
-
112
- /**
113
- * Get plugin components for a specific page slot, sorted by position.
114
- *
115
- * @param {string} pageName - The page name (e.g. 'dashboard', 'ticket.show')
116
- * @param {string} slotName - The slot name (e.g. 'header', 'sidebar', 'footer')
117
- * @returns {Array} Sorted array of component definitions for the given slot
118
- */
119
- function getPageComponents(pageName, slotName) {
120
- const key = `${pageName}.${slotName}`;
121
- const components = pluginData.value.pageComponents || {};
122
- return [...(components[key] || [])].sort((a, b) => (a.position || 100) - (b.position || 100));
123
- }
124
-
125
- /**
126
- * Check whether any plugins have registered extensions.
127
- */
128
- const hasPlugins = computed(() => {
129
- return (
130
- menuItems.value.length > 0 ||
131
- dashboardWidgets.value.length > 0 ||
132
- Object.keys(pluginData.value.pageComponents || {}).length > 0 ||
133
- ticketActions.value.length > 0 ||
134
- sidebarPanels.value.length > 0 ||
135
- ticketFields.value.length > 0 ||
136
- composerActions.value.length > 0 ||
137
- reportWidgets.value.length > 0 ||
138
- settingsPanels.value.length > 0 ||
139
- notificationChannels.value.length > 0 ||
140
- ticketListColumns.value.length > 0
141
- );
142
- });
143
-
144
- return {
145
- pluginData,
146
- menuItems,
147
- dashboardWidgets,
148
- ticketActions,
149
- sidebarPanels,
150
- ticketFields,
151
- composerActions,
152
- reportWidgets,
153
- settingsPanels,
154
- notificationChannels,
155
- ticketListColumns,
156
- getPageComponents,
157
- hasPlugins,
158
- };
159
- }
1
+ import { computed } from 'vue';
2
+ import { usePage } from '@inertiajs/vue3';
3
+
4
+ /**
5
+ * Composable for reading plugin extensions from Inertia shared props.
6
+ *
7
+ * The Laravel backend (escalated-laravel) shares plugin UI extensions via
8
+ * `$page.props.escalated.plugins`, which contains:
9
+ * - menuItems: Array of navigation items injected by plugins
10
+ * - dashboardWidgets: Array of widget definitions for the agent dashboard
11
+ * - pageComponents: Object mapping slot names to arrays of component definitions
12
+ *
13
+ * @returns {Object} Plugin extension data and helper functions
14
+ */
15
+ export function usePluginExtensions() {
16
+ const page = usePage();
17
+
18
+ const pluginData = computed(() => page.props?.escalated?.plugins || {});
19
+
20
+ /**
21
+ * Menu items injected by plugins, sorted by position.
22
+ * Each item: { label, route, icon, position, permission, badge, submenu }
23
+ */
24
+ const menuItems = computed(() => {
25
+ const items = pluginData.value.menuItems || [];
26
+ return [...items].sort((a, b) => (a.position || 100) - (b.position || 100));
27
+ });
28
+
29
+ /**
30
+ * Dashboard widgets injected by plugins, sorted by position.
31
+ * Each widget: { id, title, component, plugin, data, position, width }
32
+ */
33
+ const dashboardWidgets = computed(() => {
34
+ const widgets = pluginData.value.dashboardWidgets || [];
35
+ return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
36
+ });
37
+
38
+ /**
39
+ * Ticket actions injected by plugins (e.g., "Escalate to Jira", "Send Approval").
40
+ * Each action: { id, label, icon, handler, position, permission, context }
41
+ * context: 'agent' | 'admin' | 'both'
42
+ */
43
+ const ticketActions = computed(() => {
44
+ const actions = pluginData.value.ticketActions || [];
45
+ return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
46
+ });
47
+
48
+ /**
49
+ * Sidebar panels injected by plugins for the ticket detail context panel.
50
+ * Each panel: { id, title, component, plugin, position, collapsed, icon }
51
+ */
52
+ const sidebarPanels = computed(() => {
53
+ const panels = pluginData.value.sidebarPanels || [];
54
+ return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
55
+ });
56
+
57
+ /**
58
+ * Custom ticket fields injected by plugins for ticket creation/edit forms.
59
+ * Each field: { id, label, type, name, options, required, position, plugin }
60
+ * type: 'text' | 'textarea' | 'select' | 'checkbox' | 'date' | 'number'
61
+ */
62
+ const ticketFields = computed(() => {
63
+ const fields = pluginData.value.ticketFields || [];
64
+ return [...fields].sort((a, b) => (a.position || 100) - (b.position || 100));
65
+ });
66
+
67
+ /**
68
+ * Reply composer actions injected by plugins (e.g., "AI Suggest", "Insert KB Article").
69
+ * Each action: { id, label, icon, handler, component, plugin, position }
70
+ */
71
+ const composerActions = computed(() => {
72
+ const actions = pluginData.value.composerActions || [];
73
+ return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
74
+ });
75
+
76
+ /**
77
+ * Report widgets injected by plugins for the admin reports page.
78
+ * Each widget: { id, title, component, plugin, data, position, width }
79
+ */
80
+ const reportWidgets = computed(() => {
81
+ const widgets = pluginData.value.reportWidgets || [];
82
+ return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
83
+ });
84
+
85
+ /**
86
+ * Settings panels injected by plugins for the admin settings page.
87
+ * Each panel: { id, title, component, plugin, position, icon }
88
+ */
89
+ const settingsPanels = computed(() => {
90
+ const panels = pluginData.value.settingsPanels || [];
91
+ return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
92
+ });
93
+
94
+ /**
95
+ * Notification channels registered by plugins (e.g., Slack, SMS, WhatsApp).
96
+ * Each channel: { id, label, icon, plugin, configComponent }
97
+ */
98
+ const notificationChannels = computed(() => {
99
+ const channels = pluginData.value.notificationChannels || [];
100
+ return [...channels].sort((a, b) => (a.position || 100) - (b.position || 100));
101
+ });
102
+
103
+ /**
104
+ * Custom ticket list columns injected by plugins.
105
+ * Each column: { id, label, key, component, plugin, position, width }
106
+ */
107
+ const ticketListColumns = computed(() => {
108
+ const columns = pluginData.value.ticketListColumns || [];
109
+ return [...columns].sort((a, b) => (a.position || 100) - (b.position || 100));
110
+ });
111
+
112
+ /**
113
+ * Get plugin components for a specific page slot, sorted by position.
114
+ *
115
+ * @param {string} pageName - The page name (e.g. 'dashboard', 'ticket.show')
116
+ * @param {string} slotName - The slot name (e.g. 'header', 'sidebar', 'footer')
117
+ * @returns {Array} Sorted array of component definitions for the given slot
118
+ */
119
+ function getPageComponents(pageName, slotName) {
120
+ const key = `${pageName}.${slotName}`;
121
+ const components = pluginData.value.pageComponents || {};
122
+ return [...(components[key] || [])].sort((a, b) => (a.position || 100) - (b.position || 100));
123
+ }
124
+
125
+ /**
126
+ * Check whether any plugins have registered extensions.
127
+ */
128
+ const hasPlugins = computed(() => {
129
+ return (
130
+ menuItems.value.length > 0 ||
131
+ dashboardWidgets.value.length > 0 ||
132
+ Object.keys(pluginData.value.pageComponents || {}).length > 0 ||
133
+ ticketActions.value.length > 0 ||
134
+ sidebarPanels.value.length > 0 ||
135
+ ticketFields.value.length > 0 ||
136
+ composerActions.value.length > 0 ||
137
+ reportWidgets.value.length > 0 ||
138
+ settingsPanels.value.length > 0 ||
139
+ notificationChannels.value.length > 0 ||
140
+ ticketListColumns.value.length > 0
141
+ );
142
+ });
143
+
144
+ return {
145
+ pluginData,
146
+ menuItems,
147
+ dashboardWidgets,
148
+ ticketActions,
149
+ sidebarPanels,
150
+ ticketFields,
151
+ composerActions,
152
+ reportWidgets,
153
+ settingsPanels,
154
+ notificationChannels,
155
+ ticketListColumns,
156
+ getPageComponents,
157
+ hasPlugins,
158
+ };
159
+ }
@@ -1,65 +1,65 @@
1
- import { getCurrentInstance } from 'vue';
2
-
3
- /**
4
- * Composable for dispatching and consuming plugin hooks.
5
- *
6
- * Hooks allow plugins to react to events (e.g., ticket.created, ticket.replied)
7
- * and to filter/modify data before it's processed (e.g., reply.beforeSubmit).
8
- *
9
- * Action hooks: fire-and-forget, all handlers run
10
- * Filter hooks: chain handlers, each can modify the value
11
- *
12
- * @returns {Object} Hook dispatch functions
13
- */
14
- export function usePluginHooks() {
15
- const instance = getCurrentInstance();
16
- const hookRegistry = instance?.appContext?.config?.globalProperties?.$escalatedHooks || {};
17
-
18
- /**
19
- * Dispatch an action hook. All registered handlers are called.
20
- * @param {string} event - Hook name (e.g., 'ticket.created')
21
- * @param {...any} args - Arguments passed to handlers
22
- */
23
- async function dispatch(event, ...args) {
24
- const handlers = hookRegistry[event] || [];
25
- for (const { handler } of handlers) {
26
- try {
27
- await handler(...args);
28
- } catch (err) {
29
- console.warn(`[Escalated] Plugin hook "${event}" error:`, err);
30
- }
31
- }
32
- }
33
-
34
- /**
35
- * Dispatch a filter hook. Each handler receives the value and can return a modified version.
36
- * @param {string} event - Hook name (e.g., 'reply.beforeSubmit')
37
- * @param {*} value - The value to filter
38
- * @param {...any} args - Additional arguments passed to handlers
39
- * @returns {*} The filtered value
40
- */
41
- async function filter(event, value, ...args) {
42
- const handlers = hookRegistry[event] || [];
43
- let result = value;
44
- for (const { handler } of handlers) {
45
- try {
46
- const modified = await handler(result, ...args);
47
- if (modified !== undefined) result = modified;
48
- } catch (err) {
49
- console.warn(`[Escalated] Plugin filter "${event}" error:`, err);
50
- }
51
- }
52
- return result;
53
- }
54
-
55
- /**
56
- * Check if any handlers are registered for a given hook.
57
- * @param {string} event - Hook name
58
- * @returns {boolean}
59
- */
60
- function hasHook(event) {
61
- return (hookRegistry[event] || []).length > 0;
62
- }
63
-
64
- return { dispatch, filter, hasHook };
65
- }
1
+ import { getCurrentInstance } from 'vue';
2
+
3
+ /**
4
+ * Composable for dispatching and consuming plugin hooks.
5
+ *
6
+ * Hooks allow plugins to react to events (e.g., ticket.created, ticket.replied)
7
+ * and to filter/modify data before it's processed (e.g., reply.beforeSubmit).
8
+ *
9
+ * Action hooks: fire-and-forget, all handlers run
10
+ * Filter hooks: chain handlers, each can modify the value
11
+ *
12
+ * @returns {Object} Hook dispatch functions
13
+ */
14
+ export function usePluginHooks() {
15
+ const instance = getCurrentInstance();
16
+ const hookRegistry = instance?.appContext?.config?.globalProperties?.$escalatedHooks || {};
17
+
18
+ /**
19
+ * Dispatch an action hook. All registered handlers are called.
20
+ * @param {string} event - Hook name (e.g., 'ticket.created')
21
+ * @param {...any} args - Arguments passed to handlers
22
+ */
23
+ async function dispatch(event, ...args) {
24
+ const handlers = hookRegistry[event] || [];
25
+ for (const { handler } of handlers) {
26
+ try {
27
+ await handler(...args);
28
+ } catch (err) {
29
+ console.warn(`[Escalated] Plugin hook "${event}" error:`, err);
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Dispatch a filter hook. Each handler receives the value and can return a modified version.
36
+ * @param {string} event - Hook name (e.g., 'reply.beforeSubmit')
37
+ * @param {*} value - The value to filter
38
+ * @param {...any} args - Additional arguments passed to handlers
39
+ * @returns {*} The filtered value
40
+ */
41
+ async function filter(event, value, ...args) {
42
+ const handlers = hookRegistry[event] || [];
43
+ let result = value;
44
+ for (const { handler } of handlers) {
45
+ try {
46
+ const modified = await handler(result, ...args);
47
+ if (modified !== undefined) result = modified;
48
+ } catch (err) {
49
+ console.warn(`[Escalated] Plugin filter "${event}" error:`, err);
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+
55
+ /**
56
+ * Check if any handlers are registered for a given hook.
57
+ * @param {string} event - Hook name
58
+ * @returns {boolean}
59
+ */
60
+ function hasHook(event) {
61
+ return (hookRegistry[event] || []).length > 0;
62
+ }
63
+
64
+ return { dispatch, filter, hasHook };
65
+ }
@@ -0,0 +1,182 @@
1
+ import { ref, onUnmounted, readonly } from 'vue';
2
+
3
+ /**
4
+ * Composable for real-time WebSocket event listening via Laravel Echo.
5
+ *
6
+ * If `window.Echo` is available (provided by the host app), this composable
7
+ * subscribes to private channels and listens for broadcast events. When Echo
8
+ * is not present, it silently falls back - the caller can check `echoAvailable`
9
+ * and implement polling as needed.
10
+ *
11
+ * Usage:
12
+ * const { echoAvailable, subscribeToTicket, subscribeToTickets, subscribeToAgent } = useRealtime();
13
+ *
14
+ * All subscriptions are automatically cleaned up on component unmount.
15
+ */
16
+ export function useRealtime() {
17
+ const echoAvailable = ref(typeof window !== 'undefined' && !!window.Echo);
18
+ const subscriptions = [];
19
+
20
+ /**
21
+ * Subscribe to a private channel and listen for an event.
22
+ * Returns an unsubscribe function.
23
+ */
24
+ function listen(channelName, eventName, callback) {
25
+ if (!echoAvailable.value) return () => {};
26
+
27
+ const channel = window.Echo.private(channelName);
28
+ channel.listen(eventName, callback);
29
+
30
+ const unsub = () => {
31
+ channel.stopListening(eventName, callback);
32
+ window.Echo.leave(channelName);
33
+ };
34
+ subscriptions.push(unsub);
35
+ return unsub;
36
+ }
37
+
38
+ /**
39
+ * Subscribe to a specific ticket's channel for real-time updates.
40
+ *
41
+ * @param {number|string} ticketId - The ticket ID
42
+ * @param {Object} handlers - Event handler callbacks
43
+ * @param {Function} [handlers.onReplyCreated] - Called when a new reply is added
44
+ * @param {Function} [handlers.onTicketUpdated] - Called when ticket fields are updated
45
+ * @param {Function} [handlers.onStatusChanged] - Called when ticket status changes
46
+ * @param {Function} [handlers.onTicketAssigned] - Called when ticket is assigned
47
+ * @param {Function} [handlers.onTicketEscalated] - Called when ticket is escalated
48
+ * @returns {Function} Unsubscribe function
49
+ */
50
+ function subscribeToTicket(ticketId, handlers = {}) {
51
+ if (!echoAvailable.value) return () => {};
52
+
53
+ const channelName = `escalated.tickets.${ticketId}`;
54
+ const channel = window.Echo.private(channelName);
55
+ const listeners = [];
56
+
57
+ if (handlers.onReplyCreated) {
58
+ channel.listen('.reply.created', handlers.onReplyCreated);
59
+ listeners.push(['.reply.created', handlers.onReplyCreated]);
60
+ }
61
+ if (handlers.onTicketUpdated) {
62
+ channel.listen('.ticket.updated', handlers.onTicketUpdated);
63
+ listeners.push(['.ticket.updated', handlers.onTicketUpdated]);
64
+ }
65
+ if (handlers.onStatusChanged) {
66
+ channel.listen('.ticket.status_changed', handlers.onStatusChanged);
67
+ listeners.push(['.ticket.status_changed', handlers.onStatusChanged]);
68
+ }
69
+ if (handlers.onTicketAssigned) {
70
+ channel.listen('.ticket.assigned', handlers.onTicketAssigned);
71
+ listeners.push(['.ticket.assigned', handlers.onTicketAssigned]);
72
+ }
73
+ if (handlers.onTicketEscalated) {
74
+ channel.listen('.ticket.escalated', handlers.onTicketEscalated);
75
+ listeners.push(['.ticket.escalated', handlers.onTicketEscalated]);
76
+ }
77
+
78
+ const unsub = () => {
79
+ listeners.forEach(([event, cb]) => channel.stopListening(event, cb));
80
+ window.Echo.leave(channelName);
81
+ };
82
+ subscriptions.push(unsub);
83
+ return unsub;
84
+ }
85
+
86
+ /**
87
+ * Subscribe to the global tickets channel for new ticket notifications.
88
+ *
89
+ * @param {Object} handlers - Event handler callbacks
90
+ * @param {Function} [handlers.onTicketCreated] - Called when a new ticket is created
91
+ * @returns {Function} Unsubscribe function
92
+ */
93
+ function subscribeToTickets(handlers = {}) {
94
+ if (!echoAvailable.value) return () => {};
95
+
96
+ const channelName = 'escalated.tickets';
97
+ const channel = window.Echo.private(channelName);
98
+ const listeners = [];
99
+
100
+ if (handlers.onTicketCreated) {
101
+ channel.listen('.ticket.created', handlers.onTicketCreated);
102
+ listeners.push(['.ticket.created', handlers.onTicketCreated]);
103
+ }
104
+
105
+ const unsub = () => {
106
+ listeners.forEach(([event, cb]) => channel.stopListening(event, cb));
107
+ window.Echo.leave(channelName);
108
+ };
109
+ subscriptions.push(unsub);
110
+ return unsub;
111
+ }
112
+
113
+ /**
114
+ * Subscribe to an agent's personal channel for assignment notifications.
115
+ *
116
+ * @param {number|string} agentId - The agent's user ID
117
+ * @param {Object} handlers - Event handler callbacks
118
+ * @param {Function} [handlers.onTicketAssigned] - Called when a ticket is assigned to this agent
119
+ * @returns {Function} Unsubscribe function
120
+ */
121
+ function subscribeToAgent(agentId, handlers = {}) {
122
+ if (!echoAvailable.value) return () => {};
123
+
124
+ const channelName = `escalated.agents.${agentId}`;
125
+ const channel = window.Echo.private(channelName);
126
+ const listeners = [];
127
+
128
+ if (handlers.onTicketAssigned) {
129
+ channel.listen('.ticket.assigned', handlers.onTicketAssigned);
130
+ listeners.push(['.ticket.assigned', handlers.onTicketAssigned]);
131
+ }
132
+
133
+ const unsub = () => {
134
+ listeners.forEach(([event, cb]) => channel.stopListening(event, cb));
135
+ window.Echo.leave(channelName);
136
+ };
137
+ subscriptions.push(unsub);
138
+ return unsub;
139
+ }
140
+
141
+ /**
142
+ * Get a presence channel for a ticket (if Echo supports it).
143
+ * Returns the channel instance or null.
144
+ */
145
+ function joinTicketPresence(ticketId, callbacks = {}) {
146
+ if (!echoAvailable.value) return null;
147
+
148
+ const channelName = `escalated.tickets.${ticketId}`;
149
+ const channel = window.Echo.join(channelName);
150
+
151
+ if (callbacks.here) channel.here(callbacks.here);
152
+ if (callbacks.joining) channel.joining(callbacks.joining);
153
+ if (callbacks.leaving) channel.leaving(callbacks.leaving);
154
+
155
+ const unsub = () => {
156
+ window.Echo.leave(`presence-${channelName}`);
157
+ };
158
+ subscriptions.push(unsub);
159
+ return { channel, unsubscribe: unsub };
160
+ }
161
+
162
+ // Cleanup all subscriptions on component unmount
163
+ onUnmounted(() => {
164
+ subscriptions.forEach((unsub) => {
165
+ try {
166
+ unsub();
167
+ } catch {
168
+ /* ignore */
169
+ }
170
+ });
171
+ subscriptions.length = 0;
172
+ });
173
+
174
+ return {
175
+ echoAvailable: readonly(echoAvailable),
176
+ listen,
177
+ subscribeToTicket,
178
+ subscribeToTickets,
179
+ subscribeToAgent,
180
+ joinTicketPresence,
181
+ };
182
+ }