forked from erikvullings/strapi-to-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
89 lines (79 loc) · 2.93 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
export interface ICommandOptions {
/** Strapi folder(s)/file(s) with models (*.settings.json) */
input: string[];
/** Strapi folder(s) with components models (*.json) */
components: string;
/** @deprecated use components */
inputGroup: string;
/** Output folder */
output: string;
/** Put all interfaces in a nested tree instead of directly under the output folder */
nested: boolean;
/** Generate enumeration */
enum: boolean;
/** By default, all collection can not be undefined. You can turn this off, so only unrequired collections may be undefined. */
collectionCanBeUndefined: boolean
/** configuration file*/
config: string;
/** Display help output */
help: boolean;
}
export interface IConfigOptions extends ICommandOptions {
/**
* Model Strapi attributes type and name => type of field.
* (use default, if empty return)
* example:
* (fieldType) => { if(fieldType == 'datetime') return 'string'}
*/
fieldType: (fieldType: string, fieldName: string, interfaceName: string) => string | undefined;
/** @deprecated use fieldType */
type: (fieldType: string, fieldName: string, interfaceName: string) => string | undefined;
/**
* Model Strapi attributes name => name of field.
* (use default, if empty return)
* example:
* (fieldName) => fieldName.replace('_', '')
*/
fieldName: (fieldName: string, interfaceName: string) => string | undefined;
/**
* Model Strapi info.name => name of typescript interface.
* (use default, if empty return)
* example:
* (name) => name.charAt(0).toUpperCase() + name.slice(1)
*/
interfaceName: (name: string, filename: string) => string | undefined;
/**
* Model Strapi attributes name.
* (use default, if empty return)
* example:
* (name) => 'Enum' + name.charAt(0).toUpperCase() + name.slice(1)
*/
enumName: (name: string, interfaceName: string) => string | undefined;
/**
* outputfile .ts path.
*/
outputFileName: (interfaceName: string, filename: string) => string | undefined;
/**
* Exclude field on typescript interface.
* example:
* (interfaceName, fieldName) => fieldName === 'hide_field'
*/
excludeField: (interfaceName: string, fieldName: string) => boolean | undefined;
/**
* Use `import type` in import statements in generated files.
* ()
* example:
* (interfaceName) => true
* (interfaceName) => interfaceName === 'MyInterface'
*/
importAsType: (interfaceName: string) => boolean | undefined;
/**
* add your fields on typescript interface.
* example:
* () => [{ name: "created_by", type: "string" }, { name: "updated_by", type: "string" }]
*/
addField: (interfaceName: string) => { name: string, type: string }[]
}
declare module 'strapi-to-typescript' {
export = IConfigOptions
}