@becollective/utils 2.0.14 → 2.0.16

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.
@@ -1,14 +1,9 @@
1
1
  version: v1.0
2
- name: @becollective/utils
2
+ name: "@becollective/utils"
3
3
  agent:
4
4
  machine:
5
5
  type: e1-standard-2
6
6
  os_image: ubuntu2404
7
- global_job_config:
8
- epilogue:
9
- always:
10
- commands:
11
- - '[[ -f packages/utils/test-results/report.xml ]] && test-results publish packages/utils/test-results/report.xml || true'
12
7
  blocks:
13
8
  - name: Test
14
9
  skip:
@@ -25,8 +20,16 @@ blocks:
25
20
  - name: Test
26
21
  commands:
27
22
  - cd ./packages/utils
23
+ - sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
24
+ - sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
28
25
  - npm ci
26
+ - echo "IPv4 $(curl -4 -s https://wtfismyip.com/text)"
27
+ - echo "IPv6 $(curl -6 -s https://wtfismyip.com/text || echo disabled)"
29
28
  - npm run citest
29
+ epilogue:
30
+ always:
31
+ commands:
32
+ - '[[ -f test-results/report.xml ]] && test-results publish test-results/report.xml || true'
30
33
  after_pipeline:
31
34
  task:
32
35
  jobs:
package/lib/date-time.js CHANGED
@@ -68,8 +68,11 @@ const getShiftText = (from, to, timezone) => {
68
68
  try {
69
69
  if (!from || !to || !timezone)
70
70
  return '';
71
- const startToTimezone = luxon_1.DateTime.fromJSDate(from).setZone(timezone);
72
- const endToTimezone = luxon_1.DateTime.fromJSDate(to).setZone(timezone);
71
+ // GraphQL / JSON often yield ISO strings; fromJSDate alone rejects those as Invalid.
72
+ const startToTimezone = luxon_1.DateTime.fromJSDate(new Date(from)).setZone(timezone);
73
+ const endToTimezone = luxon_1.DateTime.fromJSDate(new Date(to)).setZone(timezone);
74
+ if (!startToTimezone.isValid || !endToTimezone.isValid)
75
+ return '';
73
76
  return `${startToTimezone.toFormat('cccc, d MMMM yyyy, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
74
77
  }
75
78
  catch (e) {
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { password } from './password';
2
+ export { isUnderSixteen, isUnderAge, getAge, datesByThemselves, getShiftText } from './date-time';
3
+ export { getCurrencyFromCurrencyCode, makeMoneyString } from './money';
4
+ export { readableOpportunityType } from './opportunity';
5
+ export { getTimeInfo } from './opportunityUser';
6
+ export { getHomeLocalityFromLocationList } from './locality';
7
+ export { FeatureFlag } from './FeatureFlag';
package/lib/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeatureFlag = exports.getHomeLocalityFromLocationList = exports.getTimeInfo = exports.readableOpportunityType = exports.makeMoneyString = exports.getCurrencyFromCurrencyCode = exports.getShiftText = exports.datesByThemselves = exports.getAge = exports.isUnderAge = exports.isUnderSixteen = exports.password = void 0;
4
+ var password_1 = require("./password");
5
+ Object.defineProperty(exports, "password", { enumerable: true, get: function () { return password_1.password; } });
6
+ var date_time_1 = require("./date-time");
7
+ Object.defineProperty(exports, "isUnderSixteen", { enumerable: true, get: function () { return date_time_1.isUnderSixteen; } });
8
+ Object.defineProperty(exports, "isUnderAge", { enumerable: true, get: function () { return date_time_1.isUnderAge; } });
9
+ Object.defineProperty(exports, "getAge", { enumerable: true, get: function () { return date_time_1.getAge; } });
10
+ Object.defineProperty(exports, "datesByThemselves", { enumerable: true, get: function () { return date_time_1.datesByThemselves; } });
11
+ Object.defineProperty(exports, "getShiftText", { enumerable: true, get: function () { return date_time_1.getShiftText; } });
12
+ var money_1 = require("./money");
13
+ Object.defineProperty(exports, "getCurrencyFromCurrencyCode", { enumerable: true, get: function () { return money_1.getCurrencyFromCurrencyCode; } });
14
+ Object.defineProperty(exports, "makeMoneyString", { enumerable: true, get: function () { return money_1.makeMoneyString; } });
15
+ var opportunity_1 = require("./opportunity");
16
+ Object.defineProperty(exports, "readableOpportunityType", { enumerable: true, get: function () { return opportunity_1.readableOpportunityType; } });
17
+ var opportunityUser_1 = require("./opportunityUser");
18
+ Object.defineProperty(exports, "getTimeInfo", { enumerable: true, get: function () { return opportunityUser_1.getTimeInfo; } });
19
+ var locality_1 = require("./locality");
20
+ Object.defineProperty(exports, "getHomeLocalityFromLocationList", { enumerable: true, get: function () { return locality_1.getHomeLocalityFromLocationList; } });
21
+ var FeatureFlag_1 = require("./FeatureFlag");
22
+ Object.defineProperty(exports, "FeatureFlag", { enumerable: true, get: function () { return FeatureFlag_1.FeatureFlag; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "2.0.14",
3
+ "version": "2.0.16",
4
4
  "description": "Common utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/date-time.ts CHANGED
@@ -65,8 +65,10 @@ export const datesByThemselves = (a, b) => {
65
65
  export const getShiftText = (from, to, timezone) => {
66
66
  try {
67
67
  if (!from || !to || !timezone) return '';
68
- const startToTimezone = DateTime.fromJSDate(from).setZone(timezone);
69
- const endToTimezone = DateTime.fromJSDate(to).setZone(timezone);
68
+ // GraphQL / JSON often yield ISO strings; fromJSDate alone rejects those as Invalid.
69
+ const startToTimezone = DateTime.fromJSDate(new Date(from)).setZone(timezone);
70
+ const endToTimezone = DateTime.fromJSDate(new Date(to)).setZone(timezone);
71
+ if (!startToTimezone.isValid || !endToTimezone.isValid) return '';
70
72
  return `${startToTimezone.toFormat('cccc, d MMMM yyyy, h:mma')}-${endToTimezone.toFormat('h:mma')}`;
71
73
  }
72
74
  catch (e) {
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { password } from './password';
2
+ export { isUnderSixteen, isUnderAge, getAge, datesByThemselves, getShiftText } from './date-time';
3
+ export { getCurrencyFromCurrencyCode, makeMoneyString } from './money';
4
+ export { readableOpportunityType } from './opportunity';
5
+ export { getTimeInfo } from './opportunityUser';
6
+ export { getHomeLocalityFromLocationList } from './locality';
7
+ export { FeatureFlag } from './FeatureFlag';
@@ -150,6 +150,11 @@ describe('getShiftText', () => {
150
150
  test('get shift text with auckland timezone', () => {
151
151
  expect(getShiftText(from, to, auckland)).toBe('Thursday, 30 July 2020, 12:00PM-5:30PM');
152
152
  });
153
+ test('accepts ISO strings from GraphQL', () => {
154
+ expect(getShiftText(from.toISOString(), to.toISOString(), melbourne)).toBe(
155
+ 'Thursday, 30 July 2020, 10:00AM-3:30PM',
156
+ );
157
+ });
153
158
  // Will not execute due to TypeScript
154
159
  // test('with empty data', () => {
155
160
  // expect(getShiftText()).toBe('');
package/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export { password } from './src/password';
2
- export { isUnderSixteen, isUnderAge, getAge, datesByThemselves, getShiftText } from './src/date-time';
3
- export { getCurrencyFromCurrencyCode, makeMoneyString } from './src/money';
4
- export { readableOpportunityType } from './src/opportunity';
5
- export { getTimeInfo } from './src/opportunityUser';
6
- export { getHomeLocalityFromLocationList } from './src/locality';
7
- export { FeatureFlag } from './src/FeatureFlag';