@simitgroup/simpleapp-generator 1.5.1-alpha → 1.6.0-alpha
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/dist/buildinschemas/branch.d.ts.map +1 -1
- package/dist/buildinschemas/branch.js +10 -0
- package/dist/buildinschemas/branch.js.map +1 -1
- package/dist/buildinschemas/index.d.ts +2 -0
- package/dist/buildinschemas/index.d.ts.map +1 -1
- package/dist/buildinschemas/index.js +5 -1
- package/dist/buildinschemas/index.js.map +1 -1
- package/dist/buildinschemas/keyvaluepair.d.ts +3 -0
- package/dist/buildinschemas/keyvaluepair.d.ts.map +1 -0
- package/dist/buildinschemas/keyvaluepair.js +28 -0
- package/dist/buildinschemas/keyvaluepair.js.map +1 -0
- package/dist/buildinschemas/message.d.ts +3 -0
- package/dist/buildinschemas/message.d.ts.map +1 -0
- package/dist/buildinschemas/message.js +34 -0
- package/dist/buildinschemas/message.js.map +1 -0
- package/dist/buildinschemas/organization.d.ts.map +1 -1
- package/dist/buildinschemas/organization.js +18 -1
- package/dist/buildinschemas/organization.js.map +1 -1
- package/dist/buildinschemas/systemmessage.d.ts +3 -0
- package/dist/buildinschemas/systemmessage.d.ts.map +1 -0
- package/dist/buildinschemas/systemmessage.js +43 -0
- package/dist/buildinschemas/systemmessage.js.map +1 -0
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +3 -2
- package/dist/framework.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +37 -9
- package/dist/generate.js.map +1 -1
- package/dist/processors/bpmnbuilder.d.ts.map +1 -1
- package/dist/processors/bpmnbuilder.js +23 -32
- package/dist/processors/bpmnbuilder.js.map +1 -1
- package/dist/processors/jrxmlbuilder.d.ts +3 -0
- package/dist/processors/jrxmlbuilder.d.ts.map +1 -0
- package/dist/processors/jrxmlbuilder.js +57 -0
- package/dist/processors/jrxmlbuilder.js.map +1 -0
- package/dist/type.d.ts +6 -0
- package/dist/type.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/buildinschemas/branch.ts +10 -0
- package/src/buildinschemas/index.ts +2 -0
- package/src/buildinschemas/keyvaluepair.ts +26 -0
- package/src/buildinschemas/organization.ts +18 -1
- package/src/buildinschemas/systemmessage.ts +42 -0
- package/src/framework.ts +3 -2
- package/src/generate.ts +41 -13
- package/src/processors/bpmnbuilder.ts +34 -38
- package/src/processors/jrxmlbuilder.ts +38 -0
- package/src/type.ts +7 -1
- package/templates/basic/nest/controller.ts.eta +34 -17
- package/templates/basic/nest/resolver.ts.eta +1 -1
- package/templates/basic/nest/service.ts.eta +22 -4
- package/templates/basic/nest/type.ts.eta +2 -2
- package/templates/basic/nuxt/pages.form.vue.eta +1 -1
- package/templates/basic/nuxt/pages.mobile.landing.vue.eta +4 -61
- package/templates/nest/src/printapi/api/.gitignore.eta +4 -0
- package/templates/nest/src/printapi/api/.npmignore.eta +1 -0
- package/templates/nest/src/printapi/api/.openapi-generator/FILES.eta +8 -0
- package/templates/nest/src/printapi/api/.openapi-generator/VERSION.eta +1 -0
- package/templates/nest/src/printapi/api/.openapi-generator-ignore.eta +23 -0
- package/templates/nest/src/printapi/api/api.ts.eta +223 -0
- package/templates/nest/src/printapi/api/base.ts.eta +86 -0
- package/templates/nest/src/printapi/api/common.ts.eta +150 -0
- package/templates/nest/src/printapi/api/configuration.ts.eta +110 -0
- package/templates/nest/src/printapi/api/git_push.sh.eta +57 -0
- package/templates/nest/src/printapi/api/index.ts.eta +18 -0
- package/templates/nest/src/printapi/api/openapitools.json.eta +7 -0
- package/templates/nest/src/printapi/printapi.module.ts.eta +15 -0
- package/templates/nest/src/printapi/printapi.service.ts.eta +42 -0
- package/templates/nest/src/simpleapp/apischemas/index.ts._eta +11 -0
- package/templates/nest/src/simpleapp/generate/commons/roles/roles.enum.ts.eta +7 -0
- package/templates/nest/src/simpleapp/generate/commons/user.context.ts.eta +9 -9
- package/templates/nest/src/simpleapp/generate/processors/autoinc.processor.ts.eta +73 -0
- package/templates/nest/src/simpleapp/generate/processors/branch.processor.ts.eta +104 -0
- package/templates/nest/src/simpleapp/generate/processors/docno.processor.ts.eta +77 -0
- package/templates/nest/src/simpleapp/generate/processors/org.processor.ts.eta +115 -0
- package/templates/nest/src/simpleapp/generate/processors/perm.processor.ts.eta +71 -0
- package/templates/nest/src/simpleapp/generate/processors/simpleapp.processor.ts.eta +29 -9
- package/templates/nest/src/simpleapp/generate/processors/sysmsg.processor.ts.eta +49 -0
- package/templates/nest/src/simpleapp/generate/processors/tenant.processor.ts.eta +52 -0
- package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +10 -3
- package/templates/nest/src/simpleapp/generate/workflow/workflow.controller.ts.eta +2 -2
- package/templates/nest/src/simpleapp/generate/workflow/workflow.delegate.ts.eta +33 -28
- package/templates/nest/src/simpleapp/generate/workflow/workflow.service.ts.eta +95 -26
- package/templates/nest/src/simpleapp/generate/workflow/workflow.type.ts.eta +4 -4
- package/templates/nest/src/simpleapp/services/sysmsg.service.ts._etaxxx +43 -0
- package/templates/nest/src/simpleapp/services/userresolver.service.ts._eta +70 -0
- package/templates/nest/src/simpleapp/simpleapp.module.ts.eta +6 -2
- package/templates/nest/src/simpleapp/types/index.ts._eta +5 -0
- package/templates/nuxt/components/button/ButtonAction.vue._eta +11 -5
- package/templates/nuxt/components/form/{FormBranch.vue.eta → FormBranch.vue._eta} +1 -1
- package/templates/nuxt/components/image/ImageAvatar.vue.eta.vue +38 -0
- package/templates/nuxt/components/image/ImageOrganization.vue.eta.vue +40 -0
- package/templates/nuxt/components/image/ImageToBase64Uploader.vue.eta.vue +147 -0
- package/templates/nuxt/components/list/ListItem.vue.eta +24 -0
- package/templates/nuxt/components/list/ListMessages.vue.eta +89 -0
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +1 -1
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +93 -7
- package/templates/nuxt/components/text/TextBold.vue._eta +13 -0
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +11 -2
- package/templates/nuxt/composables/hotvalue.generate.ts.eta +30 -0
- package/templates/nuxt/composables/pusher.ts._eta +13 -0
- package/templates/nuxt/composables/stringHelper.generate.ts.eta +2 -3
- package/templates/nuxt/composables/sysmessage.generate.ts.eta +20 -0
- package/templates/nuxt/composables/workflow.generate.ts.eta +9 -4
- package/templates/nuxt/layouts/mobile.vue._eta +31 -42
- package/templates/nuxt/nuxt.config.ts._eta +2 -2
- package/templates/nuxt/othermodules.d.ts.eta +449 -0
- package/templates/nuxt/pages/[xorg]/mobile/organization/[id].vue._eta +40 -0
- package/templates/nuxt/pages/[xorg]/mobile/organization/{index.vue.eta → index.vue.aetaz} +16 -13
- package/templates/nuxt/pages/[xorg]/organization.vue.eta +21 -15
- package/templates/nuxt/plugins/40.pusher.ts.eta +18 -0
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +7 -1
- package/templates/nuxt/simpleapp/generate/commons/roles.ts.eta +4 -1
- package/templates/nuxt/types/schema.ts.eta +8 -1
- package/templates/nuxt/types/simpleappinput.ts.eta +3 -5
- package/templates/printformats/template.jrxml._eta +27 -0
- package/templates/project/groups/admin.json.eta +6 -1
- package/templates/project/jsonschemas/branch.json._eta +113 -0
- package/templates/project/jsonschemas/invoice.json._eta +5 -1
- package/templates/project/jsonschemas/organization.json._eta +111 -0
- package/templates/project/lang/default._json +70 -150
- package/templates/workflow/next/listener.ts.eta +6 -3
- package/tsconfig.tsbuildinfo +1 -1
- /package/templates/nest/src/simpleapp/services/{autoinc.service.ts.eta → autoinc.service.ts.etaxx} +0 -0
- /package/templates/nest/src/simpleapp/services/{branch.service.ts.eta → branch.service.ts.etaxxx} +0 -0
- /package/templates/nest/src/simpleapp/services/{docno.service.ts.eta → docno.service.ts.etaxxx} +0 -0
- /package/templates/nest/src/simpleapp/services/{org.service.ts.eta → org.service.ts.etaxxx} +0 -0
- /package/templates/nest/src/simpleapp/services/{perm.service.ts.eta → perm.service.ts.etaxxx} +0 -0
- /package/templates/nest/src/simpleapp/services/{tenant.service.ts.eta → tenant.service.ts.etaxxx} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
import { Injectable, Inject,InternalServerErrorException } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import * as jsonpath from 'jsonpath';
|
|
12
|
+
import { Model } from 'mongoose';
|
|
13
|
+
import { BranchJsonSchema } from '../jsonschemas/branch.jsonschema';
|
|
14
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
15
|
+
import { IsolationType } from '../types';
|
|
16
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
17
|
+
import { AutoincreamentService } from '../../services/autoinc.service';
|
|
18
|
+
import { alldocuments } from '../commons/dicts/documents';
|
|
19
|
+
import { Docnoformat, DocnoformatService } from '../../services/docno.service';
|
|
20
|
+
import { BranchOrganization, Branch,BranchHooks } from '../types/branch.type';
|
|
21
|
+
import {
|
|
22
|
+
DefaultBranchOrganization,
|
|
23
|
+
DefaultBranch,
|
|
24
|
+
} from '../defaults/branch.default';
|
|
25
|
+
|
|
26
|
+
@Injectable()
|
|
27
|
+
export class BranchProcessor extends SimpleAppService<Branch> {
|
|
28
|
+
@Inject(AutoincreamentService)
|
|
29
|
+
protected increament: AutoincreamentService;
|
|
30
|
+
@Inject(DocnoformatService)
|
|
31
|
+
private docnoservice: DocnoformatService;
|
|
32
|
+
protected strictIsolation = false;
|
|
33
|
+
protected documentIdentityCode = 'branchCode';
|
|
34
|
+
protected documentIdentityLabel = 'branchName';
|
|
35
|
+
protected hooks: BranchHooks = {
|
|
36
|
+
beforeCreate: async (appuser: UserContext, data: Branch) => await this.branchBeforeCreate(appuser,data),
|
|
37
|
+
afterCreate: async (appuser: UserContext, data: Branch) => await this.branchAfterCreate(appuser,data),
|
|
38
|
+
};
|
|
39
|
+
protected foreignkeys = { organization: ['$.organization._id'] };
|
|
40
|
+
constructor(mydoc: Model<Branch>) {
|
|
41
|
+
super('BRANCH', 'branch', mydoc, IsolationType.org);
|
|
42
|
+
this.setSchema(BranchJsonSchema);
|
|
43
|
+
this.setData(DefaultBranch(crypto.randomUUID()));
|
|
44
|
+
this.addAutoCompleteField({
|
|
45
|
+
branchId: 'branchId',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
reCalculateValue(data: Branch) {
|
|
50
|
+
//console.log('trigger new recalculate')
|
|
51
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/***************************** additional execute *****************************************/
|
|
55
|
+
async branchBeforeCreate(appuser: UserContext, data: Branch) {
|
|
56
|
+
const searchresult = await this.increament.runGenerateNextNo(
|
|
57
|
+
appuser,
|
|
58
|
+
'branch',
|
|
59
|
+
'branchId',
|
|
60
|
+
);
|
|
61
|
+
data.branchId = searchresult.nextno;
|
|
62
|
+
}
|
|
63
|
+
async branchAfterCreate(appuser: UserContext, data: Branch) {
|
|
64
|
+
await this.generateDefaultDocNumbers(appuser, data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
generateDefaultDocNumbers = async (appuser, data) => {
|
|
68
|
+
const branchName = data.branchName;
|
|
69
|
+
const branchCode = data.branchCode;
|
|
70
|
+
const recordId = data._id;
|
|
71
|
+
const branchId = data.branchId;
|
|
72
|
+
const orgId = data.orgId;
|
|
73
|
+
const tenantId = data.tenantId;
|
|
74
|
+
const docformats = alldocuments.filter((item) => item.docNumber);
|
|
75
|
+
for (let i = 0; i < docformats.length; i++) {
|
|
76
|
+
const doc = docformats[i];
|
|
77
|
+
const pattern = `${doc.docType}-${branchCode}-[00000]`;
|
|
78
|
+
const formatdata: Docnoformat = {
|
|
79
|
+
_id: crypto.randomUUID(),
|
|
80
|
+
docNoFormatNo: `${doc.docType}-${branchCode}`,
|
|
81
|
+
docNoFormatName: `Default ${doc.docType} - ${branchCode}`,
|
|
82
|
+
docNoType: doc.docType,
|
|
83
|
+
docNoPattern: pattern,
|
|
84
|
+
branch: { _id: recordId, branchId: branchId, label: branchName },
|
|
85
|
+
branchId: branchId,
|
|
86
|
+
orgId: orgId,
|
|
87
|
+
tenantId: tenantId,
|
|
88
|
+
nextNumber: 1,
|
|
89
|
+
} as Docnoformat;
|
|
90
|
+
try {
|
|
91
|
+
const result = await this.docnoservice.create(appuser, formatdata);
|
|
92
|
+
if (!result) {
|
|
93
|
+
throw new InternalServerErrorException(
|
|
94
|
+
`Generate default document number for "${branchCode}" failed. Pattern: ${pattern}`,
|
|
95
|
+
'generateDefaultDocNumbers',
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
this.logger.error(err);
|
|
100
|
+
throw new InternalServerErrorException(err);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
import { Injectable,Inject } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import * as jsonpath from 'jsonpath';
|
|
12
|
+
import { Model } from 'mongoose';
|
|
13
|
+
import { DocnoformatJsonSchema } from '../jsonschemas/docno.jsonschema';
|
|
14
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
15
|
+
import { IsolationType } from '../types';
|
|
16
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
17
|
+
import { DocnoformatBranch, Docnoformat } from '../types/docno.type';
|
|
18
|
+
import {
|
|
19
|
+
DefaultDocnoformatBranch,
|
|
20
|
+
DefaultDocnoformat,
|
|
21
|
+
} from '../defaults/docno.default';
|
|
22
|
+
|
|
23
|
+
@Injectable()
|
|
24
|
+
export class DocnoformatProcessor extends SimpleAppService<Docnoformat> {
|
|
25
|
+
protected strictIsolation = false;
|
|
26
|
+
protected documentIdentityCode = 'docNoFormatNo';
|
|
27
|
+
protected documentIdentityLabel = 'docNoFormatName';
|
|
28
|
+
|
|
29
|
+
protected foreignkeys = { branch: ['$.branch._id'] };
|
|
30
|
+
constructor(mydoc: Model<Docnoformat>) {
|
|
31
|
+
super('DOCNO', 'docnoformat', mydoc, IsolationType.org);
|
|
32
|
+
this.setSchema(DocnoformatJsonSchema);
|
|
33
|
+
this.setData(DefaultDocnoformat(crypto.randomUUID()));
|
|
34
|
+
this.addAutoCompleteField({
|
|
35
|
+
default: 'default',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
reCalculateValue(data: Docnoformat) {
|
|
40
|
+
//console.log('trigger new recalculate')
|
|
41
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/***************************** additional execute *****************************************/
|
|
45
|
+
/**
|
|
46
|
+
* list document number format and prepare sample of docformat
|
|
47
|
+
* @param appuser
|
|
48
|
+
* @param doctype
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
async runListDocFormats(appuser: UserContext, doctype: string) {
|
|
52
|
+
doctype = doctype.toUpperCase();
|
|
53
|
+
const searchresult = await this.search(
|
|
54
|
+
appuser,
|
|
55
|
+
{ docNoType: doctype,'branch.branchId':appuser.getBranchId() },
|
|
56
|
+
undefined,
|
|
57
|
+
{default:'desc'}
|
|
58
|
+
);
|
|
59
|
+
//console.log('searchresult',searchresult);
|
|
60
|
+
let data: any = [];
|
|
61
|
+
for (let i = 0; i < searchresult.length; i++) {
|
|
62
|
+
const s = searchresult[i];
|
|
63
|
+
if (s.active && s.docNoPattern) {
|
|
64
|
+
data.push({
|
|
65
|
+
_id: s._id,
|
|
66
|
+
docNoFormatNo: s.docNoFormatNo,
|
|
67
|
+
docNoFormatName: s.docNoFormatName,
|
|
68
|
+
docNoPattern: s.docNoPattern,
|
|
69
|
+
nextNumber: s.nextNumber,
|
|
70
|
+
default: s.default,
|
|
71
|
+
sample: DocNumberFormatGenerator.previewDocNo(s),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
import { Injectable, Inject, BadRequestException } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import * as jsonpath from 'jsonpath';
|
|
12
|
+
import { Model } from 'mongoose';
|
|
13
|
+
import { OrganizationJsonSchema } from '../jsonschemas/org.jsonschema';
|
|
14
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
15
|
+
import { IsolationType, OrganizationHooks, KeyValue } from '../types';
|
|
16
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
17
|
+
import { Organization } from '../types/org.type';
|
|
18
|
+
import { AutoincreamentService } from '../../services/autoinc.service';
|
|
19
|
+
import { DefaultOrganization } from '../defaults/org.default';
|
|
20
|
+
import {
|
|
21
|
+
KeyvaluepairService,
|
|
22
|
+
Keyvaluepair,
|
|
23
|
+
} from 'src/simpleapp/services/kvpair.service';
|
|
24
|
+
@Injectable()
|
|
25
|
+
export class OrganizationProcessor extends SimpleAppService<Organization> {
|
|
26
|
+
@Inject(AutoincreamentService)
|
|
27
|
+
protected increament: AutoincreamentService;
|
|
28
|
+
@Inject(KeyvaluepairService)
|
|
29
|
+
protected kvpairService: KeyvaluepairService;
|
|
30
|
+
|
|
31
|
+
protected documentIdentityCode = 'orgCode';
|
|
32
|
+
protected documentIdentityLabel = 'orgName';
|
|
33
|
+
protected strictIsolation = false;
|
|
34
|
+
protected foreignkeys = {};
|
|
35
|
+
protected defaultlogo =
|
|
36
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=';
|
|
37
|
+
protected hooks: OrganizationHooks = {
|
|
38
|
+
beforeCreate: async (appuser: UserContext, data: Organization) =>
|
|
39
|
+
await this.orgBeforeCreate(appuser, data),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
constructor(mydoc: Model<Organization>) {
|
|
43
|
+
super('ORG', 'organization', mydoc, IsolationType.tenant);
|
|
44
|
+
this.setSchema(OrganizationJsonSchema);
|
|
45
|
+
this.setData(DefaultOrganization(crypto.randomUUID()));
|
|
46
|
+
this.addAutoCompleteField({
|
|
47
|
+
orgId: 'orgId',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async orgBeforeCreate(appuser: UserContext, data: Organization) {
|
|
52
|
+
const searchresult = await this.increament.runGenerateNextNo(
|
|
53
|
+
appuser,
|
|
54
|
+
'organization',
|
|
55
|
+
'orgId',
|
|
56
|
+
);
|
|
57
|
+
data.orgId = searchresult.nextno;
|
|
58
|
+
}
|
|
59
|
+
reCalculateValue(data: Organization) {
|
|
60
|
+
//console.log('trigger new recalculate')
|
|
61
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/***************************** additional execute *****************************************/
|
|
65
|
+
async runGetlogo(appuser: UserContext) {
|
|
66
|
+
const logo = await this.searchLogo(appuser);
|
|
67
|
+
if (logo) return logo.value;
|
|
68
|
+
else return this.defaultlogo;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async searchLogo(appuser: UserContext) {
|
|
72
|
+
const keyvaluepair = await this.kvpairService.search(appuser, {
|
|
73
|
+
key: 'orglogo',
|
|
74
|
+
});
|
|
75
|
+
if (keyvaluepair && keyvaluepair.length > 0) return keyvaluepair[0];
|
|
76
|
+
else return null;
|
|
77
|
+
}
|
|
78
|
+
async runUploadlogo(appuser: UserContext, data: KeyValue) {
|
|
79
|
+
// this.setDefaultLogo(data.value);
|
|
80
|
+
const key = data.key;
|
|
81
|
+
|
|
82
|
+
let kvdata: Keyvaluepair = await this.searchLogo(appuser);
|
|
83
|
+
if (kvdata) {
|
|
84
|
+
kvdata.value=data.value
|
|
85
|
+
const res = await this.kvpairService.findIdThenUpdate(
|
|
86
|
+
appuser,
|
|
87
|
+
kvdata._id,
|
|
88
|
+
kvdata,
|
|
89
|
+
);
|
|
90
|
+
if (res) {
|
|
91
|
+
return data.value;
|
|
92
|
+
} else {
|
|
93
|
+
throw new BadRequestException(`failed to update keyvalue pair ${key}`);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
kvdata = {
|
|
97
|
+
_id: crypto.randomUUID(),
|
|
98
|
+
key: 'orglogo',
|
|
99
|
+
value: data.value,
|
|
100
|
+
};
|
|
101
|
+
const res = await this.kvpairService.create(appuser, kvdata);
|
|
102
|
+
if (res) {
|
|
103
|
+
return data.value;
|
|
104
|
+
} else {
|
|
105
|
+
throw new BadRequestException(`failed to create keyvalue pair ${key}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this.defaultlogo;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async setDefaultLogo(data: string) {
|
|
113
|
+
this.defaultlogo = data;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
|
|
10
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
11
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
12
|
+
import * as jsonpath from 'jsonpath';
|
|
13
|
+
import { Model, PipelineStage } from 'mongoose';
|
|
14
|
+
import { PermissionJsonSchema } from '../jsonschemas/perm.jsonschema';
|
|
15
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
16
|
+
import { IsolationType } from '../types';
|
|
17
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
18
|
+
import { Permission } from '../types/perm.type';
|
|
19
|
+
import { DefaultPermission } from '../defaults/perm.default';
|
|
20
|
+
|
|
21
|
+
@Injectable()
|
|
22
|
+
export class PermissionProcessor extends SimpleAppService<Permission> {
|
|
23
|
+
protected documentIdentityCode = '';
|
|
24
|
+
protected documentIdentityLabel = '';
|
|
25
|
+
|
|
26
|
+
protected foreignkeys = { user: ['$.userId'] };
|
|
27
|
+
constructor(mydoc: Model<Permission>) {
|
|
28
|
+
super('PERM', 'permission', mydoc, IsolationType.org);
|
|
29
|
+
this.setSchema(PermissionJsonSchema);
|
|
30
|
+
this.setData(DefaultPermission(crypto.randomUUID()));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
reCalculateValue(data: Permission) {
|
|
34
|
+
//console.log('trigger new recalculate')
|
|
35
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async runListUser(appuser: UserContext) {
|
|
39
|
+
const getallrecords: PipelineStage = { $match: {} };
|
|
40
|
+
const lookupuser: PipelineStage = {
|
|
41
|
+
$lookup: {
|
|
42
|
+
from: 'user',
|
|
43
|
+
localField: 'uid',
|
|
44
|
+
foreignField: 'uid',
|
|
45
|
+
as: 'user',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const pipeline: PipelineStage[] = [getallrecords, lookupuser];
|
|
49
|
+
const result = await this.aggregate(appuser, pipeline);
|
|
50
|
+
const finalresult: any[] = [];
|
|
51
|
+
for (let i = 0; i < result.length; i++) {
|
|
52
|
+
const r = result[i];
|
|
53
|
+
|
|
54
|
+
const u = r.user[0] ?? { email: 'unknownemail', fullName: 'unknown' };
|
|
55
|
+
finalresult.push({
|
|
56
|
+
_id: r._id,
|
|
57
|
+
tenantId: r.tenantId,
|
|
58
|
+
orgId: r.orgId,
|
|
59
|
+
branchId: r.branchId,
|
|
60
|
+
uid: r.uid,
|
|
61
|
+
group: r.group,
|
|
62
|
+
fullName: u.fullname,
|
|
63
|
+
email: u.email,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// result['user'] = result['users'][0]
|
|
67
|
+
// delete result['users'][0]
|
|
68
|
+
return finalresult;
|
|
69
|
+
}
|
|
70
|
+
/***************************** additional execute *****************************************/
|
|
71
|
+
}
|
|
@@ -31,6 +31,8 @@ import {
|
|
|
31
31
|
HttpExceptionOptions,
|
|
32
32
|
} from '@nestjs/common/exceptions';
|
|
33
33
|
import { UserContext } from '../commons/user.context';
|
|
34
|
+
import {CloudApiService} from 'src/cloudapi/cloudapi.service'
|
|
35
|
+
import { PrintApiService } from 'src/printapi/printapi.service';
|
|
34
36
|
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
35
37
|
import {
|
|
36
38
|
IsolationType,
|
|
@@ -43,6 +45,10 @@ import {
|
|
|
43
45
|
export class SimpleAppService<T extends { _id?: string }> {
|
|
44
46
|
@Inject(EventEmitter2)
|
|
45
47
|
protected eventEmitter: EventEmitter2;
|
|
48
|
+
@Inject(CloudApiService)
|
|
49
|
+
protected cloudapi: CloudApiService;
|
|
50
|
+
@Inject(PrintApiService)
|
|
51
|
+
protected printapi: PrintApiService;
|
|
46
52
|
protected hooks: DefaultHooks<T> = {};
|
|
47
53
|
protected logger = new Logger();
|
|
48
54
|
protected strictIsolation = true;
|
|
@@ -79,6 +85,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
79
85
|
this.documentType = doctype.toUpperCase();
|
|
80
86
|
this.documentName = docname;
|
|
81
87
|
this.doc = newdoc;
|
|
88
|
+
|
|
82
89
|
this.isolationtype = isolationtype;
|
|
83
90
|
if (this.hooks.init) this.hooks.init();
|
|
84
91
|
// this.tenantdoc = tenantdoc
|
|
@@ -188,12 +195,15 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
188
195
|
* @param filters
|
|
189
196
|
* @returns
|
|
190
197
|
*/
|
|
191
|
-
private async searchNoIsolation(
|
|
198
|
+
private async searchNoIsolation(
|
|
199
|
+
appuser: UserContext,
|
|
200
|
+
filters: FilterQuery<T>,
|
|
201
|
+
) {
|
|
192
202
|
try {
|
|
193
203
|
if (this.hooks.beforeSearch)
|
|
194
204
|
await this.hooks.beforeSearch(appuser, filters);
|
|
195
205
|
const products = await this.doc.find(filters);
|
|
196
|
-
const productlist = products.map((p
|
|
206
|
+
const productlist = products.map((p) => {
|
|
197
207
|
return p;
|
|
198
208
|
});
|
|
199
209
|
if (this.hooks.afterSearch)
|
|
@@ -235,7 +245,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
235
245
|
this.polishIsolationFilter(isolationFilter);
|
|
236
246
|
|
|
237
247
|
// console.log("initial search",filters)
|
|
238
|
-
const newfilters = { ...filters, ...isolationFilter };
|
|
248
|
+
const newfilters: FilterQuery<T> = { ...filters, ...isolationFilter };
|
|
239
249
|
|
|
240
250
|
if (this.hooks.beforeSearch)
|
|
241
251
|
await this.hooks.beforeSearch(appuser, newfilters);
|
|
@@ -262,7 +272,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
262
272
|
async findById(appuser: UserContext, id: string) {
|
|
263
273
|
if (this.hooks.beforeFetchRecord)
|
|
264
274
|
await this.hooks.beforeFetchRecord(appuser, id);
|
|
265
|
-
|
|
275
|
+
|
|
276
|
+
const data = await this.search(appuser, { _id: id as any });
|
|
266
277
|
if (this.hooks.afterFetchRecord)
|
|
267
278
|
await this.hooks.afterFetchRecord(appuser, data[0]);
|
|
268
279
|
|
|
@@ -561,8 +572,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
561
572
|
});
|
|
562
573
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
563
574
|
if (this.hooks.afterUpdate)
|
|
564
|
-
await this.hooks.afterUpdate(appuser, id, result);
|
|
565
|
-
return
|
|
575
|
+
await this.hooks.afterUpdate(appuser, id, existingdata, result);
|
|
576
|
+
return result; // await this.findById(appuser, id);
|
|
566
577
|
} catch (err) {
|
|
567
578
|
this.logger.error(err);
|
|
568
579
|
throw new InternalServerErrorException(err.message);
|
|
@@ -614,8 +625,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
614
625
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
615
626
|
|
|
616
627
|
if (this.hooks.afterUpdate)
|
|
617
|
-
await this.hooks.afterUpdate(appuser, id, result);
|
|
618
|
-
return result //await this.findById(appuser, id);
|
|
628
|
+
await this.hooks.afterUpdate(appuser, id, existingdata, result);
|
|
629
|
+
return result; //await this.findById(appuser, id);
|
|
619
630
|
} catch (err) {
|
|
620
631
|
throw new InternalServerErrorException(err.message);
|
|
621
632
|
}
|
|
@@ -745,7 +756,11 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
745
756
|
this.logger.debug(result, 'genNewDocNo');
|
|
746
757
|
data[this.documentIdentityCode] = result;
|
|
747
758
|
}
|
|
748
|
-
|
|
759
|
+
async runDefault(appuser: UserContext): Promise<unknown> {
|
|
760
|
+
return (
|
|
761
|
+
'Hello this is ' + this.getDocumentType() + ': ' + this.getDocumentName()
|
|
762
|
+
);
|
|
763
|
+
}
|
|
749
764
|
async identifyForeignKeys(appuser: UserContext, data: T) {
|
|
750
765
|
/**
|
|
751
766
|
* 1. looping schemas identify what foreign key exists
|
|
@@ -851,4 +866,9 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
851
866
|
}
|
|
852
867
|
}
|
|
853
868
|
}
|
|
869
|
+
|
|
870
|
+
async print(appuser: UserContext, id: string, formatid: string) {
|
|
871
|
+
const pdfresult = await this.printapi.getBase64Pdf(appuser, formatid, id);
|
|
872
|
+
return pdfresult;
|
|
873
|
+
}
|
|
854
874
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
import { Injectable,Inject } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import * as jsonpath from 'jsonpath';
|
|
12
|
+
import { Model } from 'mongoose';
|
|
13
|
+
import { SystemmessageJsonSchema } from '../jsonschemas/sysmsg.jsonschema';
|
|
14
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
15
|
+
import { IsolationType } from '../types';
|
|
16
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
17
|
+
import { Systemmessage } from '../types/sysmsg.type';
|
|
18
|
+
import { DefaultSystemmessage } from '../defaults/sysmsg.default';
|
|
19
|
+
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class SystemmessageProcessor extends SimpleAppService<Systemmessage> {
|
|
22
|
+
protected documentIdentityCode = '';
|
|
23
|
+
protected documentIdentityLabel = 'messageTitle';
|
|
24
|
+
|
|
25
|
+
protected foreignkeys = {};
|
|
26
|
+
constructor(mydoc: Model<Systemmessage>) {
|
|
27
|
+
super('SYSMSG', 'systemmessage', mydoc, IsolationType.tenant);
|
|
28
|
+
this.setSchema(SystemmessageJsonSchema);
|
|
29
|
+
this.setData(DefaultSystemmessage(crypto.randomUUID()));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
reCalculateValue(data: Systemmessage) {
|
|
33
|
+
//console.log('trigger new recalculate')
|
|
34
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/***************************** additional execute *****************************************/
|
|
38
|
+
async runDefault(appuser: UserContext) {
|
|
39
|
+
return await this.search(appuser, { uid: appuser.getUid() });
|
|
40
|
+
}
|
|
41
|
+
async runReadmsg(appuser:UserContext,id:string){
|
|
42
|
+
const data = await this.findById(appuser, id);
|
|
43
|
+
data.read=true
|
|
44
|
+
await await this.findIdThenUpdate(appuser,id,data)
|
|
45
|
+
return data
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
+
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
+
* last change 2024-02-23
|
|
5
|
+
* Author: Ks Tan
|
|
6
|
+
*/
|
|
7
|
+
import { UserContext } from '../commons/user.context';
|
|
8
|
+
import * as sharelibs from '../sharelibs';
|
|
9
|
+
import { Injectable,Inject } from '@nestjs/common';
|
|
10
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
11
|
+
import * as jsonpath from 'jsonpath';
|
|
12
|
+
import { Model } from 'mongoose';
|
|
13
|
+
import { TenantJsonSchema } from '../jsonschemas/tenant.jsonschema';
|
|
14
|
+
import { SimpleAppService } from './simpleapp.processor';
|
|
15
|
+
import { IsolationType ,TenantHooks} from '../types';
|
|
16
|
+
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
17
|
+
import { TenantOwner, Tenant } from '../types/tenant.type';
|
|
18
|
+
import { DefaultTenantOwner, DefaultTenant } from '../defaults/tenant.default';
|
|
19
|
+
import { AutoincreamentService } from '../../services/autoinc.service';
|
|
20
|
+
@Injectable()
|
|
21
|
+
export class TenantProcessor extends SimpleAppService<Tenant> {
|
|
22
|
+
@Inject(AutoincreamentService)
|
|
23
|
+
protected increament: AutoincreamentService;
|
|
24
|
+
|
|
25
|
+
protected documentIdentityCode = 'tenantId';
|
|
26
|
+
protected documentIdentityLabel = 'tenantName';
|
|
27
|
+
protected hooks : TenantHooks = {
|
|
28
|
+
beforeCreate: async (appuser: UserContext, data: Tenant) => await this.tenantBeforeCreate(appuser,data),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
protected foreignkeys = { user: ['$.owner._id'] };
|
|
32
|
+
constructor(mydoc: Model<Tenant>) {
|
|
33
|
+
super('TENANT', 'tenant', mydoc, IsolationType.none);
|
|
34
|
+
this.setSchema(TenantJsonSchema);
|
|
35
|
+
this.setData(DefaultTenant(crypto.randomUUID()));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
reCalculateValue(data: Tenant) {
|
|
39
|
+
//console.log('trigger new recalculate')
|
|
40
|
+
const jsopbj = new jsonpath['JSONPath']();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/***************************** additional execute *****************************************/
|
|
44
|
+
async tenantBeforeCreate(appuser:UserContext,data:Tenant){
|
|
45
|
+
const searchresult = await this.increament.runGenerateNextNo(
|
|
46
|
+
appuser,
|
|
47
|
+
'tenant',
|
|
48
|
+
'tenantId',
|
|
49
|
+
);
|
|
50
|
+
data.tenantId = searchresult.nextno;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -49,7 +49,7 @@ export type DefaultHooks<T> = {
|
|
|
49
49
|
data: T,
|
|
50
50
|
existingdata: T,
|
|
51
51
|
) => Promise<void>;
|
|
52
|
-
afterUpdate?: (appuser: UserContext, id: string,
|
|
52
|
+
afterUpdate?: (appuser: UserContext, id: string, prevdata: T,newdata:T) => Promise<void>;
|
|
53
53
|
beforeDelete?: (
|
|
54
54
|
appuser: UserContext,
|
|
55
55
|
id: string,
|
|
@@ -140,8 +140,15 @@ export type SchemaConfig = {
|
|
|
140
140
|
documentType: string
|
|
141
141
|
documentName: string
|
|
142
142
|
collectionName?: string
|
|
143
|
-
foreignKeys?:MyForeignKey
|
|
144
|
-
|
|
143
|
+
foreignKeys?:MyForeignKey
|
|
144
|
+
printFormats?: SchemaPrintFormat[]
|
|
145
|
+
}
|
|
146
|
+
export type SchemaPrintFormat = {
|
|
147
|
+
formatName: string
|
|
148
|
+
formatId: string
|
|
149
|
+
description?: string
|
|
150
|
+
}
|
|
151
|
+
|
|
145
152
|
export type MyForeignKey = {
|
|
146
153
|
[collectionname:string]:string[]
|
|
147
154
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was automatically generated by simpleapp generator. Every
|
|
3
3
|
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
-
* last change 2024-04-
|
|
4
|
+
* last change 2024-04-21
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
@@ -72,7 +72,7 @@ export class WorkflowController {
|
|
|
72
72
|
@AppUser() appuser: UserContext,
|
|
73
73
|
@Param() uid: string,
|
|
74
74
|
) {
|
|
75
|
-
return await this.workflowService.getActorUserTask(appuser
|
|
75
|
+
return await this.workflowService.getActorUserTask(appuser);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|