@beabee/beabee-common 1.10.10 → 1.10.12
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/cjs/search/callouts.js +0 -4
- package/dist/cjs/search/contacts.js +1 -0
- package/dist/cjs/search/index.js +6 -6
- package/dist/cjs/utils/rules.js +6 -9
- package/dist/esm/search/callouts.js +0 -4
- package/dist/esm/search/contacts.js +1 -0
- package/dist/esm/search/index.js +6 -6
- package/dist/esm/utils/rules.js +6 -9
- package/dist/types/search/callouts.d.ts +0 -4
- package/dist/types/search/contacts.d.ts +1 -1
- package/dist/types/search/index.d.ts +1 -46
- package/package.json +1 -1
package/dist/cjs/search/index.js
CHANGED
|
@@ -70,12 +70,12 @@ exports.operatorsByType = {
|
|
|
70
70
|
array: arrayOperators,
|
|
71
71
|
enum: equalityOperators,
|
|
72
72
|
contact: equalityOperators,
|
|
73
|
-
custom: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
73
|
+
// custom: {
|
|
74
|
+
// ...equalityOperators,
|
|
75
|
+
// ...arrayOperators,
|
|
76
|
+
// ...stringOperators,
|
|
77
|
+
// ...numericOperators,
|
|
78
|
+
// },
|
|
79
79
|
};
|
|
80
80
|
// More general type to allow mapping while maintaining full type above
|
|
81
81
|
exports.operatorsByTypeMap = exports.operatorsByType;
|
package/dist/cjs/utils/rules.js
CHANGED
|
@@ -9,8 +9,7 @@ function isRuleGroup(ruleOrGroup) {
|
|
|
9
9
|
}
|
|
10
10
|
exports.isRuleGroup = isRuleGroup;
|
|
11
11
|
function validateRule(filters, rule) {
|
|
12
|
-
const
|
|
13
|
-
const filter = filters[fieldName];
|
|
12
|
+
const filter = filters[rule.field];
|
|
14
13
|
if (!filter) {
|
|
15
14
|
throw new error_1.InvalidRule(rule, `Invalid field: ${rule.field}`);
|
|
16
15
|
}
|
|
@@ -31,11 +30,9 @@ function validateRule(filters, rule) {
|
|
|
31
30
|
if (expectedArgs !== rule.value.length) {
|
|
32
31
|
throw new error_1.InvalidRule(rule, `Invalid operator argument count: ${rule.operator} needs ${expectedArgs}, ${rule.value.length} given`);
|
|
33
32
|
}
|
|
34
|
-
const expectedType = filter.type === "
|
|
35
|
-
?
|
|
36
|
-
:
|
|
37
|
-
? filter.type
|
|
38
|
-
: "string";
|
|
33
|
+
const expectedType = filter.type === "boolean" || filter.type === "number"
|
|
34
|
+
? filter.type
|
|
35
|
+
: "string";
|
|
39
36
|
if (rule.value.some((v) => typeof v !== expectedType)) {
|
|
40
37
|
throw new error_1.InvalidRule(rule, `Invalid operator argument type: ${rule.operator} needs ${expectedType}, ${rule.value.map((v) => typeof v)} given`);
|
|
41
38
|
}
|
|
@@ -48,8 +45,8 @@ function validateRule(filters, rule) {
|
|
|
48
45
|
throw new error_1.InvalidRule(rule, `Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`);
|
|
49
46
|
}
|
|
50
47
|
return {
|
|
51
|
-
field:
|
|
52
|
-
param: fieldParam,
|
|
48
|
+
field: rule.field,
|
|
49
|
+
// param: fieldParam,
|
|
53
50
|
type: filter.type,
|
|
54
51
|
operator: rule.operator,
|
|
55
52
|
value: rule.value,
|
package/dist/esm/search/index.js
CHANGED
|
@@ -53,12 +53,12 @@ export const operatorsByType = {
|
|
|
53
53
|
array: arrayOperators,
|
|
54
54
|
enum: equalityOperators,
|
|
55
55
|
contact: equalityOperators,
|
|
56
|
-
custom: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
56
|
+
// custom: {
|
|
57
|
+
// ...equalityOperators,
|
|
58
|
+
// ...arrayOperators,
|
|
59
|
+
// ...stringOperators,
|
|
60
|
+
// ...numericOperators,
|
|
61
|
+
// },
|
|
62
62
|
};
|
|
63
63
|
// More general type to allow mapping while maintaining full type above
|
|
64
64
|
export const operatorsByTypeMap = operatorsByType;
|
package/dist/esm/utils/rules.js
CHANGED
|
@@ -5,8 +5,7 @@ export function isRuleGroup(ruleOrGroup) {
|
|
|
5
5
|
return "condition" in ruleOrGroup;
|
|
6
6
|
}
|
|
7
7
|
export function validateRule(filters, rule) {
|
|
8
|
-
const
|
|
9
|
-
const filter = filters[fieldName];
|
|
8
|
+
const filter = filters[rule.field];
|
|
10
9
|
if (!filter) {
|
|
11
10
|
throw new InvalidRule(rule, `Invalid field: ${rule.field}`);
|
|
12
11
|
}
|
|
@@ -27,11 +26,9 @@ export function validateRule(filters, rule) {
|
|
|
27
26
|
if (expectedArgs !== rule.value.length) {
|
|
28
27
|
throw new InvalidRule(rule, `Invalid operator argument count: ${rule.operator} needs ${expectedArgs}, ${rule.value.length} given`);
|
|
29
28
|
}
|
|
30
|
-
const expectedType = filter.type === "
|
|
31
|
-
?
|
|
32
|
-
:
|
|
33
|
-
? filter.type
|
|
34
|
-
: "string";
|
|
29
|
+
const expectedType = filter.type === "boolean" || filter.type === "number"
|
|
30
|
+
? filter.type
|
|
31
|
+
: "string";
|
|
35
32
|
if (rule.value.some((v) => typeof v !== expectedType)) {
|
|
36
33
|
throw new InvalidRule(rule, `Invalid operator argument type: ${rule.operator} needs ${expectedType}, ${rule.value.map((v) => typeof v)} given`);
|
|
37
34
|
}
|
|
@@ -44,8 +41,8 @@ export function validateRule(filters, rule) {
|
|
|
44
41
|
throw new InvalidRule(rule, `Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`);
|
|
45
42
|
}
|
|
46
43
|
return {
|
|
47
|
-
field:
|
|
48
|
-
param: fieldParam,
|
|
44
|
+
field: rule.field,
|
|
45
|
+
// param: fieldParam,
|
|
49
46
|
type: filter.type,
|
|
50
47
|
operator: rule.operator,
|
|
51
48
|
value: rule.value,
|
|
@@ -35,9 +35,5 @@ export declare const calloutResponseFilters: {
|
|
|
35
35
|
readonly updatedAt: {
|
|
36
36
|
readonly type: "date";
|
|
37
37
|
};
|
|
38
|
-
readonly answers: {
|
|
39
|
-
readonly type: "custom";
|
|
40
|
-
readonly nullable: true;
|
|
41
|
-
};
|
|
42
38
|
};
|
|
43
39
|
export type CalloutResponseFilterName = keyof typeof calloutResponseFilters;
|
|
@@ -34,7 +34,7 @@ export declare const contactFilters: {
|
|
|
34
34
|
};
|
|
35
35
|
readonly newsletterStatus: {
|
|
36
36
|
readonly type: "enum";
|
|
37
|
-
readonly options: readonly [NewsletterStatus.Subscribed, NewsletterStatus.Unsubscribed, NewsletterStatus.Cleaned, NewsletterStatus.None];
|
|
37
|
+
readonly options: readonly [NewsletterStatus.Subscribed, NewsletterStatus.Unsubscribed, NewsletterStatus.Cleaned, NewsletterStatus.Pending, NewsletterStatus.None];
|
|
38
38
|
};
|
|
39
39
|
readonly activePermission: {
|
|
40
40
|
readonly type: "enum";
|
|
@@ -14,7 +14,6 @@ export type ValidatedRuleValue<T extends FilterType> = T extends "number" ? numb
|
|
|
14
14
|
interface BaseValidatedRule<T extends FilterType, F extends string> {
|
|
15
15
|
type: T;
|
|
16
16
|
field: F;
|
|
17
|
-
param: string | undefined;
|
|
18
17
|
operator: keyof (typeof operatorsByType)[T];
|
|
19
18
|
value: ValidatedRuleValue<T>[];
|
|
20
19
|
}
|
|
@@ -26,7 +25,7 @@ export interface ValidatedRuleGroup<Field extends string> {
|
|
|
26
25
|
condition: "AND" | "OR";
|
|
27
26
|
rules: (ValidatedRuleGroup<Field> | ValidatedRule<Field>)[];
|
|
28
27
|
}
|
|
29
|
-
export type FilterType = "text" | "date" | "number" | "boolean" | "array" | "enum" | "contact"
|
|
28
|
+
export type FilterType = "text" | "date" | "number" | "boolean" | "array" | "enum" | "contact";
|
|
30
29
|
interface BaseFilterArgs {
|
|
31
30
|
type: FilterType;
|
|
32
31
|
nullable?: boolean;
|
|
@@ -164,50 +163,6 @@ export declare const operatorsByType: {
|
|
|
164
163
|
args: number;
|
|
165
164
|
};
|
|
166
165
|
};
|
|
167
|
-
readonly custom: {
|
|
168
|
-
readonly between: {
|
|
169
|
-
args: number;
|
|
170
|
-
};
|
|
171
|
-
readonly not_between: {
|
|
172
|
-
args: number;
|
|
173
|
-
};
|
|
174
|
-
readonly less: {
|
|
175
|
-
args: number;
|
|
176
|
-
};
|
|
177
|
-
readonly greater: {
|
|
178
|
-
args: number;
|
|
179
|
-
};
|
|
180
|
-
readonly less_or_equal: {
|
|
181
|
-
args: number;
|
|
182
|
-
};
|
|
183
|
-
readonly greater_or_equal: {
|
|
184
|
-
args: number;
|
|
185
|
-
};
|
|
186
|
-
readonly equal: {
|
|
187
|
-
args: number;
|
|
188
|
-
};
|
|
189
|
-
readonly not_equal: {
|
|
190
|
-
args: number;
|
|
191
|
-
};
|
|
192
|
-
readonly begins_with: {
|
|
193
|
-
args: number;
|
|
194
|
-
};
|
|
195
|
-
readonly ends_with: {
|
|
196
|
-
args: number;
|
|
197
|
-
};
|
|
198
|
-
readonly not_begins_with: {
|
|
199
|
-
args: number;
|
|
200
|
-
};
|
|
201
|
-
readonly not_ends_with: {
|
|
202
|
-
args: number;
|
|
203
|
-
};
|
|
204
|
-
readonly contains: {
|
|
205
|
-
args: number;
|
|
206
|
-
};
|
|
207
|
-
readonly not_contains: {
|
|
208
|
-
args: number;
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
166
|
};
|
|
212
167
|
export declare const operatorsByTypeMap: OperatorsByType;
|
|
213
168
|
export interface Paginated<T> {
|