{"version":3,"file":"get-model-name.mjs","names":[],"sources":["../../../src/db/adapter/get-model-name.ts"],"sourcesContent":["import type { BetterAuthDBSchema } from \"../type\";\nimport { initGetDefaultModelName } from \"./get-default-model-name\";\n\nexport const initGetModelName = ({\n\tusePlural,\n\tschema,\n}: {\n\tusePlural: boolean | undefined;\n\tschema: BetterAuthDBSchema;\n}) => {\n\tconst getDefaultModelName = initGetDefaultModelName({\n\t\tschema,\n\t\tusePlural,\n\t});\n\t/**\n\t * Users can overwrite the default model of some tables. This function helps find the correct model name.\n\t * Furthermore, if the user passes `usePlural` as true in their adapter config,\n\t * then we should return the model name ending with an `s`.\n\t */\n\tconst getModelName = (model: string) => {\n\t\tconst defaultModelKey = getDefaultModelName(model);\n\t\tconst useCustomModelName =\n\t\t\tschema &&\n\t\t\tschema[defaultModelKey] &&\n\t\t\tschema[defaultModelKey].modelName !== model;\n\n\t\tif (useCustomModelName) {\n\t\t\treturn usePlural\n\t\t\t\t? `${schema[defaultModelKey]!.modelName}s`\n\t\t\t\t: schema[defaultModelKey]!.modelName;\n\t\t}\n\n\t\treturn usePlural ? `${model}s` : model;\n\t};\n\treturn getModelName;\n};\n"],"mappings":";;;AAGA,MAAa,oBAAoB,EAChC,WACA,aAIK;CACL,MAAM,sBAAsB,wBAAwB;EACnD;EACA;EACA,CAAC;;;;;;CAMF,MAAM,gBAAgB,UAAkB;EACvC,MAAM,kBAAkB,oBAAoB,MAAM;AAMlD,MAJC,UACA,OAAO,oBACP,OAAO,iBAAiB,cAAc,MAGtC,QAAO,YACJ,GAAG,OAAO,iBAAkB,UAAU,KACtC,OAAO,iBAAkB;AAG7B,SAAO,YAAY,GAAG,MAAM,KAAK;;AAElC,QAAO"}