docs-util: added AI generator (#6770)

## What

Adds an AI generator to the docblock tool that uses OpenAI.

The generator at the moment only generates examples for functions when the `--generate-examples` option is provided.

## Note

I've included the generated examples of the `IOrderModuleService` as a reference of the type of result provided by the AI generator, with minor tweeks I've made. I haven't made any changes to descriptions in that file.
This commit is contained in:
Shahed Nasser
2024-03-28 13:32:30 +02:00
committed by GitHub
parent 6bf4d40856
commit 21156f945d
16 changed files with 2655 additions and 196 deletions
@@ -22,7 +22,6 @@ export function camelToTitle(str: string): string {
.map((word) => capitalize(word))
.join(" ")
.trim()
.toLowerCase()
}
export function snakeToWords(str: string): string {
@@ -62,6 +61,10 @@ export function wordsToPascal(str: string): string {
.join("")
}
export function pascalToCamel(str: string): string {
return `${str.charAt(0).toLowerCase()}${str.substring(1)}`
}
/**
* Remove parts of the name such as DTO, Filterable, etc...
*
@@ -70,8 +73,10 @@ export function wordsToPascal(str: string): string {
*/
export function normalizeName(str: string): string {
return str
.replace(/^(create|update|delete)/i, "")
.replace(/^(create|update|delete|upsert)/i, "")
.replace(/DTO$/, "")
.replace(/^Filterable/, "")
.replace(/Props$/, "")
.replace(/^I([A-Z])/, "$1")
.replace(/ModuleService$/, "")
}