@infineit-nestjs/services 1.0.16 → 1.0.17
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/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/services/entity.action.service.js +1 -0
- package/dist/cjs/services/index.d.ts +3 -2
- package/dist/cjs/services/index.js +1 -1
- package/dist/es/index.d.ts +3 -2
- package/dist/es/index.js +1 -1
- package/dist/es/services/entity.action.service.js +1 -0
- package/dist/es/services/index.d.ts +3 -2
- package/dist/es/services/index.js +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/services/entity.action.service.d.ts +44 -0
- package/dist/types/services/index.d.ts +3 -2
- package/package.json +4 -4
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from './services/argon2.service';
|
|
2
2
|
export * from './services/data.transformer.service';
|
|
3
|
+
export * from './services/entity.action.service';
|
|
3
4
|
export * from './services/http.client.service';
|
|
4
5
|
export * from './services/logger.service';
|
|
5
|
-
export * from './services/message.formatter.service';
|
|
6
6
|
export * from './services/merge.service';
|
|
7
|
+
export * from './services/message.formatter.service';
|
|
7
8
|
export * from './services/pagination.service';
|
|
8
9
|
export * from './services/prisma.service';
|
|
9
10
|
export * from './services/resource.fetch.service';
|
|
10
|
-
export * from './services/validator.service';
|
|
11
11
|
export * from './services/util.service';
|
|
12
|
+
export * from './services/validator.service';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./services/argon2.service"),exports),e.__exportStar(require("./services/data.transformer.service"),exports),e.__exportStar(require("./services/http.client.service"),exports),e.__exportStar(require("./services/logger.service"),exports),e.__exportStar(require("./services/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./services/argon2.service"),exports),e.__exportStar(require("./services/data.transformer.service"),exports),e.__exportStar(require("./services/entity.action.service"),exports),e.__exportStar(require("./services/http.client.service"),exports),e.__exportStar(require("./services/logger.service"),exports),e.__exportStar(require("./services/merge.service"),exports),e.__exportStar(require("./services/message.formatter.service"),exports),e.__exportStar(require("./services/pagination.service"),exports),e.__exportStar(require("./services/prisma.service"),exports),e.__exportStar(require("./services/resource.fetch.service"),exports),e.__exportStar(require("./services/util.service"),exports),e.__exportStar(require("./services/validator.service"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EntityActionService=void 0;const e=require("tslib"),r=require("@nestjs/common"),t=e.__importDefault(require("p-limit")),i=require("./logger.service"),s=require("./prisma.service");let n=class{constructor(e,r){this.prismaService=e,this.loggerService=r,this.batchSize=parseInt(process.env.BATCH_SIZE??"100",10),this.concurrencyLimit=parseInt(process.env.CONCURRENCY_LIMIT??"3",10)}async handleEntityActions(e,r,i,s){const n=this.capitalize(e),c=(0,t.default)(this.concurrencyLimit);try{const t=[];for(let e=0;e<r.length;e+=this.batchSize){const o=r.slice(e,e+this.batchSize);t.push(c((async()=>{this.loggerService.info(`Processing batch ${e/this.batchSize+1} for ${n}`);return await Promise.all(o.map((async(r,t)=>{const c=e+t;try{r[i.id]=i.value,"edit"===r.action&&(r.id=r[i.id_table_primary_key]);return{success:!0,id_return:(await this.executeQuery(r.action,n,"delete"===r.action?r[i.id_table_primary_key]:r,s[0][r.action])).id_return,data:r,index:c}}catch(e){return this.loggerService.error(`Error in batch operation for ${n}`,{error:e instanceof Error?e:new Error(String(e))}),{success:!1,error:e instanceof Error?e.message:String(e),data:r,index:c,retunrn_entity_name:i.id_return||"unknown_return_entity"}}})))})))}const o=(await Promise.all(t)).flat(),a=o.filter((e=>e.success)),u=o.filter((e=>!e.success));return{entity:e,message:`${n} operations completed.`,success:0===u.length,totalProcessed:r.length,totalFailed:u.length,totalSucceeded:a.length,failedOperations:u,succeededOperations:a}}catch(r){return this.loggerService.error(`Error during ${n} operations`,{error:r instanceof Error?r:new Error(String(r))}),{entity:e,message:"An unexpected error occurred during the operations.",success:!1}}}async processEntities(e){const r=e.filter((e=>!e.success)).reduce(((e,r)=>{const t=r.failedOperations.map((e=>({[e.retunrn_entity_name]:e.id_return,message:e.error,index:e.index})));return e.push({field:r.entity,errors:t}),e}),[]);return r.length>0?{success:!1,errorsByEntity:r}:{success:!0}}async executeQuery(e,r,t,i){try{const e=await this.prismaService.executeRawQuery(i,t);return{success:!0,id_return:e?.id||null}}catch(t){throw this.loggerService.error(`Error in ${e} operation for ${r}`,{error:t instanceof Error?t:new Error(String(t))}),new Error(`Error executing ${e} operation: ${r}`)}}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};exports.EntityActionService=n,exports.EntityActionService=n=e.__decorate([(0,r.Injectable)(),e.__metadata("design:paramtypes",[s.PrismaService,i.LoggerService])],n);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from './argon2.service';
|
|
2
2
|
export * from './data.transformer.service';
|
|
3
|
+
export * from './entity.action.service';
|
|
3
4
|
export * from './http.client.service';
|
|
4
5
|
export * from './logger.service';
|
|
5
|
-
export * from './message.formatter.service';
|
|
6
6
|
export * from './merge.service';
|
|
7
|
+
export * from './message.formatter.service';
|
|
7
8
|
export * from './pagination.service';
|
|
8
9
|
export * from './prisma.service';
|
|
9
10
|
export * from './resource.fetch.service';
|
|
10
|
-
export * from './validator.service';
|
|
11
11
|
export * from './util.service';
|
|
12
|
+
export * from './validator.service';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./argon2.service"),exports),e.__exportStar(require("./data.transformer.service"),exports),e.__exportStar(require("./http.client.service"),exports),e.__exportStar(require("./logger.service"),exports),e.__exportStar(require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./argon2.service"),exports),e.__exportStar(require("./data.transformer.service"),exports),e.__exportStar(require("./entity.action.service"),exports),e.__exportStar(require("./http.client.service"),exports),e.__exportStar(require("./logger.service"),exports),e.__exportStar(require("./merge.service"),exports),e.__exportStar(require("./message.formatter.service"),exports),e.__exportStar(require("./pagination.service"),exports),e.__exportStar(require("./prisma.service"),exports),e.__exportStar(require("./resource.fetch.service"),exports),e.__exportStar(require("./util.service"),exports),e.__exportStar(require("./validator.service"),exports);
|
package/dist/es/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from './services/argon2.service';
|
|
2
2
|
export * from './services/data.transformer.service';
|
|
3
|
+
export * from './services/entity.action.service';
|
|
3
4
|
export * from './services/http.client.service';
|
|
4
5
|
export * from './services/logger.service';
|
|
5
|
-
export * from './services/message.formatter.service';
|
|
6
6
|
export * from './services/merge.service';
|
|
7
|
+
export * from './services/message.formatter.service';
|
|
7
8
|
export * from './services/pagination.service';
|
|
8
9
|
export * from './services/prisma.service';
|
|
9
10
|
export * from './services/resource.fetch.service';
|
|
10
|
-
export * from './services/validator.service';
|
|
11
11
|
export * from './services/util.service';
|
|
12
|
+
export * from './services/validator.service';
|
package/dist/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./services/argon2.service"),exports),e.__exportStar(require("./services/data.transformer.service"),exports),e.__exportStar(require("./services/http.client.service"),exports),e.__exportStar(require("./services/logger.service"),exports),e.__exportStar(require("./services/
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./services/argon2.service"),exports),e.__exportStar(require("./services/data.transformer.service"),exports),e.__exportStar(require("./services/entity.action.service"),exports),e.__exportStar(require("./services/http.client.service"),exports),e.__exportStar(require("./services/logger.service"),exports),e.__exportStar(require("./services/merge.service"),exports),e.__exportStar(require("./services/message.formatter.service"),exports),e.__exportStar(require("./services/pagination.service"),exports),e.__exportStar(require("./services/prisma.service"),exports),e.__exportStar(require("./services/resource.fetch.service"),exports),e.__exportStar(require("./services/util.service"),exports),e.__exportStar(require("./services/validator.service"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.EntityActionService=void 0;const e=require("tslib"),r=require("@nestjs/common"),t=e.__importDefault(require("p-limit")),i=require("./logger.service"),s=require("./prisma.service");let n=class{constructor(e,r){this.prismaService=e,this.loggerService=r,this.batchSize=parseInt(process.env.BATCH_SIZE??"100",10),this.concurrencyLimit=parseInt(process.env.CONCURRENCY_LIMIT??"3",10)}async handleEntityActions(e,r,i,s){const n=this.capitalize(e),c=(0,t.default)(this.concurrencyLimit);try{const t=[];for(let e=0;e<r.length;e+=this.batchSize){const o=r.slice(e,e+this.batchSize);t.push(c((async()=>{this.loggerService.info(`Processing batch ${e/this.batchSize+1} for ${n}`);return await Promise.all(o.map((async(r,t)=>{const c=e+t;try{r[i.id]=i.value,"edit"===r.action&&(r.id=r[i.id_table_primary_key]);return{success:!0,id_return:(await this.executeQuery(r.action,n,"delete"===r.action?r[i.id_table_primary_key]:r,s[0][r.action])).id_return,data:r,index:c}}catch(e){return this.loggerService.error(`Error in batch operation for ${n}`,{error:e instanceof Error?e:new Error(String(e))}),{success:!1,error:e instanceof Error?e.message:String(e),data:r,index:c,retunrn_entity_name:i.id_return||"unknown_return_entity"}}})))})))}const o=(await Promise.all(t)).flat(),a=o.filter((e=>e.success)),u=o.filter((e=>!e.success));return{entity:e,message:`${n} operations completed.`,success:0===u.length,totalProcessed:r.length,totalFailed:u.length,totalSucceeded:a.length,failedOperations:u,succeededOperations:a}}catch(r){return this.loggerService.error(`Error during ${n} operations`,{error:r instanceof Error?r:new Error(String(r))}),{entity:e,message:"An unexpected error occurred during the operations.",success:!1}}}async processEntities(e){const r=e.filter((e=>!e.success)).reduce(((e,r)=>{const t=r.failedOperations.map((e=>({[e.retunrn_entity_name]:e.id_return,message:e.error,index:e.index})));return e.push({field:r.entity,errors:t}),e}),[]);return r.length>0?{success:!1,errorsByEntity:r}:{success:!0}}async executeQuery(e,r,t,i){try{const e=await this.prismaService.executeRawQuery(i,t);return{success:!0,id_return:e?.id||null}}catch(t){throw this.loggerService.error(`Error in ${e} operation for ${r}`,{error:t instanceof Error?t:new Error(String(t))}),new Error(`Error executing ${e} operation: ${r}`)}}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};exports.EntityActionService=n,exports.EntityActionService=n=e.__decorate([(0,r.Injectable)(),e.__metadata("design:paramtypes",[s.PrismaService,i.LoggerService])],n);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export * from './argon2.service';
|
|
2
2
|
export * from './data.transformer.service';
|
|
3
|
+
export * from './entity.action.service';
|
|
3
4
|
export * from './http.client.service';
|
|
4
5
|
export * from './logger.service';
|
|
5
|
-
export * from './message.formatter.service';
|
|
6
6
|
export * from './merge.service';
|
|
7
|
+
export * from './message.formatter.service';
|
|
7
8
|
export * from './pagination.service';
|
|
8
9
|
export * from './prisma.service';
|
|
9
10
|
export * from './resource.fetch.service';
|
|
10
|
-
export * from './validator.service';
|
|
11
11
|
export * from './util.service';
|
|
12
|
+
export * from './validator.service';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./argon2.service"),exports),e.__exportStar(require("./data.transformer.service"),exports),e.__exportStar(require("./http.client.service"),exports),e.__exportStar(require("./logger.service"),exports),e.__exportStar(require("./
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});const e=require("tslib");e.__exportStar(require("./argon2.service"),exports),e.__exportStar(require("./data.transformer.service"),exports),e.__exportStar(require("./entity.action.service"),exports),e.__exportStar(require("./http.client.service"),exports),e.__exportStar(require("./logger.service"),exports),e.__exportStar(require("./merge.service"),exports),e.__exportStar(require("./message.formatter.service"),exports),e.__exportStar(require("./pagination.service"),exports),e.__exportStar(require("./prisma.service"),exports),e.__exportStar(require("./resource.fetch.service"),exports),e.__exportStar(require("./util.service"),exports),e.__exportStar(require("./validator.service"),exports);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { Argon2Service } from './services/argon2.service.js';
|
|
2
2
|
export { DataTransformerService } from './services/data.transformer.service.js';
|
|
3
|
+
export { EntityActionService } from './services/entity.action.service.js';
|
|
3
4
|
export { HttpServiceClient } from './services/http.client.service.js';
|
|
4
5
|
export { ILogData, LogLevel, LoggerService } from './services/logger.service.js';
|
|
5
|
-
export { MessageFormatterService } from './services/message.formatter.service.js';
|
|
6
6
|
export { MergeService } from './services/merge.service.js';
|
|
7
|
+
export { MessageFormatterService } from './services/message.formatter.service.js';
|
|
7
8
|
export { PaginationService } from './services/pagination.service.js';
|
|
8
9
|
export { PrismaService } from './services/prisma.service.js';
|
|
9
10
|
export { IResourceConfig, ResourceFetchService } from './services/resource.fetch.service.js';
|
|
10
|
-
export { ValidatorService } from './services/validator.service.js';
|
|
11
11
|
export { UtilsService } from './services/util.service.js';
|
|
12
|
+
export { ValidatorService } from './services/validator.service.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LoggerService } from './logger.service.js';
|
|
2
|
+
import { PrismaService } from './prisma.service.js';
|
|
3
|
+
|
|
4
|
+
declare class EntityActionService {
|
|
5
|
+
private prismaService;
|
|
6
|
+
private loggerService;
|
|
7
|
+
private readonly batchSize;
|
|
8
|
+
private readonly concurrencyLimit;
|
|
9
|
+
constructor(prismaService: PrismaService, loggerService: LoggerService);
|
|
10
|
+
handleEntityActions(entity: string, actionData: any[], idEntity: {
|
|
11
|
+
id: string;
|
|
12
|
+
value: any;
|
|
13
|
+
id_return: string;
|
|
14
|
+
id_table_primary_key: string;
|
|
15
|
+
}, query: any[]): Promise<{
|
|
16
|
+
entity: string;
|
|
17
|
+
message: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
totalProcessed?: number;
|
|
20
|
+
totalFailed?: number;
|
|
21
|
+
totalSucceeded?: number;
|
|
22
|
+
failedOperations?: {
|
|
23
|
+
success: boolean;
|
|
24
|
+
error?: string;
|
|
25
|
+
data?: any;
|
|
26
|
+
index: number;
|
|
27
|
+
retunrn_entity_name?: string;
|
|
28
|
+
}[];
|
|
29
|
+
succeededOperations?: {
|
|
30
|
+
success: boolean;
|
|
31
|
+
id_return: string;
|
|
32
|
+
data?: any;
|
|
33
|
+
index: number;
|
|
34
|
+
}[];
|
|
35
|
+
}>;
|
|
36
|
+
processEntities(entityResults: any[]): Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
errorsByEntity?: Record<string, any[]>;
|
|
39
|
+
}>;
|
|
40
|
+
private executeQuery;
|
|
41
|
+
private capitalize;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { EntityActionService };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { Argon2Service } from './argon2.service.js';
|
|
2
2
|
export { DataTransformerService } from './data.transformer.service.js';
|
|
3
|
+
export { EntityActionService } from './entity.action.service.js';
|
|
3
4
|
export { HttpServiceClient } from './http.client.service.js';
|
|
4
5
|
export { ILogData, LogLevel, LoggerService } from './logger.service.js';
|
|
5
|
-
export { MessageFormatterService } from './message.formatter.service.js';
|
|
6
6
|
export { MergeService } from './merge.service.js';
|
|
7
|
+
export { MessageFormatterService } from './message.formatter.service.js';
|
|
7
8
|
export { PaginationService } from './pagination.service.js';
|
|
8
9
|
export { PrismaService } from './prisma.service.js';
|
|
9
10
|
export { IResourceConfig, ResourceFetchService } from './resource.fetch.service.js';
|
|
10
|
-
export { ValidatorService } from './validator.service.js';
|
|
11
11
|
export { UtilsService } from './util.service.js';
|
|
12
|
+
export { ValidatorService } from './validator.service.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infineit-nestjs/services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/es/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\""
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@infineit-nestjs/core": "1.0.
|
|
40
|
+
"@infineit-nestjs/core": "1.0.8",
|
|
41
41
|
"@infineit-nestjs/types": "1.0.2",
|
|
42
|
-
"@infineit-nestjs/utils": "1.0.
|
|
42
|
+
"@infineit-nestjs/utils": "1.0.18",
|
|
43
43
|
"@infineit/winston-logger": "^1.0.30",
|
|
44
44
|
"@nestjs/axios": "^4.0.0",
|
|
45
45
|
"@nestjs/terminus": "^11.0.0",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "4935c002791f75083940f99b0c85ef3f38be1f52"
|
|
101
101
|
}
|