@simitgroup/simpleapp-generator 1.0.40 → 1.0.45
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 copy.md +402 -1
- package/README.md +61 -409
- package/dist/framework.js +1 -1
- package/dist/framework.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +7 -3
- package/dist/generate.js.map +1 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/src/framework.ts +1 -1
- package/src/generate.ts +7 -4
- package/src/type.ts +1 -2
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +1 -1
- package/templates/project/groups/admin.json.eta +40 -0
- package/templates/project/schemas/product.ts.eta +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/README copy.md
CHANGED
|
@@ -879,4 +879,405 @@ invoice => foreignkey: detail.product=>product
|
|
|
879
879
|
order => foreignkey: detail.product=>product
|
|
880
880
|
|
|
881
881
|
cat =[product.category]
|
|
882
|
-
product=[invoice.detail.product, order.detail.product]
|
|
882
|
+
product=[invoice.detail.product, order.detail.product]
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
todo:
|
|
888
|
+
## high priority Job
|
|
889
|
+
|
|
890
|
+
[ ] add special search like isolate by user for autocomplete (add property of)
|
|
891
|
+
choose org then branch
|
|
892
|
+
[ ] create invoice and receipt
|
|
893
|
+
[x] fix error reporting and success reporting at frontend
|
|
894
|
+
[x] define some allow override and some not
|
|
895
|
+
[ ] json schema can set generate what page type, no define = no generate page
|
|
896
|
+
[ ] create tenant/org/branch auto increament
|
|
897
|
+
[ ] focus on functions customer, product, invoice and receipt
|
|
898
|
+
[~] repeat same typscript formula at frontend and backend
|
|
899
|
+
[ ] frontend search
|
|
900
|
+
[ ] new transaction CRUD ui
|
|
901
|
+
[ ] student UI
|
|
902
|
+
[ ] structure of save into another document
|
|
903
|
+
|
|
904
|
+
Permission and Authorization
|
|
905
|
+
[x] hide no permission window
|
|
906
|
+
[ ] hide no permission buttons
|
|
907
|
+
[x] permission user/group (pick hard coded group from some place)
|
|
908
|
+
[ ] figure how to get enum list from permission list for user schema
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
1. copy group-to-role to both frontend and backend
|
|
913
|
+
2. loop backend role code, and define into user role
|
|
914
|
+
3. loop frontend role code, and
|
|
915
|
+
1 update to getMenus,
|
|
916
|
+
2. existing all menus store as permission list
|
|
917
|
+
3. crud and etc page need verify existing user can go in this menu or not. if can't will render no permission
|
|
918
|
+
4. use directive to control show or not show button (new, save, delete)
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
Custom Document Status and API
|
|
923
|
+
[ ] document status control
|
|
924
|
+
[ ] document api touch up
|
|
925
|
+
1. auto add document status column
|
|
926
|
+
2. change document status when change status
|
|
927
|
+
3. enum document status, but UI dont show the field
|
|
928
|
+
4. have document action, then show document button
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
# Quick start
|
|
932
|
+
** You need to have mongodb installed **
|
|
933
|
+
1. git clone from simpleapp-generator
|
|
934
|
+
```sh
|
|
935
|
+
npm -i @simitgroup/simpleapp-generator@latest
|
|
936
|
+
git clone https://github.com/SIMITGROUP/simpleapp-generator-template myapp
|
|
937
|
+
# edit myapp/config.json to match you mongodb connection string
|
|
938
|
+
cd ~/myapp
|
|
939
|
+
simpleapp-generator -c config.json
|
|
940
|
+
```
|
|
941
|
+
2. start backend
|
|
942
|
+
```sh
|
|
943
|
+
cd ~/myapp/backend
|
|
944
|
+
pnpm start:dev
|
|
945
|
+
```
|
|
946
|
+
3. start frontend
|
|
947
|
+
```sh
|
|
948
|
+
cd ~/myapp/frontend
|
|
949
|
+
pnpm dev
|
|
950
|
+
```
|
|
951
|
+
4. try ui:
|
|
952
|
+
* frontend: [http://localhost:8080](http://localhost:8080)
|
|
953
|
+
* backend: [http://localhost:8000/api](http://localhost:8000/api)
|
|
954
|
+
5. Open project with vscode, explore json schema and the generated forms
|
|
955
|
+
```sh
|
|
956
|
+
code ~/mydoc
|
|
957
|
+
```
|
|
958
|
+
you can change your project at:
|
|
959
|
+
* myapp/backend/.env
|
|
960
|
+
* myapp/backend/src/hooks/*
|
|
961
|
+
|
|
962
|
+
* myapp/frontend/.env
|
|
963
|
+
* myapp/frontend/pages/*
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
# Special Properties:
|
|
968
|
+
## Special root level property
|
|
969
|
+
_id:
|
|
970
|
+
tenantId:
|
|
971
|
+
orgId:
|
|
972
|
+
branchId:
|
|
973
|
+
created:
|
|
974
|
+
createdby:
|
|
975
|
+
updated:
|
|
976
|
+
updatedby:
|
|
977
|
+
documentStatus
|
|
978
|
+
_v:
|
|
979
|
+
x-document-status: [optional]array of document satus: such as:
|
|
980
|
+
{
|
|
981
|
+
"":{"readonly":false,"allowApi":["confirm","void"],"description":"new"},
|
|
982
|
+
"D":{"readonly":false,"allowApi":["confirm","void"],"description":"draft"},
|
|
983
|
+
"V":{"readonly":true,"allowApi":[],"description":"v"},
|
|
984
|
+
"CO":{"readonly":true,"allowApi":["void","revert"],"description":"confirmed"},
|
|
985
|
+
"CL":{"readonly":true,"allowApi":[],"description":"closed"}
|
|
986
|
+
}
|
|
987
|
+
x-document-api: [optional]array of custom api (beside default)
|
|
988
|
+
|
|
989
|
+
```typescript
|
|
990
|
+
[
|
|
991
|
+
{"action":"confirm","method":"put","setDocumentStatus":"CO", "bpmn":"generic-confirm",
|
|
992
|
+
"data":{"document":"document"}},
|
|
993
|
+
{"action":"void",,"method":"put", "setDocumentStatus":"V", "bpmn":"generic-void",
|
|
994
|
+
"data":{"document":"document"}},
|
|
995
|
+
{"action":"revert",,"method":"put", "setDocumentStatus":"D", "bpmn":"generic-revert",
|
|
996
|
+
"data":{"document":"document"}},
|
|
997
|
+
{"action":"duplicate", ,"method":"post","data":{"document":"document"}},
|
|
998
|
+
{"action":"switchStatus",,"method":"put","data":{"statusName":"string","document":"document"}}
|
|
999
|
+
]
|
|
1000
|
+
```
|
|
1001
|
+
## Custom Format
|
|
1002
|
+
|
|
1003
|
+
## Custom Property
|
|
1004
|
+
|
|
1005
|
+
# Concept of Development
|
|
1006
|
+
Development using simpleapp-generator involve below steps:
|
|
1007
|
+
## Simple
|
|
1008
|
+
1. create appropriate jsonschema
|
|
1009
|
+
2. generate frontend and backend architectures
|
|
1010
|
+
3. start backend service, obtain and save api definations into openapi.yaml
|
|
1011
|
+
4. regenerate codes so frontend can obtain openapi clients
|
|
1012
|
+
5. align frontend UI, add necessary component such as css and ui components
|
|
1013
|
+
|
|
1014
|
+
## Advance
|
|
1015
|
+
1. complete simple task
|
|
1016
|
+
2. add more api/process at backend `controller`,`service`,`schema`. Such as:
|
|
1017
|
+
a. customized search and filters
|
|
1018
|
+
b. customized workflows
|
|
1019
|
+
c. connect external api
|
|
1020
|
+
d. additional data processing and validation which is not supported by jsonschema (AJV)
|
|
1021
|
+
3. security like sso/jwt, plugins
|
|
1022
|
+
a. keycloak integration at frontends
|
|
1023
|
+
b. backend manage jwt
|
|
1024
|
+
4. allow additional field formats, validations by modifying ajv
|
|
1025
|
+
a. allow custom jsonschema field property, and do something at backend
|
|
1026
|
+
b. allow custom field format, and do something at backend
|
|
1027
|
+
5. repeat same typscript formula at frontend and backend
|
|
1028
|
+
|
|
1029
|
+
Special Root Level property
|
|
1030
|
+
[x] x-ignore-autocomplete: optional boolean, define it to allow undefine x-document-no & x-document-label
|
|
1031
|
+
[x] x-isolation-type: optional string, how data isolated, 'none,tenant,org,branch', default 'org'
|
|
1032
|
+
|
|
1033
|
+
Special Field Level property
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
# JSON Schema supported String Format
|
|
1038
|
+
all format recognize by ajv plus below:
|
|
1039
|
+
|
|
1040
|
+
1. tel: only digit, auto generate input tel
|
|
1041
|
+
2. documentno : will use documentno generator for auto generate document no
|
|
1042
|
+
3. text: do nothing, will auto generate textarea
|
|
1043
|
+
4. html editor: do nothing, will auto generate html editor
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
# Todo
|
|
1048
|
+
## Update documentation and reference
|
|
1049
|
+
1. create github simpleapp-generator-template and documentation
|
|
1050
|
+
2. update documentation for `simpleapp-generator` and `simpleapp-vue-component`
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
workflow ideal
|
|
1054
|
+
1. define apiserver at backend .env
|
|
1055
|
+
2. api-service class can have standardway for
|
|
1056
|
+
a. excute new workflow
|
|
1057
|
+
b. get tasklist belong to me or my group
|
|
1058
|
+
c. trigger task move
|
|
1059
|
+
d. cancel workflow
|
|
1060
|
+
e. can define workflow inputs
|
|
1061
|
+
3. bind hook to workflow?
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
1. try possibility of no backend modifications
|
|
1068
|
+
3. completely hide all generated codes of frontend and backend, except allow change items
|
|
1069
|
+
1. define hidden control infra of admin tenant, user api+ui (like need special role system-admin from keycloak)
|
|
1070
|
+
add lodash plugin at both side
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
autocomplete can have more dependency filter like setting in jsonschema
|
|
1074
|
+
2. way in jsonschema to use share source code for frontend/backend like
|
|
1075
|
+
calculate tax
|
|
1076
|
+
calculate subtotal
|
|
1077
|
+
|
|
1078
|
+
5. new transaction crud
|
|
1079
|
+
d. windows
|
|
1080
|
+
new user no tenant record how to do?
|
|
1081
|
+
8. way to handle :id/api
|
|
1082
|
+
9. service class which not using source code
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
1. create follow data
|
|
1087
|
+
a. users
|
|
1088
|
+
b. tenant / users
|
|
1089
|
+
c. org
|
|
1090
|
+
branch/user
|
|
1091
|
+
group
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
3. json schema setting can define isolation type
|
|
1095
|
+
2. page/index first login can pick tenant
|
|
1096
|
+
3. create all window as xorg/index
|
|
1097
|
+
4. transaction crud window
|
|
1098
|
+
with x-document-api can have button for api-buttons, control by document status
|
|
1099
|
+
support readonly status
|
|
1100
|
+
5. simple crud only support crud
|
|
1101
|
+
6. support document-no
|
|
1102
|
+
7. add special isolation method by user
|
|
1103
|
+
8. beautify nuxt page
|
|
1104
|
+
9. foreign key with different schema
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
2. tidy up error at frontend/backend messages
|
|
1108
|
+
fix success msg at frontend
|
|
1109
|
+
11.add simple and consistent external hook in service class.
|
|
1110
|
+
13.have way to create more api using different openapi schema but on same object
|
|
1111
|
+
1. support half schema setting in crud, the rest at background
|
|
1112
|
+
|
|
1113
|
+
no auto logout after session expired, or auto renew token
|
|
1114
|
+
- menulist ** less priority, can customize manually
|
|
1115
|
+
10.auto bind apiclient methods to compatible with openapi methods
|
|
1116
|
+
a. create backend service method
|
|
1117
|
+
b. create controller handle
|
|
1118
|
+
|
|
1119
|
+
b. add popup dialog for edit table
|
|
1120
|
+
c. separate list table and form table
|
|
1121
|
+
d.
|
|
1122
|
+
5. tenant setting
|
|
1123
|
+
6. user management
|
|
1124
|
+
5. security of string input, block xss
|
|
1125
|
+
12.add pusher listener in apiclient also
|
|
1126
|
+
|
|
1127
|
+
18. add transaction screen templates
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
## Lower Priority
|
|
1131
|
+
3. multi-lingual
|
|
1132
|
+
6. audit trails
|
|
1133
|
+
7. permissions
|
|
1134
|
+
7. update record need replace updated,updatedby, line item also need headache
|
|
1135
|
+
|
|
1136
|
+
11.frontend add parent/child ui for invoices
|
|
1137
|
+
|
|
1138
|
+
[done]
|
|
1139
|
+
x16. support table details in generator
|
|
1140
|
+
x3. settle instancePath in form
|
|
1141
|
+
x17. auto add source code for addarray item
|
|
1142
|
+
a. render autocomplete readonly field
|
|
1143
|
+
xauto index x-document-name
|
|
1144
|
+
x8. jwt
|
|
1145
|
+
ximprove tel control to allow empty string
|
|
1146
|
+
x15. some autocomplete wish to allow additional column like 6% tax, now become additional fields
|
|
1147
|
+
x9. frontend authentication
|
|
1148
|
+
x1. auto pretty backend and frontend
|
|
1149
|
+
x2. fix pages:id issue
|
|
1150
|
+
x3. search at backend
|
|
1151
|
+
1. remain codes after regenerate (backend)
|
|
1152
|
+
x - service
|
|
1153
|
+
x - schema
|
|
1154
|
+
x - controller
|
|
1155
|
+
x8. block uniquekey
|
|
1156
|
+
1. remain codes after regenerate (frontend)
|
|
1157
|
+
x - pages
|
|
1158
|
+
x - composable (no need )
|
|
1159
|
+
x6. fill in data for tenant/org/branch created,updated,createdby,updatedby
|
|
1160
|
+
14. force x-document-no/name is required
|
|
1161
|
+
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
## Bug fix
|
|
1165
|
+
1. Openapi some schema like primarykey/more not generated, cause error in ide
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
Document Numbering System
|
|
1169
|
+
1. generate prepare list of document no for generate.
|
|
1170
|
+
x-document-no + document-format
|
|
1171
|
+
2. if x-document-no, will auto add docformat={}
|
|
1172
|
+
3. button can pick document-no format
|
|
1173
|
+
4. have add new function
|
|
1174
|
+
5. if type manually wont create new
|
|
1175
|
+
6. preview next no api
|
|
1176
|
+
7. generate next no api
|
|
1177
|
+
8. if _id = '', will auto preview next no
|
|
1178
|
+
9. after change default format, will preview another next no
|
|
1179
|
+
10. have list to pick format
|
|
1180
|
+
11. support transactions
|
|
1181
|
+
12. only list current branch document no options
|
|
1182
|
+
11. master data
|
|
1183
|
+
a. add list for document type
|
|
1184
|
+
b. click doctype then can available document settings
|
|
1185
|
+
c. document will set by branch
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
SimpleApp-Vue-Component Fix:
|
|
1189
|
+
1. table
|
|
1190
|
+
a. column title
|
|
1191
|
+
b. nested column data, like primarykey label
|
|
1192
|
+
c. search and functions like filters, pagination, large datas
|
|
1193
|
+
1. single/multi select
|
|
1194
|
+
4. search at frontend
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
Coding Rules
|
|
1198
|
+
1. create type and codes in 'shares'
|
|
1199
|
+
2. service class and doc class
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
JSON Properties
|
|
1205
|
+
document level property
|
|
1206
|
+
{
|
|
1207
|
+
"type":"object"
|
|
1208
|
+
"x-simpleapp-config":{
|
|
1209
|
+
//isolation type, none/tenant/org/branch
|
|
1210
|
+
"isolationType":"none",
|
|
1211
|
+
|
|
1212
|
+
//what special allow access it, undefine mean only super admin, and resource+action role can go in
|
|
1213
|
+
"requiredRoles":["SuperAdmin"],
|
|
1214
|
+
|
|
1215
|
+
// page type (example: crud), undefine will not generate page in frontend
|
|
1216
|
+
"pageType":"crud",
|
|
1217
|
+
|
|
1218
|
+
//unique key for document, it build compound index depends on isolationtype
|
|
1219
|
+
"uniqueKey":"invoiceNo",
|
|
1220
|
+
|
|
1221
|
+
//use as display name in autocomplete, also add into textsearch
|
|
1222
|
+
"documentTitle":"InvoiceTitle", //no define this will not have auto complete and text search for this field
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
//frontend uniqueKey field become special input field which can generate doc number, once activated auto create new field `docNoFormat`
|
|
1226
|
+
"generateDocumentNumber":true,
|
|
1227
|
+
|
|
1228
|
+
//frontend use this field to show current month document, docNumberFormat generator will have monthly document number setting
|
|
1229
|
+
"documentDate":"invoiceDate",
|
|
1230
|
+
|
|
1231
|
+
//manage document status and accessibility, it auto add field `documentStatus` when define
|
|
1232
|
+
"allStatus":[
|
|
1233
|
+
{"status":"CO","readOnly":true,"actions":["revert","void","close"]},
|
|
1234
|
+
{"status":"V","readOnly":true,"actions":["revert"]},
|
|
1235
|
+
],
|
|
1236
|
+
|
|
1237
|
+
//all custom api, response, paras, operation put here. variable define at entrypoint or querypara
|
|
1238
|
+
"allApi":[{
|
|
1239
|
+
"action":"confirm",
|
|
1240
|
+
"entrypoint":":id/confirm",
|
|
1241
|
+
"requiredrole":["SuperUser"],
|
|
1242
|
+
"method":"post",
|
|
1243
|
+
"execute":"ping",
|
|
1244
|
+
"description":"confirm document and change status to CO"
|
|
1245
|
+
},{
|
|
1246
|
+
"action":"void",
|
|
1247
|
+
"entrypoint":":id/void",
|
|
1248
|
+
"querypara":["reason"],
|
|
1249
|
+
"requiredrole":["SuperUser"],
|
|
1250
|
+
"method":"post",
|
|
1251
|
+
"execute":"ping",
|
|
1252
|
+
"description":"confirm document and change status to CO"
|
|
1253
|
+
}],
|
|
1254
|
+
|
|
1255
|
+
// simple => pure model and service(no page,api),
|
|
1256
|
+
// default => force masterdata property,
|
|
1257
|
+
// transaction => force masterdata property
|
|
1258
|
+
"schemaType": "default",
|
|
1259
|
+
|
|
1260
|
+
//frontend(client) and backend (processor) typescript class auto import this lib, helper for `formula`
|
|
1261
|
+
"libs":[{"lib":"lodash","as":"_"}], // both process class and frontend client class will import same lib
|
|
1262
|
+
|
|
1263
|
+
// frontend apply recalculation everytime current document change
|
|
1264
|
+
// backend auto apply formula during create and update
|
|
1265
|
+
"formula": [ //apply both frontend and backend, it different with concept on change, sequence of formula important
|
|
1266
|
+
{"jsonpath":"$.subtotal","formula":"jslib.getDocumentSubTotal(@F{$.details})"}, //apply formula into single field
|
|
1267
|
+
{"jsonpath":"$.tags","formula":"$F{$.tags}.map(item=>item.toUppeCase())"}, //apply upper case to all item in string array
|
|
1268
|
+
{"jsonpath":"$.details","loop":"jslib.calculateLineTotal(item)"}, //apply multiple calculation of subtotal, tax, amtaftertax and etc, using loop
|
|
1269
|
+
{"jsonpath":"$.total","formula":"@F{$.subtotal} + @F{$.taxamt}"}, //apply simple formula here
|
|
1270
|
+
],
|
|
1271
|
+
|
|
1272
|
+
// auto generate fields
|
|
1273
|
+
documentType: 'SI',
|
|
1274
|
+
documentName: 'Sales Invoice',
|
|
1275
|
+
|
|
1276
|
+
//auto generated foreign keys catalogue
|
|
1277
|
+
"foreignKeys":{ "customer":["$.customer._id"], "user":[{"$.preparedby._id"},{$.approveby._id"}]}
|
|
1278
|
+
},
|
|
1279
|
+
"properties":{
|
|
1280
|
+
"invoiceDate":{"type":"string"},
|
|
1281
|
+
//and others field
|
|
1282
|
+
}
|
|
1283
|
+
}
|