@simitgroup/simpleapp-generator 1.0.32 → 1.0.35
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/.vscode/settings.json +3 -0
- package/README.md +185 -16
- package/buildinschemas copy/autoincreament.autoinc.jsonschema.json +39 -0
- package/buildinschemas copy/branch.branch.jsonschema.json +41 -0
- package/buildinschemas copy/docnoformat.docno.jsonschema.json +41 -0
- package/buildinschemas copy/organization.org.jsonschema.json +50 -0
- package/buildinschemas copy/permission.perm.jsonschema.json +23 -0
- package/buildinschemas copy/permission.perm.jsonschema.try.json +25 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.json +21 -0
- package/buildinschemas copy/tenant.tenant.jsonschema.try.json +27 -0
- package/buildinschemas copy/user.user.jsonschema.json +31 -0
- package/dist/buildinschemas/autoincreament.d.ts +3 -0
- package/dist/buildinschemas/autoincreament.d.ts.map +1 -0
- package/dist/buildinschemas/autoincreament.js +36 -0
- package/dist/buildinschemas/autoincreament.js.map +1 -0
- package/dist/buildinschemas/branch.d.ts +3 -0
- package/dist/buildinschemas/branch.d.ts.map +1 -0
- package/dist/buildinschemas/branch.js +41 -0
- package/dist/buildinschemas/branch.js.map +1 -0
- package/dist/buildinschemas/docnoformat.d.ts +3 -0
- package/dist/buildinschemas/docnoformat.d.ts.map +1 -0
- package/dist/buildinschemas/docnoformat.js +60 -0
- package/dist/buildinschemas/docnoformat.js.map +1 -0
- package/dist/buildinschemas/index.d.ts +8 -0
- package/dist/buildinschemas/index.d.ts.map +1 -0
- package/dist/buildinschemas/index.js +18 -0
- package/dist/buildinschemas/index.js.map +1 -0
- package/dist/buildinschemas/organization.d.ts +3 -0
- package/dist/buildinschemas/organization.d.ts.map +1 -0
- package/dist/buildinschemas/organization.js +34 -0
- package/dist/buildinschemas/organization.js.map +1 -0
- package/dist/buildinschemas/permission.d.ts +3 -0
- package/dist/buildinschemas/permission.d.ts.map +1 -0
- package/dist/buildinschemas/permission.js +34 -0
- package/dist/buildinschemas/permission.js.map +1 -0
- package/dist/buildinschemas/tenant.d.ts +3 -0
- package/dist/buildinschemas/tenant.d.ts.map +1 -0
- package/dist/buildinschemas/tenant.js +41 -0
- package/dist/buildinschemas/tenant.js.map +1 -0
- package/dist/buildinschemas/user.d.ts +3 -0
- package/dist/buildinschemas/user.d.ts.map +1 -0
- package/dist/buildinschemas/user.js +31 -0
- package/dist/buildinschemas/user.js.map +1 -0
- package/dist/constant.d.ts +4 -0
- package/dist/constant.d.ts.map +1 -0
- package/dist/constant.js +2 -1
- package/dist/constant.js.map +1 -1
- package/dist/framework.d.ts +10 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/framework.js +120 -68
- package/dist/framework.js.map +1 -1
- package/dist/generate-allow-changebackend.js +305 -0
- package/dist/generate-allow-changebackend.js.map +1 -0
- package/dist/generate.d.ts +2 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +310 -230
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -20
- package/dist/index.js.map +1 -1
- package/dist/libs.d.ts +2 -0
- package/dist/libs.d.ts.map +1 -0
- package/dist/processors/groupsbuilder.js +2 -0
- package/dist/processors/groupsbuilder.js.map +1 -0
- package/dist/processors/jsonschemabuilder.d.ts +4 -0
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -0
- package/dist/processors/jsonschemabuilder.js +146 -172
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/schematype/baseschema.js +25 -0
- package/dist/schematype/baseschema.js.map +1 -0
- package/dist/schematype/default.js +2 -0
- package/dist/schematype/default.js.map +1 -0
- package/dist/schematype/index.js +12 -0
- package/dist/schematype/index.js.map +1 -0
- package/dist/schematype/primarymasterdata.js +38 -0
- package/dist/schematype/primarymasterdata.js.map +1 -0
- package/dist/schematype/simple.js +24 -0
- package/dist/schematype/simple.js.map +1 -0
- package/dist/schematype/simplemasterdata.js +31 -0
- package/dist/schematype/simplemasterdata.js.map +1 -0
- package/dist/schematype/transaction.js +74 -0
- package/dist/schematype/transaction.js.map +1 -0
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +2 -2
- package/dist/storage.js.map +1 -1
- package/dist/type.d.ts +164 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +16 -1
- package/dist/type.js.map +1 -1
- package/dist/validation.d.ts +1 -0
- package/dist/validation.d.ts.map +1 -0
- package/documentation/designconcept.bpmn +349 -0
- package/documentation/documentation.png +0 -0
- package/documentation/infra.drawio +141 -0
- package/documentation/infra.png +0 -0
- package/documentation/management.drawio +57 -0
- package/documentation/stack.drawio +106 -0
- package/package.json +3 -1
- package/src/buildinschemas/autoincreament.ts +34 -0
- package/src/buildinschemas/branch.ts +39 -0
- package/src/buildinschemas/docnoformat.ts +58 -0
- package/src/buildinschemas/index.ts +7 -0
- package/src/buildinschemas/organization.ts +31 -0
- package/src/buildinschemas/permission.ts +31 -0
- package/src/buildinschemas/tenant.ts +38 -0
- package/src/buildinschemas/user.ts +28 -0
- package/src/constant.ts +2 -1
- package/src/framework.ts +126 -67
- package/src/generate.ts +327 -266
- package/src/generate.ts.backup +339 -0
- package/src/index.ts +93 -18
- package/src/processors/jsonschemabuilder.ts +199 -226
- package/src/processors/jsonschemabuilder.ts-old +383 -0
- package/src/storage.ts +1 -1
- package/src/type.ts +94 -27
- package/templates/basic/nest/controller.ts.eta +255 -0
- package/templates/basic/nest/default.ts.eta +42 -0
- package/templates/basic/{model.eta → nest/model.ts.eta} +18 -5
- package/templates/basic/nest/processor.ts.eta +129 -0
- package/templates/basic/nest/service.ts.eta +64 -0
- package/templates/basic/{type.eta → nest/type.ts.eta} +3 -3
- package/templates/basic/nuxt/default.ts.eta +42 -0
- package/templates/basic/{pageindex.vue.eta → nuxt/pages.crud.vue.eta} +85 -22
- package/templates/basic/nuxt/simpleapp.doc.ts.eta +11 -0
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +212 -0
- package/templates/nest/.env.eta +31 -0
- package/templates/nest/.gitignore.eta +40 -0
- package/templates/nest/src/app.controller.ts.eta +19 -0
- package/templates/nest/src/app.module.ts.eta +77 -0
- package/templates/nest/src/app.service.ts.eta +9 -0
- package/templates/nest/src/main.ts.eta +58 -0
- package/templates/nest/src/simpleapp/generate/apischemas/index.ts.eta +16 -0
- package/templates/nest/src/simpleapp/generate/commons/decorators/appuser.decorator.ts.eta +8 -0
- package/templates/nest/src/simpleapp/generate/commons/dicts/foreignkeys.ts.eta +1 -0
- package/templates/nest/src/simpleapp/generate/commons/docnogenerator.service.ts.eta +101 -0
- package/templates/nest/src/simpleapp/generate/commons/exceptions/SimpleAppExceptionFilter.ts.eta +39 -0
- package/templates/nest/src/simpleapp/generate/commons/interceptors/response.interceptor.ts.eta +38 -0
- package/templates/nest/src/simpleapp/generate/commons/middlewares/tenant.middleware.ts.eta +88 -0
- package/templates/nest/{Workflow.eta → src/simpleapp/generate/commons/providers/workflow.provider.ts.etax} +20 -14
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.decorator.ts.eta +6 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +28 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.group.ts.eta +10 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.guard.ts.eta +34 -0
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +391 -0
- package/templates/nest/src/simpleapp/generate/controllers/simpleapp.controller.ts.eta +71 -0
- package/templates/nest/src/simpleapp/generate/models/perm.model.ts.eta +53 -0
- package/templates/nest/src/simpleapp/generate/models/tenant.model.ts.eta +45 -0
- package/templates/nest/src/simpleapp/generate/models/user.model.ts.eta +57 -0
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +624 -0
- package/templates/nest/src/simpleapp/generate/types/index.ts.eta +19 -0
- package/templates/nest/src/simpleapp/profile/profile.apischema.ts.eta +74 -0
- package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +110 -0
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +195 -0
- package/templates/nest/src/simpleapp/profile/profile.types.ts.eta +18 -0
- package/templates/nest/src/simpleapp/services/autoinc.service.ts.eta +89 -0
- package/templates/nest/src/simpleapp/services/branch.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/services/docno.service.ts.eta +93 -0
- package/templates/nest/src/simpleapp/services/org.service.ts.eta +67 -0
- package/templates/nest/src/simpleapp/services/perm.service.ts.eta +102 -0
- package/templates/nest/src/simpleapp/services/tenant.service.ts.eta +69 -0
- package/templates/nest/src/simpleapp/services/user.service.ts.eta +66 -0
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +43 -0
- package/templates/nuxt/.env.eta +21 -0
- package/templates/nuxt/.gitignore.eta +28 -0
- package/templates/nuxt/app.vue.eta +5 -2
- package/templates/nuxt/assets/css/tailwind.css.eta +35 -0
- package/templates/nuxt/components/CrudNestedDoc.vue.eta +164 -0
- package/templates/nuxt/components/CrudSimple.vue.eta +179 -0
- package/templates/nuxt/{components.debugdocdata.vue.eta → components/DebugDocumentData.vue.eta} +4 -1
- package/templates/nuxt/{components.eventmonitor.vue.eta → components/EventMonitor.vue.eta} +27 -27
- package/templates/nuxt/components/Invitation.vue.eta +50 -0
- package/templates/nuxt/components/Menus.vue.eta +58 -0
- package/templates/nuxt/components/PermissionInfo.vue.eta +92 -0
- package/templates/nuxt/components/SimpleAppAutocomplete.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppAutocompletemulti.vue.eta +73 -0
- package/templates/nuxt/components/SimpleAppCalendar.vue.eta +55 -0
- package/templates/nuxt/components/SimpleAppCheckbox.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppChip.vue.eta +28 -0
- package/templates/nuxt/components/SimpleAppColor.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppDatatable.vue.eta +20 -0
- package/templates/nuxt/components/SimpleAppDocumentNo.vue.eta +90 -0
- package/templates/nuxt/components/SimpleAppDynamicInput.vue.eta +29 -0
- package/templates/nuxt/components/SimpleAppEditor.vue.eta +31 -0
- package/templates/nuxt/components/SimpleAppForm.vue.eta +131 -0
- package/templates/nuxt/components/SimpleAppInputTable.vue.eta +104 -0
- package/templates/nuxt/components/SimpleAppList.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppListmulti.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppNumber.vue.eta +32 -0
- package/templates/nuxt/components/SimpleAppPassword.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppRadio.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppRating.vue.eta +41 -0
- package/templates/nuxt/components/SimpleAppSelect.vue.eta +38 -0
- package/templates/nuxt/components/SimpleAppSelectmulti.vue.eta +39 -0
- package/templates/nuxt/components/SimpleAppSlider.vue.eta +42 -0
- package/templates/nuxt/components/SimpleAppSwitch.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppText.vue.eta +50 -0
- package/templates/nuxt/components/SimpleAppTextarea.vue.eta +30 -0
- package/templates/nuxt/components/SimpleAppValue.vue.eta +86 -0
- package/templates/nuxt/components/SimpleFieldContainer.vue.eta +102 -0
- package/templates/nuxt/components/XorgPicker.vue.eta +66 -0
- package/templates/nuxt/components/helper.ts.eta +90 -0
- package/templates/nuxt/components/type.ts.eta +32 -0
- package/templates/nuxt/composables/docformat.generate.ts.eta +5 -0
- package/templates/nuxt/{composables.getautocomplete.ts.eta → composables/getAutocomplete.generate.ts.eta} +4 -5
- package/templates/nuxt/{composables.getmenus.ts.eta → composables/getMenus.generate.ts.eta} +22 -7
- package/templates/nuxt/composables/getOpenApi.generate.ts.eta +6 -0
- package/templates/nuxt/composables/getTenant.generate.ts.eta +4 -0
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +22 -0
- package/templates/nuxt/composables/logout.generate.ts.eta +22 -0
- package/templates/nuxt/composables/roles.generate.ts.eta +48 -0
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +5 -0
- package/templates/nuxt/{layouts.default.vue.eta → layouts/default.vue.eta} +2 -0
- package/templates/nuxt/middleware/10.acl.global.ts.eta +38 -0
- package/templates/nuxt/nuxt.config.ts.eta +12 -2
- package/templates/nuxt/pages/[xorg]/branch/index.vue.eta +102 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/[id].vue.eta +17 -0
- package/templates/nuxt/pages/[xorg]/docnoformat/index.vue.eta +269 -0
- package/templates/nuxt/pages/[xorg]/index.vue.eta +36 -0
- package/templates/nuxt/pages/[xorg]/organization/index.vue.eta +148 -0
- package/templates/nuxt/pages/[xorg]/permission/index.vue.eta +280 -0
- package/templates/nuxt/pages/[xorg]/tenant/index.vue.eta +93 -0
- package/templates/nuxt/pages/[xorg]/user/index.vue.eta +468 -0
- package/templates/nuxt/pages/index.vue.eta +191 -0
- package/templates/nuxt/pages/login.vue.eta +21 -0
- package/templates/nuxt/plugins/10.simpleapp-event.ts.eta +53 -0
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +155 -0
- package/templates/nuxt/plugins/50.simpleapp-client.ts.eta +23 -0
- package/templates/nuxt/{server.api.ts.eta → server/api/[xorg]/[...].ts.eta} +5 -2
- package/templates/nuxt/server/api/auth/[...].ts.eta +68 -0
- package/templates/nuxt/{server.api.auth.logout.ts.eta → server/api/auth/logout.ts.eta} +1 -3
- package/templates/nuxt/server/api/profile/[...].ts.eta +150 -0
- package/templates/nuxt/server/api/profile/index.ts.eta +103 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +187 -0
- package/templates/nuxt/simpleapp/generate/commons/documents.ts.eta +6 -0
- package/templates/nuxt/simpleapp/generate/commons/events.ts.eta +5 -0
- package/templates/nuxt/simpleapp/generate/commons/groups.ts.eta +11 -0
- package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +21 -0
- package/templates/nuxt/types/index.ts.eta +65 -0
- package/templates/project/README.md +11 -0
- package/templates/project/build.sh.eta +17 -0
- package/templates/project/config.json.eta +2 -0
- package/templates/project/generate.ts.eta +10 -0
- package/templates/project/schemas/category.ts.eta +26 -0
- package/templates/project/schemas/index.ts.eta +5 -0
- package/templates/project/schemas/product.ts.eta +59 -0
- package/templates/project/shares/hello.ts.eta +1 -0
- package/templates/project/shares/index.ts.eta +2 -0
- package/tsconfig.json +9 -2
- package/tsconfig.tsbuildinfo +1 -0
- package/definations/category.cat.jsonschema.json +0 -55
- package/definations/level.lvl.jsonschema.json +0 -48
- package/definations/product.prd.jsonschema.json +0 -46
- package/templates/basic/controller.eta +0 -152
- package/templates/basic/module.eta +0 -22
- package/templates/basic/service.eta +0 -62
- package/templates/basic/simpleappclient.eta +0 -120
- package/templates/nest/SimpleAppController.eta +0 -69
- package/templates/nest/SimpleAppService.eta +0 -366
- package/templates/nest/TenantMiddleware.eta +0 -34
- package/templates/nest/UserProvider.eta +0 -127
- package/templates/nest/app.controller.eta +0 -12
- package/templates/nest/app.module.eta +0 -64
- package/templates/nest/app.service.eta +0 -8
- package/templates/nest/inputvalidation-exception.eta +0 -6
- package/templates/nest/nest.env.eta +0 -28
- package/templates/nest/nest.main.eta +0 -31
- package/templates/nuxt/components.crudsimple.vue.eta +0 -124
- package/templates/nuxt/components.menus.vue.eta +0 -35
- package/templates/nuxt/env.eta +0 -17
- package/templates/nuxt/pages.[xorg].index.vue.eta +0 -20
- package/templates/nuxt/pages.index.vue.eta +0 -72
- package/templates/nuxt/pages.login.vue.eta +0 -20
- package/templates/nuxt/plugins.simpleapp.ts.eta +0 -88
- package/templates/nuxt/server.api.auth[...].ts.eta +0 -233
- package/templates/nuxt/tailwind.css.eta +0 -49
- /package/templates/basic/{apischema.eta → nest/apischema.ts.eta} +0 -0
- /package/templates/basic/{jsonschema.eta → nest/jsonschema.ts.eta} +0 -0
- /package/templates/basic/{pageindexwithid.vue.eta → nuxt/pages.[id].vue.eta} +0 -0
- /package/templates/nest/{oauth2-redirect.eta → public_html/oauth2-redirect.html.eta} +0 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and regenerate this file.
|
|
5
|
+
* last change 2023-09-23
|
|
6
|
+
* Author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
import {
|
|
9
|
+
Controller,
|
|
10
|
+
Get,
|
|
11
|
+
Put,
|
|
12
|
+
Post,
|
|
13
|
+
Delete,
|
|
14
|
+
Body,
|
|
15
|
+
Query,
|
|
16
|
+
Param,
|
|
17
|
+
Type,
|
|
18
|
+
Res,
|
|
19
|
+
Req,
|
|
20
|
+
HttpStatus
|
|
21
|
+
} from '@nestjs/common';
|
|
22
|
+
import { SimpleAppAbstractController } from './simpleapp.controller';
|
|
23
|
+
import { <%= it.typename %>Service } from '../../services/<%= it.doctype %>.service';
|
|
24
|
+
import * as <%= it.doctype %>type from '../types/<%= it.doctype %>.type';
|
|
25
|
+
import {SearchBody} from '../types';
|
|
26
|
+
import {ApiSearchBody} from '../apischemas';
|
|
27
|
+
import * as <%= it.doctype %>apischema from '../apischemas/<%= it.doctype %>.apischema';
|
|
28
|
+
import { ApiTags, ApiBody, ApiResponse,ApiOperation,ApiQuery } from '@nestjs/swagger';
|
|
29
|
+
import {Roles} from '../commons/roles/roles.decorator'
|
|
30
|
+
import {Role} from '../commons/roles/roles.enum'
|
|
31
|
+
import { Response } from 'express';
|
|
32
|
+
import {AppUser} from '../commons/decorators/appuser.decorator'
|
|
33
|
+
import {UserContext} from '../commons/user.context'
|
|
34
|
+
|
|
35
|
+
<% let superadmindoctype = ['tenant','globaluser'] %>
|
|
36
|
+
const doctype = '<%= it.doctype %>'.toUpperCase();
|
|
37
|
+
@ApiTags(doctype)
|
|
38
|
+
@Controller(doctype.toLowerCase())
|
|
39
|
+
export class <%= it.typename %>Controller extends SimpleAppAbstractController<
|
|
40
|
+
<%= it.typename %>Service,
|
|
41
|
+
<%= it.doctype %>apischema.<%= it.typename %>,
|
|
42
|
+
<%= it.doctype %>type.<%= it.typename %>
|
|
43
|
+
> {
|
|
44
|
+
constructor(service: <%= it.typename %>Service) {
|
|
45
|
+
super(service);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Get()
|
|
49
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
50
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
51
|
+
<%}else{%>
|
|
52
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_search`%>)
|
|
53
|
+
<%}%>
|
|
54
|
+
@ApiResponse({
|
|
55
|
+
status: 200,
|
|
56
|
+
description: 'Found',
|
|
57
|
+
type: String //[<%= it.fullApiSchemaName%>]
|
|
58
|
+
})
|
|
59
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
60
|
+
@ApiOperation({ operationId: 'runList', description:"Say hello only" })
|
|
61
|
+
async list(@AppUser() appuser: UserContext) {
|
|
62
|
+
return `Hello, welcome to ${ this.service.getDocumentName()}`//this._list(appuser);
|
|
63
|
+
}
|
|
64
|
+
//autocomplete shall above :id
|
|
65
|
+
@Get('/autocomplete')
|
|
66
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
67
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
68
|
+
<%}else{%>
|
|
69
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.User)
|
|
70
|
+
<%}%>
|
|
71
|
+
@ApiResponse({
|
|
72
|
+
status: 200,
|
|
73
|
+
description: 'Found',
|
|
74
|
+
type: ()=>[{id:'100',label:'label1'}],
|
|
75
|
+
})
|
|
76
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
77
|
+
@ApiOperation({ operationId: 'autoComplete',description:"retrieve array of {_id, code, name}" })
|
|
78
|
+
async autoComplete(@AppUser() appuser: UserContext,@Query('keyword') keyword: string) {
|
|
79
|
+
return this._autocomplete(appuser,keyword);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@Post()
|
|
85
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
86
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_create`%>)
|
|
87
|
+
<%}else{%>
|
|
88
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_create`%>)
|
|
89
|
+
<%}%>
|
|
90
|
+
@ApiResponse({
|
|
91
|
+
status: 201,
|
|
92
|
+
description: 'success',
|
|
93
|
+
type: <%= it.fullApiSchemaName%>
|
|
94
|
+
})
|
|
95
|
+
@ApiResponse({ status: 400, description: 'bad request' })
|
|
96
|
+
@ApiResponse({ status: 500, description: 'internal error' })
|
|
97
|
+
@ApiBody({ description: 'Data',type:<%= it.fullApiSchemaName%> })
|
|
98
|
+
@ApiOperation({ operationId: 'runCreate' })
|
|
99
|
+
async create(@AppUser() appuser: UserContext,@Body() data: <%= it.fullApiSchemaName%>) {
|
|
100
|
+
return await this._create(appuser,data)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Post('/search')
|
|
104
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
105
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
106
|
+
<%}else{%>
|
|
107
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_search`%>)
|
|
108
|
+
<%}%>
|
|
109
|
+
@ApiResponse({
|
|
110
|
+
status: 200,
|
|
111
|
+
description: 'success',
|
|
112
|
+
type: [<%= it.fullApiSchemaName%>]
|
|
113
|
+
})
|
|
114
|
+
@ApiResponse({ status: 400, description: 'bad request' })
|
|
115
|
+
@ApiResponse({ status: 500, description: 'internal error' })
|
|
116
|
+
@ApiBody({ description: 'Data', type: ApiSearchBody })
|
|
117
|
+
@ApiOperation({ operationId: 'runSearch' })
|
|
118
|
+
async search(@AppUser() appuser: UserContext,@Body() data: SearchBody) {
|
|
119
|
+
return await this._search(appuser,data)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
/***************************** begin x-document-api definations *****************************************/
|
|
124
|
+
|
|
125
|
+
<% for(let i=0;i<it.apiSettings.length;i++){%>
|
|
126
|
+
<% let api = it.apiSettings[i] %>
|
|
127
|
+
<%~ `@${capitalizeFirstLetter(api.method)}('${api.entrypoint}')`%>
|
|
128
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
129
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_${api.action}`%>,
|
|
130
|
+
<%if(api.requiredrole && api.requiredrole.length>0) { %>
|
|
131
|
+
<% for(let r=0;r<api.requiredrole.length;r++){%>Role.<%=api.requiredrole[r]%>,<%}%>
|
|
132
|
+
<%}%>
|
|
133
|
+
)
|
|
134
|
+
<%}else{%>
|
|
135
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_${api.action}`%>,
|
|
136
|
+
<%if(api.requiredrole && api.requiredrole.length>0) { %>
|
|
137
|
+
<% for(let r=0;r<api.requiredrole.length;r++){%>Role.<%=api.requiredrole[r]%>,<%}%>
|
|
138
|
+
<%}%>
|
|
139
|
+
)
|
|
140
|
+
<%}%>
|
|
141
|
+
|
|
142
|
+
@ApiResponse({status: 200,description: '<%=api.description%>' ,type: Object })
|
|
143
|
+
@ApiResponse({status: 418,description: 'undefine bpmn,setDocumentStatus or bpmn'})
|
|
144
|
+
@ApiOperation({ operationId: '<%=api.execute ??api.action%>' })
|
|
145
|
+
<% if(api.querypara && api.querypara.length>0) {%>
|
|
146
|
+
<%for(let q=0;q<api.querypara.length; q++){%>
|
|
147
|
+
@ApiQuery({name: "<%=api['querypara'][q]%>",required: false,type: String})
|
|
148
|
+
<%}%>
|
|
149
|
+
<%}%>
|
|
150
|
+
async <%=api.execute??api.action %>(@AppUser() appuser: UserContext,@Res() res:Response,<% if(api.entrypoint && api.entrypoint.includes(':')) {%>
|
|
151
|
+
<%let subpath = api.entrypoint.split('/')%>
|
|
152
|
+
<% for(let a=0;a<subpath.length;a++){%>
|
|
153
|
+
<%const partstr = subpath[a]%>
|
|
154
|
+
<%if(partstr.includes(':')){%>
|
|
155
|
+
<% const paraname = partstr.replace(':','') %>
|
|
156
|
+
@Param('<%=paraname%>') <%=paraname%>: string,
|
|
157
|
+
<%}%>
|
|
158
|
+
<%}%>
|
|
159
|
+
<%}%>
|
|
160
|
+
<% if(api.querypara && api.querypara.length>0) {%>
|
|
161
|
+
<%for(let q=0;q<api.querypara.length; q++){%>
|
|
162
|
+
<% const qp = api['querypara'][q] %>
|
|
163
|
+
@Query('<%=qp%>') <%=qp%>: string,
|
|
164
|
+
<%}%>
|
|
165
|
+
<%}%>
|
|
166
|
+
){
|
|
167
|
+
<%if(api.execute){%>
|
|
168
|
+
const result = await this.service.<%=api.execute%>(appuser,<% if(api.entrypoint && api.entrypoint.includes(':')) {%>
|
|
169
|
+
<%let subpath = api.entrypoint.split('/')%>
|
|
170
|
+
<% for(let a=0;a<subpath.length;a++){%>
|
|
171
|
+
<%const partstr = subpath[a]%>
|
|
172
|
+
<%if(partstr.includes(':')){%>
|
|
173
|
+
<% const paraname = partstr.replace(':','') %>
|
|
174
|
+
<%=paraname%>,
|
|
175
|
+
<%}%>
|
|
176
|
+
<%}%>
|
|
177
|
+
<%}%>
|
|
178
|
+
<% if(api.querypara && api.querypara.length>0) {%>
|
|
179
|
+
<%for(let q=0;q<api.querypara.length; q++){%>
|
|
180
|
+
<%= api['querypara'][q] %>,
|
|
181
|
+
<%}%>
|
|
182
|
+
<%}%>
|
|
183
|
+
)
|
|
184
|
+
res.status(HttpStatus.OK).send(result)
|
|
185
|
+
<%} else if (api.bpmn){ %>
|
|
186
|
+
const result = await this.service.executeWorkFlow(appuser,id,'<%=api.bpmn%>','');
|
|
187
|
+
res.status(HttpStatus.OK).send(result)
|
|
188
|
+
<%} else if (api.setDocumentStatus){ %>
|
|
189
|
+
return await this.service.setDocumentStatus(appuser,id,'<%=api.setDocumentStatus%>');
|
|
190
|
+
<%} else {%>
|
|
191
|
+
res.status(HttpStatus.I_AM_A_TEAPOT).send('execute api"<%=api.action%>", but undefine property bpmn/setDocumentStatus/execute in jsonschema')
|
|
192
|
+
<%}%>
|
|
193
|
+
}
|
|
194
|
+
<%}%>
|
|
195
|
+
/***************************** end x-document-api definations *****************************************/
|
|
196
|
+
@Get(':id')
|
|
197
|
+
|
|
198
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
199
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_search`%>)
|
|
200
|
+
<%}else{%>
|
|
201
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_search`%>)
|
|
202
|
+
<%}%>
|
|
203
|
+
@ApiResponse({
|
|
204
|
+
status: 200,
|
|
205
|
+
description: 'Founds',
|
|
206
|
+
type: <%= it.fullApiSchemaName%>
|
|
207
|
+
})
|
|
208
|
+
@ApiResponse({ status: 404, description: 'Document not found' })
|
|
209
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
210
|
+
@ApiOperation({ operationId: 'runFindOne' })
|
|
211
|
+
async findOne(@AppUser() appuser: UserContext,@Param('id') id: string) {
|
|
212
|
+
return await this._findOne(appuser,id);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@Put(':id')
|
|
217
|
+
@ApiResponse({
|
|
218
|
+
status: 200,
|
|
219
|
+
description: 'success',
|
|
220
|
+
})
|
|
221
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
222
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_update`%>)
|
|
223
|
+
<%}else{%>
|
|
224
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_update`%>)
|
|
225
|
+
<%}%>
|
|
226
|
+
@ApiResponse({ status: 404, description: 'Document not found' })
|
|
227
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
228
|
+
@ApiBody({ description: 'Data',type: <%= it.fullApiSchemaName%> })
|
|
229
|
+
@ApiOperation({ operationId: 'runUpdate' })
|
|
230
|
+
async update(@AppUser() appuser: UserContext,@Param('id') id: string, @Body() data: <%= it.fullApiSchemaName%>) {
|
|
231
|
+
return await this._update(appuser,id, data) ;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Delete(':id')
|
|
235
|
+
<%if(superadmindoctype.includes(it.doctype)){%>
|
|
236
|
+
@Roles(Role.SuperAdmin,Role.<%= `${it.typename}_delete`%>)
|
|
237
|
+
<%}else{%>
|
|
238
|
+
@Roles(Role.SuperAdmin,Role.SuperUser,Role.<%= `${it.typename}_delete`%>)
|
|
239
|
+
<%}%>
|
|
240
|
+
@ApiResponse({
|
|
241
|
+
status: 200,
|
|
242
|
+
description: 'success',
|
|
243
|
+
type: <%= it.fullApiSchemaName%>
|
|
244
|
+
})
|
|
245
|
+
@ApiResponse({ status: 404, description: 'Document not found' })
|
|
246
|
+
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
247
|
+
@ApiOperation({ operationId: 'runDelete' })
|
|
248
|
+
async delete(@AppUser() appuser: UserContext,@Param('id') id: string) {
|
|
249
|
+
return this._delete(appuser,id);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
<%Object.keys(it.models).forEach(function(modelname) { %>
|
|
3
|
+
export const Default<%=modelname%> = (uuid:string)=>{
|
|
4
|
+
// <%~ JSON.stringify(it.models[modelname].model) %>
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
_id : uuid,
|
|
8
|
+
<%Object.keys(it.models[modelname].model).forEach(function(key){%>
|
|
9
|
+
<%let field=it.models[modelname].model[key]%>
|
|
10
|
+
|
|
11
|
+
<%if(key=='_id'){ %>
|
|
12
|
+
// skip cause already hardcoded
|
|
13
|
+
<%}else if(key=='tenantId'){ %>
|
|
14
|
+
tenantId : 0,//it will override by save handle
|
|
15
|
+
<%}else if(key=='orgId'){ %>
|
|
16
|
+
orgId : 0, //it will override by save handle
|
|
17
|
+
<%}else if(key=='branchId'){ %>
|
|
18
|
+
branchId : 0, //it will override by save handle
|
|
19
|
+
<%}else if(key=='doctype'){ %>
|
|
20
|
+
doctype : '<%=it.doctype.toUpperCase()%>',
|
|
21
|
+
<% } else if(typeof field.default !='undefined' && field.type=='string'){%>
|
|
22
|
+
<%=key%> : '<%= field.default %>',
|
|
23
|
+
<%} else if(typeof field.default !='undefined'){%>
|
|
24
|
+
<%=key%> : <%= field.default %>,
|
|
25
|
+
<%} else if(field.type=='boolean' ){%>
|
|
26
|
+
<%=key%> :false ,
|
|
27
|
+
<%} else if(typeof field=='string'){%>
|
|
28
|
+
<%=key%> : Default<%= field %>(''),
|
|
29
|
+
<%} else if(field.type=='string'){%>
|
|
30
|
+
<%=key%> : '<%= field.default %>',
|
|
31
|
+
|
|
32
|
+
<%} else if(Array.isArray(field) && ['string','integer','number','boolean'].includes(field[0])) {%>
|
|
33
|
+
<%=key%> : <<%=field[0]%>[]>[], //typeof field == array <%~JSON.stringify(field)%>
|
|
34
|
+
<%} else if(Array.isArray(field)) {%>
|
|
35
|
+
<%=key%> : [Default<%=field[0]%>(crypto.randomUUID())], //typeof field == array <%~JSON.stringify(field)%>
|
|
36
|
+
<%} else {%>
|
|
37
|
+
<%=key%> : <%=field.default%>, //else <%= typeof field %>
|
|
38
|
+
<%}%>
|
|
39
|
+
<%})%>
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
<%})%>
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
<% const schema = it.schema %>
|
|
10
10
|
<% const typeclass = it.doctype+'type' %>
|
|
11
11
|
import { Schema } from 'mongoose';
|
|
12
|
-
import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from '
|
|
12
|
+
import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from '../types/<%= it.doctype %>.type';
|
|
13
13
|
const schemasetting = {
|
|
14
14
|
|
|
15
15
|
<%Object.keys(it.schema).forEach(function(key) { %>
|
|
16
16
|
|
|
17
17
|
<% if(key == '_id'){%>
|
|
18
|
-
|
|
18
|
+
<%= key %>: {type:'string', required:true}, //force _id as string
|
|
19
19
|
<% } else if(typeof schema[key] == 'string') {%>
|
|
20
20
|
<%= key %>: {type: <<%=schema[key]%>>{}, required:false}, //object
|
|
21
21
|
<% }else if( Array.isArray( schema[key])){%>
|
|
@@ -28,8 +28,21 @@ const schemasetting = {
|
|
|
28
28
|
<%}) %>
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const <%= it.
|
|
31
|
+
export const <%= capitalizeFirstLetter(it.name) %>MongoSchema = new Schema(schemasetting,{collection: '<%= it.name %>'})
|
|
32
32
|
<%if(it.requireautocomplete){%>
|
|
33
|
-
|
|
34
|
-
.index({
|
|
33
|
+
<% if(it.doctype=='org') {%>
|
|
34
|
+
.index({tenantId:1,orgId:1},{unique:true})
|
|
35
|
+
<%} else {%>
|
|
36
|
+
.index({<%=it.autocompletecode%>:1,orgId:1},{unique:true})
|
|
37
|
+
.index({<%=it.autocompletename%>:1,orgId:1})
|
|
38
|
+
<%}%>
|
|
35
39
|
<%}%>
|
|
40
|
+
|
|
41
|
+
<% if(it.foreignkeys){%>
|
|
42
|
+
<%Object.keys(it.foreignkeys).forEach(function(key) { %>
|
|
43
|
+
|
|
44
|
+
<%for(let i =0 ; i < it.foreignkeys[key].length; i++){%>
|
|
45
|
+
.index({'<%= it.foreignkeys[key][i].replace('$.','').replaceAll('[*]','') %>':1})
|
|
46
|
+
<%}%>
|
|
47
|
+
<%})%>
|
|
48
|
+
<%}%>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and regenerate this file.
|
|
5
|
+
* last change 2023-09-23
|
|
6
|
+
* Author: Ks Tan
|
|
7
|
+
*/
|
|
8
|
+
import { UserContext } from '../commons/user.context'
|
|
9
|
+
import { Injectable } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import { Model } from 'mongoose';
|
|
12
|
+
import {<%= it.typename%>JsonSchema } from '../jsonschemas/<%= it.doctype %>.jsonschema'
|
|
13
|
+
import { SimpleAppService,IsolationType,HookType } from './simpleapp.processor';
|
|
14
|
+
import {DocNumberFormatGenerator} from '../commons/docnogenerator.service'
|
|
15
|
+
import { <%Object.keys(it.models).forEach(function(key) { %> <%=key %>, <%})%> } from '../types/<%= it.doctype %>.type';
|
|
16
|
+
import { <%Object.keys(it.models).forEach(function(modelname) { %> Default<%=modelname%>, <%})%> } from '../defaults/<%= it.doctype %>.default'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
<%if(it.jsonschema['x-import-lib']) {%>
|
|
20
|
+
<%let libs = it.jsonschema['x-import-lib'] %>
|
|
21
|
+
<%for(let l = 0; l< libs.length; l++) { %>
|
|
22
|
+
import * as <%=libs[l].importAs %> from '<%=libs[l].importFrom %>'
|
|
23
|
+
<%}%>
|
|
24
|
+
<%}%>
|
|
25
|
+
|
|
26
|
+
@Injectable()
|
|
27
|
+
export class <%= it.typename %>Processor extends SimpleAppService<<%= it.typename %>> {
|
|
28
|
+
protected documentIdentityCode='<%~ it.autocompletecode %>'
|
|
29
|
+
protected documentIdentityLabel='<%~ it.autocompletename %>'
|
|
30
|
+
protected withDocNumberFormat= <%= it.hasdocformat %>
|
|
31
|
+
|
|
32
|
+
protected foreignkeys = <%~ JSON.stringify(it.foreignkeys)%>
|
|
33
|
+
|
|
34
|
+
constructor(mydoc: Model<<%= it.typename %>>, docnogenerator:DocNumberFormatGenerator) {
|
|
35
|
+
super('<%= it.doctype.toUpperCase() %>','<%= it.name %>',mydoc,IsolationType.<%=it.isolationtype%>,docnogenerator);
|
|
36
|
+
this.setSchema(<%= it.typename%>JsonSchema)
|
|
37
|
+
this.setData(Default<%=it.typename%>(crypto.randomUUID()))
|
|
38
|
+
<%if(it.moreAutoComplete.length>0){%>
|
|
39
|
+
this.addAutoCompleteField({
|
|
40
|
+
<%Object.keys(it.moreAutoComplete).forEach(function(key) { %>
|
|
41
|
+
<% let f=it.moreAutoComplete[key] %>
|
|
42
|
+
<%~ `${f}: '${f}'` %>,
|
|
43
|
+
<%})%>
|
|
44
|
+
})
|
|
45
|
+
<%}%>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
reCalculateValue(){
|
|
50
|
+
console.log('trigger new recalculate')
|
|
51
|
+
const data = this.getData()
|
|
52
|
+
|
|
53
|
+
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
|
|
54
|
+
<%let obj = it.jsonschema.properties[key]%>
|
|
55
|
+
<%if(obj['x-compute']){%> //x-compute first level field
|
|
56
|
+
|
|
57
|
+
data.<%=key%> = <%= obj['x-compute'].function %>(
|
|
58
|
+
<% if(obj['x-compute'].paramters){ %>
|
|
59
|
+
<% let p = obj['x-compute'].paramters %>
|
|
60
|
+
<%for(let j=0; j<p.length; j++){%>
|
|
61
|
+
<%= p[j].replace('@data','data') %>,
|
|
62
|
+
<%}%>
|
|
63
|
+
<%}%>
|
|
64
|
+
)
|
|
65
|
+
<%}%>
|
|
66
|
+
<%if(obj.type=='array' && obj.items.type=='object'){%>
|
|
67
|
+
// process compute for 2nd level sub tables
|
|
68
|
+
for(let index=0;index<data.<%=key%>.length;index++){
|
|
69
|
+
<%Object.keys(obj.items.properties).forEach(function(subkey) { %>
|
|
70
|
+
<%let subobj = obj.items.properties[subkey]%>
|
|
71
|
+
<%if(subobj['x-compute']){%>
|
|
72
|
+
|
|
73
|
+
data.<%=key%>[index].<%=subkey%> = <%= subobj['x-compute'].function %>(
|
|
74
|
+
<% if(subobj['x-compute'].paramters){ %>
|
|
75
|
+
<% let subp = subobj['x-compute'].paramters %>
|
|
76
|
+
<%for(let k=0; k<subp.length; k++){%>
|
|
77
|
+
<%= subp[k].replace('@data','data').replace('@index','index') %>,
|
|
78
|
+
<%}%>
|
|
79
|
+
<%}%>
|
|
80
|
+
)
|
|
81
|
+
<%}%>
|
|
82
|
+
|
|
83
|
+
<% if(subobj.type=='array' && subobj.items && subobj.items.type=='object'){ %>
|
|
84
|
+
// process compute for 3rd level sub tables
|
|
85
|
+
for(let index2=0;index<data.<%=key%>[index].length;index2++){
|
|
86
|
+
<%Object.keys(subobj.items.properties).forEach(function(sub2key) { %>
|
|
87
|
+
<%let sub2obj = subobj.items.properties[sub2key]%>
|
|
88
|
+
<%if(sub2obj['x-compute']){%> //x-compute 3rd level field
|
|
89
|
+
data.<%=key%>[index].<%=subkey%>[index2].<%=sub2key%> = <%= sub2obj['x-compute'].function %>(
|
|
90
|
+
<% if(sub2obj['x-compute'].paramters){ %>
|
|
91
|
+
<% let sub2p = sub2obj['x-compute'].paramters %>
|
|
92
|
+
<%for(let l=0; l<sub2p.length; l++){%>
|
|
93
|
+
<%= sub2p[l].replace('@data','data').replace('@index','index').replace('@index2','index2') %>,
|
|
94
|
+
<%}%>
|
|
95
|
+
<%}%>
|
|
96
|
+
)
|
|
97
|
+
<%}%>
|
|
98
|
+
<%if(sub2obj.type=='array' && sub2obj.items && sub2obj.items.type=='object'){%>
|
|
99
|
+
// process compute for 4rd level sub tables
|
|
100
|
+
for(let index3=0;index<data.<%=key%>[index].<%=subkey%>[index2].length;index3++){
|
|
101
|
+
<%Object.keys(sub2obj.items.properties).forEach(function(sub3key) { %>
|
|
102
|
+
<%let sub3obj = sub2obj.items.properties[sub3key]%>
|
|
103
|
+
<%if(sub3obj['x-compute']){%> //x-compute 4th level field
|
|
104
|
+
data.<%=key%>[index].<%=subkey%>[index2].<%=sub2key%>.[index3].<%=sub3key%> = <%= sub3obj['x-compute'].function %>(
|
|
105
|
+
<% if(sub3obj['x-compute'].paramters){ %>
|
|
106
|
+
<% let sub3p = sub3obj['x-compute'].paramters %>
|
|
107
|
+
<%for(let m=0; m<sub3p.length; m++){%>
|
|
108
|
+
<%= subp[m].replace('@data','data').replace('@index','index').replace('@index2','index2').replace('@index3','index3') %>,
|
|
109
|
+
<%}%>
|
|
110
|
+
<%}%>
|
|
111
|
+
)
|
|
112
|
+
<%}%>
|
|
113
|
+
|
|
114
|
+
<%})%>
|
|
115
|
+
<%} /* process compute for 4rd level sub tables */%>
|
|
116
|
+
<%})%>
|
|
117
|
+
}
|
|
118
|
+
<%} // process compute for 3rd level sub tables%>
|
|
119
|
+
<%}) %>
|
|
120
|
+
}
|
|
121
|
+
<%} /*process compute for 2nd level sub tables*/%>
|
|
122
|
+
<%}) %>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
/***************************** additional execute *****************************************/
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator.
|
|
3
|
+
* It will not override by generator
|
|
4
|
+
* last change 2023-09-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
8
|
+
import { Model } from 'mongoose';
|
|
9
|
+
import { Injectable } from '@nestjs/common';
|
|
10
|
+
import { UserContext } from '../generate/commons/user.context';
|
|
11
|
+
import {DocNumberFormatGenerator} from '../generate/commons/docnogenerator.service'
|
|
12
|
+
import { <%= it.typename %>Processor } from '../generate/processors/<%= it.doctype %>.processor';
|
|
13
|
+
import { <%= it.typename %>} from '../generate/types/<%= it.doctype %>.type';
|
|
14
|
+
export { <%= it.typename %>} from '../generate/types/<%= it.doctype %>.type';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@Injectable()
|
|
18
|
+
export class <%= it.typename %>Service extends <%= it.typename %>Processor {
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
@InjectModel('<%= it.typename %>') mydoc: Model<<%= it.typename %>>,
|
|
22
|
+
docnogenerator:DocNumberFormatGenerator
|
|
23
|
+
){
|
|
24
|
+
super(mydoc,docnogenerator)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// hook = async (appuser:UserContext,type: string, data?: any) => {
|
|
28
|
+
// switch(type){
|
|
29
|
+
// case 'init':
|
|
30
|
+
// break;
|
|
31
|
+
// case 'beforeSearch':
|
|
32
|
+
// break;
|
|
33
|
+
// case 'afterSearch':
|
|
34
|
+
// break;
|
|
35
|
+
// case 'beforeValidation':
|
|
36
|
+
// break;
|
|
37
|
+
// case 'afterValidation':
|
|
38
|
+
// break;
|
|
39
|
+
// case 'beforeCreate':
|
|
40
|
+
// break;
|
|
41
|
+
// case 'afterCreate':
|
|
42
|
+
// break;
|
|
43
|
+
// case 'beforeUpdate':
|
|
44
|
+
// break;
|
|
45
|
+
// case 'afterUpdate':
|
|
46
|
+
// break;
|
|
47
|
+
// case 'beforeDelete':
|
|
48
|
+
// break;
|
|
49
|
+
// case 'afterDelete':
|
|
50
|
+
// break;
|
|
51
|
+
// case 'beforeDeleteMany':
|
|
52
|
+
// break;
|
|
53
|
+
// case 'afterDeleteMany':
|
|
54
|
+
// break;
|
|
55
|
+
// case 'beforeFetchRecord':
|
|
56
|
+
// break;
|
|
57
|
+
// case 'afterFetchRecord':
|
|
58
|
+
// break;
|
|
59
|
+
// default:
|
|
60
|
+
// break;
|
|
61
|
+
// }
|
|
62
|
+
// return true;
|
|
63
|
+
// };
|
|
64
|
+
}
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
<%Object.keys(schema.model).forEach(function(key){ %>
|
|
14
14
|
<% const obj = schema.model[key] %>
|
|
15
15
|
<% if(typeof obj == 'string') {%>
|
|
16
|
-
<%= key
|
|
16
|
+
<%= key %> <%if(obj.required){%>?<%}%>: <%= obj %>; //child object
|
|
17
17
|
<% }else if( Array.isArray( obj)){%>
|
|
18
|
-
<%= key
|
|
18
|
+
<%= key %><%if(obj.required){%>?<%}%>: <%= obj[0] %>[]; //array
|
|
19
19
|
<% }else if( obj.type == 'array'){%>
|
|
20
|
-
<%= key
|
|
20
|
+
<%= key %><%if(obj.required){%>?<%}%>: <%= obj.items.type %>[]; //array
|
|
21
21
|
<% }else{%>
|
|
22
22
|
<%= key %> <% if(!obj.required || obj.required==false){%>?<%}%>: <%= obj.type %>; // <%~ JSON.stringify(obj) %>
|
|
23
23
|
<% } %>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<%Object.keys(it.models).forEach(function(modelname) { %>
|
|
2
|
+
export const Default<%=modelname%> = (uuid:string)=>{
|
|
3
|
+
// <%~ JSON.stringify(it.models[modelname].model) %>
|
|
4
|
+
|
|
5
|
+
return {
|
|
6
|
+
_id : uuid,
|
|
7
|
+
<%Object.keys(it.models[modelname].model).forEach(function(key){%>
|
|
8
|
+
<%let field=it.models[modelname].model[key]%>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<%if(key=='_id'){ %>
|
|
12
|
+
// skip cause already hardcoded
|
|
13
|
+
<%}else if(key=='doctype'){ %>
|
|
14
|
+
doctype : '<%=it.doctype.toUpperCase()%>',
|
|
15
|
+
<%}else if(key=='tenantId'){ %>
|
|
16
|
+
tenantId : getUserProfile().tenantId,
|
|
17
|
+
<%}else if(key=='orgId'){ %>
|
|
18
|
+
orgId : getUserProfile().orgId,
|
|
19
|
+
<%}else if(key=='branchId'){ %>
|
|
20
|
+
branchId : getUserProfile().branchId,
|
|
21
|
+
<% } else if(typeof field.default !='undefined' && field.type=='string'){%>
|
|
22
|
+
<%=key%> : '<%= field.default %>',
|
|
23
|
+
<%} else if(typeof field.default !='undefined'){%>
|
|
24
|
+
<%=key%> : <%= field.default %>,
|
|
25
|
+
<%} else if(field.type=='boolean' ){%>
|
|
26
|
+
<%=key%> :false ,
|
|
27
|
+
<%} else if(typeof field=='string'){%>
|
|
28
|
+
<%=key%> : Default<%= field %>(''),
|
|
29
|
+
<%} else if(field.type=='string'){%>
|
|
30
|
+
<%=key%> : '<%= field.default %>',
|
|
31
|
+
|
|
32
|
+
<%} else if(Array.isArray(field) && ['string','integer','number','boolean'].includes(field[0])) {%>
|
|
33
|
+
<%=key%> : <<%=field[0]%>[]>[], //typeof field == array <%~JSON.stringify(field)%>
|
|
34
|
+
<%} else if(Array.isArray(field)) {%>
|
|
35
|
+
<%=key%> : [Default<%=field[0]%>(crypto.randomUUID())], //typeof field == array <%~JSON.stringify(field)%>
|
|
36
|
+
<%} else {%>
|
|
37
|
+
<%=key%> : <%=field.default%>, //else <%= typeof field %>
|
|
38
|
+
<%}%>
|
|
39
|
+
<%})%>
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
<%})%>
|