Skip to content

Commit 34740ce

Browse files
committed
v1.6.1
1. create tenant no need ask country, currency, timezeone, offsets, it autocapture from timezone 2. component select support multiple, simpleapp allow multi-select too 3. improve symbol of formula in jsconschema 4. support manage module in config 5. support runWorker concept, which allow execute code outside of service classes 6. provide data id at before validation hook 7.simpleapp support jrxml to pdf print preview 8. solve formula sometimes can't execute
1 parent a677cd7 commit 34740ce

32 files changed

Lines changed: 309 additions & 141 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@simitgroup/simpleapp-generator",
3-
"version": "1.6.0-alpha",
3+
"version": "1.6.1-alpha",
44
"description": "frontend nuxtjs and backend nests code generator using jsonschema",
55
"main": "dist/index.js",
66
"scripts": {

src/framework.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let config = {
1818
"frontendFolder":"./frontend",
1919
"frontendPort":"8080",
2020
"printFormatDir":"./printformats",
21+
"additionalNestModules":["cloudapi","printapi"],
2122
"oauthSetting":{
2223
"oauthBaseUrl":"https://keycloak-server-url/",
2324
"oauthRealm":"realm-name",
@@ -74,7 +75,7 @@ export const prepareNest = (callback:Function)=>{
7475

7576
//@nestjs/graphql @nestjs/apollo graphql apollo-server-express apollo-server-core
7677
//@nestjs/graphql graphql-tools graphql apollo-server-express
77-
exec(`cd ${targetfolder};pnpm install --save @nestjs/graphql @nestjs/apollo @apollo/server graphql @nestjs/event-emitter dayjs bpmn-server@2.1.7 @casl/ability jsonpath yaml lodash @types/lodash nest-keycloak-connect keycloak-connect bpmn-client @nestjs/serve-static jsonwebtoken axios @darkwolf/base64url json-schema @wearenova/mongoose-tenant @nestjs/swagger @nestjs/mongoose mongoose ajv ajv-formats ajv-errors @nestjs/config`,async (error, stdout, stderr)=>{
78+
exec(`cd ${targetfolder};pnpm install --save @nestjs/graphql country-to-currency countries-and-timezones @nestjs/apollo @apollo/server graphql @nestjs/event-emitter dayjs bpmn-server@2.1.7 @casl/ability jsonpath yaml lodash @types/lodash nest-keycloak-connect keycloak-connect bpmn-client @nestjs/serve-static jsonwebtoken axios @darkwolf/base64url json-schema @wearenova/mongoose-tenant @nestjs/swagger @nestjs/mongoose mongoose ajv ajv-formats ajv-errors @nestjs/config`,async (error, stdout, stderr)=>{
7879
// log.info(`dependency installed`)
7980
if(!error){
8081
// fs.mkdirSync(`${targetfolder}/public_html`,{recursive:true})

templates/basic/nest/processor.ts.eta

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ export class <%= it.typename %>Processor extends SimpleAppService<<%= it.typenam
6464

6565
reCalculateValue(data:<%= it.typename %>){
6666
//console.log('trigger new recalculate')
67+
const $data = data;
6768
const jsopbj= new jsonpath['JSONPath']()
6869
<% if(it.jsonschema['x-simpleapp-config']['formulas']){ %>
6970
<%Object.keys(it.jsonschema['x-simpleapp-config']['formulas']).forEach(function(index) { %>
7071
<% let fml = it.jsonschema['x-simpleapp-config']['formulas'][index] %>
7172
// <%~ JSON.stringify(fml) %>
7273
//const tmp = jsopbj.query(vdata,fieldpath).filter((item:string)=>item!='')
7374

74-
jsopbj.apply(data, '<%~ fml.jsonPath %>', function(value:any) { return <%~fml.formula %> });
75+
jsopbj.apply($data, '<%~ fml.jsonPath %>', function($item:any) { return <%~fml.formula %> });
7576

7677
<%}) %>
7778
<%} %>

templates/basic/nuxt/component.select.vue.eta

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
:showNull="showNull"
88
:allowAddNew="allowAddNew"
99
:filter ="filter"
10+
:multiple="multiple"
11+
:hideLabel="hideLabel"
1012
/>
1113
</template>
1214
<script setup lang="ts">
@@ -19,12 +21,14 @@
1921
import { ForeignKey } from '~/types';
2022
import { <%= it.typename %> } from "~/simpleapp/generate/openapi";
2123
const emits = defineEmits(["change"]);
22-
const modelValue = defineModel<string>();
24+
const modelValue = defineModel<string|string[]>();
2325
const props = defineProps<{
2426
placeholder?: string;
2527
showNull?:boolean;
2628
allowAddNew?: boolean;
2729
filter?: <%= it.typename %>;
30+
multiple?:boolean;
31+
hideLabel?:boolean;
2832
}>()
2933
const change = (id:string,data:ForeignKey) =>{
3034
emits('change',id,data)

templates/basic/nuxt/simpleapp.generate.client.ts.eta

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,23 @@ export class <%= it.typename%>Client extends SimpleAppClient<openapi.<%= it.type
5353
const apiobj = getDocumentApi('<%=it.name %>')
5454
super(apiobj,'<%= it.doctype %>','<%=it.name %>')
5555
this.event=$event
56-
this.listen=$listen
57-
58-
this.setNew();
59-
watch(this.getData(),(newvalue)=>{
60-
//console.log("Something change",this.completeformula)
56+
this.listen=$listen
57+
this.setNew();
58+
}
59+
60+
setWatchChange = ()=>{
61+
this.unwantchobj = watch(this.getData(),(newvalue)=>{
6162
if(this.completeformula==true){
62-
// console.log("Trigger caclculate")
6363
this.completeformula=false
6464
this.reCalculateValue()
6565
this.completeformula=true
66-
}else{
67-
//console.log("avoid unlimited loop")
68-
}
69-
})
70-
66+
}
67+
},{deep:true})
7168
}
7269
setNew = ()=>{
7370
const newdata = Default<%= it.typename%>(randomUUID())
7471
this.setData(newdata)
72+
this.setWatchChange()
7573
return true
7674
}
7775
<%if(it.jsonschema.properties['readOnly'] || it.jsonschema.properties['documentStatus']){%>
@@ -176,15 +174,15 @@ export class <%= it.typename%>Client extends SimpleAppClient<openapi.<%= it.type
176174

177175
reCalculateValue(){
178176
//console.log('trigger new recalculate')
179-
const data = this.getData()
177+
const $data = this.getData()
180178

181179
<% if(it.jsonschema['x-simpleapp-config']['formulas']){ %>
182180
<%Object.keys(it.jsonschema['x-simpleapp-config']['formulas']).forEach(function(index) { %>
183181
<% let fml = it.jsonschema['x-simpleapp-config']['formulas'][index] %>
184182
// <%~ JSON.stringify(fml) %>
185183
//const tmp = jsonpath.query(vdata,fieldpath).filter((item:string)=>item!='')
186184

187-
jsonpath.apply(data, '<%~ fml.jsonPath %>', function(value) { return <%~fml.formula %> });
185+
jsonpath.apply($data, '<%~ fml.jsonPath %>', function($item) { return <%~fml.formula %> });
188186

189187
<%}) %>
190188
<%} %>

templates/nest/src/app.module.ts.eta

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { Module, MiddlewareConsumer, NestModule, Provider } from '@nestjs/common
99
import { MongooseModule,MongooseModuleOptions } from '@nestjs/mongoose';
1010
import { GraphQLModule } from '@nestjs/graphql';
1111
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
12-
12+
import {GenerateModule} from './simpleapp/simpleapp.module'
13+
<% const nestmodules = it.configs.additionalNestModules%>
14+
<% for(let i=0; i<nestmodules.length;i++){ %>
15+
<% const modulename = capitalizeFirstLetter(nestmodules[i]) %>
16+
import {<%= modulename %>Module } from './<%=nestmodules[i]%>/<%=nestmodules[i]%>.module';
17+
<%}%>
1318
import { APP_GUARD,APP_INTERCEPTOR,APP_FILTER } from '@nestjs/core';
1419
import { ResponseInterceptor } from './simpleapp/generate/commons/interceptors/response.interceptor'
1520
import {
@@ -28,8 +33,6 @@ import { AppResolver } from './app.resolver';
2833
import { TenantMiddleware } from './simpleapp/generate/commons/middlewares/tenant.middleware';
2934
import { AppController } from './app.controller';
3035
import { AppService } from './app.service';
31-
import {GenerateModule} from './simpleapp/simpleapp.module'
32-
import { CloudApiModule } from './cloudapi/cloudapi.module';
3336
import { UserMongoSchema } from './simpleapp/generate/models/user.model';
3437
import { PermissionMongoSchema } from './simpleapp/generate/models/perm.model';
3538
import { ApiEventMongoSchema } from './simpleapp/generate/models/apievent.model';
@@ -76,7 +79,12 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
7679
tokenValidation: TokenValidation.ONLINE,
7780
}),
7881
GenerateModule,
79-
CloudApiModule,
82+
83+
<% for(let i=0; i<nestmodules.length;i++){ %>
84+
<% const modulename = capitalizeFirstLetter(nestmodules[i]) %>
85+
<%= modulename %>Module,
86+
<%}%>
87+
8088
MongooseModule.forFeature([
8189
{ name: 'User', schema: UserMongoSchema },
8290
{ name: 'Permission', schema: PermissionMongoSchema },

templates/nest/src/cloudapi/cloudapi.module.ts._eta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ import { CloudApiService } from './cloudapi.service';
1212
providers: [CloudApiService],
1313
exports: [CloudApiService],
1414
})
15-
export class CloudApiModule {}
15+
export class CloudapiModule {}

templates/nest/src/printapi/printapi.module.ts.eta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ import { PrintApiService } from './printapi.service';
1212
providers: [PrintApiService],
1313
exports: [PrintApiService],
1414
})
15-
export class PrintApiModule {}
15+
export class PrintapiModule {}

templates/nest/src/simpleapp/generate/commons/robotuser.service.ts.eta

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ export class SimpleAppRobotUserService {
8181
const nextrefresh = tokens.expires_in * 0.8;
8282
const appuser = this.prepareAppUser(undefined);
8383

84-
85-
setTimeout(async () => {
86-
await this.refreshSystemToken();
87-
}, nextrefresh * 1000);
84+
if(tokens.access_token){
85+
setTimeout(async () => {
86+
await this.refreshSystemToken();
87+
}, nextrefresh * 1000);
88+
}
8889
}
8990

9091
prepareAppUser(data: any) {

templates/nest/src/simpleapp/generate/commons/user.context.ts.eta

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ export class UserContext {
535535
};
536536

537537
searchInsertedRecordId(collection: string, _id: string) {
538+
if(!this.modifiedRecords.createds[collection]) return undefined
538539
return this.modifiedRecords.createds[collection].find(
539540
(item) => item === _id,
540541
);

0 commit comments

Comments
 (0)