🧑💻 (folders) Add folder trpc endpoints (#1218)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced folder management capabilities including creation, deletion, update, listing, and retrieval within workspaces. - Added telemetry tracking for client events, Typebot publish events, and analytics page views. - Enhanced settings to track client events under specific conditions. - Implemented server-side logic for analytics tracking with PostHog integration. - Added API documentation for folder operations (create, delete, get, list, update). - **Refactor** - Updated `onConfirm` function's return type in `ConfirmModal`. - Simplified folder creation process in tests. - Refactored logic for handling file upload blocks and parsing publish events in Typebot publishing. - Migrated handler functions to TRPC endpoints for folder operations. - **Documentation** - Introduced documentation for new folder and telemetry functionalities. - **Chores** - Added new schemas for folders and telemetry events, including event tracking and folder structure. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
13
packages/schemas/features/folder.ts
Normal file
13
packages/schemas/features/folder.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { DashboardFolder } from '@typebot.io/prisma'
|
||||
import { z } from 'zod'
|
||||
|
||||
export const folderSchema = z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
name: z.string(),
|
||||
parentFolderId: z.string().nullable(),
|
||||
workspaceId: z.string(),
|
||||
}) satisfies z.ZodType<DashboardFolder>
|
||||
|
||||
export type Folder = z.infer<typeof folderSchema>
|
||||
@@ -144,6 +144,32 @@ export const workspaceNotPastDueEventSchema = workspaceEvent.merge(
|
||||
})
|
||||
)
|
||||
|
||||
export const removedBrandingEventSchema = typebotEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Branding removed'),
|
||||
})
|
||||
)
|
||||
|
||||
export const createdFolderEventSchema = workspaceEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Folder created'),
|
||||
})
|
||||
)
|
||||
|
||||
export const publishedFileUploadBlockEventSchema = typebotEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('File upload block published'),
|
||||
})
|
||||
)
|
||||
|
||||
export const visitedAnalyticsEventSchema = typebotEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Analytics visited'),
|
||||
})
|
||||
)
|
||||
|
||||
export const clientSideEvents = [removedBrandingEventSchema] as const
|
||||
|
||||
export const eventSchema = z.discriminatedUnion('name', [
|
||||
workspaceCreatedEventSchema,
|
||||
userCreatedEventSchema,
|
||||
@@ -159,6 +185,14 @@ export const eventSchema = z.discriminatedUnion('name', [
|
||||
userUpdatedEventSchema,
|
||||
customDomainAddedEventSchema,
|
||||
whatsAppCredentialsCreatedEventSchema,
|
||||
createdFolderEventSchema,
|
||||
publishedFileUploadBlockEventSchema,
|
||||
visitedAnalyticsEventSchema,
|
||||
...clientSideEvents,
|
||||
])
|
||||
|
||||
export const clientSideCreateEventSchema = removedBrandingEventSchema.omit({
|
||||
userId: true,
|
||||
})
|
||||
|
||||
export type TelemetryEvent = z.infer<typeof eventSchema>
|
||||
|
||||
Reference in New Issue
Block a user