@beabee/beabee-common 1.19.5 → 1.19.7
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/README.md +41 -0
- package/dist/cjs/data/index.cjs +87 -0
- package/dist/cjs/error/InvalidRule.cjs +35 -0
- package/dist/cjs/error/index.cjs +22 -0
- package/dist/cjs/index.cjs +28 -0
- package/dist/cjs/search/api-keys.cjs +35 -0
- package/dist/cjs/search/callouts.cjs +131 -0
- package/dist/cjs/search/contacts.cjs +105 -0
- package/dist/cjs/search/index.cjs +32 -0
- package/dist/cjs/search/notices.cjs +61 -0
- package/dist/cjs/search/operators.cjs +89 -0
- package/dist/cjs/search/payments.cjs +51 -0
- package/dist/cjs/types/api-key-filter-name.cjs +16 -0
- package/dist/cjs/types/array-filter-args.cjs +16 -0
- package/dist/cjs/types/base-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/base-filter-args.cjs +16 -0
- package/dist/cjs/types/base-validated-rule.cjs +16 -0
- package/dist/cjs/types/callout-component-schema.cjs +16 -0
- package/dist/cjs/types/callout-filter-name.cjs +16 -0
- package/dist/cjs/types/callout-form-schema.cjs +16 -0
- package/dist/cjs/types/callout-navigation-schema.cjs +16 -0
- package/dist/cjs/types/callout-response-answer-address.cjs +16 -0
- package/dist/cjs/types/callout-response-answer-file-upload.cjs +16 -0
- package/dist/cjs/types/callout-response-answer.cjs +16 -0
- package/dist/cjs/types/callout-response-answers.cjs +16 -0
- package/dist/cjs/types/callout-response-comment-filter-name.cjs +16 -0
- package/dist/cjs/types/callout-response-filter-name.cjs +16 -0
- package/dist/cjs/types/callout-slide-schema.cjs +16 -0
- package/dist/cjs/types/callout-tag-filter-name.cjs +16 -0
- package/dist/cjs/types/content-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/date-unit.cjs +16 -0
- package/dist/cjs/types/duration.cjs +16 -0
- package/dist/cjs/types/enum-filter-args.cjs +16 -0
- package/dist/cjs/types/feeable.cjs +16 -0
- package/dist/cjs/types/filter-args.cjs +16 -0
- package/dist/cjs/types/filter-type.cjs +16 -0
- package/dist/cjs/types/filters.cjs +16 -0
- package/dist/cjs/types/index.cjs +120 -0
- package/dist/cjs/types/input-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/input-file-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/nestable-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/notice-filter-name.cjs +16 -0
- package/dist/cjs/types/operators-by-type.cjs +16 -0
- package/dist/cjs/types/other-filter-args.cjs +16 -0
- package/dist/cjs/types/paginated-query.cjs +16 -0
- package/dist/cjs/types/paginated.cjs +16 -0
- package/dist/cjs/types/payment-filter-name.cjs +16 -0
- package/dist/cjs/types/radio-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/role-type.cjs +16 -0
- package/dist/cjs/types/rule-group.cjs +16 -0
- package/dist/cjs/types/rule-operator.cjs +16 -0
- package/dist/cjs/types/rule-opperator-params.cjs +16 -0
- package/dist/cjs/types/rule-value.cjs +16 -0
- package/dist/cjs/types/rule.cjs +16 -0
- package/dist/cjs/types/select-callout-component-schema.cjs +16 -0
- package/dist/cjs/types/stripe-fee-country.cjs +16 -0
- package/dist/cjs/types/unit-matches.cjs +16 -0
- package/dist/cjs/types/validated-boolean-rule.cjs +16 -0
- package/dist/cjs/types/validated-number-rule.cjs +16 -0
- package/dist/cjs/types/validated-rule-group.cjs +16 -0
- package/dist/cjs/types/validated-rule-value.cjs +16 -0
- package/dist/cjs/types/validated-rule.cjs +16 -0
- package/dist/cjs/types/validated-string-rule.cjs +16 -0
- package/dist/cjs/utils/callouts.cjs +137 -0
- package/dist/cjs/utils/date.cjs +87 -0
- package/dist/cjs/utils/index.cjs +28 -0
- package/dist/cjs/utils/payments.cjs +53 -0
- package/dist/cjs/utils/rules.cjs +109 -0
- package/dist/esm/data/index.js +57 -50
- package/dist/esm/error/InvalidRule.js +10 -7
- package/dist/esm/error/index.js +1 -2
- package/dist/esm/index.js +4 -7
- package/dist/esm/search/api-keys.js +10 -7
- package/dist/esm/search/callouts.js +100 -94
- package/dist/esm/search/contacts.js +83 -74
- package/dist/esm/search/index.js +6 -64
- package/dist/esm/search/notices.js +36 -33
- package/dist/esm/search/operators.js +62 -0
- package/dist/esm/search/payments.js +26 -23
- package/dist/esm/types/api-key-filter-name.js +0 -0
- package/dist/esm/types/array-filter-args.js +0 -0
- package/dist/esm/types/base-callout-component-schema.js +0 -0
- package/dist/esm/types/base-filter-args.js +0 -0
- package/dist/esm/types/base-validated-rule.js +0 -0
- package/dist/esm/types/callout-component-schema.js +0 -0
- package/dist/esm/types/callout-filter-name.js +0 -0
- package/dist/esm/types/callout-form-schema.js +0 -0
- package/dist/esm/types/callout-navigation-schema.js +0 -0
- package/dist/esm/types/callout-response-answer-address.js +0 -0
- package/dist/esm/types/callout-response-answer-file-upload.js +0 -0
- package/dist/esm/types/callout-response-answer.js +0 -0
- package/dist/esm/types/callout-response-answers.js +0 -0
- package/dist/esm/types/callout-response-comment-filter-name.js +0 -0
- package/dist/esm/types/callout-response-filter-name.js +0 -0
- package/dist/esm/types/callout-slide-schema.js +0 -0
- package/dist/esm/types/callout-tag-filter-name.js +0 -0
- package/dist/esm/types/content-callout-component-schema.js +0 -0
- package/dist/esm/types/date-unit.js +0 -0
- package/dist/esm/types/duration.js +0 -0
- package/dist/esm/types/enum-filter-args.js +0 -0
- package/dist/esm/types/feeable.js +0 -0
- package/dist/esm/types/filter-args.js +0 -0
- package/dist/esm/types/filter-type.js +0 -0
- package/dist/esm/types/filters.js +0 -0
- package/dist/esm/types/index.js +50 -0
- package/dist/esm/types/input-callout-component-schema.js +0 -0
- package/dist/esm/types/input-file-callout-component-schema.js +0 -0
- package/dist/esm/types/nestable-callout-component-schema.js +0 -0
- package/dist/esm/types/notice-filter-name.js +0 -0
- package/dist/esm/types/operators-by-type.js +0 -0
- package/dist/esm/types/other-filter-args.js +0 -0
- package/dist/esm/types/paginated-query.js +0 -0
- package/dist/esm/types/paginated.js +0 -0
- package/dist/esm/types/payment-filter-name.js +0 -0
- package/dist/esm/types/radio-callout-component-schema.js +0 -0
- package/dist/esm/types/role-type.js +0 -0
- package/dist/esm/types/rule-group.js +0 -0
- package/dist/esm/types/rule-operator.js +0 -0
- package/dist/esm/types/rule-opperator-params.js +0 -0
- package/dist/esm/types/rule-value.js +0 -0
- package/dist/esm/types/rule.js +0 -0
- package/dist/esm/types/select-callout-component-schema.js +0 -0
- package/dist/esm/types/stripe-fee-country.js +0 -0
- package/dist/esm/types/unit-matches.js +0 -0
- package/dist/esm/types/validated-boolean-rule.js +0 -0
- package/dist/esm/types/validated-number-rule.js +0 -0
- package/dist/esm/types/validated-rule-group.js +0 -0
- package/dist/esm/types/validated-rule-value.js +0 -0
- package/dist/esm/types/validated-rule.js +0 -0
- package/dist/esm/types/validated-string-rule.js +0 -0
- package/dist/esm/utils/callouts.js +91 -93
- package/dist/esm/utils/date.js +56 -56
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/payments.js +25 -23
- package/dist/esm/utils/rules.js +75 -58
- package/dist/types/data/index.d.ts +0 -4
- package/dist/types/error/InvalidRule.d.ts +2 -2
- package/dist/types/error/index.d.ts +1 -2
- package/dist/types/index.d.ts +5 -7
- package/dist/types/search/api-keys.d.ts +0 -1
- package/dist/types/search/callouts.d.ts +1 -5
- package/dist/types/search/contacts.d.ts +3 -2
- package/dist/types/search/index.d.ts +6 -194
- package/dist/types/search/notices.d.ts +1 -2
- package/dist/types/search/operators.d.ts +128 -0
- package/dist/types/search/payments.d.ts +1 -2
- package/dist/types/types/api-key-filter-name.d.ts +2 -0
- package/dist/types/types/array-filter-args.d.ts +5 -0
- package/dist/types/types/base-callout-component-schema.d.ts +9 -0
- package/dist/types/types/base-filter-args.d.ts +5 -0
- package/dist/types/types/base-validated-rule.d.ts +9 -0
- package/dist/types/types/callout-component-schema.d.ts +2 -0
- package/dist/types/types/callout-filter-name.d.ts +2 -0
- package/dist/types/types/callout-form-schema.d.ts +4 -0
- package/dist/types/types/callout-navigation-schema.d.ts +6 -0
- package/dist/types/types/callout-response-answer-address.d.ts +9 -0
- package/dist/types/types/callout-response-answer-file-upload.d.ts +3 -0
- package/dist/types/types/callout-response-answer.d.ts +2 -0
- package/dist/types/types/callout-response-answers.d.ts +5 -0
- package/dist/types/types/callout-response-comment-filter-name.d.ts +2 -0
- package/dist/types/types/callout-response-filter-name.d.ts +2 -0
- package/dist/types/types/callout-slide-schema.d.ts +7 -0
- package/dist/types/types/callout-tag-filter-name.d.ts +2 -0
- package/dist/types/types/content-callout-component-schema.d.ts +5 -0
- package/dist/types/types/date-unit.d.ts +2 -0
- package/dist/types/types/duration.d.ts +1 -0
- package/dist/types/types/enum-filter-args.d.ts +5 -0
- package/dist/types/types/feeable.d.ts +6 -0
- package/dist/types/types/filter-args.d.ts +2 -0
- package/dist/types/types/filter-type.d.ts +1 -0
- package/dist/types/types/filters.d.ts +2 -0
- package/dist/types/types/index.d.ts +50 -0
- package/dist/types/types/input-callout-component-schema.d.ts +6 -0
- package/dist/types/types/input-file-callout-component-schema.d.ts +5 -0
- package/dist/types/types/nestable-callout-component-schema.d.ts +6 -0
- package/dist/types/types/notice-filter-name.d.ts +2 -0
- package/dist/types/types/operators-by-type.d.ts +2 -0
- package/dist/types/types/other-filter-args.d.ts +4 -0
- package/dist/types/types/paginated-query.d.ts +8 -0
- package/dist/types/types/paginated.d.ts +6 -0
- package/dist/types/types/payment-filter-name.d.ts +2 -0
- package/dist/types/types/radio-callout-component-schema.d.ts +10 -0
- package/dist/types/types/role-type.d.ts +2 -0
- package/dist/types/types/rule-group.d.ts +5 -0
- package/dist/types/types/rule-operator.d.ts +2 -0
- package/dist/types/types/rule-opperator-params.d.ts +3 -0
- package/dist/types/types/rule-value.d.ts +1 -0
- package/dist/types/types/rule.d.ts +6 -0
- package/dist/types/types/select-callout-component-schema.d.ts +11 -0
- package/dist/types/types/stripe-fee-country.d.ts +1 -0
- package/dist/types/types/unit-matches.d.ts +2 -0
- package/dist/types/types/validated-boolean-rule.d.ts +2 -0
- package/dist/types/types/validated-number-rule.d.ts +2 -0
- package/dist/types/types/validated-rule-group.d.ts +5 -0
- package/dist/types/types/validated-rule-value.d.ts +2 -0
- package/dist/types/types/validated-rule.d.ts +2 -0
- package/dist/types/types/validated-string-rule.d.ts +2 -0
- package/dist/types/utils/callouts.d.ts +1 -3
- package/dist/types/utils/date.d.ts +3 -3
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/payments.d.ts +1 -7
- package/dist/types/utils/rules.d.ts +1 -1
- package/package.json +31 -12
- package/dist/cjs/data/callouts.js +0 -2
- package/dist/cjs/data/index.js +0 -67
- package/dist/cjs/error/InvalidRule.js +0 -11
- package/dist/cjs/error/index.js +0 -8
- package/dist/cjs/index.js +0 -23
- package/dist/cjs/search/api-keys.js +0 -11
- package/dist/cjs/search/callouts.js +0 -101
- package/dist/cjs/search/contacts.js +0 -78
- package/dist/cjs/search/index.js +0 -81
- package/dist/cjs/search/notices.js +0 -37
- package/dist/cjs/search/payments.js +0 -27
- package/dist/cjs/utils/callouts.js +0 -118
- package/dist/cjs/utils/date.js +0 -77
- package/dist/cjs/utils/payments.js +0 -31
- package/dist/cjs/utils/rules.js +0 -69
- package/dist/esm/data/callouts.js +0 -1
- package/dist/types/data/callouts.d.ts +0 -70
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./callouts.cjs"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./date.cjs"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./payments.cjs"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("./rules.cjs"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./callouts.cjs"),
|
|
25
|
+
...require("./date.cjs"),
|
|
26
|
+
...require("./payments.cjs"),
|
|
27
|
+
...require("./rules.cjs")
|
|
28
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var payments_exports = {};
|
|
20
|
+
__export(payments_exports, {
|
|
21
|
+
calcPaymentFee: () => calcPaymentFee
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(payments_exports);
|
|
24
|
+
var import_data = require("../data/index.cjs");
|
|
25
|
+
const stripeFees = {
|
|
26
|
+
gb: {
|
|
27
|
+
[import_data.PaymentMethod.StripeCard]: (amount) => 0.2 + 0.015 * amount,
|
|
28
|
+
[import_data.PaymentMethod.StripeSEPA]: () => 0.3,
|
|
29
|
+
[import_data.PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount))
|
|
30
|
+
},
|
|
31
|
+
eu: {
|
|
32
|
+
[import_data.PaymentMethod.StripeCard]: (amount) => 0.25 + 0.015 * amount,
|
|
33
|
+
[import_data.PaymentMethod.StripeSEPA]: () => 0.35,
|
|
34
|
+
[import_data.PaymentMethod.StripeBACS]: () => 0
|
|
35
|
+
// Not available
|
|
36
|
+
},
|
|
37
|
+
ca: {
|
|
38
|
+
[import_data.PaymentMethod.StripeCard]: (amount) => 0.3 + 0.029 * amount,
|
|
39
|
+
[import_data.PaymentMethod.StripeSEPA]: () => 0,
|
|
40
|
+
// Not available
|
|
41
|
+
[import_data.PaymentMethod.StripeBACS]: () => 0
|
|
42
|
+
// Not available
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const gcFee = (amount) => 0.2 + amount * 0.01;
|
|
46
|
+
function calcPaymentFee(feeable, country) {
|
|
47
|
+
const feeFn = feeable.paymentMethod === import_data.PaymentMethod.GoCardlessDirectDebit ? gcFee : stripeFees[country][feeable.paymentMethod];
|
|
48
|
+
return feeable.period === import_data.ContributionPeriod.Annually ? 0 : feeFn(feeable.amount);
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
calcPaymentFee
|
|
53
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var rules_exports = {};
|
|
20
|
+
__export(rules_exports, {
|
|
21
|
+
isRuleGroup: () => isRuleGroup,
|
|
22
|
+
validateRule: () => validateRule,
|
|
23
|
+
validateRuleGroup: () => validateRuleGroup
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(rules_exports);
|
|
26
|
+
var import_error = require("../error/index.cjs");
|
|
27
|
+
var import_search = require("../search/index.cjs");
|
|
28
|
+
var import_date = require("./date.cjs");
|
|
29
|
+
function isRuleGroup(ruleOrGroup) {
|
|
30
|
+
return "condition" in ruleOrGroup;
|
|
31
|
+
}
|
|
32
|
+
function validateRule(filters, rule) {
|
|
33
|
+
const filter = filters[rule.field];
|
|
34
|
+
if (!filter) {
|
|
35
|
+
throw new import_error.InvalidRule(rule, `Invalid field: ${rule.field}`);
|
|
36
|
+
}
|
|
37
|
+
let expectedArgs = 0;
|
|
38
|
+
if (rule.operator in import_search.nullableOperators) {
|
|
39
|
+
if (!filter.nullable && filter.type !== "text") {
|
|
40
|
+
throw new import_error.InvalidRule(
|
|
41
|
+
rule,
|
|
42
|
+
`Invalid nullable operator: field is not nullable`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
const operator = import_search.operatorsByTypeMap[filter.type][rule.operator];
|
|
47
|
+
if (!operator) {
|
|
48
|
+
throw new import_error.InvalidRule(
|
|
49
|
+
rule,
|
|
50
|
+
`Invalid operator for type: ${filter.type} type doesn't define ${rule.operator}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
expectedArgs = operator.args;
|
|
54
|
+
}
|
|
55
|
+
if (expectedArgs !== rule.value.length) {
|
|
56
|
+
throw new import_error.InvalidRule(
|
|
57
|
+
rule,
|
|
58
|
+
`Invalid operator argument count: ${rule.operator} needs ${expectedArgs}, ${rule.value.length} given`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const expectedType = filter.type === "boolean" || filter.type === "number" ? filter.type : "string";
|
|
62
|
+
if (rule.value.some((v) => typeof v !== expectedType)) {
|
|
63
|
+
throw new import_error.InvalidRule(
|
|
64
|
+
rule,
|
|
65
|
+
`Invalid operator argument type: ${rule.operator} needs ${expectedType}, ${rule.value.map(
|
|
66
|
+
(v) => typeof v
|
|
67
|
+
)} given`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (filter.type === "date" && rule.value.some((v) => !(0, import_date.isValidDate)(v))) {
|
|
71
|
+
throw new import_error.InvalidRule(
|
|
72
|
+
rule,
|
|
73
|
+
`Invalid operator argument: date type needs valid absolute or relative date, ${rule.value} given`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if ((filter.type === "enum" || filter.type === "array") && rule.value.some((v) => {
|
|
77
|
+
var _a;
|
|
78
|
+
return ((_a = filter.options) == null ? void 0 : _a.indexOf(v)) === -1;
|
|
79
|
+
})) {
|
|
80
|
+
throw new import_error.InvalidRule(
|
|
81
|
+
rule,
|
|
82
|
+
`Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
field: rule.field,
|
|
87
|
+
type: filter.type,
|
|
88
|
+
nullable: !!filter.nullable,
|
|
89
|
+
operator: rule.operator,
|
|
90
|
+
value: rule.value
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function validateRuleGroup(filters, ruleGroup) {
|
|
94
|
+
const validatedRuleGroup = {
|
|
95
|
+
condition: ruleGroup.condition,
|
|
96
|
+
rules: []
|
|
97
|
+
};
|
|
98
|
+
for (const rule of ruleGroup.rules) {
|
|
99
|
+
const valid = isRuleGroup(rule) ? validateRuleGroup(filters, rule) : validateRule(filters, rule);
|
|
100
|
+
validatedRuleGroup.rules.push(valid);
|
|
101
|
+
}
|
|
102
|
+
return validatedRuleGroup;
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
isRuleGroup,
|
|
107
|
+
validateRule,
|
|
108
|
+
validateRuleGroup
|
|
109
|
+
});
|
package/dist/esm/data/index.js
CHANGED
|
@@ -1,50 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(ContributionPeriod ||
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(ContributionType ||
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})(ItemStatus ||
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})(MembershipStatus ||
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})(NewsletterStatus ||
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})(PaymentMethod ||
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})(PaymentStatus ||
|
|
49
|
-
export
|
|
50
|
-
|
|
1
|
+
var ContributionPeriod = /* @__PURE__ */ ((ContributionPeriod2) => {
|
|
2
|
+
ContributionPeriod2["Monthly"] = "monthly";
|
|
3
|
+
ContributionPeriod2["Annually"] = "annually";
|
|
4
|
+
return ContributionPeriod2;
|
|
5
|
+
})(ContributionPeriod || {});
|
|
6
|
+
var ContributionType = /* @__PURE__ */ ((ContributionType2) => {
|
|
7
|
+
ContributionType2["Automatic"] = "Automatic";
|
|
8
|
+
ContributionType2["Manual"] = "Manual";
|
|
9
|
+
ContributionType2["Gift"] = "Gift";
|
|
10
|
+
ContributionType2["None"] = "None";
|
|
11
|
+
return ContributionType2;
|
|
12
|
+
})(ContributionType || {});
|
|
13
|
+
var ItemStatus = /* @__PURE__ */ ((ItemStatus2) => {
|
|
14
|
+
ItemStatus2["Draft"] = "draft";
|
|
15
|
+
ItemStatus2["Scheduled"] = "scheduled";
|
|
16
|
+
ItemStatus2["Open"] = "open";
|
|
17
|
+
ItemStatus2["Ended"] = "ended";
|
|
18
|
+
return ItemStatus2;
|
|
19
|
+
})(ItemStatus || {});
|
|
20
|
+
var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
|
|
21
|
+
MembershipStatus2["Active"] = "active";
|
|
22
|
+
MembershipStatus2["Expiring"] = "expiring";
|
|
23
|
+
MembershipStatus2["Expired"] = "expired";
|
|
24
|
+
MembershipStatus2["None"] = "none";
|
|
25
|
+
return MembershipStatus2;
|
|
26
|
+
})(MembershipStatus || {});
|
|
27
|
+
var NewsletterStatus = /* @__PURE__ */ ((NewsletterStatus2) => {
|
|
28
|
+
NewsletterStatus2["Subscribed"] = "subscribed";
|
|
29
|
+
NewsletterStatus2["Unsubscribed"] = "unsubscribed";
|
|
30
|
+
NewsletterStatus2["Cleaned"] = "cleaned";
|
|
31
|
+
NewsletterStatus2["Pending"] = "pending";
|
|
32
|
+
NewsletterStatus2["None"] = "none";
|
|
33
|
+
return NewsletterStatus2;
|
|
34
|
+
})(NewsletterStatus || {});
|
|
35
|
+
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
36
|
+
PaymentMethod2["StripeCard"] = "s_card";
|
|
37
|
+
PaymentMethod2["StripeSEPA"] = "s_sepa";
|
|
38
|
+
PaymentMethod2["StripeBACS"] = "s_bacs";
|
|
39
|
+
PaymentMethod2["GoCardlessDirectDebit"] = "gc_direct-debit";
|
|
40
|
+
return PaymentMethod2;
|
|
41
|
+
})(PaymentMethod || {});
|
|
42
|
+
var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
|
|
43
|
+
PaymentStatus2["Pending"] = "pending";
|
|
44
|
+
PaymentStatus2["Successful"] = "successful";
|
|
45
|
+
PaymentStatus2["Failed"] = "failed";
|
|
46
|
+
PaymentStatus2["Cancelled"] = "cancelled";
|
|
47
|
+
return PaymentStatus2;
|
|
48
|
+
})(PaymentStatus || {});
|
|
49
|
+
export {
|
|
50
|
+
ContributionPeriod,
|
|
51
|
+
ContributionType,
|
|
52
|
+
ItemStatus,
|
|
53
|
+
MembershipStatus,
|
|
54
|
+
NewsletterStatus,
|
|
55
|
+
PaymentMethod,
|
|
56
|
+
PaymentStatus
|
|
57
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
class InvalidRule extends Error {
|
|
2
|
+
constructor(rule, message) {
|
|
3
|
+
super();
|
|
4
|
+
this.rule = rule;
|
|
5
|
+
this.message = message;
|
|
6
|
+
Object.setPrototypeOf(this, InvalidRule.prototype);
|
|
7
|
+
}
|
|
8
8
|
}
|
|
9
|
+
export {
|
|
10
|
+
InvalidRule
|
|
11
|
+
};
|
package/dist/esm/error/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { InvalidRule };
|
|
1
|
+
export * from "./InvalidRule.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./utils/
|
|
5
|
-
export * from "./utils/date";
|
|
6
|
-
export * from "./utils/payments";
|
|
7
|
-
export * from "./utils/rules";
|
|
1
|
+
export * from "./data/index.js";
|
|
2
|
+
export * from "./error/index.js";
|
|
3
|
+
export * from "./search/index.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
@@ -1,98 +1,104 @@
|
|
|
1
|
-
import { ItemStatus } from "../data";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { ItemStatus } from "../data/index.js";
|
|
2
|
+
const calloutFilters = {
|
|
3
|
+
slug: {
|
|
4
|
+
type: "text"
|
|
5
|
+
},
|
|
6
|
+
title: {
|
|
7
|
+
type: "text"
|
|
8
|
+
},
|
|
9
|
+
status: {
|
|
10
|
+
type: "enum",
|
|
11
|
+
options: [
|
|
12
|
+
ItemStatus.Draft,
|
|
13
|
+
ItemStatus.Scheduled,
|
|
14
|
+
ItemStatus.Open,
|
|
15
|
+
ItemStatus.Ended
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
answeredBy: {
|
|
19
|
+
type: "contact"
|
|
20
|
+
},
|
|
21
|
+
starts: {
|
|
22
|
+
type: "date",
|
|
23
|
+
nullable: true
|
|
24
|
+
},
|
|
25
|
+
expires: {
|
|
26
|
+
type: "date",
|
|
27
|
+
nullable: true
|
|
28
|
+
},
|
|
29
|
+
hidden: {
|
|
30
|
+
type: "boolean"
|
|
31
|
+
}
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
33
|
+
const calloutResponseFilters = {
|
|
34
|
+
id: {
|
|
35
|
+
type: "text"
|
|
36
|
+
},
|
|
37
|
+
contact: {
|
|
38
|
+
type: "contact",
|
|
39
|
+
nullable: true
|
|
40
|
+
},
|
|
41
|
+
callout: {
|
|
42
|
+
type: "text"
|
|
43
|
+
},
|
|
44
|
+
createdAt: {
|
|
45
|
+
type: "date"
|
|
46
|
+
},
|
|
47
|
+
updatedAt: {
|
|
48
|
+
type: "date"
|
|
49
|
+
},
|
|
50
|
+
bucket: {
|
|
51
|
+
type: "text",
|
|
52
|
+
nullable: true
|
|
53
|
+
},
|
|
54
|
+
tags: {
|
|
55
|
+
type: "array"
|
|
56
|
+
},
|
|
57
|
+
assignee: {
|
|
58
|
+
type: "contact",
|
|
59
|
+
nullable: true
|
|
60
|
+
},
|
|
61
|
+
answers: {
|
|
62
|
+
type: "blob"
|
|
63
|
+
}
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
const calloutResponseCommentFilters = {
|
|
66
|
+
id: {
|
|
67
|
+
type: "text"
|
|
68
|
+
},
|
|
69
|
+
responseId: {
|
|
70
|
+
type: "text"
|
|
71
|
+
},
|
|
72
|
+
contact: {
|
|
73
|
+
type: "contact"
|
|
74
|
+
},
|
|
75
|
+
createdAt: {
|
|
76
|
+
type: "date"
|
|
77
|
+
},
|
|
78
|
+
updatedAt: {
|
|
79
|
+
type: "date"
|
|
80
|
+
},
|
|
81
|
+
text: {
|
|
82
|
+
type: "text"
|
|
83
|
+
}
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
const calloutTagFilters = {
|
|
86
|
+
id: {
|
|
87
|
+
type: "text"
|
|
88
|
+
},
|
|
89
|
+
name: {
|
|
90
|
+
type: "text"
|
|
91
|
+
},
|
|
92
|
+
description: {
|
|
93
|
+
type: "text"
|
|
94
|
+
},
|
|
95
|
+
calloutSlug: {
|
|
96
|
+
type: "text"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
calloutFilters,
|
|
101
|
+
calloutResponseCommentFilters,
|
|
102
|
+
calloutResponseFilters,
|
|
103
|
+
calloutTagFilters
|
|
98
104
|
};
|