Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(webhooks): added webhook management and logic (#276)

Corentin Thomasset565bd8d7fda0
diff --git a/.github/workflows/ci-apps-papra-server.yaml b/.github/workflows/ci-apps-papra-server.yaml
index a4680d5a..6abe9cca 100644
--- a/.github/workflows/ci-apps-papra-server.yaml
+++ b/.github/workflows/ci-apps-papra-server.yaml
@@ -26,7 +26,9 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
- run: pnpm i --frozen-lockfile
+ run: |
+ pnpm i --frozen-lockfile
+ pnpm --filter "@papra/app-server^..." build
- name: Run linters
run: pnpm lint
diff --git a/.github/workflows/ci-packages-webhook.yaml b/.github/workflows/ci-packages-webhook.yaml
new file mode 100644
index 00000000..591a56a5
--- /dev/null
+++ b/.github/workflows/ci-packages-webhook.yaml
@@ -0,0 +1,41 @@
+name: CI - Webhooks
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ ci-packages-webhooks:
+ name: CI - Webhooks
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: packages/webhooks
+
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
+
+ - name: Install pnpm
+ uses: pnpm/action-setup@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: 'pnpm'
+
+ - name: Install dependencies
+ run: pnpm i
+
+ - name: Run linters
+ run: pnpm lint
+
+ - name: Type check
+ run: pnpm typecheck
+
+ - name: Run unit test
+ run: pnpm test
+
+ - name: Build the app
+ run: pnpm build
\ No newline at end of file
diff --git a/apps/papra-client/package.json b/apps/papra-client/package.json
index d1d8530d..af0f0769 100644
--- a/apps/papra-client/package.json
+++ b/apps/papra-client/package.json
@@ -1,5 +1,5 @@
{
- "name": "@papra/papra-app-client",
+ "name": "@papra/app-client",
"type": "module",
"version": "0.3.0",
"packageManager": "[email protected]",
@@ -63,6 +63,7 @@
"@types/node": "catalog:",
"eslint": "catalog:",
"jsdom": "^25.0.0",
+ "tinyglobby": "^0.2.13",
"tsx": "^4.19.1",
"typescript": "catalog:",
"unocss": "0.65.0-beta.2",
diff --git a/apps/papra-client/src/locales/en.yml b/apps/papra-client/src/locales/en.yml
index ea50e71b..81a0e21c 100644
--- a/apps/papra-client/src/locales/en.yml
+++ b/apps/papra-client/src/locales/en.yml
@@ -77,12 +77,14 @@ layout.menu.home: Home
layout.menu.documents: Documents
layout.menu.tags: Tags
layout.menu.tagging-rules: Tagging rules
-layout.menu.integrations: Integrations
layout.menu.deleted-documents: Deleted documents
-layout.menu.organization-settings: Organization settings
+layout.menu.organization-settings: Settings
layout.menu.api-keys: API keys
layout.menu.settings: Settings
layout.menu.account: Account
+layout.menu.general-settings: General settings
+layout.menu.intake-emails: Intake emails
+layout.menu.webhooks: Webhooks
tagging-rules.field.name: document name
tagging-rules.field.content: document content
@@ -121,9 +123,6 @@ tagging-rules.form.conditions.no-conditions.title: No conditions
tagging-rules.form.conditions.no-conditions.description: You didn't add any conditions to this rule. This rule will apply its tags to all documents.
tagging-rules.form.conditions.no-conditions.confirm: Apply rule without conditions
tagging-rules.form.conditions.no-conditions.cancel: Cancel
-tagging-rules.form.conditions.field.label: Field
-tagging-rules.form.conditions.operator.label: Operator
-tagging-rules.form.conditions.value.label: Value
tagging-rules.form.conditions.value.placeholder: 'Example: invoice'
tagging-rules.form.conditions.value.min-length: Please enter a value for the condition
tagging-rules.form.tags.label: Tags
@@ -132,7 +131,6 @@ tagging-rules.form.tags.min-length: At least one tag to apply is required
tagging-rules.form.tags.add-tag: Create tag
tagging-rules.form.submit: Create rule
tagging-rules.update.title: Update tagging rule
-tagging-rules.update.success: Tagging rule updated successfully
tagging-rules.update.error: Failed to update tagging rule
tagging-rules.update.submit: Update rule
tagging-rules.update.cancel: Cancel
@@ -186,23 +184,62 @@ api-keys.create.form.name.label: Name
api-keys.create.form.name.placeholder: 'Example: My API key'
api-keys.create.form.name.required: Please enter a name for the API key
api-keys.create.form.permissions.label: Permissions
-api-keys.create.form.permissions.description: Select the permissions for the API key.
api-keys.create.form.permissions.required: Please select at least one permission
api-keys.create.form.submit: Create API key
api-keys.create.created.title: API key created
api-keys.create.created.description: The API key has been created successfully. Save it in a secure location as it will not be displayed again.
api-keys.list.title: API keys
api-keys.list.description: Manage your API keys here.
-api-keys.list.delete: Delete
api-keys.list.create: Create API key
api-keys.list.empty.title: No API keys
api-keys.list.empty.description: Create an API key to access the Papra API.
api-keys.list.card.last-used: Last used
api-keys.list.card.never: Never
api-keys.list.card.created: Created
-api-keys.list.card.delete: Delete
api-keys.delete.success: The API key has been deleted successfully
api-keys.delete.confirm.title: Delete API key
api-keys.delete.confirm.message: Are you sure you want to delete this API key? This action cannot be undone.
api-keys.delete.confirm.confirm-button: Delete
api-keys.delete.confirm.cancel-button: Cancel
+
+webhooks.list.title: Webhooks
+webhooks.list.description: Manage your organization webhooks
+webhooks.list.empty.title: No webhooks
+webhooks.list.empty.description: Create your first webhook to start receiving events
+webhooks.list.create: Create webhook
+webhooks.list.card.last-triggered: Last triggered
+webhooks.list.card.never: Never
+webhooks.list.card.created: Created
+
+webhooks.create.title: Create webhook
+webhooks.create.description: Create a new webhook to receive events
+webhooks.create.success: Webhook created successfully
+webhooks.create.back: Back
+webhooks.create.form.submit: Create webhook
+webhooks.create.form.name.label: Webhook name
+webhooks.create.form.name.placeholder: Enter webhook name
+webhooks.create.form.name.required: Name is required
+webhooks.create.form.url.label: Webhook URL
+webhooks.create.form.url.placeholder: Enter webhook URL
+webhooks.create.form.url.required: URL is required
+webhooks.create.form.url.invalid: URL is invalid
+webhooks.create.form.secret.label: Secret
+webhooks.create.form.secret.placeholder: Enter webhook secret
+webhooks.create.form.events.label: Events
+webhooks.create.form.events.required: At least one event is required
+webhooks.update.title: Edit webhook
+webhooks.update.description: Update your webhook details
+webhooks.update.success: Webhook updated successfully
+webhooks.update.submit: Update webhook
+webhooks.update.cancel: Cancel
+webhooks.update.form.secret.placeholder: Enter new secret
+webhooks.update.form.secret.placeholder-redacted: '[Redacted secret]'
+webhooks.update.form.rotate-secret.button: Rotate secret
+webhooks.delete.success: Webhook deleted successfully
+webhooks.delete.confirm.title: Delete webhook
+webhooks.delete.confirm.message: Are you sure you want to delete this webhook?
+webhooks.delete.confirm.confirm-button: Delete
+webhooks.delete.confirm.cancel-button: Cancel
+
+webhooks.events.documents.document:created.description: Document created
+webhooks.events.documents.document:deleted.description: Document deleted
diff --git a/apps/papra-client/src/locales/fr.yml b/apps/papra-client/src/locales/fr.yml
index c21ef139..314cb18b 100644
--- a/apps/papra-client/src/locales/fr.yml
+++ b/apps/papra-client/src/locales/fr.yml
@@ -77,9 +77,8 @@ layout.menu.home: Accueil
layout.menu.documents: Documents
layout.menu.tags: Tags
layout.menu.tagging-rules: Règles de catégorisation
-layout.menu.integrations: Intégrations
layout.menu.deleted-documents: Documents supprimés
-layout.menu.organization-settings: Paramètres de l'organisation
+layout.menu.organization-settings: Paramètres
layout.menu.api-keys: API keys
layout.menu.settings: Paramètres
layout.menu.account: Compte
@@ -123,9 +122,6 @@ tagging-rules.form.conditions.no-conditions.title: Aucune condition
tagging-rules.form.conditions.no-conditions.description: Vous n'avez pas ajouté de conditions à cette règle. Cette règle appliquera ses tags à tous les documents.
tagging-rules.form.conditions.no-conditions.confirm: Appliquer la règle sans conditions
tagging-rules.form.conditions.no-conditions.cancel: Annuler
-tagging-rules.form.conditions.field.label: Champ
-tagging-rules.form.conditions.operator.label: Opérateur
-tagging-rules.form.conditions.value.label: Valeur
tagging-rules.form.conditions.value.placeholder: 'Exemple: facture'
tagging-rules.form.conditions.value.min-length: Veuillez entrer une valeur pour la condition
tagging-rules.form.tags.label: Tags
@@ -134,7 +130,6 @@ tagging-rules.form.tags.min-length: Au moins un tag à appliquer est requis
tagging-rules.form.tags.add-tag: Créer un tag
tagging-rules.form.submit: Créer la règle
tagging-rules.update.title: Mettre à jour la règle de catégorisation
-tagging-rules.update.success: Règle de catégorisation mise à jour avec succès
tagging-rules.update.error: Échec de la mise à jour de la règle de catégorisation
tagging-rules.update.submit: Mettre à jour la règle
tagging-rules.update.cancel: Annuler
@@ -188,21 +183,18 @@ api-keys.create.form.name.label: Nom
api-keys.create.form.name.placeholder: 'Exemple: Ma clé API'
api-keys.create.form.name.required: Veuillez entrer un nom pour la clé API
api-keys.create.form.permissions.label: Permissions
-api-keys.create.form.permissions.description: Sélectionnez les permissions pour la clé API.
api-keys.create.form.permissions.required: Veuillez sélectionner au moins une permission
api-keys.create.form.submit: Créer la clé API
api-keys.create.created.title: Clé API créée
api-keys.create.created.description: La clé API a été créée avec succès. Enregistrez-la dans un endroit sûr car elle ne sera plus affichée.
api-keys.list.title: Clés API
api-keys.list.description: Gérez vos clés API ici.
-api-keys.list.delete: Supprimer
api-keys.list.create: Créer une clé API
api-keys.list.empty.title: Aucune clé API
api-keys.list.empty.description: Créez une clé API pour accéder à l'API de Papra.
api-keys.list.card.last-used: Dernière utilisation
api-keys.list.card.never: Jamais
api-keys.list.card.created: Créée
-api-keys.list.card.delete: Supprimer
api-keys.delete.success: La clé API a été supprimée avec succès
api-keys.delete.confirm.title: Supprimer la clé API
api-keys.delete.confirm.message: Êtes-vous sûr de vouloir supprimer cette clé API ? Cette action est irréversible.
diff --git a/apps/papra-client/src/modules/i18n/locales.test.ts b/apps/papra-client/src/modules/i18n/locales.test.ts
index 8cc3b3d2..cbf5fd3c 100644
--- a/apps/papra-client/src/modules/i18n/locales.test.ts
+++ b/apps/papra-client/src/modules/i18n/locales.test.ts
@@ -1,3 +1,5 @@
+import { readFile } from 'node:fs/promises';
+import { glob } from 'tinyglobby';
import { describe, expect, test } from 'vitest';
const rawLocales = import.meta.glob('../../locales/*.yml', { eager: true });
@@ -28,4 +30,38 @@ describe('locales', () => {
});
});
}
+
+ test('all keys in en.yml must be used in the app (dynamic keys are manually excluded)', async () => {
+ const srcFileNames = await glob(['src/**/*.{ts,tsx}', '!src/**/*.test.*', '!src/modules/i18n/locales.types.ts'], { cwd: process.cwd() });
+
+ // Exclude keys that are used in dynamic contexts
+ const dynamicKeysMatchers = [
+ /^api-errors\./, // api-errors.document.already_exists
+ /^auth\.register\.providers\.[a-z0-9:]+$/, // auth.register.providers.google
+ /^webhooks\.events\.documents\.[a-z0-9:]+.description$/, // webhooks.events.organization.organization:created
+ /^api-keys\.permissions\.[a-z0-9:]+\.[a-z0-9:]+$/, // api-keys.permissions.documents.documents:delete
+ ];
+
+ const keys = new Set(
+ Object
+ .keys(defaultLocal)
+ .filter(key => !dynamicKeysMatchers.some(matcher => matcher.test(key))),
+ );
+
+ for (const srcFileName of srcFileNames) {
+ const fileContent = await readFile(srcFileName, 'utf-8');
+
+ for (const key of keys) {
+ if (fileContent.includes(key)) {
+ keys.delete(key);
+ }
+ }
+
+ if (keys.size === 0) {
+ break;
+ }
+ }
+
+ expect([...keys]).to.eql([], 'Unused keys found in en.yml, please remove them (or add them to the dynamic keys matchers in locales.test.ts if they are used in dynamic contexts)');
+ });
});
diff --git a/apps/papra-client/src/modules/i18n/locales.types.ts b/apps/papra-client/src/modules/i18n/locales.types.ts
index 2d41c8a7..414c255b 100644
--- a/apps/papra-client/src/modules/i18n/locales.types.ts
+++ b/apps/papra-client/src/modules/i18n/locales.types.ts
@@ -75,12 +75,14 @@ export type LocaleKeys =
| 'layout.menu.documents'
| 'layout.menu.tags'
| 'layout.menu.tagging-rules'
- | 'layout.menu.integrations'
| 'layout.menu.deleted-documents'
| 'layout.menu.organization-settings'
| 'layout.menu.api-keys'
| 'layout.menu.settings'
| 'layout.menu.account'
+ | 'layout.menu.general-settings'
+ | 'layout.menu.intake-emails'
+ | 'layout.menu.webhooks'
| 'tagging-rules.field.name'
| 'tagging-rules.field.content'
| 'tagging-rules.operator.equals'
@@ -118,9 +120,6 @@ export type LocaleKeys =
| 'tagging-rules.form.conditions.no-conditions.description'
| 'tagging-rules.form.conditions.no-conditions.confirm'
| 'tagging-rules.form.conditions.no-conditions.cancel'
- | 'tagging-rules.form.conditions.field.label'
- | 'tagging-rules.form.conditions.operator.label'
- | 'tagging-rules.form.conditions.value.label'
| 'tagging-rules.form.conditions.value.placeholder'
| 'tagging-rules.form.conditions.value.min-length'
| 'tagging-rules.form.tags.label'
@@ -129,7 +128,6 @@ export type LocaleKeys =
| 'tagging-rules.form.tags.add-tag'
| 'tagging-rules.form.submit'
| 'tagging-rules.update.title'
- | 'tagging-rules.update.success'
| 'tagging-rules.update.error'
| 'tagging-rules.update.submit'
| 'tagging-rules.update.cancel'
@@ -178,23 +176,59 @@ export type LocaleKeys =
| 'api-keys.create.form.name.placeholder'
| 'api-keys.create.form.name.required'
| 'api-keys.create.form.permissions.label'
- | 'api-keys.create.form.permissions.description'
| 'api-keys.create.form.permissions.required'
| 'api-keys.create.form.submit'
| 'api-keys.create.created.title'
| 'api-keys.create.created.description'
| 'api-keys.list.title'
| 'api-keys.list.description'
- | 'api-keys.list.delete'
| 'api-keys.list.create'
| 'api-keys.list.empty.title'
| 'api-keys.list.empty.description'
| 'api-keys.list.card.last-used'
| 'api-keys.list.card.never'
| 'api-keys.list.card.created'
- | 'api-keys.list.card.delete'
| 'api-keys.delete.success'
| 'api-keys.delete.confirm.title'
| 'api-keys.delete.confirm.message'
| 'api-keys.delete.confirm.confirm-button'
- | 'api-keys.delete.confirm.cancel-button';
+ | 'api-keys.delete.confirm.cancel-button'
+ | 'webhooks.list.title'
+ | 'webhooks.list.description'
+ | 'webhooks.list.empty.title'
+ | 'webhooks.list.empty.description'
+ | 'webhooks.list.create'
+ | 'webhooks.list.card.last-triggered'
+ | 'webhooks.list.card.never'
+ | 'webhooks.list.card.created'
+ | 'webhooks.create.title'
+ | 'webhooks.create.description'
+ | 'webhooks.create.success'
+ | 'webhooks.create.back'
+ | 'webhooks.create.form.submit'
+ | 'webhooks.create.form.name.label'
+ | 'webhooks.create.form.name.placeholder'
+ | 'webhooks.create.form.name.required'
+ | 'webhooks.create.form.url.label'
+ | 'webhooks.create.form.url.placeholder'
+ | 'webhooks.create.form.url.required'
+ | 'webhooks.create.form.url.invalid'
+ | 'webhooks.create.form.secret.label'
+ | 'webhooks.create.form.secret.placeholder'
+ | 'webhooks.create.form.events.label'
+ | 'webhooks.create.form.events.required'
+ | 'webhooks.update.title'
+ | 'webhooks.update.description'
+ | 'webhooks.update.success'
+ | 'webhooks.update.submit'
+ | 'webhooks.update.cancel'
+ | 'webhooks.update.form.secret.placeholder'
+ | 'webhooks.update.form.secret.placeholder-redacted'
+ | 'webhooks.update.form.rotate-secret.button'
+ | 'webhooks.delete.success'
+ | 'webhooks.delete.confirm.title'
+ | 'webhooks.delete.confirm.message'
+ | 'webhooks.delete.confirm.confirm-button'
+ | 'webhooks.delete.confirm.cancel-button'
+ | 'webhooks.events.documents.document:created.description'
+ | 'webhooks.events.documents.document:deleted.description';
diff --git a/apps/papra-client/src/modules/intake-emails/pages/intake-emails.page.tsx b/apps/papra-client/src/modules/intake-emails/pages/intake-emails.page.tsx
index 016ebeb1..58612c60 100644
--- a/apps/papra-client/src/modules/intake-emails/pages/intake-emails.page.tsx
+++ b/apps/papra-client/src/modules/intake-emails/pages/intake-emails.page.tsx
@@ -211,9 +211,9 @@ export const IntakeEmailsPage: Component = () => {
};
return (
- <Card class="p-6">
+ <div class="p-6 max-w-screen-md mx-auto mt-10">
- <h2 class="text-base font-bold">Intake Emails</h2>
+ <h1 class="text-xl font-semibold">Intake Emails</h1>
<p class="text-muted-foreground mt-1">
Intake emails address are used to automatically ingest emails into Papra. Just forward emails to the intake email address and their attachments will be added to your organization's documents.
@@ -264,7 +264,7 @@ export const IntakeEmailsPage: Component = () => {
<div class="flex flex-col gap-2">
<For each={intakeEmails()}>
{intakeEmail => (
- <div class="flex items-center justify-between border rounded-lg p-4">
+ <div class="flex items-center justify-between border rounded-lg p-4 bg-card">
<div class="flex items-center gap-4">
<div class="bg-muted size-9 rounded-lg flex items-center justify-center">
<div class={cn('i-tabler-mail size-5', intakeEmail.isEnabled ? 'text-primary' : 'text-muted-foreground')} />
@@ -342,6 +342,6 @@ export const IntakeEmailsPage: Component = () => {
)}
</Show>
</Suspense>
- </Card>
+ </div>
);
};
diff --git a/apps/papra-client/src/modules/organizations/pages/organizations-settings.page.tsx b/apps/papra-client/src/modules/organizations/pages/organizations-settings.page.tsx
index 1dc7b13b..a42dedf6 100644
--- a/apps/papra-client/src/modules/organizations/pages/organizations-settings.page.tsx
+++ b/apps/papra-client/src/modules/organizations/pages/organizations-settings.page.tsx
@@ -165,7 +165,7 @@ export const OrganizationsSettingsPage: Component = () => {
}));
return (
- <div class="p-6 mt-4 pb-32 mx-auto max-w-xl">
+ <div class="p-6 mt-10 pb-32 mx-auto max-w-screen-md w-full">
<Suspense>
<Show when={query.data?.organization}>
{ getOrganization => (
diff --git a/apps/papra-client/src/modules/ui/layouts/integrations.layout.tsx b/apps/papra-client/src/modules/ui/layouts/integrations.layout.tsx
deleted file mode 100644
index b5db2a04..00000000
--- a/apps/papra-client/src/modules/ui/layouts/integrations.layout.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { ParentComponent } from 'solid-js';
-import { A, useParams } from '@solidjs/router';
-import { Button } from '../components/button';
-
-export const IntegrationsLayout: ParentComponent = (props) => {
- const params = useParams();
-
- return (
- <div class="p-6 mt-4 pb-32 mx-auto max-w-5xl">
- <div class="border-b mb-6">
- <h1 class="text-xl font-bold">
- Integrations
- </h1>
-
- <p class="text-muted-foreground mt-1">
- Manage your organization's integrations
- </p>
-
- <div class="flex gap-2 mt-4">
- <Button as={A} href={`/organizations/${params.organizationId}/intake-emails`} variant="ghost" activeClass="border-b border-primary text-foreground!" class="text-muted-foreground rounded-b-none">
- Intake Emails
- </Button>
-
- <Button as={A} href={`/organizations/${params.organizationId}/api-keys`} variant="ghost" activeClass="border-b border-primary text-foreground!" class="text-muted-foreground rounded-b-none">
- API Keys
- </Button>
- </div>
- </div>
-
- {props.children}
- </div>
- );
-};
diff --git a/apps/papra-client/src/modules/ui/layouts/organization-settings.layout.tsx b/apps/papra-client/src/modules/ui/layouts/organization-settings.layout.tsx
new file mode 100644
index 00000000..676096f8
--- /dev/null
+++ b/apps/papra-client/src/modules/ui/layouts/organization-settings.layout.tsx
@@ -0,0 +1,53 @@
+import type { ParentComponent } from 'solid-js';
+import { useI18n } from '@/modules/i18n/i18n.provider';
+import { A, useParams } from '@solidjs/router';
+import { Button } from '../components/button';
+import { SideNav } from './sidenav.layout';
+
+export const OrganizationSettingsLayout: ParentComponent = (props) => {
+ const params = useParams();
+ const { t } = useI18n();
+
+ const getNavigationItems = () => [
+ {
+ label: t('layout.menu.general-settings'),
+ href: `/organizations/${params.organizationId}/settings`,
+ icon: 'i-tabler-settings',
+ },
+ {
+ label: t('layout.menu.intake-emails'),
+ href: `/organizations/${params.organizationId}/settings/intake-emails`,
+ icon: 'i-tabler-mail',
+ },
+ {
+ label: t('layout.menu.webhooks'),
+ href: `/organizations/${params.organizationId}/settings/webhooks`,
+ icon: 'i-tabler-webhook',
+ },
+ ];
+
+ return (
+ <div class="flex flex-row h-screen min-h-0">
+ <div class="w-350px border-r border-r-border flex-shrink-0 hidden md:block bg-card">
+
+ <SideNav
+ mainMenu={getNavigationItems()}
+ header={() => (
+ <div class="pl-6 py-3 border-b border-b-border flex items-center gap-1">
+ <Button variant="ghost" size="icon" class="text-muted-foreground" as={A} href="/">
+ <div class="i-tabler-arrow-left size-5"></div>
+ </Button>
+ <h1 class="text-base font-bold">
+ Organization Settings
+ </h1>
+ </div>
+ )}
+ />
+
+ </div>
+ <div class="flex-1 min-h-0 flex flex-col">
+ {props.children}
+ </div>
+ </div>
+ );
+};
diff --git a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
index ec1672ca..07cf4219 100644
--- a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
+++ b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
@@ -45,11 +45,6 @@ const OrganizationLayoutSideNav: Component = () => {
icon: 'i-tabler-list-check',
href: `/organizations/${params.organizationId}/tagging-rules`,
},
- {
- label: t('layout.menu.integrations'),
- icon: 'i-tabler-link',
- href: `/organizations/${params.organizationId}/intake-emails`,
- },
];
diff --git a/apps/papra-client/src/modules/ui/layouts/sidenav.layout.tsx b/apps/papra-client/src/modules/ui/layouts/sidenav.layout.tsx
index 12240c21..b2a085d5 100644
--- a/apps/papra-client/src/modules/ui/layouts/sidenav.layout.tsx
+++ b/apps/papra-client/src/modules/ui/layouts/sidenav.layout.tsx
@@ -27,12 +27,10 @@ type MenuItem = {
const MenuItemButton: Component<MenuItem> = (props) => {
return (
- <Button class="block" variant="ghost" {...(props.onClick ? { onClick: props.onClick } : { as: A, href: props.href, activeClass: 'bg-accent/50! text-accent-foreground! truncate', end: true } as ComponentProps<typeof Button>)}>
- <div class="flex items-center gap-2 dark:text-muted-foreground truncate">
- <div class={cn(props.icon, 'size-5')}></div>
- <div>{props.label}</div>
- {props.badge && <div class="ml-auto">{props.badge}</div>}
- </div>
+ <Button class="justify-start items-center gap-2 dark:text-muted-foreground truncate" variant="ghost" {...(props.onClick ? { onClick: props.onClick } : { as: A, href: props.href, activeClass: 'bg-accent/50! text-accent-foreground! truncate', end: true } as ComponentProps<typeof Button>)}>
+ <div class={cn(props.icon, 'size-5 text-muted-foreground opacity-50')}></div>
+ <div>{props.label}</div>
+ {props.badge && <div class="ml-auto">{props.badge}</div>}
</Button>
);
};
diff --git a/apps/papra-client/src/modules/webhooks/components/webhook-events-picker.component.tsx b/apps/papra-client/src/modules/webhooks/components/webhook-events-picker.component.tsx
new file mode 100644
index 00000000..dd03afa4
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/components/webhook-events-picker.component.tsx
@@ -0,0 +1,79 @@
+import type { LocaleKeys } from '@/modules/i18n/locales.types';
+import type { Component } from 'solid-js';
+import { useI18n } from '@/modules/i18n/i18n.provider';
+import { Checkbox, CheckboxControl, CheckboxLabel } from '@/modules/ui/components/checkbox';
+import { createSignal, For } from 'solid-js';
+import { WEBHOOK_EVENTS } from '../webhooks.constants';
+
+type WebhookEvent = typeof WEBHOOK_EVENTS[number]['events'][number];
+type WebhookSection = typeof WEBHOOK_EVENTS[number];
+
+export const WebhookEventsPicker: Component<{ events: WebhookEvent[]; onChange: (events: WebhookEvent[]) => void }> = (props) => {
+ const [events, setEvents] = createSignal<WebhookEvent[]>(props.events);
+ const { t } = useI18n();
+
+ const getEventsSections = () => {
+ return WEBHOOK_EVENTS.map((section: WebhookSection) => ({
+ ...section,
+ title: t(`webhooks.events.${section.section}.title` as LocaleKeys),
+ events: section.events.map((event: WebhookEvent) => {
+ const [prefix, suffix] = event.split(':');
+
+ return {
+ name: event,
+ prefix,
+ suffix,
+ description: t(`webhooks.events.${section.section}.${event}.description`),
+ };
+ }),
+ }));
+ };
+
+ const isEventSelected = (event: WebhookEvent) => {
+ return events().includes(event);
+ };
+
+ const toggleEvent = (event: WebhookEvent) => {
+ setEvents((prev) => {
+ if (prev.includes(event)) {
+ return prev.filter(e => e !== event);
+ }
+
+ return [...prev, event];
+ });
+
+ props.onChange(events());
+ };
+
+ return (
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <For each={getEventsSections()}>
+ {section => (
+ <div>
+ <p class="text-muted-foreground text-xs">{section.title}</p>
+
+ <div class="pl-4 flex flex-col gap-4 mt-4">
+ <For each={section.events}>
+ {event => (
+ <Checkbox
+ class="flex items-start gap-2"
+ checked={isEventSelected(event.name)}
+ onChange={() => toggleEvent(event.name)}
+ >
+ <CheckboxControl />
+ <div class="flex flex-col gap-1">
+ <CheckboxLabel class="text-sm leading-none">
+ <div class="font-semibold">{event.description}</div>
+ <div class="text-muted-foreground text-xs mt-1">{event.name}</div>
+ </CheckboxLabel>
+ </div>
+ </Checkbox>
+ )}
+ </For>
+ </div>
+ </div>
+ )}
+ </For>
+ </div>
+ );
+};
diff --git a/apps/papra-client/src/modules/webhooks/pages/create-webhook.page.tsx b/apps/papra-client/src/modules/webhooks/pages/create-webhook.page.tsx
new file mode 100644
index 00000000..6e2f5629
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/pages/create-webhook.page.tsx
@@ -0,0 +1,151 @@
+import type { Component } from 'solid-js';
+import { useI18n } from '@/modules/i18n/i18n.provider';
+import { createForm } from '@/modules/shared/form/form';
+import { queryClient } from '@/modules/shared/query/query-client';
+import { Button } from '@/modules/ui/components/button';
+import { createToast } from '@/modules/ui/components/sonner';
+import { TextField, TextFieldLabel, TextFieldRoot } from '@/modules/ui/components/textfield';
+import { setValue } from '@modular-forms/solid';
+import { A, useNavigate, useParams } from '@solidjs/router';
+import * as v from 'valibot';
+import { WebhookEventsPicker } from '../components/webhook-events-picker.component';
+import { WEBHOOK_EVENT_NAMES } from '../webhooks.constants';
+import { createWebhook } from '../webhooks.services';
+
+export const CreateWebhookPage: Component = () => {
+ const { t } = useI18n();
+ const params = useParams();
+ const navigate = useNavigate();
+
+ const { form, Form, Field } = createForm({
+ onSubmit: async ({ name, url, secret, enabled, events }) => {
+ await createWebhook({
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ organizationId: params.organizationId,
+ });
+
+ await queryClient.invalidateQueries({ queryKey: ['webhooks', params.organizationId] });
+
+ createToast({
+ type: 'success',
+ message: t('webhooks.create.success'),
+ });
+
+ navigate(`/organizations/${params.organizationId}/settings/webhooks`);
+ },
+ schema: v.object({
+ name: v.pipe(
+ v.string(),
+ v.nonEmpty(t('webhooks.create.form.name.required')),
+ ),
+ url: v.pipe(
+ v.string(),
+ v.nonEmpty(t('webhooks.create.form.url.required')),
+ v.url(t('webhooks.create.form.url.invalid')),
+ ),
+ secret: v.optional(v.string()),
+ enabled: v.optional(v.boolean()),
+ events: v.pipe(
+ v.array(v.picklist(WEBHOOK_EVENT_NAMES)),
+ v.nonEmpty(t('webhooks.create.form.events.required')),
+ ),
+ }),
+ initialValues: {
+ name: '',
+ url: '',
+ secret: '',
+ enabled: true,
+ events: [],
+ },
+ });
+
+ return (
+ <div class="p-6 mt-12 pb-32 mx-auto max-w-xl w-full">
+ <div class="border-b pb-4 mb-6">
+ <h1 class="text-2xl font-bold">{t('webhooks.create.title')}</h1>
+ <p class="text-sm text-muted-foreground">{t('webhooks.create.description')}</p>
+ </div>
+
+ <Form>
+ <Field name="name">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mb-6">
+ <TextFieldLabel for="name">{t('webhooks.create.form.name.label')}</TextFieldLabel>
+ <TextField
+ type="text"
+ id="name"
+ placeholder={t('webhooks.create.form.name.placeholder')}
+ {...inputProps}
+ autoFocus
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ />
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+
+ <Field name="url">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mb-6">
+ <TextFieldLabel for="url">{t('webhooks.create.form.url.label')}</TextFieldLabel>
+ <TextField
+ type="url"
+ id="url"
+ placeholder={t('webhooks.create.form.url.placeholder')}
+ {...inputProps}
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ />
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+
+ <Field name="secret">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mb-6">
+ <TextFieldLabel for="secret">{t('webhooks.create.form.secret.label')}</TextFieldLabel>
+ <TextField
+ type="password"
+ id="secret"
+ placeholder={t('webhooks.create.form.secret.placeholder')}
+ {...inputProps}
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ />
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+
+ <Field name="events" type="string[]">
+ {field => (
+ <div>
+ <p class="text-sm font-bold">{t('webhooks.create.form.events.label')}</p>
+
+ <div class="p-6 pb-8 border rounded-md mt-2">
+ <WebhookEventsPicker events={field.value ?? []} onChange={events => setValue(form, 'events', events)} />
+ </div>
+
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </div>
+ )}
+ </Field>
+
+ <div class="flex justify-end mt-6">
+ <Button type="button" variant="secondary" as={A} href={`/organizations/${params.organizationId}/settings/webhooks`}>
+ {t('webhooks.create.back')}
+ </Button>
+ <Button type="submit" class="ml-2" isLoading={form.submitting}>
+ {t('webhooks.create.form.submit')}
+ </Button>
+ </div>
+ </Form>
+ </div>
+ );
+};
diff --git a/apps/papra-client/src/modules/webhooks/pages/edit-webhook.page.tsx b/apps/papra-client/src/modules/webhooks/pages/edit-webhook.page.tsx
new file mode 100644
index 00000000..6e81abbb
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/pages/edit-webhook.page.tsx
@@ -0,0 +1,196 @@
+import type { Component } from 'solid-js';
+import type { Webhook } from '../webhooks.types';
+import { useI18n } from '@/modules/i18n/i18n.provider';
+import { createForm } from '@/modules/shared/form/form';
+import { queryClient } from '@/modules/shared/query/query-client';
+import { Button } from '@/modules/ui/components/button';
+import { createToast } from '@/modules/ui/components/sonner';
+import { TextField, TextFieldLabel, TextFieldRoot } from '@/modules/ui/components/textfield';
+import { setValue } from '@modular-forms/solid';
+import { A, useNavigate, useParams } from '@solidjs/router';
+import { createQuery } from '@tanstack/solid-query';
+import { createSignal, Show, Suspense } from 'solid-js';
+import * as v from 'valibot';
+import { WebhookEventsPicker } from '../components/webhook-events-picker.component';
+import { WEBHOOK_EVENT_NAMES } from '../webhooks.constants';
+import { fetchWebhook, updateWebhook } from '../webhooks.services';
+
+export const EditWebhookForm: Component<{ webhook: Webhook }> = (props) => {
+ const { t } = useI18n();
+ const params = useParams();
+ const navigate = useNavigate();
+ const [rotateSecret, setRotateSecret] = createSignal(false);
+
+ const { form, Form, Field } = createForm({
+ onSubmit: async ({ name, url, secret, enabled, events }) => {
+ const updateData = {
+ name,
+ url,
+ enabled,
+ events,
+ };
+
+ // Only include secret if rotation was requested
+ if (rotateSecret() && secret) {
+ Object.assign(updateData, { secret });
+ }
+
+ await updateWebhook({
+ webhookId: params.webhookId,
+ organizationId: params.organizationId,
+ input: updateData,
+ });
+
+ await queryClient.invalidateQueries({ queryKey: ['webhooks', params.organizationId] });
+ await queryClient.invalidateQueries({ queryKey: ['webhook', params.organizationId, params.webhookId] });
+
+ createToast({
+ type: 'success',
+ message: t('webhooks.update.success'),
+ });
+
+ navigate(`/organizations/${params.organizationId}/settings/webhooks`);
+ },
+ schema: v.object({
+ name: v.pipe(
+ v.string(),
+ v.nonEmpty(t('webhooks.create.form.name.required')),
+ ),
+ url: v.pipe(
+ v.string(),
+ v.nonEmpty(t('webhooks.create.form.url.required')),
+ v.url(t('webhooks.create.form.url.invalid')),
+ ),
+ secret: v.optional(v.string()),
+ enabled: v.optional(v.boolean()),
+ events: v.pipe(
+ v.array(v.picklist(WEBHOOK_EVENT_NAMES)),
+ v.nonEmpty(t('webhooks.create.form.events.required')),
+ ),
+ }),
+ initialValues: {
+ name: props.webhook.name,
+ url: props.webhook.url,
+ enabled: props.webhook.enabled,
+ events: props.webhook.events,
+ },
+ });
+
+ return (
+
+ <Form>
+ <Field name="name">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mb-6">
+ <TextFieldLabel for="name">{t('webhooks.create.form.name.label')}</TextFieldLabel>
+ <TextField
+ type="text"
+ id="name"
+ placeholder={t('webhooks.create.form.name.placeholder')}
+ {...inputProps}
+ autoFocus
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ />
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+
+ <Field name="url">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mb-6">
+ <TextFieldLabel for="url">{t('webhooks.create.form.url.label')}</TextFieldLabel>
+ <TextField
+ type="url"
+ id="url"
+ placeholder={t('webhooks.create.form.url.placeholder')}
+ {...inputProps}
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ />
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+
+ <div class="mb-6">
+ <Field name="secret">
+ {(field, inputProps) => (
+ <TextFieldRoot class="flex flex-col mt-4">
+ <TextFieldLabel for="secret">{t('webhooks.create.form.secret.label')}</TextFieldLabel>
+ <div class="flex items-center gap-2">
+ <TextField
+ type="password"
+ id="secret"
+ placeholder={rotateSecret() ? t('webhooks.update.form.secret.placeholder') : t('webhooks.update.form.secret.placeholder-redacted')}
+ {...inputProps}
+ value={field.value}
+ aria-invalid={Boolean(field.error)}
+ disabled={!rotateSecret()}
+ />
+ <Show when={!rotateSecret()}>
+ <Button type="button" variant="secondary" onClick={() => setRotateSecret(true)} class="flex-shrink-0">
+ {t('webhooks.update.form.rotate-secret.button')}
+ </Button>
+ </Show>
+ </div>
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </TextFieldRoot>
+ )}
+ </Field>
+ </div>
+
+ <Field name="events" type="string[]">
+ {field => (
+ <div>
+ <p class="text-sm font-bold">{t('webhooks.create.form.events.label')}</p>
+
+ <div class="p-6 pb-8 border rounded-md mt-2">
+ <WebhookEventsPicker events={field.value ?? []} onChange={events => setValue(form, 'events', events)} />
+ </div>
+
+ {field.error && <div class="text-red-500 text-sm">{field.error}</div>}
+ </div>
+ )}
+ </Field>
+
+ <div class="flex justify-end mt-6">
+ <Button type="button" variant="secondary" as={A} href={`/organizations/${params.organizationId}/settings/webhooks`}>
+ {t('webhooks.update.cancel')}
+ </Button>
+ <Button type="submit" class="ml-2" isLoading={form.submitting}>
+ {t('webhooks.update.submit')}
+ </Button>
+ </div>
+ </Form>
+ );
+};
+
+export const EditWebhookPage: Component = () => {
+ const { t } = useI18n();
+ const params = useParams();
+
+ const webhookQuery = createQuery(() => ({
+ queryKey: ['webhook', params.organizationId, params.webhookId],
+ queryFn: () => fetchWebhook({
+ organizationId: params.organizationId,
+ webhookId: params.webhookId,
+ }),
+ }));
+
+ return (
+ <div class="p-6 mt-12 pb-32 mx-auto max-w-xl w-full">
+ <div class="border-b pb-4 mb-6">
+ <h1 class="text-2xl font-bold">{t('webhooks.update.title')}</h1>
+ <p class="text-sm text-muted-foreground">{t('webhooks.update.description')}</p>
+ </div>
+
+ <Suspense>
+ <Show when={webhookQuery.data?.webhook}>
+ {getWebhook => <EditWebhookForm webhook={getWebhook()} />}
+ </Show>
+ </Suspense>
+ </div>
+ );
+};
diff --git a/apps/papra-client/src/modules/webhooks/pages/webhooks.page.tsx b/apps/papra-client/src/modules/webhooks/pages/webhooks.page.tsx
new file mode 100644
index 00000000..20873eec
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/pages/webhooks.page.tsx
@@ -0,0 +1,157 @@
+import type { Component } from 'solid-js';
+import type { Webhook } from '../webhooks.types';
+import { useI18n } from '@/modules/i18n/i18n.provider';
+import { useConfirmModal } from '@/modules/shared/confirm';
+import { queryClient } from '@/modules/shared/query/query-client';
+import { Button } from '@/modules/ui/components/button';
+import { EmptyState } from '@/modules/ui/components/empty';
+import { createToast } from '@/modules/ui/components/sonner';
+import { A, useParams } from '@solidjs/router';
+import { createMutation, createQuery } from '@tanstack/solid-query';
+import { format } from 'date-fns';
+import { For, Match, Show, Suspense, Switch } from 'solid-js';
+import { deleteWebhook, fetchWebhooks } from '../webhooks.services';
+
+export const WebhookCard: Component<{ webhook: Webhook }> = ({ webhook }) => {
+ const { t } = useI18n();
+ const { confirm } = useConfirmModal();
+ const params = useParams();
+
+ const deleteWebhookMutation = createMutation(() => ({
+ mutationFn: deleteWebhook,
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ['webhooks', params.organizationId] });
+ createToast({
+ message: t('webhooks.delete.success'),
+ });
+ },
+ }));
+
+ const handleDelete = async () => {
+ const confirmed = await confirm({
+ title: t('webhooks.delete.confirm.title'),
+ message: t('webhooks.delete.confirm.message'),
+ confirmButton: {
+ text: t('webhooks.delete.confirm.confirm-button'),
+ variant: 'destructive',
+ },
+ cancelButton: {
+ text: t('webhooks.delete.confirm.cancel-button'),
+ },
+ });
+
+ if (!confirmed) {
+ return;
+ }
+
+ deleteWebhookMutation.mutate({ webhookId: webhook.id, organizationId: params.organizationId });
+ };
+
+ return (
+ <div class="bg-card rounded-lg border p-4 flex items-center gap-4">
+ <div class="rounded-lg bg-muted p-2">
+ <div class="i-tabler-webhook text-muted-foreground size-5 text-primary" />
+ </div>
+ <div class="flex-1 flex flex-col gap-1 overflow-hidden">
+ <h2 class="text-sm font-medium leading-tight">{webhook.name}</h2>
+ <p class="text-muted-foreground text-xs font-mono truncate">{webhook.url}</p>
+ </div>
+
+ <div>
+ <p class="text-muted-foreground text-xs">
+ {t('webhooks.list.card.last-triggered')}
+ {' '}
+ {webhook.lastTriggeredAt ? format(webhook.lastTriggeredAt, 'MMM d, yyyy') : t('webhooks.list.card.never')}
+ </p>
+ <p class="text-muted-foreground text-xs">
+ {t('webhooks.list.card.created')}
+ {' '}
+ {format(webhook.createdAt, 'MMM d, yyyy')}
+ </p>
+ </div>
+
+ <div class="flex items-center gap-2">
+ <Button
+ variant="outline"
+ size="icon"
+ as={A}
+ href={`/organizations/${params.organizationId}/settings/webhooks/${webhook.id}`}
+ >
+ <div class="i-tabler-edit text-muted-foreground size-4" />
+ </Button>
+ <Button
+ variant="outline"
+ size="icon"
+ isLoading={deleteWebhookMutation.isPending}
+ onClick={handleDelete}
+ >
+ <div class="i-tabler-trash text-muted-foreground size-4" />
+ </Button>
+ </div>
+ </div>
+ );
+};
+
+export const WebhooksPage: Component = () => {
+ const { t } = useI18n();
+ const params = useParams();
+ const query = createQuery(() => ({
+ queryKey: ['webhooks', params.organizationId],
+ queryFn: () => fetchWebhooks({ organizationId: params.organizationId }),
+ }));
+
+ return (
+ <div class="p-6 mt-10 pb-32 mx-auto max-w-screen-md w-full">
+
+ <div class="flex gap-4 items-center justify-between">
+ <div>
+ <h1 class="text-xl font-semibold mb-2">
+ {t('webhooks.list.title')}
+ </h1>
+
+ <p class="text-muted-foreground">
+ {t('webhooks.list.description')}
+ </p>
+ </div>
+
+ <Show when={query.data?.webhooks?.length}>
+ <Button as={A} href={`/organizations/${params.organizationId}/settings/webhooks/create`} class="gap-2">
+ <div class="i-tabler-plus size-4" />
+ {t('webhooks.list.create')}
+ </Button>
+ </Show>
+ </div>
+
+ <Suspense>
+ <Switch>
+ <Match when={query.data?.webhooks?.length === 0}>
+ <div class="mt-4 py-8 border-2 border-dashed rounded-lg text-center">
+ <EmptyState
+ title={t('webhooks.list.empty.title')}
+ description={t('webhooks.list.empty.description')}
+ icon="i-tabler-webhook"
+ class="p-0"
+ cta={(
+ <Button as={A} href={`/organizations/${params.organizationId}/settings/webhooks/create`} class="gap-2">
+ <div class="i-tabler-plus size-4" />
+ {t('webhooks.list.create')}
+ </Button>
+ )}
+ />
+ </div>
+ </Match>
+
+ <Match when={query.data?.webhooks?.length}>
+ <div class="mt-6 flex flex-col gap-2">
+ <For each={query.data?.webhooks}>
+ {webhook => (
+ <WebhookCard webhook={webhook} />
+ )}
+ </For>
+ </div>
+ </Match>
+ </Switch>
+ </Suspense>
+ </div>
+ );
+};
diff --git a/apps/papra-client/src/modules/webhooks/webhooks.constants.ts b/apps/papra-client/src/modules/webhooks/webhooks.constants.ts
new file mode 100644
index 00000000..ad0fd32e
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/webhooks.constants.ts
@@ -0,0 +1,12 @@
+export const WEBHOOK_EVENTS = [
+ {
+ section: 'documents',
+ events: [
+ 'document:created',
+ 'document:deleted',
+ ],
+ },
+
+] as const;
+
+export const WEBHOOK_EVENT_NAMES = WEBHOOK_EVENTS.flatMap(event => event.events);
diff --git a/apps/papra-client/src/modules/webhooks/webhooks.services.ts b/apps/papra-client/src/modules/webhooks/webhooks.services.ts
new file mode 100644
index 00000000..b3191f1a
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/webhooks.services.ts
@@ -0,0 +1,62 @@
+import type { CreateWebhookInput, UpdateWebhookInput, Webhook } from './webhooks.types';
+import { apiClient } from '../shared/http/api-client';
+import { coerceDates } from '../shared/http/http-client.models';
+
+export async function createWebhook({ organizationId, ...input }: CreateWebhookInput) {
+ const { webhook } = await apiClient<{
+ webhook: Webhook;
+ }>({
+ path: `/api/organizations/${organizationId}/webhooks`,
+ method: 'POST',
+ body: input,
+ });
+
+ return {
+ webhook: coerceDates(webhook),
+ };
+}
+
+export async function fetchWebhooks({ organizationId }: { organizationId: string }) {
+ const { webhooks } = await apiClient<{
+ webhooks: Webhook[];
+ }>({
+ path: `/api/organizations/${organizationId}/webhooks`,
+ });
+
+ return {
+ webhooks: webhooks.map(coerceDates),
+ };
+}
+
+export async function fetchWebhook({ webhookId, organizationId }: { webhookId: string; organizationId: string }) {
+ const { webhook } = await apiClient<{
+ webhook: Webhook;
+ }>({
+ path: `/api/organizations/${organizationId}/webhooks/${webhookId}`,
+ });
+
+ return {
+ webhook: coerceDates(webhook),
+ };
+}
+
+export async function updateWebhook({ webhookId, organizationId, input }: { webhookId: string; organizationId: string; input: UpdateWebhookInput }) {
+ const { webhook } = await apiClient<{
+ webhook: Webhook;
+ }>({
+ path: `/api/organizations/${organizationId}/webhooks/${webhookId}`,
+ method: 'PUT',
+ body: input,
+ });
+
+ return {
+ webhook: coerceDates(webhook),
+ };
+}
+
+export async function deleteWebhook({ webhookId, organizationId }: { webhookId: string; organizationId: string }) {
+ await apiClient({
+ path: `/api/organizations/${organizationId}/webhooks/${webhookId}`,
+ method: 'DELETE',
+ });
+}
diff --git a/apps/papra-client/src/modules/webhooks/webhooks.types.ts b/apps/papra-client/src/modules/webhooks/webhooks.types.ts
new file mode 100644
index 00000000..e889b1ed
--- /dev/null
+++ b/apps/papra-client/src/modules/webhooks/webhooks.types.ts
@@ -0,0 +1,34 @@
+import type { WEBHOOK_EVENT_NAMES } from './webhooks.constants';
+
+export type WebhookEvent = (typeof WEBHOOK_EVENT_NAMES)[number];
+
+export type Webhook = {
+ id: string;
+ name: string;
+ url: string;
+ secret?: string;
+ enabled: boolean;
+ events: WebhookEvent[];
+ organizationId: string;
+ createdAt: Date;
+ updatedAt: Date;
+ lastTriggeredAt?: Date;
+ lastError?: string;
+};
+
+export type CreateWebhookInput = {
+ name: string;
+ url: string;
+ secret?: string;
+ enabled?: boolean;
+ events?: WebhookEvent[];
+ organizationId: string;
+};
+
+export type UpdateWebhookInput = {
+ name?: string;
+ url?: string;
+ secret?: string;
+ enabled?: boolean;
+ events?: WebhookEvent[];
+};
diff --git a/apps/papra-client/src/routes.tsx b/apps/papra-client/src/routes.tsx
index 5418c531..d624fa6f 100644
--- a/apps/papra-client/src/routes.tsx
+++ b/apps/papra-client/src/routes.tsx
@@ -20,17 +20,19 @@ import { CreateOrganizationPage } from './modules/organizations/pages/create-org
import { OrganizationPage } from './modules/organizations/pages/organization.page';
import { OrganizationsSettingsPage } from './modules/organizations/pages/organizations-settings.page';
import { OrganizationsPage } from './modules/organizations/pages/organizations.page';
-import { ComingSoonPage } from './modules/shared/pages/coming-soon.page';
import { NotFoundPage } from './modules/shared/pages/not-found.page';
import { CreateTaggingRulePage } from './modules/tagging-rules/pages/create-tagging-rule.page';
import { TaggingRulesPage } from './modules/tagging-rules/pages/tagging-rules.page';
import { UpdateTaggingRulePage } from './modules/tagging-rules/pages/update-tagging-rule.page';
import { TagsPage } from './modules/tags/pages/tags.page';
-import { IntegrationsLayout } from './modules/ui/layouts/integrations.layout';
+import { OrganizationSettingsLayout } from './modules/ui/layouts/organization-settings.layout';
import { OrganizationLayout } from './modules/ui/layouts/organization.layout';
import { SettingsLayout } from './modules/ui/layouts/settings.layout';
import { CurrentUserProvider, useCurrentUser } from './modules/users/composables/useCurrentUser';
import { UserSettingsPage } from './modules/users/pages/user-settings.page';
+import { CreateWebhookPage } from './modules/webhooks/pages/create-webhook.page';
+import { EditWebhookPage } from './modules/webhooks/pages/edit-webhook.page';
+import { WebhooksPage } from './modules/webhooks/pages/webhooks.page';
export const routes: RouteDefinition[] = [
{
@@ -106,10 +108,6 @@ export const routes: RouteDefinition[] = [
path: '/documents/:documentId',
component: DocumentPage,
},
- {
- path: '/settings',
- component: OrganizationsSettingsPage,
- },
{
path: '/deleted',
component: DeletedDocumentsPage,
@@ -130,19 +128,32 @@ export const routes: RouteDefinition[] = [
path: '/tagging-rules/:taggingRuleId',
component: UpdateTaggingRulePage,
},
+
+ ],
+ },
+ {
+ path: '/:organizationId/settings',
+ component: OrganizationSettingsLayout,
+ children: [
{
path: '/',
- component: IntegrationsLayout,
- children: [
- {
- path: '/intake-emails',
- component: IntakeEmailsPage,
- },
- {
- path: '/api-keys',
- component: ComingSoonPage,
- },
- ],
+ component: OrganizationsSettingsPage,
+ },
+ {
+ path: '/webhooks/create',
+ component: CreateWebhookPage,
+ },
+ {
+ path: '/webhooks/:webhookId',
+ component: EditWebhookPage,
+ },
+ {
+ path: '/intake-emails',
+ component: IntakeEmailsPage,
+ },
+ {
+ path: '/webhooks',
+ component: WebhooksPage,
},
],
},
diff --git a/apps/papra-server/migrations/0004_organizations-webhooks.sql b/apps/papra-server/migrations/0004_organizations-webhooks.sql
new file mode 100644
index 00000000..6082e103
--- /dev/null
+++ b/apps/papra-server/migrations/0004_organizations-webhooks.sql
@@ -0,0 +1,35 @@
+CREATE TABLE `webhook_deliveries` (
+ `id` text PRIMARY KEY NOT NULL,
+ `created_at` integer NOT NULL,
+ `updated_at` integer NOT NULL,
+ `webhook_id` text NOT NULL,
+ `event_name` text NOT NULL,
+ `request_payload` text NOT NULL,
+ `response_payload` text NOT NULL,
+ `response_status` integer NOT NULL,
+ FOREIGN KEY (`webhook_id`) REFERENCES `webhooks`(`id`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE TABLE `webhook_events` (
+ `id` text PRIMARY KEY NOT NULL,
+ `created_at` integer NOT NULL,
+ `updated_at` integer NOT NULL,
+ `webhook_id` text NOT NULL,
+ `event_name` text NOT NULL,
+ FOREIGN KEY (`webhook_id`) REFERENCES `webhooks`(`id`) ON UPDATE cascade ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE UNIQUE INDEX `webhook_events_webhook_id_event_name_unique` ON `webhook_events` (`webhook_id`,`event_name`);--> statement-breakpoint
+CREATE TABLE `webhooks` (
+ `id` text PRIMARY KEY NOT NULL,
+ `created_at` integer NOT NULL,
+ `updated_at` integer NOT NULL,
+ `name` text NOT NULL,
+ `url` text NOT NULL,
+ `secret` text,
+ `enabled` integer DEFAULT true NOT NULL,
+ `created_by` text,
+ `organization_id` text,
+ FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE set null,
+ FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE cascade ON DELETE cascade
+);
diff --git a/apps/papra-server/migrations/meta/0004_snapshot.json b/apps/papra-server/migrations/meta/0004_snapshot.json
new file mode 100644
index 00000000..dc0a44a2
--- /dev/null
+++ b/apps/papra-server/migrations/meta/0004_snapshot.json
@@ -0,0 +1,1861 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "73fa27b4-1c62-4631-b2e8-9e6b9128d030",
+ "prevId": "5986ec37-a9d8-46a4-8669-e0650dac4726",
+ "tables": {
+ "documents": {
+ "name": "documents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "deleted_by": {
+ "name": "deleted_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "original_name": {
+ "name": "original_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "original_size": {
+ "name": "original_size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "original_storage_key": {
+ "name": "original_storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "original_sha256_hash": {
+ "name": "original_sha256_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ }
+ },
+ "indexes": {
+ "documents_organization_id_is_deleted_created_at_index": {
+ "name": "documents_organization_id_is_deleted_created_at_index",
+ "columns": [
+ "organization_id",
+ "is_deleted",
+ "created_at"
+ ],
+ "isUnique": false
+ },
+ "documents_organization_id_is_deleted_index": {
+ "name": "documents_organization_id_is_deleted_index",
+ "columns": [
+ "organization_id",
+ "is_deleted"
+ ],
+ "isUnique": false
+ },
+ "documents_organization_id_original_sha256_hash_unique": {
+ "name": "documents_organization_id_original_sha256_hash_unique",
+ "columns": [
+ "organization_id",
+ "original_sha256_hash"
+ ],
+ "isUnique": true
+ },
+ "documents_original_sha256_hash_index": {
+ "name": "documents_original_sha256_hash_index",
+ "columns": [
+ "original_sha256_hash"
+ ],
+ "isUnique": false
+ },
+ "documents_organization_id_size_index": {
+ "name": "documents_organization_id_size_index",
+ "columns": [
+ "organization_id",
+ "original_size"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "documents_organization_id_organizations_id_fk": {
+ "name": "documents_organization_id_organizations_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "documents_created_by_users_id_fk": {
+ "name": "documents_created_by_users_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "documents_deleted_by_users_id_fk": {
+ "name": "documents_deleted_by_users_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "deleted_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organization_invitations": {
+ "name": "organization_invitations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_invitations_organization_id_organizations_id_fk": {
+ "name": "organization_invitations_organization_id_organizations_id_fk",
+ "tableFrom": "organization_invitations",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "organization_invitations_inviter_id_users_id_fk": {
+ "name": "organization_invitations_inviter_id_users_id_fk",
+ "tableFrom": "organization_invitations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "inviter_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organization_members": {
+ "name": "organization_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "organization_members_user_organization_unique": {
+ "name": "organization_members_user_organization_unique",
+ "columns": [
+ "organization_id",
+ "user_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "organization_members_organization_id_organizations_id_fk": {
+ "name": "organization_members_organization_id_organizations_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "organization_members_user_id_users_id_fk": {
+ "name": "organization_members_user_id_users_id_fk",
+ "tableFrom": "organization_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organizations": {
+ "name": "organizations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "customer_id": {
+ "name": "customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user_roles": {
+ "name": "user_roles",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_roles_role_index": {
+ "name": "user_roles_role_index",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ },
+ "user_roles_user_id_role_unique_index": {
+ "name": "user_roles_user_id_role_unique_index",
+ "columns": [
+ "user_id",
+ "role"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "user_roles_user_id_users_id_fk": {
+ "name": "user_roles_user_id_users_id_fk",
+ "tableFrom": "user_roles",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "documents_tags": {
+ "name": "documents_tags",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "documents_tags_document_id_documents_id_fk": {
+ "name": "documents_tags_document_id_documents_id_fk",
+ "tableFrom": "documents_tags",
+ "tableTo": "documents",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "documents_tags_tag_id_tags_id_fk": {
+ "name": "documents_tags_tag_id_tags_id_fk",
+ "tableFrom": "documents_tags",
+ "tableTo": "tags",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {
+ "documents_tags_pkey": {
+ "columns": [
+ "document_id",
+ "tag_id"
+ ],
+ "name": "documents_tags_pkey"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tags": {
+ "name": "tags",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "tags_organization_id_name_unique": {
+ "name": "tags_organization_id_name_unique",
+ "columns": [
+ "organization_id",
+ "name"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "tags_organization_id_organizations_id_fk": {
+ "name": "tags_organization_id_organizations_id_fk",
+ "tableFrom": "tags",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "users": {
+ "name": "users",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "max_organization_count": {
+ "name": "max_organization_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "users_email_unique": {
+ "name": "users_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ },
+ "users_email_index": {
+ "name": "users_email_index",
+ "columns": [
+ "email"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "api_key_organizations": {
+ "name": "api_key_organizations",
+ "columns": {
+ "api_key_id": {
+ "name": "api_key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_member_id": {
+ "name": "organization_member_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "api_key_organizations_api_key_id_api_keys_id_fk": {
+ "name": "api_key_organizations_api_key_id_api_keys_id_fk",
+ "tableFrom": "api_key_organizations",
+ "tableTo": "api_keys",
+ "columnsFrom": [
+ "api_key_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "api_key_organizations_organization_member_id_organization_members_id_fk": {
+ "name": "api_key_organizations_organization_member_id_organization_members_id_fk",
+ "tableFrom": "api_key_organizations",
+ "tableTo": "organization_members",
+ "columnsFrom": [
+ "organization_member_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "api_keys": {
+ "name": "api_keys",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "key_hash": {
+ "name": "key_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "all_organizations": {
+ "name": "all_organizations",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "api_keys_key_hash_unique": {
+ "name": "api_keys_key_hash_unique",
+ "columns": [
+ "key_hash"
+ ],
+ "isUnique": true
+ },
+ "key_hash_index": {
+ "name": "key_hash_index",
+ "columns": [
+ "key_hash"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "api_keys_user_id_users_id_fk": {
+ "name": "api_keys_user_id_users_id_fk",
+ "tableFrom": "api_keys",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "auth_accounts": {
+ "name": "auth_accounts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "auth_accounts_user_id_users_id_fk": {
+ "name": "auth_accounts_user_id_users_id_fk",
+ "tableFrom": "auth_accounts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "auth_sessions": {
+ "name": "auth_sessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "auth_sessions_token_index": {
+ "name": "auth_sessions_token_index",
+ "columns": [
+ "token"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "auth_sessions_user_id_users_id_fk": {
+ "name": "auth_sessions_user_id_users_id_fk",
+ "tableFrom": "auth_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "auth_sessions_active_organization_id_organizations_id_fk": {
+ "name": "auth_sessions_active_organization_id_organizations_id_fk",
+ "tableFrom": "auth_sessions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "active_organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "auth_verifications": {
+ "name": "auth_verifications",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "auth_verifications_identifier_index": {
+ "name": "auth_verifications_identifier_index",
+ "columns": [
+ "identifier"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "intake_emails": {
+ "name": "intake_emails",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email_address": {
+ "name": "email_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "allowed_origins": {
+ "name": "allowed_origins",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ }
+ },
+ "indexes": {
+ "intake_emails_email_address_unique": {
+ "name": "intake_emails_email_address_unique",
+ "columns": [
+ "email_address"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "intake_emails_organization_id_organizations_id_fk": {
+ "name": "intake_emails_organization_id_organizations_id_fk",
+ "tableFrom": "intake_emails",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "organization_subscriptions": {
+ "name": "organization_subscriptions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "customer_id": {
+ "name": "customer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "plan_id": {
+ "name": "plan_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "seats_count": {
+ "name": "seats_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "current_period_end": {
+ "name": "current_period_end",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "current_period_start": {
+ "name": "current_period_start",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "cancel_at_period_end": {
+ "name": "cancel_at_period_end",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "organization_subscriptions_organization_id_organizations_id_fk": {
+ "name": "organization_subscriptions_organization_id_organizations_id_fk",
+ "tableFrom": "organization_subscriptions",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tagging_rule_actions": {
+ "name": "tagging_rule_actions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tagging_rule_id": {
+ "name": "tagging_rule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "tagging_rule_actions_tagging_rule_id_tagging_rules_id_fk": {
+ "name": "tagging_rule_actions_tagging_rule_id_tagging_rules_id_fk",
+ "tableFrom": "tagging_rule_actions",
+ "tableTo": "tagging_rules",
+ "columnsFrom": [
+ "tagging_rule_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ },
+ "tagging_rule_actions_tag_id_tags_id_fk": {
+ "name": "tagging_rule_actions_tag_id_tags_id_fk",
+ "tableFrom": "tagging_rule_actions",
+ "tableTo": "tags",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tagging_rule_conditions": {
+ "name": "tagging_rule_conditions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tagging_rule_id": {
+ "name": "tagging_rule_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "field": {
+ "name": "field",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "operator": {
+ "name": "operator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "is_case_sensitive": {
+ "name": "is_case_sensitive",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "tagging_rule_conditions_tagging_rule_id_tagging_rules_id_fk": {
+ "name": "tagging_rule_conditions_tagging_rule_id_tagging_rules_id_fk",
+ "tableFrom": "tagging_rule_conditions",
+ "tableTo": "tagging_rules",
+ "columnsFrom": [
+ "tagging_rule_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tagging_rules": {
+ "name": "tagging_rules",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "tagging_rules_organization_id_organizations_id_fk": {
+ "name": "tagging_rules_organization_id_organizations_id_fk",
+ "tableFrom": "tagging_rules",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "webhook_deliveries": {
+ "name": "webhook_deliveries",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "event_name": {
+ "name": "event_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "request_payload": {
+ "name": "request_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "response_payload": {
+ "name": "response_payload",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "response_status": {
+ "name": "response_status",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "webhook_deliveries_webhook_id_webhooks_id_fk": {
+ "name": "webhook_deliveries_webhook_id_webhooks_id_fk",
+ "tableFrom": "webhook_deliveries",
+ "tableTo": "webhooks",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "webhook_events": {
+ "name": "webhook_events",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "event_name": {
+ "name": "event_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "webhook_events_webhook_id_event_name_unique": {
+ "name": "webhook_events_webhook_id_event_name_unique",
+ "columns": [
+ "webhook_id",
+ "event_name"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "webhook_events_webhook_id_webhooks_id_fk": {
+ "name": "webhook_events_webhook_id_webhooks_id_fk",
+ "tableFrom": "webhook_events",
+ "tableTo": "webhooks",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "webhooks": {
+ "name": "webhooks",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "webhooks_created_by_users_id_fk": {
+ "name": "webhooks_created_by_users_id_fk",
+ "tableFrom": "webhooks",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "cascade"
+ },
+ "webhooks_organization_id_organizations_id_fk": {
+ "name": "webhooks_organization_id_organizations_id_fk",
+ "tableFrom": "webhooks",
+ "tableTo": "organizations",
+ "columnsFrom": [
+ "organization_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "cascade"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
diff --git a/apps/papra-server/migrations/meta/_journal.json b/apps/papra-server/migrations/meta/_journal.json
index b598a1cb..50d9f20d 100644
--- a/apps/papra-server/migrations/meta/_journal.json
+++ b/apps/papra-server/migrations/meta/_journal.json
@@ -29,6 +29,13 @@
"when": 1745131802627,
"tag": "0003_api-keys",
"breakpoints": true
+ },
+ {
+ "idx": 4,
+ "version": "6",
+ "when": 1746297779495,
+ "tag": "0004_organizations-webhooks",
+ "breakpoints": true
}
]
}
diff --git a/apps/papra-server/package.json b/apps/papra-server/package.json
index 8d96690c..7e03fda8 100644
--- a/apps/papra-server/package.json
+++ b/apps/papra-server/package.json
@@ -1,5 +1,5 @@
{
- "name": "@papra/papra-app-server",
+ "name": "@papra/app-server",
"type": "module",
"version": "0.3.0",
"packageManager": "[email protected]",
@@ -41,6 +41,7 @@
"@owlrelay/api-sdk": "^0.0.2",
"@owlrelay/webhook": "^0.0.3",
"@papra/lecture": "^0.0.4",
+ "@papra/webhooks": "workspace:*",
"@paralleldrive/cuid2": "^2.2.2",
"backblaze-b2": "^1.7.0",
"better-auth": "catalog:",
diff --git a/apps/papra-server/src/modules/app/database/database.test-utils.ts b/apps/papra-server/src/modules/app/database/database.test-utils.ts
index 1d8517b4..f7594576 100644
--- a/apps/papra-server/src/modules/app/database/database.test-utils.ts
+++ b/apps/papra-server/src/modules/app/database/database.test-utils.ts
@@ -7,6 +7,7 @@ import { organizationSubscriptionsTable } from '../../subscriptions/subscription
import { taggingRuleActionsTable, taggingRuleConditionsTable, taggingRulesTable } from '../../tagging-rules/tagging-rules.tables';
import { documentsTagsTable, tagsTable } from '../../tags/tags.table';
import { usersTable } from '../../users/users.table';
+import { webhookDeliveriesTable, webhookEventsTable, webhooksTable } from '../../webhooks/webhooks.tables';
import { setupDatabase } from './database';
import { runMigrations } from './database.services';
@@ -38,6 +39,9 @@ const seedTables = {
taggingRuleActions: taggingRuleActionsTable,
apiKeys: apiKeysTable,
apiKeyOrganizations: apiKeyOrganizationsTable,
+ webhooks: webhooksTable,
+ webhookEvents: webhookEventsTable,
+ webhookDeliveries: webhookDeliveriesTable,
} as const;
type SeedTablesRows = {
diff --git a/apps/papra-server/src/modules/app/server.routes.test.ts b/apps/papra-server/src/modules/app/server.routes.test.ts
index eee21530..d8f9a39b 100644
--- a/apps/papra-server/src/modules/app/server.routes.test.ts
+++ b/apps/papra-server/src/modules/app/server.routes.test.ts
@@ -11,8 +11,8 @@ function setValidParams(path: string) {
.replaceAll(':tagId', 'tag_444444444444444444444444')
.replaceAll(':taggingRuleId', 'rule_555555555555555555555555')
.replaceAll(':intakeEmailId', 'email_666666666666666666666666')
- .replaceAll(':apiKeyId', 'api_key_777777777777777777777777');
-
+ .replaceAll(':apiKeyId', 'api_key_777777777777777777777777')
+ .replaceAll(':webhookId', 'wbh_888888888888888888888888');
// throw if there are any remaining params
if (newPath.match(/:(\w+)/g)) {
throw new Error(`Add a dummy value for the params in ${path}`);
diff --git a/apps/papra-server/src/modules/app/server.routes.ts b/apps/papra-server/src/modules/app/server.routes.ts
index c6911e8e..c9474234 100644
--- a/apps/papra-server/src/modules/app/server.routes.ts
+++ b/apps/papra-server/src/modules/app/server.routes.ts
@@ -8,6 +8,7 @@ import { registerSubscriptionsRoutes } from '../subscriptions/subscriptions.rout
import { registerTaggingRulesRoutes } from '../tagging-rules/tagging-rules.routes';
import { registerTagsRoutes } from '../tags/tags.routes';
import { registerUsersRoutes } from '../users/users.routes';
+import { registerWebhooksRoutes } from '../webhooks/webhook.routes';
import { registerAuthRoutes } from './auth/auth.routes';
import { registerHealthCheckRoutes } from './health-check/health-check.routes';
@@ -23,4 +24,5 @@ export function registerRoutes(context: RouteDefinitionContext) {
registerTagsRoutes(context);
registerTaggingRulesRoutes(context);
registerApiKeysRoutes(context);
+ registerWebhooksRoutes(context);
}
diff --git a/apps/papra-server/src/modules/documents/documents.routes.ts b/apps/papra-server/src/modules/documents/documents.routes.ts
index 142764b9..3ceed21d 100644
--- a/apps/papra-server/src/modules/documents/documents.routes.ts
+++ b/apps/papra-server/src/modules/documents/documents.routes.ts
@@ -12,6 +12,8 @@ import { validateFormData, validateJsonBody, validateParams, validateQuery } fro
import { createSubscriptionsRepository } from '../subscriptions/subscriptions.repository';
import { createTaggingRulesRepository } from '../tagging-rules/tagging-rules.repository';
import { createTagsRepository } from '../tags/tags.repository';
+import { createWebhookRepository } from '../webhooks/webhook.repository';
+import { triggerWebhooks } from '../webhooks/webhook.usecases';
import { createDocumentIsNotDeletedError } from './documents.errors';
import { isDocumentSizeLimitEnabled } from './documents.models';
import { createDocumentsRepository } from './documents.repository';
@@ -93,6 +95,7 @@ function setupCreateDocumentRoute({ app, config, db, trackingServices }: RouteDe
const subscriptionsRepository = createSubscriptionsRepository({ db });
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
const { document } = await createDocument({
file,
@@ -105,6 +108,7 @@ function setupCreateDocumentRoute({ app, config, db, trackingServices }: RouteDe
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
return context.json({
@@ -240,12 +244,19 @@ function setupDeleteDocumentRoute({ app, db }: RouteDefinitionContext) {
const documentsRepository = createDocumentsRepository({ db });
const organizationsRepository = createOrganizationsRepository({ db });
-
+ const webhookRepository = createWebhookRepository({ db });
await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
await ensureDocumentExists({ documentId, organizationId, documentsRepository });
await documentsRepository.softDeleteDocument({ documentId, organizationId, userId });
+ await triggerWebhooks({
+ webhookRepository,
+ organizationId,
+ event: 'document:deleted',
+ payload: { documentId, organizationId },
+ });
+
return context.json({
success: true,
});
diff --git a/apps/papra-server/src/modules/documents/documents.usecases.test.ts b/apps/papra-server/src/modules/documents/documents.usecases.test.ts
index 9106498b..294b9a48 100644
--- a/apps/papra-server/src/modules/documents/documents.usecases.test.ts
+++ b/apps/papra-server/src/modules/documents/documents.usecases.test.ts
@@ -9,6 +9,7 @@ import { createTaggingRulesRepository } from '../tagging-rules/tagging-rules.rep
import { createTagsRepository } from '../tags/tags.repository';
import { documentsTagsTable } from '../tags/tags.table';
import { createDummyTrackingServices } from '../tracking/tracking.services';
+import { createWebhookRepository } from '../webhooks/webhook.repository';
import { createDocumentAlreadyExistsError } from './documents.errors';
import { createDocumentsRepository } from './documents.repository';
import { documentsTable } from './documents.table';
@@ -31,6 +32,7 @@ describe('documents usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
const generateDocumentId = () => 'doc_1';
const file = new File(['content'], 'file.txt', { type: 'text/plain' });
@@ -49,6 +51,7 @@ describe('documents usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
expect(document).to.include({
@@ -90,7 +93,7 @@ describe('documents usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
-
+ const webhookRepository = createWebhookRepository({ db });
let documentIdIndex = 1;
const generateDocumentId = () => `doc_${documentIdIndex++}`;
@@ -110,6 +113,7 @@ describe('documents usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
expect(document1).to.include({
@@ -138,6 +142,7 @@ describe('documents usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}),
).rejects.toThrow(
createDocumentAlreadyExistsError(),
@@ -204,7 +209,7 @@ describe('documents usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
-
+ const webhookRepository = createWebhookRepository({ db });
// 3. Re-create the document
const { document: documentRestored } = await createDocument({
file: new File(['hello world'], 'file-2.txt', { type: 'text/plain' }),
@@ -216,6 +221,7 @@ describe('documents usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
expect(documentRestored).to.deep.include({
@@ -256,6 +262,7 @@ describe('documents usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
const generateDocumentId = () => 'doc_1';
const file = new File(['content'], 'file.txt', { type: 'text/plain' });
@@ -280,6 +287,7 @@ describe('documents usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}),
).rejects.toThrow(new Error('Macron, explosion!'));
diff --git a/apps/papra-server/src/modules/documents/documents.usecases.ts b/apps/papra-server/src/modules/documents/documents.usecases.ts
index 3e26875a..6bc28a07 100644
--- a/apps/papra-server/src/modules/documents/documents.usecases.ts
+++ b/apps/papra-server/src/modules/documents/documents.usecases.ts
@@ -6,6 +6,7 @@ import type { SubscriptionsRepository } from '../subscriptions/subscriptions.rep
import type { TaggingRulesRepository } from '../tagging-rules/tagging-rules.repository';
import type { TagsRepository } from '../tags/tags.repository';
import type { TrackingServices } from '../tracking/tracking.services';
+import type { WebhookRepository } from '../webhooks/webhook.repository';
import type { DocumentsRepository } from './documents.repository';
import type { Document } from './documents.types';
import type { DocumentStorageService } from './storage/documents.storage.services';
@@ -20,6 +21,8 @@ import { createTaggingRulesRepository } from '../tagging-rules/tagging-rules.rep
import { applyTaggingRules } from '../tagging-rules/tagging-rules.usecases';
import { createTagsRepository } from '../tags/tags.repository';
import { createTrackingServices } from '../tracking/tracking.services';
+import { createWebhookRepository } from '../webhooks/webhook.repository';
+import { triggerWebhooks } from '../webhooks/webhook.usecases';
import { createDocumentAlreadyExistsError, createDocumentNotDeletedError, createDocumentNotFoundError } from './documents.errors';
import { buildOriginalDocumentKey, generateDocumentId as generateDocumentIdImpl } from './documents.models';
import { createDocumentsRepository } from './documents.repository';
@@ -32,7 +35,7 @@ export async function extractDocumentText({ file }: { file: File }) {
const { textContent, error, extractorName } = await extractTextFromFile({ file });
if (error) {
- logger.error({ error, extractorName }, 'Error while attempting to extract text from PDF');
+ logger.error({ error, extractorName }, 'Error while extracting text from document');
}
return {
@@ -52,6 +55,7 @@ export async function createDocument({
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
logger = createLogger({ namespace: 'documents:usecases' }),
}: {
file: File;
@@ -65,6 +69,7 @@ export async function createDocument({
trackingServices: TrackingServices;
taggingRulesRepository: TaggingRulesRepository;
tagsRepository: TagsRepository;
+ webhookRepository: WebhookRepository;
logger?: Logger;
}) {
const {
@@ -112,6 +117,19 @@ export async function createDocument({
await applyTaggingRules({ document, taggingRulesRepository, tagsRepository });
+ await triggerWebhooks({
+ webhookRepository,
+ organizationId,
+ event: 'document:created',
+ payload: {
+ documentId: document.id,
+ organizationId,
+ name: document.name,
+ createdAt: document.createdAt,
+ updatedAt: document.updatedAt,
+ },
+ });
+
return { document };
}
@@ -137,6 +155,7 @@ export async function createDocumentCreationUsecase({
trackingServices: createTrackingServices({ config }),
taggingRulesRepository: createTaggingRulesRepository({ db }),
tagsRepository: createTagsRepository({ db }),
+ webhookRepository: createWebhookRepository({ db }),
generateDocumentId,
logger,
};
diff --git a/apps/papra-server/src/modules/intake-emails/intake-emails.routes.ts b/apps/papra-server/src/modules/intake-emails/intake-emails.routes.ts
index dabd8309..f9df4841 100644
--- a/apps/papra-server/src/modules/intake-emails/intake-emails.routes.ts
+++ b/apps/papra-server/src/modules/intake-emails/intake-emails.routes.ts
@@ -17,6 +17,7 @@ import { validateFormData, validateJsonBody, validateParams } from '../shared/va
import { createSubscriptionsRepository } from '../subscriptions/subscriptions.repository';
import { createTaggingRulesRepository } from '../tagging-rules/tagging-rules.repository';
import { createTagsRepository } from '../tags/tags.repository';
+import { createWebhookRepository } from '../webhooks/webhook.repository';
import { INTAKE_EMAILS_INGEST_ROUTE } from './intake-emails.constants';
import { createIntakeEmailsRepository } from './intake-emails.repository';
import { intakeEmailIdSchema, intakeEmailsIngestionMetaSchema, parseJson } from './intake-emails.schemas';
@@ -196,6 +197,7 @@ function setupIngestIntakeEmailRoute({ app, db, config, trackingServices }: Rout
const subscriptionsRepository = createSubscriptionsRepository({ db });
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await processIntakeEmailIngestion({
fromAddress: email.from.address,
@@ -209,6 +211,7 @@ function setupIngestIntakeEmailRoute({ app, db, config, trackingServices }: Rout
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
return context.body(null, 202);
diff --git a/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.test.ts b/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.test.ts
index 5d2ff05d..205c67cf 100644
--- a/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.test.ts
+++ b/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.test.ts
@@ -15,6 +15,7 @@ import { createSubscriptionsRepository } from '../subscriptions/subscriptions.re
import { createTaggingRulesRepository } from '../tagging-rules/tagging-rules.repository';
import { createTagsRepository } from '../tags/tags.repository';
import { createDummyTrackingServices } from '../tracking/tracking.services';
+import { createWebhookRepository } from '../webhooks/webhook.repository';
import { createIntakeEmailLimitReachedError } from './intake-emails.errors';
import { createIntakeEmailsRepository } from './intake-emails.repository';
import { intakeEmailsTable } from './intake-emails.tables';
@@ -37,6 +38,7 @@ describe('intake-emails usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await ingestEmailForRecipient({
fromAddress: '[email protected]',
@@ -53,6 +55,7 @@ describe('intake-emails usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
const documents = await db.select().from(documentsTable).orderBy(asc(documentsTable.name));
@@ -82,6 +85,7 @@ describe('intake-emails usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await ingestEmailForRecipient({
fromAddress: '[email protected]',
@@ -96,6 +100,7 @@ describe('intake-emails usecases', () => {
logger,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
expect(loggerTransport.getLogs({ excludeTimestampMs: true })).to.eql([
@@ -118,6 +123,7 @@ describe('intake-emails usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await ingestEmailForRecipient({
fromAddress: '[email protected]',
@@ -132,6 +138,7 @@ describe('intake-emails usecases', () => {
taggingRulesRepository,
tagsRepository,
logger,
+ webhookRepository,
});
expect(loggerTransport.getLogs({ excludeTimestampMs: true })).to.eql([
@@ -159,6 +166,7 @@ describe('intake-emails usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await ingestEmailForRecipient({
fromAddress: '[email protected]',
@@ -173,6 +181,7 @@ describe('intake-emails usecases', () => {
taggingRulesRepository,
tagsRepository,
logger,
+ webhookRepository,
});
expect(loggerTransport.getLogs({ excludeTimestampMs: true })).to.eql([
@@ -211,6 +220,7 @@ describe('intake-emails usecases', () => {
const trackingServices = createDummyTrackingServices();
const taggingRulesRepository = createTaggingRulesRepository({ db });
const tagsRepository = createTagsRepository({ db });
+ const webhookRepository = createWebhookRepository({ db });
await processIntakeEmailIngestion({
fromAddress: '[email protected]',
@@ -226,6 +236,7 @@ describe('intake-emails usecases', () => {
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
});
const documents = await db.select().from(documentsTable).orderBy(asc(documentsTable.organizationId));
diff --git a/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.ts b/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.ts
index 26482217..c68a0849 100644
--- a/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.ts
+++ b/apps/papra-server/src/modules/intake-emails/intake-emails.usecases.ts
@@ -6,6 +6,7 @@ import type { SubscriptionsRepository } from '../subscriptions/subscriptions.rep
import type { TaggingRulesRepository } from '../tagging-rules/tagging-rules.repository';
import type { TagsRepository } from '../tags/tags.repository';
import type { TrackingServices } from '../tracking/tracking.services';
+import type { WebhookRepository } from '../webhooks/webhook.repository';
import type { IntakeEmailsServices } from './drivers/intake-emails.drivers.models';
import type { IntakeEmailsRepository } from './intake-emails.repository';
import { safely } from '@corentinth/chisels';
@@ -54,6 +55,7 @@ export function processIntakeEmailIngestion({
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}: {
fromAddress: string;
recipientsAddresses: string[];
@@ -66,6 +68,7 @@ export function processIntakeEmailIngestion({
trackingServices: TrackingServices;
taggingRulesRepository: TaggingRulesRepository;
tagsRepository: TagsRepository;
+ webhookRepository: WebhookRepository;
}) {
return Promise.all(
recipientsAddresses.map(recipientAddress => safely(
@@ -81,6 +84,7 @@ export function processIntakeEmailIngestion({
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}),
)),
);
@@ -99,6 +103,7 @@ export async function ingestEmailForRecipient({
subscriptionsRepository,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}: {
fromAddress: string;
recipientAddress: string;
@@ -111,6 +116,7 @@ export async function ingestEmailForRecipient({
trackingServices: TrackingServices;
taggingRulesRepository: TaggingRulesRepository;
tagsRepository: TagsRepository;
+ webhookRepository: WebhookRepository;
logger?: Logger;
}) {
const { intakeEmail } = await intakeEmailsRepository.getIntakeEmailByEmailAddress({ emailAddress: recipientAddress });
@@ -151,6 +157,7 @@ export async function ingestEmailForRecipient({
trackingServices,
taggingRulesRepository,
tagsRepository,
+ webhookRepository,
}));
if (error) {
diff --git a/apps/papra-server/src/modules/webhooks/index.ts b/apps/papra-server/src/modules/webhooks/index.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/apps/papra-server/src/modules/webhooks/webhook.errors.ts b/apps/papra-server/src/modules/webhooks/webhook.errors.ts
new file mode 100644
index 00000000..c8eed80e
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhook.errors.ts
@@ -0,0 +1,7 @@
+import { createErrorFactory } from '../shared/errors/errors';
+
+export const createWebhookNotFoundError = createErrorFactory({
+ message: 'Webhook not found',
+ code: 'webhooks.not_found',
+ statusCode: 404,
+});
diff --git a/apps/papra-server/src/modules/webhooks/webhook.repository.ts b/apps/papra-server/src/modules/webhooks/webhook.repository.ts
new file mode 100644
index 00000000..41e4e49c
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhook.repository.ts
@@ -0,0 +1,154 @@
+import type { EventName } from '@papra/webhooks';
+import type { Database } from '../app/database/database.types';
+import type { Webhook, WebhookDeliveryInsert, WebhookEvent } from './webhooks.types';
+import { injectArguments } from '@corentinth/chisels';
+import { and, eq, getTableColumns } from 'drizzle-orm';
+import { omitUndefined } from '../shared/utils';
+import { webhookDeliveriesTable, webhookEventsTable, webhooksTable } from './webhooks.tables';
+
+export type WebhookRepository = ReturnType<typeof createWebhookRepository>;
+
+export function createWebhookRepository({ db }: { db: Database }) {
+ return injectArguments(
+ {
+ createOrganizationWebhook,
+ updateOrganizationWebhook,
+ getOrganizationWebhookById,
+ deleteOrganizationWebhook,
+ getOrganizationWebhooks,
+ getOrganizationEnabledWebhooksForEvent,
+ saveWebhookDelivery,
+ },
+ { db },
+ );
+}
+
+async function createOrganizationWebhook({ db, ...webhook }: { db: Database } & { name: string; url: string; secret?: string; enabled?: boolean; events?: EventName[]; organizationId: string; createdBy: string }) {
+ const [createdWebhook] = await db.insert(webhooksTable).values(webhook).returning();
+
+ if (webhook.events?.length) {
+ await db
+ .insert(webhookEventsTable)
+ .values(
+ webhook.events.map(eventName => ({
+ webhookId: createdWebhook.id,
+ eventName,
+ })),
+ );
+ }
+
+ return { webhook: createdWebhook };
+}
+
+async function updateOrganizationWebhook({ db, webhookId, events, organizationId, ...webhook }: { db: Database; webhookId: string; events?: EventName[]; organizationId: string } & { name?: string; url?: string; secret?: string; enabled?: boolean }) {
+ const [updatedWebhook] = await db
+ .update(webhooksTable)
+ .set(omitUndefined(webhook))
+ .where(
+ and(
+ eq(webhooksTable.id, webhookId),
+ eq(webhooksTable.organizationId, organizationId),
+ ),
+ )
+ .returning();
+
+ if (events) {
+ // Delete existing events
+ await db
+ .delete(webhookEventsTable)
+ .where(eq(webhookEventsTable.webhookId, webhookId));
+
+ // Insert new events
+ if (events.length) {
+ await db.insert(webhookEventsTable).values(
+ events.map(eventName => ({
+ webhookId,
+ eventName,
+ })),
+ );
+ }
+ }
+
+ return { webhook: updatedWebhook };
+}
+
+async function getOrganizationWebhookById({ db, webhookId, organizationId }: { db: Database; webhookId: string; organizationId: string }) {
+ const records = await db
+ .select({
+ webhook: getTableColumns(webhooksTable),
+ webhookEvents: getTableColumns(webhookEventsTable),
+ })
+ .from(webhooksTable)
+ .leftJoin(webhookEventsTable, eq(webhooksTable.id, webhookEventsTable.webhookId))
+ .where(
+ and(
+ eq(webhooksTable.id, webhookId),
+ eq(webhooksTable.organizationId, organizationId),
+ ),
+ );
+
+ const [{ webhook } = {}] = records;
+ const events = records.map(record => record.webhookEvents?.eventName);
+
+ return { webhook: { ...webhook, events } };
+}
+
+async function deleteOrganizationWebhook({ db, webhookId, organizationId }: { db: Database; webhookId: string; organizationId: string }) {
+ await db.delete(webhooksTable).where(
+ and(
+ eq(webhooksTable.id, webhookId),
+ eq(webhooksTable.organizationId, organizationId),
+ ),
+ );
+}
+
+async function getOrganizationWebhooks({ db, organizationId }: { db: Database; organizationId: string }) {
+ const rawWebhooks = await db
+ .select()
+ .from(webhooksTable)
+ .leftJoin(webhookEventsTable, eq(webhooksTable.id, webhookEventsTable.webhookId))
+ .where(eq(webhooksTable.organizationId, organizationId));
+
+ const webhooksRecord = rawWebhooks
+ .reduce((acc, { webhooks, webhook_events }) => {
+ const webhookId = webhooks.id;
+ const webhookEvents = webhook_events;
+
+ if (!acc[webhookId]) {
+ acc[webhookId] = {
+ ...webhooks,
+ events: [],
+ };
+ }
+
+ if (webhookEvents) {
+ acc[webhookId].events.push(webhookEvents);
+ }
+
+ return acc;
+ }, {} as Record<string, Webhook & { events: WebhookEvent[] }>);
+
+ return { webhooks: Object.values(webhooksRecord) };
+}
+
+async function getOrganizationEnabledWebhooksForEvent({ db, organizationId, event }: { db: Database; organizationId: string; event: EventName }) {
+ const webhooks = await db
+ .select({
+ ...getTableColumns(webhooksTable),
+ })
+ .from(webhooksTable)
+ .leftJoin(webhookEventsTable, eq(webhooksTable.id, webhookEventsTable.webhookId))
+ .where(
+ and(
+ eq(webhooksTable.organizationId, organizationId),
+ eq(webhooksTable.enabled, true),
+ eq(webhookEventsTable.eventName, event),
+ ),
+ );
+
+ return { webhooks };
+}
+
+async function saveWebhookDelivery({ db, ...webhookDelivery }: { db: Database } & WebhookDeliveryInsert) {
+ await db.insert(webhookDeliveriesTable).values(webhookDelivery);
+}
diff --git a/apps/papra-server/src/modules/webhooks/webhook.routes.ts b/apps/papra-server/src/modules/webhooks/webhook.routes.ts
new file mode 100644
index 00000000..4c58d923
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhook.routes.ts
@@ -0,0 +1,185 @@
+import type { RouteDefinitionContext } from '../app/server.types';
+import { omit } from 'lodash-es';
+import { z } from 'zod';
+import { requireAuthentication } from '../app/auth/auth.middleware';
+import { getUser } from '../app/auth/auth.models';
+import { organizationIdSchema } from '../organizations/organization.schemas';
+import { createOrganizationsRepository } from '../organizations/organizations.repository';
+import { ensureUserIsInOrganization } from '../organizations/organizations.usecases';
+import { validateJsonBody, validateParams } from '../shared/validation/validation';
+import { createWebhookNotFoundError } from './webhook.errors';
+import { createWebhookRepository } from './webhook.repository';
+import { createWebhook, updateWebhook } from './webhook.usecases';
+import { webhookEventListSchema } from './webhooks.schemas';
+
+export function registerWebhooksRoutes(context: RouteDefinitionContext) {
+ setupCreateWebhookRoute(context);
+ setupGetWebhooksRoute(context);
+ setupGetWebhookRoute(context);
+ setupUpdateWebhookRoute(context);
+ setupDeleteWebhookRoute(context);
+}
+
+function setupCreateWebhookRoute({ app, db }: RouteDefinitionContext) {
+ app.post(
+ '/api/organizations/:organizationId/webhooks',
+ requireAuthentication(),
+ validateParams(z.object({
+ organizationId: organizationIdSchema,
+ })),
+ validateJsonBody(z.object({
+ name: z.string().min(3).max(50),
+ url: z.string().url(),
+ secret: z.string().min(1).optional(),
+ enabled: z.boolean().optional().default(true),
+ events: webhookEventListSchema.min(1),
+ })),
+ async (context) => {
+ const { userId } = getUser({ context });
+ const { name, url, secret, enabled, events } = context.req.valid('json');
+ const { organizationId } = context.req.valid('param');
+
+ const organizationsRepository = createOrganizationsRepository({ db });
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
+
+ const webhookRepository = createWebhookRepository({ db });
+
+ const { webhook } = await createWebhook({
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ organizationId,
+ webhookRepository,
+ createdBy: userId,
+ });
+
+ return context.json({
+ webhook,
+ });
+ },
+ );
+}
+
+function setupGetWebhooksRoute({ app, db }: RouteDefinitionContext) {
+ app.get(
+ '/api/organizations/:organizationId/webhooks',
+ requireAuthentication(),
+ validateParams(z.object({
+ organizationId: organizationIdSchema,
+ })),
+ async (context) => {
+ const { organizationId } = context.req.valid('param');
+ const webhookRepository = createWebhookRepository({ db });
+
+ const { webhooks } = await webhookRepository.getOrganizationWebhooks({ organizationId });
+
+ return context.json({
+ webhooks: webhooks.map(webhook => omit(webhook, ['secret'])),
+ });
+ },
+ );
+}
+
+function setupGetWebhookRoute({ app, db }: RouteDefinitionContext) {
+ app.get(
+ '/api/organizations/:organizationId/webhooks/:webhookId',
+ requireAuthentication(),
+ validateParams(z.object({
+ organizationId: organizationIdSchema,
+ webhookId: z.string().min(1),
+ })),
+ async (context) => {
+ const { userId } = getUser({ context });
+ const { organizationId, webhookId } = context.req.valid('param');
+
+ const webhookRepository = createWebhookRepository({ db });
+ const organizationsRepository = createOrganizationsRepository({ db });
+
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
+
+ const { webhook } = await webhookRepository.getOrganizationWebhookById({ webhookId, organizationId });
+
+ if (!webhook) {
+ throw createWebhookNotFoundError();
+ }
+
+ return context.json({
+ webhook: omit(webhook, ['secret']),
+ });
+ },
+ );
+}
+
+function setupUpdateWebhookRoute({ app, db }: RouteDefinitionContext) {
+ app.put(
+ '/api/organizations/:organizationId/webhooks/:webhookId',
+ requireAuthentication(),
+ validateParams(z.object({
+ organizationId: organizationIdSchema,
+ webhookId: z.string().min(1),
+ })),
+ validateJsonBody(z.object({
+ name: z.string().min(3).max(50).optional(),
+ url: z.string().url().optional(),
+ secret: z.string().min(1).optional(),
+ enabled: z.boolean().optional(),
+ events: webhookEventListSchema.min(1).optional(),
+ })),
+ async (context) => {
+ const { userId } = getUser({ context });
+ const { webhookId, organizationId } = context.req.valid('param');
+ const { name, url, secret, enabled, events } = context.req.valid('json');
+
+ const webhookRepository = createWebhookRepository({ db });
+ const organizationsRepository = createOrganizationsRepository({ db });
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
+
+ const { webhook } = await updateWebhook({
+ webhookId,
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ webhookRepository,
+ organizationId,
+ });
+
+ return context.json({
+ webhook,
+ });
+ },
+ );
+}
+
+function setupDeleteWebhookRoute({ app, db }: RouteDefinitionContext) {
+ app.delete(
+ '/api/organizations/:organizationId/webhooks/:webhookId',
+ requireAuthentication(),
+ validateParams(z.object({
+ organizationId: organizationIdSchema,
+ webhookId: z.string().min(1),
+ })),
+ async (context) => {
+ const { userId } = getUser({ context });
+ const { webhookId, organizationId } = context.req.valid('param');
+
+ const organizationsRepository = createOrganizationsRepository({ db });
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
+
+ const webhookRepository = createWebhookRepository({ db });
+
+ const { webhook } = await webhookRepository.getOrganizationWebhookById({ webhookId, organizationId });
+
+ if (!webhook) {
+ throw createWebhookNotFoundError();
+ }
+
+ await webhookRepository.deleteOrganizationWebhook({ webhookId, organizationId });
+
+ return context.body(null, 204);
+ },
+ );
+}
diff --git a/apps/papra-server/src/modules/webhooks/webhook.usecases.test.ts b/apps/papra-server/src/modules/webhooks/webhook.usecases.test.ts
new file mode 100644
index 00000000..d58bced8
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhook.usecases.test.ts
@@ -0,0 +1,185 @@
+import { eq } from 'drizzle-orm';
+import { omit } from 'lodash-es';
+import { describe, expect, test } from 'vitest';
+import { createInMemoryDatabase } from '../app/database/database.test-utils';
+import { ORGANIZATION_ROLES } from '../organizations/organizations.constants';
+import { createTestLogger } from '../shared/logger/logger.test-utils';
+import { createWebhookRepository } from './webhook.repository';
+import { createWebhook, triggerWebhooks, updateWebhook } from './webhook.usecases';
+import { webhookEventsTable, webhooksTable } from './webhooks.tables';
+
+describe('webhook usecases', () => {
+ describe('createWebhook', () => {
+ test('creates a new webhook and saves the events in the webhook_events table', async () => {
+ const { db } = await createInMemoryDatabase({
+ organizations: [
+ { id: 'org_1', name: 'Test Organization' },
+ ],
+ users: [
+ { id: 'user_1', email: '[email protected]', name: 'Test User' },
+ ],
+ organizationMembers: [
+ { organizationId: 'org_1', userId: 'user_1', role: ORGANIZATION_ROLES.OWNER },
+ ],
+ });
+ const webhookRepository = createWebhookRepository({ db });
+
+ const { webhook } = await createWebhook({
+ name: 'Test Webhook',
+ url: 'https://example.com/webhook',
+ secret: 'test-secret',
+ events: ['document:created', 'document:deleted'],
+ webhookRepository,
+ organizationId: 'org_1',
+ createdBy: 'user_1',
+ });
+
+ expect(webhook).to.deep.include({
+ name: 'Test Webhook',
+ url: 'https://example.com/webhook',
+ secret: 'test-secret',
+ enabled: true,
+ });
+
+ // Verify events were created
+ const events = await db.select().from(webhookEventsTable).where(eq(webhookEventsTable.webhookId, webhook.id));
+ expect(events.map(e => omit(e, 'createdAt', 'updatedAt', 'id'))).to.eql([
+ {
+ webhookId: webhook.id,
+ eventName: 'document:created',
+ },
+ {
+ webhookId: webhook.id,
+ eventName: 'document:deleted',
+ },
+ ]);
+ });
+ });
+
+ describe('updateWebhook', () => {
+ test('updates a webhook and saves the events in the webhook_events table', async () => {
+ const { db } = await createInMemoryDatabase({
+ organizations: [
+ { id: 'org_1', name: 'Test Organization' },
+ ],
+ webhooks: [
+ { id: 'wbh_1', name: 'Test Webhook', url: 'https://example.com/webhook', organizationId: 'org_1' },
+ ],
+ webhookEvents: [
+ { id: 'wbh_ev_1', webhookId: 'wbh_1', eventName: 'document:created' },
+ { id: 'wbh_ev_2', webhookId: 'wbh_1', eventName: 'document:deleted' },
+ ],
+ });
+ const webhookRepository = createWebhookRepository({ db });
+
+ await updateWebhook({
+ webhookId: 'wbh_1',
+ name: 'Test Webhook',
+ url: 'https://foo.bar',
+ secret: 'test-secret',
+ events: ['document:deleted'],
+ webhookRepository,
+ organizationId: 'org_1',
+ });
+
+ const webhooks = await db.select().from(webhooksTable);
+ expect(webhooks.length).to.eq(1);
+ const [webhook] = webhooks;
+
+ expect(webhook).to.deep.include({
+ id: 'wbh_1',
+ name: 'Test Webhook',
+ url: 'https://foo.bar',
+ secret: 'test-secret',
+ organizationId: 'org_1',
+ });
+
+ const events = await db.select().from(webhookEventsTable).where(eq(webhookEventsTable.webhookId, 'wbh_1'));
+ expect(events.map(e => omit(e, 'createdAt', 'updatedAt', 'id'))).to.eql([
+ {
+ webhookId: 'wbh_1',
+ eventName: 'document:deleted',
+ },
+ ]);
+ });
+ });
+
+ describe('triggerWebhooks', () => {
+ test('when an organization has webhooks enabled for an event, the configured urls are called with the event payload', async () => {
+ const { db } = await createInMemoryDatabase({
+ organizations: [
+ { id: 'org_1', name: 'Organization 1' },
+ { id: 'org_2', name: 'Organization 2' },
+ ],
+ webhooks: [
+ // webhook 1 is enabled and has the event document.created
+ { id: 'wbh_1', name: 'Test Webhook', url: 'https://example.com/webhook1', organizationId: 'org_1', enabled: true },
+ // webhook 2 is enabled and has the event document.deleted (so it will not be triggered)
+ { id: 'wbh_2', name: 'Test Webhook', url: 'https://example.com/webhook2', organizationId: 'org_1', enabled: true },
+ // webhook 3 is enabled and has the event document.created (so it will be triggered)
+ { id: 'wbh_3', name: 'Test Webhook', url: 'https://example.com/webhook3', organizationId: 'org_1', secret: 'secret3' }, // by default the webhook is enabled
+ // webhook 4 is disabled and has the event document.created (so it will not be triggered)
+ { id: 'wbh_4', name: 'Test Webhook', url: 'https://example.com/webhook4', organizationId: 'org_1', enabled: false },
+ // webhook 5 is related to organization 2 and has the event document.created (so it will not be triggered)
+ { id: 'wbh_5', name: 'Test Webhook', url: 'https://example.com/webhook5', organizationId: 'org_2', enabled: true },
+ ],
+ webhookEvents: [
+ { id: 'wbh_ev_1', webhookId: 'wbh_1', eventName: 'document:created' },
+ { id: 'wbh_ev_2', webhookId: 'wbh_2', eventName: 'document:deleted' },
+ { id: 'wbh_ev_3', webhookId: 'wbh_3', eventName: 'document:created' },
+ { id: 'wbh_ev_4', webhookId: 'wbh_4', eventName: 'document:created' },
+ { id: 'wbh_ev_5', webhookId: 'wbh_5', eventName: 'document:created' },
+ ],
+ });
+
+ const webhookRepository = createWebhookRepository({ db });
+ const { logger } = createTestLogger();
+ const triggerWebhookServiceArgs: unknown[] = [];
+
+ const eventPayload = {
+ documentId: 'doc_1',
+ organizationId: 'org_1',
+ name: 'Document 1',
+ createdAt: new Date('2025-01-01'),
+ updatedAt: new Date('2025-01-01'),
+ };
+
+ await triggerWebhooks({
+ webhookRepository,
+ organizationId: 'org_1',
+ event: 'document:created',
+ payload: eventPayload,
+ logger,
+ now: new Date('2025-05-04'),
+ triggerWebhookService: async (args) => {
+ triggerWebhookServiceArgs.push(args);
+
+ const { event, payload } = args;
+
+ return {
+ responseData: {},
+ responseStatus: 200,
+ requestPayload: JSON.stringify({ event, payload }),
+ };
+ },
+ });
+
+ expect(triggerWebhookServiceArgs).to.eql([
+ {
+ webhookUrl: 'https://example.com/webhook1',
+ webhookSecret: null,
+ now: new Date('2025-05-04'),
+ event: 'document:created',
+ payload: eventPayload,
+ },
+ {
+ webhookUrl: 'https://example.com/webhook3',
+ webhookSecret: 'secret3',
+ now: new Date('2025-05-04'),
+ event: 'document:created',
+ payload: eventPayload,
+ },
+ ]);
+ });
+ });
+});
diff --git a/apps/papra-server/src/modules/webhooks/webhook.usecases.ts b/apps/papra-server/src/modules/webhooks/webhook.usecases.ts
new file mode 100644
index 00000000..fb0702d7
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhook.usecases.ts
@@ -0,0 +1,145 @@
+import type { EventName, WebhookPayloads } from '@papra/webhooks';
+import type { Logger } from '../shared/logger/logger';
+import type { WebhookRepository } from './webhook.repository';
+import type { Webhook } from './webhooks.types';
+import { triggerWebhook as triggerWebhookServiceImpl } from '@papra/webhooks';
+import pLimit from 'p-limit';
+import { createLogger } from '../shared/logger/logger';
+import { createWebhookNotFoundError } from './webhook.errors';
+
+export async function createWebhook({
+ name,
+ url,
+ secret,
+ enabled = true,
+ events = [],
+ organizationId,
+ webhookRepository,
+ createdBy,
+}: {
+ name: string;
+ url: string;
+ secret?: string;
+ enabled?: boolean;
+ events?: EventName[];
+ organizationId: string;
+ webhookRepository: WebhookRepository;
+ createdBy: string;
+}) {
+ const { webhook } = await webhookRepository.createOrganizationWebhook({
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ organizationId,
+ createdBy,
+ });
+
+ return { webhook };
+}
+
+export async function updateWebhook({
+ webhookId,
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ webhookRepository,
+ organizationId,
+}: {
+ webhookId: string;
+ name?: string;
+ url?: string;
+ secret?: string;
+ enabled?: boolean;
+ events?: EventName[];
+ webhookRepository: WebhookRepository;
+ organizationId: string;
+}) {
+ const { webhook: existingWebhook } = await webhookRepository.getOrganizationWebhookById({ webhookId, organizationId });
+
+ if (!existingWebhook) {
+ throw createWebhookNotFoundError();
+ }
+
+ const { webhook } = await webhookRepository.updateOrganizationWebhook({
+ webhookId,
+ name,
+ url,
+ secret,
+ enabled,
+ events,
+ organizationId,
+ });
+
+ return { webhook };
+}
+
+export async function triggerWebhooks({
+ webhookRepository,
+ organizationId,
+ now = new Date(),
+ logger = createLogger({ namespace: 'webhook' }),
+ triggerWebhookService = triggerWebhookServiceImpl,
+ ...webhookData
+}: {
+ webhookRepository: WebhookRepository;
+ organizationId: string;
+ now?: Date;
+ logger?: Logger;
+ triggerWebhookService?: typeof triggerWebhookServiceImpl;
+} & WebhookPayloads) {
+ const { event } = webhookData;
+ const { webhooks } = await webhookRepository.getOrganizationEnabledWebhooksForEvent({ organizationId, event });
+
+ logger.info({ webhooksCount: webhooks.length, organizationId, event }, 'Triggering webhooks');
+
+ const limit = pLimit(10);
+
+ await Promise.all(
+ webhooks.map(webhook =>
+ limit(() =>
+ triggerWebhook({ webhook, webhookRepository, now, ...webhookData, logger, triggerWebhookService }),
+ ),
+ ),
+ );
+}
+
+export async function triggerWebhook({
+ webhook,
+ webhookRepository,
+ now = new Date(),
+ logger = createLogger({ namespace: 'webhook' }),
+ triggerWebhookService = triggerWebhookServiceImpl,
+ ...webhookData
+}: {
+ webhook: Webhook;
+ webhookRepository: WebhookRepository;
+ now?: Date;
+ logger?: Logger;
+ triggerWebhookService?: typeof triggerWebhookServiceImpl;
+} & WebhookPayloads) {
+ const { url, secret, organizationId } = webhook;
+ const { event } = webhookData;
+
+ logger.info({ webhookId: webhook.id, event, organizationId }, 'Triggering webhook');
+
+ const { responseData, responseStatus, requestPayload } = await triggerWebhookService({
+ webhookUrl: url,
+ webhookSecret: secret,
+ now,
+ ...webhookData,
+ });
+
+ logger.info({ webhookId: webhook.id, event, responseStatus, organizationId }, 'Webhook triggered');
+
+ await webhookRepository.saveWebhookDelivery({
+ webhookId: webhook.id,
+ eventName: event,
+ requestPayload: JSON.stringify(requestPayload),
+ responsePayload: JSON.stringify(responseData),
+ responseStatus,
+ });
+}
diff --git a/apps/papra-server/src/modules/webhooks/webhooks.schemas.ts b/apps/papra-server/src/modules/webhooks/webhooks.schemas.ts
new file mode 100644
index 00000000..8534abc3
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhooks.schemas.ts
@@ -0,0 +1,5 @@
+import { EVENT_NAMES } from '@papra/webhooks';
+import { z } from 'zod';
+
+export const webhookEventSchema = z.enum(EVENT_NAMES);
+export const webhookEventListSchema = z.array(webhookEventSchema);
diff --git a/apps/papra-server/src/modules/webhooks/webhooks.tables.ts b/apps/papra-server/src/modules/webhooks/webhooks.tables.ts
new file mode 100644
index 00000000..78027a4c
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhooks.tables.ts
@@ -0,0 +1,38 @@
+import { EVENT_NAMES } from '@papra/webhooks';
+import { integer, sqliteTable, text, unique } from 'drizzle-orm/sqlite-core';
+import { organizationsTable } from '../organizations/organizations.table';
+import { createPrimaryKeyField, createTimestampColumns } from '../shared/db/columns.helpers';
+import { usersTable } from '../users/users.table';
+
+export const webhooksTable = sqliteTable('webhooks', {
+ ...createPrimaryKeyField({ prefix: 'wbh' }),
+ ...createTimestampColumns(),
+
+ name: text('name').notNull(),
+ url: text('url').notNull(),
+ secret: text('secret'),
+ enabled: integer('enabled', { mode: 'boolean' }).notNull().default(true),
+ createdBy: text('created_by').references(() => usersTable.id, { onDelete: 'set null', onUpdate: 'cascade' }),
+ organizationId: text('organization_id').references(() => organizationsTable.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
+});
+
+export const webhookEventsTable = sqliteTable('webhook_events', {
+ ...createPrimaryKeyField({ prefix: 'wbh_ev' }),
+ ...createTimestampColumns(),
+
+ webhookId: text('webhook_id').notNull().references(() => webhooksTable.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
+ eventName: text('event_name', { enum: EVENT_NAMES }).notNull(),
+}, t => [
+ unique('webhook_events_webhook_id_event_name_unique').on(t.webhookId, t.eventName),
+]);
+
+export const webhookDeliveriesTable = sqliteTable('webhook_deliveries', {
+ ...createPrimaryKeyField({ prefix: 'wbh_dlv' }),
+ ...createTimestampColumns(),
+
+ webhookId: text('webhook_id').notNull().references(() => webhooksTable.id, { onDelete: 'cascade', onUpdate: 'cascade' }),
+ eventName: text('event_name').notNull(),
+ requestPayload: text('request_payload').notNull(),
+ responsePayload: text('response_payload').notNull(),
+ responseStatus: integer('response_status').notNull(),
+});
diff --git a/apps/papra-server/src/modules/webhooks/webhooks.types.ts b/apps/papra-server/src/modules/webhooks/webhooks.types.ts
new file mode 100644
index 00000000..72b6f56f
--- /dev/null
+++ b/apps/papra-server/src/modules/webhooks/webhooks.types.ts
@@ -0,0 +1,6 @@
+import type { webhookDeliveriesTable, webhookEventsTable, webhooksTable } from './webhooks.tables';
+
+export type Webhook = typeof webhooksTable.$inferSelect;
+export type WebhookEvent = typeof webhookEventsTable.$inferSelect;
+export type WebhookDelivery = typeof webhookDeliveriesTable.$inferSelect;
+export type WebhookDeliveryInsert = typeof webhookDeliveriesTable.$inferInsert;
diff --git a/packages/api-sdk/README.md b/packages/api-sdk/README.md
index 06ac48bb..7db6d8e3 100644
--- a/packages/api-sdk/README.md
+++ b/packages/api-sdk/README.md
@@ -46,3 +46,16 @@ const client = createClient({ apiKey, apiBaseUrl }).forOrganization('org_...');
await client.uploadDocument({ file });
```
+
+## License
+
+This project is licensed under the AGPL-3.0 License - see the [LICENSE](./LICENSE) file for details.
+
+## Community
+
+Join the community on [Papra's Discord server](https://papra.app/discord) to discuss the project, ask questions, or get help.
+
+## Credits
+
+This project is crafted with ❤️ by [Corentin Thomasset](https://corentin.tech).
+If you find this project helpful, please consider [supporting my work](https://buymeacoffee.com/cthmsst).
diff --git a/packages/webhooks/README.md b/packages/webhooks/README.md
new file mode 100644
index 00000000..b9e455e1
--- /dev/null
+++ b/packages/webhooks/README.md
@@ -0,0 +1,29 @@
+# Papra webhooks
+
+This package is used to trigger and easily consume webhooks from Papra.
+
+## Installation
+
+```bash
+# using pnpm
+pnpm add @papra/webhooks
+
+# using npm
+npm install @papra/webhooks
+
+# using yarn
+yarn add @papra/webhooks
+```
+
+## License
+
+This project is licensed under the AGPL-3.0 License - see the [LICENSE](./LICENSE) file for details.
+
+## Community
+
+Join the community on [Papra's Discord server](https://papra.app/discord) to discuss the project, ask questions, or get help.
+
+## Credits
+
+This project is crafted with ❤️ by [Corentin Thomasset](https://corentin.tech).
+If you find this project helpful, please consider [supporting my work](https://buymeacoffee.com/cthmsst).
diff --git a/packages/webhooks/build.config.ts b/packages/webhooks/build.config.ts
new file mode 100644
index 00000000..da11c9fc
--- /dev/null
+++ b/packages/webhooks/build.config.ts
@@ -0,0 +1,13 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+ entries: [
+ 'src/index',
+ ],
+ clean: true,
+ declaration: true,
+ sourcemap: true,
+ rollup: {
+ emitCJS: true,
+ },
+});
diff --git a/packages/webhooks/eslint.config.js b/packages/webhooks/eslint.config.js
new file mode 100644
index 00000000..e0175daf
--- /dev/null
+++ b/packages/webhooks/eslint.config.js
@@ -0,0 +1,21 @@
+import antfu from '@antfu/eslint-config';
+
+export default antfu({
+ stylistic: {
+ semi: true,
+ },
+
+ rules: {
+ // To allow export on top of files
+ 'ts/no-use-before-define': ['error', { allowNamedExports: true, functions: false }],
+ 'curly': ['error', 'all'],
+ 'vitest/consistent-test-it': ['error', { fn: 'test' }],
+ 'ts/consistent-type-definitions': ['error', 'type'],
+ 'style/brace-style': ['error', '1tbs', { allowSingleLine: false }],
+ 'unused-imports/no-unused-vars': ['error', {
+ argsIgnorePattern: '^_',
+ varsIgnorePattern: '^_',
+ caughtErrorsIgnorePattern: '^_',
+ }],
+ },
+});
diff --git a/packages/webhooks/package.json b/packages/webhooks/package.json
new file mode 100644
index 00000000..9ad1202c
--- /dev/null
+++ b/packages/webhooks/package.json
@@ -0,0 +1,55 @@
+{
+ "name": "@papra/webhooks",
+ "type": "module",
+ "version": "0.0.1",
+ "packageManager": "[email protected]",
+ "description": "Webhooks helper library for Papra, the document archiving platform.",
+ "author": "Corentin Thomasset <[email protected]> (https://corentin.tech)",
+ "license": "AGPL-3.0-or-later",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/papra-app/papra.git",
+ "directory": "packages/webhooks"
+ },
+ "bugs": {
+ "url": "https://github.com/papra-app/papra/issues"
+ },
+ "keywords": [
+ "papra",
+ "webhooks",
+ "document",
+ "archiving",
+ "storage"
+ ],
+ "exports": {
+ ".": {
+ "import": "./dist/index.mjs",
+ "require": "./dist/index.cjs"
+ }
+ },
+ "main": "./dist/index.cjs",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist"
+ ],
+ "scripts": {
+ "lint": "eslint .",
+ "lint:fix": "eslint --fix .",
+ "test": "vitest run",
+ "test:watch": "vitest watch",
+ "typecheck": "tsc --noEmit",
+ "build": "unbuild"
+ },
+ "dependencies": {
+ "@corentinth/chisels": "^1.3.0",
+ "ofetch": "^1.4.1",
+ "tsee": "^1.3.4"
+ },
+ "devDependencies": {
+ "@antfu/eslint-config": "catalog:",
+ "eslint": "catalog:",
+ "typescript": "catalog:",
+ "unbuild": "^3.5.0",
+ "vitest": "catalog:"
+ }
+}
diff --git a/packages/webhooks/src/handler/handler.errors.ts b/packages/webhooks/src/handler/handler.errors.ts
new file mode 100644
index 00000000..2c79f575
--- /dev/null
+++ b/packages/webhooks/src/handler/handler.errors.ts
@@ -0,0 +1,8 @@
+export function createInvalidSignatureError() {
+ return Object.assign(
+ new Error('[Papra Webhooks] Invalid signature'),
+ {
+ code: 'INVALID_SIGNATURE',
+ },
+ );
+}
diff --git a/packages/webhooks/src/handler/handler.services.ts b/packages/webhooks/src/handler/handler.services.ts
new file mode 100644
index 00000000..fa87d497
--- /dev/null
+++ b/packages/webhooks/src/handler/handler.services.ts
@@ -0,0 +1,36 @@
+import type { BuildWebhookEventPayload, WebhookEvents, WebhookPayloads } from '../webhooks.types';
+import { EventEmitter } from 'tsee';
+import { verifySignature } from '../signature';
+import { parseBody } from '../webhooks.models';
+import { createInvalidSignatureError } from './handler.errors';
+
+export function createWebhooksHandler({
+ secret,
+ onInvalidSignature = () => {
+ createInvalidSignatureError();
+ },
+}: {
+ secret: string;
+ onInvalidSignature?: ({ bodyBuffer, signature }: { bodyBuffer: ArrayBuffer; signature: string }) => void | Promise<void>;
+}) {
+ const eventEmitter = new EventEmitter<WebhookEvents & { '*': (payload: BuildWebhookEventPayload<WebhookPayloads>) => void }>();
+
+ return {
+ on: eventEmitter.on,
+ ee: eventEmitter,
+ handle: async ({ bodyBuffer, signature }: { bodyBuffer: ArrayBuffer; signature: string }) => {
+ const isValid = await verifySignature({ bodyBuffer, signature, secret });
+
+ if (!isValid) {
+ await onInvalidSignature({ bodyBuffer, signature });
+ return;
+ }
+
+ const payload = parseBody(bodyBuffer.toString());
+ const { event } = payload;
+
+ eventEmitter.emit(event, payload as any);
+ eventEmitter.emit('*', payload);
+ },
+ };
+}
diff --git a/packages/webhooks/src/index.ts b/packages/webhooks/src/index.ts
new file mode 100644
index 00000000..1acb0ac0
--- /dev/null
+++ b/packages/webhooks/src/index.ts
@@ -0,0 +1,4 @@
+export { createWebhooksHandler } from './handler/handler.services';
+export { EVENT_NAMES, type EventName } from './webhooks.constants';
+export { triggerWebhook } from './webhooks.services';
+export type { WebhookEventPayload, WebhookEvents, WebhookPayload, WebhookPayloads } from './webhooks.types';
diff --git a/packages/webhooks/src/signature.test.ts b/packages/webhooks/src/signature.test.ts
new file mode 100644
index 00000000..92b4702b
--- /dev/null
+++ b/packages/webhooks/src/signature.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, test } from 'vitest';
+import { arrayBufferToBase64, base64ToArrayBuffer, signBody, verifySignature } from './signature';
+
+const arrayBuffer = (str: string) => new TextEncoder().encode(str).buffer as ArrayBuffer;
+
+describe('signature', () => {
+ describe('signBody', () => {
+ test('a buffer can be signed with a secret, the resulting signature is a base64 encoded string', async () => {
+ const bodyBuffer = arrayBuffer('test');
+ const secret = 'secret-key';
+
+ const { signature } = await signBody({ bodyBuffer, secret });
+
+ expect(signature).to.equal('2yIt56m6njKnw7VCoPEYRQE1jSIxyuYutt8/c1ezh9M=');
+ });
+ });
+
+ describe('verifySignature', () => {
+ test('verify that the signature of a buffer has been created with a given secret', async () => {
+ const bodyBuffer = arrayBuffer('test');
+ const secret = 'secret-key';
+ const signature = '2yIt56m6njKnw7VCoPEYRQE1jSIxyuYutt8/c1ezh9M=';
+
+ const result = await verifySignature({ bodyBuffer, signature, secret });
+
+ expect(result).to.equal(true);
+ });
+ });
+
+ describe('arrayBufferToBase64', () => {
+ test('a buffer can be converted to a base64 encoded string', () => {
+ expect(arrayBufferToBase64(arrayBuffer('test'))).to.equal('dGVzdA==');
+ expect(arrayBufferToBase64(arrayBuffer(''))).to.equal('');
+ });
+ });
+
+ describe('base64ToArrayBuffer', () => {
+ test('a base64 encoded string can be converted to a buffer', () => {
+ expect(base64ToArrayBuffer('dGVzdA==')).to.deep.equal(arrayBuffer('test'));
+ expect(base64ToArrayBuffer('')).to.deep.equal(arrayBuffer(''));
+ });
+
+ test('an error is thrown when the base64 encoded string is invalid', () => {
+ expect(() => base64ToArrayBuffer('invalid--')).to.throw('Invalid character');
+ });
+
+ test('a buffer can be converted to a base64 encoded string and back to a buffer', () => {
+ expect(
+ base64ToArrayBuffer(
+ arrayBufferToBase64(
+ arrayBuffer('test'),
+ ),
+ ),
+ ).to.deep.equal(arrayBuffer('test'));
+ });
+ });
+});
diff --git a/packages/webhooks/src/signature.ts b/packages/webhooks/src/signature.ts
new file mode 100644
index 00000000..a3388d25
--- /dev/null
+++ b/packages/webhooks/src/signature.ts
@@ -0,0 +1,42 @@
+export function arrayBufferToBase64(arrayBuffer: ArrayBuffer) {
+ return btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
+}
+
+export function base64ToArrayBuffer(base64: string) {
+ return new Uint8Array(atob(base64).split('').map(char => char.charCodeAt(0))).buffer;
+}
+
+export async function signBody({
+ bodyBuffer,
+ secret,
+}: {
+ bodyBuffer: ArrayBuffer;
+ secret: string;
+}) {
+ const encoder = new TextEncoder();
+ const keyData = encoder.encode(secret);
+ const key = await crypto.subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
+
+ const signature = await crypto.subtle.sign('HMAC', key, bodyBuffer);
+ const signatureBase64 = arrayBufferToBase64(signature);
+
+ return { signature: signatureBase64 };
+}
+
+export async function verifySignature({
+ bodyBuffer,
+ signature: base64Signature,
+ secret,
+}: {
+ bodyBuffer: ArrayBuffer;
+ signature: string;
+ secret: string;
+}): Promise<boolean> {
+ const encoder = new TextEncoder();
+ const keyData = encoder.encode(secret);
+ const key = await crypto.subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
+
+ const signatureBuffer = base64ToArrayBuffer(base64Signature);
+
+ return crypto.subtle.verify('HMAC', key, signatureBuffer, bodyBuffer);
+}
diff --git a/packages/webhooks/src/webhooks.constants.ts b/packages/webhooks/src/webhooks.constants.ts
new file mode 100644
index 00000000..793d1a4d
--- /dev/null
+++ b/packages/webhooks/src/webhooks.constants.ts
@@ -0,0 +1,6 @@
+export const EVENT_NAMES = [
+ 'document:created',
+ 'document:deleted',
+] as const;
+
+export type EventName = (typeof EVENT_NAMES)[number];
diff --git a/packages/webhooks/src/webhooks.models.ts b/packages/webhooks/src/webhooks.models.ts
new file mode 100644
index 00000000..8f6e1932
--- /dev/null
+++ b/packages/webhooks/src/webhooks.models.ts
@@ -0,0 +1,14 @@
+import type { WebhookEventPayload, WebhookPayloads } from './webhooks.types';
+
+export function serializeBody({ now = new Date(), ...payload }: { now?: Date } & WebhookPayloads) {
+ const body: WebhookEventPayload = {
+ ...payload,
+ timestampMs: now.getTime(),
+ };
+
+ return JSON.stringify(body);
+}
+
+export function parseBody(body: string) {
+ return JSON.parse(body) as WebhookEventPayload;
+}
diff --git a/packages/webhooks/src/webhooks.services.ts b/packages/webhooks/src/webhooks.services.ts
new file mode 100644
index 00000000..2b789746
--- /dev/null
+++ b/packages/webhooks/src/webhooks.services.ts
@@ -0,0 +1,67 @@
+import type { WebhookPayloads } from './webhooks.types';
+import { ofetch } from 'ofetch';
+import { signBody } from './signature';
+import { serializeBody } from './webhooks.models';
+
+export async function webhookHttpClient({
+ url,
+ ...options
+}: {
+ url: string;
+ method: string;
+ body: ArrayBuffer;
+ headers: Record<string, string>;
+}) {
+ const response = await ofetch.raw<unknown>(url, {
+ ...options,
+ ignoreResponseError: true,
+ });
+
+ return {
+ responseStatus: response.status,
+ responseData: response._data,
+ };
+}
+
+export async function triggerWebhook({
+ webhookUrl,
+ webhookSecret,
+ httpClient = webhookHttpClient,
+ now = new Date(),
+ ...payload
+
+}: {
+ webhookUrl: string;
+ webhookSecret?: string | null;
+ httpClient?: typeof webhookHttpClient;
+ now?: Date;
+} & WebhookPayloads) {
+ const { event } = payload;
+
+ const headers: Record<string, string> = {
+ 'User-Agent': 'papra-webhook-client',
+ 'Content-Type': 'application/json',
+ 'X-Event': event,
+ };
+
+ const body = serializeBody({ ...payload, now });
+ const bodyBuffer = new TextEncoder().encode(body).buffer as ArrayBuffer;
+
+ if (webhookSecret) {
+ const { signature } = await signBody({ bodyBuffer, secret: webhookSecret });
+ headers['X-Signature'] = signature;
+ }
+
+ const { responseData, responseStatus } = await httpClient({
+ url: webhookUrl,
+ method: 'POST',
+ body: bodyBuffer,
+ headers,
+ });
+
+ return {
+ responseData,
+ responseStatus,
+ requestPayload: body,
+ };
+}
diff --git a/packages/webhooks/src/webhooks.types.ts b/packages/webhooks/src/webhooks.types.ts
new file mode 100644
index 00000000..556d1913
--- /dev/null
+++ b/packages/webhooks/src/webhooks.types.ts
@@ -0,0 +1,34 @@
+import type { EventName } from './webhooks.constants';
+
+export type WebhookPayload<T extends EventName, D extends Record<string, unknown>> = { event: T; payload: D };
+
+export type DocumentCreatedPayload = WebhookPayload<
+ 'document:created',
+ {
+ documentId: string;
+ organizationId: string;
+ name: string;
+ createdAt: Date;
+ updatedAt: Date;
+ }
+>;
+
+export type DocumentDeletedPayload = WebhookPayload<
+ 'document:deleted',
+ {
+ documentId: string;
+ organizationId: string;
+ }
+>;
+
+export type WebhookPayloads = DocumentCreatedPayload | DocumentDeletedPayload;
+
+type ExtractEventName<T> = T extends WebhookPayload<infer E, any> ? E : never;
+export type BuildWebhookEventPayload<T> = T & { timestampMs: number };
+export type BuildWebhookEvents<T extends WebhookPayloads> = {
+ [K in ExtractEventName<T>]: (args: BuildWebhookEventPayload<Extract<T, WebhookPayload<K, any>>>) => void;
+};
+
+export type WebhookEvents = BuildWebhookEvents<WebhookPayloads>;
+
+export type WebhookEventPayload = BuildWebhookEventPayload<WebhookPayloads>;
diff --git a/packages/webhooks/tsconfig.json b/packages/webhooks/tsconfig.json
new file mode 100644
index 00000000..43dd7d01
--- /dev/null
+++ b/packages/webhooks/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "moduleDetection": "force",
+ "module": "preserve",
+ "resolveJsonModule": true,
+ "allowJs": true,
+ "strict": true,
+ "noImplicitOverride": true,
+ "noUncheckedIndexedAccess": true,
+ "noEmit": true,
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "isolatedModules": true,
+ "verbatimModuleSyntax": true,
+ "skipLibCheck": true
+ }
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2da17868..36306194 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -190,6 +190,9 @@ importers:
jsdom:
specifier: ^25.0.0
version: 25.0.1([email protected])
+ tinyglobby:
+ specifier: ^0.2.13
+ version: 0.2.13
tsx:
specifier: ^4.19.1
version: 4.19.3
@@ -250,6 +253,9 @@ importers:
'@papra/lecture':
specifier: ^0.0.4
version: 0.0.4
+ '@papra/webhooks':
+ specifier: workspace:*
+ version: link:../../packages/webhooks
'@paralleldrive/cuid2':
specifier: ^2.2.2
version: 2.2.2
@@ -440,6 +446,34 @@ importers:
specifier: 'catalog:'
+ packages/webhooks:
+ dependencies:
+ '@corentinth/chisels':
+ specifier: ^1.3.0
+ version: 1.3.1
+ ofetch:
+ specifier: ^1.4.1
+ version: 1.4.1
+ tsee:
+ specifier: ^1.3.4
+ version: 1.3.4
+ devDependencies:
+ '@antfu/eslint-config':
+ specifier: 'catalog:'
+ eslint:
+ specifier: 'catalog:'
+ version: 9.25.1([email protected])
+ typescript:
+ specifier: 'catalog:'
+ version: 5.8.2
+ unbuild:
+ specifier: ^3.5.0
+ vitest:
+ specifier: 'catalog:'
+ version: 3.0.5(@types/[email protected])(@types/[email protected])([email protected])
+
packages:
'@ampproject/[email protected]':
@@ -3134,6 +3168,9 @@ packages:
resolution: {integrity: sha512-0ikrnug3/IyneSHqCBeslAhlK2aBfYek1fGo4bP4QnZPmiqSGRK+Oy7ZMisLWkesffJvQ1cqAcBnJC+8+nxIAg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}
+
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
@@ -4899,14 +4936,6 @@ packages:
resolution: {integrity: sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==}
- resolution: {integrity: sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==}
- peerDependencies:
- picomatch: ^3 || ^4
- peerDependenciesMeta:
- picomatch:
- optional: true
-
resolution: {integrity: sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==}
peerDependencies:
@@ -7164,10 +7193,6 @@ packages:
resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
- resolution: {integrity: sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==}
- engines: {node: '>=12.0.0'}
-
resolution: {integrity: sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw==}
engines: {node: '>=12.0.0'}
@@ -7251,6 +7276,9 @@ packages:
typescript:
optional: true
+ resolution: {integrity: sha512-QD6huu+7aqZBjKjVgc4JaYRViICAlNefKiWuge5iUx3oYEz6a7f/uDBrAdwVmHCVetkhQ7MmNNd1HrF1LV7Rjg==}
+
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -10780,6 +10808,8 @@ snapshots:
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
'@types/[email protected]': {}
@@ -11051,7 +11081,7 @@ snapshots:
magic-string: 0.30.17
pathe: 1.1.2
perfect-debounce: 1.0.0
- tinyglobby: 0.2.12
+ tinyglobby: 0.2.13
transitivePeerDependencies:
- rollup
- supports-color
@@ -11092,7 +11122,7 @@ snapshots:
'@unocss/rule-utils': 0.65.0-beta.2
css-tree: 3.1.0
postcss: 8.5.3
- tinyglobby: 0.2.12
+ tinyglobby: 0.2.13
transitivePeerDependencies:
- supports-color
@@ -11199,7 +11229,7 @@ snapshots:
'@unocss/inspector': 0.65.0-beta.2([email protected]([email protected]))
chokidar: 3.6.0
magic-string: 0.30.17
- tinyglobby: 0.2.12
+ tinyglobby: 0.2.13
vite: 5.4.14(@types/[email protected])
transitivePeerDependencies:
- rollup
@@ -11830,7 +11860,7 @@ snapshots:
semver: 7.7.1
tiny-conventional-commits-parser: 0.0.1
tinyexec: 0.3.2
- tinyglobby: 0.2.12
+ tinyglobby: 0.2.13
transitivePeerDependencies:
- magicast
@@ -13109,10 +13139,6 @@ snapshots:
dependencies:
format: 0.2.2
- optionalDependencies:
- picomatch: 4.0.2
-
optionalDependencies:
picomatch: 4.0.2
@@ -16033,11 +16059,6 @@ snapshots:
- dependencies:
- fdir: 6.4.3([email protected])
- picomatch: 4.0.2
-
dependencies:
fdir: 6.4.4([email protected])
@@ -16097,6 +16118,10 @@ snapshots:
optionalDependencies:
typescript: 5.8.2
+ dependencies:
+ '@types/node': 12.20.55
+