@simitgroup/simpleapp-generator 1.0.47 → 1.0.49
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 +44 -4
- package/buildinschemas copy/docnoformat.docno.jsonschema.json +2 -20
- package/dist/buildinschemas/autoincreament.js +1 -1
- package/dist/buildinschemas/autoincreament.js.map +1 -1
- package/dist/buildinschemas/branch.js +1 -1
- package/dist/buildinschemas/branch.js.map +1 -1
- package/dist/buildinschemas/docnoformat.d.ts.map +1 -1
- package/dist/buildinschemas/docnoformat.js +12 -25
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/user.d.ts.map +1 -1
- package/dist/buildinschemas/user.js +1 -0
- package/dist/buildinschemas/user.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +10 -2
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +24 -13
- package/dist/generate.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/type.d.ts +1 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/autoincreament.ts +1 -1
- package/src/buildinschemas/branch.ts +1 -1
- package/src/buildinschemas/docnoformat.ts +13 -27
- package/src/buildinschemas/user.ts +1 -0
- package/src/framework.ts +10 -2
- package/src/generate.ts +26 -13
- package/src/index.ts +1 -1
- package/src/type.ts +1 -0
- package/templates/basic/nest/processor.ts.eta +2 -2
- package/templates/basic/nest/service.ts.eta +2 -4
- package/templates/basic/nuxt/pages.crud.vue.eta +2 -2
- package/templates/nest/src/app.controller.ts.eta +6 -0
- package/templates/nest/src/app.module.ts.eta +9 -1
- package/templates/nest/src/app.service.ts.eta +6 -0
- package/templates/nest/src/main.ts.eta +7 -0
- package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +6 -2
- package/templates/nest/src/simpleapp/generate/commons/audittrail.service.ts.eta +17 -0
- package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/documents.ts.eta +14 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +9 -3
- package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +23 -3
- package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +52 -10
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/providers/workflow.provider.ts.etax +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -1
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +6 -1
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +15 -7
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/models/apievent.model.ts.eta +27 -0
- package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +3 -4
- package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +3 -5
- package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +3 -4
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +42 -11
- package/templates/nest/src/simpleapp/generate/types/apievent.type.ts.eta +22 -0
- package/templates/nest/src/simpleapp/generate/types/index.ts.eta +6 -0
- package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +6 -0
- package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +6 -0
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +6 -0
- package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +6 -0
- package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +5 -6
- package/templates/nest/src/simpleapp/services/branch.service.ts.eta +50 -10
- package/templates/nest/src/simpleapp/services/docno.service.ts.eta +5 -7
- package/templates/nest/src/simpleapp/services/org.service.ts.eta +4 -6
- package/templates/nest/src/simpleapp/services/perm.service.ts.eta +6 -7
- package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +5 -6
- package/templates/nest/src/simpleapp/services/user.service.ts.eta +5 -6
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +6 -8
- package/templates/nuxt/app.vue.eta +6 -1
- package/templates/nuxt/assets/css/style.css._eta +12 -0
- package/templates/nuxt/assets/css/tailwind.css._eta +10 -0
- package/templates/nuxt/assets/primevue/passthrough.ts._eta +37 -0
- package/templates/nuxt/components/ButtonCreateTenant.vue.eta +68 -0
- package/templates/nuxt/components/ButtonHome.vue.eta +10 -0
- package/templates/nuxt/components/ButtonLogout.vue.eta +9 -0
- package/templates/nuxt/components/ButtonMenuPicker.vue.eta +55 -0
- package/templates/nuxt/components/ButtonPermissionInfo.vue.eta +113 -0
- package/templates/nuxt/components/ButtonProfile.vue.eta +52 -0
- package/templates/nuxt/components/CrudNestedDoc.vue.eta +11 -7
- package/templates/nuxt/components/CrudSimple.vue.eta +13 -11
- package/templates/nuxt/components/DebugDocumentData.vue.eta +1 -1
- package/templates/nuxt/components/HeaderBar.vue.eta +39 -0
- package/templates/nuxt/components/Invitation.vue.eta +2 -2
- package/templates/nuxt/components/Menus.vue.eta +7 -7
- package/templates/nuxt/components/SelectBranch.vue.eta +35 -0
- package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +1 -1
- package/templates/nuxt/components/SimpleAppDatatable.vue.eta +0 -1
- package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +1 -1
- package/templates/nuxt/components/SimpleAppForm.vue.eta +1 -1
- package/templates/nuxt/components/SimpleAppInputTable.vue.eta +2 -2
- package/templates/nuxt/components/SimpleFieldContainer.vue.eta +18 -12
- package/templates/nuxt/components/Spinner.vue.eta +9 -0
- package/templates/nuxt/composables/getMenus.generate.ts.eta +5 -4
- package/templates/nuxt/layouts/default.vue.eta +3 -12
- package/templates/nuxt/middleware/{10.acl.global.ts.eta → 30.acl.global.ts.eta} +6 -0
- package/templates/nuxt/nuxt.config.ts.eta +55 -12
- package/templates/nuxt/pages/[xorg]/branch/{index.vue.eta → index.vue.etax} +1 -4
- package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +83 -113
- package/templates/nuxt/pages/[xorg]/index.vue._eta +13 -0
- package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +89 -69
- package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +7 -7
- package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +0 -4
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +33 -33
- package/templates/nuxt/pages/index.vue.eta +10 -85
- package/templates/nuxt/pages/login.vue.eta +9 -3
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +16 -19
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +19 -3
- package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +4 -4
- package/templates/nuxt/server/api/[xorg]/[...].ts.eta +4 -4
- package/templates/nuxt/server/api/auth/[...].ts.eta +6 -0
- package/templates/nuxt/server/api/auth/logout.ts.eta +6 -1
- package/templates/nuxt/server/api/profile/[...].ts.eta +4 -5
- package/templates/nuxt/server/api/profile/index.ts.eta +4 -6
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +9 -2
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +12 -3
- package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +6 -0
- package/templates/nuxt/tailwind.config.ts._eta +66 -0
- package/templates/nuxt/types/index.ts.eta +22 -1
- package/templates/project/build.sh.eta +4 -4
- package/templates/project/schemas/invoice.ts.eta +1 -0
- package/templates/project/schemas/product.ts.eta +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/templates/nuxt/assets/css/tailwind.css.eta +0 -35
- package/templates/nuxt/components/PermissionInfo.vue.eta +0 -92
- package/templates/nuxt/components/XorgPicker.vue.eta +0 -66
- package/templates/nuxt/pages/[xorg]/index.vue.eta +0 -36
- package/templates/nuxt/tailwind.config.ts.eta +0 -9
- /package/templates/nest/{.env.eta → .env._eta} +0 -0
- /package/templates/nuxt/{.env.eta → .env._eta} +0 -0
- /package/templates/project/{config.json.eta → config.json._eta} +0 -0
|
@@ -18,8 +18,7 @@ export const docnoformat:SchemaType ={
|
|
|
18
18
|
"execute":"listDocFormats",
|
|
19
19
|
"description":"get list of document format for 1 doctype"
|
|
20
20
|
} ]
|
|
21
|
-
},
|
|
22
|
-
|
|
21
|
+
},
|
|
23
22
|
properties: {
|
|
24
23
|
_id:{type:'string'},
|
|
25
24
|
created:{type:'string'},
|
|
@@ -29,30 +28,17 @@ export const docnoformat:SchemaType ={
|
|
|
29
28
|
tenantId: {type:'integer',default:1,minimum:1 },
|
|
30
29
|
orgId: {type:'integer',default:1,minimum:1 },
|
|
31
30
|
branchId: {type:'integer',default:1,minimum:1 },
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"feb": {"type": "integer","default":1},
|
|
45
|
-
"mar": {"type": "integer","default":1},
|
|
46
|
-
"apr": {"type": "integer","default":1},
|
|
47
|
-
"may": {"type": "integer","default":1},
|
|
48
|
-
"jun": {"type": "integer","default":1},
|
|
49
|
-
"jul": {"type": "integer","default":1},
|
|
50
|
-
"aug": {"type": "integer","default":1},
|
|
51
|
-
"sep": {"type": "integer","default":1},
|
|
52
|
-
"oct": {"type": "integer","default":1},
|
|
53
|
-
"nov": {"type": "integer","default":1},
|
|
54
|
-
"dec": {"type": "integer","default":1}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
31
|
+
branch:{type:"object", "x-foreignkey":"branch",properties:{
|
|
32
|
+
"_id":{"type":"string"},
|
|
33
|
+
"label":{"type":"string"},
|
|
34
|
+
"branchId":{type:"integer"},
|
|
35
|
+
}},
|
|
36
|
+
docNoFormatNo: {"type": "string","examples": ["INV"]},
|
|
37
|
+
docNoFormatName: { "type": "string", "examples": ["Invoice Default Format"]},
|
|
38
|
+
active: {type: "boolean","examples": [true],default:true},
|
|
39
|
+
default:{type: "boolean","examples": [true],default:true},
|
|
40
|
+
docNoType: {type: "string","examples": ["SI","PI"]},
|
|
41
|
+
docNoPattern: {type: "string","examples": ["SI{YYMM}-<000>","PI-2023-<0000>"],"description":"{date} format as ISO8601 symbol"},
|
|
42
|
+
nextNumber:{type:"integer",default:1}
|
|
57
43
|
}
|
|
58
44
|
}
|
package/src/framework.ts
CHANGED
|
@@ -126,6 +126,14 @@ export const prepareProject = async (callback)=>{
|
|
|
126
126
|
// log.info(fullfilename+"====>>"+tofilename)
|
|
127
127
|
// console.log(txt)
|
|
128
128
|
writeFileSync(tofilename,txt)
|
|
129
|
+
}else if(filename.includes('._eta')){
|
|
130
|
+
const tofilename =targetfolder + filename.replace('._eta','')
|
|
131
|
+
log.info(tofilename,"Render file")
|
|
132
|
+
const txt = eta.render(fullfilename,vars)
|
|
133
|
+
if(!existsSync(tofilename)){
|
|
134
|
+
writeFileSync(tofilename,txt)
|
|
135
|
+
}
|
|
136
|
+
|
|
129
137
|
}else if(filename.includes('.md')){
|
|
130
138
|
const tofilename =dir + filename.replace('.eta','')
|
|
131
139
|
log.info(tofilename,"Copy")
|
|
@@ -149,10 +157,10 @@ export const prepareNuxt = (callback:Function)=>{
|
|
|
149
157
|
const targetfolder = config.frontendFolder
|
|
150
158
|
if(!fs.existsSync(`${targetfolder}/.env`)){
|
|
151
159
|
//asume no environment. prepare now
|
|
152
|
-
exec(`cd ${targetfolder};pnpm install;pnpm install -D @nuxtjs/tailwindcss @sidebase/nuxt-auth @nuxt/ui @types/node @vueuse/nuxt @sidebase/nuxt-auth @vueuse/core
|
|
160
|
+
exec(`cd ${targetfolder};pnpm install;pnpm install -D nuxt-primevue @nuxtjs/tailwindcss @sidebase/nuxt-auth @nuxt/ui @types/node @vueuse/nuxt @sidebase/nuxt-auth @vueuse/core prettier `, (error, stdout, stderr)=>{
|
|
153
161
|
//;pnpm install
|
|
154
162
|
console.log(error, stdout, stderr)
|
|
155
|
-
exec(`cd ${targetfolder};pnpm install --save jsonpath pinia @pinia/nuxt @nuxt/kit lodash @types/lodash @darkwolf/base64url next-auth@4.21.1 @darkwolf/base64url @nuxt/ui ajv ajv-formats ajv-errors dotenv @fullcalendar/core @fullcalendar/vue3 quill
|
|
163
|
+
exec(`cd ${targetfolder};pnpm install --save primeicons moment memory-cache jsonpath pinia @pinia/nuxt @nuxt/kit lodash @types/lodash @darkwolf/base64url next-auth@4.21.1 @darkwolf/base64url @nuxt/ui ajv ajv-formats ajv-errors dotenv @fullcalendar/core @fullcalendar/vue3 quill prettier axios json-schema mitt `, (error, stdout, stderr)=>{
|
|
156
164
|
console.log(error, stdout, stderr)
|
|
157
165
|
|
|
158
166
|
// fs.mkdirSync(`${targetfolder}/assets/css/`,{recursive:true})
|
package/src/generate.ts
CHANGED
|
@@ -92,15 +92,15 @@ export const run = async (paraconfigs:any,genFor:string[],callback:Function) =>
|
|
|
92
92
|
await processSchema(file.replace('.json',''),jsonschema)
|
|
93
93
|
}
|
|
94
94
|
// //generate groups
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
const systemgroups = readdirSync(`${groupFolder}`)
|
|
96
|
+
for(let g = 0; g< systemgroups.length;g++){
|
|
97
|
+
const groupfile = systemgroups[g]
|
|
98
|
+
const groupjsonstr = readFileSync(`${groupFolder}/${groupfile}`, 'utf-8');
|
|
99
|
+
const groupdata = JSON.parse(groupjsonstr);
|
|
100
|
+
const documentname = groupfile.split('.')[0]
|
|
101
|
+
const roles = prepareRoles(groupdata)
|
|
102
|
+
allroles[documentname]=roles
|
|
103
|
+
}
|
|
104
104
|
finalize(activatemodules)
|
|
105
105
|
callback()
|
|
106
106
|
}
|
|
@@ -128,6 +128,7 @@ const processSchema= async (schemaname:string,jsondata:JSONSchema7)=>{
|
|
|
128
128
|
// const jsondata = JSON.parse(jsonstring);
|
|
129
129
|
const rendertype = 'basic';
|
|
130
130
|
jsonschemas[docname] = jsondata;
|
|
131
|
+
const copyofjsonschema = {...jsondata}
|
|
131
132
|
const allmodels:ChildModels = await readJsonSchemaBuilder(docname, jsondata);
|
|
132
133
|
// log.error("allmodels",docname,schemaname)
|
|
133
134
|
generateSchema(docname, doctype, rendertype, allmodels);
|
|
@@ -135,7 +136,8 @@ const processSchema= async (schemaname:string,jsondata:JSONSchema7)=>{
|
|
|
135
136
|
doctype:doctype,
|
|
136
137
|
docname:capitalizeFirstLetter(docname),
|
|
137
138
|
pagetype: config.pageType??'',
|
|
138
|
-
api:config.additionalApis
|
|
139
|
+
api:config.additionalApis,
|
|
140
|
+
schema : copyofjsonschema
|
|
139
141
|
})
|
|
140
142
|
// } else {
|
|
141
143
|
// log.warn(`Load `+clc.yellow(file) + ` but it is not supported`)
|
|
@@ -339,15 +341,26 @@ const finalize=(modules:ModuleObject[])=>{
|
|
|
339
341
|
const arrfilename:string[] = filename.split('.')
|
|
340
342
|
// log.info("check longfilename:::",longfilename,"become====",arrfilename)
|
|
341
343
|
//only process .eta
|
|
342
|
-
if(_.last(arrfilename)=='eta'){
|
|
344
|
+
if(_.last(arrfilename)=='eta'|| _.last(arrfilename)=='_eta'){
|
|
343
345
|
const relativepath = longfilename.includes('/') ? longfilename.replace(`/${filename}`,'') : ''
|
|
344
346
|
const foldername = `${frameworkpath}/${relativepath}`
|
|
345
|
-
const shortfilename = filename.replace('.eta','')
|
|
347
|
+
const shortfilename = filename.replace('.eta','').replace('._eta','')
|
|
346
348
|
const targetfilename = `${foldername}/${shortfilename}`
|
|
349
|
+
let forceoverride=true
|
|
350
|
+
if(filename.includes('._eta')){
|
|
351
|
+
forceoverride=false
|
|
352
|
+
}
|
|
353
|
+
// log.warn("Process=== ",targetfilename)
|
|
354
|
+
if(existsSync(targetfilename) && forceoverride == false){
|
|
355
|
+
log.info("file exists, skip: ",targetfilename)
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
347
360
|
if(!existsSync(foldername)){
|
|
348
361
|
mkdirSync(foldername,{recursive:true})
|
|
349
362
|
}
|
|
350
|
-
const templatename = `${frameworkfolder}/${longfilename}`.replace(".eta","")
|
|
363
|
+
// const templatename = `${frameworkfolder}/${longfilename}`.replace(".eta","").replace('._eta','')
|
|
351
364
|
log.info("Write template:",targetfilename)
|
|
352
365
|
const txt = eta.render(longfilename, renderProperties)
|
|
353
366
|
writeFileSync(targetfilename,txt)
|
package/src/index.ts
CHANGED
package/src/type.ts
CHANGED
|
@@ -33,8 +33,8 @@ export class <%= it.typename %>Processor extends SimpleAppService<<%= it.typenam
|
|
|
33
33
|
|
|
34
34
|
protected foreignkeys = <%~ JSON.stringify(it.foreignkeys)%>
|
|
35
35
|
|
|
36
|
-
constructor(mydoc: Model<<%= it.typename
|
|
37
|
-
super('<%= it.doctype.toUpperCase() %>','<%= it.name %>',mydoc,IsolationType.<%=it.isolationtype
|
|
36
|
+
constructor(mydoc: Model<<%= it.typename %>>) {
|
|
37
|
+
super('<%= it.doctype.toUpperCase() %>','<%= it.name %>',mydoc,IsolationType.<%=it.isolationtype%>);
|
|
38
38
|
this.setSchema(<%= it.typename%>JsonSchema)
|
|
39
39
|
this.setData(Default<%=it.typename%>(crypto.randomUUID()))
|
|
40
40
|
<%if(it.moreAutoComplete.length>0){%>
|
|
@@ -8,7 +8,6 @@ import { InjectModel } from '@nestjs/mongoose';
|
|
|
8
8
|
import { Model } from 'mongoose';
|
|
9
9
|
import { Injectable } from '@nestjs/common';
|
|
10
10
|
import { UserContext } from '../generate/commons/user.context';
|
|
11
|
-
import {DocNumberFormatGenerator} from '../generate/commons/docnogenerator.service'
|
|
12
11
|
import { <%= it.typename %>Processor } from '../generate/processors/<%= it.doctype %>.processor';
|
|
13
12
|
import { <%= it.typename %>} from '../generate/types/<%= it.doctype %>.type';
|
|
14
13
|
export { <%= it.typename %>} from '../generate/types/<%= it.doctype %>.type';
|
|
@@ -18,10 +17,9 @@ export { <%= it.typename %>} from '../generate/types/<%= it.doctype %>.type';
|
|
|
18
17
|
export class <%= it.typename %>Service extends <%= it.typename %>Processor {
|
|
19
18
|
|
|
20
19
|
constructor(
|
|
21
|
-
@InjectModel('<%= it.typename %>') mydoc: Model<<%= it.typename
|
|
22
|
-
docnogenerator:DocNumberFormatGenerator
|
|
20
|
+
@InjectModel('<%= it.typename %>') mydoc: Model<<%= it.typename %>>
|
|
23
21
|
){
|
|
24
|
-
super(mydoc
|
|
22
|
+
super(mydoc)
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
// hook = async (appuser:UserContext,type: string, data?: any) => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* author: Ks Tan
|
|
8
8
|
*/
|
|
9
9
|
<% let skipcolumns = ['_id','createdby','created','updatedby','updated','orgId','branchId','tenantId','doctype'] %>
|
|
10
|
-
import {InputTableColumnType,InputTableColumn} from "
|
|
10
|
+
import {InputTableColumnType,InputTableColumn} from "~/components/type";
|
|
11
11
|
import Column from "primevue/column";
|
|
12
12
|
const {$<%= it.typename %>Doc } = useNuxtApp();
|
|
13
13
|
const doc = $<%= it.typename %>Doc()
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
</column>
|
|
171
171
|
<%}%>
|
|
172
172
|
<column #body="{index}" header="Delete">
|
|
173
|
-
<
|
|
173
|
+
<Button class="btn-danger" type="button" @click="data.<%=key%>.splice(index,1)">X</Button>
|
|
174
174
|
</column>
|
|
175
175
|
</SimpleAppInputTable>
|
|
176
176
|
<% } else{%>
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { Controller, Get,Logger } from '@nestjs/common';
|
|
2
8
|
import { AppService } from './app.service';
|
|
3
9
|
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { Module, MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
9
|
import { MongooseModule,MongooseModuleOptions } from '@nestjs/mongoose';
|
|
3
10
|
import { APP_GUARD,APP_INTERCEPTOR,APP_FILTER } from '@nestjs/core';
|
|
@@ -20,7 +27,7 @@ import { AppService } from './app.service';
|
|
|
20
27
|
import {GenerateModule} from './simpleapp/simpleapp.module'
|
|
21
28
|
import { UserMongoSchema } from './simpleapp/generate/models/user.model';
|
|
22
29
|
import { PermissionMongoSchema } from './simpleapp/generate/models/perm.model';
|
|
23
|
-
|
|
30
|
+
import { ApiEventMongoSchema } from './simpleapp/generate/models/apievent.model';
|
|
24
31
|
@Module({
|
|
25
32
|
//define environment variables: MONGODB_URL='mongodb://<user>:<pass>@<host>:<port>/<db>?authMechanism=DEFAULT'
|
|
26
33
|
imports: [
|
|
@@ -42,6 +49,7 @@ import { PermissionMongoSchema } from './simpleapp/generate/models/perm.model';
|
|
|
42
49
|
MongooseModule.forFeature([
|
|
43
50
|
{ name: 'User', schema: UserMongoSchema },
|
|
44
51
|
{ name: 'Permission', schema: PermissionMongoSchema },
|
|
52
|
+
{ name: 'ApiEvent', schema: ApiEventMongoSchema },
|
|
45
53
|
])
|
|
46
54
|
],
|
|
47
55
|
controllers: [AppController],
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { Injectable } from '@nestjs/common';
|
|
2
8
|
// import { Workflow } from './simpleapp/generate/commons/providers/Workflow';
|
|
3
9
|
@Injectable()
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { NestFactory } from '@nestjs/core';
|
|
2
9
|
import { AppModule } from './app.module';
|
|
3
10
|
import { SimpleAppExceptionFilter } from './simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
|
|
2
8
|
import { ApiProperty } from '@nestjs/swagger';
|
|
3
|
-
|
|
4
|
-
|
|
5
9
|
export class ApiKeyValuePair {
|
|
6
10
|
@ApiProperty({"type":Object,"required":false,"examples":['{"field1":"1"}'],"default":""} )
|
|
7
11
|
field1: any
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { Injectable } from "@nestjs/common";
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class AuditTrail {
|
|
11
|
+
constructor(){
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addEvent(data:any){
|
|
15
|
+
console.log("Add event into db:",data)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
|
2
8
|
|
|
3
9
|
export const AppUser = createParamDecorator(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
export const alldocuments:any[] = [
|
|
8
|
+
<%for(let i=0; i<it.modules.length;i++){ %>
|
|
9
|
+
<% const d = it.modules[i] %>
|
|
10
|
+
<% const conf = d.schema["x-simpleapp-config"] %>
|
|
11
|
+
{docName:'<%= d['docname'] %>',docType:'<%= d['doctype'].toUpperCase()%>',page: '<%=d['pagetype']%>', isolationType:'<%=conf['isolationType']%>',
|
|
12
|
+
documentDate:'<%=conf['documentDate']??""%>', docNumber:<%=conf['generateDocumentNumber']??false%>},
|
|
13
|
+
<%}%>
|
|
14
|
+
]
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { UserContext } from './user.context';
|
|
2
8
|
import { InjectModel } from '@nestjs/mongoose';
|
|
3
9
|
import { Model } from 'mongoose';
|
|
@@ -61,7 +67,7 @@ export class DocNumberFormatGenerator{
|
|
|
61
67
|
static previewDocNo = (s: Docnoformat) => {
|
|
62
68
|
try {
|
|
63
69
|
const pattern = s.docNoPattern;
|
|
64
|
-
const numberReg: RegExp =
|
|
70
|
+
const numberReg: RegExp = /\[(.*?)\]/g;
|
|
65
71
|
const dateReg: RegExp = /\{(.*?)\}/g;
|
|
66
72
|
let newvalue = pattern;
|
|
67
73
|
const numberpattern: string[] = pattern.match(numberReg);
|
|
@@ -69,8 +75,8 @@ export class DocNumberFormatGenerator{
|
|
|
69
75
|
|
|
70
76
|
if (numberpattern && numberpattern.length > 0) {
|
|
71
77
|
const numberlength = numberpattern[0]
|
|
72
|
-
.replace('
|
|
73
|
-
.replace('
|
|
78
|
+
.replace('[', '')
|
|
79
|
+
.replace(']', '').length;
|
|
74
80
|
|
|
75
81
|
let nextnumber = s.nextNumber.toString();
|
|
76
82
|
|
package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import {
|
|
2
8
|
ExceptionFilter,
|
|
3
9
|
Catch,
|
|
@@ -9,7 +15,8 @@ import { HttpAdapterHost } from '@nestjs/core';
|
|
|
9
15
|
import { ClientSession } from 'mongoose';
|
|
10
16
|
@Catch()
|
|
11
17
|
export class SimpleAppExceptionFilter implements ExceptionFilter {
|
|
12
|
-
constructor(
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly httpAdapterHost: HttpAdapterHost) {}
|
|
13
20
|
|
|
14
21
|
catch(exception, host: ArgumentsHost): void {
|
|
15
22
|
// In certain situations `httpAdapter` might not be available in the
|
|
@@ -17,6 +24,7 @@ export class SimpleAppExceptionFilter implements ExceptionFilter {
|
|
|
17
24
|
const { httpAdapter } = this.httpAdapterHost;
|
|
18
25
|
const ctx = host.switchToHttp();
|
|
19
26
|
const request = ctx.getRequest<Request>();
|
|
27
|
+
|
|
20
28
|
if(request['sessionuser']){
|
|
21
29
|
const session:ClientSession = request['sessionuser'].getDBSession()
|
|
22
30
|
if(session.inTransaction())session.abortTransaction()
|
|
@@ -32,8 +40,20 @@ export class SimpleAppExceptionFilter implements ExceptionFilter {
|
|
|
32
40
|
// console.log("exception properties", Object.getOwnPropertyNames(exception),exception.options)
|
|
33
41
|
|
|
34
42
|
// console.log("exception.responseexception.response",exception)
|
|
35
|
-
|
|
43
|
+
const finalstatus = exception.response.status??exception.status
|
|
44
|
+
const eventObj = request['eventObj']
|
|
45
|
+
if(eventObj){
|
|
46
|
+
eventObj.statusCode=finalstatus
|
|
47
|
+
eventObj.errMsg=responseBody.message
|
|
48
|
+
const endtime =new Date()
|
|
49
|
+
eventObj.updated = endtime.toISOString()
|
|
50
|
+
eventObj.data = request.body
|
|
51
|
+
eventObj.errData = responseBody.error
|
|
52
|
+
eventObj.status="NG"
|
|
53
|
+
eventObj.duration = endtime.getTime() - new Date(eventObj.created).getTime()
|
|
54
|
+
eventObj.save()
|
|
55
|
+
}
|
|
36
56
|
|
|
37
|
-
httpAdapter.reply(ctx.getResponse(), responseBody,
|
|
57
|
+
httpAdapter.reply(ctx.getResponse(), responseBody,finalstatus);
|
|
38
58
|
}
|
|
39
59
|
}
|
package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta
CHANGED
|
@@ -1,30 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
2
7
|
import { Injectable, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
3
8
|
import { Observable } from 'rxjs';
|
|
4
9
|
import { tap } from 'rxjs/operators';
|
|
5
10
|
import { Model,Connection, ClientSession } from 'mongoose';
|
|
6
|
-
import { InjectConnection } from '@nestjs/mongoose';
|
|
11
|
+
import { InjectConnection,InjectModel } from '@nestjs/mongoose';
|
|
7
12
|
import { UserContext } from '../user.context';
|
|
13
|
+
import { ApiEvent } from '../../types/apievent.type';
|
|
8
14
|
@Injectable()
|
|
9
15
|
export class ResponseInterceptor implements NestInterceptor {
|
|
10
16
|
|
|
11
|
-
constructor(
|
|
17
|
+
constructor(
|
|
18
|
+
@InjectConnection() private readonly connection: Connection,
|
|
19
|
+
@InjectModel('ApiEvent') private apieventmodel: Model<ApiEvent>,
|
|
20
|
+
){
|
|
12
21
|
|
|
13
22
|
|
|
14
23
|
}
|
|
15
|
-
intercept(context: ExecutionContext, next: CallHandler): Observable<any
|
|
16
|
-
const req = context.switchToHttp().getRequest()
|
|
17
|
-
|
|
24
|
+
async intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>> {
|
|
25
|
+
const req = context.switchToHttp().getRequest()
|
|
26
|
+
const resp = context.switchToHttp().getResponse()
|
|
18
27
|
const usersession:UserContext = req['sessionuser']
|
|
28
|
+
const method = req['method']
|
|
29
|
+
const headers = {...req['headers']}
|
|
30
|
+
const ip = req['ip']
|
|
31
|
+
const url = req['url']
|
|
32
|
+
// let { url, method, headers, body }
|
|
19
33
|
const session:ClientSession = usersession.getDBSession()
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
const logid:string = crypto.randomUUID()
|
|
35
|
+
const starttime =new Date()
|
|
36
|
+
|
|
37
|
+
//authorization no need
|
|
38
|
+
delete headers['authorization']//='--removed--'
|
|
39
|
+
const data:ApiEvent = {
|
|
40
|
+
_id: logid,
|
|
41
|
+
created: starttime.toISOString(),
|
|
42
|
+
duration : 0,
|
|
43
|
+
createdby: usersession.getUid(),
|
|
44
|
+
path: url,
|
|
45
|
+
method: method,
|
|
46
|
+
headers: headers,
|
|
47
|
+
ip:ip,
|
|
48
|
+
// data: req.body,
|
|
49
|
+
statusCode:0,
|
|
50
|
+
status:'D'
|
|
51
|
+
}
|
|
52
|
+
const eventmodel = new this.apieventmodel(data)
|
|
53
|
+
|
|
54
|
+
const eventObj = await eventmodel.save()
|
|
22
55
|
|
|
23
|
-
|
|
56
|
+
req['eventObj']=eventObj
|
|
24
57
|
return next
|
|
25
58
|
.handle()
|
|
26
59
|
.pipe(
|
|
27
|
-
tap(() => {
|
|
60
|
+
tap(async () => {
|
|
61
|
+
|
|
62
|
+
const endtime =new Date()
|
|
63
|
+
eventObj.isNew=false
|
|
64
|
+
eventObj.statusCode=resp['statusCode']
|
|
65
|
+
eventObj.updated = endtime.toISOString()
|
|
66
|
+
eventObj.status="OK"
|
|
67
|
+
eventObj.duration = endtime.getTime() - starttime.getTime()
|
|
68
|
+
const result = await eventObj.save()//({_id:logid},{statusCode:resp['statusCode']})
|
|
69
|
+
// console.log("result===",logid,result)
|
|
28
70
|
|
|
29
71
|
if(process.env.DRYRUN=='true'){
|
|
30
72
|
console.warn("--------dryrun! roll back everything-----------")
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { Injectable, NestMiddleware, Logger,Scope,Inject } from '@nestjs/common';
|
|
2
8
|
import { Request, Response, NextFunction } from 'express';
|
|
3
9
|
import { InjectModel } from '@nestjs/mongoose';
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import { BPMNClient } from "bpmn-client";
|
|
2
8
|
import { UserContext } from './user.context';
|
|
3
9
|
import { Injectable,Scope } from '@nestjs/common';
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
1
7
|
import {Role} from './roles.enum'
|
|
2
8
|
|
|
3
9
|
<% Object.getOwnPropertyNames(it.allroles).forEach((key)=>{ %>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2023-10-28
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
2
7
|
import { Injectable, Inject, CanActivate, ExecutionContext, Scope } from '@nestjs/common';
|
|
3
8
|
import { Reflector } from '@nestjs/core';
|
|
4
9
|
import { Role } from './roles.enum'
|