@simitgroup/simpleapp-generator 1.6.6-n-alpha → 1.6.6-o-alpha
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.
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -7,6 +7,35 @@
|
|
|
7
7
|
import { ApiProperty } from '@nestjs/swagger';
|
|
8
8
|
import { Field, ObjectType,ID } from '@nestjs/graphql';
|
|
9
9
|
import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';
|
|
10
|
+
|
|
11
|
+
<% const draw = (it, obj, key) => { %>
|
|
12
|
+
<% if(typeof obj == 'string') {%>
|
|
13
|
+
<% // This Is Dynamic Object %>
|
|
14
|
+
<% if(it.models?.[obj] && it.models[obj]?.model && Object.keys(it.models[obj]?.model).length === 0) { %>
|
|
15
|
+
@Field(()=>GraphQLJSON)
|
|
16
|
+
@ApiProperty({ type:()=>Object,required: false, default: {} })
|
|
17
|
+
<%= key %>: Object;
|
|
18
|
+
<% } else { %>
|
|
19
|
+
@Field()
|
|
20
|
+
@ApiProperty({type: ()=><%=obj%>})
|
|
21
|
+
<%= key %>: <%= obj %>;
|
|
22
|
+
<% } %>
|
|
23
|
+
<%} else if(typeof obj.default !='undefined' && JSON.stringify(obj.default)=='{}'){%>
|
|
24
|
+
@Field(()=>GraphQLJSON)
|
|
25
|
+
@ApiProperty({ type:()=>Object,required: false, default: {} })
|
|
26
|
+
<%= key %>: Object;
|
|
27
|
+
<% } else if( Array.isArray( obj)){%>
|
|
28
|
+
@Field(type=>[<%=initType(obj[0]) %>])
|
|
29
|
+
@ApiProperty({type: ()=>[<%=initType(obj[0]) %>] })
|
|
30
|
+
<%= key %>: <%= obj[0] %>[];
|
|
31
|
+
|
|
32
|
+
<% }else{%>
|
|
33
|
+
@Field()
|
|
34
|
+
@ApiProperty(<%~ JSON.stringify(obj)%> )
|
|
35
|
+
<%= key %>: <%= obj.type %>;
|
|
36
|
+
<% } %>
|
|
37
|
+
<% } %>
|
|
38
|
+
|
|
10
39
|
<%Object.keys(it.models).forEach(function(name) { %>
|
|
11
40
|
<% let schema = it.models[name].model %>
|
|
12
41
|
|
|
@@ -18,35 +47,35 @@ import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';
|
|
|
18
47
|
|
|
19
48
|
<% Object.keys(schema).forEach(function(key) { %>
|
|
20
49
|
<% let obj = schema[key] %>
|
|
21
|
-
<%
|
|
22
|
-
<% // This Is Dynamic Object %>
|
|
23
|
-
<% if(it.models?.[obj] && it.models[obj]?.model && Object.keys(it.models[obj]?.model).length === 0) { %>
|
|
24
|
-
@Field(()=>GraphQLJSON)
|
|
25
|
-
@ApiProperty({ type:()=>Object,required: false, default: {} })
|
|
26
|
-
<%= key %>: Object;
|
|
27
|
-
<% } else { %>
|
|
28
|
-
@Field()
|
|
29
|
-
@ApiProperty({type: ()=><%=obj%>})
|
|
30
|
-
<%= key %>: <%= obj %>;
|
|
31
|
-
<% } %>
|
|
32
|
-
<%} else if(typeof obj.default !='undefined' && JSON.stringify(obj.default)=='{}'){%>
|
|
33
|
-
@Field(()=>GraphQLJSON)
|
|
34
|
-
@ApiProperty({ type:()=>Object,required: false, default: {} })
|
|
35
|
-
<%= key %>: Object;
|
|
36
|
-
<% } else if( Array.isArray( obj)){%>
|
|
37
|
-
@Field(type=>[<%=initType(obj[0]) %>])
|
|
38
|
-
@ApiProperty({type: ()=>[<%=initType(obj[0]) %>] })
|
|
39
|
-
<%= key %>: <%= obj[0] %>[];
|
|
40
|
-
|
|
41
|
-
<% }else{%>
|
|
42
|
-
@Field()
|
|
43
|
-
@ApiProperty(<%~ JSON.stringify(obj)%> )
|
|
44
|
-
<%= key %>: <%= obj.type %>;
|
|
45
|
-
<% } %>
|
|
50
|
+
<% draw(it, obj, key) %>
|
|
46
51
|
<% }) %>
|
|
47
52
|
}
|
|
48
53
|
<%}) %>
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
/***************************************** Start Auto Complete *****************************************/
|
|
56
|
+
@ObjectType()
|
|
57
|
+
export class <%= it.apiSchemaName %>AutoComplete {
|
|
58
|
+
@Field()
|
|
59
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
60
|
+
_id: string;
|
|
61
|
+
|
|
62
|
+
@Field()
|
|
63
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
64
|
+
code: string;
|
|
65
|
+
|
|
66
|
+
@Field()
|
|
67
|
+
@ApiProperty({ type: 'string', required: true, default: '' })
|
|
68
|
+
label: string;
|
|
69
|
+
|
|
70
|
+
<% if(it.moreAutoComplete && Array.isArray(it.moreAutoComplete)) { %>
|
|
71
|
+
<% it.moreAutoComplete.forEach(function(field){ %>
|
|
72
|
+
<% draw(it, it.models[it.apiSchemaName].model[field], field) %>
|
|
73
|
+
|
|
74
|
+
<% }) %>
|
|
75
|
+
<% } %>
|
|
76
|
+
}
|
|
77
|
+
/****************************************** End Auto Complete ******************************************/
|
|
78
|
+
|
|
79
|
+
/************************************** Customized Code Begin Here *************************************/
|
|
80
|
+
<%~ it.apiSchemaCode %>
|
|
52
81
|
|
|
@@ -96,7 +96,8 @@ export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
|
96
96
|
@ApiResponse({
|
|
97
97
|
status: 200,
|
|
98
98
|
description: 'Found',
|
|
99
|
-
type:
|
|
99
|
+
type: schemas.<%= it.typename %>AutoComplete,
|
|
100
|
+
isArray: true,
|
|
100
101
|
})
|
|
101
102
|
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
102
103
|
@ApiQuery({ name: 'keyword', type:String})
|
|
@@ -6,15 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {DefaultHooks} from "../types"
|
|
8
8
|
|
|
9
|
-
<%
|
|
10
|
-
<% let schema = it.models[prop] %>
|
|
11
|
-
export type <%= prop %> = {
|
|
12
|
-
<% // Dynamic Object %>
|
|
13
|
-
<% if(it.models[prop].type === 'object' && it.models[prop]?.model && Object.keys(it.models[prop].model).length === 0 ) { %>
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
<% } else { %>
|
|
16
|
-
<%Object.keys(schema.model).forEach(function(key){ %>
|
|
17
|
-
<% const obj = schema.model[key] %>
|
|
9
|
+
<% const draw = (it, obj, key, schema) => { %>
|
|
18
10
|
<% if(typeof obj == 'string') {%>
|
|
19
11
|
<%= key %> <%if(!schema.required.includes(key)){%>?<%}%>: <%= obj %>; //child object
|
|
20
12
|
<% }else if( Array.isArray( obj)){%>
|
|
@@ -24,6 +16,18 @@ import {DefaultHooks} from "../types"
|
|
|
24
16
|
<% }else{%>
|
|
25
17
|
<%= key %> <% if(!obj.required || obj.required==false){%>?<%}%>: <%= obj.type %>; // <%~ JSON.stringify(obj) %>
|
|
26
18
|
<% } %>
|
|
19
|
+
<% } %>
|
|
20
|
+
|
|
21
|
+
<%Object.keys(it.models).forEach(function(prop){ %>
|
|
22
|
+
<% let schema = it.models[prop] %>
|
|
23
|
+
export type <%= prop %> = {
|
|
24
|
+
<% // Dynamic Object %>
|
|
25
|
+
<% if(it.models[prop].type === 'object' && it.models[prop]?.model && Object.keys(it.models[prop].model).length === 0 ) { %>
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
<% } else { %>
|
|
28
|
+
<%Object.keys(schema.model).forEach(function(key){ %>
|
|
29
|
+
<% const obj = schema.model[key] %>
|
|
30
|
+
<% draw(it, obj, key, schema) %>
|
|
27
31
|
<%})%>
|
|
28
32
|
|
|
29
33
|
<% } %>
|
|
@@ -35,4 +39,18 @@ import {DefaultHooks} from "../types"
|
|
|
35
39
|
export type <%=it.typename%>Hooks = DefaultHooks<<%=it.typename%>> & {
|
|
36
40
|
|
|
37
41
|
|
|
38
|
-
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/***************************************** Start Auto Complete *****************************************/
|
|
45
|
+
export type <%= it.apiSchemaName %>AutoComplete = {
|
|
46
|
+
_id: string;
|
|
47
|
+
code: string;
|
|
48
|
+
label: string;
|
|
49
|
+
<% if(it.moreAutoComplete && Array.isArray(it.moreAutoComplete)) { %>
|
|
50
|
+
<% it.moreAutoComplete.forEach(function(field){ %>
|
|
51
|
+
<% draw(it, it.models[it.apiSchemaName].model[field], field, it.models[it.apiSchemaName]) %>
|
|
52
|
+
<% }) %>
|
|
53
|
+
|
|
54
|
+
<% } %>
|
|
55
|
+
}
|
|
56
|
+
/****************************************** End Auto Complete ******************************************/
|