ti2-tourplan 1.0.113 → 1.0.116-beta.0

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,7 +1,6 @@
1
1
  name: Node.js Package
2
2
 
3
3
  on:
4
- workflow_dispatch:
5
4
  push:
6
5
 
7
6
  jobs:
@@ -20,23 +19,45 @@ jobs:
20
19
  ti2_tourplan_endpoint: ${{ secrets.TOURPLAN_ENDPOINT }}
21
20
  ti2_tourplan_username: ${{ secrets.TOURPLAN_USERNAME }}
22
21
  ti2_tourplan_password: ${{ secrets.TOURPLAN_PASSWORD }}
23
- tag:
24
- if: github.ref == 'refs/heads/main'
22
+ publish-npm:
23
+ if: startsWith(github.ref, 'refs/tags/v')
25
24
  needs: build_and_test
26
25
  runs-on: ubuntu-latest
27
26
  steps:
28
27
  - uses: actions/checkout@v2
29
- - uses: tool3/bump@master
30
- with:
31
- github_token: ${{ secrets.GITHUB_TOKEN }}
32
- unrelated: true
33
- branch: main
34
- publish-npm:
35
- if: github.ref == 'refs/heads/main'
36
- needs: tag
37
- runs-on: ubuntu-latest
38
- steps:
39
- - uses: actions/checkout@v1
40
- - uses: JS-DevTools/npm-publish@v1
28
+ - uses: actions/setup-node@v1
41
29
  with:
42
- token: ${{ secrets.NPM_TOKEN }}
30
+ node-version: 12
31
+ - name: Validate release tag
32
+ id: release_meta
33
+ env:
34
+ TAG_NAME: ${{ github.ref_name }}
35
+ run: |
36
+ set -euo pipefail
37
+
38
+ if [[ ! "$TAG_NAME" =~ ^v([0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?)$ ]]; then
39
+ echo "Unsupported release tag format: $TAG_NAME"
40
+ exit 1
41
+ fi
42
+
43
+ TAG_VERSION="${BASH_REMATCH[1]}"
44
+ PACKAGE_VERSION="$(node -p "require('./package.json').version")"
45
+
46
+ if [[ "$TAG_VERSION" != "$PACKAGE_VERSION" ]]; then
47
+ echo "Tag version ${TAG_VERSION} does not match package.json version ${PACKAGE_VERSION}"
48
+ exit 1
49
+ fi
50
+
51
+ DIST_TAG="latest"
52
+ if [[ "$TAG_VERSION" == *-beta.* ]]; then
53
+ DIST_TAG="beta"
54
+ fi
55
+
56
+ echo "tag_version=${TAG_VERSION}" >> "$GITHUB_OUTPUT"
57
+ echo "dist_tag=${DIST_TAG}" >> "$GITHUB_OUTPUT"
58
+ - name: Configure npm auth
59
+ run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
60
+ env:
61
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62
+ - name: Publish package
63
+ run: npm publish --tag "${{ steps.release_meta.outputs.dist_tag }}"
package/index.js CHANGED
@@ -25,6 +25,7 @@ const defaultXmlOptions = {
25
25
  name: 'tourConnect_4_00_000.dtd',
26
26
  },
27
27
  };
28
+ const urlRegExp = /^(?!mailto:)(?:(?:http|https|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))|localhost)(?::\d{2,5})?(?:(\/|\?|#)[^\s]*)?$/i;
28
29
  const getHeaders = ({ length }) => ({
29
30
  Accept: 'application/xml',
30
31
  'Content-Type': 'application/xml; charset=utf-8',
@@ -39,20 +40,18 @@ class BuyerPlugin {
39
40
  this.tokenTemplate = () => ({
40
41
  endpoint: {
41
42
  type: 'text',
42
- regExp: /^(?!mailto:)(?:(?:http|https|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))|localhost)(?::\d{2,5})?(?:(\/|\?|#)[^\s]*)?$/i,
43
+ regExp: urlRegExp,
43
44
  description: 'The uri for the tourplan adapter',
44
45
  },
45
46
  username: {
46
47
  type: 'text',
47
48
  regExp: /.+/,
48
49
  description: 'The tourplan provided username',
49
- default: 'en',
50
50
  },
51
51
  password: {
52
52
  type: 'text',
53
53
  regExp: /.+/,
54
54
  description: 'The tourplan provided password',
55
- default: 'en',
56
55
  },
57
56
  hostConnectEndpoint: {
58
57
  type: 'text',
@@ -66,6 +65,11 @@ class BuyerPlugin {
66
65
  type: 'text',
67
66
  regExp: /.+/,
68
67
  },
68
+ hostConnectBookingLinkBaseUrl: {
69
+ type: 'text',
70
+ regExp: urlRegExp,
71
+ description: 'The HostConnect booking page url used by the add-in to build booking reference links',
72
+ },
69
73
  productConnectEndpoint: {
70
74
  type: 'text',
71
75
  regExp: /.+/,
@@ -418,6 +422,8 @@ class BuyerPlugin {
418
422
  return true;
419
423
  }
420
424
 
425
+ assert(username, 'Must provide token.username for authentication');
426
+ assert(password, 'Must provide token.password for authentication');
421
427
  const model = {
422
428
  AuthenticationRequest: {
423
429
  Login: username,
@@ -439,9 +445,9 @@ class BuyerPlugin {
439
445
  async queryAllotment({
440
446
  axios,
441
447
  token: {
442
- endpoint = this.endpoint,
443
- username = this.username,
444
- password = this.password,
448
+ endpoint,
449
+ username,
450
+ password,
445
451
  },
446
452
  payload: {
447
453
  dateFormat = 'DD/MM/YYYY',
@@ -456,6 +462,8 @@ class BuyerPlugin {
456
462
  (inputString || '').toString()
457
463
  .replaceAll(username, '****').replaceAll(password, '****');
458
464
  assert(endpoint);
465
+ assert(username, 'Must provide token.username for allotment API');
466
+ assert(password, 'Must provide token.password for allotment API');
459
467
  assert(startDate);
460
468
  assert(endDate);
461
469
  assert(keyPath, 'Must provide a supplier/product spec');
package/index.test.js CHANGED
@@ -104,6 +104,7 @@ describe('search tests', () => {
104
104
  hostConnectEndpoint: 'https://test_hostConnectEndpoint.com',
105
105
  hostConnectAgentID: 'test_hostConnectAgentID',
106
106
  hostConnectAgentPassword: 'test_hostConnectAgentPassword',
107
+ hostConnectBookingLinkBaseUrl: 'https://example.tourplan.net/TourplanNX_Test/#/fastbook',
107
108
  seeAvailabilityRateInSupplierCurrency: 'Y',
108
109
  };
109
110
  const dateFormat = 'DD/MM/YYYY';
@@ -134,6 +135,7 @@ describe('search tests', () => {
134
135
  expect(rules).toContain('endpoint');
135
136
  expect(rules).toContain('password');
136
137
  expect(rules).toContain('username');
138
+ expect(rules).toContain('hostConnectBookingLinkBaseUrl');
137
139
  });
138
140
  it('username', () => {
139
141
  const username = template.username.regExp;
@@ -150,6 +152,13 @@ describe('search tests', () => {
150
152
  expect(password.test('')).toBeFalsy();
151
153
  expect(password.test('somepassword')).toBeTruthy();
152
154
  });
155
+ it('hostConnectBookingLinkBaseUrl', () => {
156
+ const hostConnectBookingLinkBaseUrl = template.hostConnectBookingLinkBaseUrl.regExp;
157
+ expect(hostConnectBookingLinkBaseUrl.test('something')).toBeFalsy();
158
+ expect(hostConnectBookingLinkBaseUrl.test(
159
+ 'https://example.tourplan.net/TourplanNX_Test/#/fastbook'
160
+ )).toBeTruthy();
161
+ });
153
162
  });
154
163
  describe('DTD version detection', () => {
155
164
  it('should detect and use correct DTD version from error response', async () => {
package/normalizer.js CHANGED
@@ -63,7 +63,7 @@ const normalizeDate = date => {
63
63
  return [year, month, day].join('-');
64
64
  };
65
65
 
66
- const getConsectuiveDays = days => {
66
+ const getConsecutiveDays = days => {
67
67
  const dayNumbers = _.map(days, mapDaysToNumbers).sort();
68
68
  let firstDay;
69
69
  let lastDay;
@@ -121,7 +121,7 @@ module.exports = {
121
121
  if (days.length === 7) return 'Everyday';
122
122
  if (days.length === 1) return `${days[0]} Only`;
123
123
 
124
- consecutiveDays = getConsectuiveDays(days);
124
+ consecutiveDays = getConsecutiveDays(days);
125
125
  return consecutiveDays || days.join(', ');
126
126
  }
127
127
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.113",
3
+ "version": "1.0.116-beta.0",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,8 @@
21
21
  "coveragePathIgnorePatterns": [
22
22
  "/node_modules/"
23
23
  ],
24
- "setupFiles": [
25
- "./jest.timezone.js"
24
+ "setupFiles": [
25
+ "./jest.timezone.js"
26
26
  ],
27
27
  "setupFilesAfterEnv": [
28
28
  "./jest.setup.js"