A full-featured CRM built with React, shadcn/ui, and Supabase.
set attachments webhook secret in remote init
Anibal Svarcasaa583c416906
diff --git a/doc/src/content/docs/developers/supabase-configuration.mdx b/doc/src/content/docs/developers/supabase-configuration.mdxindex 1b9c4292..333379cc 100644--- a/doc/src/content/docs/developers/supabase-configuration.mdx+++ b/doc/src/content/docs/developers/supabase-configuration.mdx@@ -13,7 +13,7 @@ Atomic CRM comes with a CLI utility to create a backend instance on [supabase.comake supabase-remote-init```-The script will ask you for the Supabase instance name, create the database, apply the migrations and deploy the edge functions. Finally, it will create a `.env.production.local` file with your remote Supabase configuration.+The script will ask you for the Supabase instance name, create the database, apply the migrations, and set up the secrets needed by the edge functions. Finally, it will create a `.env.production.local` file with your remote Supabase configuration.The script cannot yet automate the configuration of the required SMTP provider on your Supabase instance. To do that, please follow the instructions detailed in the [Email Provider Setup](#email-provider-setup) section.@@ -46,6 +46,14 @@ npx supabase db pushnpx supabase functions deploy```+The migrations create database triggers that call `delete_note_attachments` when notes are deleted or when attachments are removed from an existing note.++Atomic CRM also needs one extra secret for note attachment cleanup:++```sh+npx supabase secrets set ATTACHMENTS_WEBHOOK_SECRET=atomic-crm-note-attachments-webhook-secret+```+Finally, add a `.env.production.local` file in the root directory with your remote Supabase credentials:```sh@@ -74,6 +82,7 @@ Using a remote Supabase instance can be interesting if you deploy from your compIn order to support [the invitations workflow](../../users/user-management#adding-users) and the default email/password authentication (including password reset), Atomic CRM needs to be able to send emails from your Supabase instance.By default, Supabase provides a simple SMTP server for all projects. But this server imposes a few important restrictions and is not meant for production use:+- It can only send messages to pre-authorized addresses- It imposes significant rate-limits- There is no SLA guarantee on message delivery or uptime@@ -126,7 +135,7 @@ If you want more information on how to customize email templates, check the [Cus## Frequently Asked Questions-**I have a *Security Definer View* error in *Security Advisor***+**I have a _Security Definer View_ error in _Security Advisor_**This warning informs you that the `init_state` state view is public and can be called by everybody.diff --git a/scripts/supabase-remote-init.mjs b/scripts/supabase-remote-init.mjsindex 2a151be2..33040739 100644--- a/scripts/supabase-remote-init.mjs+++ b/scripts/supabase-remote-init.mjs@@ -2,6 +2,9 @@ import { input } from "@inquirer/prompts";import { execa } from "execa";import fs from "node:fs";+const DEFAULT_ATTACHMENTS_WEBHOOK_SECRET =+ "atomic-crm-note-attachments-webhook-secret";+(async () => {await loginToSupabase();const projectName = await input({@@ -12,6 +15,9 @@ import fs from "node:fs";message: "Enter a database password:",default: generatePassword(16),});+ const attachmentsWebhookSecret =+ process.env.ATTACHMENTS_WEBHOOK_SECRET ??+ DEFAULT_ATTACHMENTS_WEBHOOK_SECRET;const projectRef = await createProject({ projectName, databasePassword });await waitForProjectToBeReady({ projectRef });@@ -34,6 +40,7 @@ import fs from "node:fs";projectRef,publishableKey,secretKey,+ attachmentsWebhookSecret,});await persistSupabaseEnv({@@ -216,7 +223,12 @@ async function fetchApiKeys({ projectRef }) {return { publishableKey, secretKey };}-async function setupSupabaseSecrets({ projectRef, publishableKey, secretKey }) {+async function setupSupabaseSecrets({+ projectRef,+ publishableKey,+ secretKey,+ attachmentsWebhookSecret,+}) {await execa("npx",[@@ -225,6 +237,7 @@ async function setupSupabaseSecrets({ projectRef, publishableKey, secretKey }) {"set",`SB_PUBLISHABLE_KEY=${publishableKey}`,`SB_SECRET_KEY=${secretKey}`,+ `ATTACHMENTS_WEBHOOK_SECRET=${attachmentsWebhookSecret}`,"--project-ref",projectRef,],