@roit/roit-data-firestore 1.2.38 → 1.2.41
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/archive/ArchiveService.d.ts +0 -1
- package/dist/archive/ArchiveService.js +113 -136
- package/dist/cache/CacheResolver.js +80 -104
- package/dist/cache/providers/RedisCacheArchiveProvider.d.ts +0 -1
- package/dist/cache/providers/RedisCacheArchiveProvider.js +45 -67
- package/dist/cache/providers/RedisCacheProvider.js +37 -52
- package/dist/config/ArchiveConfig.d.ts +4 -0
- package/dist/config/ArchiveConfig.js +20 -1
- package/dist/config/BaseRepository.js +13 -30
- package/dist/config/ReadonlyRepository.js +7 -20
- package/dist/decorators/Repository.js +3 -12
- package/dist/exception/RepositoryException.js +1 -1
- package/dist/exception/handle/ValidatorDataHandle.js +12 -24
- package/dist/firestore-read-audit/FirestoreReadAuditResolver.js +15 -18
- package/dist/firestore-read-audit/providers/BigQueryFirestoreReadAuditProvider.js +53 -66
- package/dist/firestore-read-audit/providers/PubSubFirestoreReadAuditProvider.js +15 -26
- package/dist/model/CacheProviders.js +1 -1
- package/dist/query/ManualQueryHelper.js +132 -150
- package/dist/query/QueryCreatorConfig.js +30 -42
- package/dist/query/QueryPredicateFunctionTransform.js +10 -10
- package/dist/query/TransformMethodFromQuery.js +2 -2
- package/dist/tracer/Tracer.js +5 -14
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/tsconfig.json +2 -2
|
@@ -81,7 +81,7 @@ class QueryPredicateFunctionTransform {
|
|
|
81
81
|
startTracer: Tracer_1.startTracer,
|
|
82
82
|
archiveService: ArchiveService_1.ArchiveService.getInstance()
|
|
83
83
|
};
|
|
84
|
-
if (!
|
|
84
|
+
if (!options?.collection) {
|
|
85
85
|
throw new Error(`Collection is required`);
|
|
86
86
|
}
|
|
87
87
|
this.classConfig.set(repositoryClassName, options);
|
|
@@ -97,28 +97,28 @@ class QueryPredicateFunctionTransform {
|
|
|
97
97
|
.replace(/yield/g, 'await')
|
|
98
98
|
.replace(/<COLLECTION_REPLACE>/g, options.collection)
|
|
99
99
|
.replace("let modelName = ''", `let modelName = '${modelName}'`)
|
|
100
|
-
.replace("let validatorOptions", `let validatorOptions = ${
|
|
100
|
+
.replace("let validatorOptions", `let validatorOptions = ${options?.validatorOptions ? JSON.stringify(options?.validatorOptions) : undefined}`)
|
|
101
101
|
.replace("let repositoryClassName = ''", `let repositoryClassName = '${repositoryClassName}'`)
|
|
102
102
|
.replace("let methodSignature = ''", `let methodSignature = '${methodSignature}'`);
|
|
103
|
-
if (options
|
|
104
|
-
functionString = functionString.replace("let ttlExpirationIn", `let ttlExpirationIn = ${options
|
|
105
|
-
functionString = functionString.replace("let ttlUnit", `let ttlUnit = '${options
|
|
106
|
-
functionString = functionString.replace("let ttlUpdate", `let ttlUpdate = ${options
|
|
103
|
+
if (options?.ttl) {
|
|
104
|
+
functionString = functionString.replace("let ttlExpirationIn", `let ttlExpirationIn = ${options?.ttl.expirationIn}`);
|
|
105
|
+
functionString = functionString.replace("let ttlUnit", `let ttlUnit = '${options?.ttl.unit}'`);
|
|
106
|
+
functionString = functionString.replace("let ttlUpdate", `let ttlUpdate = ${options?.ttl.ttlUpdate}`);
|
|
107
107
|
}
|
|
108
108
|
functionString = this.removeLast(functionString, '});');
|
|
109
109
|
return Function(`return ${functionString}`)();
|
|
110
110
|
}
|
|
111
|
-
let parameters = queryPredicate.filter(query =>
|
|
111
|
+
let parameters = queryPredicate.filter(query => query.operator?.includes('.where'));
|
|
112
112
|
parameters = parameters.concat({ attribute: 'paging' });
|
|
113
113
|
let functionBuilder = functionQueryTemplate;
|
|
114
|
-
const getAttribute = (queryPredicate) =>
|
|
114
|
+
const getAttribute = (queryPredicate) => queryPredicate.paramContent ?? queryPredicate.attribute;
|
|
115
115
|
functionBuilder = functionBuilder.replace(/<repositoryClassName_value>/g, repositoryClassName);
|
|
116
116
|
functionBuilder = functionBuilder.replace(/<methodSignature_value>/g, methodSignature);
|
|
117
117
|
functionBuilder = functionBuilder.replace(/<params_replace>/g, parameters.map(att => getAttribute(att)).join(','));
|
|
118
118
|
functionBuilder = functionBuilder.replace(/<params_validator_replace>/g, parameters.filter(par => par.attribute != 'paging').map(att => `!${getAttribute(att)}`).join('||'));
|
|
119
119
|
functionBuilder = functionBuilder.replace(/<collection_name_replace>/g, options.collection);
|
|
120
|
-
functionBuilder = functionBuilder.replace(/<query_predicate_replace>/g, queryPredicate.map(att =>
|
|
121
|
-
functionBuilder = functionBuilder.replace(/<is_one_row>/g,
|
|
120
|
+
functionBuilder = functionBuilder.replace(/<query_predicate_replace>/g, queryPredicate.map(att => `${att.operator?.replace('ATRIBUTE', att.attribute).replace('VALUE', getAttribute(att))}`).join(''));
|
|
121
|
+
functionBuilder = functionBuilder.replace(/<is_one_row>/g, methodQueryOptions?.oneRow ? 'true' : 'false');
|
|
122
122
|
return Function(`return ${functionBuilder}`)();
|
|
123
123
|
}
|
|
124
124
|
static removeLast(value, repl) {
|
|
@@ -13,9 +13,9 @@ class TransformMethodFromQuery {
|
|
|
13
13
|
const operator = operators.find(opt => opt.length == opertorMaxLength) || 'Iqual';
|
|
14
14
|
const operatorConfig = OperatorMap_1.operatorMap.get(operator);
|
|
15
15
|
const predicate = new QueryPredicate_1.QueryPredicate;
|
|
16
|
-
const attribute = this.lowerCamelCase(
|
|
16
|
+
const attribute = this.lowerCamelCase(operatorConfig?.extractOperator ? operatorConfig?.extractOperator(part) : part.replace(operator, ''));
|
|
17
17
|
predicate.attribute = attribute;
|
|
18
|
-
predicate.operator = operatorConfig
|
|
18
|
+
predicate.operator = operatorConfig?.predicate(part);
|
|
19
19
|
predicate.operatorKey = operator;
|
|
20
20
|
predicate.paramContent = `${attribute}${index}`;
|
|
21
21
|
return predicate;
|
package/dist/tracer/Tracer.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.startTracer = void 0;
|
|
13
4
|
const getTracerAgent = () => {
|
|
@@ -17,7 +8,7 @@ const getTracerAgent = () => {
|
|
|
17
8
|
}
|
|
18
9
|
return agent;
|
|
19
10
|
};
|
|
20
|
-
const startTracer = (name, operation) =>
|
|
11
|
+
const startTracer = async (name, operation) => {
|
|
21
12
|
const tracerAgent = getTracerAgent();
|
|
22
13
|
if (!tracerAgent) {
|
|
23
14
|
return operation({
|
|
@@ -25,13 +16,13 @@ const startTracer = (name, operation) => __awaiter(void 0, void 0, void 0, funct
|
|
|
25
16
|
end: () => { }
|
|
26
17
|
});
|
|
27
18
|
}
|
|
28
|
-
return
|
|
19
|
+
return await tracerAgent.getGlobalTracer().startActiveSpan(name, async (span) => {
|
|
29
20
|
try {
|
|
30
|
-
return
|
|
21
|
+
return await operation(span);
|
|
31
22
|
}
|
|
32
23
|
finally {
|
|
33
24
|
span.end();
|
|
34
25
|
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
37
28
|
exports.startTracer = startTracer;
|