@simitgroup/simpleapp-generator 1.0.22 → 1.0.24
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/README.md +48 -0
- package/dist/createproject.js +1 -1
- package/dist/createproject.js.map +1 -1
- package/dist/framework.js +20 -16
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +38 -16
- package/dist/generate.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/processors/jsonschemabuilder.js +9 -9
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/package.json +1 -1
- package/src/framework.ts +37 -30
- package/src/generate.ts +37 -21
- package/src/index.ts +2 -1
- package/src/processors/jsonschemabuilder.ts +9 -9
- package/src/type.ts +1 -0
- package/templates/basic/apischema.eta +8 -4
- package/templates/basic/controller.eta +21 -5
- package/templates/basic/jsonschema.eta +2 -0
- package/templates/basic/model.eta +2 -6
- package/templates/basic/module.eta +2 -0
- package/templates/basic/pageindex.vue.eta +28 -15
- package/templates/basic/pageindexwithid.vue.eta +13 -1
- package/templates/basic/service.eta +11 -9
- package/templates/basic/simpleappclient.eta +9 -8
- package/templates/basic/type.eta +2 -1
- package/templates/nest/SimpleAppController.eta +5 -5
- package/templates/nest/SimpleAppService.eta +87 -31
- package/templates/nest/TenantMiddleware.eta +30 -0
- package/templates/nest/User.eta +80 -0
- package/templates/nest/app.module.eta +14 -3
- package/templates/nest/inputvalidation-exception.eta +6 -0
- package/templates/nest/nest.main.eta +2 -0
- package/templates/nuxt/components.crudsimple.vue.eta +61 -48
- package/templates/nuxt/components.debugdocdata.vue.eta +12 -4
- package/templates/nuxt/components.eventmonitor.vue.eta +17 -11
- package/templates/nuxt/components.menus.vue.eta +14 -12
- package/templates/nuxt/composables.getautocomplete.ts.eta +7 -1
- package/templates/nuxt/composables.getmenus.ts.eta +9 -2
- package/templates/nuxt/env.eta +2 -0
- package/templates/nuxt/layouts.default.vue.eta +10 -3
- package/templates/nuxt/nuxt.config.ts.eta +4 -1
- package/templates/nuxt/pages.index.vue.eta +8 -0
- package/templates/nuxt/plugins.simpleapp.ts.eta +10 -1
- package/templates/nuxt/server.api.ts.eta +14 -5
- package/src/createproject.ts +0 -121
- package/src/index2.ts +0 -132
- package/src/installdependency.sh +0 -5
- package/src/installnest.ts +0 -0
- package/src/installnuxt.ts +0 -0
- package/templates/basic/backend.config.eta +0 -1
- package/templates/basic/beforesave.eta +0 -7
- package/templates/basic/controller2.eta +0 -86
- package/templates/basic/frontend.config.eta +0 -1
- package/templates/basic/model-converter.etabackup +0 -21
- package/templates/basic/readme.eta +0 -3
- package/templates/basic/service.etabackupe +0 -106
- package/templates/basic/type.etabackup +0 -23
- package/templates/basic/uischema.eta +0 -13
package/src/generate.ts
CHANGED
|
@@ -72,7 +72,7 @@ const generate = (
|
|
|
72
72
|
frontendfolder:string
|
|
73
73
|
) => {
|
|
74
74
|
const targetfolder = `${backendfolder}/src/docs/${doctype}`;
|
|
75
|
-
const frontendpagefolder=`${frontendfolder}/pages`
|
|
75
|
+
const frontendpagefolder=`${frontendfolder}/pages/[xorg]`
|
|
76
76
|
try {
|
|
77
77
|
|
|
78
78
|
mkdirSync(targetfolder,{ recursive: true });
|
|
@@ -106,7 +106,8 @@ const generate = (
|
|
|
106
106
|
bothEndCode: '',
|
|
107
107
|
frontEndCode: '',
|
|
108
108
|
backEndCode: '',
|
|
109
|
-
controllerCode:''
|
|
109
|
+
controllerCode:'',
|
|
110
|
+
apiSchemaCode:'',
|
|
110
111
|
};
|
|
111
112
|
|
|
112
113
|
// console.log('generate 2', JSON.stringify(variables));
|
|
@@ -126,21 +127,33 @@ const generate = (
|
|
|
126
127
|
writeFileSync(`${targetfolder}/${doctype}.jsonschema.ts`, txtJsonSchema);
|
|
127
128
|
|
|
128
129
|
// generate before save source code, wont override after regenerate
|
|
129
|
-
const customizefilename = `${targetfolder}/${doctype}.beforesave.ts`;
|
|
130
|
-
if (!existsSync(customizefilename)) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
130
|
+
// const customizefilename = `${targetfolder}/${doctype}.beforesave.ts`;
|
|
131
|
+
// if (!existsSync(customizefilename)) {
|
|
132
|
+
// const txtBeforeSave = eta.render('./beforesave', variables);
|
|
133
|
+
// writeFileSync(
|
|
134
|
+
// `${targetfolder}/${doctype}.beforesave.ts`,
|
|
135
|
+
// txtBeforeSave,
|
|
136
|
+
// );
|
|
137
|
+
// }
|
|
137
138
|
// write mongoose model file
|
|
138
139
|
const txtModel = eta.render('./model', variables);
|
|
139
140
|
writeFileSync(`${targetfolder}/${doctype}.model.ts`, txtModel);
|
|
140
141
|
|
|
141
142
|
// prepare openapi schema
|
|
143
|
+
const apischemafile=`${targetfolder}/${doctype}.apischema.ts`
|
|
144
|
+
if (existsSync(apischemafile)) {
|
|
145
|
+
const apischemaCode = readFileSync(apischemafile).toString();
|
|
146
|
+
const regexapischema =
|
|
147
|
+
/\/\/<begin-apischema-code>([\s\S]*?)\/\/<end-apischema-code>/g;
|
|
148
|
+
const apischemaresult = apischemaCode.match(regexapischema);
|
|
149
|
+
if (apischemaresult) {
|
|
150
|
+
variables.apiSchemaCode = apischemaresult[0];
|
|
151
|
+
}else{
|
|
152
|
+
variables.apiSchemaCode="//<begin-apischema-code>\n//<end-apischema-code>";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
142
155
|
const txtApiSchema = eta.render('./apischema', variables);
|
|
143
|
-
writeFileSync(
|
|
156
|
+
writeFileSync(apischemafile, txtApiSchema);
|
|
144
157
|
|
|
145
158
|
// prepare backend classes
|
|
146
159
|
// prepare frontend api client
|
|
@@ -158,17 +171,22 @@ const generate = (
|
|
|
158
171
|
/\/\/<begin-backend-code>([\s\S]*?)\/\/<end-backend-code>/g;
|
|
159
172
|
const bothendresult = servicecodes.match(regex1);
|
|
160
173
|
const backendresult = servicecodes.match(regex2);
|
|
174
|
+
console.log("bothendresult",bothendresult)
|
|
175
|
+
console.log("backendresult",backendresult)
|
|
161
176
|
if (bothendresult) {
|
|
162
|
-
bothEndCode = bothendresult[0];
|
|
177
|
+
variables.bothEndCode = bothendresult[0];
|
|
178
|
+
}else{
|
|
179
|
+
variables.bothEndCode="//<begin-bothend-code>\n//<end-bothend-code>";
|
|
163
180
|
}
|
|
164
181
|
|
|
165
182
|
if (backendresult) {
|
|
166
|
-
backEndCode = backendresult[0];
|
|
183
|
+
variables.backEndCode = backendresult[0];
|
|
184
|
+
}else{
|
|
185
|
+
variables.backEndCode="//<begin-backend-code>\n//<end-backend-code>";
|
|
167
186
|
}
|
|
168
187
|
}
|
|
169
188
|
|
|
170
|
-
|
|
171
|
-
variables.backEndCode = backEndCode ?? "//<begin-backend-code>\n//<end-backend-code>";
|
|
189
|
+
|
|
172
190
|
const txtService = eta.render('./service', variables);
|
|
173
191
|
writeFileSync(`${targetfolder}/${doctype}.service.ts`, txtService);
|
|
174
192
|
|
|
@@ -193,8 +211,8 @@ const generate = (
|
|
|
193
211
|
writeFileSync(`${targetfolder}/${doctype}.module.ts`, txtModule);
|
|
194
212
|
|
|
195
213
|
// prepare readme
|
|
196
|
-
const txtReadme = eta.render('./readme', variables);
|
|
197
|
-
writeFileSync(`${targetfolder}/README.md`, txtReadme);
|
|
214
|
+
// const txtReadme = eta.render('./readme', variables);
|
|
215
|
+
// writeFileSync(`${targetfolder}/README.md`, txtReadme);
|
|
198
216
|
|
|
199
217
|
const frontendfile = `${frontendfolder}/simpleapp/simpleappdocs/${variables.typename}Doc.ts`;
|
|
200
218
|
let frontEndCode = '';
|
|
@@ -249,12 +267,10 @@ const prepareEnvironments = (backendfolder:string,frontendfolder:string)=>{
|
|
|
249
267
|
//do nothing
|
|
250
268
|
}
|
|
251
269
|
|
|
252
|
-
//copy over backend service class
|
|
253
|
-
|
|
254
270
|
copyFileSync(`${constants.templatedir}/nest/SimpleAppService.eta`,`${targetfolder}/SimpleAppService.ts`)
|
|
255
|
-
|
|
256
|
-
//copy over backend controller
|
|
257
271
|
copyFileSync(`${constants.templatedir}/nest/SimpleAppController.eta`,`${targetfolder}/SimpleAppController.ts`)
|
|
272
|
+
copyFileSync(`${constants.templatedir}/nest/TenantMiddleware.eta`,`${targetfolder}/TenantMiddleware.ts`)
|
|
273
|
+
copyFileSync(`${constants.templatedir}/nest/User.eta`,`${targetfolder}/User.ts`)
|
|
258
274
|
|
|
259
275
|
//copy over frontend apiabstract class
|
|
260
276
|
// copyFileSync(`${constants.templatedir}/nuxt.apigateway.eta`,`${targetfrontendfolder}/[...].ts`)
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,8 @@ program
|
|
|
27
27
|
|
|
28
28
|
let path=''
|
|
29
29
|
const options = program.opts();
|
|
30
|
-
console.log(figlet.textSync(`SimpleApp Generator
|
|
30
|
+
console.log(figlet.textSync(`SimpleApp Generator`));
|
|
31
|
+
console.log(figlet.textSync(`${version}`));
|
|
31
32
|
if(!options.configFile){
|
|
32
33
|
log.error("Config file parameter is required. Example: simpleapp-generator -c ./config.json")
|
|
33
34
|
throw "Undefine configuration file"
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
} from '../type';
|
|
18
18
|
import { json } from 'stream/consumers';
|
|
19
19
|
const log: Logger<ILogObj> = new Logger();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
20
|
+
const X_DOCUMENT_NO='x-document-no'
|
|
21
|
+
const X_DOCUMENT_NAME='x-document-name'
|
|
22
22
|
const FOREIGNKEY_PROPERTY='x-foreignkey'
|
|
23
23
|
let allmodels: ChildModels = {};
|
|
24
24
|
let fullschema={}
|
|
@@ -53,11 +53,11 @@ export const readJsonSchemaBuilder = async (
|
|
|
53
53
|
throw(`unsupport array type for ${docname}.${doctype}`)
|
|
54
54
|
}
|
|
55
55
|
if(fieldAutoCompleteCode=='') {
|
|
56
|
-
log.error(`you shall define 1 field with format:'${
|
|
56
|
+
log.error(`you shall define 1 field with format:'${X_DOCUMENT_NO}'`)
|
|
57
57
|
throw "missing field format"
|
|
58
58
|
}
|
|
59
59
|
if(fieldAutoCompleteName=='') {
|
|
60
|
-
log.error(`you shall define 1 field with format: '${
|
|
60
|
+
log.error(`you shall define 1 field with format: '${X_DOCUMENT_NAME}'}`)
|
|
61
61
|
throw "missing field format"
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -75,9 +75,9 @@ const processObject = (doctype: string,
|
|
|
75
75
|
//ensure some field exists, also override it
|
|
76
76
|
jsondata.properties['_id'] = {type: 'string',description: 'Control value, dont edit it',};
|
|
77
77
|
jsondata.properties['doctype'] = {type: 'string', default:doctype, examples: [doctype],description: 'Control value, dont edit it',};
|
|
78
|
-
jsondata.properties['
|
|
79
|
-
jsondata.properties['
|
|
80
|
-
jsondata.properties['
|
|
78
|
+
jsondata.properties['tenantId'] = {type: 'number',description: 'Control value, dont edit it',};
|
|
79
|
+
jsondata.properties['orgId'] = {type: 'number',description: 'Control value, dont edit it',};
|
|
80
|
+
jsondata.properties['branchId'] = {type: 'number',description: 'Control value, dont edit it',};
|
|
81
81
|
jsondata.properties['created'] = {type: 'string',description: 'Control value, dont edit it',};
|
|
82
82
|
jsondata.properties['updated'] = {type: 'string',description: 'Control value, dont edit it',};
|
|
83
83
|
jsondata.properties['createdby'] = {type: 'string',description: 'Control value, dont edit it',};
|
|
@@ -111,10 +111,10 @@ const genSchema = (
|
|
|
111
111
|
|
|
112
112
|
const isrequired = requiredlist && requiredlist.includes(key);
|
|
113
113
|
const newName: string = docname + capitalizeFirstLetter(key);
|
|
114
|
-
if(obj.format && obj.format==
|
|
114
|
+
if(obj.format && obj.format==X_DOCUMENT_NO){
|
|
115
115
|
fieldAutoCompleteCode=key
|
|
116
116
|
}
|
|
117
|
-
if(obj.format && obj.format==
|
|
117
|
+
if(obj.format && obj.format==X_DOCUMENT_NAME){
|
|
118
118
|
fieldAutoCompleteName=key
|
|
119
119
|
}
|
|
120
120
|
// if (obj.type == 'object' && obj.items ){
|
package/src/type.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR Except content between:
|
|
4
|
+
* <begin-apischema-code><end-apischema-code>
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
import { ApiProperty } from '@nestjs/swagger';
|
|
7
9
|
|
|
@@ -26,4 +28,6 @@ import { ApiProperty } from '@nestjs/swagger';
|
|
|
26
28
|
}
|
|
27
29
|
<%}) %>
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
/*****************************customized code begin here *****************************************/
|
|
32
|
+
<%~ it.apiSchemaCode %>
|
|
33
|
+
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR Except content between:
|
|
4
|
+
* <begin-controller-code><end-controller-code>
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
import {
|
|
7
9
|
Controller,
|
|
@@ -39,7 +41,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
39
41
|
type: [<%= it.fullApiSchemaName%>]
|
|
40
42
|
})
|
|
41
43
|
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
42
|
-
@ApiOperation({ operationId: 'runList' })
|
|
44
|
+
@ApiOperation({ operationId: 'runList', description:"List all data" })
|
|
43
45
|
async list() {
|
|
44
46
|
return this._list();
|
|
45
47
|
}
|
|
@@ -51,7 +53,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
51
53
|
type: ()=>[{id:'100',label:'label1'}],
|
|
52
54
|
})
|
|
53
55
|
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
54
|
-
@ApiOperation({ operationId: 'autoComplete' })
|
|
56
|
+
@ApiOperation({ operationId: 'autoComplete',description:"retrieve array of {_id, code, name}" })
|
|
55
57
|
async autoComplete(@Query('keyword') keyword: string) {
|
|
56
58
|
return this._autocomplete(keyword);
|
|
57
59
|
}
|
|
@@ -86,6 +88,20 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
86
88
|
return await this._create(data)
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
@Post('/search')
|
|
92
|
+
@ApiResponse({
|
|
93
|
+
status: 201,
|
|
94
|
+
description: 'success',
|
|
95
|
+
type: [<%= it.fullApiSchemaName%>]
|
|
96
|
+
})
|
|
97
|
+
@ApiResponse({ status: 400, description: 'bad request' })
|
|
98
|
+
@ApiResponse({ status: 500, description: 'internal error' })
|
|
99
|
+
@ApiBody({ description: 'Data', type: Object })
|
|
100
|
+
@ApiOperation({ operationId: 'runSearch' })
|
|
101
|
+
async search(@Body() data: Object) {
|
|
102
|
+
return await this._search(data)
|
|
103
|
+
}
|
|
104
|
+
|
|
89
105
|
@Put(':id')
|
|
90
106
|
@ApiResponse({
|
|
91
107
|
status: 200,
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* This file was automatically generated by simpleapp generator.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and regenerate this file.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
export const <%= it.typename%>JsonSchema = <%~ JSON.stringify(it.jsonschema) %>
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
* This file was automatically generated by simpleapp generator.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and regenerate this file.
|
|
5
|
-
*
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
<% const schema = it.schema %>
|
|
9
10
|
<% const typeclass = it.doctype+'type' %>
|
|
10
11
|
import { Schema } from 'mongoose';
|
|
11
12
|
import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from './<%= it.doctype %>.type';
|
|
12
|
-
import { beforeSave } from './<%= it.doctype %>.beforesave';
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
const schemasetting = {
|
|
16
14
|
|
|
17
15
|
<%Object.keys(it.schema).forEach(function(key) { %>
|
|
@@ -31,5 +29,3 @@ const schemasetting = {
|
|
|
31
29
|
};
|
|
32
30
|
|
|
33
31
|
export const <%= it.doctype %>MongoSchema = new Schema(schemasetting,{collection: '<%= it.name %>'})
|
|
34
|
-
.post('validate', (doc: <%= it.typename %>) => beforeSave(doc))
|
|
35
|
-
.pre('save', () => {});
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* This file was automatically generated by simpleapp generator.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and regenerate this file.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
import { Module } from '@nestjs/common';
|
|
7
9
|
import { <%= it.typename %>Controller } from './<%= it.doctype %>.controller';
|
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp everytime regenerate code.
|
|
4
|
+
* delete file "delete-me-for-avoid-override" if you want to modify this file and
|
|
5
|
+
* prevent regenerate code override it.
|
|
6
|
+
* last change 2023-09-09
|
|
7
|
+
* author: Ks Tan
|
|
8
|
+
*/
|
|
9
|
+
<% let skipcolumns = ['_id','createdby','created','updatedby','updated','orgId','branchId','tenantId','doctype'] %>
|
|
10
|
+
|
|
11
|
+
import { <%= it.typename %>Doc } from "../../../simpleapp/simpleappdocs/<%= it.typename %>Doc";
|
|
12
|
+
const { $event, $listen } = useNuxtApp();
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
const doc = new <%= it.typename %>Doc(route.params.xorg,$event, $listen);
|
|
15
|
+
const documentpath = `/${route.params.xorg}/<%= it.name %>`;
|
|
16
|
+
const data = doc.getReactiveData();
|
|
17
|
+
const columns = [
|
|
18
|
+
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
19
|
+
<%let obj=it.jsonschema.properties[key] %>
|
|
20
|
+
<%if(skipcolumns.indexOf(key)>=0){%>/* skip system columns <%=key%>*/
|
|
21
|
+
<%} else if(['string','number','integer'].indexOf(obj.type)>=0){%>'<%=key%>',<%}%>
|
|
22
|
+
<%})%>
|
|
23
|
+
]
|
|
24
|
+
</script>
|
|
1
25
|
<template>
|
|
2
|
-
<% let skipcolumns = ['_id','createdby','created','updatedby','updated','organization_id','branch_id','tenant_id','doctype'] %>
|
|
3
26
|
<div>
|
|
4
|
-
<CrudSimple :document="doc" title="<%= it.typename %>"
|
|
27
|
+
<CrudSimple :document="doc" title="<%= it.typename %>"
|
|
28
|
+
#default="o"
|
|
29
|
+
:path="documentpath"
|
|
5
30
|
:listColumns="columns">
|
|
6
31
|
|
|
7
32
|
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
@@ -38,17 +63,5 @@
|
|
|
38
63
|
</CrudSimple>
|
|
39
64
|
</div>
|
|
40
65
|
</template>
|
|
41
|
-
|
|
42
|
-
import { <%= it.typename %>Doc } from "../../simpleapp/simpleappdocs/<%= it.typename %>Doc";
|
|
43
|
-
const { $event, $listen } = useNuxtApp();
|
|
44
|
-
const doc = new <%= it.typename %>Doc($event, $listen);
|
|
45
|
-
const data = doc.getReactiveData();
|
|
46
|
-
const columns = [
|
|
47
|
-
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
48
|
-
<%let obj=it.jsonschema.properties[key] %>
|
|
49
|
-
<%if(skipcolumns.indexOf(key)>=0){%>/* skip system columns <%=key%>*/
|
|
50
|
-
<%} else if(['string','number','integer'].indexOf(obj.type)>=0){%>'<%=key%>',<%}%>
|
|
51
|
-
<%})%>
|
|
52
|
-
]
|
|
53
|
-
</script>
|
|
66
|
+
|
|
54
67
|
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
<
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by simpleapp everytime regenerate code.
|
|
4
|
+
* delete file "delete-me-for-avoid-override" if you want to modify this file and
|
|
5
|
+
* prevent regenerate code override it.
|
|
6
|
+
* last change 2023-09-09
|
|
7
|
+
* author: Ks Tan
|
|
8
|
+
*/
|
|
9
|
+
import Index from './index.vue'
|
|
10
|
+
</script>
|
|
11
|
+
<template>
|
|
12
|
+
<Index/>
|
|
13
|
+
</template>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR Except content between:
|
|
4
|
+
* <begin-bothend-code><end-bothend-code>
|
|
5
|
+
* <begin-backend-code><end-backend-code>
|
|
6
|
+
* last change 2023-09-09
|
|
7
|
+
* Author: Ks Tan
|
|
5
8
|
*/
|
|
6
9
|
import { Injectable } from '@nestjs/common';
|
|
7
10
|
import { InjectModel } from '@nestjs/mongoose';
|
|
8
11
|
import { Model } from 'mongoose';
|
|
9
12
|
import {<%= it.typename%>JsonSchema } from './<%= it.doctype %>.jsonschema'
|
|
10
|
-
import { SimpleAppService } from '../../class/SimpleAppService';
|
|
13
|
+
import { SimpleAppService,IsolationType } from '../../class/SimpleAppService';
|
|
11
14
|
import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from './<%= it.doctype %>.type';
|
|
12
15
|
|
|
13
16
|
|
|
@@ -17,18 +20,17 @@ export class <%= it.typename %>Service extends SimpleAppService<<%= it.typename
|
|
|
17
20
|
protected documentIdentityName='<%~ it.autocompletename %>'
|
|
18
21
|
constructor(@InjectModel('<%= it.name %>') mydoc: Model<<%= it.typename %>>,
|
|
19
22
|
) {
|
|
20
|
-
super(mydoc);
|
|
23
|
+
super(mydoc,IsolationType.org);
|
|
21
24
|
this.setSchema(<%= it.typename%>JsonSchema)
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
/*****************************customized frontend + backend code*****************************************/
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
<%~ it.bothEndCode %>
|
|
29
31
|
|
|
30
32
|
/*****************************customized backend only code*****************************************/
|
|
31
|
-
|
|
32
|
-
<%~ it.backEndCode %>
|
|
33
|
+
|
|
34
|
+
<%~ it.backEndCode %>
|
|
33
35
|
|
|
34
36
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was automatically generated by simpleapp generator.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR Except content between:
|
|
4
|
+
* <begin-frontend-code><end-frontend-code>
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
import { SimpleAppClient } from "@simitgroup/simpleapp-vue-component/src/SimpleAppClient";
|
|
7
9
|
|
|
@@ -21,8 +23,8 @@ export class <%= it.typename%>Doc extends SimpleAppClient<<%= it.typename%>,<%=
|
|
|
21
23
|
public readonly schema= <%~ JSON.stringify(it.jsonschema) %>;
|
|
22
24
|
protected documentIdentityCode='<%~ it.autocompletecode %>'
|
|
23
25
|
protected documentIdentityName='<%~ it.autocompletename %>'
|
|
24
|
-
constructor(event:any,listen?:any) {
|
|
25
|
-
const apiconfig = new Configuration({ basePath: useRuntimeConfig().public.APP_URL
|
|
26
|
+
constructor(xorg:string,event:any,listen?:any) {
|
|
27
|
+
const apiconfig = new Configuration({ basePath: `${useRuntimeConfig().public.APP_URL}/api/${xorg}` });
|
|
26
28
|
const apiobj = new <%= it.doctype.toUpperCase()%>Api(apiconfig)
|
|
27
29
|
super(apiobj,'<%= it.doctype %>','<%=it.name %>')
|
|
28
30
|
this.event=event
|
|
@@ -56,11 +58,10 @@ export class <%= it.typename%>Doc extends SimpleAppClient<<%= it.typename%>,<%=
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/*****************************customized frontend + backend code*****************************************/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
|
|
61
62
|
<%~ it.bothEndCode %>
|
|
62
63
|
|
|
63
64
|
/*****************************customized frontend only code*****************************************/
|
|
64
|
-
|
|
65
65
|
<%~ it.frontEndCode %>
|
|
66
|
+
|
|
66
67
|
}
|
package/templates/basic/type.eta
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* This file was automatically generated by simpleapp generator.
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and regenerate this file.
|
|
5
|
+
* last change 2023-09-09
|
|
6
|
+
* Author: Ks Tan
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
|
|
8
9
|
<%Object.keys(it.models).forEach(function(prop){ %>
|
|
9
10
|
<% let schema = it.models[prop] %>
|
|
10
11
|
export type <%= prop %> = {
|
|
@@ -13,6 +13,7 @@ import { ApiTags, ApiBody, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
|
13
13
|
const doctype = 'person'.toUpperCase();
|
|
14
14
|
type ServiceType = {
|
|
15
15
|
list: Function;
|
|
16
|
+
search: Function;
|
|
16
17
|
create: Function;
|
|
17
18
|
update: Function;
|
|
18
19
|
delete: Function;
|
|
@@ -34,10 +35,12 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema, T> {
|
|
|
34
35
|
this.service = service;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
38
|
async _list() {
|
|
39
39
|
return this.service.list();
|
|
40
40
|
}
|
|
41
|
+
async _search(searchObject:Object) {
|
|
42
|
+
return this.service.search(searchObject);
|
|
43
|
+
}
|
|
41
44
|
async _autocomplete(keyword: string) {
|
|
42
45
|
return this.service.getAutoComplete(keyword);
|
|
43
46
|
}
|
|
@@ -47,7 +50,6 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema, T> {
|
|
|
47
50
|
return result as Type<TApiSchema>;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
|
|
51
53
|
async _create(data: TApiSchema) {
|
|
52
54
|
//const newdata: persontype.Person = { ...data };
|
|
53
55
|
const newdata: T = {} as T; //= { ...data };
|
|
@@ -55,14 +57,12 @@ export class SimpleAppController<TService extends ServiceType, TApiSchema, T> {
|
|
|
55
57
|
return this.service.setData(newdata).create() as TApiSchema;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
async _update( id: string,data: TApiSchema) {
|
|
60
|
+
async _update(id: string, data: TApiSchema) {
|
|
60
61
|
const newdata: T = {} as T; //= { ...data };
|
|
61
62
|
Object.assign(newdata, data); //
|
|
62
63
|
return this.service.findIdThenUpdate(id, newdata) as TApiSchema;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
66
|
async _delete(id: string) {
|
|
67
67
|
return this.service.findIdThenDelete(id);
|
|
68
68
|
}
|