@beabee/beabee-common 1.19.7 → 1.19.9

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.
Files changed (220) hide show
  1. package/dist/cjs/data/callouts.js +2 -0
  2. package/dist/cjs/data/index.js +67 -0
  3. package/dist/cjs/error/InvalidRule.js +11 -0
  4. package/dist/cjs/error/index.js +8 -0
  5. package/dist/cjs/index.js +23 -0
  6. package/dist/cjs/search/api-keys.js +11 -0
  7. package/dist/cjs/search/callouts.js +101 -0
  8. package/dist/cjs/search/contacts.js +78 -0
  9. package/dist/cjs/search/index.js +81 -0
  10. package/dist/cjs/search/notices.js +37 -0
  11. package/dist/cjs/search/payments.js +27 -0
  12. package/dist/cjs/utils/callouts.js +118 -0
  13. package/dist/cjs/utils/date.js +77 -0
  14. package/dist/cjs/utils/payments.js +31 -0
  15. package/dist/cjs/utils/rules.js +69 -0
  16. package/dist/esm/data/callouts.js +1 -0
  17. package/dist/esm/data/index.js +50 -57
  18. package/dist/esm/error/InvalidRule.js +7 -10
  19. package/dist/esm/error/index.js +2 -1
  20. package/dist/esm/index.js +7 -4
  21. package/dist/esm/search/api-keys.js +7 -10
  22. package/dist/esm/search/callouts.js +94 -100
  23. package/dist/esm/search/contacts.js +74 -83
  24. package/dist/esm/search/index.js +64 -6
  25. package/dist/esm/search/notices.js +33 -36
  26. package/dist/esm/search/payments.js +23 -26
  27. package/dist/esm/utils/callouts.js +93 -91
  28. package/dist/esm/utils/date.js +56 -56
  29. package/dist/esm/utils/payments.js +23 -25
  30. package/dist/esm/utils/rules.js +58 -75
  31. package/dist/types/data/callouts.d.ts +74 -0
  32. package/dist/types/data/index.d.ts +4 -0
  33. package/dist/types/error/InvalidRule.d.ts +2 -2
  34. package/dist/types/error/index.d.ts +2 -1
  35. package/dist/types/index.d.ts +7 -5
  36. package/dist/types/search/api-keys.d.ts +1 -0
  37. package/dist/types/search/callouts.d.ts +5 -1
  38. package/dist/types/search/contacts.d.ts +1 -2
  39. package/dist/types/search/index.d.ts +194 -6
  40. package/dist/types/search/notices.d.ts +2 -1
  41. package/dist/types/search/payments.d.ts +2 -1
  42. package/dist/types/utils/callouts.d.ts +3 -1
  43. package/dist/types/utils/date.d.ts +3 -3
  44. package/dist/types/utils/payments.d.ts +7 -1
  45. package/dist/types/utils/rules.d.ts +1 -1
  46. package/package.json +12 -31
  47. package/README.md +0 -41
  48. package/dist/cjs/data/index.cjs +0 -87
  49. package/dist/cjs/error/InvalidRule.cjs +0 -35
  50. package/dist/cjs/error/index.cjs +0 -22
  51. package/dist/cjs/index.cjs +0 -28
  52. package/dist/cjs/search/api-keys.cjs +0 -35
  53. package/dist/cjs/search/callouts.cjs +0 -131
  54. package/dist/cjs/search/contacts.cjs +0 -105
  55. package/dist/cjs/search/index.cjs +0 -32
  56. package/dist/cjs/search/notices.cjs +0 -61
  57. package/dist/cjs/search/operators.cjs +0 -89
  58. package/dist/cjs/search/payments.cjs +0 -51
  59. package/dist/cjs/types/api-key-filter-name.cjs +0 -16
  60. package/dist/cjs/types/array-filter-args.cjs +0 -16
  61. package/dist/cjs/types/base-callout-component-schema.cjs +0 -16
  62. package/dist/cjs/types/base-filter-args.cjs +0 -16
  63. package/dist/cjs/types/base-validated-rule.cjs +0 -16
  64. package/dist/cjs/types/callout-component-schema.cjs +0 -16
  65. package/dist/cjs/types/callout-filter-name.cjs +0 -16
  66. package/dist/cjs/types/callout-form-schema.cjs +0 -16
  67. package/dist/cjs/types/callout-navigation-schema.cjs +0 -16
  68. package/dist/cjs/types/callout-response-answer-address.cjs +0 -16
  69. package/dist/cjs/types/callout-response-answer-file-upload.cjs +0 -16
  70. package/dist/cjs/types/callout-response-answer.cjs +0 -16
  71. package/dist/cjs/types/callout-response-answers.cjs +0 -16
  72. package/dist/cjs/types/callout-response-comment-filter-name.cjs +0 -16
  73. package/dist/cjs/types/callout-response-filter-name.cjs +0 -16
  74. package/dist/cjs/types/callout-slide-schema.cjs +0 -16
  75. package/dist/cjs/types/callout-tag-filter-name.cjs +0 -16
  76. package/dist/cjs/types/content-callout-component-schema.cjs +0 -16
  77. package/dist/cjs/types/date-unit.cjs +0 -16
  78. package/dist/cjs/types/duration.cjs +0 -16
  79. package/dist/cjs/types/enum-filter-args.cjs +0 -16
  80. package/dist/cjs/types/feeable.cjs +0 -16
  81. package/dist/cjs/types/filter-args.cjs +0 -16
  82. package/dist/cjs/types/filter-type.cjs +0 -16
  83. package/dist/cjs/types/filters.cjs +0 -16
  84. package/dist/cjs/types/index.cjs +0 -120
  85. package/dist/cjs/types/input-callout-component-schema.cjs +0 -16
  86. package/dist/cjs/types/input-file-callout-component-schema.cjs +0 -16
  87. package/dist/cjs/types/nestable-callout-component-schema.cjs +0 -16
  88. package/dist/cjs/types/notice-filter-name.cjs +0 -16
  89. package/dist/cjs/types/operators-by-type.cjs +0 -16
  90. package/dist/cjs/types/other-filter-args.cjs +0 -16
  91. package/dist/cjs/types/paginated-query.cjs +0 -16
  92. package/dist/cjs/types/paginated.cjs +0 -16
  93. package/dist/cjs/types/payment-filter-name.cjs +0 -16
  94. package/dist/cjs/types/radio-callout-component-schema.cjs +0 -16
  95. package/dist/cjs/types/role-type.cjs +0 -16
  96. package/dist/cjs/types/rule-group.cjs +0 -16
  97. package/dist/cjs/types/rule-operator.cjs +0 -16
  98. package/dist/cjs/types/rule-opperator-params.cjs +0 -16
  99. package/dist/cjs/types/rule-value.cjs +0 -16
  100. package/dist/cjs/types/rule.cjs +0 -16
  101. package/dist/cjs/types/select-callout-component-schema.cjs +0 -16
  102. package/dist/cjs/types/stripe-fee-country.cjs +0 -16
  103. package/dist/cjs/types/unit-matches.cjs +0 -16
  104. package/dist/cjs/types/validated-boolean-rule.cjs +0 -16
  105. package/dist/cjs/types/validated-number-rule.cjs +0 -16
  106. package/dist/cjs/types/validated-rule-group.cjs +0 -16
  107. package/dist/cjs/types/validated-rule-value.cjs +0 -16
  108. package/dist/cjs/types/validated-rule.cjs +0 -16
  109. package/dist/cjs/types/validated-string-rule.cjs +0 -16
  110. package/dist/cjs/utils/callouts.cjs +0 -137
  111. package/dist/cjs/utils/date.cjs +0 -87
  112. package/dist/cjs/utils/index.cjs +0 -28
  113. package/dist/cjs/utils/payments.cjs +0 -53
  114. package/dist/cjs/utils/rules.cjs +0 -109
  115. package/dist/esm/search/operators.js +0 -62
  116. package/dist/esm/types/api-key-filter-name.js +0 -0
  117. package/dist/esm/types/array-filter-args.js +0 -0
  118. package/dist/esm/types/base-callout-component-schema.js +0 -0
  119. package/dist/esm/types/base-filter-args.js +0 -0
  120. package/dist/esm/types/base-validated-rule.js +0 -0
  121. package/dist/esm/types/callout-component-schema.js +0 -0
  122. package/dist/esm/types/callout-filter-name.js +0 -0
  123. package/dist/esm/types/callout-form-schema.js +0 -0
  124. package/dist/esm/types/callout-navigation-schema.js +0 -0
  125. package/dist/esm/types/callout-response-answer-address.js +0 -0
  126. package/dist/esm/types/callout-response-answer-file-upload.js +0 -0
  127. package/dist/esm/types/callout-response-answer.js +0 -0
  128. package/dist/esm/types/callout-response-answers.js +0 -0
  129. package/dist/esm/types/callout-response-comment-filter-name.js +0 -0
  130. package/dist/esm/types/callout-response-filter-name.js +0 -0
  131. package/dist/esm/types/callout-slide-schema.js +0 -0
  132. package/dist/esm/types/callout-tag-filter-name.js +0 -0
  133. package/dist/esm/types/content-callout-component-schema.js +0 -0
  134. package/dist/esm/types/date-unit.js +0 -0
  135. package/dist/esm/types/duration.js +0 -0
  136. package/dist/esm/types/enum-filter-args.js +0 -0
  137. package/dist/esm/types/feeable.js +0 -0
  138. package/dist/esm/types/filter-args.js +0 -0
  139. package/dist/esm/types/filter-type.js +0 -0
  140. package/dist/esm/types/filters.js +0 -0
  141. package/dist/esm/types/index.js +0 -50
  142. package/dist/esm/types/input-callout-component-schema.js +0 -0
  143. package/dist/esm/types/input-file-callout-component-schema.js +0 -0
  144. package/dist/esm/types/nestable-callout-component-schema.js +0 -0
  145. package/dist/esm/types/notice-filter-name.js +0 -0
  146. package/dist/esm/types/operators-by-type.js +0 -0
  147. package/dist/esm/types/other-filter-args.js +0 -0
  148. package/dist/esm/types/paginated-query.js +0 -0
  149. package/dist/esm/types/paginated.js +0 -0
  150. package/dist/esm/types/payment-filter-name.js +0 -0
  151. package/dist/esm/types/radio-callout-component-schema.js +0 -0
  152. package/dist/esm/types/role-type.js +0 -0
  153. package/dist/esm/types/rule-group.js +0 -0
  154. package/dist/esm/types/rule-operator.js +0 -0
  155. package/dist/esm/types/rule-opperator-params.js +0 -0
  156. package/dist/esm/types/rule-value.js +0 -0
  157. package/dist/esm/types/rule.js +0 -0
  158. package/dist/esm/types/select-callout-component-schema.js +0 -0
  159. package/dist/esm/types/stripe-fee-country.js +0 -0
  160. package/dist/esm/types/unit-matches.js +0 -0
  161. package/dist/esm/types/validated-boolean-rule.js +0 -0
  162. package/dist/esm/types/validated-number-rule.js +0 -0
  163. package/dist/esm/types/validated-rule-group.js +0 -0
  164. package/dist/esm/types/validated-rule-value.js +0 -0
  165. package/dist/esm/types/validated-rule.js +0 -0
  166. package/dist/esm/types/validated-string-rule.js +0 -0
  167. package/dist/esm/utils/index.js +0 -4
  168. package/dist/types/search/operators.d.ts +0 -128
  169. package/dist/types/types/api-key-filter-name.d.ts +0 -2
  170. package/dist/types/types/array-filter-args.d.ts +0 -5
  171. package/dist/types/types/base-callout-component-schema.d.ts +0 -9
  172. package/dist/types/types/base-filter-args.d.ts +0 -5
  173. package/dist/types/types/base-validated-rule.d.ts +0 -9
  174. package/dist/types/types/callout-component-schema.d.ts +0 -2
  175. package/dist/types/types/callout-filter-name.d.ts +0 -2
  176. package/dist/types/types/callout-form-schema.d.ts +0 -4
  177. package/dist/types/types/callout-navigation-schema.d.ts +0 -6
  178. package/dist/types/types/callout-response-answer-address.d.ts +0 -9
  179. package/dist/types/types/callout-response-answer-file-upload.d.ts +0 -3
  180. package/dist/types/types/callout-response-answer.d.ts +0 -2
  181. package/dist/types/types/callout-response-answers.d.ts +0 -5
  182. package/dist/types/types/callout-response-comment-filter-name.d.ts +0 -2
  183. package/dist/types/types/callout-response-filter-name.d.ts +0 -2
  184. package/dist/types/types/callout-slide-schema.d.ts +0 -7
  185. package/dist/types/types/callout-tag-filter-name.d.ts +0 -2
  186. package/dist/types/types/content-callout-component-schema.d.ts +0 -5
  187. package/dist/types/types/date-unit.d.ts +0 -2
  188. package/dist/types/types/duration.d.ts +0 -1
  189. package/dist/types/types/enum-filter-args.d.ts +0 -5
  190. package/dist/types/types/feeable.d.ts +0 -6
  191. package/dist/types/types/filter-args.d.ts +0 -2
  192. package/dist/types/types/filter-type.d.ts +0 -1
  193. package/dist/types/types/filters.d.ts +0 -2
  194. package/dist/types/types/index.d.ts +0 -50
  195. package/dist/types/types/input-callout-component-schema.d.ts +0 -6
  196. package/dist/types/types/input-file-callout-component-schema.d.ts +0 -5
  197. package/dist/types/types/nestable-callout-component-schema.d.ts +0 -6
  198. package/dist/types/types/notice-filter-name.d.ts +0 -2
  199. package/dist/types/types/operators-by-type.d.ts +0 -2
  200. package/dist/types/types/other-filter-args.d.ts +0 -4
  201. package/dist/types/types/paginated-query.d.ts +0 -8
  202. package/dist/types/types/paginated.d.ts +0 -6
  203. package/dist/types/types/payment-filter-name.d.ts +0 -2
  204. package/dist/types/types/radio-callout-component-schema.d.ts +0 -10
  205. package/dist/types/types/role-type.d.ts +0 -2
  206. package/dist/types/types/rule-group.d.ts +0 -5
  207. package/dist/types/types/rule-operator.d.ts +0 -2
  208. package/dist/types/types/rule-opperator-params.d.ts +0 -3
  209. package/dist/types/types/rule-value.d.ts +0 -1
  210. package/dist/types/types/rule.d.ts +0 -6
  211. package/dist/types/types/select-callout-component-schema.d.ts +0 -11
  212. package/dist/types/types/stripe-fee-country.d.ts +0 -1
  213. package/dist/types/types/unit-matches.d.ts +0 -2
  214. package/dist/types/types/validated-boolean-rule.d.ts +0 -2
  215. package/dist/types/types/validated-number-rule.d.ts +0 -2
  216. package/dist/types/types/validated-rule-group.d.ts +0 -5
  217. package/dist/types/types/validated-rule-value.d.ts +0 -2
  218. package/dist/types/types/validated-rule.d.ts +0 -2
  219. package/dist/types/types/validated-string-rule.d.ts +0 -2
  220. package/dist/types/utils/index.d.ts +0 -4
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateRuleGroup = exports.validateRule = exports.isRuleGroup = void 0;
4
+ const error_1 = require("../error");
5
+ const search_1 = require("../search");
6
+ const date_1 = require("./date");
7
+ function isRuleGroup(ruleOrGroup) {
8
+ return "condition" in ruleOrGroup;
9
+ }
10
+ exports.isRuleGroup = isRuleGroup;
11
+ function validateRule(filters, rule) {
12
+ const filter = filters[rule.field];
13
+ if (!filter) {
14
+ throw new error_1.InvalidRule(rule, `Invalid field: ${rule.field}`);
15
+ }
16
+ let expectedArgs = 0;
17
+ if (rule.operator in search_1.nullableOperators) {
18
+ // Field cannot be empty (except text which can always be empty)
19
+ if (!filter.nullable && filter.type !== "text") {
20
+ throw new error_1.InvalidRule(rule, `Invalid nullable operator: field is not nullable`);
21
+ }
22
+ }
23
+ else {
24
+ const operator = search_1.operatorsByTypeMap[filter.type][rule.operator];
25
+ if (!operator) {
26
+ throw new error_1.InvalidRule(rule, `Invalid operator for type: ${filter.type} type doesn't define ${rule.operator}`);
27
+ }
28
+ expectedArgs = operator.args;
29
+ }
30
+ if (expectedArgs !== rule.value.length) {
31
+ throw new error_1.InvalidRule(rule, `Invalid operator argument count: ${rule.operator} needs ${expectedArgs}, ${rule.value.length} given`);
32
+ }
33
+ const expectedType = filter.type === "boolean" || filter.type === "number"
34
+ ? filter.type
35
+ : "string";
36
+ if (rule.value.some((v) => typeof v !== expectedType)) {
37
+ throw new error_1.InvalidRule(rule, `Invalid operator argument type: ${rule.operator} needs ${expectedType}, ${rule.value.map((v) => typeof v)} given`);
38
+ }
39
+ if (filter.type === "date" &&
40
+ rule.value.some((v) => !(0, date_1.isValidDate)(v))) {
41
+ throw new error_1.InvalidRule(rule, `Invalid operator argument: date type needs valid absolute or relative date, ${rule.value} given`);
42
+ }
43
+ if ((filter.type === "enum" || filter.type === "array") &&
44
+ rule.value.some((v) => filter.options?.indexOf(v) === -1)) {
45
+ throw new error_1.InvalidRule(rule, `Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`);
46
+ }
47
+ return {
48
+ field: rule.field,
49
+ type: filter.type,
50
+ nullable: !!filter.nullable,
51
+ operator: rule.operator,
52
+ value: rule.value,
53
+ };
54
+ }
55
+ exports.validateRule = validateRule;
56
+ function validateRuleGroup(filters, ruleGroup) {
57
+ const validatedRuleGroup = {
58
+ condition: ruleGroup.condition,
59
+ rules: [],
60
+ };
61
+ for (const rule of ruleGroup.rules) {
62
+ const valid = isRuleGroup(rule)
63
+ ? validateRuleGroup(filters, rule)
64
+ : validateRule(filters, rule);
65
+ validatedRuleGroup.rules.push(valid);
66
+ }
67
+ return validatedRuleGroup;
68
+ }
69
+ exports.validateRuleGroup = validateRuleGroup;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,57 +1,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
+ export var ContributionPeriod;
2
+ (function (ContributionPeriod) {
3
+ ContributionPeriod["Monthly"] = "monthly";
4
+ ContributionPeriod["Annually"] = "annually";
5
+ })(ContributionPeriod || (ContributionPeriod = {}));
6
+ export var ContributionType;
7
+ (function (ContributionType) {
8
+ ContributionType["Automatic"] = "Automatic";
9
+ ContributionType["Manual"] = "Manual";
10
+ ContributionType["Gift"] = "Gift";
11
+ ContributionType["None"] = "None";
12
+ })(ContributionType || (ContributionType = {}));
13
+ export var ItemStatus;
14
+ (function (ItemStatus) {
15
+ ItemStatus["Draft"] = "draft";
16
+ ItemStatus["Scheduled"] = "scheduled";
17
+ ItemStatus["Open"] = "open";
18
+ ItemStatus["Ended"] = "ended";
19
+ })(ItemStatus || (ItemStatus = {}));
20
+ export var MembershipStatus;
21
+ (function (MembershipStatus) {
22
+ MembershipStatus["Active"] = "active";
23
+ MembershipStatus["Expiring"] = "expiring";
24
+ MembershipStatus["Expired"] = "expired";
25
+ MembershipStatus["None"] = "none";
26
+ })(MembershipStatus || (MembershipStatus = {}));
27
+ export var NewsletterStatus;
28
+ (function (NewsletterStatus) {
29
+ NewsletterStatus["Subscribed"] = "subscribed";
30
+ NewsletterStatus["Unsubscribed"] = "unsubscribed";
31
+ NewsletterStatus["Cleaned"] = "cleaned";
32
+ NewsletterStatus["Pending"] = "pending";
33
+ NewsletterStatus["None"] = "none";
34
+ })(NewsletterStatus || (NewsletterStatus = {}));
35
+ export var PaymentMethod;
36
+ (function (PaymentMethod) {
37
+ PaymentMethod["StripeCard"] = "s_card";
38
+ PaymentMethod["StripeSEPA"] = "s_sepa";
39
+ PaymentMethod["StripeBACS"] = "s_bacs";
40
+ PaymentMethod["GoCardlessDirectDebit"] = "gc_direct-debit";
41
+ })(PaymentMethod || (PaymentMethod = {}));
42
+ export var PaymentStatus;
43
+ (function (PaymentStatus) {
44
+ PaymentStatus["Pending"] = "pending";
45
+ PaymentStatus["Successful"] = "successful";
46
+ PaymentStatus["Failed"] = "failed";
47
+ PaymentStatus["Cancelled"] = "cancelled";
48
+ })(PaymentStatus || (PaymentStatus = {}));
49
+ export const RoleTypes = ["member", "admin", "superadmin"];
50
+ export * from "./callouts";
@@ -1,11 +1,8 @@
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
- }
1
+ export default 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
- };
@@ -1 +1,2 @@
1
- export * from "./InvalidRule.js";
1
+ import InvalidRule from "./InvalidRule";
2
+ export { InvalidRule };
package/dist/esm/index.js CHANGED
@@ -1,4 +1,7 @@
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
+ export * from "./search";
2
+ export * from "./data";
3
+ export * from "./error";
4
+ export * from "./utils/callouts";
5
+ export * from "./utils/date";
6
+ export * from "./utils/payments";
7
+ export * from "./utils/rules";
@@ -1,11 +1,8 @@
1
- const apiKeyFilters = {
2
- id: {
3
- type: "text"
4
- },
5
- createdAt: {
6
- type: "date"
7
- }
8
- };
9
- export {
10
- apiKeyFilters
1
+ export const apiKeyFilters = {
2
+ id: {
3
+ type: "text",
4
+ },
5
+ createdAt: {
6
+ type: "date",
7
+ },
11
8
  };
@@ -1,104 +1,98 @@
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
- }
1
+ import { ItemStatus } from "../data";
2
+ export 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
- 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
- }
33
+ export 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
- 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
- }
65
+ export 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
- 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
85
+ export 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
+ },
104
98
  };
@@ -1,84 +1,75 @@
1
- import {
2
- ContributionPeriod,
3
- ContributionType,
4
- NewsletterStatus
5
- } from "../data/index.js";
6
- const RoleTypes = ["member", "admin", "superadmin"];
7
- const contactFilters = {
8
- id: {
9
- type: "contact"
10
- },
11
- firstname: {
12
- type: "text"
13
- },
14
- lastname: {
15
- type: "text"
16
- },
17
- email: {
18
- type: "text"
19
- },
20
- joined: {
21
- type: "date"
22
- },
23
- lastSeen: {
24
- type: "date"
25
- },
26
- contributionCancelled: {
27
- type: "date",
28
- nullable: true
29
- },
30
- contributionType: {
31
- type: "enum",
32
- options: [
33
- ContributionType.Automatic,
34
- ContributionType.Gift,
35
- ContributionType.Manual,
36
- ContributionType.None
37
- ]
38
- },
39
- contributionMonthlyAmount: {
40
- type: "number"
41
- },
42
- contributionPeriod: {
43
- type: "enum",
44
- options: [ContributionPeriod.Monthly, ContributionPeriod.Annually]
45
- },
46
- deliveryOptIn: {
47
- type: "boolean"
48
- },
49
- newsletterStatus: {
50
- type: "enum",
51
- options: [
52
- NewsletterStatus.Subscribed,
53
- NewsletterStatus.Unsubscribed,
54
- NewsletterStatus.Cleaned,
55
- NewsletterStatus.Pending,
56
- NewsletterStatus.None
57
- ]
58
- },
59
- activePermission: {
60
- type: "enum",
61
- options: RoleTypes
62
- },
63
- activeMembership: {
64
- type: "boolean"
65
- },
66
- membershipStarts: {
67
- type: "date"
68
- },
69
- membershipExpires: {
70
- type: "date"
71
- },
72
- manualPaymentSource: {
73
- type: "text",
74
- nullable: true
75
- },
76
- tags: {
77
- type: "array",
78
- nullable: true
79
- }
80
- };
81
- export {
82
- RoleTypes,
83
- contactFilters
1
+ import { ContributionPeriod, ContributionType, NewsletterStatus, RoleTypes, } from "../data";
2
+ export const contactFilters = {
3
+ id: {
4
+ type: "contact",
5
+ },
6
+ firstname: {
7
+ type: "text",
8
+ },
9
+ lastname: {
10
+ type: "text",
11
+ },
12
+ email: {
13
+ type: "text",
14
+ },
15
+ joined: {
16
+ type: "date",
17
+ },
18
+ lastSeen: {
19
+ type: "date",
20
+ },
21
+ contributionCancelled: {
22
+ type: "date",
23
+ nullable: true,
24
+ },
25
+ contributionType: {
26
+ type: "enum",
27
+ options: [
28
+ ContributionType.Automatic,
29
+ ContributionType.Gift,
30
+ ContributionType.Manual,
31
+ ContributionType.None,
32
+ ],
33
+ },
34
+ contributionMonthlyAmount: {
35
+ type: "number",
36
+ },
37
+ contributionPeriod: {
38
+ type: "enum",
39
+ options: [ContributionPeriod.Monthly, ContributionPeriod.Annually],
40
+ },
41
+ deliveryOptIn: {
42
+ type: "boolean",
43
+ },
44
+ newsletterStatus: {
45
+ type: "enum",
46
+ options: [
47
+ NewsletterStatus.Subscribed,
48
+ NewsletterStatus.Unsubscribed,
49
+ NewsletterStatus.Cleaned,
50
+ NewsletterStatus.Pending,
51
+ NewsletterStatus.None,
52
+ ],
53
+ },
54
+ activePermission: {
55
+ type: "enum",
56
+ options: RoleTypes,
57
+ },
58
+ activeMembership: {
59
+ type: "boolean",
60
+ },
61
+ membershipStarts: {
62
+ type: "date",
63
+ },
64
+ membershipExpires: {
65
+ type: "date",
66
+ },
67
+ manualPaymentSource: {
68
+ type: "text",
69
+ nullable: true,
70
+ },
71
+ tags: {
72
+ type: "array",
73
+ nullable: true,
74
+ },
84
75
  };
@@ -1,6 +1,64 @@
1
- export * from "./api-keys.js";
2
- export * from "./callouts.js";
3
- export * from "./contacts.js";
4
- export * from "./notices.js";
5
- export * from "./operators.js";
6
- export * from "./payments.js";
1
+ // *** Definitions for rules ***
2
+ export const ruleOperators = [
3
+ "equal",
4
+ "not_equal",
5
+ "less",
6
+ "less_or_equal",
7
+ "greater",
8
+ "greater_or_equal",
9
+ "between",
10
+ "not_between",
11
+ "begins_with",
12
+ "not_begins_with",
13
+ "contains",
14
+ "not_contains",
15
+ "ends_with",
16
+ "not_ends_with",
17
+ "is_empty",
18
+ "is_not_empty",
19
+ ];
20
+ const equalityOperators = {
21
+ equal: { args: 1 },
22
+ not_equal: { args: 1 },
23
+ };
24
+ const stringOperators = {
25
+ begins_with: { args: 1 },
26
+ ends_with: { args: 1 },
27
+ not_begins_with: { args: 1 },
28
+ not_ends_with: { args: 1 },
29
+ };
30
+ const numericOperators = {
31
+ ...equalityOperators,
32
+ between: { args: 2 },
33
+ not_between: { args: 2 },
34
+ less: { args: 1 },
35
+ greater: { args: 1 },
36
+ less_or_equal: { args: 1 },
37
+ greater_or_equal: { args: 1 },
38
+ };
39
+ const arrayOperators = {
40
+ contains: { args: 1 },
41
+ not_contains: { args: 1 },
42
+ };
43
+ // Special operator can be applied across all fields if they are nullable
44
+ export const nullableOperators = {
45
+ is_empty: { args: 0 },
46
+ is_not_empty: { args: 0 },
47
+ };
48
+ export const operatorsByType = {
49
+ text: { ...equalityOperators, ...arrayOperators, ...stringOperators },
50
+ blob: arrayOperators,
51
+ date: numericOperators,
52
+ number: numericOperators,
53
+ boolean: { equal: equalityOperators.equal },
54
+ array: arrayOperators,
55
+ enum: equalityOperators,
56
+ contact: equalityOperators,
57
+ };
58
+ // More general type to allow mapping while maintaining full type above
59
+ export const operatorsByTypeMap = operatorsByType;
60
+ export * from "./api-keys";
61
+ export * from "./callouts";
62
+ export * from "./contacts";
63
+ export * from "./notices";
64
+ export * from "./payments";