feat: AI description - Backend for adding translation objects to EventType model (#17657)
* feat: AI description - DB model + frontend + backend (fetch only) * fix types and add validation to backend * improve log * improve * import type * add EventTypeTranslationRepository * fix replexica error * fix replexica error * fix * fix test * wip * wip * add createManyDescriptionTranslations method * improve logic * refactor * update replexica type * improve typing * Renamed descriptionTranslations to fieldTranslations * log errors in replexica service * handle translations in background * don't create, upsert instead * make sure that description is updated * simplify * fix * Update packages/trpc/server/routers/viewer/eventTypes/update.handler.ts * improve filter logic in frontend * implement background job using Tasker * update schema * update schema again * rename * rename id to uid * add migration * fix type * update * update schema and migration sql * fix migration * fix type check * fix type check 2 * improve find logic in EventMeta * add more validation * add logger * rename * upgrade replexica/sdk to 0.7.0 * upgrade replexica to 0.7.0 * use batchLocalizeText * add comments * override browser locale if user is a signed in calcom user * fix type in replexica * fix migration sql * fix type * use dynamic import * do not use batchLocalizeText * fix * add more validations * fix type error * address comment * update locales * update locales --------- Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
1 parent
93489709a8
commit
62976a4c77
14 files changed
+290
-22
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `sourceLocale` to the `EventTypeTranslation` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `targetLocale` to the `EventTypeTranslation` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeTranslation" ADD COLUMN "sourceLocale" TEXT,
|
||||
ADD COLUMN "targetLocale" TEXT;
|
||||
|
||||
-- Update data
|
||||
UPDATE "EventTypeTranslation" SET
|
||||
"sourceLocale" = "sourceLang",
|
||||
"targetLocale" = "targetLang";
|
||||
|
||||
-- Then make NOT NULL after data is copied
|
||||
ALTER TABLE "EventTypeTranslation"
|
||||
ALTER COLUMN "sourceLocale" SET NOT NULL,
|
||||
ALTER COLUMN "targetLocale" SET NOT NULL;
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[eventTypeId,field,targetLocale]` on the table `EventTypeTranslation` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeTranslation" ADD COLUMN "uid" TEXT;
|
||||
|
||||
-- Copy data
|
||||
UPDATE "EventTypeTranslation" SET
|
||||
"uid" = "id";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "EventTypeTranslation_eventTypeId_field_targetLocale_idx" ON "EventTypeTranslation"("eventTypeId", "field", "targetLocale");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventTypeTranslation_eventTypeId_field_targetLocale_key" ON "EventTypeTranslation"("eventTypeId", "field", "targetLocale");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeTranslation" ADD CONSTRAINT "EventTypeTranslation_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeTranslation" ADD CONSTRAINT "EventTypeTranslation_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -355,6 +355,8 @@ model User {
|
||||
referralLinkId String?
|
||||
features UserFeatures[]
|
||||
reassignedBookings Booking[] @relation("reassignByUser")
|
||||
createdTranslations EventTypeTranslation[] @relation("CreatedEventTypeTranslations")
|
||||
updatedTranslations EventTypeTranslation[] @relation("UpdatedEventTypeTranslations")
|
||||
|
||||
@@unique([email])
|
||||
@@unique([email, username])
|
||||
@@ -1632,17 +1634,24 @@ enum EventTypeAutoTranslatedField {
|
||||
|
||||
model EventTypeTranslation {
|
||||
id String @id @default(cuid())
|
||||
uid String?
|
||||
eventType EventType @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)
|
||||
eventTypeId Int
|
||||
field EventTypeAutoTranslatedField
|
||||
sourceLang String
|
||||
targetLang String
|
||||
sourceLocale String
|
||||
targetLocale String
|
||||
translatedText String @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
createdBy Int
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy Int?
|
||||
creator User @relation("CreatedEventTypeTranslations", fields: [createdBy], references: [id])
|
||||
updater User? @relation("UpdatedEventTypeTranslations", fields: [updatedBy], references: [id], onDelete: SetNull)
|
||||
|
||||
@@unique([eventTypeId, field, targetLang])
|
||||
@@index([eventTypeId, field, targetLang])
|
||||
@@unique([eventTypeId, field, targetLang]) // TODO: remove after migration
|
||||
@@unique([eventTypeId, field, targetLocale])
|
||||
@@index([eventTypeId, field, targetLang]) // TODO: remove after migration
|
||||
@@index([eventTypeId, field, targetLocale])
|
||||
}
|
||||
Reference in new issue
Block a user