🔧 Introduce 'isShared' property to Typebot model

This commit is contained in:
Baptiste Arnaud 2025-03-31 18:25:59 +02:00
parent 6488df64ff
commit 18459bc4d3
No known key found for this signature in database
12 changed files with 47 additions and 6 deletions

View File

@ -194,6 +194,7 @@ test.describe("Guest on public typebot", () => {
id: typebotId,
name: "Guest typebot",
workspaceId: guestWorkspaceId,
isShared: true,
...parseDefaultGroupWithBlock({
type: InputBlockType.TEXT,
}),

View File

@ -53,6 +53,7 @@ type UpdateTypebotPayload = Partial<
| "isClosed"
| "whatsAppCredentialsId"
| "riskLevel"
| "isShared"
>
>;

View File

@ -28,6 +28,7 @@ export const convertPublicTypebotToTypebot = (
selectedThemeTemplateId: existingTypebot.selectedThemeTemplateId,
whatsAppCredentialsId: existingTypebot.whatsAppCredentialsId,
riskLevel: existingTypebot.riskLevel,
isShared: existingTypebot.isShared,
events: typebot.events,
};
};

View File

@ -15,6 +15,7 @@ export const SharePopoverContent = () => {
const updateIsPublicShareEnabled = async (isEnabled: boolean) => {
await updateTypebot({
updates: {
isShared: isEnabled,
settings: {
...typebot?.settings,
publicShare: {
@ -33,7 +34,11 @@ export const SharePopoverContent = () => {
<Stack p="4" borderTopWidth={1}>
<SwitchWithRelatedSettings
label={t("share.button.popover.publicFlow.label")}
initialValue={typebot?.settings.publicShare?.isEnabled ?? false}
initialValue={
typebot?.isShared ??
typebot?.settings.publicShare?.isEnabled ??
false
}
onCheckChange={updateIsPublicShareEnabled}
>
<Stack spacing={4}>

View File

@ -6761,6 +6761,10 @@
"type": "string",
"nullable": true
},
"isShared": {
"type": "boolean",
"nullable": true
},
"resultsTablePreferences": {
"type": "object",
"nullable": true,
@ -6811,7 +6815,8 @@
"theme",
"settings",
"icon",
"folderId"
"folderId",
"isShared"
],
"title": "Typebot V6"
},
@ -8697,6 +8702,10 @@
"type": "string",
"nullable": true
},
"isShared": {
"type": "boolean",
"nullable": true
},
"resultsTablePreferences": {
"type": "object",
"nullable": true,
@ -8747,7 +8756,8 @@
"theme",
"settings",
"icon",
"folderId"
"folderId",
"isShared"
],
"title": "Typebot V5"
}
@ -22996,6 +23006,10 @@
"riskLevel": {
"type": "number",
"nullable": true
},
"isShared": {
"type": "boolean",
"nullable": true
}
},
"required": [
@ -23020,7 +23034,8 @@
"isArchived",
"isClosed",
"whatsAppCredentialsId",
"riskLevel"
"riskLevel",
"isShared"
],
"title": "Typebot V6"
},
@ -24972,6 +24987,10 @@
"riskLevel": {
"type": "number",
"nullable": true
},
"isShared": {
"type": "boolean",
"nullable": true
}
},
"required": [
@ -24996,7 +25015,8 @@
"isArchived",
"isClosed",
"whatsAppCredentialsId",
"riskLevel"
"riskLevel",
"isShared"
],
"title": "Typebot V5"
},

View File

@ -1,3 +1,9 @@
App v3.7
- publicShare > isEnabled has been removed in favor of isShared. Before upgrading to 3.6, make sure to first upgrade to 3.5 and update the public share status of your shared bots.
App v3.6
- If you have active user responding to bots, make sure to first upgrade to v3.5 and let it go run for at least 3 days
Typebot 6.2
- file block migrate html placeholder to markdown?
- Set variable: stop interpreting Texte value as code

View File

@ -47,6 +47,7 @@ export const parseTestTypebot = (
},
],
groups: partialTypebot.groups ?? [],
isShared: null,
});
export const parseTypebotToPublicTypebot = (

View File

@ -227,6 +227,7 @@ model Typebot {
webhooks Webhook[]
isArchived Boolean @default(false)
isClosed Boolean @default(false)
isShared Boolean?
whatsAppCredentialsId String?
riskLevel Int?
bannedIps BannedIp[]

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Typebot" ADD COLUMN "isShared" BOOLEAN;

View File

@ -209,6 +209,7 @@ model Typebot {
webhooks Webhook[]
isArchived Boolean @default(false)
isClosed Boolean @default(false)
isShared Boolean?
whatsAppCredentialsId String?
riskLevel Int?
bannedIps BannedIp[]

View File

@ -6,6 +6,7 @@ import type { Workspace } from "@typebot.io/workspaces/schemas";
export const isReadTypebotForbidden = async (
typebot: {
settings?: Prisma.Typebot["settings"];
isShared?: boolean | null;
collaborators: Pick<Prisma.CollaboratorsOnTypebots, "userId">[];
} & {
workspace: Pick<Workspace, "isSuspended" | "isPastDue"> & {
@ -18,7 +19,7 @@ export const isReadTypebotForbidden = async (
? settingsSchema.parse(typebot.settings)
: undefined;
const isTypebotPublic = settings?.publicShare?.isEnabled === true;
if (isTypebotPublic) return false;
if (isTypebotPublic || typebot.isShared) return false;
return (
!user ||
typebot.workspace.isSuspended ||

View File

@ -63,6 +63,7 @@ export const typebotV5Schema = z
isClosed: z.boolean(),
whatsAppCredentialsId: z.string().nullable(),
riskLevel: z.number().nullable(),
isShared: z.boolean().nullable(),
}) satisfies z.ZodType<Prisma.Typebot, z.ZodTypeDef, unknown>,
)
._def.schema.openapi({