ti2-tourplan 1.0.115 → 1.0.117

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,7 +40,7 @@ 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: {
@@ -64,6 +65,11 @@ class BuyerPlugin {
64
65
  type: 'text',
65
66
  regExp: /.+/,
66
67
  },
68
+ hostConnectBookingLinkBaseUrl: {
69
+ type: 'text',
70
+ regExp: urlRegExp,
71
+ description: 'The HostConnect base url used by the add-in to build FastBook booking reference links',
72
+ },
67
73
  productConnectEndpoint: {
68
74
  type: 'text',
69
75
  regExp: /.+/,
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',
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'
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.115",
3
+ "version": "1.0.117",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {