@symbo.ls/sdk 2.34.24 → 2.34.29

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.
@@ -141,7 +141,7 @@ class PullRequestService extends import_BaseService.BaseService {
141
141
  }
142
142
  );
143
143
  if (response.success) {
144
- return response.data;
144
+ return response;
145
145
  }
146
146
  throw new Error(response.message);
147
147
  } catch (error) {
@@ -172,7 +172,7 @@ class PullRequestService extends import_BaseService.BaseService {
172
172
  }
173
173
  );
174
174
  if (response.success) {
175
- return response.data;
175
+ return response;
176
176
  }
177
177
  throw new Error(response.message);
178
178
  } catch (error) {
@@ -199,7 +199,7 @@ class PullRequestService extends import_BaseService.BaseService {
199
199
  }
200
200
  );
201
201
  if (response.success) {
202
- return response.data;
202
+ return response;
203
203
  }
204
204
  throw new Error(response.message);
205
205
  } catch (error) {
package/dist/esm/index.js CHANGED
@@ -48044,7 +48044,7 @@ var PullRequestService = class extends BaseService {
48044
48044
  }
48045
48045
  );
48046
48046
  if (response.success) {
48047
- return response.data;
48047
+ return response;
48048
48048
  }
48049
48049
  throw new Error(response.message);
48050
48050
  } catch (error) {
@@ -48075,7 +48075,7 @@ var PullRequestService = class extends BaseService {
48075
48075
  }
48076
48076
  );
48077
48077
  if (response.success) {
48078
- return response.data;
48078
+ return response;
48079
48079
  }
48080
48080
  throw new Error(response.message);
48081
48081
  } catch (error) {
@@ -48102,7 +48102,7 @@ var PullRequestService = class extends BaseService {
48102
48102
  }
48103
48103
  );
48104
48104
  if (response.success) {
48105
- return response.data;
48105
+ return response;
48106
48106
  }
48107
48107
  throw new Error(response.message);
48108
48108
  } catch (error) {
@@ -918,7 +918,7 @@ var PullRequestService = class extends BaseService {
918
918
  }
919
919
  );
920
920
  if (response.success) {
921
- return response.data;
921
+ return response;
922
922
  }
923
923
  throw new Error(response.message);
924
924
  } catch (error) {
@@ -949,7 +949,7 @@ var PullRequestService = class extends BaseService {
949
949
  }
950
950
  );
951
951
  if (response.success) {
952
- return response.data;
952
+ return response;
953
953
  }
954
954
  throw new Error(response.message);
955
955
  } catch (error) {
@@ -976,7 +976,7 @@ var PullRequestService = class extends BaseService {
976
976
  }
977
977
  );
978
978
  if (response.success) {
979
- return response.data;
979
+ return response;
980
980
  }
981
981
  throw new Error(response.message);
982
982
  } catch (error) {
@@ -48044,7 +48044,7 @@ var PullRequestService = class extends BaseService {
48044
48044
  }
48045
48045
  );
48046
48046
  if (response.success) {
48047
- return response.data;
48047
+ return response;
48048
48048
  }
48049
48049
  throw new Error(response.message);
48050
48050
  } catch (error) {
@@ -48075,7 +48075,7 @@ var PullRequestService = class extends BaseService {
48075
48075
  }
48076
48076
  );
48077
48077
  if (response.success) {
48078
- return response.data;
48078
+ return response;
48079
48079
  }
48080
48080
  throw new Error(response.message);
48081
48081
  } catch (error) {
@@ -48102,7 +48102,7 @@ var PullRequestService = class extends BaseService {
48102
48102
  }
48103
48103
  );
48104
48104
  if (response.success) {
48105
- return response.data;
48105
+ return response;
48106
48106
  }
48107
48107
  throw new Error(response.message);
48108
48108
  } catch (error) {
@@ -119,7 +119,7 @@ class PullRequestService extends BaseService {
119
119
  }
120
120
  );
121
121
  if (response.success) {
122
- return response.data;
122
+ return response;
123
123
  }
124
124
  throw new Error(response.message);
125
125
  } catch (error) {
@@ -150,7 +150,7 @@ class PullRequestService extends BaseService {
150
150
  }
151
151
  );
152
152
  if (response.success) {
153
- return response.data;
153
+ return response;
154
154
  }
155
155
  throw new Error(response.message);
156
156
  } catch (error) {
@@ -177,7 +177,7 @@ class PullRequestService extends BaseService {
177
177
  }
178
178
  );
179
179
  if (response.success) {
180
- return response.data;
180
+ return response;
181
181
  }
182
182
  throw new Error(response.message);
183
183
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/sdk",
3
- "version": "2.34.24",
3
+ "version": "2.34.29",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -47,12 +47,12 @@
47
47
  "test:unit-all": "cross-env NODE_ENV=$NODE_ENV npx tape src/services/tests/**/*.test.js | tap-spec"
48
48
  },
49
49
  "dependencies": {
50
- "@domql/element": "^2.34.24",
51
- "@domql/utils": "^2.34.24",
50
+ "@domql/element": "^2.34.29",
51
+ "@domql/utils": "^2.34.29",
52
52
  "@grafana/faro-web-sdk": "^1.19.0",
53
53
  "@grafana/faro-web-tracing": "^1.19.0",
54
- "@symbo.ls/router": "^2.34.24",
55
- "@symbo.ls/socket": "^2.34.24",
54
+ "@symbo.ls/router": "^2.34.29",
55
+ "@symbo.ls/socket": "^2.34.29",
56
56
  "acorn": "^8.14.0",
57
57
  "acorn-walk": "^8.3.4",
58
58
  "dexie": "^4.0.11",
@@ -75,5 +75,5 @@
75
75
  "tap-spec": "^5.0.0",
76
76
  "tape": "^5.9.0"
77
77
  },
78
- "gitHead": "4886a866c3adef97083fc36e3e4db40c1543054d"
78
+ "gitHead": "90cb8b61065249122ff356c3ea6eb56191c49bfa"
79
79
  }
@@ -136,7 +136,7 @@ export class PullRequestService extends BaseService {
136
136
  }
137
137
  )
138
138
  if (response.success) {
139
- return response.data
139
+ return response
140
140
  }
141
141
  throw new Error(response.message)
142
142
  } catch (error) {
@@ -169,7 +169,7 @@ export class PullRequestService extends BaseService {
169
169
  }
170
170
  )
171
171
  if (response.success) {
172
- return response.data
172
+ return response
173
173
  }
174
174
  throw new Error(response.message)
175
175
  } catch (error) {
@@ -199,7 +199,7 @@ export class PullRequestService extends BaseService {
199
199
  )
200
200
 
201
201
  if (response.success) {
202
- return response.data
202
+ return response
203
203
  }
204
204
  throw new Error(response.message)
205
205
  } catch (error) {
@@ -34,6 +34,29 @@ test('mergeBranch should return response data', async (t) => {
34
34
  t.end()
35
35
  })
36
36
 
37
+ test('mergeBranch should handle error', async (t) => {
38
+ t.plan(1)
39
+ const branchDataMock = {
40
+ name: 'Test_Branch_Name'
41
+ }
42
+ const testProjectId = 'Test Project ID'
43
+ const branchServiceStub = new BranchService()
44
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
45
+ sandbox.stub(branchServiceStub, '_request').throws('Test Error')
46
+ try {
47
+ await branchServiceStub.mergeBranch(testProjectId, branchDataMock.name)
48
+ t.fail('mergeBranch successfully failed')
49
+ } catch (err) {
50
+ t.equal(
51
+ err.toString(),
52
+ 'Error: Failed to merge branch: Sinon-provided Test Error',
53
+ 'Actual error matches expected error'
54
+ )
55
+ }
56
+ sandbox.restore()
57
+ t.end()
58
+ })
59
+
37
60
  function checkProjectIdValidation () {
38
61
  const badData = [
39
62
  {
@@ -135,8 +158,48 @@ function checkBranchDataNameValidation () {
135
158
  }
136
159
  }
137
160
 
161
+ function checkMergeConflictErrorHandling () {
162
+ const mergeError = [
163
+ {
164
+ name: 'merge conflict error',
165
+ value: 'conflicts',
166
+ expectedError: 'Error: Merge conflicts detected: Sinon-provided conflicts'
167
+ },
168
+ {
169
+ name: '409 Conflict client error',
170
+ value: '409',
171
+ expectedError: 'Error: Merge conflicts detected: Sinon-provided 409'
172
+ }
173
+ ]
174
+ for (let ii = 0; ii < mergeError.length; ii++) {
175
+ test(`mergeBranch should handle ${mergeError[ii].name}`, async (t) => {
176
+ t.plan(1)
177
+ const branchDataMock = {
178
+ name: 'Test_Branch_Name'
179
+ }
180
+ const testProjectId = 'Test Project ID'
181
+ const branchServiceStub = new BranchService()
182
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
183
+ sandbox.stub(branchServiceStub, '_request').throws(mergeError[ii].value)
184
+ try {
185
+ await branchServiceStub.mergeBranch(testProjectId, branchDataMock.name)
186
+ t.fail('mergeBranch successfully failed')
187
+ } catch (err) {
188
+ t.equal(
189
+ err.toString(),
190
+ mergeError[ii].expectedError,
191
+ 'Actual error matches expected error'
192
+ )
193
+ }
194
+ sandbox.restore()
195
+ t.end()
196
+ })
197
+ }
198
+ }
199
+
138
200
  checkBranchDataNameValidation()
139
201
  checkProjectIdValidation()
202
+ checkMergeConflictErrorHandling()
140
203
  // #endregion
141
204
 
142
205
  // #region Cleanup
@@ -0,0 +1,183 @@
1
+ /* eslint-disable no-undefined */
2
+ import test from 'tape'
3
+ import sinon from 'sinon'
4
+ import { BranchService } from '../../BranchService.js'
5
+
6
+ // #region Setup
7
+ const sandbox = sinon.createSandbox()
8
+ // #endregion
9
+
10
+ // #region Tests
11
+ test('publishVersion should return response data', async (t) => {
12
+ t.plan(1)
13
+ const responseStub = {
14
+ success: true,
15
+ data: 'Test data response'
16
+ }
17
+ const publishVersionMock = {
18
+ name: 'Test_Branch_Name',
19
+ version: '1.0.0',
20
+ branch: 'main'
21
+ }
22
+ const testProjectId = 'Test Project ID'
23
+ const branchServiceStub = new BranchService()
24
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
25
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
26
+ const response = await branchServiceStub.publishVersion(
27
+ testProjectId,
28
+ publishVersionMock
29
+ )
30
+ t.equal(
31
+ response,
32
+ responseStub.data,
33
+ 'Actual response matches expected response'
34
+ )
35
+ sandbox.restore()
36
+ t.end()
37
+ })
38
+
39
+ test('publishVersion should return response data', async (t) => {
40
+ t.plan(1)
41
+ const publishVersionMock = {
42
+ name: 'Test_Branch_Name',
43
+ version: '1.0.0',
44
+ branch: 'main'
45
+ }
46
+ const testProjectId = 'Test Project ID'
47
+ const branchServiceStub = new BranchService()
48
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
49
+ sandbox.stub(branchServiceStub, '_request').throws('Test Error')
50
+ try {
51
+ await branchServiceStub.publishVersion(testProjectId, publishVersionMock)
52
+ t.fail('publish version threw an error')
53
+ } catch (err) {
54
+ t.equal(
55
+ err.toString(),
56
+ 'Error: Failed to publish version: Sinon-provided Test Error',
57
+ 'Actual error matches expected error'
58
+ )
59
+ }
60
+ sandbox.restore()
61
+ t.end()
62
+ })
63
+
64
+ function checkProjectIdValidation () {
65
+ const badData = [
66
+ {
67
+ testName: 'No Project ID'
68
+ },
69
+ {
70
+ testName: 'Empty string',
71
+ projectId: ''
72
+ },
73
+ {
74
+ testName: 'False boolean value',
75
+ projectId: false
76
+ },
77
+ {
78
+ testName: 'Undefined value',
79
+ projectId: undefined
80
+ },
81
+ {
82
+ testName: 'Null value',
83
+ projectId: null
84
+ }
85
+ ]
86
+ for (let ii = 0; ii < badData.length; ii++) {
87
+ test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
88
+ t.plan(1)
89
+ const responseStub = {
90
+ success: true,
91
+ data: 'Test data response'
92
+ }
93
+ const publishVersionMock = {
94
+ name: 'Test_Branch_Name',
95
+ version: '1.0.0',
96
+ branch: 'main'
97
+ }
98
+ const testProjectId = badData[ii].projectId
99
+ const branchServiceStub = new BranchService()
100
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
101
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
102
+ try {
103
+ await branchServiceStub.publishVersion(
104
+ testProjectId,
105
+ publishVersionMock
106
+ )
107
+ t.fail('Project ID validation threw an error with an invalid value')
108
+ } catch (err) {
109
+ t.equal(
110
+ err.toString(),
111
+ 'Error: Project ID is required',
112
+ `Project ID validation successfully threw an error with: ${badData[ii].testName}`
113
+ )
114
+ }
115
+ sandbox.restore()
116
+ t.end()
117
+ })
118
+ }
119
+ }
120
+
121
+ function checkBranchDataNameValidation () {
122
+ const badData = [
123
+ {
124
+ testName: 'No name',
125
+ branch: 'main'
126
+ },
127
+ {
128
+ testName: 'Empty string',
129
+ version: '',
130
+ branch: 'main'
131
+ },
132
+ {
133
+ testName: 'False boolean value',
134
+ version: false,
135
+ branch: 'main'
136
+ },
137
+ {
138
+ testName: 'Undefined value',
139
+ version: undefined,
140
+ branch: 'main'
141
+ },
142
+ {
143
+ testName: 'Null value',
144
+ version: null,
145
+ branch: 'main'
146
+ }
147
+ ]
148
+ for (let ii = 0; ii < badData.length; ii++) {
149
+ test(`publishData version validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
150
+ t.plan(1)
151
+ const responseStub = {
152
+ success: true,
153
+ data: 'Test data response'
154
+ }
155
+ const testProjectId = 'Test Project ID'
156
+ const branchServiceStub = new BranchService()
157
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
158
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
159
+ try {
160
+ await branchServiceStub.publishVersion(testProjectId, badData[ii])
161
+ t.fail('Branch name validation threw an error with an invalid value')
162
+ } catch (err) {
163
+ t.equal(
164
+ err.toString(),
165
+ 'Error: Version is required',
166
+ `publishData version validation successfully threw an error with: ${badData[ii].testName}`
167
+ )
168
+ }
169
+ sandbox.restore()
170
+ t.end()
171
+ })
172
+ }
173
+ }
174
+ checkBranchDataNameValidation()
175
+ checkProjectIdValidation()
176
+ // #endregion
177
+
178
+ // #region Cleanup
179
+ test('teardown', (t) => {
180
+ sandbox.restore()
181
+ t.end()
182
+ })
183
+ // #endregion
@@ -0,0 +1,152 @@
1
+ /* eslint-disable no-undefined */
2
+ import test from 'tape'
3
+ import sinon from 'sinon'
4
+ import { BranchService } from '../../BranchService.js'
5
+
6
+ // #region Setup
7
+ const sandbox = sinon.createSandbox()
8
+ // #endregion
9
+
10
+ // #region Tests
11
+ test('resetBranch should return response data', async (t) => {
12
+ t.plan(1)
13
+ const responseStub = {
14
+ success: true,
15
+ data: 'Test data response'
16
+ }
17
+ const branchDataMock = {
18
+ name: 'Test_Branch_Name',
19
+ branchName: 'main'
20
+ }
21
+ const testProjectId = 'Test Project ID'
22
+ const branchServiceStub = new BranchService()
23
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
24
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
25
+ const response = await branchServiceStub.resetBranch(
26
+ testProjectId,
27
+ branchDataMock.branchName
28
+ )
29
+ t.equal(
30
+ response,
31
+ responseStub.data,
32
+ 'Actual response matches expected response'
33
+ )
34
+ sandbox.restore()
35
+ t.end()
36
+ })
37
+
38
+ function checkProjectIdValidation () {
39
+ const badData = [
40
+ {
41
+ testName: 'No Project ID'
42
+ },
43
+ {
44
+ testName: 'Empty string',
45
+ projectId: ''
46
+ },
47
+ {
48
+ testName: 'False boolean value',
49
+ projectId: false
50
+ },
51
+ {
52
+ testName: 'Undefined value',
53
+ projectId: undefined
54
+ },
55
+ {
56
+ testName: 'Null value',
57
+ projectId: null
58
+ }
59
+ ]
60
+ for (let ii = 0; ii < badData.length; ii++) {
61
+ test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
62
+ t.plan(1)
63
+ const responseStub = {
64
+ success: true,
65
+ data: 'Test data response'
66
+ }
67
+ const branchDataMock = {
68
+ name: 'Test_Branch_Name',
69
+ branchName: 'main'
70
+ }
71
+ const testProjectId = badData[ii].projectId
72
+ const branchServiceStub = new BranchService()
73
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
74
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
75
+ try {
76
+ await branchServiceStub.resetBranch(testProjectId, branchDataMock)
77
+ t.fail('Project ID validation threw an error with an invalid value')
78
+ } catch (err) {
79
+ t.equal(
80
+ err.toString(),
81
+ 'Error: Project ID is required',
82
+ `Project ID validation successfully threw an error with: ${badData[ii].testName}`
83
+ )
84
+ }
85
+ sandbox.restore()
86
+ t.end()
87
+ })
88
+ }
89
+ }
90
+
91
+ function checkBranchDataNameValidation () {
92
+ const badData = [
93
+ {
94
+ testName: 'No name'
95
+ },
96
+ {
97
+ testName: 'Empty string',
98
+ branchName: ''
99
+ },
100
+ {
101
+ testName: 'False boolean value',
102
+ branchName: false
103
+ },
104
+ {
105
+ testName: 'Undefined value',
106
+ branchName: undefined
107
+ },
108
+ {
109
+ testName: 'Null value',
110
+ branchName: null
111
+ }
112
+ ]
113
+ for (let ii = 0; ii < badData.length; ii++) {
114
+ test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
115
+ t.plan(1)
116
+ const responseStub = {
117
+ success: true,
118
+ data: 'Test data response'
119
+ }
120
+ const testProjectId = 'Test Project ID'
121
+ const branchServiceStub = new BranchService()
122
+ sandbox.stub(branchServiceStub, '_requireReady').resolves()
123
+ sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
124
+ try {
125
+ await branchServiceStub.resetBranch(
126
+ testProjectId,
127
+ badData[ii].branchName
128
+ )
129
+ t.fail('Branch name validation threw an error with an invalid value')
130
+ } catch (err) {
131
+ t.equal(
132
+ err.toString(),
133
+ 'Error: Branch name is required',
134
+ `Branch name validation successfully threw an error with: ${badData[ii].testName}`
135
+ )
136
+ }
137
+ sandbox.restore()
138
+ t.end()
139
+ })
140
+ }
141
+ }
142
+
143
+ checkBranchDataNameValidation()
144
+ checkProjectIdValidation()
145
+ // #endregion
146
+
147
+ // #region Cleanup
148
+ test('teardown', (t) => {
149
+ sandbox.restore()
150
+ t.end()
151
+ })
152
+ // #endregion