@frigear-nu/inbox 0.0.0-stage → 0.0.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 (174) hide show
  1. package/README.md +39 -2
  2. package/dist/module.d.mts +452 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +242 -0
  5. package/dist/runtime/access.d.ts +1 -0
  6. package/dist/runtime/access.js +62 -0
  7. package/dist/runtime/app/components/InboxChannelSlideover.d.vue.ts +12 -0
  8. package/dist/runtime/app/components/InboxChannelSlideover.vue +171 -0
  9. package/dist/runtime/app/components/InboxChannelSlideover.vue.d.ts +12 -0
  10. package/dist/runtime/app/components/InboxComposer.d.vue.ts +12 -0
  11. package/dist/runtime/app/components/InboxComposer.vue +71 -0
  12. package/dist/runtime/app/components/InboxComposer.vue.d.ts +12 -0
  13. package/dist/runtime/app/components/InboxConversation.d.vue.ts +8 -0
  14. package/dist/runtime/app/components/InboxConversation.vue +82 -0
  15. package/dist/runtime/app/components/InboxConversation.vue.d.ts +8 -0
  16. package/dist/runtime/app/components/InboxHideSlideover.d.vue.ts +12 -0
  17. package/dist/runtime/app/components/InboxHideSlideover.vue +54 -0
  18. package/dist/runtime/app/components/InboxHideSlideover.vue.d.ts +12 -0
  19. package/dist/runtime/app/components/InboxMailboxSlideover.d.vue.ts +11 -0
  20. package/dist/runtime/app/components/InboxMailboxSlideover.vue +125 -0
  21. package/dist/runtime/app/components/InboxMailboxSlideover.vue.d.ts +11 -0
  22. package/dist/runtime/app/composables/index.d.ts +6 -0
  23. package/dist/runtime/app/composables/index.js +5 -0
  24. package/dist/runtime/app/composables/useInboxChannelActions.d.ts +15 -0
  25. package/dist/runtime/app/composables/useInboxChannelActions.js +45 -0
  26. package/dist/runtime/app/composables/useInboxLinks.d.ts +11 -0
  27. package/dist/runtime/app/composables/useInboxLinks.js +17 -0
  28. package/dist/runtime/app/composables/useInboxMailboxActions.d.ts +14 -0
  29. package/dist/runtime/app/composables/useInboxMailboxActions.js +47 -0
  30. package/dist/runtime/app/composables/useInboxThreadActions.d.ts +29 -0
  31. package/dist/runtime/app/composables/useInboxThreadActions.js +76 -0
  32. package/dist/runtime/app/composables/useInboxTranslate.d.ts +3 -0
  33. package/dist/runtime/app/composables/useInboxTranslate.js +7 -0
  34. package/dist/runtime/app/dashboard/InboxMine.d.vue.ts +3 -0
  35. package/dist/runtime/app/dashboard/InboxMine.vue +25 -0
  36. package/dist/runtime/app/dashboard/InboxMine.vue.d.ts +3 -0
  37. package/dist/runtime/app/dashboard/InboxUnassigned.d.vue.ts +3 -0
  38. package/dist/runtime/app/dashboard/InboxUnassigned.vue +25 -0
  39. package/dist/runtime/app/dashboard/InboxUnassigned.vue.d.ts +3 -0
  40. package/dist/runtime/app/pages/admin-settings.d.vue.ts +3 -0
  41. package/dist/runtime/app/pages/admin-settings.vue +161 -0
  42. package/dist/runtime/app/pages/admin-settings.vue.d.ts +3 -0
  43. package/dist/runtime/app/pages/admin-thread.d.vue.ts +3 -0
  44. package/dist/runtime/app/pages/admin-thread.vue +234 -0
  45. package/dist/runtime/app/pages/admin-thread.vue.d.ts +3 -0
  46. package/dist/runtime/app/pages/admin.d.vue.ts +3 -0
  47. package/dist/runtime/app/pages/admin.vue +211 -0
  48. package/dist/runtime/app/pages/admin.vue.d.ts +3 -0
  49. package/dist/runtime/channels/email.d.ts +2 -0
  50. package/dist/runtime/channels/email.js +8 -0
  51. package/dist/runtime/channels/form.d.ts +2 -0
  52. package/dist/runtime/channels/form.js +9 -0
  53. package/dist/runtime/channels/instagram.d.ts +2 -0
  54. package/dist/runtime/channels/instagram.js +5 -0
  55. package/dist/runtime/channels/messenger.d.ts +2 -0
  56. package/dist/runtime/channels/messenger.js +5 -0
  57. package/dist/runtime/channels/whatsapp.d.ts +2 -0
  58. package/dist/runtime/channels/whatsapp.js +5 -0
  59. package/dist/runtime/i18n/lang/da.json +247 -0
  60. package/dist/runtime/i18n/lang/en.json +247 -0
  61. package/dist/runtime/menus.d.ts +2 -0
  62. package/dist/runtime/menus.js +19 -0
  63. package/dist/runtime/server/db/schema.postgresql.d.ts +1216 -0
  64. package/dist/runtime/server/db/schema.postgresql.js +154 -0
  65. package/dist/runtime/server/db/schema.sqlite.d.ts +1294 -0
  66. package/dist/runtime/server/db/schema.sqlite.js +154 -0
  67. package/dist/runtime/server/plugins/forms.d.ts +2 -0
  68. package/dist/runtime/server/plugins/forms.js +55 -0
  69. package/dist/runtime/server/plugins/links.d.ts +2 -0
  70. package/dist/runtime/server/plugins/links.js +18 -0
  71. package/dist/runtime/server/plugins/notify.d.ts +2 -0
  72. package/dist/runtime/server/plugins/notify.js +24 -0
  73. package/dist/runtime/server/plugins/seed.d.ts +2 -0
  74. package/dist/runtime/server/plugins/seed.js +7 -0
  75. package/dist/runtime/server/plugins/teams.d.ts +2 -0
  76. package/dist/runtime/server/plugins/teams.js +3 -0
  77. package/dist/runtime/server/policies.d.ts +2 -0
  78. package/dist/runtime/server/policies.js +15 -0
  79. package/dist/runtime/server/routes/admin/audit.get.d.ts +2 -0
  80. package/dist/runtime/server/routes/admin/audit.get.js +43 -0
  81. package/dist/runtime/server/routes/admin/channel.delete.d.ts +2 -0
  82. package/dist/runtime/server/routes/admin/channel.delete.js +13 -0
  83. package/dist/runtime/server/routes/admin/channel.patch.d.ts +2 -0
  84. package/dist/runtime/server/routes/admin/channel.patch.js +24 -0
  85. package/dist/runtime/server/routes/admin/channels.get.d.ts +2 -0
  86. package/dist/runtime/server/routes/admin/channels.get.js +10 -0
  87. package/dist/runtime/server/routes/admin/channels.post.d.ts +2 -0
  88. package/dist/runtime/server/routes/admin/channels.post.js +21 -0
  89. package/dist/runtime/server/routes/admin/contact-erase.post.d.ts +2 -0
  90. package/dist/runtime/server/routes/admin/contact-erase.post.js +20 -0
  91. package/dist/runtime/server/routes/admin/contact-export.get.d.ts +2 -0
  92. package/dist/runtime/server/routes/admin/contact-export.get.js +41 -0
  93. package/dist/runtime/server/routes/admin/mailbox.delete.d.ts +2 -0
  94. package/dist/runtime/server/routes/admin/mailbox.delete.js +14 -0
  95. package/dist/runtime/server/routes/admin/mailbox.get.d.ts +2 -0
  96. package/dist/runtime/server/routes/admin/mailbox.get.js +9 -0
  97. package/dist/runtime/server/routes/admin/mailbox.patch.d.ts +2 -0
  98. package/dist/runtime/server/routes/admin/mailbox.patch.js +17 -0
  99. package/dist/runtime/server/routes/admin/mailboxes.get.d.ts +2 -0
  100. package/dist/runtime/server/routes/admin/mailboxes.get.js +5 -0
  101. package/dist/runtime/server/routes/admin/mailboxes.post.d.ts +2 -0
  102. package/dist/runtime/server/routes/admin/mailboxes.post.js +22 -0
  103. package/dist/runtime/server/routes/admin/summary.get.d.ts +2 -0
  104. package/dist/runtime/server/routes/admin/summary.get.js +19 -0
  105. package/dist/runtime/server/routes/admin/thread-assignees.get.d.ts +2 -0
  106. package/dist/runtime/server/routes/admin/thread-assignees.get.js +11 -0
  107. package/dist/runtime/server/routes/admin/thread-hide.post.d.ts +2 -0
  108. package/dist/runtime/server/routes/admin/thread-hide.post.js +23 -0
  109. package/dist/runtime/server/routes/admin/thread-messages.post.d.ts +2 -0
  110. package/dist/runtime/server/routes/admin/thread-messages.post.js +10 -0
  111. package/dist/runtime/server/routes/admin/thread-notes.post.d.ts +2 -0
  112. package/dist/runtime/server/routes/admin/thread-notes.post.js +10 -0
  113. package/dist/runtime/server/routes/admin/thread.get.d.ts +2 -0
  114. package/dist/runtime/server/routes/admin/thread.get.js +27 -0
  115. package/dist/runtime/server/routes/admin/thread.patch.d.ts +2 -0
  116. package/dist/runtime/server/routes/admin/thread.patch.js +23 -0
  117. package/dist/runtime/server/routes/admin/threads.get.d.ts +2 -0
  118. package/dist/runtime/server/routes/admin/threads.get.js +49 -0
  119. package/dist/runtime/server/routes/webhooks/channel.post.d.ts +2 -0
  120. package/dist/runtime/server/routes/webhooks/channel.post.js +11 -0
  121. package/dist/runtime/server/routes/webhooks/email.post.d.ts +2 -0
  122. package/dist/runtime/server/routes/webhooks/email.post.js +38 -0
  123. package/dist/runtime/server/routes/webhooks/meta.get.d.ts +2 -0
  124. package/dist/runtime/server/routes/webhooks/meta.get.js +19 -0
  125. package/dist/runtime/server/routes/webhooks/meta.post.d.ts +2 -0
  126. package/dist/runtime/server/routes/webhooks/meta.post.js +29 -0
  127. package/dist/runtime/server/search-index.d.ts +2 -0
  128. package/dist/runtime/server/search-index.js +7 -0
  129. package/dist/runtime/server/tasks/retention.d.ts +2 -0
  130. package/dist/runtime/server/tasks/retention.js +12 -0
  131. package/dist/runtime/server/utils/inbox-audit.d.ts +17 -0
  132. package/dist/runtime/server/utils/inbox-audit.js +35 -0
  133. package/dist/runtime/server/utils/inbox-channels.d.ts +42 -0
  134. package/dist/runtime/server/utils/inbox-channels.js +73 -0
  135. package/dist/runtime/server/utils/inbox-config.d.ts +12 -0
  136. package/dist/runtime/server/utils/inbox-config.js +8 -0
  137. package/dist/runtime/server/utils/inbox-dto.d.ts +19 -0
  138. package/dist/runtime/server/utils/inbox-dto.js +92 -0
  139. package/dist/runtime/server/utils/inbox-ingest.d.ts +43 -0
  140. package/dist/runtime/server/utils/inbox-ingest.js +136 -0
  141. package/dist/runtime/server/utils/inbox-integrations.d.ts +7 -0
  142. package/dist/runtime/server/utils/inbox-integrations.js +13 -0
  143. package/dist/runtime/server/utils/inbox-mailboxes.d.ts +14 -0
  144. package/dist/runtime/server/utils/inbox-mailboxes.js +27 -0
  145. package/dist/runtime/server/utils/inbox-registry.d.ts +7 -0
  146. package/dist/runtime/server/utils/inbox-registry.js +10 -0
  147. package/dist/runtime/server/utils/inbox-retention.d.ts +57 -0
  148. package/dist/runtime/server/utils/inbox-retention.js +167 -0
  149. package/dist/runtime/server/utils/inbox-schemas.d.ts +123 -0
  150. package/dist/runtime/server/utils/inbox-schemas.js +78 -0
  151. package/dist/runtime/server/utils/inbox-search.d.ts +8 -0
  152. package/dist/runtime/server/utils/inbox-search.js +2 -0
  153. package/dist/runtime/server/utils/inbox-seed.d.ts +9 -0
  154. package/dist/runtime/server/utils/inbox-seed.js +35 -0
  155. package/dist/runtime/server/utils/inbox-send.d.ts +25 -0
  156. package/dist/runtime/server/utils/inbox-send.js +84 -0
  157. package/dist/runtime/server/utils/inbox-tombstones.d.ts +25 -0
  158. package/dist/runtime/server/utils/inbox-tombstones.js +47 -0
  159. package/dist/runtime/server/utils/inbox-webhooks.d.ts +8 -0
  160. package/dist/runtime/server/utils/inbox-webhooks.js +10 -0
  161. package/dist/runtime/server/utils/inbox.d.ts +79 -0
  162. package/dist/runtime/server/utils/inbox.js +134 -0
  163. package/dist/runtime/utils/api.d.ts +40 -0
  164. package/dist/runtime/utils/api.js +43 -0
  165. package/dist/runtime/utils/index.d.ts +44 -0
  166. package/dist/runtime/utils/index.js +27 -0
  167. package/dist/runtime/utils/payloads.d.ts +99 -0
  168. package/dist/runtime/utils/payloads.js +173 -0
  169. package/dist/runtime/utils/registry.d.ts +17 -0
  170. package/dist/runtime/utils/registry.js +29 -0
  171. package/dist/runtime/utils/signature.d.ts +14 -0
  172. package/dist/runtime/utils/signature.js +16 -0
  173. package/dist/types.d.mts +7 -0
  174. package/package.json +118 -3
@@ -0,0 +1,82 @@
1
+ <script setup>
2
+ import { useFormat, useModuleT } from "#imports";
3
+ defineOptions({ name: "InboxConversation" });
4
+ defineProps({
5
+ messages: { type: Array, required: true },
6
+ contactName: { type: [String, null], required: false }
7
+ });
8
+ const t = useModuleT("inbox");
9
+ const format = useFormat();
10
+ </script>
11
+
12
+ <template>
13
+ <ol class="flex flex-col gap-3">
14
+ <li
15
+ v-for="message in messages"
16
+ :key="message.id"
17
+ class="flex"
18
+ :class="message.direction === 'in' ? 'justify-start' : 'justify-end'"
19
+ >
20
+ <div
21
+ class="max-w-[85%] rounded-lg px-3 py-2 text-sm"
22
+ :class="{
23
+ 'bg-elevated': message.direction === 'in',
24
+ 'bg-primary/10': message.direction === 'out',
25
+ 'border border-dashed border-warning/60 bg-warning/10': message.direction === 'note'
26
+ }"
27
+ :data-direction="message.direction"
28
+ >
29
+ <div class="mb-1 flex flex-wrap items-center gap-x-2 text-xs text-muted">
30
+ <UIcon
31
+ v-if="message.direction === 'note'"
32
+ name="i-lucide-sticky-note"
33
+ class="size-3.5"
34
+ />
35
+ <span class="font-medium text-highlighted">
36
+ {{ message.direction === "in" ? contactName || t("contact.anonymous", "Unnamed contact") : message.author?.name ?? t("thread.staff", "Staff") }}
37
+ </span>
38
+ <span v-if="message.direction === 'note'">{{ t("thread.noteLabel", "Internal note, not sent") }}</span>
39
+ <time
40
+ class="tabular-nums"
41
+ :datetime="message.createdAt"
42
+ >{{ format.dateTime(message.createdAt) }}</time>
43
+ </div>
44
+ <p
45
+ v-if="message.cc?.length"
46
+ class="mb-1 text-xs text-muted"
47
+ data-cc
48
+ >
49
+ {{ t("thread.cc", "Cc: {recipients}", { recipients: message.cc.join(", ") }) }}
50
+ </p>
51
+ <p
52
+ v-if="message.body"
53
+ class="whitespace-pre-wrap break-words"
54
+ >
55
+ {{ message.body }}
56
+ </p>
57
+ <p
58
+ v-else
59
+ class="italic text-muted"
60
+ >
61
+ {{ t("thread.removed", "Removed under the retention policy or on request.") }}
62
+ </p>
63
+ <ul
64
+ v-if="message.attachments.length"
65
+ class="mt-2 flex flex-wrap gap-1.5"
66
+ >
67
+ <li
68
+ v-for="(file, index) in message.attachments"
69
+ :key="index"
70
+ >
71
+ <UBadge
72
+ color="neutral"
73
+ variant="subtle"
74
+ icon="i-lucide-paperclip"
75
+ :label="file.filename"
76
+ />
77
+ </li>
78
+ </ul>
79
+ </div>
80
+ </li>
81
+ </ol>
82
+ </template>
@@ -0,0 +1,8 @@
1
+ import type { InboxMessageDto } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ messages: InboxMessageDto[];
4
+ contactName?: string | null;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import type { InboxThreadDto } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ thread: InboxThreadDto;
4
+ roles: string[];
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ close: (saved: false | InboxThreadDto) => any;
8
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ onClose?: ((saved: false | InboxThreadDto) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,54 @@
1
+ <script setup>
2
+ import { inboxApi } from "../../utils/api";
3
+ import { $fetch, computed, reactive, useAction, useModuleT } from "#imports";
4
+ defineOptions({ name: "InboxHideSlideover" });
5
+ const props = defineProps({
6
+ thread: { type: Object, required: true },
7
+ roles: { type: Array, required: true }
8
+ });
9
+ const emit = defineEmits(["close"]);
10
+ const t = useModuleT("inbox");
11
+ const { busy, run } = useAction();
12
+ const NONE = "__none__";
13
+ const state = reactive({ role: props.thread.hiddenBelow ?? props.roles[0] ?? NONE });
14
+ const options = computed(() => [
15
+ { label: t("hide.everyone", "Everyone with access to the mailbox"), value: NONE },
16
+ ...props.roles.map((role) => ({ label: t("hide.role", "{role} and up", { role }), value: role }))
17
+ ]);
18
+ async function save() {
19
+ const role = state.role === NONE ? null : state.role;
20
+ const saved = await run(
21
+ () => $fetch(inboxApi.admin.hide(props.thread.id), { method: "POST", body: { role } }),
22
+ { success: role ? t("hide.hidden", "Hidden below {role}", { role }) : t("hide.shown", "Shown to everyone with access") }
23
+ );
24
+ if (saved) emit("close", saved);
25
+ }
26
+ </script>
27
+
28
+ <template>
29
+ <FormSlideover
30
+ form-id="inbox-hide-form"
31
+ :title="t('hide.title', 'Hide from lower roles')"
32
+ :description="t('hide.description', 'People without the role no longer see the thread, as if it did not exist. Its assignee is dropped when they lack the role.')"
33
+ :submit-label="t('hide.save', 'Save who sees it')"
34
+ :loading="busy"
35
+ @close="emit('close', false)"
36
+ >
37
+ <UForm
38
+ id="inbox-hide-form"
39
+ :state="state"
40
+ class="flex flex-col gap-4"
41
+ @submit="save"
42
+ >
43
+ <UFormField
44
+ name="role"
45
+ :label="t('hide.label', 'Who sees the thread')"
46
+ >
47
+ <URadioGroup
48
+ v-model="state.role"
49
+ :items="options"
50
+ />
51
+ </UFormField>
52
+ </UForm>
53
+ </FormSlideover>
54
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { InboxThreadDto } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ thread: InboxThreadDto;
4
+ roles: string[];
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ close: (saved: false | InboxThreadDto) => any;
8
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ onClose?: ((saved: false | InboxThreadDto) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { InboxMailboxDto } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ mailbox?: InboxMailboxDto;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ close: (saved: false | InboxMailboxDto) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onClose?: ((saved: false | InboxMailboxDto) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,125 @@
1
+ <script setup>
2
+ import { z } from "zod";
3
+ import { inboxApi } from "../../utils/api";
4
+ import { $fetch, reactive, useAction, useInboxTranslate, useModuleT } from "#imports";
5
+ import { grantFields } from "#auth/grant-fields";
6
+ defineOptions({ name: "InboxMailboxSlideover" });
7
+ const props = defineProps({
8
+ mailbox: { type: Object, required: false }
9
+ });
10
+ const emit = defineEmits(["close"]);
11
+ const t = useModuleT("inbox");
12
+ const tr = useInboxTranslate();
13
+ const { busy, run } = useAction();
14
+ const hasRoleKind = grantFields.some((field) => field.kind === "role");
15
+ const state = reactive(props.mailbox ? { name: props.mailbox.name, key: props.mailbox.key, ownerType: props.mailbox.ownerType === "team" ? "team" : "platform", ownerId: props.mailbox.ownerId ?? "", grants: props.mailbox.grants, retentionDays: props.mailbox.retentionDays ?? void 0 } : { name: null, key: "", ownerType: "platform", ownerId: "", grants: hasRoleKind ? [{ kind: "role", role: "admin" }] : [], retentionDays: void 0 });
16
+ const grantKinds = grantFields.map((field) => field.kind).filter((kind) => kind !== "public");
17
+ const ownerOptions = [
18
+ { label: t("settings.ownerPlatform", "Platform"), value: "platform" },
19
+ { label: t("settings.ownerTeam", "A team"), value: "team" }
20
+ ];
21
+ const schema = z.object({
22
+ name: z.union([z.string().trim().min(1), z.record(z.string(), z.string())]).nullable().refine((value) => !!tr(value), t("settings.nameRequired", "Give the mailbox a name.")),
23
+ key: z.string().trim().regex(/^[a-z0-9][\w.-]{0,63}$/i, t("settings.keyHelp", 'Letters, digits, ".", "_" and "-".')),
24
+ ownerId: z.string().trim(),
25
+ retentionDays: z.number().int().min(1).max(36500).optional()
26
+ });
27
+ async function save() {
28
+ const name = tr(state.name);
29
+ const shared = { name: state.name, grants: state.grants, retentionDays: state.retentionDays ?? null };
30
+ const saved = await run(
31
+ () => props.mailbox ? $fetch(inboxApi.admin.mailbox(props.mailbox.id), { method: "PATCH", body: shared }) : $fetch(inboxApi.admin.mailboxes, {
32
+ method: "POST",
33
+ body: { ...shared, key: state.key.trim(), ownerType: state.ownerType, ownerId: state.ownerType === "team" ? state.ownerId.trim() : null }
34
+ }),
35
+ { success: props.mailbox ? t("settings.mailboxSaved", "Saved {name}", { name }) : t("settings.mailboxCreated", "Created {name}", { name }) }
36
+ );
37
+ if (saved) emit("close", saved);
38
+ }
39
+ </script>
40
+
41
+ <template>
42
+ <FormSlideover
43
+ form-id="inbox-mailbox-form"
44
+ :title="mailbox ? t('settings.editMailbox', 'Edit mailbox') : t('settings.addMailbox', 'Add mailbox')"
45
+ :description="mailbox ? void 0 : t('settings.addMailboxDescription', 'A shared inbox. Connect channels to it once it is created.')"
46
+ :submit-label="mailbox ? t('settings.saveMailbox', 'Save mailbox') : t('settings.createMailbox', 'Create mailbox')"
47
+ :loading="busy"
48
+ @close="emit('close', false)"
49
+ >
50
+ <UForm
51
+ id="inbox-mailbox-form"
52
+ :schema="schema"
53
+ :state="state"
54
+ class="flex flex-col gap-4"
55
+ @submit="save"
56
+ >
57
+ <UFormField
58
+ name="name"
59
+ :label="t('settings.name', 'Name')"
60
+ required
61
+ >
62
+ <TranslatedInput v-model="state.name" />
63
+ </UFormField>
64
+ <UFormField
65
+ v-if="!mailbox"
66
+ name="key"
67
+ :label="t('settings.key', 'Key')"
68
+ :description="t('settings.keyDescription', 'A stable name for code and seeds, such as support.')"
69
+ required
70
+ >
71
+ <UInput
72
+ v-model="state.key"
73
+ class="w-full"
74
+ />
75
+ </UFormField>
76
+ <template v-if="!mailbox">
77
+ <UFormField
78
+ name="ownerType"
79
+ :label="t('settings.owner', 'Owner')"
80
+ :description="t('settings.ownerHelp', 'A team mailbox is read by the team\'s leads.')"
81
+ >
82
+ <USelect
83
+ v-model="state.ownerType"
84
+ :items="ownerOptions"
85
+ class="w-full"
86
+ />
87
+ </UFormField>
88
+ <UFormField
89
+ v-if="state.ownerType === 'team'"
90
+ name="ownerId"
91
+ :label="t('settings.team', 'Team id')"
92
+ required
93
+ >
94
+ <UInput
95
+ v-model="state.ownerId"
96
+ placeholder="tem_…"
97
+ class="w-full"
98
+ />
99
+ </UFormField>
100
+ </template>
101
+ <UFormField
102
+ name="grants"
103
+ :label="t('settings.readers', 'Who reads it')"
104
+ :description="t('settings.readersHelp', 'Staff who manage inboxes always do. A platform mailbox needs at least one rule.')"
105
+ >
106
+ <GrantsEditor
107
+ v-model="state.grants"
108
+ :kinds="grantKinds"
109
+ />
110
+ </UFormField>
111
+ <UFormField
112
+ name="retentionDays"
113
+ :label="t('settings.retention', 'Keep closed threads for')"
114
+ :description="t('settings.retentionHelp', 'Days after the last message. Leave empty for the default.')"
115
+ >
116
+ <UInputNumber
117
+ v-model="state.retentionDays"
118
+ :min="1"
119
+ :max="36500"
120
+ class="w-40"
121
+ />
122
+ </UFormField>
123
+ </UForm>
124
+ </FormSlideover>
125
+ </template>
@@ -0,0 +1,11 @@
1
+ import type { InboxMailboxDto } from '../../../types.js';
2
+ type __VLS_Props = {
3
+ mailbox?: InboxMailboxDto;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ close: (saved: false | InboxMailboxDto) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onClose?: ((saved: false | InboxMailboxDto) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export { useInboxChannelActions } from './useInboxChannelActions.js';
2
+ export { useInboxLinks } from './useInboxLinks.js';
3
+ export { useInboxMailboxActions } from './useInboxMailboxActions.js';
4
+ export { useInboxThreadActions } from './useInboxThreadActions.js';
5
+ export type { InboxThreadMenuOptions } from './useInboxThreadActions.js';
6
+ export { useInboxTranslate } from './useInboxTranslate.js';
@@ -0,0 +1,5 @@
1
+ export { useInboxChannelActions } from "./useInboxChannelActions.js";
2
+ export { useInboxLinks } from "./useInboxLinks.js";
3
+ export { useInboxMailboxActions } from "./useInboxMailboxActions.js";
4
+ export { useInboxThreadActions } from "./useInboxThreadActions.js";
5
+ export { useInboxTranslate } from "./useInboxTranslate.js";
@@ -0,0 +1,15 @@
1
+ import type { DropdownMenuItem } from '@nuxt/ui';
2
+ import type { InboxChannelAccountDto, InboxMailboxDto } from '../../../types.js';
3
+ /**
4
+ * What staff can do with a channel account: `create` and `edit` (a slideover), `toggle` (turn it on or off),
5
+ * `remove` (confirms first) and `menu(account)`: Edit, Turn off | Disconnect.
6
+ */
7
+ export declare function useInboxChannelActions(): {
8
+ create: (mailboxes: InboxMailboxDto[]) => Promise<InboxChannelAccountDto | false>;
9
+ edit: (account: InboxChannelAccountDto, mailboxes: InboxMailboxDto[]) => Promise<InboxChannelAccountDto | false>;
10
+ toggle: (account: InboxChannelAccountDto) => Promise<boolean>;
11
+ remove: (account: InboxChannelAccountDto) => Promise<boolean>;
12
+ menu: (account: InboxChannelAccountDto, mailboxes: InboxMailboxDto[], options?: {
13
+ onChanged?: () => unknown;
14
+ }) => DropdownMenuItem[][];
15
+ };
@@ -0,0 +1,45 @@
1
+ import InboxChannelSlideover from "../components/InboxChannelSlideover.vue";
2
+ import { inboxApi } from "../../utils/api.js";
3
+ import { $fetch, useAction, useConfirmDialog, useModuleT, useOverlay } from "#imports";
4
+ export function useInboxChannelActions() {
5
+ const t = useModuleT("inbox");
6
+ const overlay = useOverlay();
7
+ const confirm = useConfirmDialog();
8
+ const { run } = useAction();
9
+ const create = async (mailboxes) => await overlay.create(InboxChannelSlideover, { destroyOnClose: true, props: { mailboxes } }).open();
10
+ const edit = async (account, mailboxes) => await overlay.create(InboxChannelSlideover, { destroyOnClose: true, props: { account, mailboxes } }).open();
11
+ async function toggle(account) {
12
+ const done = await run(
13
+ () => $fetch(inboxApi.admin.channel(account.id), { method: "PATCH", body: { enabled: !account.enabled } }).then(() => true),
14
+ { success: account.enabled ? t("settings.channelOff", "Turned off {address}", { address: account.address }) : t("settings.channelOn", "Turned on {address}", { address: account.address }) }
15
+ );
16
+ return done === true;
17
+ }
18
+ async function remove(account) {
19
+ const confirmed = await confirm({
20
+ title: t("settings.disconnectTitle", "Disconnect {address}?", { address: account.address }),
21
+ description: t("settings.disconnectDescription", "New messages to it are dropped. Its threads stay in the mailbox, but replies to them can no longer be sent."),
22
+ confirmText: t("settings.disconnect", "Disconnect channel"),
23
+ destructive: true
24
+ });
25
+ if (!confirmed) return false;
26
+ const done = await run(
27
+ () => $fetch(inboxApi.admin.channel(account.id), { method: "DELETE" }).then(() => true),
28
+ { success: t("settings.disconnected", "Disconnected {address}", { address: account.address }), error: t("settings.disconnectFailed", "Could not disconnect the channel") }
29
+ );
30
+ return done === true;
31
+ }
32
+ function menu(account, mailboxes, options = {}) {
33
+ const changed = async (result) => {
34
+ if (result) await options.onChanged?.();
35
+ };
36
+ return [
37
+ [
38
+ { label: t("settings.editChannel", "Edit channel"), icon: "i-lucide-pencil", onSelect: async () => changed(await edit(account, mailboxes)) },
39
+ account.enabled ? { label: t("settings.turnOff", "Turn off channel"), icon: "i-lucide-pause", onSelect: async () => changed(await toggle(account)) } : { label: t("settings.turnOn", "Turn on channel"), icon: "i-lucide-play", onSelect: async () => changed(await toggle(account)) }
40
+ ],
41
+ [{ label: t("settings.disconnect", "Disconnect channel"), icon: "i-lucide-trash-2", color: "error", onSelect: async () => changed(await remove(account)) }]
42
+ ];
43
+ }
44
+ return { create, edit, toggle, remove, menu };
45
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Locale-aware links to the staff inbox pages (`inbox.settings.pages`). Each returns `undefined` when that page is off.
3
+ */
4
+ export declare function useInboxLinks(): {
5
+ /** The thread list, optionally with filters in the query. */
6
+ admin: (query?: Record<string, string>) => any;
7
+ /** One thread. */
8
+ thread: (id: string) => any;
9
+ /** Mailbox and channel settings. */
10
+ settings: () => any;
11
+ };
@@ -0,0 +1,17 @@
1
+ import { useLocaleLink, useRuntimeConfig } from "#imports";
2
+ export function useInboxLinks() {
3
+ const { localize } = useLocaleLink();
4
+ const pages = useRuntimeConfig().public.inbox?.pages ?? {};
5
+ return {
6
+ /** The thread list, optionally with filters in the query. */
7
+ admin: (query) => {
8
+ if (!pages.admin) return void 0;
9
+ const search = query ? new URLSearchParams(query).toString() : "";
10
+ return localize(search ? `${pages.admin}?${search}` : pages.admin);
11
+ },
12
+ /** One thread. */
13
+ thread: (id) => pages.adminThread ? localize(pages.adminThread.replace(":id", encodeURIComponent(id))) : void 0,
14
+ /** Mailbox and channel settings. */
15
+ settings: () => pages.adminSettings ? localize(pages.adminSettings) : void 0
16
+ };
17
+ }
@@ -0,0 +1,14 @@
1
+ import type { DropdownMenuItem } from '@nuxt/ui';
2
+ import type { InboxMailboxDto } from '../../../types.js';
3
+ /**
4
+ * What staff can do with a mailbox: `create` and `edit` (a slideover, resolving with the saved mailbox), `remove`
5
+ * (confirms first; a mailbox with threads cannot go) and `menu(mailbox)`: Edit | Delete.
6
+ */
7
+ export declare function useInboxMailboxActions(): {
8
+ create: () => Promise<InboxMailboxDto | false>;
9
+ edit: (mailbox: InboxMailboxDto) => Promise<InboxMailboxDto | false>;
10
+ remove: (mailbox: InboxMailboxDto) => Promise<boolean>;
11
+ menu: (mailbox: InboxMailboxDto, options?: {
12
+ onChanged?: () => unknown;
13
+ }) => DropdownMenuItem[][];
14
+ };
@@ -0,0 +1,47 @@
1
+ import InboxMailboxSlideover from "../components/InboxMailboxSlideover.vue";
2
+ import { inboxApi } from "../../utils/api.js";
3
+ import { $fetch, useAction, useConfirmDialog, useInboxTranslate, useModuleT, useOverlay } from "#imports";
4
+ export function useInboxMailboxActions() {
5
+ const t = useModuleT("inbox");
6
+ const tr = useInboxTranslate();
7
+ const overlay = useOverlay();
8
+ const confirm = useConfirmDialog();
9
+ const { run } = useAction();
10
+ const create = async () => await overlay.create(InboxMailboxSlideover, { destroyOnClose: true }).open();
11
+ const edit = async (mailbox) => await overlay.create(InboxMailboxSlideover, { destroyOnClose: true, props: { mailbox } }).open();
12
+ async function remove(mailbox) {
13
+ const name = tr(mailbox.name);
14
+ const confirmed = await confirm({
15
+ title: t("settings.deleteMailboxTitle", "Delete {name}?", { name }),
16
+ description: t("settings.deleteMailboxDescription", "Its channels are disconnected. A mailbox that still has threads cannot be deleted."),
17
+ confirmText: t("settings.deleteMailbox", "Delete mailbox"),
18
+ destructive: true
19
+ });
20
+ if (!confirmed) return false;
21
+ const done = await run(
22
+ () => $fetch(inboxApi.admin.mailbox(mailbox.id), { method: "DELETE" }).then(() => true),
23
+ { success: t("settings.mailboxDeleted", "Deleted {name}", { name }), error: t("settings.deleteMailboxFailed", "Could not delete the mailbox") }
24
+ );
25
+ return done === true;
26
+ }
27
+ function menu(mailbox, options = {}) {
28
+ return [
29
+ [{
30
+ label: t("settings.editMailbox", "Edit mailbox"),
31
+ icon: "i-lucide-pencil",
32
+ onSelect: async () => {
33
+ if (await edit(mailbox)) await options.onChanged?.();
34
+ }
35
+ }],
36
+ [{
37
+ label: t("settings.deleteMailbox", "Delete mailbox"),
38
+ icon: "i-lucide-trash-2",
39
+ color: "error",
40
+ onSelect: async () => {
41
+ if (await remove(mailbox)) await options.onChanged?.();
42
+ }
43
+ }]
44
+ ];
45
+ }
46
+ return { create, edit, remove, menu };
47
+ }
@@ -0,0 +1,29 @@
1
+ import type { DropdownMenuItem } from '@nuxt/ui';
2
+ import type { InboxContactDto, InboxThreadDto, InboxThreadStatus } from '../../../types.js';
3
+ export type InboxThreadMenuOptions = {
4
+ /** Runs after the thread changed (refresh a list or the page). */
5
+ onChanged?: () => unknown;
6
+ /** Leave out "Open", e.g. on the thread's own page. Defaults to `true`. */
7
+ open?: boolean;
8
+ /** What the caller may do; without it every action is offered and the API decides. */
9
+ can?: {
10
+ reply?: boolean;
11
+ assign?: boolean;
12
+ hide?: boolean;
13
+ };
14
+ /** The roles the caller may hide the thread below. */
15
+ hideRoles?: string[];
16
+ };
17
+ /**
18
+ * What staff can do with a thread, shared by the list and the thread page: `setStatus`, `assign` (`null` unassigns),
19
+ * `hide` (a slideover with the caller's roles), `exportContact`, `eraseContact` (confirms first) and `menu(thread)`:
20
+ * Open | Assign to me, Close or Reopen, Hide.
21
+ */
22
+ export declare function useInboxThreadActions(): {
23
+ setStatus: (thread: InboxThreadDto, status: InboxThreadStatus) => Promise<InboxThreadDto | undefined>;
24
+ assign: (thread: InboxThreadDto, assigneeId: number | null) => Promise<InboxThreadDto | undefined>;
25
+ hide: (thread: InboxThreadDto, roles: string[]) => Promise<InboxThreadDto | false>;
26
+ exportContact: (contact: InboxContactDto) => Promise<boolean>;
27
+ eraseContact: (contact: InboxContactDto) => Promise<boolean>;
28
+ menu: (thread: InboxThreadDto, options?: InboxThreadMenuOptions) => DropdownMenuItem[][];
29
+ };
@@ -0,0 +1,76 @@
1
+ import InboxHideSlideover from "../components/InboxHideSlideover.vue";
2
+ import { inboxApi } from "../../utils/api.js";
3
+ import { INBOX_STATUS_LABELS } from "../../utils/index.js";
4
+ import { $fetch, useAction, useConfirmDialog, useInboxLinks, useModuleT, useOverlay, useUserSession } from "#imports";
5
+ export function useInboxThreadActions() {
6
+ const t = useModuleT("inbox");
7
+ const overlay = useOverlay();
8
+ const confirm = useConfirmDialog();
9
+ const { run } = useAction();
10
+ const links = useInboxLinks();
11
+ const { user } = useUserSession();
12
+ const myId = () => user.value?.id !== void 0 ? Number(user.value.id) : void 0;
13
+ const subjectOf = (thread) => thread.subject || t("thread.noSubject", "(no subject)");
14
+ async function setStatus(thread, status) {
15
+ return run(
16
+ () => $fetch(inboxApi.admin.thread(thread.id), { method: "PATCH", body: { status } }),
17
+ { success: t(`thread.statusChanged.${status}`, `Marked {subject} as ${(INBOX_STATUS_LABELS[status] ?? status).toLowerCase()}`, { subject: subjectOf(thread) }) }
18
+ );
19
+ }
20
+ async function assign(thread, assigneeId) {
21
+ return run(
22
+ () => $fetch(inboxApi.admin.thread(thread.id), { method: "PATCH", body: { assigneeId } }),
23
+ { success: assigneeId === null ? t("thread.unassigned", "Unassigned {subject}", { subject: subjectOf(thread) }) : t("thread.assigned", "Assigned {subject}", { subject: subjectOf(thread) }) }
24
+ );
25
+ }
26
+ const hide = async (thread, roles) => await overlay.create(InboxHideSlideover, { destroyOnClose: true, props: { thread, roles } }).open();
27
+ async function exportContact(contact) {
28
+ const data = await run(
29
+ () => $fetch(inboxApi.admin.contactExport(contact.id)),
30
+ { success: t("contact.exported", "Exported {name}", { name: contact.name ?? contact.id }), error: t("contact.exportFailed", "Could not export the contact") }
31
+ );
32
+ if (!data) return false;
33
+ const url = URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], { type: "application/json" }));
34
+ const anchor = Object.assign(document.createElement("a"), { href: url, download: `inbox-contact-${contact.id}.json` });
35
+ anchor.click();
36
+ URL.revokeObjectURL(url);
37
+ return true;
38
+ }
39
+ async function eraseContact(contact) {
40
+ const name = contact.name ?? t("contact.unnamed", "this contact");
41
+ const confirmed = await confirm({
42
+ title: t("contact.eraseTitle", "Erase {name}?", { name }),
43
+ description: t("contact.eraseDescription", "Their name, email address and phone number are removed and every message in their threads is blanked. The threads stay, empty. This cannot be undone."),
44
+ confirmText: t("contact.erase", "Erase contact"),
45
+ destructive: true
46
+ });
47
+ if (!confirmed) return false;
48
+ const done = await run(
49
+ () => $fetch(inboxApi.admin.contactErase(contact.id), { method: "POST" }).then(() => true),
50
+ { success: t("contact.erased", "Erased {name}", { name }), error: t("contact.eraseFailed", "Could not erase the contact") }
51
+ );
52
+ return done === true;
53
+ }
54
+ function menu(thread, options = {}) {
55
+ const can = options.can ?? { reply: true, assign: true, hide: true };
56
+ const changed = async (result) => {
57
+ if (result) await options.onChanged?.();
58
+ };
59
+ const open = [];
60
+ const to = links.thread(thread.id);
61
+ if (options.open !== false && to) open.push({ label: t("thread.open", "Open thread"), icon: "i-lucide-arrow-right", to });
62
+ const edits = [];
63
+ const me = myId();
64
+ if (can.assign && me !== void 0) {
65
+ edits.push(thread.assigneeId === me ? { label: t("thread.unassign", "Unassign thread"), icon: "i-lucide-user-minus", onSelect: async () => changed(await assign(thread, null)) } : { label: t("thread.assignToMe", "Assign thread to me"), icon: "i-lucide-user-check", onSelect: async () => changed(await assign(thread, me)) });
66
+ }
67
+ if (can.reply) {
68
+ edits.push(thread.status === "closed" ? { label: t("thread.reopen", "Reopen thread"), icon: "i-lucide-rotate-ccw", onSelect: async () => changed(await setStatus(thread, "open")) } : { label: t("thread.close", "Close thread"), icon: "i-lucide-check", onSelect: async () => changed(await setStatus(thread, "closed")) });
69
+ }
70
+ if (can.hide) {
71
+ edits.push({ label: t("thread.hide", "Hide from lower roles"), icon: "i-lucide-eye-off", onSelect: async () => changed(await hide(thread, options.hideRoles ?? [])) });
72
+ }
73
+ return [open, edits].filter((group) => group.length);
74
+ }
75
+ return { setStatus, assign, hide, exportContact, eraseContact, menu };
76
+ }
@@ -0,0 +1,3 @@
1
+ import type { Translated } from '@frigear-nu/ui/translated';
2
+ /** `tr(value)`: a translated text in the current locale, falling back to the default locale, then `en`, then any. */
3
+ export declare function useInboxTranslate(): (value: Translated | null | undefined) => string;
@@ -0,0 +1,7 @@
1
+ import { translate } from "@frigear-nu/ui/translated";
2
+ import { useTranslatedFallbackLocale, useTranslatedLocale } from "#imports";
3
+ export function useInboxTranslate() {
4
+ const locale = useTranslatedLocale();
5
+ const fallback = useTranslatedFallbackLocale();
6
+ return (value) => translate(value, locale.value, fallback.value);
7
+ }
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,25 @@
1
+ <script setup>
2
+ import { inboxApi } from "../../utils/api";
3
+ import { computed, useInboxLinks, useLazyFetch, useModuleT } from "#imports";
4
+ defineOptions({ name: "InboxDashboardMine" });
5
+ const t = useModuleT("inbox.dashboard");
6
+ const links = useInboxLinks();
7
+ const { data, status } = useLazyFetch(inboxApi.admin.summary, {
8
+ key: "inbox:summary",
9
+ server: false,
10
+ onResponseError: () => {
11
+ }
12
+ });
13
+ const visible = computed(() => status.value === "success" && (data.value?.mailboxes ?? 0) > 0);
14
+ </script>
15
+
16
+ <template>
17
+ <StatCard
18
+ v-if="visible"
19
+ :label="t('mine', 'Assigned to me')"
20
+ icon="i-lucide-user-check"
21
+ :value="data?.mine ?? 0"
22
+ :hint="t('mineHint', 'Open threads waiting for your answer')"
23
+ :to="links.admin({ assignee: 'me' })"
24
+ />
25
+ </template>