diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 000000000..90d549726 Binary files /dev/null and b/bun.lockb differ diff --git a/src/utils/writeClient.ts b/src/utils/writeClient.ts index cea2f3d88..f0fedd953 100644 --- a/src/utils/writeClient.ts +++ b/src/utils/writeClient.ts @@ -50,6 +50,25 @@ export const writeClient = async ( clientName?: string, request?: string ): Promise => { + // if there are any duplicates in the models, append a number + const modelNames = client.models.map((model) => model.name); + const modelNamesSet = new Set(modelNames); + if (modelNames.length !== modelNamesSet.size) { + const modelNamesMap = new Map(); + for (const modelName of modelNames) { + if (modelNamesMap.has(modelName)) { + modelNamesMap.set(modelName, modelNamesMap.get(modelName)! + 1); + } else { + modelNamesMap.set(modelName, 1); + } + } + for (const model of client.models) { + if (modelNamesMap.get(model.name)! > 1) { + model.name = `${model.name}${modelNamesMap.get(model.name)}`; + } + } + } + const outputPath = resolve(process.cwd(), output); const outputPathCore = resolve(outputPath, 'core'); const outputPathModels = resolve(outputPath, 'models');