@postxl/generator 0.33.0 → 0.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,31 +5,34 @@ exports.generateEnumType = void 0;
|
|
|
5
5
|
* Generator that generates type definitions for all enumerators.
|
|
6
6
|
*/
|
|
7
7
|
function generateEnumType({ enumerator, meta, prismaClientPath, }) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
`
|
|
18
|
-
: ''}
|
|
19
|
-
export const ${meta.types.membersList}: ${enumerator.tsTypeName}[] = [
|
|
20
|
-
${enumerator.values
|
|
21
|
-
.map((v) => {
|
|
8
|
+
let description = '';
|
|
9
|
+
if (enumerator.description) {
|
|
10
|
+
description = `
|
|
11
|
+
/**
|
|
12
|
+
* ${enumerator.description.split('\n').join('\n * ')}
|
|
13
|
+
*/`;
|
|
14
|
+
}
|
|
15
|
+
const cases = enumerator.values.map((v) => {
|
|
22
16
|
var _a;
|
|
23
17
|
const description = (_a = enumerator.attributes.valueDescription) === null || _a === void 0 ? void 0 : _a[v];
|
|
24
18
|
if (description) {
|
|
25
19
|
return `
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
/** ${description} */
|
|
21
|
+
'${v}'
|
|
22
|
+
`;
|
|
29
23
|
}
|
|
30
24
|
return `'${v}'`;
|
|
31
|
-
})
|
|
32
|
-
|
|
25
|
+
});
|
|
26
|
+
return `
|
|
27
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
28
|
+
import * as Prisma from '${prismaClientPath}'
|
|
29
|
+
|
|
30
|
+
export type ${enumerator.tsTypeName} = Prisma.${enumerator.sourceName}
|
|
31
|
+
export const ${enumerator.tsTypeName} = Prisma.${enumerator.sourceName}
|
|
32
|
+
|
|
33
|
+
${description}
|
|
34
|
+
export const ${meta.types.membersList}: ${enumerator.tsTypeName}[] = [
|
|
35
|
+
${cases.join(', ')}
|
|
33
36
|
]
|
|
34
37
|
`;
|
|
35
38
|
}
|