{"version":3,"file":"get-field-name.mjs","names":[],"sources":["../../../src/db/adapter/get-field-name.ts"],"sourcesContent":["import type { BetterAuthDBSchema } from \"../type\";\nimport { initGetDefaultFieldName } from \"./get-default-field-name\";\nimport { initGetDefaultModelName } from \"./get-default-model-name\";\n\nexport const initGetFieldName = ({\n\tschema,\n\tusePlural,\n}: {\n\tschema: BetterAuthDBSchema;\n\tusePlural: boolean | undefined;\n}) => {\n\tconst getDefaultModelName = initGetDefaultModelName({\n\t\tschema,\n\t\tusePlural,\n\t});\n\n\tconst getDefaultFieldName = initGetDefaultFieldName({\n\t\tschema,\n\t\tusePlural,\n\t});\n\n\t/**\n\t * Get the field name which is expected to be saved in the database based on the user's schema.\n\t *\n\t * This function is useful if you need to save the field name to the database.\n\t *\n\t * For example, if the user has defined a custom field name for the `user` model, then you can use this function to get the actual field name from the schema.\n\t */\n\tfunction getFieldName({\n\t\tmodel: modelName,\n\t\tfield: fieldName,\n\t}: {\n\t\tmodel: string;\n\t\tfield: string;\n\t}) {\n\t\tconst model = getDefaultModelName(modelName);\n\t\tconst field = getDefaultFieldName({ model, field: fieldName });\n\n\t\treturn schema[model]?.fields[field]?.fieldName || field;\n\t}\n\n\treturn getFieldName;\n};\n"],"mappings":";;;;AAIA,MAAa,oBAAoB,EAChC,QACA,gBAIK;CACL,MAAM,sBAAsB,wBAAwB;EACnD;EACA;EACA,CAAC;CAEF,MAAM,sBAAsB,wBAAwB;EACnD;EACA;EACA,CAAC;;;;;;;;CASF,SAAS,aAAa,EACrB,OAAO,WACP,OAAO,aAIL;EACF,MAAM,QAAQ,oBAAoB,UAAU;EAC5C,MAAM,QAAQ,oBAAoB;GAAE;GAAO,OAAO;GAAW,CAAC;AAE9D,SAAO,OAAO,QAAQ,OAAO,QAAQ,aAAa;;AAGnD,QAAO"}