@becollective/utils 2.0.12 → 2.0.14

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 (60) hide show
  1. package/.semaphore/utils.yml +13 -22
  2. package/jestconfig.json +12 -1
  3. package/lib/constants/allowedHtmlTags.d.ts +6 -2
  4. package/lib/constants/allowedHtmlTags.js +9 -5
  5. package/lib/constants/countries.d.ts +2 -2
  6. package/lib/constants/countries.js +3 -1
  7. package/lib/constants/customFields.d.ts +2 -2
  8. package/lib/constants/customFields.js +3 -1
  9. package/lib/constants/distancesUnits.d.ts +2 -2
  10. package/lib/constants/distancesUnits.js +13 -9
  11. package/lib/constants/groups.d.ts +12 -2
  12. package/lib/constants/groups.js +86 -81
  13. package/lib/constants/insuranceStatuses.d.ts +14 -2
  14. package/lib/constants/insuranceStatuses.js +9 -4
  15. package/lib/constants/insuranceTypes.d.ts +34 -2
  16. package/lib/constants/insuranceTypes.js +43 -33
  17. package/lib/constants/languages.d.ts +2 -2
  18. package/lib/constants/languages.js +3 -1
  19. package/lib/constants/qualificationTypes.d.ts +2 -2
  20. package/lib/constants/qualificationTypes.js +3 -2
  21. package/lib/constants/rules.d.ts +12 -2
  22. package/lib/constants/rules.js +7 -5
  23. package/lib/constants/surveys.d.ts +15 -2
  24. package/lib/constants/surveys.js +18 -14
  25. package/lib/date-time.js +1 -1
  26. package/lib/forms.d.ts +3 -0
  27. package/lib/forms.js +3 -0
  28. package/package.json +10 -1
  29. package/src/constants/allowedHtmlTags.ts +10 -5
  30. package/src/constants/countries.ts +3 -1
  31. package/src/constants/customFields.ts +3 -1
  32. package/src/constants/distancesUnits.ts +15 -9
  33. package/src/constants/groups.ts +89 -81
  34. package/src/constants/insuranceStatuses.ts +10 -4
  35. package/src/constants/insuranceTypes.ts +51 -33
  36. package/src/constants/languages.ts +3 -1
  37. package/src/constants/qualificationTypes.ts +2 -1
  38. package/src/constants/rules.ts +5 -3
  39. package/src/constants/surveys.ts +20 -14
  40. package/src/date-time.ts +1 -1
  41. package/src/forms.ts +3 -0
  42. package/tests/forms.test.ts +121 -1
  43. package/lib/rrule/parsing.test.d.ts +0 -1
  44. package/lib/rrule/parsing.test.js +0 -11
  45. package/lib/src/FeatureFlag.d.ts +0 -12
  46. package/lib/src/FeatureFlag.js +0 -51
  47. package/lib/src/date-time.d.ts +0 -28
  48. package/lib/src/date-time.js +0 -79
  49. package/lib/src/forms.d.ts +0 -1
  50. package/lib/src/forms.js +0 -728
  51. package/lib/src/locality.d.ts +0 -5
  52. package/lib/src/locality.js +0 -15
  53. package/lib/src/money.d.ts +0 -7
  54. package/lib/src/money.js +0 -32
  55. package/lib/src/opportunity.d.ts +0 -1
  56. package/lib/src/opportunity.js +0 -11
  57. package/lib/src/opportunityUser.d.ts +0 -8
  58. package/lib/src/opportunityUser.js +0 -29
  59. package/lib/src/password.d.ts +0 -8
  60. package/lib/src/password.js +0 -43
@@ -1,4 +1,17 @@
1
- declare const _default: {
1
+ export declare const participantStatuses: {
2
+ notSent: string;
3
+ sent: string;
4
+ reSent: string;
5
+ responded: string;
6
+ };
7
+ export declare const subscriptionDowngradeReasons: {
8
+ featureLack: string;
9
+ expense: string;
10
+ difficulty: string;
11
+ technicalIssues: string;
12
+ other: string;
13
+ };
14
+ export declare const surveys: {
2
15
  participantStatuses: {
3
16
  notSent: string;
4
17
  sent: string;
@@ -13,4 +26,4 @@ declare const _default: {
13
26
  other: string;
14
27
  };
15
28
  };
16
- export default _default;
29
+ export default surveys;
@@ -1,17 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- participantStatuses: {
5
- notSent: 'not-sent',
6
- sent: 'sent',
7
- reSent: 're-sent',
8
- responded: 'responded',
9
- },
10
- subscriptionDowngradeReasons: {
11
- featureLack: 'Features not useful / missing features we need',
12
- expense: 'Too expensive',
13
- difficulty: 'Difficult to use',
14
- technicalIssues: 'Technical issues',
15
- other: 'Other',
16
- },
3
+ exports.surveys = exports.subscriptionDowngradeReasons = exports.participantStatuses = void 0;
4
+ exports.participantStatuses = {
5
+ notSent: 'not-sent',
6
+ sent: 'sent',
7
+ reSent: 're-sent',
8
+ responded: 'responded',
17
9
  };
10
+ exports.subscriptionDowngradeReasons = {
11
+ featureLack: 'Features not useful / missing features we need',
12
+ expense: 'Too expensive',
13
+ difficulty: 'Difficult to use',
14
+ technicalIssues: 'Technical issues',
15
+ other: 'Other',
16
+ };
17
+ exports.surveys = {
18
+ participantStatuses: exports.participantStatuses,
19
+ subscriptionDowngradeReasons: exports.subscriptionDowngradeReasons,
20
+ };
21
+ exports.default = exports.surveys;
package/lib/date-time.js CHANGED
@@ -70,7 +70,7 @@ const getShiftText = (from, to, timezone) => {
70
70
  return '';
71
71
  const startToTimezone = luxon_1.DateTime.fromJSDate(from).setZone(timezone);
72
72
  const endToTimezone = luxon_1.DateTime.fromJSDate(to).setZone(timezone);
73
- return `${startToTimezone.toFormat('cccc, DD, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
73
+ return `${startToTimezone.toFormat('cccc, d MMMM yyyy, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
74
74
  }
75
75
  catch (e) {
76
76
  return '';
package/lib/forms.d.ts CHANGED
@@ -46,6 +46,9 @@ export declare const validator: {
46
46
  'ui:bc-multiSelect': {
47
47
  type: string;
48
48
  };
49
+ 'ui:bc-allowCustomAnswer': {
50
+ type: string;
51
+ };
49
52
  'ui:widget': {
50
53
  type: string;
51
54
  enum: string[];
package/lib/forms.js CHANGED
@@ -312,6 +312,9 @@ exports.validator = {
312
312
  'ui:bc-multiSelect': {
313
313
  type: 'boolean',
314
314
  },
315
+ 'ui:bc-allowCustomAnswer': {
316
+ type: 'boolean',
317
+ },
315
318
  'ui:widget': {
316
319
  type: 'string',
317
320
  enum: widgetTypes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "Common utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,17 +11,26 @@
11
11
  },
12
12
  "scripts": {
13
13
  "test": "npm run build && NODE_ENV=localtest jest --config jestconfig.json --detectOpenHandles --verbose --forceExit",
14
+ "citest": "npm run build && NODE_ENV=localtest jest --config jestconfig.json --detectOpenHandles --verbose --forceExit",
14
15
  "build": "tsc",
15
16
  "prepare": "npm run build"
16
17
  },
17
18
  "author": "",
18
19
  "license": "ISC",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/tickboxAU/becollective-npm.git"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
19
27
  "devDependencies": {
20
28
  "@types/jest": "^30.0.0",
21
29
  "@types/mongodb": "^4.0.7",
22
30
  "@types/node": "^25.6.0",
23
31
  "@types/pino": "^7.0.5",
24
32
  "jest": "^30.3.0",
33
+ "jest-junit": "^17.0.0",
25
34
  "prettier": "^3.8.3",
26
35
  "ts-jest": "^29.4.9",
27
36
  "tslint": "^6.1.3",
@@ -1,6 +1,11 @@
1
- export default {
2
- allowedTags: ['b', 'i', 'em', 'strong', 'a', 'p', 'u', 'del', 'div', 'ins', 'li', 'ul', 'ol', 'br'],
3
- allowedAttributes: {
4
- a: ['href', 'target', 'rel'],
5
- },
1
+ export const allowedTags = ['b', 'i', 'em', 'strong', 'a', 'p', 'u', 'del', 'div', 'ins', 'li', 'ul', 'ol', 'br'];
2
+ export const allowedAttributes = {
3
+ a: ['href', 'target', 'rel'],
6
4
  };
5
+
6
+ export const allowedHtmlTags = {
7
+ allowedTags,
8
+ allowedAttributes,
9
+ };
10
+
11
+ export default allowedHtmlTags;
@@ -1,4 +1,4 @@
1
- export default {
1
+ export const countries = {
2
2
  BD: 'Bangladesh',
3
3
  BE: 'Belgium',
4
4
  BF: 'Burkina Faso',
@@ -250,3 +250,5 @@ export default {
250
250
  QA: 'Qatar',
251
251
  MZ: 'Mozambique',
252
252
  };
253
+
254
+ export default countries;
@@ -1,4 +1,4 @@
1
- export default {
1
+ export const customFields = {
2
2
  maxMongoStringLength: 4096, // https://github.com/mongodb/mongo/blob/master/src/mongo/shell/linenoise.cpp#L145
3
3
  maxFileSizeBytes: 16000000, // 16 MB https://docs.mongodb.com/manual/reference/limits/
4
4
  emailReferenceHeadingString: 'Email (ref.)',
@@ -8,3 +8,5 @@ export default {
8
8
  maxNumberOfRows: 501, // 500 rows + headings row
9
9
  templateFileName: 'Custom_Fields_Template.csv', // should end in .csv
10
10
  };
11
+
12
+ export default customFields;
@@ -1,11 +1,17 @@
1
1
  // These align to https://www.elastic.co/guide/en/elasticsearch/reference/7.3/common-options.html#distance-units
2
- export default {
3
- km: {
4
- long: 'kilometers',
5
- short: 'km',
6
- },
7
- mi: {
8
- long: 'miles',
9
- short: 'mi',
10
- },
2
+ const km = {
3
+ long: 'kilometers',
4
+ short: 'km',
11
5
  };
6
+
7
+ const mi = {
8
+ long: 'miles',
9
+ short: 'mi',
10
+ };
11
+
12
+ export const distancesUnits = {
13
+ km,
14
+ mi,
15
+ }
16
+
17
+ export default distancesUnits;
@@ -1,83 +1,91 @@
1
- export default {
2
- maxNumberOfGroupMembers: 10000,
3
- defaultOptions: {
4
- details: [
5
- 'Phone Number',
6
- 'Gender',
7
- 'Date of Birth',
8
- 'Home Address',
9
- 'Current Job Title',
10
- 'Emergency Contact Details',
11
- ],
12
- requirements: [
13
- 'Working with Children Check',
14
- 'Drivers License',
15
- 'Police Check',
16
- 'First Aid Certificate',
17
- 'Orientation',
18
- 'Training',
19
- ],
20
- industries: [
21
- 'Accommodations',
22
- 'Accounting',
23
- 'Advertising',
24
- 'Aerospace',
25
- 'Agriculture & Agribusiness',
26
- 'Air Transportation',
27
- 'Apparel & Accessories',
28
- 'Auto',
29
- 'Banking',
30
- 'Beauty & Cosmetics',
31
- 'Biotechnology',
32
- 'Chemical',
33
- 'Communications',
34
- 'Computer',
35
- 'Construction',
36
- 'Consulting',
37
- 'Consumer Products',
38
- 'Education',
39
- 'Electronics',
40
- 'Employment',
41
- 'Energy',
42
- 'Entertainment & Recreation',
43
- 'Fashion',
44
- 'Financial Services',
45
- 'Food & Beverage',
46
- 'Health',
47
- 'Information',
48
- 'Information Technology',
49
- 'Insurance',
50
- 'Journalism & News',
51
- 'Legal Services',
52
- 'Manufacturing',
53
- 'Media & Broadcasting',
54
- 'Medical Devices & Supplies',
55
- 'Motion Pictures & Video',
56
- 'Music',
57
- 'Pharmaceutical',
58
- 'Public Administration',
59
- 'Public Relations',
60
- 'Publishing',
61
- 'Real Estate',
62
- 'Retail',
63
- 'Service',
64
- 'Sports',
65
- 'Technology',
66
- 'Telecommunications',
67
- 'Tourism',
68
- 'Transportation',
69
- 'Travel',
70
- 'Utilities',
71
- 'Video Game',
72
- 'Web Services',
73
- ],
74
- },
75
- groupTypes: [
76
- { name: 'Business', value: 'business' },
77
- { name: 'Charity/Not-for-profit', value: 'charity-not-for-profit' },
78
- { name: 'Club/Community group', value: 'club-community-group' },
79
- { name: 'Education provider', value: 'education-provider' },
80
- { name: 'Government/Public sector', value: 'government-public-sector' },
81
- { name: 'Volunteer services & centre', value: 'volunteer-service-centre' },
1
+ export const maxNumberOfGroupMembers = 10000;
2
+
3
+ export const defaultOptions = {
4
+ details: [
5
+ 'Phone Number',
6
+ 'Gender',
7
+ 'Date of Birth',
8
+ 'Home Address',
9
+ 'Current Job Title',
10
+ 'Emergency Contact Details',
82
11
  ],
12
+ requirements: [
13
+ 'Working with Children Check',
14
+ 'Drivers License',
15
+ 'Police Check',
16
+ 'First Aid Certificate',
17
+ 'Orientation',
18
+ 'Training',
19
+ ],
20
+ industries: [
21
+ 'Accommodations',
22
+ 'Accounting',
23
+ 'Advertising',
24
+ 'Aerospace',
25
+ 'Agriculture & Agribusiness',
26
+ 'Air Transportation',
27
+ 'Apparel & Accessories',
28
+ 'Auto',
29
+ 'Banking',
30
+ 'Beauty & Cosmetics',
31
+ 'Biotechnology',
32
+ 'Chemical',
33
+ 'Communications',
34
+ 'Computer',
35
+ 'Construction',
36
+ 'Consulting',
37
+ 'Consumer Products',
38
+ 'Education',
39
+ 'Electronics',
40
+ 'Employment',
41
+ 'Energy',
42
+ 'Entertainment & Recreation',
43
+ 'Fashion',
44
+ 'Financial Services',
45
+ 'Food & Beverage',
46
+ 'Health',
47
+ 'Information',
48
+ 'Information Technology',
49
+ 'Insurance',
50
+ 'Journalism & News',
51
+ 'Legal Services',
52
+ 'Manufacturing',
53
+ 'Media & Broadcasting',
54
+ 'Medical Devices & Supplies',
55
+ 'Motion Pictures & Video',
56
+ 'Music',
57
+ 'Pharmaceutical',
58
+ 'Public Administration',
59
+ 'Public Relations',
60
+ 'Publishing',
61
+ 'Real Estate',
62
+ 'Retail',
63
+ 'Service',
64
+ 'Sports',
65
+ 'Technology',
66
+ 'Telecommunications',
67
+ 'Tourism',
68
+ 'Transportation',
69
+ 'Travel',
70
+ 'Utilities',
71
+ 'Video Game',
72
+ 'Web Services',
73
+ ],
74
+ };
75
+
76
+ export const groupTypes = [
77
+ { name: 'Business', value: 'business' },
78
+ { name: 'Charity/Not-for-profit', value: 'charity-not-for-profit' },
79
+ { name: 'Club/Community group', value: 'club-community-group' },
80
+ { name: 'Education provider', value: 'education-provider' },
81
+ { name: 'Government/Public sector', value: 'government-public-sector' },
82
+ { name: 'Volunteer services & centre', value: 'volunteer-service-centre' },
83
+ ];
84
+
85
+ export const groups = {
86
+ maxNumberOfGroupMembers,
87
+ defaultOptions,
88
+ groupTypes,
83
89
  };
90
+
91
+ export default groups;
@@ -1,5 +1,11 @@
1
- export default {
2
- INSURED: { value: 'insured', label: 'We have insurance' },
3
- UNINSURED: { value: 'uninsured', label: "We don't have insurance" },
4
- AUSPICED: { value: 'auspiced', label: 'We are auspiced by another organisation' },
1
+ export const INSURED = { value: 'insured', label: 'We have insurance' };
2
+ export const UNINSURED = { value: 'uninsured', label: "We don't have insurance" };
3
+ export const AUSPICED = { value: 'auspiced', label: 'We are auspiced by another organisation' };
4
+
5
+ export const insuranceStatuses = {
6
+ INSURED,
7
+ UNINSURED,
8
+ AUSPICED,
5
9
  };
10
+
11
+ export default insuranceStatuses;
@@ -1,34 +1,52 @@
1
- export default {
2
- publicLiabilityAU: {
3
- type: 'publicLiabilityAU',
4
- label: 'Public Liability Insurance',
5
- },
6
- volunteerAccidentAU: {
7
- type: 'volunteerAccidentAU',
8
- label: 'Volunteer Accident Insurance',
9
- },
10
- publicLiabilityGB: {
11
- type: 'publicLiabilityGB',
12
- label: 'Public Liability',
13
- },
14
- volunteerAccidentGB: {
15
- type: 'volunteerAccidentGB',
16
- label: "Employer's Liability",
17
- },
18
- publicLiabilityNZ: {
19
- type: 'publicLiabilityNZ',
20
- label: 'Public Liability',
21
- },
22
- volunteerAccidentNZ: {
23
- type: 'volunteerAccidentNZ',
24
- label: "Employer's Liability",
25
- },
26
- publicLiabilityOthers: {
27
- type: 'publicLiabilityOthers',
28
- label: 'Public Liability',
29
- },
30
- volunteerAccidentOthers: {
31
- type: 'volunteerAccidentOthers',
32
- label: "Employer's Liability",
33
- },
1
+ export const publicLiabilityAU = {
2
+ type: 'publicLiabilityAU',
3
+ label: 'Public Liability Insurance',
34
4
  };
5
+
6
+ export const volunteerAccidentAU = {
7
+ type: 'volunteerAccidentAU',
8
+ label: 'Volunteer Accident Insurance',
9
+ };
10
+
11
+ export const publicLiabilityGB = {
12
+ type: 'publicLiabilityGB',
13
+ label: 'Public Liability',
14
+ };
15
+
16
+ export const volunteerAccidentGB = {
17
+ type: 'volunteerAccidentGB',
18
+ label: "Employer's Liability",
19
+ };
20
+
21
+ export const publicLiabilityNZ = {
22
+ type: 'publicLiabilityNZ',
23
+ label: 'Public Liability',
24
+ };
25
+
26
+ export const volunteerAccidentNZ = {
27
+ type: 'volunteerAccidentNZ',
28
+ label: "Employer's Liability",
29
+ };
30
+
31
+ export const publicLiabilityOthers = {
32
+ type: 'publicLiabilityOthers',
33
+ label: 'Public Liability',
34
+ };
35
+
36
+ export const volunteerAccidentOthers = {
37
+ type: 'volunteerAccidentOthers',
38
+ label: "Employer's Liability",
39
+ };
40
+
41
+ export const insuranceTypes = {
42
+ publicLiabilityAU,
43
+ volunteerAccidentAU,
44
+ publicLiabilityGB,
45
+ volunteerAccidentGB,
46
+ publicLiabilityNZ,
47
+ volunteerAccidentNZ,
48
+ publicLiabilityOthers,
49
+ volunteerAccidentOthers
50
+ };
51
+
52
+ export default insuranceTypes;
@@ -1,4 +1,4 @@
1
- export default [
1
+ export const languages = [
2
2
  'abkhaz',
3
3
  'afar',
4
4
  'afrikaans',
@@ -190,3 +190,5 @@ export default [
190
190
  'zhuang',
191
191
  'zulu',
192
192
  ];
193
+
194
+ export default languages;
@@ -14,4 +14,5 @@ export const educationalQualifications = [
14
14
  "Master's Degree / Postgraduate and above",
15
15
  ];
16
16
 
17
- export default [...licencesAndCertifications, ...educationalQualifications];
17
+ export const qualificationTypes = [...licencesAndCertifications, ...educationalQualifications];
18
+ export default qualificationTypes;
@@ -1,6 +1,6 @@
1
1
  import { RRule } from 'rrule';
2
2
 
3
- const daysOfTheWeek = [
3
+ export const daysOfTheWeek = [
4
4
  { label: 'Monday', value: RRule.MO, selected: false },
5
5
  { label: 'Tuesday', value: RRule.TU, selected: false },
6
6
  { label: 'Wednesday', value: RRule.WE, selected: false },
@@ -10,13 +10,15 @@ const daysOfTheWeek = [
10
10
  { label: 'Sunday', value: RRule.SU, selected: false },
11
11
  ];
12
12
 
13
- const frequencyOptions = [
13
+ export const frequencyOptions = [
14
14
  { value: 0, label: 'in total', description: '' },
15
15
  { value: RRule.WEEKLY, label: 'per week', description: 'each week' },
16
16
  { value: RRule.MONTHLY, label: 'per month', description: 'each month' },
17
17
  ];
18
18
 
19
- export default {
19
+ export const rules = {
20
20
  daysOfTheWeek,
21
21
  frequencyOptions,
22
22
  };
23
+
24
+ export default rules;
@@ -1,15 +1,21 @@
1
- export default {
2
- participantStatuses: {
3
- notSent: 'not-sent',
4
- sent: 'sent',
5
- reSent: 're-sent',
6
- responded: 'responded',
7
- },
8
- subscriptionDowngradeReasons: {
9
- featureLack: 'Features not useful / missing features we need',
10
- expense: 'Too expensive',
11
- difficulty: 'Difficult to use',
12
- technicalIssues: 'Technical issues',
13
- other: 'Other',
14
- },
1
+ export const participantStatuses = {
2
+ notSent: 'not-sent',
3
+ sent: 'sent',
4
+ reSent: 're-sent',
5
+ responded: 'responded',
15
6
  };
7
+
8
+ export const subscriptionDowngradeReasons = {
9
+ featureLack: 'Features not useful / missing features we need',
10
+ expense: 'Too expensive',
11
+ difficulty: 'Difficult to use',
12
+ technicalIssues: 'Technical issues',
13
+ other: 'Other',
14
+ };
15
+
16
+ export const surveys = {
17
+ participantStatuses,
18
+ subscriptionDowngradeReasons,
19
+ };
20
+
21
+ export default surveys;
package/src/date-time.ts CHANGED
@@ -67,7 +67,7 @@ export const getShiftText = (from, to, timezone) => {
67
67
  if (!from || !to || !timezone) return '';
68
68
  const startToTimezone = DateTime.fromJSDate(from).setZone(timezone);
69
69
  const endToTimezone = DateTime.fromJSDate(to).setZone(timezone);
70
- return `${startToTimezone.toFormat('cccc, DD, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
70
+ return `${startToTimezone.toFormat('cccc, d MMMM yyyy, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
71
71
  }
72
72
  catch (e) {
73
73
  return '';
package/src/forms.ts CHANGED
@@ -359,6 +359,9 @@ export const validator = {
359
359
  'ui:bc-multiSelect': {
360
360
  type: 'boolean',
361
361
  },
362
+ 'ui:bc-allowCustomAnswer': {
363
+ type: 'boolean',
364
+ },
362
365
  'ui:widget': {
363
366
  type: 'string',
364
367
  enum: widgetTypes,