@simitgroup/simpleapp-generator 1.5.1-alpha → 1.6.1-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 +4 -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 +4 -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/processor.ts.eta +2 -1
- 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/component.select.vue.eta +5 -1
- package/templates/basic/nuxt/pages.form.vue.eta +1 -1
- package/templates/basic/nuxt/pages.mobile.landing.vue.eta +4 -61
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +11 -13
- package/templates/nest/src/app.module.ts.eta +12 -4
- package/templates/nest/src/cloudapi/cloudapi.module.ts._eta +1 -1
- 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/robotuser.service.ts.eta +5 -4
- 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 +10 -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 +77 -13
- 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 +12 -5
- 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/profile/profile.apischema.ts.eta +15 -0
- package/templates/nest/src/simpleapp/profile/profile.controller.ts.eta +3 -1
- package/templates/nest/src/simpleapp/profile/profile.service.ts.eta +20 -3
- 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 +8 -4
- package/templates/nest/src/simpleapp/types/index.ts._eta +5 -0
- package/templates/nuxt/assets/css/listview.css._eta +2 -2
- package/templates/nuxt/components/button/ButtonAction.vue._eta +11 -5
- package/templates/nuxt/components/calendar/CalendarSmall.vue.eta +11 -2
- package/templates/nuxt/components/debug/DebugDocumentData.vue.eta +1 -1
- 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/list/ListView.vue.eta +9 -12
- package/templates/nuxt/components/renderer/RendererMoney.vue.eta +11 -12
- package/templates/nuxt/components/select/SelectTemplate.vue.eta +49 -20
- package/templates/nuxt/components/simpleApp/SimpleAppAutocomplete.vue.eta +2 -2
- package/templates/nuxt/components/simpleApp/SimpleAppChildrenList.vue.eta +16 -15
- package/templates/nuxt/components/simpleApp/SimpleAppFormToolBar.vue._eta +92 -8
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +29 -6
- package/templates/nuxt/components/text/TextBold.vue._eta +13 -0
- package/templates/nuxt/components/user/UserButtonCreateTenant.vue._eta +18 -2
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +12 -3
- 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 +10 -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 +71 -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
|
@@ -25,12 +25,15 @@ import addFormats from 'ajv-formats';
|
|
|
25
25
|
import addErrors from 'ajv-errors';
|
|
26
26
|
import {
|
|
27
27
|
NotFoundException,
|
|
28
|
+
HttpException,
|
|
28
29
|
BadRequestException,
|
|
29
30
|
ForbiddenException,
|
|
30
31
|
InternalServerErrorException,
|
|
31
32
|
HttpExceptionOptions,
|
|
32
33
|
} from '@nestjs/common/exceptions';
|
|
33
34
|
import { UserContext } from '../commons/user.context';
|
|
35
|
+
import { CloudApiService } from 'src/cloudapi/cloudapi.service';
|
|
36
|
+
import { PrintApiService } from 'src/printapi/printapi.service';
|
|
34
37
|
import { DocNumberFormatGenerator } from '../commons/docnogenerator.service';
|
|
35
38
|
import {
|
|
36
39
|
IsolationType,
|
|
@@ -43,6 +46,10 @@ import {
|
|
|
43
46
|
export class SimpleAppService<T extends { _id?: string }> {
|
|
44
47
|
@Inject(EventEmitter2)
|
|
45
48
|
protected eventEmitter: EventEmitter2;
|
|
49
|
+
@Inject(CloudApiService)
|
|
50
|
+
protected cloudapi: CloudApiService;
|
|
51
|
+
@Inject(PrintApiService)
|
|
52
|
+
protected printapi: PrintApiService;
|
|
46
53
|
protected hooks: DefaultHooks<T> = {};
|
|
47
54
|
protected logger = new Logger();
|
|
48
55
|
protected strictIsolation = true;
|
|
@@ -79,6 +86,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
79
86
|
this.documentType = doctype.toUpperCase();
|
|
80
87
|
this.documentName = docname;
|
|
81
88
|
this.doc = newdoc;
|
|
89
|
+
|
|
82
90
|
this.isolationtype = isolationtype;
|
|
83
91
|
if (this.hooks.init) this.hooks.init();
|
|
84
92
|
// this.tenantdoc = tenantdoc
|
|
@@ -188,12 +196,15 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
188
196
|
* @param filters
|
|
189
197
|
* @returns
|
|
190
198
|
*/
|
|
191
|
-
private async searchNoIsolation(
|
|
199
|
+
private async searchNoIsolation(
|
|
200
|
+
appuser: UserContext,
|
|
201
|
+
filters: FilterQuery<T>,
|
|
202
|
+
) {
|
|
192
203
|
try {
|
|
193
204
|
if (this.hooks.beforeSearch)
|
|
194
205
|
await this.hooks.beforeSearch(appuser, filters);
|
|
195
206
|
const products = await this.doc.find(filters);
|
|
196
|
-
const productlist = products.map((p
|
|
207
|
+
const productlist = products.map((p) => {
|
|
197
208
|
return p;
|
|
198
209
|
});
|
|
199
210
|
if (this.hooks.afterSearch)
|
|
@@ -235,7 +246,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
235
246
|
this.polishIsolationFilter(isolationFilter);
|
|
236
247
|
|
|
237
248
|
// console.log("initial search",filters)
|
|
238
|
-
const newfilters = { ...filters, ...isolationFilter };
|
|
249
|
+
const newfilters: FilterQuery<T> = { ...filters, ...isolationFilter };
|
|
239
250
|
|
|
240
251
|
if (this.hooks.beforeSearch)
|
|
241
252
|
await this.hooks.beforeSearch(appuser, newfilters);
|
|
@@ -262,7 +273,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
262
273
|
async findById(appuser: UserContext, id: string) {
|
|
263
274
|
if (this.hooks.beforeFetchRecord)
|
|
264
275
|
await this.hooks.beforeFetchRecord(appuser, id);
|
|
265
|
-
|
|
276
|
+
|
|
277
|
+
const data = await this.search(appuser, { _id: id as any });
|
|
266
278
|
if (this.hooks.afterFetchRecord)
|
|
267
279
|
await this.hooks.afterFetchRecord(appuser, data[0]);
|
|
268
280
|
|
|
@@ -395,7 +407,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
395
407
|
}
|
|
396
408
|
}
|
|
397
409
|
};
|
|
398
|
-
async validateData(appuser: UserContext, data: T) {
|
|
410
|
+
async validateData(appuser: UserContext, data: T, _id?: string) {
|
|
399
411
|
const ajv = new Ajv({ allErrors: true, useDefaults: true });
|
|
400
412
|
addFormats(ajv);
|
|
401
413
|
addErrors(ajv);
|
|
@@ -410,7 +422,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
410
422
|
this.logger.debug('run hook during validation');
|
|
411
423
|
let issuccess = true;
|
|
412
424
|
if (this.hooks.beforeValidation) {
|
|
413
|
-
issuccess = await this.hooks.beforeValidation(appuser, data);
|
|
425
|
+
issuccess = await this.hooks.beforeValidation(appuser, data, _id);
|
|
414
426
|
}
|
|
415
427
|
// const issuccess = await this.hook(appuser, HookType.beforeValidation, data);
|
|
416
428
|
if (!issuccess) {
|
|
@@ -441,7 +453,7 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
441
453
|
);
|
|
442
454
|
}
|
|
443
455
|
if (this.hooks.afterValidation)
|
|
444
|
-
await this.hooks.afterValidation(appuser, data);
|
|
456
|
+
await this.hooks.afterValidation(appuser, data, _id);
|
|
445
457
|
}
|
|
446
458
|
|
|
447
459
|
polishIsolationFilter = (filterIsolation: any, data: any = {}) => {
|
|
@@ -544,11 +556,12 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
544
556
|
// try {
|
|
545
557
|
Object.assign(data, appuser.getUpdateFilter());
|
|
546
558
|
// Object.assign(existingdata, data);
|
|
559
|
+
|
|
547
560
|
delete data['_id'];
|
|
548
561
|
this.reCalculateValue(data);
|
|
549
562
|
|
|
550
563
|
// existingdata['_id']=''
|
|
551
|
-
await this.validateData(appuser, data);
|
|
564
|
+
await this.validateData(appuser, data, id);
|
|
552
565
|
|
|
553
566
|
const isolationFilter = { ...this.getIsolationFilter(appuser) };
|
|
554
567
|
this.polishIsolationFilter(isolationFilter);
|
|
@@ -561,8 +574,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
561
574
|
});
|
|
562
575
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
563
576
|
if (this.hooks.afterUpdate)
|
|
564
|
-
await this.hooks.afterUpdate(appuser, id, result);
|
|
565
|
-
return
|
|
577
|
+
await this.hooks.afterUpdate(appuser, id, existingdata, result);
|
|
578
|
+
return result; // await this.findById(appuser, id);
|
|
566
579
|
} catch (err) {
|
|
567
580
|
this.logger.error(err);
|
|
568
581
|
throw new InternalServerErrorException(err.message);
|
|
@@ -614,8 +627,8 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
614
627
|
appuser.addUpdatedRecordId(this.documentName, data._id);
|
|
615
628
|
|
|
616
629
|
if (this.hooks.afterUpdate)
|
|
617
|
-
await this.hooks.afterUpdate(appuser, id, result);
|
|
618
|
-
return result //await this.findById(appuser, id);
|
|
630
|
+
await this.hooks.afterUpdate(appuser, id, existingdata, result);
|
|
631
|
+
return result; //await this.findById(appuser, id);
|
|
619
632
|
} catch (err) {
|
|
620
633
|
throw new InternalServerErrorException(err.message);
|
|
621
634
|
}
|
|
@@ -722,6 +735,48 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
722
735
|
}
|
|
723
736
|
}
|
|
724
737
|
|
|
738
|
+
/**
|
|
739
|
+
* similar like runWorker, but it is syncronizely add event into queue and return.
|
|
740
|
+
* No result will return from this method, it also lose appuser db's transaction
|
|
741
|
+
* due out of request flow
|
|
742
|
+
*
|
|
743
|
+
* @param {UserContext} appuser The appuser
|
|
744
|
+
* @param {string} eventName The event name
|
|
745
|
+
* @param {any} data The data
|
|
746
|
+
*/
|
|
747
|
+
runBackgroundWorker(appuser: UserContext, eventName: string, payloads:any) {
|
|
748
|
+
this.eventEmitter.emit(eventName, appuser, payloads);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* runWorker design with 2 purpose
|
|
753
|
+
* 1. we wish developer develop complex programming flow in worker class instead
|
|
754
|
+
* of service class. We wish service class remain simple and easy to understand
|
|
755
|
+
* it wish to do hook and api only
|
|
756
|
+
* complex task service class may pass to worker class.
|
|
757
|
+
* 2. it not cause circulate injection hell, which is useful in complex dependency
|
|
758
|
+
* this run foreground event which can async/await to obtain execution result,
|
|
759
|
+
* the appuser dbtransaction remain usable. however, the execution may delay response
|
|
760
|
+
*
|
|
761
|
+
*
|
|
762
|
+
* @param {UserContext} appuser The appuser
|
|
763
|
+
* @param {string} eventName The event name
|
|
764
|
+
* @param {any} data The data
|
|
765
|
+
* @return {Promise} { description_of_the_return_value }
|
|
766
|
+
*/
|
|
767
|
+
async runWorker(appuser: UserContext, eventName: string, payloads:any) {
|
|
768
|
+
const res = await this.eventEmitter.emitAsync(eventName, appuser, payloads);
|
|
769
|
+
if (!this.eventEmitter.hasListeners(eventName)) {
|
|
770
|
+
throw new InternalServerErrorException(`${eventName} seems no listener`);
|
|
771
|
+
}
|
|
772
|
+
if (!res) {
|
|
773
|
+
throw new InternalServerErrorException(`${eventName} is invalid worker`);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const result = res[0];
|
|
777
|
+
if (result?.name && result?.name.includes('Exception')) throw result;
|
|
778
|
+
return result;
|
|
779
|
+
}
|
|
725
780
|
startWorkflow(
|
|
726
781
|
appuser: UserContext,
|
|
727
782
|
processName: WorkflowName,
|
|
@@ -745,7 +800,11 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
745
800
|
this.logger.debug(result, 'genNewDocNo');
|
|
746
801
|
data[this.documentIdentityCode] = result;
|
|
747
802
|
}
|
|
748
|
-
|
|
803
|
+
async runDefault(appuser: UserContext): Promise<unknown> {
|
|
804
|
+
return (
|
|
805
|
+
'Hello this is ' + this.getDocumentType() + ': ' + this.getDocumentName()
|
|
806
|
+
);
|
|
807
|
+
}
|
|
749
808
|
async identifyForeignKeys(appuser: UserContext, data: T) {
|
|
750
809
|
/**
|
|
751
810
|
* 1. looping schemas identify what foreign key exists
|
|
@@ -851,4 +910,9 @@ export class SimpleAppService<T extends { _id?: string }> {
|
|
|
851
910
|
}
|
|
852
911
|
}
|
|
853
912
|
}
|
|
913
|
+
|
|
914
|
+
async print(appuser: UserContext, id: string, formatid: string) {
|
|
915
|
+
const pdfresult = await this.printapi.getBase64Pdf(appuser, formatid, id);
|
|
916
|
+
return pdfresult;
|
|
917
|
+
}
|
|
854
918
|
}
|
|
@@ -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
|
+
}
|
|
@@ -39,8 +39,8 @@ export type DefaultHooks<T> = {
|
|
|
39
39
|
init?: () => Promise<void>;
|
|
40
40
|
beforeSearch?: (appuser: UserContext, filter: any) => Promise<void>;
|
|
41
41
|
afterSearch?: (appuser: UserContext, data: T[]) => Promise<void>;
|
|
42
|
-
beforeValidation?: (appuser: UserContext, data: T) => Promise<boolean>;
|
|
43
|
-
afterValidation?: (appuser: UserContext, data: T) => Promise<void>;
|
|
42
|
+
beforeValidation?: (appuser: UserContext, data: T,_id?:string) => Promise<boolean>;
|
|
43
|
+
afterValidation?: (appuser: UserContext, data: T,_id?:string) => Promise<void>;
|
|
44
44
|
beforeCreate?: (appuser: UserContext, data: T) => Promise<void>;
|
|
45
45
|
afterCreate?: (appuser: UserContext, data: T) => Promise<void>;
|
|
46
46
|
beforeUpdate?: (
|
|
@@ -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
|
/**
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This file was automatically generated by simpleapp generator. Every
|
|
3
3
|
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
-
* last change 2024-
|
|
4
|
+
* last change 2024-04-23
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
8
|
Injectable,
|
|
9
9
|
InternalServerErrorException,
|
|
10
10
|
Logger,
|
|
11
|
+
Inject,
|
|
11
12
|
} from '@nestjs/common';
|
|
12
13
|
import {
|
|
13
14
|
IExecution,
|
|
@@ -19,13 +20,17 @@ import {
|
|
|
19
20
|
BPMNServer,
|
|
20
21
|
Execution,
|
|
21
22
|
} from 'bpmn-server';
|
|
23
|
+
import { UserResolverService } from '../../services/userresolver.service';
|
|
22
24
|
import { moddleOptions } from 'bpmn-server/dist/elements/js-bpmn-moddle';
|
|
23
25
|
let mydelegate: WorkflowDelegate;
|
|
24
26
|
@Injectable()
|
|
25
27
|
export class WorkflowDelegate implements IAppDelegate {
|
|
26
28
|
protected logger = new Logger();
|
|
27
29
|
server: BPMNServer;
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
@Inject(UserResolverService)
|
|
32
|
+
servicesProvider: UserResolverService;
|
|
33
|
+
|
|
29
34
|
constructor() {}
|
|
30
35
|
getServicesProvider = (execution: Execution) => this.servicesProvider;
|
|
31
36
|
|
|
@@ -60,7 +65,7 @@ export class WorkflowDelegate implements IAppDelegate {
|
|
|
60
65
|
|
|
61
66
|
async messageThrown(messageId, data, messageMatchingKey: any, item: Item) {
|
|
62
67
|
const msgId = item.node.messageId;
|
|
63
|
-
item.context.logger.log('Message Issued' + msgId);
|
|
68
|
+
// item.context.logger.log('Message Issued' + msgId);
|
|
64
69
|
// issue it back for others to receive
|
|
65
70
|
const resp = await item.context.engine.throwMessage(
|
|
66
71
|
msgId,
|
|
@@ -68,19 +73,19 @@ export class WorkflowDelegate implements IAppDelegate {
|
|
|
68
73
|
messageMatchingKey,
|
|
69
74
|
);
|
|
70
75
|
if (resp && resp.instance) {
|
|
71
|
-
item.context.logger.log(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
76
|
+
// item.context.logger.log(
|
|
77
|
+
// ' invoked another process ' +
|
|
78
|
+
// resp.instance.id +
|
|
79
|
+
// ' for ' +
|
|
80
|
+
// resp.instance.name,
|
|
81
|
+
// );
|
|
77
82
|
} else await this.issueMessage(messageId, data);
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
async issueMessage(messageId, data) {}
|
|
81
86
|
async issueSignal(signalId, data) {}
|
|
82
87
|
async signalThrown(signalId, data, messageMatchingKey: any, item: Item) {
|
|
83
|
-
item.context.logger.log('Signal Issued' + signalId);
|
|
88
|
+
// item.context.logger.log('Signal Issued' + signalId);
|
|
84
89
|
|
|
85
90
|
const resp = await item.context.engine.throwSignal(
|
|
86
91
|
signalId,
|
|
@@ -88,27 +93,27 @@ export class WorkflowDelegate implements IAppDelegate {
|
|
|
88
93
|
messageMatchingKey,
|
|
89
94
|
);
|
|
90
95
|
if (resp && resp.instance) {
|
|
91
|
-
item.context.logger.log(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
96
|
+
// item.context.logger.log(
|
|
97
|
+
// ' invoked another process ' +
|
|
98
|
+
// resp.instance.id +
|
|
99
|
+
// ' for ' +
|
|
100
|
+
// resp.instance.name,
|
|
101
|
+
// );
|
|
97
102
|
} else await this.issueSignal(signalId, data);
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
consoleKeyTypes = (obj1) => {
|
|
101
106
|
const keys = Object.getOwnPropertyNames(obj1);
|
|
102
|
-
console.log('consoleKeyTypesconsoleKeyTypesconsoleKeyTypes', keys);
|
|
107
|
+
// console.log('consoleKeyTypesconsoleKeyTypesconsoleKeyTypes', keys);
|
|
103
108
|
for (let k = 0; k < keys.length; k++) {
|
|
104
109
|
const key = keys[k];
|
|
105
110
|
|
|
106
111
|
if (!obj1[key]) {
|
|
107
|
-
console.log(key, 'empty ');
|
|
112
|
+
// console.log(key, 'empty ');
|
|
108
113
|
} else if (typeof obj1[key] == 'object') {
|
|
109
|
-
console.log(key, typeof obj1[key], Object.keys(obj1[key]));
|
|
114
|
+
// console.log(key, typeof obj1[key], Object.keys(obj1[key]));
|
|
110
115
|
} else {
|
|
111
|
-
console.log(key, typeof obj1[key], obj1[key]);
|
|
116
|
+
// console.log(key, typeof obj1[key], obj1[key]);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
};
|
|
@@ -165,8 +170,8 @@ export class WorkflowDelegate implements IAppDelegate {
|
|
|
165
170
|
return (${script});`;
|
|
166
171
|
result = Function(js).bind(scope)();
|
|
167
172
|
} catch (exc) {
|
|
168
|
-
console.log('error in script evaluation', js);
|
|
169
|
-
console.log(exc);
|
|
173
|
+
// console.log('error in script evaluation', js);
|
|
174
|
+
// console.log(exc);
|
|
170
175
|
}
|
|
171
176
|
return result;
|
|
172
177
|
}
|
|
@@ -183,13 +188,13 @@ export class WorkflowDelegate implements IAppDelegate {
|
|
|
183
188
|
var output=this.output;
|
|
184
189
|
${script}`;
|
|
185
190
|
result = await new AsyncFunction(js).bind(scope)();
|
|
186
|
-
scope.token.log('..executing js is done ' + scope.id);
|
|
191
|
+
// scope.token.log('..executing js is done ' + scope.id);
|
|
187
192
|
} catch (exc) {
|
|
188
|
-
scope.token.log(
|
|
189
|
-
|
|
190
|
-
);
|
|
191
|
-
console.log('error in script execution', js);
|
|
192
|
-
console.log(exc);
|
|
193
|
+
// scope.token.log(
|
|
194
|
+
// 'ERROR in executing Script ' + exc.message + '\n' + script,
|
|
195
|
+
// );
|
|
196
|
+
// console.log('error in script execution', js);
|
|
197
|
+
// console.log(exc);
|
|
193
198
|
}
|
|
194
199
|
return result;
|
|
195
200
|
}
|