@infrab4a/connect 4.4.2-beta.1 → 4.5.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.
- package/index.cjs.js +51 -6
- package/index.esm.js +51 -6
- package/package.json +1 -1
- package/src/domain/generic/repository/enums/where.enum.d.ts +2 -1
- package/src/domain/generic/repository/types/repository-find-filters.type.d.ts +2 -0
- package/src/domain/shopping/models/line-item.d.ts +0 -2
- package/src/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +4 -1
- package/src/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -256,6 +256,7 @@ exports.Where = void 0;
|
|
|
256
256
|
Where["NOTLIKE"] = "not like";
|
|
257
257
|
Where["ISNULL"] = "is null";
|
|
258
258
|
Where["ISNOTNULL"] = "is not null";
|
|
259
|
+
Where["IREGEX"] = "iregex";
|
|
259
260
|
})(exports.Where || (exports.Where = {}));
|
|
260
261
|
|
|
261
262
|
exports.UpdateOptionActions = void 0;
|
|
@@ -2248,9 +2249,6 @@ class UpdateUserImage {
|
|
|
2248
2249
|
}
|
|
2249
2250
|
|
|
2250
2251
|
class LineItem extends Product {
|
|
2251
|
-
get pricePaidWithDiscount() {
|
|
2252
|
-
return this.pricePaid - this.discount;
|
|
2253
|
-
}
|
|
2254
2252
|
}
|
|
2255
2253
|
|
|
2256
2254
|
class ShippingMethod extends BaseModel {
|
|
@@ -3836,11 +3834,14 @@ var HasuraGraphQLWhere;
|
|
|
3836
3834
|
HasuraGraphQLWhere["LT"] = "_lt";
|
|
3837
3835
|
HasuraGraphQLWhere["LTE"] = "_lte";
|
|
3838
3836
|
HasuraGraphQLWhere["LIKE"] = "_like";
|
|
3837
|
+
HasuraGraphQLWhere["ILIKE"] = "_ilike";
|
|
3839
3838
|
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
3840
3839
|
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
3841
3840
|
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
3842
3841
|
HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
|
|
3843
3842
|
HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
|
|
3843
|
+
HasuraGraphQLWhere["IREGEX"] = "_iregex";
|
|
3844
|
+
HasuraGraphQLWhere["REGEX"] = "_regex";
|
|
3844
3845
|
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
3845
3846
|
|
|
3846
3847
|
var HasuraGraphQLColumnType;
|
|
@@ -3871,9 +3872,47 @@ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
|
3871
3872
|
: (value) => filter.operator === exports.Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
|
|
3872
3873
|
? `%${value}%`
|
|
3873
3874
|
: value;
|
|
3874
|
-
|
|
3875
|
+
const converterResult = Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
|
|
3875
3876
|
? filter.value.map((fieldValue) => converter(fieldValue))
|
|
3876
3877
|
: converter(filter.value);
|
|
3878
|
+
const newValue = filter.ignoreCase && !filter.ignoreAccent && !Array.isArray(filter.value) && converterResult.indexOf('%') < 0
|
|
3879
|
+
? `%${converterResult}%`
|
|
3880
|
+
: converterResult;
|
|
3881
|
+
return filter.ignoreAccent && !Array.isArray(filter.value)
|
|
3882
|
+
? FilterOptionHelper.buildInsensitiveSentence(newValue)
|
|
3883
|
+
: newValue;
|
|
3884
|
+
};
|
|
3885
|
+
FilterOptionHelper.buildInsensitiveSentence = (value) => {
|
|
3886
|
+
const valueWithoutAccents = FilterOptionHelper.removeAccents(value);
|
|
3887
|
+
let result = '';
|
|
3888
|
+
for (const char of valueWithoutAccents) {
|
|
3889
|
+
const allCharOptions = [];
|
|
3890
|
+
if (['a', 'e', 'i', 'o', 'u', 'c', 'A', 'E', 'I', 'O', 'U', 'C'].includes(char)) {
|
|
3891
|
+
const charOptions = {
|
|
3892
|
+
a: ['á', 'â', 'ã', 'à', 'a'],
|
|
3893
|
+
e: ['é', 'ê', 'ẽ', 'è', 'e'],
|
|
3894
|
+
i: ['í', 'î', 'ĩ', 'ì', 'i'],
|
|
3895
|
+
o: ['ó', 'ô', 'õ', 'ò', 'o'],
|
|
3896
|
+
u: ['ú', 'û', 'ũ', 'ù', 'u'],
|
|
3897
|
+
c: ['ç', 'c'],
|
|
3898
|
+
A: ['Á', 'Â', 'Ã', 'À', 'A'],
|
|
3899
|
+
E: ['É', 'Ê', 'Ẽ', 'È', 'E'],
|
|
3900
|
+
I: ['Í', 'Î', 'Ĩ', 'Ì', 'I'],
|
|
3901
|
+
O: ['Ó', 'Ô', 'Õ', 'Ò', 'O'],
|
|
3902
|
+
U: ['Ú', 'Û', 'Ũ', 'Ù', 'U'],
|
|
3903
|
+
C: ['Ç', 'C'],
|
|
3904
|
+
};
|
|
3905
|
+
allCharOptions.push(...charOptions[char]);
|
|
3906
|
+
result += `[${allCharOptions.join('')}]`;
|
|
3907
|
+
}
|
|
3908
|
+
else {
|
|
3909
|
+
result += char;
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
return result;
|
|
3913
|
+
};
|
|
3914
|
+
FilterOptionHelper.removeAccents = (text) => {
|
|
3915
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
3877
3916
|
};
|
|
3878
3917
|
|
|
3879
3918
|
class BindFilterQueryHelper {
|
|
@@ -3917,8 +3956,14 @@ BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
|
3917
3956
|
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3918
3957
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
3919
3958
|
? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
|
|
3920
|
-
:
|
|
3921
|
-
|
|
3959
|
+
: options.operator === exports.Where.LIKE && options.ignoreCase && options.ignoreAccent
|
|
3960
|
+
? HasuraGraphQLWhere.IREGEX
|
|
3961
|
+
: options.operator === exports.Where.LIKE && options.ignoreAccent
|
|
3962
|
+
? HasuraGraphQLWhere.REGEX
|
|
3963
|
+
: options.operator === exports.Where.LIKE && options.ignoreCase
|
|
3964
|
+
? HasuraGraphQLWhere.ILIKE
|
|
3965
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3966
|
+
Object.keys(exports.Where).find((operator) => exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
3922
3967
|
: HasuraGraphQLWhere.EQUALS;
|
|
3923
3968
|
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === exports.Where.IN
|
|
3924
3969
|
? HasuraGraphQLWhere.JSON_CONTAINS
|
package/index.esm.js
CHANGED
|
@@ -232,6 +232,7 @@ var Where;
|
|
|
232
232
|
Where["NOTLIKE"] = "not like";
|
|
233
233
|
Where["ISNULL"] = "is null";
|
|
234
234
|
Where["ISNOTNULL"] = "is not null";
|
|
235
|
+
Where["IREGEX"] = "iregex";
|
|
235
236
|
})(Where || (Where = {}));
|
|
236
237
|
|
|
237
238
|
var UpdateOptionActions;
|
|
@@ -2224,9 +2225,6 @@ class UpdateUserImage {
|
|
|
2224
2225
|
}
|
|
2225
2226
|
|
|
2226
2227
|
class LineItem extends Product {
|
|
2227
|
-
get pricePaidWithDiscount() {
|
|
2228
|
-
return this.pricePaid - this.discount;
|
|
2229
|
-
}
|
|
2230
2228
|
}
|
|
2231
2229
|
|
|
2232
2230
|
class ShippingMethod extends BaseModel {
|
|
@@ -3812,11 +3810,14 @@ var HasuraGraphQLWhere;
|
|
|
3812
3810
|
HasuraGraphQLWhere["LT"] = "_lt";
|
|
3813
3811
|
HasuraGraphQLWhere["LTE"] = "_lte";
|
|
3814
3812
|
HasuraGraphQLWhere["LIKE"] = "_like";
|
|
3813
|
+
HasuraGraphQLWhere["ILIKE"] = "_ilike";
|
|
3815
3814
|
HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
|
|
3816
3815
|
HasuraGraphQLWhere["ISNULL"] = "_is_null";
|
|
3817
3816
|
HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
|
|
3818
3817
|
HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
|
|
3819
3818
|
HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
|
|
3819
|
+
HasuraGraphQLWhere["IREGEX"] = "_iregex";
|
|
3820
|
+
HasuraGraphQLWhere["REGEX"] = "_regex";
|
|
3820
3821
|
})(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
|
|
3821
3822
|
|
|
3822
3823
|
var HasuraGraphQLColumnType;
|
|
@@ -3847,9 +3848,47 @@ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
|
3847
3848
|
: (value) => filter.operator === Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
|
|
3848
3849
|
? `%${value}%`
|
|
3849
3850
|
: value;
|
|
3850
|
-
|
|
3851
|
+
const converterResult = Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
|
|
3851
3852
|
? filter.value.map((fieldValue) => converter(fieldValue))
|
|
3852
3853
|
: converter(filter.value);
|
|
3854
|
+
const newValue = filter.ignoreCase && !filter.ignoreAccent && !Array.isArray(filter.value) && converterResult.indexOf('%') < 0
|
|
3855
|
+
? `%${converterResult}%`
|
|
3856
|
+
: converterResult;
|
|
3857
|
+
return filter.ignoreAccent && !Array.isArray(filter.value)
|
|
3858
|
+
? FilterOptionHelper.buildInsensitiveSentence(newValue)
|
|
3859
|
+
: newValue;
|
|
3860
|
+
};
|
|
3861
|
+
FilterOptionHelper.buildInsensitiveSentence = (value) => {
|
|
3862
|
+
const valueWithoutAccents = FilterOptionHelper.removeAccents(value);
|
|
3863
|
+
let result = '';
|
|
3864
|
+
for (const char of valueWithoutAccents) {
|
|
3865
|
+
const allCharOptions = [];
|
|
3866
|
+
if (['a', 'e', 'i', 'o', 'u', 'c', 'A', 'E', 'I', 'O', 'U', 'C'].includes(char)) {
|
|
3867
|
+
const charOptions = {
|
|
3868
|
+
a: ['á', 'â', 'ã', 'à', 'a'],
|
|
3869
|
+
e: ['é', 'ê', 'ẽ', 'è', 'e'],
|
|
3870
|
+
i: ['í', 'î', 'ĩ', 'ì', 'i'],
|
|
3871
|
+
o: ['ó', 'ô', 'õ', 'ò', 'o'],
|
|
3872
|
+
u: ['ú', 'û', 'ũ', 'ù', 'u'],
|
|
3873
|
+
c: ['ç', 'c'],
|
|
3874
|
+
A: ['Á', 'Â', 'Ã', 'À', 'A'],
|
|
3875
|
+
E: ['É', 'Ê', 'Ẽ', 'È', 'E'],
|
|
3876
|
+
I: ['Í', 'Î', 'Ĩ', 'Ì', 'I'],
|
|
3877
|
+
O: ['Ó', 'Ô', 'Õ', 'Ò', 'O'],
|
|
3878
|
+
U: ['Ú', 'Û', 'Ũ', 'Ù', 'U'],
|
|
3879
|
+
C: ['Ç', 'C'],
|
|
3880
|
+
};
|
|
3881
|
+
allCharOptions.push(...charOptions[char]);
|
|
3882
|
+
result += `[${allCharOptions.join('')}]`;
|
|
3883
|
+
}
|
|
3884
|
+
else {
|
|
3885
|
+
result += char;
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
return result;
|
|
3889
|
+
};
|
|
3890
|
+
FilterOptionHelper.removeAccents = (text) => {
|
|
3891
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
3853
3892
|
};
|
|
3854
3893
|
|
|
3855
3894
|
class BindFilterQueryHelper {
|
|
@@ -3893,8 +3932,14 @@ BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
|
3893
3932
|
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3894
3933
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
3895
3934
|
? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
|
|
3896
|
-
:
|
|
3897
|
-
|
|
3935
|
+
: options.operator === Where.LIKE && options.ignoreCase && options.ignoreAccent
|
|
3936
|
+
? HasuraGraphQLWhere.IREGEX
|
|
3937
|
+
: options.operator === Where.LIKE && options.ignoreAccent
|
|
3938
|
+
? HasuraGraphQLWhere.REGEX
|
|
3939
|
+
: options.operator === Where.LIKE && options.ignoreCase
|
|
3940
|
+
? HasuraGraphQLWhere.ILIKE
|
|
3941
|
+
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3942
|
+
Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
|
|
3898
3943
|
: HasuraGraphQLWhere.EQUALS;
|
|
3899
3944
|
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
|
|
3900
3945
|
? HasuraGraphQLWhere.JSON_CONTAINS
|
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ import { Where } from '../enums/where.enum';
|
|
|
5
5
|
export type RepositoryFindFieltersOptions<Model, FieldName extends keyof Model> = {
|
|
6
6
|
operator: Where;
|
|
7
7
|
value?: PropType<Model, FieldName> | PropType<Model, FieldName>[];
|
|
8
|
+
ignoreCase?: boolean;
|
|
9
|
+
ignoreAccent?: boolean;
|
|
8
10
|
};
|
|
9
11
|
export type RepositoryFindField<Model, FieldName extends keyof Model> = RepositoryFindFieltersOptions<Model, FieldName> | RepositoryFindFieltersOptions<Model, FieldName>[] | Partial<PropType<Model, FieldName>>;
|
|
10
12
|
export type NestedRepositoryFindFieltersOptions<Model> = {
|
|
@@ -7,9 +7,12 @@ export declare enum HasuraGraphQLWhere {
|
|
|
7
7
|
LT = "_lt",
|
|
8
8
|
LTE = "_lte",
|
|
9
9
|
LIKE = "_like",
|
|
10
|
+
ILIKE = "_ilike",
|
|
10
11
|
NOTLIKE = "_nlike",
|
|
11
12
|
ISNULL = "_is_null",
|
|
12
13
|
ISNOTNULL = "_is_null",
|
|
13
14
|
JSON_CONTAINS = "_contains",
|
|
14
|
-
JSON_HAS_KEYS_ANY = "_has_keys_any"
|
|
15
|
+
JSON_HAS_KEYS_ANY = "_has_keys_any",
|
|
16
|
+
IREGEX = "_iregex",
|
|
17
|
+
REGEX = "_regex"
|
|
15
18
|
}
|
|
@@ -5,4 +5,6 @@ export declare class FilterOptionHelper {
|
|
|
5
5
|
identifiersFields: any[];
|
|
6
6
|
}, any>>(filter: any) => filter is RepositoryFindFieltersOptions<Model, any>;
|
|
7
7
|
static GetValueFromFilter: <Model extends ModelBaseStructure<Model, Model["identifiersFields"][number]>>(filter: RepositoryFindFieltersOptions<Model, any>, fieldOption: ColumnOptions<any, any>) => any;
|
|
8
|
+
private static buildInsensitiveSentence;
|
|
9
|
+
private static removeAccents;
|
|
8
10
|
}
|