@creatioart-js/express-storage 0.1.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +192 -0
  3. package/README.md +87 -0
  4. package/lib/enum/database.type.d.ts +4 -0
  5. package/lib/enum/database.type.js +9 -0
  6. package/lib/enum/database.type.js.map +1 -0
  7. package/lib/index.d.ts +11 -0
  8. package/lib/index.js +16 -0
  9. package/lib/index.js.map +1 -0
  10. package/lib/repository/base.datastore.repository.d.ts +14 -0
  11. package/lib/repository/base.datastore.repository.js +161 -0
  12. package/lib/repository/base.datastore.repository.js.map +1 -0
  13. package/lib/repository/base.firestore.repository.d.ts +14 -0
  14. package/lib/repository/base.firestore.repository.js +165 -0
  15. package/lib/repository/base.firestore.repository.js.map +1 -0
  16. package/lib/repository/interfaces/iRepository.d.ts +9 -0
  17. package/lib/repository/interfaces/iRepository.js +3 -0
  18. package/lib/repository/interfaces/iRepository.js.map +1 -0
  19. package/lib/repository/interfaces/iRepository.manager.repository.d.ts +4 -0
  20. package/lib/repository/interfaces/iRepository.manager.repository.js +3 -0
  21. package/lib/repository/interfaces/iRepository.manager.repository.js.map +1 -0
  22. package/lib/service/base.service.d.ts +15 -0
  23. package/lib/service/base.service.js +114 -0
  24. package/lib/service/base.service.js.map +1 -0
  25. package/lib/service/big.query.service.d.ts +6 -0
  26. package/lib/service/big.query.service.js +183 -0
  27. package/lib/service/big.query.service.js.map +1 -0
  28. package/lib/service/interfaces/ibase.service.d.ts +10 -0
  29. package/lib/service/interfaces/ibase.service.js +3 -0
  30. package/lib/service/interfaces/ibase.service.js.map +1 -0
  31. package/lib/service/interfaces/ibig.query.service.d.ts +4 -0
  32. package/lib/service/interfaces/ibig.query.service.js +3 -0
  33. package/lib/service/interfaces/ibig.query.service.js.map +1 -0
  34. package/lib/service/interfaces/iredis.cache.service.d.ts +7 -0
  35. package/lib/service/interfaces/iredis.cache.service.js +3 -0
  36. package/lib/service/interfaces/iredis.cache.service.js.map +1 -0
  37. package/lib/service/redis.cache.service.d.ts +18 -0
  38. package/lib/service/redis.cache.service.js +172 -0
  39. package/lib/service/redis.cache.service.js.map +1 -0
  40. package/package.json +124 -0
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseFirestoreRepository = void 0;
4
+ require("reflect-metadata");
5
+ const express_logging_1 = require("@creatioart-js/express-logging");
6
+ const express_core_1 = require("@creatioart-js/express-core");
7
+ const express_error_1 = require("@creatioart-js/express-error");
8
+ const express_error_handler_1 = require("@creatioart-js/express-error-handler");
9
+ class BaseFirestoreRepository {
10
+ key;
11
+ firestore;
12
+ constructor(firestore, key) {
13
+ this.firestore = firestore;
14
+ this.key = key;
15
+ }
16
+ async create(item, traceId) {
17
+ try {
18
+ (0, express_logging_1.Logger)().info(`Create Entity on Firestore by ${this.key} ${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
19
+ const collectionReference = this.firestore.collection(this.key);
20
+ delete item.id;
21
+ const createdEntity = await collectionReference.add(JSON.parse(JSON.stringify(item)));
22
+ if (createdEntity === undefined) {
23
+ (0, express_logging_1.Logger)().error(`Oops! Error on Create Entity on Firestore ` +
24
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
25
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.INTERNAL_SERVER_ERROR, `Oops! Error on create entity`, express_error_1.ErrorCode.INTERNAL_SERVER_ERROR_BASE));
26
+ }
27
+ item.id = createdEntity.id;
28
+ }
29
+ catch (error) {
30
+ if (error instanceof express_error_handler_1.ErrorResponse) {
31
+ throw error;
32
+ }
33
+ if (error && Object.keys(error) !== undefined && Object.keys(error).length > 0) {
34
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
35
+ }
36
+ else {
37
+ (0, express_logging_1.Logger)().warn(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
38
+ (0, express_logging_1.Logger)().warn(`Undefined Error on Create Entity on Firestore ` +
39
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
40
+ }
41
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.INTERNAL_SERVER_ERROR, `Oops! Error on create entity`, express_error_1.ErrorCode.INTERNAL_SERVER_ERROR_BASE));
42
+ }
43
+ return item;
44
+ }
45
+ async update(item, traceId) {
46
+ try {
47
+ (0, express_logging_1.Logger)().info(`Edit Entity on Firestore by ${this.key} ${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
48
+ const id = item.id;
49
+ const collectionReference = this.firestore.collection(this.key);
50
+ const documentReference = collectionReference.doc(id);
51
+ delete item.id;
52
+ await documentReference.update(JSON.parse(JSON.stringify(item)));
53
+ item.id = id;
54
+ }
55
+ catch (error) {
56
+ if (error && Object.keys(error) !== undefined && Object.keys(error).length > 0) {
57
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
58
+ }
59
+ else {
60
+ (0, express_logging_1.Logger)().warn(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
61
+ (0, express_logging_1.Logger)().warn(`Undefined Error on Uptate Entity on Firestore ` +
62
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
63
+ }
64
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.INTERNAL_SERVER_ERROR, `Oops! Error on uptate entity`, express_error_1.ErrorCode.INTERNAL_SERVER_ERROR_BASE));
65
+ }
66
+ return item;
67
+ }
68
+ async delete(id, traceId) {
69
+ try {
70
+ (0, express_logging_1.Logger)().info(`Delete by Id on Firestore by ${this.key} ${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
71
+ const collectionReference = this.firestore.collection(this.key);
72
+ const documentReference = collectionReference.doc(id);
73
+ if (documentReference !== undefined) {
74
+ await documentReference.delete();
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+ catch (error) {
80
+ if (error && Object.keys(error) !== undefined && Object.keys(error).length > 0) {
81
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
82
+ }
83
+ else {
84
+ (0, express_logging_1.Logger)().warn(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
85
+ (0, express_logging_1.Logger)().warn(`Undefined Error on Delete Entity on Firestore ` +
86
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
87
+ }
88
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.INTERNAL_SERVER_ERROR, `Oops! Error on delete entity`, express_error_1.ErrorCode.INTERNAL_SERVER_ERROR_BASE));
89
+ }
90
+ }
91
+ async findOne(id, filter, traceId) {
92
+ (0, express_logging_1.Logger)().info(`Get by Id on Filter on Firestore by ${this.key} ` +
93
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
94
+ try {
95
+ let collectionReference = this.firestore.collection(this.key);
96
+ collectionReference = express_core_1.Filter.setQueryFilter(collectionReference, filter, express_core_1.FilterType.FIRESTORE);
97
+ const documentReference = collectionReference.doc(id);
98
+ if (documentReference !== undefined) {
99
+ const response = await documentReference.get();
100
+ if (response !== undefined && response.exists) {
101
+ const entity = response.data();
102
+ entity.id = response.id;
103
+ return entity;
104
+ }
105
+ }
106
+ }
107
+ catch (error) {
108
+ if (error && Object.keys(error) !== undefined && Object.keys(error).length > 0) {
109
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
110
+ }
111
+ else {
112
+ (0, express_logging_1.Logger)().warn(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
113
+ (0, express_logging_1.Logger)().warn(`Undefined Error on Get By Id Entity on Firestore ` +
114
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
115
+ }
116
+ }
117
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.EntityError(express_core_1.ErrorStatus.NOT_FOUND, `Oops! You're trying to get an invalid data. Please check it and try again`, express_error_1.ErrorCode.NOT_FOUND_BASE, this.key, undefined));
118
+ }
119
+ async findBy(filter, order, page, pageCount, traceId) {
120
+ (0, express_logging_1.Logger)().info(`Get Entities List by Filter on Firestore by ${this.key} ` +
121
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
122
+ try {
123
+ let collectionReference = this.firestore.collection(this.key);
124
+ collectionReference = express_core_1.Filter.setQueryFilter(collectionReference, filter, express_core_1.FilterType.FIRESTORE);
125
+ collectionReference = express_core_1.Order.setQueryOrder(collectionReference, order, express_core_1.OrderType.FIRESTORE);
126
+ const count = await this.count(filter);
127
+ if (page !== undefined && pageCount !== undefined && page > 0 && pageCount > 0) {
128
+ collectionReference = collectionReference.limit(pageCount);
129
+ collectionReference = collectionReference.offset((page - 1) * pageCount);
130
+ }
131
+ const response = await collectionReference.get();
132
+ if (response !== undefined && response.size > 0) {
133
+ const list = [];
134
+ for (const item of response.docs) {
135
+ const entity = item.data();
136
+ entity.id = item.id;
137
+ list.push(entity);
138
+ }
139
+ return new express_core_1.BaseList(count, list);
140
+ }
141
+ }
142
+ catch (error) {
143
+ if (error && Object.keys(error) !== undefined && Object.keys(error).length > 0) {
144
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
145
+ }
146
+ else {
147
+ (0, express_logging_1.Logger)().warn(express_core_1.ErrorHelper.toErrorString(error, traceId ?? ''));
148
+ (0, express_logging_1.Logger)().warn(`Undefined Error on Find By Entity on Firestore ` +
149
+ `${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
150
+ }
151
+ }
152
+ return new express_core_1.BaseList(0, []);
153
+ }
154
+ async count(filter, traceId) {
155
+ (0, express_logging_1.Logger)().info(`Get Count element by ${this.key} ${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
156
+ let countQuery = this.firestore.collection(this.key);
157
+ countQuery = express_core_1.Filter.setQueryFilter(countQuery, filter, express_core_1.FilterType.FIRESTORE);
158
+ const countResponse = await countQuery.get();
159
+ const size = countResponse !== undefined && countResponse.size !== undefined ? countResponse.size : 0;
160
+ (0, express_logging_1.Logger)().info(`Count element: ${size} ${traceId !== undefined ? `. Trace: ${traceId}` : ''}`);
161
+ return size;
162
+ }
163
+ }
164
+ exports.BaseFirestoreRepository = BaseFirestoreRepository;
165
+ //# sourceMappingURL=base.firestore.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.firestore.repository.js","sourceRoot":"","sources":["../../src/repository/base.firestore.repository.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAE1B,oEAAsD;AACtD,8DAAiI;AAEjI,gEAAmF;AACnF,gFAAmE;AAKnE,MAAsB,uBAAuB;IACpC,GAAG,CAAS;IAET,SAAS,CAAM;IAOzB,YAAY,SAAc,EAAE,GAAW;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAOM,KAAK,CAAC,MAAM,CAAC,IAAO,EAAE,OAAgB;QAC3C,IAAI,CAAC;YACH,IAAA,wBAAM,GAAE,CAAC,IAAI,CAAC,iCAAiC,IAAI,CAAC,GAAG,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAGjH,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAGhE,OAAO,IAAI,CAAC,EAAE,CAAC;YAGf,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACtF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAEhC,IAAA,wBAAM,GAAE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C,YAAY,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnQD,0DAmQC"}
@@ -0,0 +1,9 @@
1
+ import { BaseList, Filter, Order } from '@creatioart-js/express-core';
2
+ export interface IRepository<T> {
3
+ create(item: T, traceId?: string): Promise<T>;
4
+ update(item: T, traceId?: string): Promise<T>;
5
+ delete(id: any, traceId?: string): Promise<boolean>;
6
+ findOne(id: any, filter: Filter[] | undefined, traceId?: string): Promise<T>;
7
+ findBy(filter: Filter[] | undefined, order: Order | undefined, page: number | 0, pageCount: number | 0, traceId?: string): Promise<BaseList<T>>;
8
+ count(filter: Filter[] | undefined, traceId?: string): Promise<number>;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=iRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iRepository.js","sourceRoot":"","sources":["../../../src/repository/interfaces/iRepository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { IRepository } from './iRepository';
2
+ export interface IRepositoryManager<T> extends IRepository<T> {
3
+ _: boolean;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=iRepository.manager.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iRepository.manager.repository.js","sourceRoot":"","sources":["../../../src/repository/interfaces/iRepository.manager.repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import 'reflect-metadata';
2
+ import { BaseEntity, BaseList, Filter, Order } from '@creatioart-js/express-core';
3
+ import { IBaseService } from './interfaces/ibase.service';
4
+ export declare abstract class BaseService<T extends BaseEntity<T>> implements IBaseService<T> {
5
+ protected entityName: string;
6
+ private repository;
7
+ constructor(repository: any, x: any);
8
+ findBy(filter: Filter[] | undefined, order: Order | undefined, page: number | 0, pageCount: number | 0, traceId: string): Promise<BaseList<T>>;
9
+ findOne(entityId: string, traceId: string): Promise<T | undefined>;
10
+ exist(filter: Filter[] | undefined, traceId: string): Promise<boolean>;
11
+ countBy(filter: Filter[] | undefined, traceId: string): Promise<number>;
12
+ create(entity: T, traceId: string): Promise<T>;
13
+ update(entity: T, traceId: string): Promise<T>;
14
+ delete(entityId: string, traceId: string): Promise<boolean>;
15
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseService = void 0;
4
+ require("reflect-metadata");
5
+ const express_core_1 = require("@creatioart-js/express-core");
6
+ const express_logging_1 = require("@creatioart-js/express-logging");
7
+ const express_error_1 = require("@creatioart-js/express-error");
8
+ const express_error_handler_1 = require("@creatioart-js/express-error-handler");
9
+ class BaseService {
10
+ entityName;
11
+ repository;
12
+ constructor(repository, x) {
13
+ this.entityName = x.Name;
14
+ this.repository = repository;
15
+ }
16
+ async findBy(filter, order, page, pageCount, traceId) {
17
+ (0, express_logging_1.Logger)().info(`Get ${this.entityName} by Filter: ${JSON.stringify(filter)}, Order: ${JSON.stringify(order)}, ` +
18
+ `Page: ${page}, Elements: ${pageCount}. Trace: ${traceId}`);
19
+ return await this.repository.findBy(filter, order, page, pageCount, traceId);
20
+ }
21
+ async findOne(entityId, traceId) {
22
+ try {
23
+ (0, express_logging_1.Logger)().info(`Get ${this.entityName} by ${entityId} id. Trace: ${traceId}`);
24
+ if (entityId !== undefined && entityId !== '') {
25
+ return await this.repository.findOne(entityId, [], traceId);
26
+ }
27
+ }
28
+ catch (err) {
29
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
30
+ (0, express_logging_1.Logger)().error(`You're requesting a data that doesn't exist. Trace: ${traceId}`);
31
+ }
32
+ return undefined;
33
+ }
34
+ async exist(filter, traceId) {
35
+ try {
36
+ (0, express_logging_1.Logger)().info(`Check if any ${this.entityName} exist by filter: ${JSON.stringify(filter)}. Trace: ${traceId}`);
37
+ const count = await this.repository.count(filter, traceId);
38
+ return count > 0 ? true : false;
39
+ }
40
+ catch (err) {
41
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
42
+ (0, express_logging_1.Logger)().error(`Unhandler error in Database. Trace: ${traceId}`);
43
+ }
44
+ return false;
45
+ }
46
+ async countBy(filter, traceId) {
47
+ try {
48
+ (0, express_logging_1.Logger)().info(`Count the ${this.entityName} by filter: ${JSON.stringify(filter)}. Trace: ${traceId}`);
49
+ const count = await this.repository.count(filter, traceId);
50
+ return count > 0 ? count : 0;
51
+ }
52
+ catch (err) {
53
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
54
+ (0, express_logging_1.Logger)().error(`Unhandler error in Database. Trace: ${traceId}`);
55
+ }
56
+ return 0;
57
+ }
58
+ async create(entity, traceId) {
59
+ (0, express_logging_1.Logger)().info(`Create the ${this.entityName}: ${JSON.stringify(entity)}. Trace: ${traceId}`);
60
+ if (entity !== undefined) {
61
+ const validated = await entity.validate();
62
+ if (validated) {
63
+ (0, express_logging_1.Logger)().error(`${JSON.stringify(validated)}. Trace: ${traceId}`);
64
+ throw new express_error_handler_1.ErrorResponse(validated);
65
+ }
66
+ entity = await this.repository.create(entity, traceId);
67
+ if (entity !== undefined) {
68
+ return entity;
69
+ }
70
+ }
71
+ else {
72
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.EntityError(express_core_1.ErrorStatus.NOT_FOUND, `${this.entityName} entity not found`, express_error_1.ErrorCode.NOT_FOUND_BASE, this.entityName, undefined));
73
+ }
74
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.EntityError(express_core_1.ErrorStatus.BAD_REQUEST, `An error occurred while creating the ${this.entityName}`, express_error_1.ErrorCode.BAD_REQUEST_BASE, this.entityName, undefined));
75
+ }
76
+ async update(entity, traceId) {
77
+ (0, express_logging_1.Logger)().info(`Update ${this.entityName} ${JSON.stringify(entity)} by the ${entity.id} entityId. ` +
78
+ `Trace: ${traceId}`);
79
+ if (entity !== undefined) {
80
+ const validated = await entity.validate();
81
+ if (validated) {
82
+ (0, express_logging_1.Logger)().error(`${JSON.stringify(validated)}. Trace: ${traceId}`);
83
+ throw new express_error_handler_1.ErrorResponse(validated);
84
+ }
85
+ entity = await this.repository.update(entity, traceId);
86
+ if (entity !== undefined) {
87
+ return entity;
88
+ }
89
+ }
90
+ else {
91
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.EntityError(express_core_1.ErrorStatus.NOT_FOUND, `${this.entityName} entity not found`, express_error_1.ErrorCode.NOT_FOUND_BASE, this.entityName, undefined));
92
+ }
93
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.EntityError(express_core_1.ErrorStatus.BAD_REQUEST, `An error occurred while updating the ${this.entityName}`, express_error_1.ErrorCode.BAD_REQUEST_BASE, this.entityName, undefined));
94
+ }
95
+ async delete(entityId, traceId) {
96
+ (0, express_logging_1.Logger)().info(`Delete the ${this.entityName} by ${entityId} id. Trace: ${traceId}`);
97
+ let response = false;
98
+ try {
99
+ const entity = await this.findOne(entityId, traceId);
100
+ if (entity !== undefined) {
101
+ response = await this.repository.delete(entityId, traceId);
102
+ }
103
+ }
104
+ catch (err) {
105
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
106
+ (0, express_logging_1.Logger)().error(`Some error ocurr while deleting the ${this.entityName} for the ${entityId} id. ` +
107
+ `Trace: ${traceId}`);
108
+ }
109
+ (0, express_logging_1.Logger)().info(`Delete ${this.entityName} for the ${entityId} id. Result Operation: ${response}. Trace: ${traceId}`);
110
+ return response;
111
+ }
112
+ }
113
+ exports.BaseService = BaseService;
114
+ //# sourceMappingURL=base.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../src/service/base.service.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAE1B,8DAA0G;AAC1G,oEAAsD;AACtD,gEAA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,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,UAAU,OAAO,QAAQ,eAAe,OAAO,EAAE,CAAC,CAAC;QACpF,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAErD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAEzB,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAA,wBAAM,GAAE,CAAC,KAAK,CAAC,0BAAW,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;YACxD,IAAA,wBAAM,GAAE,CAAC,KAAK,CAAC,uCAAuC,IAAI,CAAC,UAAU,YAAY,QAAQ,OAAO;gBACjF,UAAU,OAAO,EAAE,CAAC,CAAC;QACtC,CAAC;QAED,IAAA,wBAAM,GAAE,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,YAAY,QAAQ,0BAA0B,QAAQ,YAAY,OAAO,EAAE,CAAC,CAAC;QACpH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AArLD,kCAqLC"}
@@ -0,0 +1,6 @@
1
+ import 'reflect-metadata';
2
+ import { IBigQueryService } from './interfaces/ibig.query.service';
3
+ export declare class BigQueryService implements IBigQueryService {
4
+ insertRowInBigQuery(bigqueryClient: any, datasetName: string, schema: any, tableName: string, partitionConfig: any, row: any, traceId: string): Promise<boolean>;
5
+ insertMultipleRowsInBigQuery(bigqueryClient: any, datasetName: string, schema: any, tableName: string, partitionConfig: any, rows: any[], traceId: string): Promise<boolean>;
6
+ }
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BigQueryService = void 0;
4
+ require("reflect-metadata");
5
+ const express_core_1 = require("@creatioart-js/express-core");
6
+ const express_logging_1 = require("@creatioart-js/express-logging");
7
+ const express_error_1 = require("@creatioart-js/express-error");
8
+ const express_error_handler_1 = require("@creatioart-js/express-error-handler");
9
+ class BigQueryService {
10
+ async insertRowInBigQuery(bigqueryClient, datasetName, schema, tableName, partitionConfig, row, traceId) {
11
+ (0, express_logging_1.Logger)().info(`Save one Rows In Big Query. Trace: ${traceId}`);
12
+ let response = false;
13
+ const rows = [row];
14
+ const promise = new Promise((resolve, reject) => {
15
+ try {
16
+ (0, express_logging_1.Logger)().info(`Reference to ${datasetName} DataSet. Trace: ${traceId}`);
17
+ const datasetRef = bigqueryClient.dataset(datasetName);
18
+ datasetRef.get({ autoCreate: true }).then(function (data) {
19
+ const dataset = data[0];
20
+ (0, express_logging_1.Logger)().info(`Reference to ${tableName} Table. Trace: ${traceId}`);
21
+ const tableRef = dataset.table(tableName);
22
+ tableRef.exists(function (errExist, exists) {
23
+ if (errExist) {
24
+ (0, express_logging_1.Logger)().error(`Exist error: ${JSON.stringify(errExist)}. Trace: ${traceId}`);
25
+ }
26
+ if (exists) {
27
+ dataset.table(tableName).insert(rows).then(() => {
28
+ resolve({});
29
+ }).catch((inserError) => {
30
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(inserError, traceId));
31
+ (0, express_logging_1.Logger)().error(`Exist table insert error: ${JSON.stringify(inserError)}. Trace: ${traceId}`);
32
+ reject(new Error());
33
+ });
34
+ }
35
+ else {
36
+ (0, express_logging_1.Logger)().info(`Create a new table ${datasetName} table. Trace: ${traceId}`);
37
+ const options = {
38
+ schema,
39
+ };
40
+ if (partitionConfig !== undefined) {
41
+ (0, express_logging_1.Logger)().info('Set Partition Table');
42
+ options.timePartitioning = {
43
+ expirationMs: partitionConfig.expirationMs,
44
+ field: partitionConfig.field,
45
+ requirePartitionFilter: partitionConfig.requirePartitionFilter,
46
+ type: 'DAY'
47
+ };
48
+ }
49
+ dataset.createTable(tableName, options).then(function () {
50
+ dataset.table(tableName).insert(rows).then(() => {
51
+ resolve({});
52
+ }).catch((err) => {
53
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
54
+ (0, express_logging_1.Logger)().error(`Insert in a new table error: ${JSON.stringify(err)}. Trace: ${traceId}`);
55
+ reject(new Error());
56
+ });
57
+ });
58
+ }
59
+ });
60
+ })
61
+ .catch((datasetError) => {
62
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(datasetError, traceId));
63
+ (0, express_logging_1.Logger)().error(`DataSet Error: ${JSON.stringify(datasetError)}. Trace: ${traceId}`);
64
+ if (datasetError.code === 403) {
65
+ resolve({
66
+ googleCode: datasetError.code,
67
+ googleError: datasetError.message !== undefined ? datasetError.message : 'unspecified'
68
+ });
69
+ }
70
+ else {
71
+ reject(new Error());
72
+ }
73
+ });
74
+ }
75
+ catch (error) {
76
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId));
77
+ (0, express_logging_1.Logger)().error(`Promise error: ${JSON.stringify(error)}. Trace: ${traceId}`);
78
+ reject(new Error());
79
+ }
80
+ });
81
+ await promise.then((promiseResponse) => {
82
+ if (promiseResponse.googleCode !== undefined) {
83
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.BAD_REQUEST, `An error occurred while creating a new item in BigQuery for ${datasetName} dataset and ${tableName} ` +
84
+ `table. Google API. Code: ${promiseResponse.googleCode}. Google API response: ${promiseResponse.googleError}`, express_error_1.ErrorCode.BAD_REQUEST_CLOUD_PROCESSING_ERROR));
85
+ }
86
+ response = true;
87
+ }, () => {
88
+ response = false;
89
+ });
90
+ await promise.catch(errorCatch => {
91
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(errorCatch, traceId));
92
+ response = false;
93
+ });
94
+ return response;
95
+ }
96
+ async insertMultipleRowsInBigQuery(bigqueryClient, datasetName, schema, tableName, partitionConfig, rows, traceId) {
97
+ (0, express_logging_1.Logger)().info(`Save ${rows.length} Rows In Big Query. Trace: ${traceId}`);
98
+ let response = false;
99
+ const promise = new Promise((resolve, reject) => {
100
+ try {
101
+ (0, express_logging_1.Logger)().info(`Reference to ${datasetName} DataSet. Trace: ${traceId}`);
102
+ const datasetRef = bigqueryClient.dataset(datasetName);
103
+ datasetRef.get({ autoCreate: true }).then(function (data) {
104
+ const dataset = data[0];
105
+ (0, express_logging_1.Logger)().info(`Reference to ${tableName} Table. Trace: ${traceId}`);
106
+ const tableRef = dataset.table(tableName);
107
+ tableRef.exists(function (errExist, exists) {
108
+ if (errExist) {
109
+ (0, express_logging_1.Logger)().error(`Exist error: ${JSON.stringify(errExist)}. Trace: ${traceId}`);
110
+ }
111
+ if (exists) {
112
+ dataset.table(tableName).insert(rows).then(() => {
113
+ resolve({});
114
+ }).catch((inserError) => {
115
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(inserError, traceId));
116
+ (0, express_logging_1.Logger)().error(`Exist table insert error: ${JSON.stringify(inserError)}. Trace: ${traceId}`);
117
+ reject(new Error());
118
+ });
119
+ }
120
+ else {
121
+ (0, express_logging_1.Logger)().info(`Create a new table ${datasetName} table. Trace: ${traceId}`);
122
+ const options = {
123
+ schema,
124
+ };
125
+ if (partitionConfig !== undefined) {
126
+ (0, express_logging_1.Logger)().info('Set Partition Table');
127
+ options.timePartitioning = {
128
+ expirationMs: partitionConfig.expirationMs,
129
+ field: partitionConfig.field,
130
+ requirePartitionFilter: partitionConfig.requirePartitionFilter,
131
+ type: 'DAY'
132
+ };
133
+ }
134
+ dataset.createTable(tableName, options).then(function () {
135
+ dataset.table(tableName).insert(rows).then(() => {
136
+ resolve({});
137
+ }).catch((err) => {
138
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(err, traceId));
139
+ (0, express_logging_1.Logger)().error(`Insert in a new table error: ${JSON.stringify(err)}. Trace: ${traceId}`);
140
+ reject(new Error());
141
+ });
142
+ });
143
+ }
144
+ });
145
+ })
146
+ .catch((datasetError) => {
147
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(datasetError, traceId));
148
+ (0, express_logging_1.Logger)().error(`DataSet Error: ${JSON.stringify(datasetError)}. Trace: ${traceId}`);
149
+ if (datasetError.code === 403) {
150
+ resolve({
151
+ googleCode: datasetError.code,
152
+ googleError: datasetError.message !== undefined ? datasetError.message : 'unspecified'
153
+ });
154
+ }
155
+ else {
156
+ reject(new Error());
157
+ }
158
+ });
159
+ }
160
+ catch (error) {
161
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(error, traceId));
162
+ (0, express_logging_1.Logger)().error(`Promise error: ${JSON.stringify(error)}. Trace: ${traceId}`);
163
+ reject(new Error());
164
+ }
165
+ });
166
+ await promise.then((promiseResponse) => {
167
+ if (promiseResponse.googleCode !== undefined) {
168
+ throw new express_error_handler_1.ErrorResponse(new express_error_1.InternalError(express_core_1.ErrorStatus.BAD_REQUEST, `An error occurred while creating a new item in BigQuery for ${datasetName} dataset and ${tableName} ` +
169
+ `table. Google API Code: ${promiseResponse.googleCode}. Google API response: ${promiseResponse.googleError}`, express_error_1.ErrorCode.BAD_REQUEST_CLOUD_PROCESSING_ERROR));
170
+ }
171
+ response = true;
172
+ }, () => {
173
+ response = false;
174
+ });
175
+ await promise.catch(errorCatch => {
176
+ (0, express_logging_1.Logger)().error(express_core_1.ErrorHelper.toErrorString(errorCatch, traceId));
177
+ response = false;
178
+ });
179
+ return response;
180
+ }
181
+ }
182
+ exports.BigQueryService = BigQueryService;
183
+ //# sourceMappingURL=big.query.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"big.query.service.js","sourceRoot":"","sources":["../../src/service/big.query.service.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAE1B,8DAAqE;AACrE,oEAAsD;AACtD,gEAAsE;AAEtE,gFAAmE;AAKnE,MAAa,eAAe;IAanB,KAAK,CAAC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,CAAC,EAAE;YAC/B,IAAA,wBAAM,GAAE,CAAC,KAAK,CAAC,0BAAW,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/D,QAAQ,GAAG,KAAK,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlOD,0CAkOC"}
@@ -0,0 +1,10 @@
1
+ import { BaseList, Filter, Order } from '@creatioart-js/express-core';
2
+ export interface IBaseService<T> {
3
+ findBy(filter: Filter[] | undefined, order: Order | undefined, page: number | 0, pageCount: number | 0, traceId: string): Promise<BaseList<T>>;
4
+ findOne(entityId: string, traceId: string): Promise<T | undefined>;
5
+ exist(filter: Filter[] | undefined, traceId: string): Promise<boolean>;
6
+ countBy(filter: Filter[] | undefined, traceId: string): Promise<number>;
7
+ create(entity: T, traceId: string): Promise<T>;
8
+ update(entity: T, traceId: string): Promise<T>;
9
+ delete(entityId: string, traceId: string): Promise<boolean>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ibase.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ibase.service.js","sourceRoot":"","sources":["../../../src/service/interfaces/ibase.service.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export interface IBigQueryService {
2
+ insertRowInBigQuery(bigqueryClient: any, datasetName: string, schema: any, tableName: string, partitionConfig: any, row: any, traceId: string): Promise<boolean>;
3
+ insertMultipleRowsInBigQuery(bigqueryClient: any, datasetName: string, schema: any, tableName: string, partitionConfig: any, rows: any[], traceId: string): Promise<boolean>;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ibig.query.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ibig.query.service.js","sourceRoot":"","sources":["../../../src/service/interfaces/ibig.query.service.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { RedisClientType } from 'redis';
2
+ export interface IRedisCacheService {
3
+ getElement(key: string, traceId: string): Promise<any>;
4
+ setElement(key: string, data: any, timeSeg: number, traceId: string): Promise<void>;
5
+ removeElement(key: string, traceId: string): Promise<void>;
6
+ disconnect(client: RedisClientType<any> | undefined, traceId: string): Promise<void>;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=iredis.cache.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iredis.cache.service.js","sourceRoot":"","sources":["../../../src/service/interfaces/iredis.cache.service.ts"],"names":[],"mappings":""}