@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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.RoleTypes = exports.PaymentStatus = exports.PaymentMethod = exports.NewsletterStatus = exports.MembershipStatus = exports.ItemStatus = exports.ContributionType = exports.ContributionPeriod = void 0;
18
+ var ContributionPeriod;
19
+ (function (ContributionPeriod) {
20
+ ContributionPeriod["Monthly"] = "monthly";
21
+ ContributionPeriod["Annually"] = "annually";
22
+ })(ContributionPeriod = exports.ContributionPeriod || (exports.ContributionPeriod = {}));
23
+ var ContributionType;
24
+ (function (ContributionType) {
25
+ ContributionType["Automatic"] = "Automatic";
26
+ ContributionType["Manual"] = "Manual";
27
+ ContributionType["Gift"] = "Gift";
28
+ ContributionType["None"] = "None";
29
+ })(ContributionType = exports.ContributionType || (exports.ContributionType = {}));
30
+ var ItemStatus;
31
+ (function (ItemStatus) {
32
+ ItemStatus["Draft"] = "draft";
33
+ ItemStatus["Scheduled"] = "scheduled";
34
+ ItemStatus["Open"] = "open";
35
+ ItemStatus["Ended"] = "ended";
36
+ })(ItemStatus = exports.ItemStatus || (exports.ItemStatus = {}));
37
+ var MembershipStatus;
38
+ (function (MembershipStatus) {
39
+ MembershipStatus["Active"] = "active";
40
+ MembershipStatus["Expiring"] = "expiring";
41
+ MembershipStatus["Expired"] = "expired";
42
+ MembershipStatus["None"] = "none";
43
+ })(MembershipStatus = exports.MembershipStatus || (exports.MembershipStatus = {}));
44
+ var NewsletterStatus;
45
+ (function (NewsletterStatus) {
46
+ NewsletterStatus["Subscribed"] = "subscribed";
47
+ NewsletterStatus["Unsubscribed"] = "unsubscribed";
48
+ NewsletterStatus["Cleaned"] = "cleaned";
49
+ NewsletterStatus["Pending"] = "pending";
50
+ NewsletterStatus["None"] = "none";
51
+ })(NewsletterStatus = exports.NewsletterStatus || (exports.NewsletterStatus = {}));
52
+ var PaymentMethod;
53
+ (function (PaymentMethod) {
54
+ PaymentMethod["StripeCard"] = "s_card";
55
+ PaymentMethod["StripeSEPA"] = "s_sepa";
56
+ PaymentMethod["StripeBACS"] = "s_bacs";
57
+ PaymentMethod["GoCardlessDirectDebit"] = "gc_direct-debit";
58
+ })(PaymentMethod = exports.PaymentMethod || (exports.PaymentMethod = {}));
59
+ var PaymentStatus;
60
+ (function (PaymentStatus) {
61
+ PaymentStatus["Pending"] = "pending";
62
+ PaymentStatus["Successful"] = "successful";
63
+ PaymentStatus["Failed"] = "failed";
64
+ PaymentStatus["Cancelled"] = "cancelled";
65
+ })(PaymentStatus = exports.PaymentStatus || (exports.PaymentStatus = {}));
66
+ exports.RoleTypes = ["member", "admin", "superadmin"];
67
+ __exportStar(require("./callouts"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class InvalidRule extends Error {
4
+ constructor(rule, message) {
5
+ super();
6
+ this.rule = rule;
7
+ this.message = message;
8
+ Object.setPrototypeOf(this, InvalidRule.prototype);
9
+ }
10
+ }
11
+ exports.default = InvalidRule;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InvalidRule = void 0;
7
+ const InvalidRule_1 = __importDefault(require("./InvalidRule"));
8
+ exports.InvalidRule = InvalidRule_1.default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./search"), exports);
18
+ __exportStar(require("./data"), exports);
19
+ __exportStar(require("./error"), exports);
20
+ __exportStar(require("./utils/callouts"), exports);
21
+ __exportStar(require("./utils/date"), exports);
22
+ __exportStar(require("./utils/payments"), exports);
23
+ __exportStar(require("./utils/rules"), exports);
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiKeyFilters = void 0;
4
+ exports.apiKeyFilters = {
5
+ id: {
6
+ type: "text",
7
+ },
8
+ createdAt: {
9
+ type: "date",
10
+ },
11
+ };
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calloutTagFilters = exports.calloutResponseCommentFilters = exports.calloutResponseFilters = exports.calloutFilters = void 0;
4
+ const data_1 = require("../data");
5
+ exports.calloutFilters = {
6
+ slug: {
7
+ type: "text",
8
+ },
9
+ title: {
10
+ type: "text",
11
+ },
12
+ status: {
13
+ type: "enum",
14
+ options: [
15
+ data_1.ItemStatus.Draft,
16
+ data_1.ItemStatus.Scheduled,
17
+ data_1.ItemStatus.Open,
18
+ data_1.ItemStatus.Ended,
19
+ ],
20
+ },
21
+ answeredBy: {
22
+ type: "contact",
23
+ },
24
+ starts: {
25
+ type: "date",
26
+ nullable: true,
27
+ },
28
+ expires: {
29
+ type: "date",
30
+ nullable: true,
31
+ },
32
+ hidden: {
33
+ type: "boolean",
34
+ },
35
+ };
36
+ exports.calloutResponseFilters = {
37
+ id: {
38
+ type: "text",
39
+ },
40
+ contact: {
41
+ type: "contact",
42
+ nullable: true,
43
+ },
44
+ callout: {
45
+ type: "text",
46
+ },
47
+ createdAt: {
48
+ type: "date",
49
+ },
50
+ updatedAt: {
51
+ type: "date",
52
+ },
53
+ bucket: {
54
+ type: "text",
55
+ nullable: true,
56
+ },
57
+ tags: {
58
+ type: "array",
59
+ },
60
+ assignee: {
61
+ type: "contact",
62
+ nullable: true,
63
+ },
64
+ answers: {
65
+ type: "blob",
66
+ },
67
+ };
68
+ exports.calloutResponseCommentFilters = {
69
+ id: {
70
+ type: "text",
71
+ },
72
+ responseId: {
73
+ type: "text",
74
+ },
75
+ contact: {
76
+ type: "contact",
77
+ },
78
+ createdAt: {
79
+ type: "date",
80
+ },
81
+ updatedAt: {
82
+ type: "date",
83
+ },
84
+ text: {
85
+ type: "text",
86
+ },
87
+ };
88
+ exports.calloutTagFilters = {
89
+ id: {
90
+ type: "text",
91
+ },
92
+ name: {
93
+ type: "text",
94
+ },
95
+ description: {
96
+ type: "text",
97
+ },
98
+ calloutSlug: {
99
+ type: "text",
100
+ },
101
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contactFilters = void 0;
4
+ const data_1 = require("../data");
5
+ exports.contactFilters = {
6
+ id: {
7
+ type: "contact",
8
+ },
9
+ firstname: {
10
+ type: "text",
11
+ },
12
+ lastname: {
13
+ type: "text",
14
+ },
15
+ email: {
16
+ type: "text",
17
+ },
18
+ joined: {
19
+ type: "date",
20
+ },
21
+ lastSeen: {
22
+ type: "date",
23
+ },
24
+ contributionCancelled: {
25
+ type: "date",
26
+ nullable: true,
27
+ },
28
+ contributionType: {
29
+ type: "enum",
30
+ options: [
31
+ data_1.ContributionType.Automatic,
32
+ data_1.ContributionType.Gift,
33
+ data_1.ContributionType.Manual,
34
+ data_1.ContributionType.None,
35
+ ],
36
+ },
37
+ contributionMonthlyAmount: {
38
+ type: "number",
39
+ },
40
+ contributionPeriod: {
41
+ type: "enum",
42
+ options: [data_1.ContributionPeriod.Monthly, data_1.ContributionPeriod.Annually],
43
+ },
44
+ deliveryOptIn: {
45
+ type: "boolean",
46
+ },
47
+ newsletterStatus: {
48
+ type: "enum",
49
+ options: [
50
+ data_1.NewsletterStatus.Subscribed,
51
+ data_1.NewsletterStatus.Unsubscribed,
52
+ data_1.NewsletterStatus.Cleaned,
53
+ data_1.NewsletterStatus.Pending,
54
+ data_1.NewsletterStatus.None,
55
+ ],
56
+ },
57
+ activePermission: {
58
+ type: "enum",
59
+ options: data_1.RoleTypes,
60
+ },
61
+ activeMembership: {
62
+ type: "boolean",
63
+ },
64
+ membershipStarts: {
65
+ type: "date",
66
+ },
67
+ membershipExpires: {
68
+ type: "date",
69
+ },
70
+ manualPaymentSource: {
71
+ type: "text",
72
+ nullable: true,
73
+ },
74
+ tags: {
75
+ type: "array",
76
+ nullable: true,
77
+ },
78
+ };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ // *** Definitions for rules ***
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.operatorsByTypeMap = exports.operatorsByType = exports.nullableOperators = exports.ruleOperators = void 0;
19
+ exports.ruleOperators = [
20
+ "equal",
21
+ "not_equal",
22
+ "less",
23
+ "less_or_equal",
24
+ "greater",
25
+ "greater_or_equal",
26
+ "between",
27
+ "not_between",
28
+ "begins_with",
29
+ "not_begins_with",
30
+ "contains",
31
+ "not_contains",
32
+ "ends_with",
33
+ "not_ends_with",
34
+ "is_empty",
35
+ "is_not_empty",
36
+ ];
37
+ const equalityOperators = {
38
+ equal: { args: 1 },
39
+ not_equal: { args: 1 },
40
+ };
41
+ const stringOperators = {
42
+ begins_with: { args: 1 },
43
+ ends_with: { args: 1 },
44
+ not_begins_with: { args: 1 },
45
+ not_ends_with: { args: 1 },
46
+ };
47
+ const numericOperators = {
48
+ ...equalityOperators,
49
+ between: { args: 2 },
50
+ not_between: { args: 2 },
51
+ less: { args: 1 },
52
+ greater: { args: 1 },
53
+ less_or_equal: { args: 1 },
54
+ greater_or_equal: { args: 1 },
55
+ };
56
+ const arrayOperators = {
57
+ contains: { args: 1 },
58
+ not_contains: { args: 1 },
59
+ };
60
+ // Special operator can be applied across all fields if they are nullable
61
+ exports.nullableOperators = {
62
+ is_empty: { args: 0 },
63
+ is_not_empty: { args: 0 },
64
+ };
65
+ exports.operatorsByType = {
66
+ text: { ...equalityOperators, ...arrayOperators, ...stringOperators },
67
+ blob: arrayOperators,
68
+ date: numericOperators,
69
+ number: numericOperators,
70
+ boolean: { equal: equalityOperators.equal },
71
+ array: arrayOperators,
72
+ enum: equalityOperators,
73
+ contact: equalityOperators,
74
+ };
75
+ // More general type to allow mapping while maintaining full type above
76
+ exports.operatorsByTypeMap = exports.operatorsByType;
77
+ __exportStar(require("./api-keys"), exports);
78
+ __exportStar(require("./callouts"), exports);
79
+ __exportStar(require("./contacts"), exports);
80
+ __exportStar(require("./notices"), exports);
81
+ __exportStar(require("./payments"), exports);
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noticeFilters = void 0;
4
+ const data_1 = require("../data");
5
+ exports.noticeFilters = {
6
+ id: {
7
+ type: "text",
8
+ },
9
+ createdAt: {
10
+ type: "date",
11
+ },
12
+ updatedAt: {
13
+ type: "date",
14
+ },
15
+ name: {
16
+ type: "text",
17
+ },
18
+ expires: {
19
+ type: "date",
20
+ nullable: true,
21
+ },
22
+ enabled: {
23
+ type: "boolean",
24
+ },
25
+ text: {
26
+ type: "text",
27
+ },
28
+ status: {
29
+ type: "enum",
30
+ options: [
31
+ data_1.ItemStatus.Draft,
32
+ data_1.ItemStatus.Scheduled,
33
+ data_1.ItemStatus.Open,
34
+ data_1.ItemStatus.Ended,
35
+ ],
36
+ },
37
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paymentFilters = void 0;
4
+ const data_1 = require("../data");
5
+ exports.paymentFilters = {
6
+ id: {
7
+ type: "text",
8
+ },
9
+ contact: {
10
+ type: "contact",
11
+ },
12
+ chargeDate: {
13
+ type: "date",
14
+ },
15
+ amount: {
16
+ type: "number",
17
+ },
18
+ status: {
19
+ type: "enum",
20
+ options: [
21
+ data_1.PaymentStatus.Successful,
22
+ data_1.PaymentStatus.Pending,
23
+ data_1.PaymentStatus.Failed,
24
+ data_1.PaymentStatus.Cancelled,
25
+ ],
26
+ },
27
+ };
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyAnswer = exports.isFileUploadAnswer = exports.isAddressAnswer = exports.getCalloutFilters = exports.getCalloutComponents = exports.filterComponents = exports.flattenComponents = void 0;
4
+ function isNestableComponent(component) {
5
+ // Addresses have embedded components we don't want to include
6
+ return "components" in component && component.type !== "address";
7
+ }
8
+ function convertValuesToOptions(values) {
9
+ return values.map(({ value, label }) => value);
10
+ }
11
+ function convertComponentToFilter(component) {
12
+ const baseItem = {
13
+ label: component.label || component.fullKey,
14
+ nullable: true,
15
+ };
16
+ switch (component.type) {
17
+ case "checkbox":
18
+ return { ...baseItem, type: "boolean", nullable: false };
19
+ case "number":
20
+ return { ...baseItem, type: "number" };
21
+ case "select":
22
+ return {
23
+ ...baseItem,
24
+ type: "enum",
25
+ options: convertValuesToOptions(component.data.values),
26
+ };
27
+ case "selectboxes":
28
+ case "radio":
29
+ return {
30
+ ...baseItem,
31
+ type: component.type === "radio" ? "enum" : "array",
32
+ options: convertValuesToOptions(component.values),
33
+ };
34
+ case "textarea":
35
+ return { ...baseItem, type: "blob" };
36
+ default:
37
+ return { ...baseItem, type: "text" };
38
+ }
39
+ }
40
+ function getNiceAnswer(component, value) {
41
+ switch (component.type) {
42
+ case "radio":
43
+ case "selectboxes":
44
+ return component.values.find((v) => v.value === value)?.label || value;
45
+ case "select":
46
+ return (component.data.values.find((v) => v.value === value)?.label || value);
47
+ default:
48
+ return value;
49
+ }
50
+ }
51
+ function flattenComponents(components) {
52
+ return components.flatMap((component) => isNestableComponent(component)
53
+ ? [component, ...flattenComponents(component.components)]
54
+ : [component]);
55
+ }
56
+ exports.flattenComponents = flattenComponents;
57
+ function filterComponents(components, filterFn) {
58
+ return components.filter(filterFn).map((component) => {
59
+ return {
60
+ ...component,
61
+ ...(isNestableComponent(component) && {
62
+ components: filterComponents(component.components, filterFn),
63
+ }),
64
+ };
65
+ });
66
+ }
67
+ exports.filterComponents = filterComponents;
68
+ function getCalloutComponents(formSchema) {
69
+ return formSchema.slides.flatMap((slide) => flattenComponents(slide.components).map((component) => ({
70
+ ...component,
71
+ slideId: slide.id,
72
+ fullKey: `${slide.id}.${component.key}`,
73
+ })));
74
+ }
75
+ exports.getCalloutComponents = getCalloutComponents;
76
+ function getCalloutFilters(formSchema) {
77
+ const items = getCalloutComponents(formSchema)
78
+ .filter((c) => c.input)
79
+ .map((c) => [`answers.${c.fullKey}`, convertComponentToFilter(c)]);
80
+ return Object.fromEntries(items);
81
+ }
82
+ exports.getCalloutFilters = getCalloutFilters;
83
+ function isAddressAnswer(answer) {
84
+ return !!answer && typeof answer === "object" && "geometry" in answer;
85
+ }
86
+ exports.isAddressAnswer = isAddressAnswer;
87
+ function isFileUploadAnswer(answer) {
88
+ return !!answer && typeof answer === "object" && "url" in answer;
89
+ }
90
+ exports.isFileUploadAnswer = isFileUploadAnswer;
91
+ function stringifyAnswer(component, answer) {
92
+ if (Array.isArray(answer)) {
93
+ return answer.map((a) => stringifyAnswer(component, a)).join(", ");
94
+ }
95
+ else if (!answer) {
96
+ return "";
97
+ }
98
+ else if (isAddressAnswer(answer)) {
99
+ return answer.geometry.location.lat + ", " + answer.geometry.location.lng;
100
+ }
101
+ else if (isFileUploadAnswer(answer)) {
102
+ return answer.url;
103
+ }
104
+ else if (typeof answer === "object") {
105
+ // Checkboxes
106
+ return Object.entries(answer)
107
+ .filter(([, selected]) => selected)
108
+ .map(([value]) => getNiceAnswer(component, value))
109
+ .join(", ");
110
+ }
111
+ else if (typeof answer === "string") {
112
+ return getNiceAnswer(component, answer);
113
+ }
114
+ else {
115
+ return answer.toString();
116
+ }
117
+ }
118
+ exports.stringifyAnswer = stringifyAnswer;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isValidDate = exports.getMinDateUnit = exports.parseDate = void 0;
7
+ const add_1 = __importDefault(require("date-fns/add"));
8
+ const isValid_1 = __importDefault(require("date-fns/isValid"));
9
+ const parseISO_1 = __importDefault(require("date-fns/parseISO"));
10
+ const startOfDay_1 = __importDefault(require("date-fns/startOfDay"));
11
+ const startOfHour_1 = __importDefault(require("date-fns/startOfHour"));
12
+ const startOfMinute_1 = __importDefault(require("date-fns/startOfMinute"));
13
+ const startOfMonth_1 = __importDefault(require("date-fns/startOfMonth"));
14
+ const startOfSecond_1 = __importDefault(require("date-fns/startOfSecond"));
15
+ const startOfYear_1 = __importDefault(require("date-fns/startOfYear"));
16
+ // Must be ordered from highest resolution to lowest (seconds to years)
17
+ const dateUnits = ["s", "m", "h", "d", "M", "y"];
18
+ const dateUnitMap = {
19
+ y: "years",
20
+ M: "months",
21
+ d: "days",
22
+ h: "hours",
23
+ m: "minutes",
24
+ s: "seconds",
25
+ };
26
+ const startOf = {
27
+ y: startOfYear_1.default,
28
+ M: startOfMonth_1.default,
29
+ d: startOfDay_1.default,
30
+ h: startOfHour_1.default,
31
+ m: startOfMinute_1.default,
32
+ s: startOfSecond_1.default,
33
+ };
34
+ const relativeDate = /^\$now(?<units>\(((y|M|d|h|m|s):(-?\d+),?)+\))?$/;
35
+ const relativeUnit = /(y|M|d|h|m|s):(-?\d+)/g;
36
+ // Matches the different parts of an ISO 8601 date. Note we don't validate the
37
+ // pattern properly as that is handled by parseISO, we just want to know which
38
+ // parts of the date were specified
39
+ const absoluteDate = /^(?<y>\d{4,})(-(?<M>\d\d)(-(?<d>\d\d)([T ](?<h>\d\d)(:(?<m>\d\d)(:(?<s>\d\d))?)?)?)?)?/;
40
+ // Convert relative dates and returns the minimum date unit specified
41
+ function parseDate(value, now) {
42
+ let date;
43
+ let units;
44
+ const relativeMatch = relativeDate.exec(value);
45
+ if (relativeMatch) {
46
+ date = now || new Date();
47
+ const unitsGroup = relativeMatch.groups?.units;
48
+ if (unitsGroup) {
49
+ const unitMatches = unitsGroup.matchAll(relativeUnit);
50
+ units = [];
51
+ for (const [_, unit, delta] of unitMatches) {
52
+ date = (0, add_1.default)(date, { [dateUnitMap[unit]]: Number(delta) });
53
+ units.push(unit);
54
+ }
55
+ }
56
+ else {
57
+ units = ["d"];
58
+ }
59
+ }
60
+ else {
61
+ date = (0, parseISO_1.default)(value);
62
+ units = Object.entries(absoluteDate.exec(value)?.groups || {})
63
+ .filter(([_, n]) => !!n)
64
+ .map(([unit]) => unit);
65
+ }
66
+ const minUnit = getMinDateUnit(units) || "s";
67
+ return [startOf[minUnit](date), minUnit];
68
+ }
69
+ exports.parseDate = parseDate;
70
+ function getMinDateUnit(units) {
71
+ return dateUnits.find((unit) => units.includes(unit));
72
+ }
73
+ exports.getMinDateUnit = getMinDateUnit;
74
+ function isValidDate(s) {
75
+ return relativeDate.test(s) || (0, isValid_1.default)((0, parseISO_1.default)(s));
76
+ }
77
+ exports.isValidDate = isValidDate;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calcPaymentFee = void 0;
4
+ const data_1 = require("../data");
5
+ const stripeFees = {
6
+ gb: {
7
+ [data_1.PaymentMethod.StripeCard]: (amount) => 0.2 + 0.015 * amount,
8
+ [data_1.PaymentMethod.StripeSEPA]: () => 0.3,
9
+ [data_1.PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount)),
10
+ },
11
+ eu: {
12
+ [data_1.PaymentMethod.StripeCard]: (amount) => 0.25 + 0.015 * amount,
13
+ [data_1.PaymentMethod.StripeSEPA]: () => 0.35,
14
+ [data_1.PaymentMethod.StripeBACS]: () => 0, // Not available
15
+ },
16
+ ca: {
17
+ [data_1.PaymentMethod.StripeCard]: (amount) => 0.3 + 0.029 * amount,
18
+ [data_1.PaymentMethod.StripeSEPA]: () => 0,
19
+ [data_1.PaymentMethod.StripeBACS]: () => 0, // Not available
20
+ },
21
+ };
22
+ const gcFee = (amount) => 0.2 + amount * 0.01;
23
+ function calcPaymentFee(feeable, country) {
24
+ const feeFn = feeable.paymentMethod === data_1.PaymentMethod.GoCardlessDirectDebit
25
+ ? gcFee
26
+ : stripeFees[country][feeable.paymentMethod];
27
+ return feeable.period === data_1.ContributionPeriod.Annually
28
+ ? 0
29
+ : feeFn(feeable.amount);
30
+ }
31
+ exports.calcPaymentFee = calcPaymentFee;