@infrab4a/connect 4.25.0-beta.4 → 4.25.0-beta.5
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/index.cjs.js +12 -10
- package/index.esm.js +12 -10
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -5098,19 +5098,21 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5098
5098
|
});
|
|
5099
5099
|
}
|
|
5100
5100
|
async find(params, options) {
|
|
5101
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
5102
5102
|
this.logger = DebugHelper.from(this, 'find');
|
|
5103
5103
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5104
5104
|
const cacheKey = generateCacheKey(this.model, params);
|
|
5105
5105
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
5106
5106
|
if (cachedData) {
|
|
5107
|
+
const json = JSON.parse(cachedData);
|
|
5108
|
+
const data = (_c = json.data) === null || _c === void 0 ? void 0 : _c.map((item) => this.convertDataFromHasura(item));
|
|
5107
5109
|
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
5108
|
-
return
|
|
5110
|
+
return Object.assign(Object.assign({}, json), { data });
|
|
5109
5111
|
}
|
|
5110
5112
|
}
|
|
5111
5113
|
const { filters, limits, orderBy, options: findOptions } = params || {};
|
|
5112
5114
|
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
5113
|
-
const enableCount = (
|
|
5115
|
+
const enableCount = (_d = findOptions === null || findOptions === void 0 ? void 0 : findOptions.enableCount) !== null && _d !== void 0 ? _d : true;
|
|
5114
5116
|
const variablesFilters = lodash.isNil(filters)
|
|
5115
5117
|
? {}
|
|
5116
5118
|
: {
|
|
@@ -5161,7 +5163,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5161
5163
|
]
|
|
5162
5164
|
: []),
|
|
5163
5165
|
...((!this.lastDistinct[tableFiltersNamed] &&
|
|
5164
|
-
((
|
|
5166
|
+
((_f = (_e = params.options) === null || _e === void 0 ? void 0 : _e.distinct) === null || _f === void 0 ? void 0 : _f.map((distinct) => {
|
|
5165
5167
|
var _a, _b;
|
|
5166
5168
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
5167
5169
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -5182,34 +5184,34 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5182
5184
|
[]),
|
|
5183
5185
|
]);
|
|
5184
5186
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
5185
|
-
const findResult = Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
5187
|
+
const findResult = Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_g = findOptions === null || findOptions === void 0 ? void 0 : findOptions.minimal) === null || _g === void 0 ? void 0 : _g.length)
|
|
5186
5188
|
? {
|
|
5187
5189
|
minimal: findOptions.minimal.reduce((minimals, current) => {
|
|
5188
5190
|
var _a;
|
|
5189
5191
|
return (Object.assign(Object.assign({}, minimals), lodash.set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
5190
5192
|
}, {}),
|
|
5191
5193
|
}
|
|
5192
|
-
: {})), (((
|
|
5194
|
+
: {})), (((_h = findOptions === null || findOptions === void 0 ? void 0 : findOptions.maximum) === null || _h === void 0 ? void 0 : _h.length)
|
|
5193
5195
|
? {
|
|
5194
5196
|
maximum: findOptions.maximum.reduce((maximums, current) => {
|
|
5195
5197
|
var _a;
|
|
5196
5198
|
return (Object.assign(Object.assign({}, maximums), lodash.set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
5197
5199
|
}, {}),
|
|
5198
5200
|
}
|
|
5199
|
-
: {})), (((
|
|
5200
|
-
distinct: (
|
|
5201
|
+
: {})), (((_j = findOptions === null || findOptions === void 0 ? void 0 : findOptions.distinct) === null || _j === void 0 ? void 0 : _j.length) && {
|
|
5202
|
+
distinct: (_k = this.lastDistinct[tableFiltersNamed]) !== null && _k !== void 0 ? _k : (this.lastDistinct[tableFiltersNamed] = findOptions === null || findOptions === void 0 ? void 0 : findOptions.distinct.reduce((distinct, current) => {
|
|
5201
5203
|
var _a, _b;
|
|
5202
5204
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
5203
5205
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
5204
5206
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
5205
5207
|
}, {})),
|
|
5206
5208
|
}));
|
|
5207
|
-
if (((
|
|
5209
|
+
if (((_l = this.cache) === null || _l === void 0 ? void 0 : _l.cacheAdapter) && ((_m = options === null || options === void 0 ? void 0 : options.cache) === null || _m === void 0 ? void 0 : _m.enabled)) {
|
|
5208
5210
|
const cacheKey = generateCacheKey(this.model, params);
|
|
5209
5211
|
await this.cache.cacheAdapter.set({
|
|
5210
5212
|
key: cacheKey,
|
|
5211
5213
|
data: JSON.stringify(findResult),
|
|
5212
|
-
expirationInSeconds: ((
|
|
5214
|
+
expirationInSeconds: ((_o = options === null || options === void 0 ? void 0 : options.cache) === null || _o === void 0 ? void 0 : _o.ttl) || this.cache.ttlDefault,
|
|
5213
5215
|
});
|
|
5214
5216
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5215
5217
|
}
|
package/index.esm.js
CHANGED
|
@@ -5092,19 +5092,21 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5092
5092
|
});
|
|
5093
5093
|
}
|
|
5094
5094
|
async find(params, options) {
|
|
5095
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5095
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
5096
5096
|
this.logger = DebugHelper.from(this, 'find');
|
|
5097
5097
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5098
5098
|
const cacheKey = generateCacheKey(this.model, params);
|
|
5099
5099
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
5100
5100
|
if (cachedData) {
|
|
5101
|
+
const json = JSON.parse(cachedData);
|
|
5102
|
+
const data = (_c = json.data) === null || _c === void 0 ? void 0 : _c.map((item) => this.convertDataFromHasura(item));
|
|
5101
5103
|
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
5102
|
-
return
|
|
5104
|
+
return Object.assign(Object.assign({}, json), { data });
|
|
5103
5105
|
}
|
|
5104
5106
|
}
|
|
5105
5107
|
const { filters, limits, orderBy, options: findOptions } = params || {};
|
|
5106
5108
|
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
5107
|
-
const enableCount = (
|
|
5109
|
+
const enableCount = (_d = findOptions === null || findOptions === void 0 ? void 0 : findOptions.enableCount) !== null && _d !== void 0 ? _d : true;
|
|
5108
5110
|
const variablesFilters = isNil(filters)
|
|
5109
5111
|
? {}
|
|
5110
5112
|
: {
|
|
@@ -5155,7 +5157,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5155
5157
|
]
|
|
5156
5158
|
: []),
|
|
5157
5159
|
...((!this.lastDistinct[tableFiltersNamed] &&
|
|
5158
|
-
((
|
|
5160
|
+
((_f = (_e = params.options) === null || _e === void 0 ? void 0 : _e.distinct) === null || _f === void 0 ? void 0 : _f.map((distinct) => {
|
|
5159
5161
|
var _a, _b;
|
|
5160
5162
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
5161
5163
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -5176,34 +5178,34 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5176
5178
|
[]),
|
|
5177
5179
|
]);
|
|
5178
5180
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
5179
|
-
const findResult = Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
5181
|
+
const findResult = Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_g = findOptions === null || findOptions === void 0 ? void 0 : findOptions.minimal) === null || _g === void 0 ? void 0 : _g.length)
|
|
5180
5182
|
? {
|
|
5181
5183
|
minimal: findOptions.minimal.reduce((minimals, current) => {
|
|
5182
5184
|
var _a;
|
|
5183
5185
|
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
5184
5186
|
}, {}),
|
|
5185
5187
|
}
|
|
5186
|
-
: {})), (((
|
|
5188
|
+
: {})), (((_h = findOptions === null || findOptions === void 0 ? void 0 : findOptions.maximum) === null || _h === void 0 ? void 0 : _h.length)
|
|
5187
5189
|
? {
|
|
5188
5190
|
maximum: findOptions.maximum.reduce((maximums, current) => {
|
|
5189
5191
|
var _a;
|
|
5190
5192
|
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
5191
5193
|
}, {}),
|
|
5192
5194
|
}
|
|
5193
|
-
: {})), (((
|
|
5194
|
-
distinct: (
|
|
5195
|
+
: {})), (((_j = findOptions === null || findOptions === void 0 ? void 0 : findOptions.distinct) === null || _j === void 0 ? void 0 : _j.length) && {
|
|
5196
|
+
distinct: (_k = this.lastDistinct[tableFiltersNamed]) !== null && _k !== void 0 ? _k : (this.lastDistinct[tableFiltersNamed] = findOptions === null || findOptions === void 0 ? void 0 : findOptions.distinct.reduce((distinct, current) => {
|
|
5195
5197
|
var _a, _b;
|
|
5196
5198
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
5197
5199
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
5198
5200
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
5199
5201
|
}, {})),
|
|
5200
5202
|
}));
|
|
5201
|
-
if (((
|
|
5203
|
+
if (((_l = this.cache) === null || _l === void 0 ? void 0 : _l.cacheAdapter) && ((_m = options === null || options === void 0 ? void 0 : options.cache) === null || _m === void 0 ? void 0 : _m.enabled)) {
|
|
5202
5204
|
const cacheKey = generateCacheKey(this.model, params);
|
|
5203
5205
|
await this.cache.cacheAdapter.set({
|
|
5204
5206
|
key: cacheKey,
|
|
5205
5207
|
data: JSON.stringify(findResult),
|
|
5206
|
-
expirationInSeconds: ((
|
|
5208
|
+
expirationInSeconds: ((_o = options === null || options === void 0 ? void 0 : options.cache) === null || _o === void 0 ? void 0 : _o.ttl) || this.cache.ttlDefault,
|
|
5207
5209
|
});
|
|
5208
5210
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5209
5211
|
}
|