@roit/roit-data-firestore 1.2.39 → 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.
@@ -81,7 +81,7 @@ class QueryPredicateFunctionTransform {
81
81
  startTracer: Tracer_1.startTracer,
82
82
  archiveService: ArchiveService_1.ArchiveService.getInstance()
83
83
  };
84
- if (!(options === null || options === void 0 ? void 0 : options.collection)) {
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 = ${(options === null || options === void 0 ? void 0 : options.validatorOptions) ? JSON.stringify(options === null || options === void 0 ? void 0 : options.validatorOptions) : undefined}`)
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 === null || options === void 0 ? void 0 : options.ttl) {
104
- functionString = functionString.replace("let ttlExpirationIn", `let ttlExpirationIn = ${options === null || options === void 0 ? void 0 : options.ttl.expirationIn}`);
105
- functionString = functionString.replace("let ttlUnit", `let ttlUnit = '${options === null || options === void 0 ? void 0 : options.ttl.unit}'`);
106
- functionString = functionString.replace("let ttlUpdate", `let ttlUpdate = ${options === null || options === void 0 ? void 0 : options.ttl.ttlUpdate}`);
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 => { var _a; return (_a = query.operator) === null || _a === void 0 ? void 0 : _a.includes('.where'); });
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) => { var _a; return (_a = queryPredicate.paramContent) !== null && _a !== void 0 ? _a : queryPredicate.attribute; };
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 => { var _a; return `${(_a = att.operator) === null || _a === void 0 ? void 0 : _a.replace('ATRIBUTE', att.attribute).replace('VALUE', getAttribute(att))}`; }).join(''));
121
- functionBuilder = functionBuilder.replace(/<is_one_row>/g, (methodQueryOptions === null || methodQueryOptions === void 0 ? void 0 : methodQueryOptions.oneRow) ? 'true' : 'false');
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((operatorConfig === null || operatorConfig === void 0 ? void 0 : operatorConfig.extractOperator) ? operatorConfig === null || operatorConfig === void 0 ? void 0 : operatorConfig.extractOperator(part) : part.replace(operator, ''));
16
+ const attribute = this.lowerCamelCase(operatorConfig?.extractOperator ? operatorConfig?.extractOperator(part) : part.replace(operator, ''));
17
17
  predicate.attribute = attribute;
18
- predicate.operator = operatorConfig === null || operatorConfig === void 0 ? void 0 : operatorConfig.predicate(part);
18
+ predicate.operator = operatorConfig?.predicate(part);
19
19
  predicate.operatorKey = operator;
20
20
  predicate.paramContent = `${attribute}${index}`;
21
21
  return predicate;
@@ -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) => __awaiter(void 0, void 0, void 0, function* () {
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 yield tracerAgent.getGlobalTracer().startActiveSpan(name, (span) => __awaiter(void 0, void 0, void 0, function* () {
19
+ return await tracerAgent.getGlobalTracer().startActiveSpan(name, async (span) => {
29
20
  try {
30
- return yield operation(span);
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;