@symbo.ls/sdk 2.34.35 → 3.1.2

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 (187) hide show
  1. package/README.md +2 -143
  2. package/dist/cjs/config/environment.js +30 -98
  3. package/dist/cjs/index.js +24 -144
  4. package/dist/cjs/services/AIService.js +155 -0
  5. package/dist/cjs/services/AuthService.js +305 -738
  6. package/dist/cjs/services/BaseService.js +6 -158
  7. package/dist/cjs/services/BasedService.js +1185 -0
  8. package/dist/cjs/services/CoreService.js +1751 -0
  9. package/dist/cjs/services/SocketIOService.js +307 -0
  10. package/dist/cjs/services/SocketService.js +161 -0
  11. package/dist/cjs/services/SymstoryService.js +571 -0
  12. package/dist/cjs/services/index.js +16 -64
  13. package/dist/cjs/utils/TokenManager.js +30 -78
  14. package/dist/cjs/utils/basedQuerys.js +181 -0
  15. package/dist/cjs/utils/services.js +103 -301
  16. package/dist/cjs/utils/symstoryClient.js +259 -0
  17. package/dist/cjs/utils/validation.js +3 -0
  18. package/dist/esm/config/environment.js +30 -98
  19. package/dist/esm/index.js +8797 -49416
  20. package/dist/esm/services/AIService.js +185 -0
  21. package/dist/esm/services/AuthService.js +386 -1493
  22. package/dist/esm/services/BaseService.js +6 -757
  23. package/dist/esm/services/BasedService.js +5278 -0
  24. package/dist/esm/services/CoreService.js +2264 -0
  25. package/dist/esm/services/SocketIOService.js +470 -0
  26. package/dist/esm/services/SocketService.js +191 -0
  27. package/dist/esm/services/SymstoryService.js +7041 -0
  28. package/dist/esm/services/index.js +8690 -49015
  29. package/dist/esm/utils/TokenManager.js +30 -78
  30. package/dist/esm/utils/basedQuerys.js +163 -0
  31. package/dist/esm/utils/services.js +103 -301
  32. package/dist/esm/utils/symstoryClient.js +370 -0
  33. package/dist/esm/utils/validation.js +7 -4
  34. package/dist/node/config/environment.js +30 -98
  35. package/dist/node/index.js +32 -175
  36. package/dist/node/services/AIService.js +136 -0
  37. package/dist/node/services/AuthService.js +310 -742
  38. package/dist/node/services/BaseService.js +6 -148
  39. package/dist/node/services/BasedService.js +1156 -0
  40. package/dist/node/services/CoreService.js +1722 -0
  41. package/dist/node/services/SocketIOService.js +278 -0
  42. package/dist/node/services/SocketService.js +142 -0
  43. package/dist/node/services/SymstoryService.js +542 -0
  44. package/dist/node/services/index.js +16 -64
  45. package/dist/node/utils/TokenManager.js +30 -78
  46. package/dist/node/utils/basedQuerys.js +162 -0
  47. package/dist/node/utils/services.js +103 -301
  48. package/dist/node/utils/symstoryClient.js +230 -0
  49. package/dist/node/utils/validation.js +3 -0
  50. package/package.json +16 -35
  51. package/src/config/environment.js +28 -99
  52. package/src/index.js +36 -181
  53. package/src/services/AIService.js +150 -0
  54. package/src/services/AuthService.js +328 -874
  55. package/src/services/BaseService.js +6 -166
  56. package/src/services/BasedService.js +1301 -0
  57. package/src/services/CoreService.js +1943 -0
  58. package/src/services/SocketIOService.js +334 -0
  59. package/src/services/SocketService.js +168 -0
  60. package/src/services/SymstoryService.js +649 -0
  61. package/src/services/index.js +13 -80
  62. package/src/utils/TokenManager.js +33 -88
  63. package/src/utils/basedQuerys.js +164 -0
  64. package/src/utils/services.js +107 -326
  65. package/src/utils/symstoryClient.js +252 -0
  66. package/src/utils/validation.js +3 -0
  67. package/dist/cjs/services/AdminService.js +0 -351
  68. package/dist/cjs/services/BranchService.js +0 -484
  69. package/dist/cjs/services/CollabService.js +0 -743
  70. package/dist/cjs/services/DnsService.js +0 -340
  71. package/dist/cjs/services/FeatureFlagService.js +0 -175
  72. package/dist/cjs/services/FileService.js +0 -201
  73. package/dist/cjs/services/IntegrationService.js +0 -538
  74. package/dist/cjs/services/MetricsService.js +0 -62
  75. package/dist/cjs/services/PaymentService.js +0 -271
  76. package/dist/cjs/services/PlanService.js +0 -426
  77. package/dist/cjs/services/ProjectService.js +0 -1207
  78. package/dist/cjs/services/PullRequestService.js +0 -503
  79. package/dist/cjs/services/ScreenshotService.js +0 -304
  80. package/dist/cjs/services/SubscriptionService.js +0 -396
  81. package/dist/cjs/services/TrackingService.js +0 -661
  82. package/dist/cjs/services/WaitlistService.js +0 -148
  83. package/dist/cjs/state/RootStateManager.js +0 -65
  84. package/dist/cjs/state/rootEventBus.js +0 -74
  85. package/dist/cjs/utils/CollabClient.js +0 -223
  86. package/dist/cjs/utils/changePreprocessor.js +0 -199
  87. package/dist/cjs/utils/jsonDiff.js +0 -145
  88. package/dist/cjs/utils/ordering.js +0 -309
  89. package/dist/esm/services/AdminService.js +0 -1132
  90. package/dist/esm/services/BranchService.js +0 -1265
  91. package/dist/esm/services/CollabService.js +0 -26838
  92. package/dist/esm/services/DnsService.js +0 -1121
  93. package/dist/esm/services/FeatureFlagService.js +0 -956
  94. package/dist/esm/services/FileService.js +0 -982
  95. package/dist/esm/services/IntegrationService.js +0 -1319
  96. package/dist/esm/services/MetricsService.js +0 -843
  97. package/dist/esm/services/PaymentService.js +0 -1052
  98. package/dist/esm/services/PlanService.js +0 -1207
  99. package/dist/esm/services/ProjectService.js +0 -2526
  100. package/dist/esm/services/PullRequestService.js +0 -1284
  101. package/dist/esm/services/ScreenshotService.js +0 -1085
  102. package/dist/esm/services/SubscriptionService.js +0 -1177
  103. package/dist/esm/services/TrackingService.js +0 -18343
  104. package/dist/esm/services/WaitlistService.js +0 -929
  105. package/dist/esm/state/RootStateManager.js +0 -90
  106. package/dist/esm/state/rootEventBus.js +0 -56
  107. package/dist/esm/utils/CollabClient.js +0 -18901
  108. package/dist/esm/utils/changePreprocessor.js +0 -542
  109. package/dist/esm/utils/jsonDiff.js +0 -7011
  110. package/dist/esm/utils/ordering.js +0 -291
  111. package/dist/node/services/AdminService.js +0 -332
  112. package/dist/node/services/BranchService.js +0 -465
  113. package/dist/node/services/CollabService.js +0 -724
  114. package/dist/node/services/DnsService.js +0 -321
  115. package/dist/node/services/FeatureFlagService.js +0 -156
  116. package/dist/node/services/FileService.js +0 -182
  117. package/dist/node/services/IntegrationService.js +0 -519
  118. package/dist/node/services/MetricsService.js +0 -43
  119. package/dist/node/services/PaymentService.js +0 -252
  120. package/dist/node/services/PlanService.js +0 -407
  121. package/dist/node/services/ProjectService.js +0 -1188
  122. package/dist/node/services/PullRequestService.js +0 -484
  123. package/dist/node/services/ScreenshotService.js +0 -285
  124. package/dist/node/services/SubscriptionService.js +0 -377
  125. package/dist/node/services/TrackingService.js +0 -632
  126. package/dist/node/services/WaitlistService.js +0 -129
  127. package/dist/node/state/RootStateManager.js +0 -36
  128. package/dist/node/state/rootEventBus.js +0 -55
  129. package/dist/node/utils/CollabClient.js +0 -194
  130. package/dist/node/utils/changePreprocessor.js +0 -180
  131. package/dist/node/utils/jsonDiff.js +0 -116
  132. package/dist/node/utils/ordering.js +0 -290
  133. package/src/services/AdminService.js +0 -374
  134. package/src/services/BranchService.js +0 -536
  135. package/src/services/CollabService.js +0 -900
  136. package/src/services/DnsService.js +0 -366
  137. package/src/services/FeatureFlagService.js +0 -174
  138. package/src/services/FileService.js +0 -213
  139. package/src/services/IntegrationService.js +0 -548
  140. package/src/services/MetricsService.js +0 -40
  141. package/src/services/PaymentService.js +0 -287
  142. package/src/services/PlanService.js +0 -468
  143. package/src/services/ProjectService.js +0 -1366
  144. package/src/services/PullRequestService.js +0 -537
  145. package/src/services/ScreenshotService.js +0 -258
  146. package/src/services/SubscriptionService.js +0 -425
  147. package/src/services/TrackingService.js +0 -853
  148. package/src/services/WaitlistService.js +0 -130
  149. package/src/services/tests/BranchService/createBranch.test.js +0 -153
  150. package/src/services/tests/BranchService/deleteBranch.test.js +0 -173
  151. package/src/services/tests/BranchService/getBranchChanges.test.js +0 -146
  152. package/src/services/tests/BranchService/listBranches.test.js +0 -87
  153. package/src/services/tests/BranchService/mergeBranch.test.js +0 -210
  154. package/src/services/tests/BranchService/publishVersion.test.js +0 -183
  155. package/src/services/tests/BranchService/renameBranch.test.js +0 -240
  156. package/src/services/tests/BranchService/resetBranch.test.js +0 -152
  157. package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +0 -67
  158. package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +0 -75
  159. package/src/services/tests/FileService/createFileFormData.test.js +0 -74
  160. package/src/services/tests/FileService/getFileUrl.test.js +0 -69
  161. package/src/services/tests/FileService/updateProjectIcon.test.js +0 -109
  162. package/src/services/tests/FileService/uploadDocument.test.js +0 -36
  163. package/src/services/tests/FileService/uploadFile.test.js +0 -78
  164. package/src/services/tests/FileService/uploadFileWithValidation.test.js +0 -114
  165. package/src/services/tests/FileService/uploadImage.test.js +0 -36
  166. package/src/services/tests/FileService/uploadMultipleFiles.test.js +0 -111
  167. package/src/services/tests/FileService/validateFile.test.js +0 -63
  168. package/src/services/tests/PlanService/createPlan.test.js +0 -104
  169. package/src/services/tests/PlanService/createPlanWithValidation.test.js +0 -523
  170. package/src/services/tests/PlanService/deletePlan.test.js +0 -92
  171. package/src/services/tests/PlanService/getActivePlans.test.js +0 -123
  172. package/src/services/tests/PlanService/getAdminPlans.test.js +0 -84
  173. package/src/services/tests/PlanService/getPlan.test.js +0 -50
  174. package/src/services/tests/PlanService/getPlanByKey.test.js +0 -109
  175. package/src/services/tests/PlanService/getPlanWithValidation.test.js +0 -85
  176. package/src/services/tests/PlanService/getPlans.test.js +0 -53
  177. package/src/services/tests/PlanService/getPlansByPriceRange.test.js +0 -109
  178. package/src/services/tests/PlanService/getPlansWithValidation.test.js +0 -48
  179. package/src/services/tests/PlanService/initializePlans.test.js +0 -75
  180. package/src/services/tests/PlanService/updatePlan.test.js +0 -111
  181. package/src/services/tests/PlanService/updatePlanWithValidation.test.js +0 -556
  182. package/src/state/RootStateManager.js +0 -76
  183. package/src/state/rootEventBus.js +0 -67
  184. package/src/utils/CollabClient.js +0 -248
  185. package/src/utils/changePreprocessor.js +0 -239
  186. package/src/utils/jsonDiff.js +0 -144
  187. package/src/utils/ordering.js +0 -271
@@ -1,130 +0,0 @@
1
- import { BaseService } from './BaseService.js'
2
-
3
- export class WaitlistService extends BaseService {
4
- // ==================== WAITLIST METHODS ====================
5
-
6
- /**
7
- * Join a waitlist campaign (public).
8
- *
9
- * Mirrors: POST /waitlist (WaitlistController.join)
10
- */
11
- async joinWaitlist (data = {}) {
12
- this._requireReady('joinWaitlist')
13
- if (!data || typeof data !== 'object') {
14
- throw new Error('Waitlist join payload is required')
15
- }
16
- if (!data.email) {
17
- throw new Error('Email is required')
18
- }
19
-
20
- try {
21
- const response = await this._request('/waitlist', {
22
- method: 'POST',
23
- body: JSON.stringify(data),
24
- methodName: 'joinWaitlist'
25
- })
26
- if (response.success) {
27
- return response.data
28
- }
29
- throw new Error(response.message)
30
- } catch (error) {
31
- throw new Error(`Failed to join waitlist: ${error.message}`, { cause: error })
32
- }
33
- }
34
-
35
- /**
36
- * List waitlist entries (admin).
37
- *
38
- * Mirrors: GET /waitlist (WaitlistController.list)
39
- */
40
- async listWaitlistEntries (options = {}) {
41
- this._requireReady('listWaitlistEntries')
42
-
43
- const {
44
- campaignKey,
45
- status,
46
- search,
47
- page,
48
- limit
49
- } = options || {}
50
-
51
- const queryParams = new URLSearchParams()
52
- if (campaignKey != null) { queryParams.append('campaignKey', String(campaignKey)) }
53
- if (status != null) { queryParams.append('status', String(status)) }
54
- if (search != null) { queryParams.append('search', String(search)) }
55
- if (page != null) { queryParams.append('page', String(page)) }
56
- if (limit != null) { queryParams.append('limit', String(limit)) }
57
-
58
- const queryString = queryParams.toString()
59
- const url = `/waitlist${queryString ? `?${queryString}` : ''}`
60
-
61
- try {
62
- const response = await this._request(url, {
63
- method: 'GET',
64
- methodName: 'listWaitlistEntries'
65
- })
66
- if (response.success) {
67
- return response.data
68
- }
69
- throw new Error(response.message)
70
- } catch (error) {
71
- throw new Error(`Failed to list waitlist entries: ${error.message}`, { cause: error })
72
- }
73
- }
74
-
75
- /**
76
- * Update a waitlist entry (admin).
77
- *
78
- * Mirrors: PATCH /waitlist/:id (WaitlistController.update)
79
- */
80
- async updateWaitlistEntry (id, update = {}) {
81
- this._requireReady('updateWaitlistEntry')
82
- if (!id) {
83
- throw new Error('Waitlist entry ID is required')
84
- }
85
- if (!update || typeof update !== 'object') {
86
- throw new Error('Update payload is required')
87
- }
88
-
89
- try {
90
- const response = await this._request(`/waitlist/${id}`, {
91
- method: 'PATCH',
92
- body: JSON.stringify(update),
93
- methodName: 'updateWaitlistEntry'
94
- })
95
- if (response.success) {
96
- return response.data
97
- }
98
- throw new Error(response.message)
99
- } catch (error) {
100
- throw new Error(`Failed to update waitlist entry: ${error.message}`, { cause: error })
101
- }
102
- }
103
-
104
- /**
105
- * Send an invitation email for a waitlist entry (admin).
106
- *
107
- * Mirrors: POST /waitlist/:id/invite (WaitlistController.invite)
108
- */
109
- async inviteWaitlistEntry (id) {
110
- this._requireReady('inviteWaitlistEntry')
111
- if (!id) {
112
- throw new Error('Waitlist entry ID is required')
113
- }
114
-
115
- try {
116
- const response = await this._request(`/waitlist/${id}/invite`, {
117
- method: 'POST',
118
- methodName: 'inviteWaitlistEntry'
119
- })
120
- if (response.success) {
121
- return response.data
122
- }
123
- throw new Error(response.message)
124
- } catch (error) {
125
- throw new Error(`Failed to invite waitlist entry: ${error.message}`, { cause: error })
126
- }
127
- }
128
- }
129
-
130
- // End
@@ -1,153 +0,0 @@
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('createBranch 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
- source: '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.createBranch(
26
- testProjectId,
27
- branchDataMock
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
- source: '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.createBranch(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
- name: ''
99
- },
100
- {
101
- testName: 'False boolean value',
102
- name: false
103
- },
104
- {
105
- testName: 'Undefined value',
106
- name: undefined
107
- },
108
- {
109
- testName: 'Null value',
110
- name: 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 branchName = {
121
- name: badData[ii].name,
122
- source: 'main'
123
- }
124
- const testProjectId = 'Test Project ID'
125
- const branchServiceStub = new BranchService()
126
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
127
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
128
- try {
129
- await branchServiceStub.createBranch(testProjectId, branchName)
130
- t.fail('Branch name validation threw an error with an invalid value')
131
- } catch (err) {
132
- t.equal(
133
- err.toString(),
134
- 'Error: Branch name is required',
135
- `Branch name validation successfully threw an error with: ${badData[ii].testName}`
136
- )
137
- }
138
- sandbox.restore()
139
- t.end()
140
- })
141
- }
142
- }
143
-
144
- checkBranchDataNameValidation()
145
- checkProjectIdValidation()
146
- // #endregion
147
-
148
- // #region Cleanup
149
- test('teardown', t => {
150
- sandbox.restore()
151
- t.end()
152
- })
153
- // #endregion
@@ -1,173 +0,0 @@
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('deleteBranch should return response data', async t => {
12
- t.plan(2)
13
- const responseStub = {
14
- success: true,
15
- data: 'Test data response'
16
- }
17
- const branchDataMock = {
18
- name: 'Test_Branch_Name',
19
- branch: 'not_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.deleteBranch(
26
- testProjectId,
27
- branchDataMock.branch
28
- )
29
- t.ok(response.success, 'Response successfully returned')
30
- t.equal(
31
- response.data,
32
- responseStub.data,
33
- 'Actual response matches expected response'
34
- )
35
- sandbox.restore()
36
- t.end()
37
- })
38
-
39
- test('Branch name validation should throw an error when the branch is main', async t => {
40
- t.plan(1)
41
- const responseStub = {
42
- success: true,
43
- data: 'Test data response'
44
- }
45
- const branchServiceStub = new BranchService()
46
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
47
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
48
- try {
49
- await branchServiceStub.deleteBranch('Test Project ID', 'main')
50
- t.fail('Branch name validation threw an error with an invalid value')
51
- } catch (err) {
52
- t.equal(
53
- err.toString(),
54
- 'Error: Cannot delete main branch',
55
- 'deleteBranch successfully threw an error when the main branch is deleted'
56
- )
57
- }
58
- sandbox.restore()
59
- t.end()
60
- })
61
-
62
- function checkProjectIdValidation () {
63
- const badData = [
64
- {
65
- testName: 'No Project ID'
66
- },
67
- {
68
- testName: 'Empty string',
69
- projectId: ''
70
- },
71
- {
72
- testName: 'False boolean value',
73
- projectId: false
74
- },
75
- {
76
- testName: 'Undefined value',
77
- projectId: undefined
78
- },
79
- {
80
- testName: 'Null value',
81
- projectId: null
82
- }
83
- ]
84
- for (let ii = 0; ii < badData.length; ii++) {
85
- test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
86
- t.plan(1)
87
- const responseStub = {
88
- success: true,
89
- data: 'Test data response'
90
- }
91
- const branchDataMock = {
92
- name: 'Test_Branch_Name',
93
- branch: 'not_main'
94
- }
95
- const testProjectId = badData[ii].projectId
96
- const branchServiceStub = new BranchService()
97
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
98
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
99
- try {
100
- await branchServiceStub.deleteBranch(testProjectId, branchDataMock)
101
- t.fail('Project ID validation threw an error with an invalid value')
102
- } catch (err) {
103
- t.equal(
104
- err.toString(),
105
- 'Error: Project ID is required',
106
- `Project ID validation successfully threw an error with: ${badData[ii].testName}`
107
- )
108
- }
109
- sandbox.restore()
110
- t.end()
111
- })
112
- }
113
- }
114
-
115
- function checkBranchDataNameValidation () {
116
- const badData = [
117
- {
118
- testName: 'No name'
119
- },
120
- {
121
- testName: 'Empty string',
122
- name: ''
123
- },
124
- {
125
- testName: 'False boolean value',
126
- name: false
127
- },
128
- {
129
- testName: 'Undefined value',
130
- name: undefined
131
- },
132
- {
133
- testName: 'Null value',
134
- name: null
135
- }
136
- ]
137
- for (let ii = 0; ii < badData.length; ii++) {
138
- test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async t => {
139
- t.plan(1)
140
- const responseStub = {
141
- success: true,
142
- data: 'Test data response'
143
- }
144
- const testProjectId = 'Test Project ID'
145
- const branchServiceStub = new BranchService()
146
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
147
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
148
- try {
149
- await branchServiceStub.deleteBranch(testProjectId, badData[ii].name)
150
- t.fail('Branch name validation threw an error with an invalid value')
151
- } catch (err) {
152
- t.equal(
153
- err.toString(),
154
- 'Error: Branch name is required',
155
- `Branch name validation successfully threw an error with: ${badData[ii].testName}`
156
- )
157
- }
158
- sandbox.restore()
159
- t.end()
160
- })
161
- }
162
- }
163
-
164
- checkBranchDataNameValidation()
165
- checkProjectIdValidation()
166
- // #endregion
167
-
168
- // #region Cleanup
169
- test('teardown', t => {
170
- sandbox.restore()
171
- t.end()
172
- })
173
- // #endregion
@@ -1,146 +0,0 @@
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('getBranchChanges 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
- }
20
- const testProjectId = 'Test Project ID'
21
- const branchServiceStub = new BranchService()
22
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
23
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
24
- const response = await branchServiceStub.getBranchChanges(
25
- testProjectId,
26
- branchDataMock.name
27
- )
28
- t.equal(
29
- response,
30
- responseStub.data,
31
- 'Actual response matches expected response'
32
- )
33
- sandbox.restore()
34
- t.end()
35
- })
36
-
37
- function checkProjectIdValidation () {
38
- const badData = [
39
- {
40
- testName: 'No Project ID'
41
- },
42
- {
43
- testName: 'Empty string',
44
- projectId: ''
45
- },
46
- {
47
- testName: 'False boolean value',
48
- projectId: false
49
- },
50
- {
51
- testName: 'Undefined value',
52
- projectId: undefined
53
- },
54
- {
55
- testName: 'Null value',
56
- projectId: null
57
- }
58
- ]
59
- for (let ii = 0; ii < badData.length; ii++) {
60
- test(`Project ID validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
61
- t.plan(1)
62
- const responseStub = {
63
- success: true,
64
- data: 'Test data response'
65
- }
66
- const branchDataMock = {
67
- name: 'Test_Branch_Name'
68
- }
69
- const testProjectId = badData[ii].projectId
70
- const branchServiceStub = new BranchService()
71
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
72
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
73
- try {
74
- await branchServiceStub.getBranchChanges(
75
- testProjectId,
76
- branchDataMock.name
77
- )
78
- t.fail('Project ID validation threw an error with an invalid value')
79
- } catch (err) {
80
- t.equal(
81
- err.toString(),
82
- 'Error: Project ID is required',
83
- `Project ID validation successfully threw an error with: ${badData[ii].testName}`
84
- )
85
- }
86
- sandbox.restore()
87
- t.end()
88
- })
89
- }
90
- }
91
-
92
- function checkBranchDataNameValidation () {
93
- const badData = [
94
- {
95
- testName: 'Empty string',
96
- name: ''
97
- },
98
- {
99
- testName: 'False boolean value',
100
- name: false
101
- },
102
- {
103
- testName: 'Null value',
104
- name: null
105
- }
106
- ]
107
- for (let ii = 0; ii < badData.length; ii++) {
108
- test(`Branch name validation should throw an error when: ${badData[ii].testName} is passed in`, async (t) => {
109
- t.plan(1)
110
- const responseStub = {
111
- success: true,
112
- data: 'Test data response'
113
- }
114
- const testProjectId = 'Test Project ID'
115
- const branchServiceStub = new BranchService()
116
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
117
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
118
- try {
119
- await branchServiceStub.getBranchChanges(
120
- testProjectId,
121
- badData[ii].name
122
- )
123
- t.fail('Branch name validation threw an error with an invalid value')
124
- } catch (err) {
125
- t.equal(
126
- err.toString(),
127
- 'Error: Branch name is required',
128
- `Branch name validation successfully threw an error with: ${badData[ii].testName}`
129
- )
130
- }
131
- sandbox.restore()
132
- t.end()
133
- })
134
- }
135
- }
136
-
137
- checkBranchDataNameValidation()
138
- checkProjectIdValidation()
139
- // #endregion
140
-
141
- // #region Cleanup
142
- test('teardown', (t) => {
143
- sandbox.restore()
144
- t.end()
145
- })
146
- // #endregion
@@ -1,87 +0,0 @@
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('listBranches should return response data', async t => {
12
- t.plan(1)
13
- const responseStub = {
14
- success: true,
15
- data: 'Test data response'
16
- }
17
- const testProjectId = 'Test Project ID'
18
- const branchServiceStub = new BranchService()
19
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
20
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
21
- const response = await branchServiceStub.listBranches(testProjectId)
22
- t.equal(
23
- response,
24
- responseStub.data,
25
- 'Actual response matches expected response'
26
- )
27
- sandbox.restore()
28
- t.end()
29
- })
30
-
31
- function checkProjectIdValidation () {
32
- const badData = [
33
- {
34
- name: 'No Project ID'
35
- },
36
- {
37
- name: 'Empty string',
38
- value: ''
39
- },
40
- {
41
- name: 'False boolean value',
42
- value: false
43
- },
44
- {
45
- name: 'Undefined value',
46
- value: undefined
47
- },
48
- {
49
- name: 'Null value',
50
- value: null
51
- }
52
- ]
53
- for (let ii = 0; ii < badData.length; ii++) {
54
- test(`Project ID validation should throw an error when: ${badData[ii].name} is passed in`, async t => {
55
- t.plan(1)
56
- const responseStub = {
57
- success: true,
58
- data: 'Test data response'
59
- }
60
- const testProjectId = badData[ii].value
61
- const branchServiceStub = new BranchService()
62
- sandbox.stub(branchServiceStub, '_requireReady').resolves()
63
- sandbox.stub(branchServiceStub, '_request').resolves(responseStub)
64
- try {
65
- await branchServiceStub.listBranches(testProjectId)
66
- t.fail('Project ID validation threw an error with an invalid value')
67
- } catch (err) {
68
- t.equal(
69
- err.toString(),
70
- 'Error: Project ID is required',
71
- `Project ID validation successfully threw an error with: ${badData[ii].name}`
72
- )
73
- }
74
- sandbox.restore()
75
- t.end()
76
- })
77
- }
78
- }
79
- checkProjectIdValidation()
80
- // #endregion
81
-
82
- // #region Cleanup
83
- test('teardown', t => {
84
- sandbox.restore()
85
- t.end()
86
- })
87
- // #endregion