@symbo.ls/sdk 2.34.35 → 3.1.1

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 +13 -315
  2. package/dist/cjs/config/environment.js +50 -124
  3. package/dist/cjs/index.js +22 -169
  4. package/dist/cjs/services/AIService.js +155 -0
  5. package/dist/cjs/services/AuthService.js +277 -751
  6. package/dist/cjs/services/BaseService.js +6 -158
  7. package/dist/cjs/services/BasedService.js +679 -0
  8. package/dist/cjs/services/SocketIOService.js +309 -0
  9. package/dist/cjs/services/SocketService.js +161 -0
  10. package/dist/cjs/services/SymstoryService.js +485 -0
  11. package/dist/cjs/services/index.js +16 -64
  12. package/dist/cjs/utils/basedQuerys.js +61 -0
  13. package/dist/cjs/utils/permission.js +4 -4
  14. package/dist/cjs/utils/services.js +80 -301
  15. package/dist/cjs/utils/symstoryClient.js +228 -0
  16. package/dist/cjs/utils/validation.js +3 -0
  17. package/dist/esm/config/environment.js +50 -124
  18. package/dist/esm/index.js +11282 -49789
  19. package/dist/esm/services/AIService.js +185 -0
  20. package/dist/esm/services/AuthService.js +358 -1506
  21. package/dist/esm/services/BaseService.js +6 -757
  22. package/dist/esm/services/BasedService.js +4651 -0
  23. package/dist/esm/services/SocketIOService.js +467 -0
  24. package/dist/esm/services/SocketService.js +191 -0
  25. package/dist/esm/services/SymstoryService.js +6849 -0
  26. package/dist/esm/services/index.js +11188 -49352
  27. package/dist/esm/utils/basedQuerys.js +43 -0
  28. package/dist/esm/utils/permission.js +4 -4
  29. package/dist/esm/utils/services.js +80 -301
  30. package/dist/esm/utils/symstoryClient.js +334 -0
  31. package/dist/esm/utils/validation.js +26 -93
  32. package/dist/node/config/environment.js +50 -124
  33. package/dist/node/index.js +26 -202
  34. package/dist/node/services/AIService.js +136 -0
  35. package/dist/node/services/AuthService.js +278 -751
  36. package/dist/node/services/BaseService.js +6 -148
  37. package/dist/node/services/BasedService.js +650 -0
  38. package/dist/node/services/SocketIOService.js +280 -0
  39. package/dist/node/services/SocketService.js +142 -0
  40. package/dist/node/services/SymstoryService.js +456 -0
  41. package/dist/node/services/index.js +16 -64
  42. package/dist/node/utils/basedQuerys.js +42 -0
  43. package/dist/node/utils/permission.js +4 -4
  44. package/dist/node/utils/services.js +80 -301
  45. package/dist/node/utils/symstoryClient.js +199 -0
  46. package/dist/node/utils/validation.js +3 -0
  47. package/package.json +21 -43
  48. package/src/config/environment.js +50 -126
  49. package/src/index.js +24 -208
  50. package/src/services/AIService.js +150 -0
  51. package/src/services/AuthService.js +298 -893
  52. package/src/services/BaseService.js +6 -166
  53. package/src/services/BasedService.js +722 -0
  54. package/src/services/SocketIOService.js +356 -0
  55. package/src/services/SocketService.js +168 -0
  56. package/src/services/SymstoryService.js +563 -0
  57. package/src/services/index.js +13 -80
  58. package/src/utils/basedQuerys.js +41 -0
  59. package/src/utils/permission.js +4 -4
  60. package/src/utils/services.js +83 -325
  61. package/src/utils/symstoryClient.js +218 -0
  62. package/src/utils/validation.js +3 -0
  63. package/dist/cjs/services/AdminService.js +0 -351
  64. package/dist/cjs/services/BranchService.js +0 -484
  65. package/dist/cjs/services/CollabService.js +0 -743
  66. package/dist/cjs/services/DnsService.js +0 -340
  67. package/dist/cjs/services/FeatureFlagService.js +0 -175
  68. package/dist/cjs/services/FileService.js +0 -201
  69. package/dist/cjs/services/IntegrationService.js +0 -538
  70. package/dist/cjs/services/MetricsService.js +0 -62
  71. package/dist/cjs/services/PaymentService.js +0 -271
  72. package/dist/cjs/services/PlanService.js +0 -426
  73. package/dist/cjs/services/ProjectService.js +0 -1207
  74. package/dist/cjs/services/PullRequestService.js +0 -503
  75. package/dist/cjs/services/ScreenshotService.js +0 -304
  76. package/dist/cjs/services/SubscriptionService.js +0 -396
  77. package/dist/cjs/services/TrackingService.js +0 -661
  78. package/dist/cjs/services/WaitlistService.js +0 -148
  79. package/dist/cjs/state/RootStateManager.js +0 -65
  80. package/dist/cjs/state/rootEventBus.js +0 -74
  81. package/dist/cjs/utils/CollabClient.js +0 -223
  82. package/dist/cjs/utils/TokenManager.js +0 -422
  83. package/dist/cjs/utils/changePreprocessor.js +0 -199
  84. package/dist/cjs/utils/jsonDiff.js +0 -145
  85. package/dist/cjs/utils/ordering.js +0 -309
  86. package/dist/esm/services/AdminService.js +0 -1132
  87. package/dist/esm/services/BranchService.js +0 -1265
  88. package/dist/esm/services/CollabService.js +0 -26838
  89. package/dist/esm/services/DnsService.js +0 -1121
  90. package/dist/esm/services/FeatureFlagService.js +0 -956
  91. package/dist/esm/services/FileService.js +0 -982
  92. package/dist/esm/services/IntegrationService.js +0 -1319
  93. package/dist/esm/services/MetricsService.js +0 -843
  94. package/dist/esm/services/PaymentService.js +0 -1052
  95. package/dist/esm/services/PlanService.js +0 -1207
  96. package/dist/esm/services/ProjectService.js +0 -2526
  97. package/dist/esm/services/PullRequestService.js +0 -1284
  98. package/dist/esm/services/ScreenshotService.js +0 -1085
  99. package/dist/esm/services/SubscriptionService.js +0 -1177
  100. package/dist/esm/services/TrackingService.js +0 -18343
  101. package/dist/esm/services/WaitlistService.js +0 -929
  102. package/dist/esm/state/RootStateManager.js +0 -90
  103. package/dist/esm/state/rootEventBus.js +0 -56
  104. package/dist/esm/utils/CollabClient.js +0 -18901
  105. package/dist/esm/utils/TokenManager.js +0 -408
  106. package/dist/esm/utils/changePreprocessor.js +0 -542
  107. package/dist/esm/utils/jsonDiff.js +0 -7011
  108. package/dist/esm/utils/ordering.js +0 -291
  109. package/dist/node/services/AdminService.js +0 -332
  110. package/dist/node/services/BranchService.js +0 -465
  111. package/dist/node/services/CollabService.js +0 -724
  112. package/dist/node/services/DnsService.js +0 -321
  113. package/dist/node/services/FeatureFlagService.js +0 -156
  114. package/dist/node/services/FileService.js +0 -182
  115. package/dist/node/services/IntegrationService.js +0 -519
  116. package/dist/node/services/MetricsService.js +0 -43
  117. package/dist/node/services/PaymentService.js +0 -252
  118. package/dist/node/services/PlanService.js +0 -407
  119. package/dist/node/services/ProjectService.js +0 -1188
  120. package/dist/node/services/PullRequestService.js +0 -484
  121. package/dist/node/services/ScreenshotService.js +0 -285
  122. package/dist/node/services/SubscriptionService.js +0 -377
  123. package/dist/node/services/TrackingService.js +0 -632
  124. package/dist/node/services/WaitlistService.js +0 -129
  125. package/dist/node/state/RootStateManager.js +0 -36
  126. package/dist/node/state/rootEventBus.js +0 -55
  127. package/dist/node/utils/CollabClient.js +0 -194
  128. package/dist/node/utils/TokenManager.js +0 -403
  129. package/dist/node/utils/changePreprocessor.js +0 -180
  130. package/dist/node/utils/jsonDiff.js +0 -116
  131. package/dist/node/utils/ordering.js +0 -290
  132. package/src/services/AdminService.js +0 -374
  133. package/src/services/BranchService.js +0 -536
  134. package/src/services/CollabService.js +0 -900
  135. package/src/services/DnsService.js +0 -366
  136. package/src/services/FeatureFlagService.js +0 -174
  137. package/src/services/FileService.js +0 -213
  138. package/src/services/IntegrationService.js +0 -548
  139. package/src/services/MetricsService.js +0 -40
  140. package/src/services/PaymentService.js +0 -287
  141. package/src/services/PlanService.js +0 -468
  142. package/src/services/ProjectService.js +0 -1366
  143. package/src/services/PullRequestService.js +0 -537
  144. package/src/services/ScreenshotService.js +0 -258
  145. package/src/services/SubscriptionService.js +0 -425
  146. package/src/services/TrackingService.js +0 -853
  147. package/src/services/WaitlistService.js +0 -130
  148. package/src/services/tests/BranchService/createBranch.test.js +0 -153
  149. package/src/services/tests/BranchService/deleteBranch.test.js +0 -173
  150. package/src/services/tests/BranchService/getBranchChanges.test.js +0 -146
  151. package/src/services/tests/BranchService/listBranches.test.js +0 -87
  152. package/src/services/tests/BranchService/mergeBranch.test.js +0 -210
  153. package/src/services/tests/BranchService/publishVersion.test.js +0 -183
  154. package/src/services/tests/BranchService/renameBranch.test.js +0 -240
  155. package/src/services/tests/BranchService/resetBranch.test.js +0 -152
  156. package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +0 -67
  157. package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +0 -75
  158. package/src/services/tests/FileService/createFileFormData.test.js +0 -74
  159. package/src/services/tests/FileService/getFileUrl.test.js +0 -69
  160. package/src/services/tests/FileService/updateProjectIcon.test.js +0 -109
  161. package/src/services/tests/FileService/uploadDocument.test.js +0 -36
  162. package/src/services/tests/FileService/uploadFile.test.js +0 -78
  163. package/src/services/tests/FileService/uploadFileWithValidation.test.js +0 -114
  164. package/src/services/tests/FileService/uploadImage.test.js +0 -36
  165. package/src/services/tests/FileService/uploadMultipleFiles.test.js +0 -111
  166. package/src/services/tests/FileService/validateFile.test.js +0 -63
  167. package/src/services/tests/PlanService/createPlan.test.js +0 -104
  168. package/src/services/tests/PlanService/createPlanWithValidation.test.js +0 -523
  169. package/src/services/tests/PlanService/deletePlan.test.js +0 -92
  170. package/src/services/tests/PlanService/getActivePlans.test.js +0 -123
  171. package/src/services/tests/PlanService/getAdminPlans.test.js +0 -84
  172. package/src/services/tests/PlanService/getPlan.test.js +0 -50
  173. package/src/services/tests/PlanService/getPlanByKey.test.js +0 -109
  174. package/src/services/tests/PlanService/getPlanWithValidation.test.js +0 -85
  175. package/src/services/tests/PlanService/getPlans.test.js +0 -53
  176. package/src/services/tests/PlanService/getPlansByPriceRange.test.js +0 -109
  177. package/src/services/tests/PlanService/getPlansWithValidation.test.js +0 -48
  178. package/src/services/tests/PlanService/initializePlans.test.js +0 -75
  179. package/src/services/tests/PlanService/updatePlan.test.js +0 -111
  180. package/src/services/tests/PlanService/updatePlanWithValidation.test.js +0 -556
  181. package/src/state/RootStateManager.js +0 -76
  182. package/src/state/rootEventBus.js +0 -67
  183. package/src/utils/CollabClient.js +0 -248
  184. package/src/utils/TokenManager.js +0 -479
  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,287 +0,0 @@
1
- import { BaseService } from './BaseService.js'
2
-
3
- export class PaymentService extends BaseService {
4
- // ==================== PAYMENT METHODS ====================
5
-
6
- async checkout (options = {}) {
7
- this._requireReady('checkout')
8
- const {
9
- projectId,
10
- seats = 1,
11
- price = 'starter_monthly',
12
- successUrl = `${window.location.origin}/success`,
13
- cancelUrl = `${window.location.origin}/pricing`
14
- } = options
15
-
16
- if (!projectId) {
17
- throw new Error('Project ID is required for checkout')
18
- }
19
-
20
- try {
21
- const response = await this._request('/payments/checkout', {
22
- method: 'POST',
23
- body: JSON.stringify({
24
- projectId,
25
- seats,
26
- price,
27
- successUrl,
28
- cancelUrl
29
- }),
30
- methodName: 'checkout'
31
- })
32
- if (response.success) {
33
- return response.data
34
- }
35
- throw new Error(response.message)
36
- } catch (error) {
37
- throw new Error(`Failed to checkout: ${error.message}`, { cause: error })
38
- }
39
- }
40
-
41
- async getSubscriptionStatus (projectId) {
42
- this._requireReady('getSubscriptionStatus')
43
- if (!projectId) {
44
- throw new Error('Project ID is required')
45
- }
46
- try {
47
- const response = await this._request(
48
- `/payments/subscription/${projectId}`,
49
- {
50
- method: 'GET',
51
- methodName: 'getSubscriptionStatus'
52
- }
53
- )
54
- if (response.success) {
55
- return response.data
56
- }
57
- throw new Error(response.message)
58
- } catch (error) {
59
- throw new Error(`Failed to get subscription status: ${error.message}`, { cause: error })
60
- }
61
- }
62
-
63
- // ==================== PAYMENT HELPER METHODS ====================
64
-
65
- /**
66
- * Helper method to create checkout with validation
67
- */
68
- async checkoutWithValidation (options = {}) {
69
- const {
70
- projectId,
71
- seats,
72
- price,
73
- successUrl,
74
- cancelUrl
75
- } = options
76
-
77
- // Validate required fields
78
- if (!projectId) {
79
- throw new Error('Project ID is required')
80
- }
81
-
82
- if (seats && (typeof seats !== 'number' || seats < 1)) {
83
- throw new Error('Seats must be a positive number')
84
- }
85
-
86
- if (price && typeof price !== 'string') {
87
- throw new Error('Price must be a string')
88
- }
89
-
90
- // Validate URLs if provided
91
- if (successUrl && !this._isValidUrl(successUrl)) {
92
- throw new Error('Success URL must be a valid URL')
93
- }
94
-
95
- if (cancelUrl && !this._isValidUrl(cancelUrl)) {
96
- throw new Error('Cancel URL must be a valid URL')
97
- }
98
-
99
- return await this.checkout(options)
100
- }
101
-
102
- /**
103
- * Helper method to get subscription status with validation
104
- */
105
- async getSubscriptionStatusWithValidation (projectId) {
106
- if (!projectId || typeof projectId !== 'string') {
107
- throw new Error('Project ID must be a valid string')
108
- }
109
-
110
- return await this.getSubscriptionStatus(projectId)
111
- }
112
-
113
- /**
114
- * Helper method to check if project has active subscription
115
- */
116
- async hasActiveSubscription (projectId) {
117
- try {
118
- const status = await this.getSubscriptionStatus(projectId)
119
- return status?.active === true
120
- } catch (error) {
121
- console.warn('Failed to check subscription status:', error.message)
122
- return false
123
- }
124
- }
125
-
126
- /**
127
- * Helper method to get subscription details
128
- */
129
- async getSubscriptionDetails (projectId) {
130
- try {
131
- const status = await this.getSubscriptionStatus(projectId)
132
-
133
- if (!status) {
134
- return {
135
- hasSubscription: false,
136
- active: false,
137
- message: 'No subscription found'
138
- }
139
- }
140
-
141
- return {
142
- hasSubscription: true,
143
- active: status.active || false,
144
- plan: status.plan,
145
- seats: status.seats,
146
- nextBillingDate: status.nextBillingDate,
147
- amount: status.amount,
148
- currency: status.currency,
149
- status: status.status
150
- }
151
- } catch (error) {
152
- throw new Error(`Failed to get subscription details: ${error.message}`, { cause: error })
153
- }
154
- }
155
-
156
- /**
157
- * Helper method to create checkout for specific plan
158
- */
159
- async checkoutForPlan (projectId, planKey, options = {}) {
160
- if (!projectId) {
161
- throw new Error('Project ID is required')
162
- }
163
- if (!planKey) {
164
- throw new Error('Plan key is required')
165
- }
166
-
167
- const checkoutOptions = {
168
- projectId,
169
- price: planKey,
170
- ...options
171
- }
172
-
173
- return await this.checkoutWithValidation(checkoutOptions)
174
- }
175
-
176
- /**
177
- * Helper method to create checkout for team plan
178
- */
179
- async checkoutForTeam (projectId, seats, options = {}) {
180
- if (!projectId) {
181
- throw new Error('Project ID is required')
182
- }
183
- if (!seats || seats < 1) {
184
- throw new Error('Seats must be a positive number')
185
- }
186
-
187
- const checkoutOptions = {
188
- projectId,
189
- seats,
190
- price: 'team_monthly',
191
- ...options
192
- }
193
-
194
- return await this.checkoutWithValidation(checkoutOptions)
195
- }
196
-
197
- /**
198
- * Helper method to validate subscription status
199
- */
200
- validateSubscriptionStatus (status) {
201
- if (!status || typeof status !== 'object') {
202
- return {
203
- isValid: false,
204
- error: 'Invalid subscription status format'
205
- }
206
- }
207
-
208
- const requiredFields = ['active', 'plan', 'seats']
209
- const missingFields = requiredFields.filter(field => !(field in status))
210
-
211
- if (missingFields.length > 0) {
212
- return {
213
- isValid: false,
214
- error: `Missing required fields: ${missingFields.join(', ')}`
215
- }
216
- }
217
-
218
- return {
219
- isValid: true,
220
- error: null
221
- }
222
- }
223
-
224
- /**
225
- * Helper method to format subscription amount
226
- */
227
- formatSubscriptionAmount (amount, currency = 'USD') {
228
- if (!amount || typeof amount !== 'number') {
229
- return 'N/A'
230
- }
231
-
232
- return new Intl.NumberFormat('en-US', {
233
- style: 'currency',
234
- currency
235
- }).format(amount / 100) // Assuming amount is in cents
236
- }
237
-
238
- /**
239
- * Helper method to get subscription summary
240
- */
241
- async getSubscriptionSummary (projectId) {
242
- try {
243
- const details = await this.getSubscriptionDetails(projectId)
244
-
245
- if (!details.hasSubscription) {
246
- return {
247
- status: 'no_subscription',
248
- message: 'No active subscription',
249
- action: 'subscribe'
250
- }
251
- }
252
-
253
- if (!details.active) {
254
- return {
255
- status: 'inactive',
256
- message: 'Subscription is inactive',
257
- action: 'reactivate'
258
- }
259
- }
260
-
261
- return {
262
- status: 'active',
263
- message: `Active ${details.plan} plan with ${details.seats} seats`,
264
- action: 'manage',
265
- details
266
- }
267
- } catch (error) {
268
- return {
269
- status: 'error',
270
- message: `Failed to get subscription: ${error.message}`,
271
- action: 'retry'
272
- }
273
- }
274
- }
275
-
276
- /**
277
- * Private helper to validate URL
278
- */
279
- _isValidUrl (string) {
280
- try {
281
- const url = new URL(string)
282
- return Boolean(url)
283
- } catch {
284
- return false
285
- }
286
- }
287
- }