@beabee/beabee-common 1.19.7 → 1.19.8

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,74 @@
1
+ export interface BaseCalloutComponentSchema {
2
+ id: string;
3
+ type: string;
4
+ key: string;
5
+ label?: string;
6
+ input?: boolean;
7
+ adminOnly?: boolean;
8
+ [key: string]: unknown;
9
+ }
10
+ export interface ContentCalloutComponentSchema extends BaseCalloutComponentSchema {
11
+ type: "content";
12
+ input: false;
13
+ }
14
+ export interface NestableCalloutComponentSchema extends BaseCalloutComponentSchema {
15
+ type: "panel" | "well" | "tabs";
16
+ input: false;
17
+ components: CalloutComponentSchema[];
18
+ }
19
+ export interface InputCalloutComponentSchema extends BaseCalloutComponentSchema {
20
+ type: "address" | "button" | "checkbox" | "email" | "file" | "number" | "password" | "textfield" | "textarea";
21
+ input: true;
22
+ }
23
+ export interface SelectCalloutComponentSchema extends BaseCalloutComponentSchema {
24
+ type: "select";
25
+ input: true;
26
+ data: {
27
+ values: {
28
+ label: string;
29
+ value: string;
30
+ }[];
31
+ };
32
+ }
33
+ export interface RadioCalloutComponentSchema extends BaseCalloutComponentSchema {
34
+ type: "radio" | "selectboxes";
35
+ input: true;
36
+ values: {
37
+ label: string;
38
+ value: string;
39
+ nextSlideId: string;
40
+ }[];
41
+ }
42
+ export type CalloutComponentSchema = ContentCalloutComponentSchema | SelectCalloutComponentSchema | RadioCalloutComponentSchema | InputCalloutComponentSchema | NestableCalloutComponentSchema;
43
+ export interface CalloutNavigationSchema {
44
+ prevText: string;
45
+ nextText: string;
46
+ nextSlideId: string;
47
+ submitText: string;
48
+ }
49
+ export interface CalloutSlideSchema {
50
+ id: string;
51
+ title: string;
52
+ components: CalloutComponentSchema[];
53
+ navigation: CalloutNavigationSchema;
54
+ }
55
+ export interface CalloutFormSchema {
56
+ slides: CalloutSlideSchema[];
57
+ }
58
+ export interface CalloutResponseAnswerAddress {
59
+ formatted_address: string;
60
+ geometry: {
61
+ location: {
62
+ lat: number;
63
+ lng: number;
64
+ };
65
+ };
66
+ }
67
+ export interface CalloutResponseAnswerFileUpload {
68
+ url: string;
69
+ }
70
+ export type CalloutResponseAnswer = string | boolean | number | null | undefined | Record<string, boolean> | CalloutResponseAnswerAddress | CalloutResponseAnswerFileUpload;
71
+ /**
72
+ * Answers are grouped by slide key: {[slideId]: {[componentKey]: answer | answer[]}}
73
+ */
74
+ export type CalloutResponseAnswers = Record<string, Record<string, CalloutResponseAnswer | CalloutResponseAnswer[]> | undefined>;
@@ -39,3 +39,7 @@ export declare enum PaymentStatus {
39
39
  Failed = "failed",
40
40
  Cancelled = "cancelled"
41
41
  }
42
+ export declare const RoleTypes: readonly ["member", "admin", "superadmin"];
43
+ export type RoleType = (typeof RoleTypes)[number];
44
+ export type StripeFeeCountry = "eu" | "gb" | "ca";
45
+ export * from "./callouts";
@@ -1,5 +1,5 @@
1
- import { Rule } from "../types/index.ts";
2
- export declare class InvalidRule extends Error {
1
+ import { Rule } from "../search";
2
+ export default class InvalidRule extends Error {
3
3
  readonly rule: Rule;
4
4
  readonly message: string;
5
5
  constructor(rule: Rule, message: string);
@@ -1 +1,2 @@
1
- export * from "./InvalidRule.ts";
1
+ import InvalidRule from "./InvalidRule";
2
+ export { InvalidRule };
@@ -1,5 +1,7 @@
1
- export * from "./data/index.ts";
2
- export * from "./error/index.ts";
3
- export * from "./search/index.ts";
4
- export * from "./utils/index.ts";
5
- export type * from "./types/index.ts";
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";
@@ -6,3 +6,4 @@ export declare const apiKeyFilters: {
6
6
  readonly type: "date";
7
7
  };
8
8
  };
9
+ export type ApiKeyFilterName = keyof typeof apiKeyFilters;
@@ -1,4 +1,4 @@
1
- import { ItemStatus } from "../data/index.ts";
1
+ import { ItemStatus } from "../data";
2
2
  export declare const calloutFilters: {
3
3
  readonly slug: {
4
4
  readonly type: "text";
@@ -25,6 +25,7 @@ export declare const calloutFilters: {
25
25
  readonly type: "boolean";
26
26
  };
27
27
  };
28
+ export type CalloutFilterName = keyof typeof calloutFilters;
28
29
  export declare const calloutResponseFilters: {
29
30
  readonly id: {
30
31
  readonly type: "text";
@@ -57,6 +58,7 @@ export declare const calloutResponseFilters: {
57
58
  readonly type: "blob";
58
59
  };
59
60
  };
61
+ export type CalloutResponseFilterName = keyof typeof calloutResponseFilters;
60
62
  export declare const calloutResponseCommentFilters: {
61
63
  readonly id: {
62
64
  readonly type: "text";
@@ -77,6 +79,7 @@ export declare const calloutResponseCommentFilters: {
77
79
  readonly type: "text";
78
80
  };
79
81
  };
82
+ export type CalloutResponseCommentFilterName = keyof typeof calloutResponseCommentFilters;
80
83
  export declare const calloutTagFilters: {
81
84
  readonly id: {
82
85
  readonly type: "text";
@@ -91,3 +94,4 @@ export declare const calloutTagFilters: {
91
94
  readonly type: "text";
92
95
  };
93
96
  };
97
+ export type CalloutTagFilterName = keyof typeof calloutTagFilters;
@@ -1,5 +1,4 @@
1
- import { ContributionPeriod, ContributionType, NewsletterStatus } from "../data/index.ts";
2
- export declare const RoleTypes: readonly ["member", "admin", "superadmin"];
1
+ import { ContributionPeriod, ContributionType, NewsletterStatus } from "../data";
3
2
  export declare const contactFilters: {
4
3
  readonly id: {
5
4
  readonly type: "contact";
@@ -1,6 +1,194 @@
1
- export * from "./api-keys.ts";
2
- export * from "./callouts.ts";
3
- export * from "./contacts.ts";
4
- export * from "./notices.ts";
5
- export * from "./operators.ts";
6
- export * from "./payments.ts";
1
+ export declare const ruleOperators: readonly ["equal", "not_equal", "less", "less_or_equal", "greater", "greater_or_equal", "between", "not_between", "begins_with", "not_begins_with", "contains", "not_contains", "ends_with", "not_ends_with", "is_empty", "is_not_empty"];
2
+ export type RuleOperator = (typeof ruleOperators)[number];
3
+ export type RuleValue = string | number | boolean;
4
+ export interface Rule {
5
+ field: string;
6
+ operator: RuleOperator;
7
+ value: RuleValue[];
8
+ }
9
+ export interface RuleGroup {
10
+ condition: "AND" | "OR";
11
+ rules: (RuleGroup | Rule)[];
12
+ }
13
+ export type ValidatedRuleValue<T extends FilterType> = T extends "number" ? number : T extends "boolean" ? boolean : string;
14
+ interface BaseValidatedRule<T extends FilterType, F extends string> {
15
+ type: T;
16
+ field: F;
17
+ nullable: boolean;
18
+ operator: keyof (typeof operatorsByType)[T];
19
+ value: ValidatedRuleValue<T>[];
20
+ }
21
+ type ValidatedNumberRule<Field extends string> = BaseValidatedRule<"number", Field>;
22
+ type ValidatedStringRule<Field extends string> = BaseValidatedRule<Exclude<FilterType, "number" | "boolean">, Field>;
23
+ type ValidatedBooleanRule<Field extends string> = BaseValidatedRule<"boolean", Field>;
24
+ export type ValidatedRule<Field extends string> = ValidatedNumberRule<Field> | ValidatedStringRule<Field> | ValidatedBooleanRule<Field>;
25
+ export interface ValidatedRuleGroup<Field extends string> {
26
+ condition: "AND" | "OR";
27
+ rules: (ValidatedRuleGroup<Field> | ValidatedRule<Field>)[];
28
+ }
29
+ export type FilterType = "text" | "blob" | "date" | "number" | "boolean" | "array" | "enum" | "contact";
30
+ interface BaseFilterArgs {
31
+ type: FilterType;
32
+ nullable?: boolean;
33
+ }
34
+ export interface ArrayFilterArgs<T extends readonly string[] | undefined> extends BaseFilterArgs {
35
+ type: "array";
36
+ options?: T;
37
+ }
38
+ export interface EnumFilterArgs<T extends readonly string[]> extends BaseFilterArgs {
39
+ type: "enum";
40
+ options: T;
41
+ }
42
+ export interface OtherFilterArgs extends BaseFilterArgs {
43
+ type: Exclude<FilterType, "array" | "enum">;
44
+ }
45
+ export type FilterArgs = ArrayFilterArgs<readonly string[] | undefined> | EnumFilterArgs<readonly string[]> | OtherFilterArgs;
46
+ export type Filters<T extends string = string> = Record<T, FilterArgs>;
47
+ export interface RuleOperatorParams {
48
+ args: number;
49
+ }
50
+ export declare const nullableOperators: {
51
+ is_empty: {
52
+ args: number;
53
+ };
54
+ is_not_empty: {
55
+ args: number;
56
+ };
57
+ };
58
+ type OperatorsByType = Record<FilterType, Partial<Record<RuleOperator, RuleOperatorParams>>>;
59
+ export declare const operatorsByType: {
60
+ readonly text: {
61
+ readonly begins_with: {
62
+ args: number;
63
+ };
64
+ readonly ends_with: {
65
+ args: number;
66
+ };
67
+ readonly not_begins_with: {
68
+ args: number;
69
+ };
70
+ readonly not_ends_with: {
71
+ args: number;
72
+ };
73
+ readonly contains: {
74
+ args: number;
75
+ };
76
+ readonly not_contains: {
77
+ args: number;
78
+ };
79
+ readonly equal: {
80
+ args: number;
81
+ };
82
+ readonly not_equal: {
83
+ args: number;
84
+ };
85
+ };
86
+ readonly blob: {
87
+ contains: {
88
+ args: number;
89
+ };
90
+ not_contains: {
91
+ args: number;
92
+ };
93
+ };
94
+ readonly date: {
95
+ between: {
96
+ args: number;
97
+ };
98
+ not_between: {
99
+ args: number;
100
+ };
101
+ less: {
102
+ args: number;
103
+ };
104
+ greater: {
105
+ args: number;
106
+ };
107
+ less_or_equal: {
108
+ args: number;
109
+ };
110
+ greater_or_equal: {
111
+ args: number;
112
+ };
113
+ equal: {
114
+ args: number;
115
+ };
116
+ not_equal: {
117
+ args: number;
118
+ };
119
+ };
120
+ readonly number: {
121
+ between: {
122
+ args: number;
123
+ };
124
+ not_between: {
125
+ args: number;
126
+ };
127
+ less: {
128
+ args: number;
129
+ };
130
+ greater: {
131
+ args: number;
132
+ };
133
+ less_or_equal: {
134
+ args: number;
135
+ };
136
+ greater_or_equal: {
137
+ args: number;
138
+ };
139
+ equal: {
140
+ args: number;
141
+ };
142
+ not_equal: {
143
+ args: number;
144
+ };
145
+ };
146
+ readonly boolean: {
147
+ readonly equal: {
148
+ args: number;
149
+ };
150
+ };
151
+ readonly array: {
152
+ contains: {
153
+ args: number;
154
+ };
155
+ not_contains: {
156
+ args: number;
157
+ };
158
+ };
159
+ readonly enum: {
160
+ equal: {
161
+ args: number;
162
+ };
163
+ not_equal: {
164
+ args: number;
165
+ };
166
+ };
167
+ readonly contact: {
168
+ equal: {
169
+ args: number;
170
+ };
171
+ not_equal: {
172
+ args: number;
173
+ };
174
+ };
175
+ };
176
+ export declare const operatorsByTypeMap: OperatorsByType;
177
+ export interface Paginated<T> {
178
+ items: T[];
179
+ offset: number;
180
+ count: number;
181
+ total: number;
182
+ }
183
+ export interface PaginatedQuery {
184
+ limit?: number;
185
+ offset?: number;
186
+ sort?: string;
187
+ order?: "ASC" | "DESC";
188
+ rules?: RuleGroup;
189
+ }
190
+ export * from "./api-keys";
191
+ export * from "./callouts";
192
+ export * from "./contacts";
193
+ export * from "./notices";
194
+ export * from "./payments";
@@ -1,4 +1,4 @@
1
- import { ItemStatus } from "../data/index.ts";
1
+ import { ItemStatus } from "../data";
2
2
  export declare const noticeFilters: {
3
3
  readonly id: {
4
4
  readonly type: "text";
@@ -27,3 +27,4 @@ export declare const noticeFilters: {
27
27
  readonly options: readonly [ItemStatus.Draft, ItemStatus.Scheduled, ItemStatus.Open, ItemStatus.Ended];
28
28
  };
29
29
  };
30
+ export type NoticeFilterName = keyof typeof noticeFilters;
@@ -1,4 +1,4 @@
1
- import { PaymentStatus } from "../data/index.ts";
1
+ import { PaymentStatus } from "../data";
2
2
  export declare const paymentFilters: {
3
3
  readonly id: {
4
4
  readonly type: "text";
@@ -17,3 +17,4 @@ export declare const paymentFilters: {
17
17
  readonly options: readonly [PaymentStatus.Successful, PaymentStatus.Pending, PaymentStatus.Failed, PaymentStatus.Cancelled];
18
18
  };
19
19
  };
20
+ export type PaymentFilterName = keyof typeof paymentFilters;
@@ -1,4 +1,6 @@
1
- import type { CalloutComponentSchema, CalloutFormSchema, CalloutResponseAnswer, CalloutResponseAnswerAddress, CalloutResponseAnswerFileUpload, FilterArgs } from "../types/index.ts";
1
+ import { CalloutComponentSchema, CalloutFormSchema, CalloutResponseAnswer } from "../data/callouts";
2
+ import { FilterArgs } from "../search";
3
+ import { CalloutResponseAnswerAddress, CalloutResponseAnswerFileUpload } from "../data/callouts";
2
4
  export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
3
5
  export declare function filterComponents(components: CalloutComponentSchema[], filterFn: (component: CalloutComponentSchema) => boolean): CalloutComponentSchema[];
4
6
  export declare function getCalloutComponents(formSchema: CalloutFormSchema): (CalloutComponentSchema & {
@@ -1,7 +1,7 @@
1
- import type { DateUnit, Duration } from "../types/index.ts";
2
- export declare const dateUnits: readonly ["s", "m", "h", "d", "M", "y"];
3
- export declare const dateUnitMap: Record<DateUnit, keyof Duration>;
1
+ declare const dateUnits: readonly ["s", "m", "h", "d", "M", "y"];
2
+ type DateUnit = (typeof dateUnits)[number];
4
3
  export declare function parseDate(value: string, now?: Date): [Date, DateUnit];
5
4
  export declare function getMinDateUnit(units: [DateUnit, ...DateUnit[]]): DateUnit;
6
5
  export declare function getMinDateUnit(units: DateUnit[]): DateUnit | undefined;
7
6
  export declare function isValidDate(s: string): boolean;
7
+ export {};
@@ -1,2 +1,8 @@
1
- import type { Feeable, StripeFeeCountry } from "../types/index.ts";
1
+ import { ContributionPeriod, PaymentMethod, StripeFeeCountry } from "../data";
2
+ interface Feeable {
3
+ amount: number;
4
+ period: ContributionPeriod;
5
+ paymentMethod: PaymentMethod;
6
+ }
2
7
  export declare function calcPaymentFee(feeable: Feeable, country: StripeFeeCountry): number;
8
+ export {};
@@ -1,4 +1,4 @@
1
- import type { Filters, Rule, RuleGroup, ValidatedRule, ValidatedRuleGroup } from "../types/index.ts";
1
+ import { Filters, Rule, RuleGroup, ValidatedRule, ValidatedRuleGroup } from "../search";
2
2
  export declare function isRuleGroup(ruleOrGroup: Rule | RuleGroup): ruleOrGroup is RuleGroup;
3
3
  export declare function validateRule<Field extends string>(filters: Filters<Field>, rule: Rule): ValidatedRule<Field>;
4
4
  export declare function validateRuleGroup<Field extends string>(filters: Filters<Field>, ruleGroup: RuleGroup): ValidatedRuleGroup<Field>;
package/package.json CHANGED
@@ -1,38 +1,16 @@
1
1
  {
2
2
  "name": "@beabee/beabee-common",
3
- "version": "1.19.7",
4
- "description": "Shared code between Beabee projects for Node.js, Deno and the browser",
5
- "type": "module",
6
- "main": "./dist/cjs/index.cjs",
3
+ "version": "1.19.8",
4
+ "description": "",
5
+ "main": "./dist/cjs/index.js",
7
6
  "module": "./dist/esm/index.js",
8
7
  "types": "./dist/types/index.d.ts",
9
8
  "files": [
10
9
  "dist/"
11
10
  ],
12
- "exports": {
13
- ".": {
14
- "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.cjs",
16
- "types": "./dist/types/index.d.ts"
17
- },
18
- "./package.json": "./package.json"
19
- },
20
11
  "scripts": {
21
- "test": "npm run test:types && npm run test:node",
22
- "test:deno": "deno task test",
23
- "test:node": "npm run test:node:esm && npm run test:node:cjs",
24
- "test:types": "tsc --noEmit --emitDeclarationOnly false",
25
- "test:node:esm": "node test/node/import.mjs",
26
- "test:node:cjs": "node test/node/require.cjs",
27
- "clear": "rimraf ./dist/",
28
- "build": "npm run clear && npm run generate:index && npm run sync:deps && npm run format && npm run build:types && npm run build:node",
29
- "build:node": "npm run build:node:esm && npm run build:node:cjs",
30
- "build:node:esm": "deno task build:node:esm",
31
- "build:node:cjs": "deno task build:node:cjs",
32
- "build:types": "tsc",
33
- "generate:index": "deno task generate:index",
34
- "sync:deps": "deno task sync:deps",
35
- "format": "deno task format",
12
+ "test": "jest",
13
+ "build": "rimraf ./dist/ && tsc -p tsconfig.build.esm.json && tsc -p tsconfig.build.cjs.json && tsc -p tsconfig.build.types.json",
36
14
  "prepublishOnly": "npm run build"
37
15
  },
38
16
  "repository": {
@@ -46,11 +24,14 @@
46
24
  },
47
25
  "homepage": "https://github.com/beabee-communityrm/beabee-common#readme",
48
26
  "devDependencies": {
49
- "@tsconfig/recommended": "^1.0.3",
50
- "rimraf": "^5.0.5",
51
- "typescript": "^5.3.3"
27
+ "@tsconfig/recommended": "^1.0.2",
28
+ "jest": "^29.3.1",
29
+ "prettier": "^2.8.3",
30
+ "rimraf": "^4.1.1",
31
+ "ts-jest": "^29.0.5",
32
+ "typescript": "^4.9.4"
52
33
  },
53
34
  "dependencies": {
54
- "date-fns": "^3.2.0"
35
+ "date-fns": "^2.29.3"
55
36
  }
56
37
  }
package/README.md DELETED
@@ -1,41 +0,0 @@
1
- # beabee-common
2
-
3
- Shared code between Beabee projects for Node.js, Deno and the browser.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @beabee/beabee-common --save
9
- ```
10
-
11
- ## Usage
12
-
13
- ### Node.js
14
-
15
- ```typescript
16
- import { parseDate } from "@beabee/beabee-common";
17
-
18
- parseDate("2022"); // [ 2021-12-31T23:00:00.000Z, 'y' ]
19
- ```
20
-
21
- ### Deno
22
-
23
- TODO: Publish to deno.land
24
-
25
- ## Development
26
-
27
- ### Requirements
28
-
29
- - Deno latest stable version
30
- - Node.js latest stable version
31
-
32
- ### Build
33
-
34
- ```bash
35
- npm install
36
- npm run build
37
- ```
38
-
39
- ## License
40
-
41
- Licensed under the [AGPL-3.0](./LICENSE) license.
@@ -1,87 +0,0 @@
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 data_exports = {};
20
- __export(data_exports, {
21
- ContributionPeriod: () => ContributionPeriod,
22
- ContributionType: () => ContributionType,
23
- ItemStatus: () => ItemStatus,
24
- MembershipStatus: () => MembershipStatus,
25
- NewsletterStatus: () => NewsletterStatus,
26
- PaymentMethod: () => PaymentMethod,
27
- PaymentStatus: () => PaymentStatus
28
- });
29
- module.exports = __toCommonJS(data_exports);
30
- var ContributionPeriod = /* @__PURE__ */ ((ContributionPeriod2) => {
31
- ContributionPeriod2["Monthly"] = "monthly";
32
- ContributionPeriod2["Annually"] = "annually";
33
- return ContributionPeriod2;
34
- })(ContributionPeriod || {});
35
- var ContributionType = /* @__PURE__ */ ((ContributionType2) => {
36
- ContributionType2["Automatic"] = "Automatic";
37
- ContributionType2["Manual"] = "Manual";
38
- ContributionType2["Gift"] = "Gift";
39
- ContributionType2["None"] = "None";
40
- return ContributionType2;
41
- })(ContributionType || {});
42
- var ItemStatus = /* @__PURE__ */ ((ItemStatus2) => {
43
- ItemStatus2["Draft"] = "draft";
44
- ItemStatus2["Scheduled"] = "scheduled";
45
- ItemStatus2["Open"] = "open";
46
- ItemStatus2["Ended"] = "ended";
47
- return ItemStatus2;
48
- })(ItemStatus || {});
49
- var MembershipStatus = /* @__PURE__ */ ((MembershipStatus2) => {
50
- MembershipStatus2["Active"] = "active";
51
- MembershipStatus2["Expiring"] = "expiring";
52
- MembershipStatus2["Expired"] = "expired";
53
- MembershipStatus2["None"] = "none";
54
- return MembershipStatus2;
55
- })(MembershipStatus || {});
56
- var NewsletterStatus = /* @__PURE__ */ ((NewsletterStatus2) => {
57
- NewsletterStatus2["Subscribed"] = "subscribed";
58
- NewsletterStatus2["Unsubscribed"] = "unsubscribed";
59
- NewsletterStatus2["Cleaned"] = "cleaned";
60
- NewsletterStatus2["Pending"] = "pending";
61
- NewsletterStatus2["None"] = "none";
62
- return NewsletterStatus2;
63
- })(NewsletterStatus || {});
64
- var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
65
- PaymentMethod2["StripeCard"] = "s_card";
66
- PaymentMethod2["StripeSEPA"] = "s_sepa";
67
- PaymentMethod2["StripeBACS"] = "s_bacs";
68
- PaymentMethod2["GoCardlessDirectDebit"] = "gc_direct-debit";
69
- return PaymentMethod2;
70
- })(PaymentMethod || {});
71
- var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
72
- PaymentStatus2["Pending"] = "pending";
73
- PaymentStatus2["Successful"] = "successful";
74
- PaymentStatus2["Failed"] = "failed";
75
- PaymentStatus2["Cancelled"] = "cancelled";
76
- return PaymentStatus2;
77
- })(PaymentStatus || {});
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- ContributionPeriod,
81
- ContributionType,
82
- ItemStatus,
83
- MembershipStatus,
84
- NewsletterStatus,
85
- PaymentMethod,
86
- PaymentStatus
87
- });
@@ -1,35 +0,0 @@
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 InvalidRule_exports = {};
20
- __export(InvalidRule_exports, {
21
- InvalidRule: () => InvalidRule
22
- });
23
- module.exports = __toCommonJS(InvalidRule_exports);
24
- class InvalidRule extends Error {
25
- constructor(rule, message) {
26
- super();
27
- this.rule = rule;
28
- this.message = message;
29
- Object.setPrototypeOf(this, InvalidRule.prototype);
30
- }
31
- }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- InvalidRule
35
- });
@@ -1,22 +0,0 @@
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 error_exports = {};
17
- module.exports = __toCommonJS(error_exports);
18
- __reExport(error_exports, require("./InvalidRule.cjs"), module.exports);
19
- // Annotate the CommonJS export names for ESM import in node:
20
- 0 && (module.exports = {
21
- ...require("./InvalidRule.cjs")
22
- });