@opra/sqb 1.0.0-alpha.36 → 1.0.0-alpha.38
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.
|
@@ -473,10 +473,42 @@ class SqbEntityService extends core_1.ServiceBase {
|
|
|
473
473
|
if (!(proto instanceof SqbEntityService))
|
|
474
474
|
break;
|
|
475
475
|
}
|
|
476
|
+
/** Call before[X] hooks */
|
|
477
|
+
if (command.crud === 'create')
|
|
478
|
+
await this._beforeCreate(command);
|
|
479
|
+
else if (command.crud === 'update' && command.byId) {
|
|
480
|
+
await this._beforeUpdate(command);
|
|
481
|
+
}
|
|
482
|
+
else if (command.crud === 'update' && !command.byId) {
|
|
483
|
+
await this._beforeUpdateMany(command);
|
|
484
|
+
}
|
|
485
|
+
else if (command.crud === 'delete' && command.byId) {
|
|
486
|
+
await this._beforeDelete(command);
|
|
487
|
+
}
|
|
488
|
+
else if (command.crud === 'delete' && !command.byId) {
|
|
489
|
+
await this._beforeDeleteMany(command);
|
|
490
|
+
}
|
|
491
|
+
/** Call command function */
|
|
476
492
|
return commandFn();
|
|
477
493
|
};
|
|
478
494
|
try {
|
|
479
|
-
|
|
495
|
+
const result = await next();
|
|
496
|
+
/** Call after[X] hooks */
|
|
497
|
+
if (command.crud === 'create')
|
|
498
|
+
await this._afterCreate(command, result);
|
|
499
|
+
else if (command.crud === 'update' && command.byId) {
|
|
500
|
+
await this._afterUpdate(command, result);
|
|
501
|
+
}
|
|
502
|
+
else if (command.crud === 'update' && !command.byId) {
|
|
503
|
+
await this._afterUpdateMany(command, result);
|
|
504
|
+
}
|
|
505
|
+
else if (command.crud === 'delete' && command.byId) {
|
|
506
|
+
await this._afterDelete(command, result);
|
|
507
|
+
}
|
|
508
|
+
else if (command.crud === 'delete' && !command.byId) {
|
|
509
|
+
await this._afterDeleteMany(command, result);
|
|
510
|
+
}
|
|
511
|
+
return result;
|
|
480
512
|
}
|
|
481
513
|
catch (e) {
|
|
482
514
|
Error.captureStackTrace(e, this._executeCommand);
|
|
@@ -484,5 +516,45 @@ class SqbEntityService extends core_1.ServiceBase {
|
|
|
484
516
|
throw e;
|
|
485
517
|
}
|
|
486
518
|
}
|
|
519
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
520
|
+
async _beforeCreate(command) {
|
|
521
|
+
// Do nothing
|
|
522
|
+
}
|
|
523
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
524
|
+
async _beforeUpdate(command) {
|
|
525
|
+
// Do nothing
|
|
526
|
+
}
|
|
527
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
528
|
+
async _beforeUpdateMany(command) {
|
|
529
|
+
// Do nothing
|
|
530
|
+
}
|
|
531
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
532
|
+
async _beforeDelete(command) {
|
|
533
|
+
// Do nothing
|
|
534
|
+
}
|
|
535
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
536
|
+
async _beforeDeleteMany(command) {
|
|
537
|
+
// Do nothing
|
|
538
|
+
}
|
|
539
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
540
|
+
async _afterCreate(command, result) {
|
|
541
|
+
// Do nothing
|
|
542
|
+
}
|
|
543
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
544
|
+
async _afterUpdate(command, result) {
|
|
545
|
+
// Do nothing
|
|
546
|
+
}
|
|
547
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
548
|
+
async _afterUpdateMany(command, affected) {
|
|
549
|
+
// Do nothing
|
|
550
|
+
}
|
|
551
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
552
|
+
async _afterDelete(command, affected) {
|
|
553
|
+
// Do nothing
|
|
554
|
+
}
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
556
|
+
async _afterDeleteMany(command, affected) {
|
|
557
|
+
// Do nothing
|
|
558
|
+
}
|
|
487
559
|
}
|
|
488
560
|
exports.SqbEntityService = SqbEntityService;
|
|
@@ -470,10 +470,42 @@ export class SqbEntityService extends ServiceBase {
|
|
|
470
470
|
if (!(proto instanceof SqbEntityService))
|
|
471
471
|
break;
|
|
472
472
|
}
|
|
473
|
+
/** Call before[X] hooks */
|
|
474
|
+
if (command.crud === 'create')
|
|
475
|
+
await this._beforeCreate(command);
|
|
476
|
+
else if (command.crud === 'update' && command.byId) {
|
|
477
|
+
await this._beforeUpdate(command);
|
|
478
|
+
}
|
|
479
|
+
else if (command.crud === 'update' && !command.byId) {
|
|
480
|
+
await this._beforeUpdateMany(command);
|
|
481
|
+
}
|
|
482
|
+
else if (command.crud === 'delete' && command.byId) {
|
|
483
|
+
await this._beforeDelete(command);
|
|
484
|
+
}
|
|
485
|
+
else if (command.crud === 'delete' && !command.byId) {
|
|
486
|
+
await this._beforeDeleteMany(command);
|
|
487
|
+
}
|
|
488
|
+
/** Call command function */
|
|
473
489
|
return commandFn();
|
|
474
490
|
};
|
|
475
491
|
try {
|
|
476
|
-
|
|
492
|
+
const result = await next();
|
|
493
|
+
/** Call after[X] hooks */
|
|
494
|
+
if (command.crud === 'create')
|
|
495
|
+
await this._afterCreate(command, result);
|
|
496
|
+
else if (command.crud === 'update' && command.byId) {
|
|
497
|
+
await this._afterUpdate(command, result);
|
|
498
|
+
}
|
|
499
|
+
else if (command.crud === 'update' && !command.byId) {
|
|
500
|
+
await this._afterUpdateMany(command, result);
|
|
501
|
+
}
|
|
502
|
+
else if (command.crud === 'delete' && command.byId) {
|
|
503
|
+
await this._afterDelete(command, result);
|
|
504
|
+
}
|
|
505
|
+
else if (command.crud === 'delete' && !command.byId) {
|
|
506
|
+
await this._afterDeleteMany(command, result);
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
477
509
|
}
|
|
478
510
|
catch (e) {
|
|
479
511
|
Error.captureStackTrace(e, this._executeCommand);
|
|
@@ -481,4 +513,44 @@ export class SqbEntityService extends ServiceBase {
|
|
|
481
513
|
throw e;
|
|
482
514
|
}
|
|
483
515
|
}
|
|
516
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
517
|
+
async _beforeCreate(command) {
|
|
518
|
+
// Do nothing
|
|
519
|
+
}
|
|
520
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
521
|
+
async _beforeUpdate(command) {
|
|
522
|
+
// Do nothing
|
|
523
|
+
}
|
|
524
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
525
|
+
async _beforeUpdateMany(command) {
|
|
526
|
+
// Do nothing
|
|
527
|
+
}
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
529
|
+
async _beforeDelete(command) {
|
|
530
|
+
// Do nothing
|
|
531
|
+
}
|
|
532
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
533
|
+
async _beforeDeleteMany(command) {
|
|
534
|
+
// Do nothing
|
|
535
|
+
}
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
537
|
+
async _afterCreate(command, result) {
|
|
538
|
+
// Do nothing
|
|
539
|
+
}
|
|
540
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
541
|
+
async _afterUpdate(command, result) {
|
|
542
|
+
// Do nothing
|
|
543
|
+
}
|
|
544
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
545
|
+
async _afterUpdateMany(command, affected) {
|
|
546
|
+
// Do nothing
|
|
547
|
+
}
|
|
548
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
549
|
+
async _afterDelete(command, affected) {
|
|
550
|
+
// Do nothing
|
|
551
|
+
}
|
|
552
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
553
|
+
async _afterDeleteMany(command, affected) {
|
|
554
|
+
// Do nothing
|
|
555
|
+
}
|
|
484
556
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/sqb",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.38",
|
|
4
4
|
"description": "Opra SQB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"valgen": "^5.9.0"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/core": "^1.0.0-alpha.
|
|
13
|
+
"@opra/core": "^1.0.0-alpha.38",
|
|
14
14
|
"@sqb/connect": ">= 4.10.6"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
@@ -428,4 +428,14 @@ export declare class SqbEntityService<T extends object = object> extends Service
|
|
|
428
428
|
*/
|
|
429
429
|
protected _getCommonFilter(command: SqbEntityService.CommandInfo): SQBAdapter.FilterInput | Promise<SQBAdapter.FilterInput> | undefined;
|
|
430
430
|
protected _executeCommand(command: SqbEntityService.CommandInfo, commandFn: () => any): Promise<any>;
|
|
431
|
+
protected _beforeCreate(command: SqbEntityService.CreateCommand): Promise<void>;
|
|
432
|
+
protected _beforeUpdate(command: SqbEntityService.UpdateOneCommand<T>): Promise<void>;
|
|
433
|
+
protected _beforeUpdateMany(command: SqbEntityService.UpdateManyCommand<T>): Promise<void>;
|
|
434
|
+
protected _beforeDelete(command: SqbEntityService.DeleteOneCommand): Promise<void>;
|
|
435
|
+
protected _beforeDeleteMany(command: SqbEntityService.DeleteManyCommand): Promise<void>;
|
|
436
|
+
protected _afterCreate(command: SqbEntityService.CreateCommand, result: PartialDTO<T>): Promise<void>;
|
|
437
|
+
protected _afterUpdate(command: SqbEntityService.UpdateOneCommand<T>, result?: PartialDTO<T>): Promise<void>;
|
|
438
|
+
protected _afterUpdateMany(command: SqbEntityService.UpdateManyCommand<T>, affected: number): Promise<void>;
|
|
439
|
+
protected _afterDelete(command: SqbEntityService.DeleteOneCommand, affected: number): Promise<void>;
|
|
440
|
+
protected _afterDeleteMany(command: SqbEntityService.DeleteManyCommand, affected: number): Promise<void>;
|
|
431
441
|
}
|