@symbo.ls/sdk 3.2.3 → 3.2.7

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 (183) hide show
  1. package/README.md +141 -0
  2. package/dist/cjs/config/environment.js +94 -10
  3. package/dist/cjs/index.js +152 -12
  4. package/dist/cjs/services/AdminService.js +351 -0
  5. package/dist/cjs/services/AuthService.js +738 -305
  6. package/dist/cjs/services/BaseService.js +158 -6
  7. package/dist/cjs/services/BranchService.js +484 -0
  8. package/dist/cjs/services/CollabService.js +439 -116
  9. package/dist/cjs/services/DnsService.js +340 -0
  10. package/dist/cjs/services/FeatureFlagService.js +175 -0
  11. package/dist/cjs/services/FileService.js +201 -0
  12. package/dist/cjs/services/IntegrationService.js +538 -0
  13. package/dist/cjs/services/MetricsService.js +62 -0
  14. package/dist/cjs/services/PaymentService.js +271 -0
  15. package/dist/cjs/services/PlanService.js +426 -0
  16. package/dist/cjs/services/ProjectService.js +1207 -0
  17. package/dist/cjs/services/PullRequestService.js +503 -0
  18. package/dist/cjs/services/ScreenshotService.js +304 -0
  19. package/dist/cjs/services/SubscriptionService.js +396 -0
  20. package/dist/cjs/services/TrackingService.js +661 -0
  21. package/dist/cjs/services/WaitlistService.js +148 -0
  22. package/dist/cjs/services/index.js +60 -4
  23. package/dist/cjs/state/RootStateManager.js +2 -23
  24. package/dist/cjs/state/rootEventBus.js +9 -0
  25. package/dist/cjs/utils/CollabClient.js +78 -12
  26. package/dist/cjs/utils/TokenManager.js +16 -3
  27. package/dist/cjs/utils/changePreprocessor.js +199 -0
  28. package/dist/cjs/utils/jsonDiff.js +46 -4
  29. package/dist/cjs/utils/ordering.js +309 -0
  30. package/dist/cjs/utils/services.js +285 -128
  31. package/dist/cjs/utils/validation.js +0 -3
  32. package/dist/esm/config/environment.js +94 -10
  33. package/dist/esm/index.js +47862 -18248
  34. package/dist/esm/services/AdminService.js +1132 -0
  35. package/dist/esm/services/AuthService.js +1493 -386
  36. package/dist/esm/services/BaseService.js +757 -6
  37. package/dist/esm/services/BranchService.js +1265 -0
  38. package/dist/esm/services/CollabService.js +24956 -16089
  39. package/dist/esm/services/DnsService.js +1121 -0
  40. package/dist/esm/services/FeatureFlagService.js +956 -0
  41. package/dist/esm/services/FileService.js +982 -0
  42. package/dist/esm/services/IntegrationService.js +1319 -0
  43. package/dist/esm/services/MetricsService.js +843 -0
  44. package/dist/esm/services/PaymentService.js +1052 -0
  45. package/dist/esm/services/PlanService.js +1207 -0
  46. package/dist/esm/services/ProjectService.js +2526 -0
  47. package/dist/esm/services/PullRequestService.js +1284 -0
  48. package/dist/esm/services/ScreenshotService.js +1085 -0
  49. package/dist/esm/services/SubscriptionService.js +1177 -0
  50. package/dist/esm/services/TrackingService.js +18454 -0
  51. package/dist/esm/services/WaitlistService.js +929 -0
  52. package/dist/esm/services/index.js +47373 -18027
  53. package/dist/esm/state/RootStateManager.js +11 -23
  54. package/dist/esm/state/rootEventBus.js +9 -0
  55. package/dist/esm/utils/CollabClient.js +17526 -16120
  56. package/dist/esm/utils/TokenManager.js +16 -3
  57. package/dist/esm/utils/changePreprocessor.js +542 -0
  58. package/dist/esm/utils/jsonDiff.js +958 -43
  59. package/dist/esm/utils/ordering.js +291 -0
  60. package/dist/esm/utils/services.js +285 -128
  61. package/dist/esm/utils/validation.js +116 -50
  62. package/dist/node/config/environment.js +94 -10
  63. package/dist/node/index.js +183 -16
  64. package/dist/node/services/AdminService.js +332 -0
  65. package/dist/node/services/AuthService.js +742 -310
  66. package/dist/node/services/BaseService.js +148 -6
  67. package/dist/node/services/BranchService.js +465 -0
  68. package/dist/node/services/CollabService.js +439 -116
  69. package/dist/node/services/DnsService.js +321 -0
  70. package/dist/node/services/FeatureFlagService.js +156 -0
  71. package/dist/node/services/FileService.js +182 -0
  72. package/dist/node/services/IntegrationService.js +519 -0
  73. package/dist/node/services/MetricsService.js +43 -0
  74. package/dist/node/services/PaymentService.js +252 -0
  75. package/dist/node/services/PlanService.js +407 -0
  76. package/dist/node/services/ProjectService.js +1188 -0
  77. package/dist/node/services/PullRequestService.js +484 -0
  78. package/dist/node/services/ScreenshotService.js +285 -0
  79. package/dist/node/services/SubscriptionService.js +377 -0
  80. package/dist/node/services/TrackingService.js +632 -0
  81. package/dist/node/services/WaitlistService.js +129 -0
  82. package/dist/node/services/index.js +60 -4
  83. package/dist/node/state/RootStateManager.js +2 -23
  84. package/dist/node/state/rootEventBus.js +9 -0
  85. package/dist/node/utils/CollabClient.js +77 -11
  86. package/dist/node/utils/TokenManager.js +16 -3
  87. package/dist/node/utils/changePreprocessor.js +180 -0
  88. package/dist/node/utils/jsonDiff.js +46 -4
  89. package/dist/node/utils/ordering.js +290 -0
  90. package/dist/node/utils/services.js +285 -128
  91. package/dist/node/utils/validation.js +0 -3
  92. package/package.json +30 -18
  93. package/src/config/environment.js +95 -10
  94. package/src/index.js +190 -23
  95. package/src/services/AdminService.js +374 -0
  96. package/src/services/AuthService.js +874 -328
  97. package/src/services/BaseService.js +166 -6
  98. package/src/services/BranchService.js +536 -0
  99. package/src/services/CollabService.js +557 -148
  100. package/src/services/DnsService.js +366 -0
  101. package/src/services/FeatureFlagService.js +174 -0
  102. package/src/services/FileService.js +213 -0
  103. package/src/services/IntegrationService.js +548 -0
  104. package/src/services/MetricsService.js +40 -0
  105. package/src/services/PaymentService.js +287 -0
  106. package/src/services/PlanService.js +468 -0
  107. package/src/services/ProjectService.js +1366 -0
  108. package/src/services/PullRequestService.js +537 -0
  109. package/src/services/ScreenshotService.js +258 -0
  110. package/src/services/SubscriptionService.js +425 -0
  111. package/src/services/TrackingService.js +853 -0
  112. package/src/services/WaitlistService.js +130 -0
  113. package/src/services/index.js +79 -5
  114. package/src/services/tests/BranchService/createBranch.test.js +153 -0
  115. package/src/services/tests/BranchService/deleteBranch.test.js +173 -0
  116. package/src/services/tests/BranchService/getBranchChanges.test.js +146 -0
  117. package/src/services/tests/BranchService/listBranches.test.js +87 -0
  118. package/src/services/tests/BranchService/mergeBranch.test.js +210 -0
  119. package/src/services/tests/BranchService/publishVersion.test.js +183 -0
  120. package/src/services/tests/BranchService/renameBranch.test.js +240 -0
  121. package/src/services/tests/BranchService/resetBranch.test.js +152 -0
  122. package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +67 -0
  123. package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +75 -0
  124. package/src/services/tests/FileService/createFileFormData.test.js +74 -0
  125. package/src/services/tests/FileService/getFileUrl.test.js +69 -0
  126. package/src/services/tests/FileService/updateProjectIcon.test.js +109 -0
  127. package/src/services/tests/FileService/uploadDocument.test.js +36 -0
  128. package/src/services/tests/FileService/uploadFile.test.js +78 -0
  129. package/src/services/tests/FileService/uploadFileWithValidation.test.js +114 -0
  130. package/src/services/tests/FileService/uploadImage.test.js +36 -0
  131. package/src/services/tests/FileService/uploadMultipleFiles.test.js +111 -0
  132. package/src/services/tests/FileService/validateFile.test.js +63 -0
  133. package/src/services/tests/PlanService/createPlan.test.js +104 -0
  134. package/src/services/tests/PlanService/createPlanWithValidation.test.js +523 -0
  135. package/src/services/tests/PlanService/deletePlan.test.js +92 -0
  136. package/src/services/tests/PlanService/getActivePlans.test.js +123 -0
  137. package/src/services/tests/PlanService/getAdminPlans.test.js +84 -0
  138. package/src/services/tests/PlanService/getPlan.test.js +50 -0
  139. package/src/services/tests/PlanService/getPlanByKey.test.js +109 -0
  140. package/src/services/tests/PlanService/getPlanWithValidation.test.js +85 -0
  141. package/src/services/tests/PlanService/getPlans.test.js +53 -0
  142. package/src/services/tests/PlanService/getPlansByPriceRange.test.js +109 -0
  143. package/src/services/tests/PlanService/getPlansWithValidation.test.js +48 -0
  144. package/src/services/tests/PlanService/initializePlans.test.js +75 -0
  145. package/src/services/tests/PlanService/updatePlan.test.js +111 -0
  146. package/src/services/tests/PlanService/updatePlanWithValidation.test.js +556 -0
  147. package/src/state/RootStateManager.js +37 -32
  148. package/src/state/rootEventBus.js +19 -0
  149. package/src/utils/CollabClient.js +99 -12
  150. package/src/utils/TokenManager.js +20 -3
  151. package/src/utils/changePreprocessor.js +239 -0
  152. package/src/utils/jsonDiff.js +40 -5
  153. package/src/utils/ordering.js +271 -0
  154. package/src/utils/services.js +306 -139
  155. package/src/utils/validation.js +0 -3
  156. package/dist/cjs/services/AIService.js +0 -155
  157. package/dist/cjs/services/BasedService.js +0 -1185
  158. package/dist/cjs/services/CoreService.js +0 -2295
  159. package/dist/cjs/services/SocketService.js +0 -309
  160. package/dist/cjs/services/SymstoryService.js +0 -571
  161. package/dist/cjs/utils/basedQuerys.js +0 -181
  162. package/dist/cjs/utils/symstoryClient.js +0 -259
  163. package/dist/esm/services/AIService.js +0 -185
  164. package/dist/esm/services/BasedService.js +0 -5262
  165. package/dist/esm/services/CoreService.js +0 -2827
  166. package/dist/esm/services/SocketService.js +0 -456
  167. package/dist/esm/services/SymstoryService.js +0 -7025
  168. package/dist/esm/utils/basedQuerys.js +0 -163
  169. package/dist/esm/utils/symstoryClient.js +0 -354
  170. package/dist/node/services/AIService.js +0 -136
  171. package/dist/node/services/BasedService.js +0 -1156
  172. package/dist/node/services/CoreService.js +0 -2266
  173. package/dist/node/services/SocketService.js +0 -280
  174. package/dist/node/services/SymstoryService.js +0 -542
  175. package/dist/node/utils/basedQuerys.js +0 -162
  176. package/dist/node/utils/symstoryClient.js +0 -230
  177. package/src/services/AIService.js +0 -150
  178. package/src/services/BasedService.js +0 -1302
  179. package/src/services/CoreService.js +0 -2548
  180. package/src/services/SocketService.js +0 -336
  181. package/src/services/SymstoryService.js +0 -649
  182. package/src/utils/basedQuerys.js +0 -164
  183. package/src/utils/symstoryClient.js +0 -252
@@ -1,230 +0,0 @@
1
- import config from "../config/environment.js";
2
- const DEFAULT_OPTIONS = {
3
- apiUrl: config.apiUrl
4
- };
5
- class SymstoryClient {
6
- /**
7
- * Creates an instance of SymstoryClient.
8
- * @param {string} appKey - The application key.
9
- * @param {object} [options={}] - The options for the client.
10
- */
11
- constructor(appKey, options = {}) {
12
- if (!appKey) {
13
- throw new Error("AppKey is required");
14
- }
15
- this.appKey = appKey;
16
- this.options = { ...DEFAULT_OPTIONS, ...options };
17
- this.headers = {
18
- "Content-Type": "application/json",
19
- ...this.options.headers,
20
- "X-AppKey": appKey
21
- };
22
- }
23
- /**
24
- * Makes a request to the Symstory service.
25
- * @param {string} [path=''] - The request path.
26
- * @param {object} [options={}] - The request options.
27
- * @returns {Promise<any>} - The response data.
28
- */
29
- async request(path = "", options = {}) {
30
- const url = `${this.options.apiUrl}/symstory/${this.appKey}${path}`;
31
- const response = await fetch(url, {
32
- ...options,
33
- headers: { ...this.headers, ...options.headers }
34
- });
35
- if (!response.ok) {
36
- const error = await response.json();
37
- throw new Error(error.message || error.error || "Request failed");
38
- }
39
- return response.status === 204 ? null : response.json();
40
- }
41
- /**
42
- * Fetches project data.
43
- * @param {object} query - The query object to filter data.
44
- * @param {string|null} [branch=null] - The branch name.
45
- * @param {string|null} [version=null] - The version number.
46
- * @returns {Promise<any>} - The project data.
47
- */
48
- get(query, branch = null, version = null) {
49
- const params = new URLSearchParams({
50
- ...branch && { branch },
51
- ...version ? { version } : { cacheId: Math.random() },
52
- ...query && { query: JSON.stringify(query) }
53
- });
54
- return this.request(`?${params}`);
55
- }
56
- /**
57
- * Sets a value at the specified path.
58
- * @param {string} path - The path where the value should be set.
59
- * @param {any} value - The value to set.
60
- * @returns {Promise<any>} - The response data.
61
- */
62
- set(path, value) {
63
- return this.request("", {
64
- method: "POST",
65
- body: JSON.stringify({ changes: [["update", path, value]] })
66
- });
67
- }
68
- /**
69
- * Updates project data.
70
- * @param {Array} changes - The changes to apply.
71
- * @param {object} [options={}] - The update options.
72
- * @param {string} [options.type='patch'] - The type of update.
73
- * @param {string} [options.message=''] - A message describing the update.
74
- * @param {string} [options.branch='main'] - The branch name.
75
- * @returns {Promise<any>} - The response data.
76
- */
77
- async update(changes, { type = "patch", message = "", branch = "main" } = {}) {
78
- return await this.request("", {
79
- method: "POST",
80
- body: JSON.stringify({ changes, type, message, branch })
81
- });
82
- }
83
- /**
84
- * Retrieves all branches of the project.
85
- * @returns {Promise<any>} - The branches data.
86
- */
87
- getBranches() {
88
- return this.request("/branches");
89
- }
90
- /**
91
- * Creates a new branch.
92
- * @param {string} branch - The name of the new branch.
93
- * @param {object} [options={}] - The branch creation options.
94
- * @param {string} [options.message] - A message describing the branch creation.
95
- * @param {string} [options.source='main'] - The source branch.
96
- * @param {string} [options.version] - The version number.
97
- * @returns {Promise<any>} - The response data.
98
- */
99
- createBranch(branch, { message, source = "main", version } = {}) {
100
- return this.request("/branch", {
101
- method: "POST",
102
- body: JSON.stringify({ branch, message, source, version })
103
- });
104
- }
105
- /**
106
- * Edit an existing branch. (For now only supports branch renaming)
107
- * @param {string} branch - The current name of the branch to edit.
108
- * @param {object} [options={}] - The branch edit options.
109
- * @param {string} [options.name] - New name for the branch
110
- * @returns {Promise<any>} - The response data.
111
- */
112
- editBranch(branch, { name } = {}) {
113
- return this.request("/branch", {
114
- method: "PATCH",
115
- body: JSON.stringify({ branch, name })
116
- });
117
- }
118
- /**
119
- * Delete an existing branch.
120
- * @param {string} branch - The name of the branch to delete.
121
- * @returns {Promise<any>} - The response data.
122
- */
123
- deleteBranch(branch) {
124
- return this.request("/branch", {
125
- method: "DELETE",
126
- body: JSON.stringify({ branch })
127
- });
128
- }
129
- /**
130
- * Merges a branch into the target branch.
131
- * @param {string} target - The target branch.
132
- * @param {object} [options={}] - The merge options.
133
- * @param {string} [options.message] - A message describing the merge.
134
- * @param {string} [options.source='main'] - The source branch.
135
- * @param {string} [options.type='patch'] - The type of merge.
136
- * @param {string} [options.version] - The version number.
137
- * @param {boolean} [options.commit='false'] - Whether to commit the merge.
138
- * @param {Array} [options.changes] - The changes to apply during the merge.
139
- * @returns {Promise<any>} - The response data.
140
- */
141
- mergeBranch(target, {
142
- message,
143
- source = "main",
144
- type = "patch",
145
- version,
146
- commit = "false",
147
- changes
148
- } = {}) {
149
- return this.request("/merge", {
150
- method: "POST",
151
- body: JSON.stringify({
152
- target,
153
- source,
154
- message,
155
- type,
156
- version,
157
- commit,
158
- changes
159
- })
160
- });
161
- }
162
- /**
163
- * Restores an older version of the project.
164
- * @param {string} version - The version number to restore.
165
- * @param {object} [options={}] - The restore options.
166
- * @param {string} [options.branch='main'] - The branch name.
167
- * @param {string} [options.type='patch'] - The type of restore.
168
- * @param {string} [options.message] - A message describing the restore.
169
- * @returns {Promise<any>} - The response data.
170
- */
171
- restoreVersion(version, { branch = "main", type = "patch", message } = {}) {
172
- return this.request("/restore", {
173
- method: "POST",
174
- body: JSON.stringify({ branch, version, type, message })
175
- });
176
- }
177
- /**
178
- * Publishes an existing version of the project.
179
- * @param {string} version - The version ID/number to publish.
180
- * @param {object} [options={}] - The publishing options.
181
- * @param {string} [options.branch='main'] - The branch name. (Only if version number is provided)
182
- * @returns {Promise<any>} - The response data.
183
- */
184
- publishVersion(version) {
185
- return this.request("/publish", {
186
- method: "POST",
187
- body: JSON.stringify({ version })
188
- });
189
- }
190
- /**
191
- * Retrieves all changes after a specific version.
192
- * @param {object} [options={}] - The changes options.
193
- * @param {string} [options.versionId] - The version ID to publish.
194
- * @param {string} [options.versionValue] - The version ID to publish. (alternative to versionId)
195
- * @param {string} [options.branch] - The branch to publish (Only in combination to versionValue)
196
- * @returns {Promise<any>} - The changes data.
197
- */
198
- getChanges({ versionId, versionValue, branch } = {}) {
199
- return this.request(
200
- `/changes?${new URLSearchParams({
201
- ...versionId ? { versionId } : {},
202
- ...versionValue ? { versionValue } : {},
203
- ...branch ? { branch } : {}
204
- }).toString()}`,
205
- {}
206
- );
207
- }
208
- }
209
- var symstoryClient_default = {
210
- /**
211
- * Creates a new SymstoryClient instance.
212
- * @param {string} appKey - The application key.
213
- * @param {object} options - The options for the client.
214
- * @returns {SymstoryClient} - The SymstoryClient instance.
215
- */
216
- create: (appKey, options) => new SymstoryClient(appKey, options),
217
- /**
218
- * Initializes the Symstory client.
219
- * @param {string} appKey - The application key.
220
- * @param {object} options - The options for the client.
221
- * @returns {SymstoryClient} - The initialized SymstoryClient instance.
222
- */
223
- init(appKey, options) {
224
- this.client = this.create(appKey, options);
225
- return this;
226
- }
227
- };
228
- export {
229
- symstoryClient_default as default
230
- };
@@ -1,150 +0,0 @@
1
- import { BaseService } from './BaseService.js'
2
-
3
- export class AIService extends BaseService {
4
- constructor (config) {
5
- super(config)
6
- this._client = null
7
- this._initialized = false
8
- this._defaultConfig = {
9
- apiUrl: 'https://api.openai.com/v1/engines/text-curie/completions',
10
- temperature: 0.0,
11
- maxTokens: 2000,
12
- headers: {
13
- 'Content-Type': 'application/json'
14
- }
15
- }
16
- }
17
-
18
- init () {
19
- try {
20
- const { appKey, authToken } = this._context
21
-
22
- // Store masked configuration info
23
- this._info = {
24
- config: {
25
- appKey: appKey ? `${appKey.substr(0, 4)}...${appKey.substr(-4)}` : '',
26
- hasToken: Boolean(authToken)
27
- }
28
- }
29
-
30
- this._initialized = true
31
- this._setReady()
32
- } catch (error) {
33
- this._setError(error)
34
- throw error
35
- }
36
- }
37
-
38
- // Helper to check if method requires initialization
39
- _requiresInit (methodName) {
40
- const noInitMethods = new Set(['getConfig', 'validateConfig'])
41
- return !noInitMethods.has(methodName)
42
- }
43
-
44
- // Override _requireReady to be more flexible
45
- _requireReady (methodName) {
46
- if (this._requiresInit(methodName) && !this._initialized) {
47
- throw new Error('AI service not initialized')
48
- }
49
- }
50
-
51
- // Configuration methods
52
- getConfig () {
53
- return {
54
- ...this._defaultConfig,
55
- ...this._context.ai?.config
56
- }
57
- }
58
-
59
- validateConfig (config = {}) {
60
- const requiredFields = ['apiUrl', 'temperature', 'maxTokens']
61
- const missingFields = requiredFields.filter(field => !config[field])
62
-
63
- if (missingFields.length > 0) {
64
- throw new Error(
65
- `Missing required configuration fields: ${missingFields.join(', ')}`
66
- )
67
- }
68
-
69
- return true
70
- }
71
-
72
- // AI Methods
73
- async prompt (query, opts = {}) {
74
- this._requireReady('prompt')
75
-
76
- try {
77
- const config = this.getConfig()
78
- const options = {
79
- method: 'POST',
80
- headers: {
81
- ...config.headers,
82
- Authorization: `Bearer ${this._context.ai?.authToken}`
83
- },
84
- body: JSON.stringify({
85
- prompt: query,
86
- temperature: opts.temperature || config.temperature,
87
- max_tokens: opts.maxTokens || config.maxTokens,
88
- ...opts
89
- })
90
- }
91
-
92
- const response = await this._request(config.apiUrl, options)
93
- return response
94
- } catch (error) {
95
- throw new Error(`AI prompt failed: ${error.message}`)
96
- }
97
- }
98
-
99
- // Helper methods
100
- async _request (url, options = {}) {
101
- try {
102
- const response = await fetch(url, {
103
- ...options,
104
- headers: {
105
- ...this._defaultConfig.headers,
106
- ...options.headers
107
- }
108
- })
109
-
110
- if (!response.ok) {
111
- const error = await response.json()
112
- throw new Error(error.message || 'Request failed')
113
- }
114
-
115
- return response.status === 204 ? null : response.json()
116
- } catch (error) {
117
- throw new Error(`Request failed: ${error.message}`)
118
- }
119
- }
120
-
121
- // Context update methods
122
- updateAuth (authToken) {
123
- this.updateContext({
124
- ai: {
125
- ...this._context.ai,
126
- authToken
127
- }
128
- })
129
- }
130
-
131
- updateConfig (config) {
132
- this.validateConfig(config)
133
- this.updateContext({
134
- ai: {
135
- ...this._context.ai,
136
- config: {
137
- ...this._context.ai?.config,
138
- ...config
139
- }
140
- }
141
- })
142
- }
143
-
144
- // Cleanup
145
- destroy () {
146
- this._client = null
147
- this._initialized = false
148
- this._setReady(false)
149
- }
150
- }