@frigear-nu/inbox 0.0.0-stage → 0.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.
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,154 @@
1
+ import { pgTable, text, integer, bigint, boolean, jsonb, timestamp, index, uniqueIndex } from "drizzle-orm/pg-core";
2
+ export const inboxMailboxes = pgTable("inbox_mailboxes", {
3
+ /** `ibx_` + random id. */
4
+ id: text().primaryKey(),
5
+ /** Stable name for code and seeds (`support`), unique. */
6
+ key: text().notNull().unique(),
7
+ /** `platform | team | user` (only `platform` and `team` are used for now). */
8
+ ownerType: text().notNull(),
9
+ /** The owner's id as text; `null` for `platform`. */
10
+ ownerId: text(),
11
+ name: jsonb().$type().notNull(),
12
+ /** Who may read it (`@frigear-nu/auth`): any one grant admits, an empty list admits nobody. */
13
+ grants: jsonb().$type().notNull().default([]),
14
+ /** Days a closed thread is kept; `null` takes the module's `retention.days`. */
15
+ retentionDays: integer(),
16
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
17
+ updatedAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
18
+ }, (t) => [
19
+ index("inbox_mailbox_owner_idx").on(t.ownerType, t.ownerId)
20
+ ]);
21
+ export const inboxChannelAccounts = pgTable("inbox_channel_accounts", {
22
+ /** `ica_` + random id. */
23
+ id: text().primaryKey(),
24
+ mailboxId: text().notNull().references(() => inboxMailboxes.id, { onDelete: "cascade" }),
25
+ /** A registered channel id (`email`, `whatsapp`, ...). */
26
+ channel: text().notNull(),
27
+ /** The identity on the channel (email address, phone number id, page id, form slug), unique per channel. */
28
+ address: text().notNull(),
29
+ /** Settings that are not secret. */
30
+ config: jsonb().$type().notNull(),
31
+ /** The name of a secret in the runtime config or environment; never the secret itself. */
32
+ secretRef: text(),
33
+ enabled: boolean().notNull().default(true),
34
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
35
+ updatedAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
36
+ }, (t) => [
37
+ uniqueIndex("inbox_channel_address_idx").on(t.channel, t.address),
38
+ index("inbox_channel_mailbox_idx").on(t.mailboxId)
39
+ ]);
40
+ export const inboxContacts = pgTable("inbox_contacts", {
41
+ /** `icn_` + random id. */
42
+ id: text().primaryKey(),
43
+ channel: text().notNull(),
44
+ /** Who the person is on the channel (email address, WhatsApp id, page-scoped id); `erased:<id>` once erased. */
45
+ externalId: text().notNull(),
46
+ name: text(),
47
+ email: text(),
48
+ phone: text(),
49
+ /** The signed-in user who wrote, when known. */
50
+ userId: integer(),
51
+ erasedAt: timestamp({ withTimezone: true }),
52
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
53
+ }, (t) => [
54
+ uniqueIndex("inbox_contact_external_idx").on(t.channel, t.externalId),
55
+ index("inbox_contact_user_idx").on(t.userId)
56
+ ]);
57
+ export const inboxThreads = pgTable("inbox_threads", {
58
+ /** `ibt_` + random id. */
59
+ id: text().primaryKey(),
60
+ mailboxId: text().notNull().references(() => inboxMailboxes.id, { onDelete: "cascade" }),
61
+ contactId: text().notNull().references(() => inboxContacts.id),
62
+ /** The account replies go out through; `null` once the account is deleted. */
63
+ channelAccountId: text().references(() => inboxChannelAccounts.id, { onDelete: "set null" }),
64
+ channel: text().notNull(),
65
+ subject: text(),
66
+ /** `subject` folded for search (`searchText` of `@frigear-nu/module-kit/server`); cleared with it. */
67
+ searchText: text().notNull().default(""),
68
+ /** `open | pending | closed`. */
69
+ status: text().notNull().default("open"),
70
+ assigneeId: integer(),
71
+ /** `null`, or the lowest global role that sees the thread. */
72
+ hiddenBelow: text(),
73
+ /** The start of the last message that is not a note, for the thread list. */
74
+ preview: text(),
75
+ lastMessageAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
76
+ /** When retention or an erase blanked its messages. */
77
+ anonymisedAt: timestamp({ withTimezone: true }),
78
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()),
79
+ updatedAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date()).$onUpdateFn(() => /* @__PURE__ */ new Date())
80
+ }, (t) => [
81
+ index("inbox_thread_mailbox_idx").on(t.mailboxId, t.status),
82
+ index("inbox_thread_assignee_idx").on(t.assigneeId),
83
+ index("inbox_thread_contact_idx").on(t.contactId),
84
+ index("inbox_thread_last_idx").on(t.lastMessageAt)
85
+ ]);
86
+ export const inboxMessages = pgTable("inbox_messages", {
87
+ /** `ibm_` + random id. */
88
+ id: text().primaryKey(),
89
+ threadId: text().notNull().references(() => inboxThreads.id, { onDelete: "cascade" }),
90
+ /** `in | out | note`. */
91
+ direction: text().notNull(),
92
+ /** The staff member who replied or wrote the note. */
93
+ authorId: integer(),
94
+ body: text().notNull(),
95
+ attachments: jsonb().$type().notNull(),
96
+ /**
97
+ * Email `Cc` recipients (lower case, valid addresses only): who an inbound message copied (the mailbox's own address
98
+ * left out), or who a reply copied. `null` otherwise.
99
+ */
100
+ cc: jsonb().$type(),
101
+ /**
102
+ * The channel account the message came in on or went out through. No foreign key: it stays when the account is
103
+ * deleted, so the account's provider ids keep their meaning.
104
+ */
105
+ channelAccountId: text(),
106
+ /** `<channel>:<provider id>`, unique per channel account: a webhook delivered twice stores one message. */
107
+ externalId: text(),
108
+ /**
109
+ * The contact who sent an inbound message (`null` for replies and notes). Usually the thread's contact; a reply by
110
+ * email to a contact form thread is filed under the form's contact but sent by the email contact, and exports and
111
+ * erases find it by this column.
112
+ */
113
+ contactId: text(),
114
+ /** Whether the channel verified the sender of an inbound message (see `InboxInboundMessage.authenticated`). */
115
+ authenticated: boolean().notNull().default(false),
116
+ /** Epoch milliseconds: orders a thread's messages (`createdAt` has whole seconds on sqlite). */
117
+ createdAtMs: bigint({ mode: "number" }).notNull().$defaultFn(() => Date.now()),
118
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
119
+ }, (t) => [
120
+ index("inbox_message_thread_idx").on(t.threadId, t.createdAtMs),
121
+ uniqueIndex("inbox_message_external_idx").on(t.channelAccountId, t.externalId),
122
+ index("inbox_message_contact_idx").on(t.contactId)
123
+ ]);
124
+ export const inboxAudit = pgTable("inbox_audit", {
125
+ /** `iba_` + random id. */
126
+ id: text().primaryKey(),
127
+ /** No foreign key: the log outlives deleted threads. */
128
+ threadId: text(),
129
+ /** The thread's mailbox (or the mailbox of a retention run): the log is filtered by mailbox access. */
130
+ mailboxId: text(),
131
+ contactId: text(),
132
+ actorId: integer(),
133
+ /** `viewed | replied | noted | assigned | status | hidden | exported | erased | retention`. */
134
+ action: text().notNull(),
135
+ data: jsonb().$type(),
136
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
137
+ }, (t) => [
138
+ index("inbox_audit_thread_idx").on(t.threadId),
139
+ index("inbox_audit_contact_idx").on(t.contactId),
140
+ index("inbox_audit_mailbox_idx").on(t.mailboxId),
141
+ index("inbox_audit_created_idx").on(t.createdAt)
142
+ ]);
143
+ export const inboxTombstones = pgTable("inbox_tombstones", {
144
+ /** Hex SHA-256 of `<channel account id>:<external id>`: no provider id or address is kept in the clear. */
145
+ key: text().primaryKey(),
146
+ /** The contact who sent the message (no foreign key: the tombstone outlives the contact). */
147
+ contactId: text(),
148
+ /** Written by an erase (GDPR): never pruned, so a replay can never bring the message back. */
149
+ permanent: boolean().notNull().default(false),
150
+ createdAt: timestamp({ withTimezone: true }).notNull().$defaultFn(() => /* @__PURE__ */ new Date())
151
+ }, (t) => [
152
+ index("inbox_tombstone_created_idx").on(t.createdAt),
153
+ index("inbox_tombstone_contact_idx").on(t.contactId)
154
+ ]);