@simitgroup/simpleapp-generator 2.0.1-c-alpha → 2.0.1-d-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/ReleaseNote.md +5 -0
- package/dist/buildinschemas/autoincreament.js +1 -1
- package/dist/buildinschemas/docnoformat.js +1 -1
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/documentevent.js +1 -1
- 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/webhookhistory.d.ts +3 -0
- package/dist/buildinschemas/webhookhistory.d.ts.map +1 -0
- package/dist/buildinschemas/webhookhistory.js +44 -0
- package/dist/buildinschemas/webhookhistory.js.map +1 -0
- package/dist/createproject.js +138 -0
- package/dist/createproject.js.map +1 -0
- package/dist/generate-allow-changebackend.js +305 -0
- package/dist/generate-allow-changebackend.js.map +1 -0
- package/dist/index2.js +118 -0
- package/dist/index2.js.map +1 -0
- package/dist/installdependency.js +20 -0
- package/dist/installdependency.js.map +1 -0
- package/dist/installnest.js +2 -0
- package/dist/installnest.js.map +1 -0
- package/dist/installnuxt.js +2 -0
- package/dist/installnuxt.js.map +1 -0
- package/dist/processors/groupsbuilder.js +2 -0
- package/dist/processors/groupsbuilder.js.map +1 -0
- 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/package.json +1 -1
- package/templates/basic/nest/model.ts.eta +1 -1
- package/templates/nest/src/simple-app/_core/features/profile/profile.service.ts.eta +1 -1
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +8 -172
|
@@ -357,106 +357,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
// async createManyWithId(appuser: UserContext, datas: T[]) {
|
|
362
|
-
// if (Array.isArray(datas)) {
|
|
363
|
-
// for (let i = 0; i < datas.length; i++) {
|
|
364
|
-
// const data = datas[i];
|
|
365
|
-
// let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
|
|
366
|
-
// isolationFilter = this.polishIsolationFilter(isolationFilter, data);
|
|
367
|
-
|
|
368
|
-
// Object.assign(data, isolationFilter);
|
|
369
|
-
// this.reCalculateValue(data);
|
|
370
|
-
// await this.validateData(appuser, data);
|
|
371
|
-
// this.applyNestedDateTime(appuser, data, 'create');
|
|
372
|
-
// }
|
|
373
|
-
|
|
374
|
-
// const dbsession = appuser.getDBSession();
|
|
375
|
-
// if (dbsession && !dbsession.inTransaction()) {
|
|
376
|
-
// dbsession.startTransaction({ readPreference: 'primary' });
|
|
377
|
-
// }
|
|
378
|
-
|
|
379
|
-
// const result = await this.doc.insertMany(datas, { session: dbsession });
|
|
380
|
-
// await this.addManyAuditEvents(appuser, this.documentName, 'createMany', datas);
|
|
381
|
-
// for (let i = 0; i < datas.length; i++) {
|
|
382
|
-
// appuser.addInsertedRecordId(this.documentName, datas[i]._id);
|
|
383
|
-
// }
|
|
384
|
-
// return result;
|
|
385
|
-
// } else {
|
|
386
|
-
// throw new BadRequestException(this.getDocumentType() + ': create many only support array');
|
|
387
|
-
// }
|
|
388
|
-
// }
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* create many from array with hooks (temporary used for generate sample data only)
|
|
392
|
-
* @param appuser
|
|
393
|
-
* @param datas
|
|
394
|
-
*/
|
|
395
|
-
//seems nobody use. also confusing
|
|
396
|
-
// async createManyWithHook(appuser: UserContext, datas: T[]) {
|
|
397
|
-
// if (Array.isArray(datas)) {
|
|
398
|
-
// for (let i = 0; i < datas.length; i++) {
|
|
399
|
-
// const data = datas[i];
|
|
400
|
-
|
|
401
|
-
// let result;
|
|
402
|
-
// const dbsession = appuser.getDBSession();
|
|
403
|
-
// if (dbsession && !dbsession.inTransaction()) {
|
|
404
|
-
// dbsession.startTransaction({ readPreference: 'primary' });
|
|
405
|
-
// }
|
|
406
|
-
|
|
407
|
-
// if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
|
|
408
|
-
// await this.genNewDocNo(appuser, data);
|
|
409
|
-
// }
|
|
410
|
-
|
|
411
|
-
// let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
|
|
412
|
-
// isolationFilter = this.polishIsolationFilter(isolationFilter, data);
|
|
413
|
-
|
|
414
|
-
// Object.assign(data, isolationFilter);
|
|
415
|
-
// this.reCalculateValue(data);
|
|
416
|
-
// await this.validateData(appuser, data);
|
|
417
|
-
// this.applyNestedDateTime(appuser, data, 'create');
|
|
418
|
-
|
|
419
|
-
// //new way of hook
|
|
420
|
-
// await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
|
|
421
|
-
|
|
422
|
-
// const newdoc = new this.doc(data);
|
|
423
|
-
|
|
424
|
-
// try {
|
|
425
|
-
// result = await newdoc.save({ session: dbsession });
|
|
426
|
-
// await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
|
|
427
|
-
// appuser.addInsertedRecordId(this.documentName, result._id);
|
|
428
|
-
// } catch (err) {
|
|
429
|
-
// this.logger.error(err);
|
|
430
|
-
// throw new ProcessErrorException('ERR_CREATE_MANY',err.message,{
|
|
431
|
-
// err:err
|
|
432
|
-
// })
|
|
433
|
-
// // const processdata = await this.runEvent(appuser, 'processdata.processError', {
|
|
434
|
-
// // err: err,
|
|
435
|
-
// // });
|
|
436
|
-
|
|
437
|
-
// // if (!processdata) {
|
|
438
|
-
// // throw new InternalServerErrorException(err);
|
|
439
|
-
// // } else {
|
|
440
|
-
// // throw new CustomException(processdata.code, processdata.msg);
|
|
441
|
-
// // }
|
|
442
|
-
// }
|
|
443
|
-
|
|
444
|
-
// try {
|
|
445
|
-
// //new way of hook
|
|
446
|
-
// await this.runEvent(appuser, this.setHookName('afterCreate'), { data: data }, false);
|
|
447
|
-
// await this.callWebhook(appuser, 'create', result);
|
|
448
|
-
|
|
449
|
-
// // return result as T;
|
|
450
|
-
// } catch (err) {
|
|
451
|
-
// throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
|
|
452
|
-
// }
|
|
453
|
-
// }
|
|
454
|
-
// } else {
|
|
455
|
-
// throw new BadRequestException(this.getDocumentType() + ': create many only support array');
|
|
456
|
-
// }
|
|
457
|
-
// return 'ok';
|
|
458
|
-
// }
|
|
459
|
-
|
|
360
|
+
|
|
460
361
|
/**
|
|
461
362
|
* create many from array, for performance reason it submit all item in 1 go, so it won't implement hooks
|
|
462
363
|
* @param appuser
|
|
@@ -476,7 +377,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
476
377
|
}
|
|
477
378
|
const dbsession = appuser.getDBSession();
|
|
478
379
|
if (dbsession && !dbsession.inTransaction()) {
|
|
479
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
380
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
480
381
|
}
|
|
481
382
|
|
|
482
383
|
try {
|
|
@@ -495,71 +396,6 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
495
396
|
}
|
|
496
397
|
}
|
|
497
398
|
|
|
498
|
-
//seems nobody use, also confusing
|
|
499
|
-
// async createWithId(appuser: UserContext, data: T) {
|
|
500
|
-
// let result;
|
|
501
|
-
|
|
502
|
-
// if (!data._id) {
|
|
503
|
-
// data._id = crypto.randomUUID();
|
|
504
|
-
// }
|
|
505
|
-
// const dbsession = appuser.getDBSession();
|
|
506
|
-
// if (dbsession && !dbsession.inTransaction()) {
|
|
507
|
-
// dbsession.startTransaction({ readPreference: 'primary' });
|
|
508
|
-
// }
|
|
509
|
-
|
|
510
|
-
// this.logger.debug('this.withDocNumberFormat :' + this.withDocNumberFormat + ' && ' + '!data[this.documentIdentityCode] ==' + !data[this.documentIdentityCode]);
|
|
511
|
-
// if (this.withDocNumberFormat && !data[this.documentIdentityCode]) {
|
|
512
|
-
// await this.genNewDocNo(appuser, data);
|
|
513
|
-
// }
|
|
514
|
-
|
|
515
|
-
// let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
|
|
516
|
-
// isolationFilter = this.polishIsolationFilter(isolationFilter, data);
|
|
517
|
-
|
|
518
|
-
// this.logger.debug('isolationFilter', 'SimpleAppService');
|
|
519
|
-
// this.logger.debug(isolationFilter, 'SimpleAppService');
|
|
520
|
-
// this.logger.debug('Create data before isolation', 'SimpleAppService');
|
|
521
|
-
// this.logger.debug(data, 'SimpleAppService');
|
|
522
|
-
// Object.assign(data, isolationFilter);
|
|
523
|
-
// this.reCalculateValue(data);
|
|
524
|
-
// await this.validateData(appuser, data);
|
|
525
|
-
// this.logger.debug(data, `after create validation`);
|
|
526
|
-
// this.applyNestedDateTime(appuser, data, 'create');
|
|
527
|
-
|
|
528
|
-
// //new way of hook
|
|
529
|
-
|
|
530
|
-
// await this.runEvent(appuser, this.setHookName('beforeCreate'), { data: data }, false);
|
|
531
|
-
|
|
532
|
-
// this.logger.debug(data, `Create Record ${this.documentName}`);
|
|
533
|
-
// const newdoc = new this.doc(data);
|
|
534
|
-
// await this.identifyForeignKeys(appuser, data);
|
|
535
|
-
// try {
|
|
536
|
-
// result = await newdoc.save({ session: dbsession });
|
|
537
|
-
// await this.addAuditEvent(appuser, this.documentName, result._id, 'create', data);
|
|
538
|
-
// appuser.addInsertedRecordId(this.documentName, result._id);
|
|
539
|
-
// } catch (err) {
|
|
540
|
-
// this.logger.error(err);
|
|
541
|
-
// const processdata = await this.runEvent(appuser, 'processdata.processError', {
|
|
542
|
-
// err: err,
|
|
543
|
-
// });
|
|
544
|
-
|
|
545
|
-
// if (!processdata) {
|
|
546
|
-
// throw new InternalServerErrorException(err);
|
|
547
|
-
// } else {
|
|
548
|
-
// throw new CustomException(processdata.code, processdata.msg);
|
|
549
|
-
// }
|
|
550
|
-
// }
|
|
551
|
-
|
|
552
|
-
// try {
|
|
553
|
-
// //new way of hook
|
|
554
|
-
// await this.runEvent(appuser, this.setHookName('afterCreate'), { data: result }, false);
|
|
555
|
-
|
|
556
|
-
// await this.callWebhook(appuser, 'create', result);
|
|
557
|
-
// return result as T;
|
|
558
|
-
// } catch (err) {
|
|
559
|
-
// throw new InternalServerErrorException(`createHook ${this.documentType} error: ${JSON.stringify(err)}`, `${this.documentType} createHook error`);
|
|
560
|
-
// }
|
|
561
|
-
// }
|
|
562
|
-
|
|
563
399
|
async create(appuser: UserContext, data: T, noStartTransaction: boolean = false) {
|
|
564
400
|
let result;
|
|
565
401
|
|
|
@@ -568,7 +404,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
568
404
|
}
|
|
569
405
|
const dbsession = appuser.getDBSession();
|
|
570
406
|
if (dbsession && !dbsession.inTransaction() && !noStartTransaction) {
|
|
571
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
407
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
572
408
|
}
|
|
573
409
|
|
|
574
410
|
this.logger.debug('this.withDocNumberFormat :' + this.withDocNumberFormat + ' && ' + '!data[this.documentIdentityCode] ==' + !data[this.documentIdentityCode]);
|
|
@@ -714,7 +550,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
714
550
|
}
|
|
715
551
|
const dbsession = appuser.getDBSession();
|
|
716
552
|
if (dbsession && !dbsession.inTransaction()) {
|
|
717
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
553
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
718
554
|
}
|
|
719
555
|
|
|
720
556
|
let dependency;
|
|
@@ -793,7 +629,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
793
629
|
|
|
794
630
|
const dbsession = appuser.getDBSession();
|
|
795
631
|
if (dbsession && !dbsession.inTransaction() && !noStartTransaction) {
|
|
796
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
632
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
797
633
|
}
|
|
798
634
|
// try {
|
|
799
635
|
Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -852,7 +688,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
852
688
|
|
|
853
689
|
const dbsession = appuser.getDBSession();
|
|
854
690
|
if (dbsession && !dbsession.inTransaction()) {
|
|
855
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
691
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
856
692
|
}
|
|
857
693
|
// try {
|
|
858
694
|
// Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -908,7 +744,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
908
744
|
await this.runEvent(appuser, this.setHookName('beforePatch'), { id: id, patchData: data, prevData: existingdata }, false);
|
|
909
745
|
const dbsession = appuser.getDBSession();
|
|
910
746
|
if (dbsession && !dbsession.inTransaction()) {
|
|
911
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
747
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
912
748
|
}
|
|
913
749
|
// try {
|
|
914
750
|
Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -963,7 +799,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
963
799
|
// Get DB Session
|
|
964
800
|
const dbsession = appuser.getDBSession();
|
|
965
801
|
if (dbsession && !dbsession.inTransaction()) {
|
|
966
|
-
dbsession.startTransaction({ readPreference: 'primary' });
|
|
802
|
+
dbsession.startTransaction({readConcern:{level:"snapshot"},writeConcern:{w:"majority"}, readPreference: 'primary' });
|
|
967
803
|
}
|
|
968
804
|
|
|
969
805
|
const result = await this.doc.updateMany(isolationFilter, { $set: patch }, { session: dbsession });
|