Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export const templates = [
component: EmailVerificationTemplate
},
{
key: EmailTemplateType.Magicsession,
key: 'magicSession' as EmailTemplateType,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find the EmailTemplateType enum definition in the installed package
find node_modules -name "*.d.ts" -o -name "*.ts" 2>/dev/null | head -20

Repository: appwrite/console

Length of output: 3816


🏁 Script executed:

# Search for EmailTemplateType enum definition
rg "enum EmailTemplateType|export.*EmailTemplateType" --type ts --type js -A 15

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

# Look at the file context to understand the usage
head -100 src/routes/\(console\)/project-\[region\]-\[project\]/auth/templates/store.ts | tail -60

Repository: appwrite/console

Length of output: 1872


🏁 Script executed:

# Check if the file imports EmailTemplateType and how it's used
grep -n "EmailTemplateType\|import.*Email" "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts"

Repository: appwrite/console

Length of output: 978


🏁 Script executed:

find node_modules -path "*@appwrite.io/console*" -name "*.d.ts" -o -path "*@appwrite.io/console*" -name "*.ts" 2>/dev/null | grep -v ".test\|.spec" | head -20

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

find node_modules -path "*@appwrite.io/console*" -type f \( -name "*.d.ts" -o -name "*.js" \) 2>/dev/null | head -30

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

rg "enum EmailTemplateType|export.*EmailTemplateType" node_modules/@appwrite.io/console -A 20 2>/dev/null

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

rg "EmailTemplateType" node_modules 2>/dev/null | head -20

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

find node_modules -type f -name "*.d.ts" | xargs grep -l "EmailTemplateType" 2>/dev/null | head -10

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

ls -la node_modules/@appwrite.io/ 2>/dev/null || ls -la node_modules/ | grep appwrite

Repository: appwrite/console

Length of output: 614


🏁 Script executed:

rg "EmailTemplateType" --type ts --type js -B 2 -A 10 | head -100

Repository: appwrite/console

Length of output: 6429


🏁 Script executed:

find src -type f \( -name "*.ts" -o -name "*.d.ts" \) | xargs grep -l "enum EmailTemplateType\|export.*EmailTemplateType" 2>/dev/null

Repository: appwrite/console

Length of output: 44


🏁 Script executed:

cat package.json | grep -A 5 -B 5 "@appwrite.io/console"

Repository: appwrite/console

Length of output: 639


🏁 Script executed:

find src -type f \( -name "*.ts" -o -name "*.d.ts" \) | xargs grep -l "enum.*EmailTemplateType\|export.*EmailTemplateType.*=" 2>/dev/null

Repository: appwrite/console

Length of output: 44


🏁 Script executed:

rg "enum EmailTemplateType|EmailTemplateType\s*=" --type ts --type tsx -B 2 -A 15

Repository: appwrite/console

Length of output: 87


🏁 Script executed:

# Check if there's a types or lib folder
find . -maxdepth 3 -type d -name "types" -o -name "lib" -o -name "@appwrite.io" 2>/dev/null | grep -v node_modules

Repository: appwrite/console

Length of output: 69


🏁 Script executed:

# Look at git history to understand what changed
git log --oneline -20 -- "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts" 2>/dev/null

Repository: appwrite/console

Length of output: 115


🏁 Script executed:

git show 1405f4231 -- "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts" 2>/dev/null | head -100

Repository: appwrite/console

Length of output: 3475


🏁 Script executed:

# Look in src/lib for type definitions
find src/lib -type f \( -name "*.ts" -o -name "*.d.ts" \) | head -20

Repository: appwrite/console

Length of output: 782


🌐 Web query:

@appwrite.io/console EmailTemplateType enum members

💡 Result:

In Appwrite, the email template types (exposed as EmailTemplateType in the Console SDK @appwrite.io/console) correspond to these built-in template categories:

  • Account verification
  • Magic URL authentication
  • Password reset
  • User invite (appwrite.io)

Citations:


🌐 Web query:

appwrite console SDK EmailTemplateType magicSession otpSession

💡 Result:

In the Appwrite Console SDK (@appwrite.io/console), the EmailTemplateType enum uses Magicsession and Otpsession (not magicSession / otpSession) and they map to these string values: "magicsession" and "otpsession". [1]

import { EmailTemplateType } from '@appwrite.io/console';

EmailTemplateType.Magicsession; // "magicsession"
EmailTemplateType.Otpsession;   // "otpsession"

These correspond to the email templates used for Magic URL login and Email OTP login flows in Appwrite. [2][3]

Sources
[1] Appwrite Console SDK types: email-template-type.d.ts (jsDelivr)
[2] Appwrite Docs: Email OTP
[3] Appwrite Docs: Message templates / email templates


Add TODO comments documenting the enum value mismatch workaround.

The four changed keys use '...' as EmailTemplateType type assertions because the @appwrite.io/console SDK's enum members (Magicsession, Otpsession, Mfachallenge, Sessionalert) hold all-lowercase string values ("magicsession", "otpsession", etc.), which don't match the camelCase strings the API expects ("magicSession", "otpSession", etc.). Using as EmailTemplateType bypasses type safety—if the SDK is ever updated with correct enum members, this code won't be caught by the type system.

Add // TODO comments to each of the four lines (54, 60, 78, 84) explaining the workaround, following the guideline to comment complex logic. Example:

-        key: 'magicSession' as EmailTemplateType,
+        // TODO: Use EmailTemplateType.MagicSession once SDK enum is corrected
+        key: 'magicSession' as EmailTemplateType,

The inconsistency of mixing three direct enum references (Verification, Recovery, Invitation) with four string literal assertions should be resolved once the SDK is fixed.

Also applies to: 60-60, 78-78, 84-84

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/`(console)/project-[region]-[project]/auth/templates/store.ts at
line 54, Add a brief TODO comment on each of the four lines that use string
assertions for EmailTemplateType—specifically the keys "'magicSession' as
EmailTemplateType", "'otpSession' as EmailTemplateType", "'mfaChallenge' as
EmailTemplateType", and "'sessionAlert' as EmailTemplateType"—explaining this is
a temporary workaround because the `@appwrite.io/console` SDK enum members (e.g.,
Magicsession, Otpsession, Mfachallenge, Sessionalert) use all-lowercase values
that don't match the API's camelCase template names, that the type assertion
bypasses type safety, and that the TODO should be removed once the SDK enum is
corrected.

title: 'Magic URL',
description: 'Send an email to users that sign in with a magic URL.',
component: EmailMagicUrlTemplate
},
{
key: EmailTemplateType.Otpsession,
key: 'otpSession' as EmailTemplateType,
title: 'OTP session',
description: 'Send an email to users that sign in with a email OTP.',
component: EmailOtpSessionTemplate
Expand All @@ -75,13 +75,13 @@ export const templates = [
component: EmailInviteTemplate
},
{
key: EmailTemplateType.Mfachallenge,
key: 'mfaChallenge' as EmailTemplateType,
title: '2FA verification',
description: 'Send a two-factor authentication email to a user.',
component: Email2FaTemplate
},
{
key: EmailTemplateType.Sessionalert,
key: 'sessionAlert' as EmailTemplateType,
title: 'Session alert',
description: 'Send an email to users when a new session is created.',
component: EmailSessionAlertTemplate,
Expand Down