@simitgroup/simpleapp-generator 1.0.46 → 1.0.48
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 +35 -1
- 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 +11 -3
- package/dist/framework.js.map +1 -1
- package/dist/generate.js +33 -22
- package/dist/generate.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
- package/dist/processors/jsonschemabuilder.js +10 -0
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/type.d.ts +115 -22
- 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 +11 -3
- package/src/generate.ts +35 -22
- package/src/index.ts +1 -1
- package/src/processors/jsonschemabuilder.ts +14 -1
- package/src/type.ts +137 -22
- package/templates/basic/nest/processor.ts.eta +5 -3
- package/templates/basic/nest/service.ts.eta +2 -4
- package/templates/basic/nuxt/pages.crud.vue.eta +3 -2
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +18 -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 +54 -12
- 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 +9 -10
- 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 +16 -8
- 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/ListView.vue.eta +52 -0
- package/templates/nuxt/components/Menus.vue.eta +6 -6
- package/templates/nuxt/components/SelectBranch.vue.eta +35 -0
- package/templates/nuxt/components/SimpleAppDatatable.vue.eta +0 -1
- package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +2 -2
- 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/layouts/sidelistcrud.vue.eta +43 -0
- 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]/docnoformat/index.vue.eta +274 -247
- package/templates/nuxt/pages/[xorg]/index.vue._eta +13 -0
- package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +89 -65
- package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +7 -7
- 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/category.ts.eta +40 -27
- package/templates/project/schemas/customer.ts.eta +35 -0
- package/templates/project/schemas/index.ts.eta +4 -4
- package/templates/project/schemas/invoice.ts.eta +56 -0
- package/templates/project/schemas/product.ts.eta +41 -57
- package/templates/project/sharelibs/index.ts.eta +2 -0
- package/templates/project/sharelibs/money.ts.eta +17 -0
- 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/pages/[xorg]/index.vue.eta +0 -36
- package/templates/nuxt/tailwind.config.ts.eta +0 -9
- package/templates/project/shares/index.ts.eta +0 -2
- /package/templates/nest/{.env.eta → .env._eta} +0 -0
- /package/templates/nuxt/{.env.eta → .env._eta} +0 -0
- /package/templates/nuxt/pages/[xorg]/branch/{index.vue.eta → index.vue.etax} +0 -0
- /package/templates/project/{config.json.eta → config.json._eta} +0 -0
- /package/templates/project/{shares → sharelibs}/hello.ts.eta +0 -0
package/src/type.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
|
1
|
+
import { JSONSchema7,JSONSchema7Type,JSONSchema7Version, JSONSchema7TypeName,JSONSchema7Definition } from 'json-schema';
|
|
2
2
|
export type ChildModels = {
|
|
3
3
|
[key: string]: {
|
|
4
4
|
type: string;
|
|
@@ -65,6 +65,7 @@ export type ModuleObject = {
|
|
|
65
65
|
docname:string
|
|
66
66
|
pagetype:string
|
|
67
67
|
api:DocumentApi[]
|
|
68
|
+
schema:SimpleAppJSONSchema7
|
|
68
69
|
}
|
|
69
70
|
export type TypeGenerateDocumentVariable ={
|
|
70
71
|
name: string
|
|
@@ -78,7 +79,7 @@ apiSchemaName: string
|
|
|
78
79
|
typename: string
|
|
79
80
|
fullApiSchemaName: string
|
|
80
81
|
fullTypeName:string
|
|
81
|
-
jsonschema:
|
|
82
|
+
jsonschema: SimpleAppJSONSchema7
|
|
82
83
|
bothEndCode: string
|
|
83
84
|
frontEndCode: string
|
|
84
85
|
backEndCode: string
|
|
@@ -123,14 +124,14 @@ export type DocumentApi = {
|
|
|
123
124
|
description:string //description of api
|
|
124
125
|
}
|
|
125
126
|
export enum IsolationType {"none"="none" , "tenant"="tenant","org"="org", "branch"="branch"}
|
|
126
|
-
export type ImportLibs = {"lib":string,"as":string}
|
|
127
|
+
// export type ImportLibs = {"lib":string,"as":string}
|
|
127
128
|
export type Formula = {
|
|
128
129
|
"jsonpath":string //example: "$.subtotal","$.details[*]"
|
|
129
130
|
"formula":string //example "jslib.getDocumentSubTotal(@F{$.details})"
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
export type SchemaConfig = {
|
|
133
|
-
isolationType: IsolationType
|
|
134
|
+
isolationType: IsolationType
|
|
134
135
|
requiredRoles?:string[]
|
|
135
136
|
pageType?: string
|
|
136
137
|
uniqueKey?:string
|
|
@@ -140,7 +141,7 @@ export type SchemaConfig = {
|
|
|
140
141
|
allStatus?:DocumentStatus[]
|
|
141
142
|
additionalApis?:DocumentApi[]
|
|
142
143
|
additionalAutoCompleteFields ?: string[]
|
|
143
|
-
libs?:ImportLibs[] // both process class and frontend client class will import same lib
|
|
144
|
+
// libs?:ImportLibs[] // both process class and frontend client class will import same lib
|
|
144
145
|
formulas?: Formula[]
|
|
145
146
|
documentType: string
|
|
146
147
|
documentName: string
|
|
@@ -148,28 +149,142 @@ export type SchemaConfig = {
|
|
|
148
149
|
foreignKeys?:MyForeignKey,
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
// [key:string]:JSONSchema7Object
|
|
153
|
-
// }
|
|
154
|
-
export type ForeignKeyProperty = {'x-foreignkey' ?:string}
|
|
152
|
+
|
|
155
153
|
export type SchemaFields = {
|
|
156
|
-
_id:
|
|
157
|
-
tenantId:
|
|
158
|
-
orgId:
|
|
159
|
-
branchId:
|
|
160
|
-
created:
|
|
161
|
-
updated:
|
|
162
|
-
createdby:
|
|
163
|
-
updatedby:
|
|
164
|
-
[key:string]:
|
|
154
|
+
_id: SimpleAppJSONSchema7
|
|
155
|
+
tenantId: SimpleAppJSONSchema7
|
|
156
|
+
orgId: SimpleAppJSONSchema7
|
|
157
|
+
branchId: SimpleAppJSONSchema7
|
|
158
|
+
created: SimpleAppJSONSchema7
|
|
159
|
+
updated: SimpleAppJSONSchema7
|
|
160
|
+
createdby: SimpleAppJSONSchema7
|
|
161
|
+
updatedby: SimpleAppJSONSchema7
|
|
162
|
+
[key:string]:SimpleAppJSONSchema7 | SimpleAppJSONSchema7[] | undefined
|
|
163
|
+
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
|
|
167
|
+
export type SchemaType = {
|
|
168
|
+
type:string
|
|
169
|
+
definitions?:SimpleAppJSONSchema7
|
|
170
|
+
required?:string[]
|
|
171
|
+
|
|
172
|
+
"x-simpleapp-config":SchemaConfig
|
|
173
|
+
properties: SchemaFields
|
|
170
174
|
}
|
|
171
175
|
|
|
172
|
-
export type SchemaType = JSONSchema7 & AdditionalSchemaType
|
|
173
176
|
|
|
174
177
|
|
|
175
178
|
|
|
179
|
+
// modified from jsonschemas
|
|
180
|
+
export type SimpleAppJSONSchema7Definition = SimpleAppJSONSchema7 | boolean;
|
|
181
|
+
export interface SimpleAppJSONSchema7 {
|
|
182
|
+
|
|
183
|
+
'x-foreignkey' ?:string
|
|
184
|
+
$id?: string | undefined;
|
|
185
|
+
$ref?: string | undefined;
|
|
186
|
+
$schema?: JSONSchema7Version | undefined;
|
|
187
|
+
$comment?: string | undefined;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
191
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
192
|
+
*/
|
|
193
|
+
$defs?: {
|
|
194
|
+
[key: string]: JSONSchema7Definition;
|
|
195
|
+
} | undefined;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
|
|
199
|
+
*/
|
|
200
|
+
type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
|
|
201
|
+
enum?: JSONSchema7Type[] | undefined;
|
|
202
|
+
const?: JSONSchema7Type | undefined;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
206
|
+
*/
|
|
207
|
+
multipleOf?: number | undefined;
|
|
208
|
+
maximum?: number | undefined;
|
|
209
|
+
exclusiveMaximum?: number | undefined;
|
|
210
|
+
minimum?: number | undefined;
|
|
211
|
+
exclusiveMinimum?: number | undefined;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
|
|
215
|
+
*/
|
|
216
|
+
maxLength?: number | undefined;
|
|
217
|
+
minLength?: number | undefined;
|
|
218
|
+
pattern?: string | undefined;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
|
|
222
|
+
*/
|
|
223
|
+
items?: SimpleAppJSONSchema7Definition | SimpleAppJSONSchema7Definition[] | undefined;
|
|
224
|
+
additionalItems?: JSONSchema7Definition | undefined;
|
|
225
|
+
maxItems?: number | undefined;
|
|
226
|
+
minItems?: number | undefined;
|
|
227
|
+
uniqueItems?: boolean | undefined;
|
|
228
|
+
contains?: SimpleAppJSONSchema7Definition | undefined;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
|
|
232
|
+
*/
|
|
233
|
+
maxProperties?: number | undefined;
|
|
234
|
+
minProperties?: number | undefined;
|
|
235
|
+
required?: string[] | undefined;
|
|
236
|
+
properties?: {
|
|
237
|
+
[key: string]: SimpleAppJSONSchema7Definition;
|
|
238
|
+
} | undefined;
|
|
239
|
+
patternProperties?: {
|
|
240
|
+
[key: string]: SimpleAppJSONSchema7Definition;
|
|
241
|
+
} | undefined;
|
|
242
|
+
additionalProperties?: SimpleAppJSONSchema7Definition | undefined;
|
|
243
|
+
dependencies?: {
|
|
244
|
+
[key: string]: SimpleAppJSONSchema7Definition | string[];
|
|
245
|
+
} | undefined;
|
|
246
|
+
propertyNames?: SimpleAppJSONSchema7Definition | undefined;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
|
|
250
|
+
*/
|
|
251
|
+
if?: SimpleAppJSONSchema7Definition | undefined;
|
|
252
|
+
then?: SimpleAppJSONSchema7Definition | undefined;
|
|
253
|
+
else?: SimpleAppJSONSchema7Definition | undefined;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
|
|
257
|
+
*/
|
|
258
|
+
allOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
259
|
+
anyOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
260
|
+
oneOf?: SimpleAppJSONSchema7Definition[] | undefined;
|
|
261
|
+
not?: SimpleAppJSONSchema7Definition | undefined;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
|
|
265
|
+
*/
|
|
266
|
+
format?: string | undefined;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
|
|
270
|
+
*/
|
|
271
|
+
contentMediaType?: string | undefined;
|
|
272
|
+
contentEncoding?: string | undefined;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
|
|
276
|
+
*/
|
|
277
|
+
definitions?: {
|
|
278
|
+
[key: string]: JSONSchema7Definition;
|
|
279
|
+
} | undefined;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
|
|
283
|
+
*/
|
|
284
|
+
title?: string | undefined;
|
|
285
|
+
description?: string | undefined;
|
|
286
|
+
default?: JSONSchema7Type | undefined;
|
|
287
|
+
readOnly?: boolean | undefined;
|
|
288
|
+
writeOnly?: boolean | undefined;
|
|
289
|
+
examples?: JSONSchema7Type | undefined;
|
|
290
|
+
}
|
|
@@ -27,12 +27,14 @@ import { <%Object.keys(it.models).forEach(function(modelname) { %> Default<%=mo
|
|
|
27
27
|
export class <%= it.typename %>Processor extends SimpleAppService<<%= it.typename %>> {
|
|
28
28
|
protected documentIdentityCode='<%~ it.autocompletecode %>'
|
|
29
29
|
protected documentIdentityLabel='<%~ it.autocompletename %>'
|
|
30
|
-
|
|
30
|
+
<%if(it.jsonschema['x-simpleapp-config']['generateDocumentNumber']){%>
|
|
31
|
+
protected withDocNumberFormat = true
|
|
32
|
+
<%}%>
|
|
31
33
|
|
|
32
34
|
protected foreignkeys = <%~ JSON.stringify(it.foreignkeys)%>
|
|
33
35
|
|
|
34
|
-
constructor(mydoc: Model<<%= it.typename
|
|
35
|
-
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%>);
|
|
36
38
|
this.setSchema(<%= it.typename%>JsonSchema)
|
|
37
39
|
this.setData(Default<%=it.typename%>(crypto.randomUUID()))
|
|
38
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) => {
|
|
@@ -125,8 +125,9 @@
|
|
|
125
125
|
<%let tablefields = Object.keys(obj.items.properties) %>
|
|
126
126
|
<% for(let a=0;a<tablefields.length;a++){%>
|
|
127
127
|
<%let col= tablefields[a] %>
|
|
128
|
+
<% if(skipcolumns.includes(col)){ continue}%>
|
|
128
129
|
<%let subobj = obj.items.properties[col] %>
|
|
129
|
-
<column field="<%=col%>" #body="{index}" :header="camelCaseToWords('<%=col%>')">
|
|
130
|
+
<column field="<%=col%>" #body="{index}" :header="camelCaseToWords('<%=col%>')">
|
|
130
131
|
<%if(subobj['x-foreignkey']){%>
|
|
131
132
|
<SimpleAppAutocomplete v-model="data.<%=key%>[index].<%=col%>"
|
|
132
133
|
:setting="o.getField('#/properties/<%=key%>/items/properties/<%=col%>')"
|
|
@@ -169,7 +170,7 @@
|
|
|
169
170
|
</column>
|
|
170
171
|
<%}%>
|
|
171
172
|
<column #body="{index}" header="Delete">
|
|
172
|
-
<
|
|
173
|
+
<Button class="btn-danger" type="button" @click="data.<%=key%>.splice(index,1)">X</Button>
|
|
173
174
|
</column>
|
|
174
175
|
</SimpleAppInputTable>
|
|
175
176
|
<% } else{%>
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* last change 2023-09-23
|
|
6
6
|
* Author: Ks Tan
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import _ from 'lodash'
|
|
9
|
+
import * as sharelibs from '../sharelibs'
|
|
10
|
+
import * as jsonpath from 'jsonpath'
|
|
9
11
|
import { SimpleAppClient } from "./SimpleAppClient";
|
|
10
12
|
import {
|
|
11
13
|
<%Object.keys(it.models).forEach(function(modelname) { %> Default<%=modelname%>, <%})%>
|
|
@@ -47,6 +49,9 @@ export class <%= it.typename%>Client extends SimpleAppClient<<%= it.typename%>,<
|
|
|
47
49
|
public readonly schema= <%~ JSON.stringify(it.jsonschema) %>;
|
|
48
50
|
protected documentIdentityCode='<%~ it.autocompletecode %>'
|
|
49
51
|
protected documentIdentityName='<%~ it.autocompletename %>'
|
|
52
|
+
<%if(it.jsonschema['x-simpleapp-config']['generateDocumentNumber']){%>
|
|
53
|
+
protected withDocNumberFormat = true
|
|
54
|
+
<%}%>
|
|
50
55
|
constructor() {
|
|
51
56
|
const {$event,$listen,$axios}=useNuxtApp()
|
|
52
57
|
let xorg = useRoute().params.xorg
|
|
@@ -137,7 +142,18 @@ export class <%= it.typename%>Client extends SimpleAppClient<<%= it.typename%>,<
|
|
|
137
142
|
reCalculateValue(){
|
|
138
143
|
console.log('trigger new recalculate')
|
|
139
144
|
const data = this.getData()
|
|
145
|
+
|
|
146
|
+
<% if(it.jsonschema['x-simpleapp-config']['formulas']){ %>
|
|
147
|
+
<%Object.keys(it.jsonschema['x-simpleapp-config']['formulas']).forEach(function(index) { %>
|
|
148
|
+
<% let fml = it.jsonschema['x-simpleapp-config']['formulas'][index] %>
|
|
149
|
+
// <%~ JSON.stringify(fml) %>
|
|
150
|
+
//const tmp = jsonpath.query(vdata,fieldpath).filter((item:string)=>item!='')
|
|
151
|
+
|
|
152
|
+
jsonpath.apply(data, '<%~ fml.jsonpath %>', function(value) { return <%~fml.formula %> });
|
|
140
153
|
|
|
154
|
+
<%}) %>
|
|
155
|
+
<%} %>
|
|
156
|
+
/*
|
|
141
157
|
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
142
158
|
<%let obj = it.jsonschema.properties[key]%>
|
|
143
159
|
<%if(obj['x-compute']){%> //x-compute first level field
|
|
@@ -207,6 +223,6 @@ export class <%= it.typename%>Client extends SimpleAppClient<<%= it.typename%>,<
|
|
|
207
223
|
<%}) %>
|
|
208
224
|
}
|
|
209
225
|
<%} /*process compute for 2nd level sub tables*/%>
|
|
210
|
-
<%}) %>
|
|
226
|
+
<%}) %> */
|
|
211
227
|
}
|
|
212
228
|
}
|
|
@@ -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)=>{ %>
|