UNPKG

better-auth

Version:

The most comprehensive authentication framework for TypeScript.

1 lines 1.55 kB
{"version":3,"file":"schema.mjs","names":[],"sources":["../../../src/plugins/username/schema.ts"],"sourcesContent":["import type { BetterAuthPluginDBSchema } from \"@better-auth/core/db\";\n\nexport const getSchema = (normalizer: {\n\tusername: (username: string) => string;\n\tdisplayUsername: (displayUsername: string) => string;\n}) => {\n\treturn {\n\t\tuser: {\n\t\t\tfields: {\n\t\t\t\tusername: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tsortable: true,\n\t\t\t\t\tunique: true,\n\t\t\t\t\treturned: true,\n\t\t\t\t\ttransform: {\n\t\t\t\t\t\tinput(value) {\n\t\t\t\t\t\t\treturn typeof value !== \"string\"\n\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t: normalizer.username(value as string);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdisplayUsername: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\ttransform: {\n\t\t\t\t\t\tinput(value) {\n\t\t\t\t\t\t\treturn typeof value !== \"string\"\n\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t: normalizer.displayUsername(value as string);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthPluginDBSchema;\n};\n\nexport type UsernameSchema = ReturnType<typeof getSchema>;\n"],"mappings":";AAEA,MAAa,aAAa,eAGpB;AACL,QAAO,EACN,MAAM,EACL,QAAQ;EACP,UAAU;GACT,MAAM;GACN,UAAU;GACV,UAAU;GACV,QAAQ;GACR,UAAU;GACV,WAAW,EACV,MAAM,OAAO;AACZ,WAAO,OAAO,UAAU,WACrB,QACA,WAAW,SAAS,MAAgB;MAExC;GACD;EACD,iBAAiB;GAChB,MAAM;GACN,UAAU;GACV,WAAW,EACV,MAAM,OAAO;AACZ,WAAO,OAAO,UAAU,WACrB,QACA,WAAW,gBAAgB,MAAgB;MAE/C;GACD;EACD,EACD,EACD"}