@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
@@ -0,0 +1,519 @@
1
+ import { BaseService } from "./BaseService.js";
2
+ class IntegrationService extends BaseService {
3
+ // ==================== INTEGRATION METHODS ====================
4
+ /**
5
+ * Programmatic auth sanity check (API key based).
6
+ *
7
+ * Mirrors: GET /integrations/whoami (requireApiKey)
8
+ *
9
+ * Assumption: backend reads API key from `x-api-key` header.
10
+ * You can override via `options.headers`.
11
+ */
12
+ async integrationWhoami(apiKey, options = {}) {
13
+ this._requireReady("integrationWhoami");
14
+ if (!apiKey) {
15
+ throw new Error("API key is required");
16
+ }
17
+ const headers = {
18
+ "x-api-key": apiKey,
19
+ ...options.headers || {}
20
+ };
21
+ try {
22
+ const response = await this._request("/integrations/whoami", {
23
+ method: "GET",
24
+ headers,
25
+ methodName: "integrationWhoami"
26
+ });
27
+ if (response.success) {
28
+ return response.data;
29
+ }
30
+ throw new Error(response.message);
31
+ } catch (error) {
32
+ throw new Error(`Failed to validate integration API key: ${error.message}`, { cause: error });
33
+ }
34
+ }
35
+ /**
36
+ * List integrations visible to the user.
37
+ *
38
+ * Mirrors: GET /integrations?orgId=&projectId=
39
+ */
40
+ async listIntegrations(options = {}) {
41
+ this._requireReady("listIntegrations");
42
+ const { orgId, projectId } = options || {};
43
+ const queryParams = new URLSearchParams();
44
+ if (orgId != null) {
45
+ queryParams.append("orgId", String(orgId));
46
+ }
47
+ if (projectId != null) {
48
+ queryParams.append("projectId", String(projectId));
49
+ }
50
+ const queryString = queryParams.toString();
51
+ const url = `/integrations${queryString ? `?${queryString}` : ""}`;
52
+ try {
53
+ const response = await this._request(url, {
54
+ method: "GET",
55
+ methodName: "listIntegrations"
56
+ });
57
+ if (response.success) {
58
+ return response.data;
59
+ }
60
+ throw new Error(response.message);
61
+ } catch (error) {
62
+ throw new Error(`Failed to list integrations: ${error.message}`, { cause: error });
63
+ }
64
+ }
65
+ /**
66
+ * Create an integration.
67
+ *
68
+ * Mirrors: POST /integrations
69
+ */
70
+ async createIntegration(data = {}) {
71
+ this._requireReady("createIntegration");
72
+ if (!data || typeof data !== "object") {
73
+ throw new Error("Integration payload is required");
74
+ }
75
+ if (!data.name) {
76
+ throw new Error("Integration name is required");
77
+ }
78
+ if (!data.ownerType) {
79
+ throw new Error("ownerType is required");
80
+ }
81
+ try {
82
+ const response = await this._request("/integrations", {
83
+ method: "POST",
84
+ body: JSON.stringify(data),
85
+ methodName: "createIntegration"
86
+ });
87
+ if (response.success) {
88
+ return response.data;
89
+ }
90
+ throw new Error(response.message);
91
+ } catch (error) {
92
+ throw new Error(`Failed to create integration: ${error.message}`, { cause: error });
93
+ }
94
+ }
95
+ /**
96
+ * Update an integration.
97
+ *
98
+ * Mirrors: PATCH /integrations/:integrationId
99
+ */
100
+ async updateIntegration(integrationId, update = {}) {
101
+ this._requireReady("updateIntegration");
102
+ if (!integrationId) {
103
+ throw new Error("Integration ID is required");
104
+ }
105
+ if (!update || typeof update !== "object") {
106
+ throw new Error("Update payload is required");
107
+ }
108
+ try {
109
+ const response = await this._request(`/integrations/${integrationId}`, {
110
+ method: "PATCH",
111
+ body: JSON.stringify(update),
112
+ methodName: "updateIntegration"
113
+ });
114
+ if (response.success) {
115
+ return response.data;
116
+ }
117
+ throw new Error(response.message);
118
+ } catch (error) {
119
+ throw new Error(`Failed to update integration: ${error.message}`, { cause: error });
120
+ }
121
+ }
122
+ // ==================== INTEGRATION API KEY METHODS ====================
123
+ /**
124
+ * Create a new API key for an integration.
125
+ *
126
+ * Mirrors: POST /integrations/:integrationId/api-keys
127
+ */
128
+ async createIntegrationApiKey(integrationId, data = {}) {
129
+ this._requireReady("createIntegrationApiKey");
130
+ if (!integrationId) {
131
+ throw new Error("Integration ID is required");
132
+ }
133
+ if (!data || typeof data !== "object") {
134
+ throw new Error("API key payload is required");
135
+ }
136
+ try {
137
+ const response = await this._request(`/integrations/${integrationId}/api-keys`, {
138
+ method: "POST",
139
+ body: JSON.stringify(data),
140
+ methodName: "createIntegrationApiKey"
141
+ });
142
+ if (response.success) {
143
+ return response.data;
144
+ }
145
+ throw new Error(response.message);
146
+ } catch (error) {
147
+ throw new Error(`Failed to create integration API key: ${error.message}`, { cause: error });
148
+ }
149
+ }
150
+ /**
151
+ * List API keys for an integration.
152
+ *
153
+ * Mirrors: GET /integrations/:integrationId/api-keys
154
+ */
155
+ async listIntegrationApiKeys(integrationId) {
156
+ this._requireReady("listIntegrationApiKeys");
157
+ if (!integrationId) {
158
+ throw new Error("Integration ID is required");
159
+ }
160
+ try {
161
+ const response = await this._request(`/integrations/${integrationId}/api-keys`, {
162
+ method: "GET",
163
+ methodName: "listIntegrationApiKeys"
164
+ });
165
+ if (response.success) {
166
+ return response.data;
167
+ }
168
+ throw new Error(response.message);
169
+ } catch (error) {
170
+ throw new Error(`Failed to list integration API keys: ${error.message}`, { cause: error });
171
+ }
172
+ }
173
+ /**
174
+ * Revoke an API key for an integration.
175
+ *
176
+ * Mirrors: POST /integrations/:integrationId/api-keys/:keyId/revoke
177
+ */
178
+ async revokeIntegrationApiKey(integrationId, keyId) {
179
+ this._requireReady("revokeIntegrationApiKey");
180
+ if (!integrationId) {
181
+ throw new Error("Integration ID is required");
182
+ }
183
+ if (!keyId) {
184
+ throw new Error("API key ID is required");
185
+ }
186
+ try {
187
+ const response = await this._request(
188
+ `/integrations/${integrationId}/api-keys/${keyId}/revoke`,
189
+ {
190
+ method: "POST",
191
+ methodName: "revokeIntegrationApiKey"
192
+ }
193
+ );
194
+ if (response.success) {
195
+ return response.data;
196
+ }
197
+ throw new Error(response.message);
198
+ } catch (error) {
199
+ throw new Error(`Failed to revoke integration API key: ${error.message}`, { cause: error });
200
+ }
201
+ }
202
+ // ==================== WEBHOOK METHODS ====================
203
+ /**
204
+ * Create a webhook endpoint for an integration.
205
+ *
206
+ * Mirrors: POST /integrations/:integrationId/webhooks
207
+ */
208
+ async createIntegrationWebhook(integrationId, data = {}) {
209
+ this._requireReady("createIntegrationWebhook");
210
+ if (!integrationId) {
211
+ throw new Error("Integration ID is required");
212
+ }
213
+ if (!data || typeof data !== "object") {
214
+ throw new Error("Webhook payload is required");
215
+ }
216
+ try {
217
+ const response = await this._request(`/integrations/${integrationId}/webhooks`, {
218
+ method: "POST",
219
+ body: JSON.stringify(data),
220
+ methodName: "createIntegrationWebhook"
221
+ });
222
+ if (response.success) {
223
+ return response.data;
224
+ }
225
+ throw new Error(response.message);
226
+ } catch (error) {
227
+ throw new Error(`Failed to create integration webhook: ${error.message}`, { cause: error });
228
+ }
229
+ }
230
+ /**
231
+ * List webhook endpoints for an integration.
232
+ *
233
+ * Mirrors: GET /integrations/:integrationId/webhooks
234
+ */
235
+ async listIntegrationWebhooks(integrationId) {
236
+ this._requireReady("listIntegrationWebhooks");
237
+ if (!integrationId) {
238
+ throw new Error("Integration ID is required");
239
+ }
240
+ try {
241
+ const response = await this._request(`/integrations/${integrationId}/webhooks`, {
242
+ method: "GET",
243
+ methodName: "listIntegrationWebhooks"
244
+ });
245
+ if (response.success) {
246
+ return response.data;
247
+ }
248
+ throw new Error(response.message);
249
+ } catch (error) {
250
+ throw new Error(`Failed to list integration webhooks: ${error.message}`, { cause: error });
251
+ }
252
+ }
253
+ /**
254
+ * Update a webhook endpoint for an integration.
255
+ *
256
+ * Mirrors: PATCH /integrations/:integrationId/webhooks/:webhookId
257
+ */
258
+ async updateIntegrationWebhook(integrationId, webhookId, update = {}) {
259
+ this._requireReady("updateIntegrationWebhook");
260
+ if (!integrationId) {
261
+ throw new Error("Integration ID is required");
262
+ }
263
+ if (!webhookId) {
264
+ throw new Error("Webhook ID is required");
265
+ }
266
+ if (!update || typeof update !== "object") {
267
+ throw new Error("Update payload is required");
268
+ }
269
+ try {
270
+ const response = await this._request(
271
+ `/integrations/${integrationId}/webhooks/${webhookId}`,
272
+ {
273
+ method: "PATCH",
274
+ body: JSON.stringify(update),
275
+ methodName: "updateIntegrationWebhook"
276
+ }
277
+ );
278
+ if (response.success) {
279
+ return response.data;
280
+ }
281
+ throw new Error(response.message);
282
+ } catch (error) {
283
+ throw new Error(`Failed to update integration webhook: ${error.message}`, { cause: error });
284
+ }
285
+ }
286
+ /**
287
+ * Delete a webhook endpoint for an integration.
288
+ *
289
+ * Mirrors: DELETE /integrations/:integrationId/webhooks/:webhookId
290
+ */
291
+ async deleteIntegrationWebhook(integrationId, webhookId) {
292
+ this._requireReady("deleteIntegrationWebhook");
293
+ if (!integrationId) {
294
+ throw new Error("Integration ID is required");
295
+ }
296
+ if (!webhookId) {
297
+ throw new Error("Webhook ID is required");
298
+ }
299
+ try {
300
+ const response = await this._request(
301
+ `/integrations/${integrationId}/webhooks/${webhookId}`,
302
+ {
303
+ method: "DELETE",
304
+ methodName: "deleteIntegrationWebhook"
305
+ }
306
+ );
307
+ if (response && response.success) {
308
+ return response.data;
309
+ }
310
+ if (response == null) {
311
+ return null;
312
+ }
313
+ throw new Error(response.message);
314
+ } catch (error) {
315
+ throw new Error(`Failed to delete integration webhook: ${error.message}`, { cause: error });
316
+ }
317
+ }
318
+ /**
319
+ * List webhook deliveries for an integration webhook.
320
+ *
321
+ * Mirrors: GET /integrations/:integrationId/webhooks/:webhookId/deliveries
322
+ */
323
+ async listIntegrationWebhookDeliveries(integrationId, webhookId, options = {}) {
324
+ this._requireReady("listIntegrationWebhookDeliveries");
325
+ if (!integrationId) {
326
+ throw new Error("Integration ID is required");
327
+ }
328
+ if (!webhookId) {
329
+ throw new Error("Webhook ID is required");
330
+ }
331
+ const { page, limit, status, includePayload } = options || {};
332
+ const queryParams = new URLSearchParams();
333
+ if (page != null) {
334
+ queryParams.append("page", String(page));
335
+ }
336
+ if (limit != null) {
337
+ queryParams.append("limit", String(limit));
338
+ }
339
+ if (status != null) {
340
+ queryParams.append("status", String(status));
341
+ }
342
+ if (includePayload != null) {
343
+ queryParams.append("includePayload", String(includePayload));
344
+ }
345
+ const queryString = queryParams.toString();
346
+ const url = `/integrations/${integrationId}/webhooks/${webhookId}/deliveries${queryString ? `?${queryString}` : ""}`;
347
+ try {
348
+ const response = await this._request(url, {
349
+ method: "GET",
350
+ methodName: "listIntegrationWebhookDeliveries"
351
+ });
352
+ if (response.success) {
353
+ return response.data;
354
+ }
355
+ throw new Error(response.message);
356
+ } catch (error) {
357
+ throw new Error(`Failed to list webhook deliveries: ${error.message}`, { cause: error });
358
+ }
359
+ }
360
+ /**
361
+ * Replay a webhook delivery.
362
+ *
363
+ * Mirrors: POST /integrations/:integrationId/webhooks/:webhookId/replay
364
+ * Body: { deliveryId }
365
+ */
366
+ async replayIntegrationWebhookDelivery(integrationId, webhookId, deliveryId) {
367
+ this._requireReady("replayIntegrationWebhookDelivery");
368
+ if (!integrationId) {
369
+ throw new Error("Integration ID is required");
370
+ }
371
+ if (!webhookId) {
372
+ throw new Error("Webhook ID is required");
373
+ }
374
+ if (!deliveryId) {
375
+ throw new Error("deliveryId is required");
376
+ }
377
+ try {
378
+ const response = await this._request(
379
+ `/integrations/${integrationId}/webhooks/${webhookId}/replay`,
380
+ {
381
+ method: "POST",
382
+ body: JSON.stringify({ deliveryId }),
383
+ methodName: "replayIntegrationWebhookDelivery"
384
+ }
385
+ );
386
+ if (response.success) {
387
+ return response.data;
388
+ }
389
+ throw new Error(response.message);
390
+ } catch (error) {
391
+ throw new Error(`Failed to replay webhook delivery: ${error.message}`, { cause: error });
392
+ }
393
+ }
394
+ // ==================== CONNECTOR METHODS (GITHUB) ====================
395
+ /**
396
+ * List GitHub connectors for an integration.
397
+ *
398
+ * Mirrors: GET /integrations/:integrationId/connectors/github
399
+ */
400
+ async listGitHubConnectors(integrationId) {
401
+ this._requireReady("listGitHubConnectors");
402
+ if (!integrationId) {
403
+ throw new Error("Integration ID is required");
404
+ }
405
+ try {
406
+ const response = await this._request(`/integrations/${integrationId}/connectors/github`, {
407
+ method: "GET",
408
+ methodName: "listGitHubConnectors"
409
+ });
410
+ if (response.success) {
411
+ return response.data;
412
+ }
413
+ throw new Error(response.message);
414
+ } catch (error) {
415
+ throw new Error(`Failed to list GitHub connectors: ${error.message}`, { cause: error });
416
+ }
417
+ }
418
+ /**
419
+ * Create a GitHub connector for an integration.
420
+ *
421
+ * Mirrors: POST /integrations/:integrationId/connectors/github
422
+ */
423
+ async createGitHubConnector(integrationId, data = {}) {
424
+ this._requireReady("createGitHubConnector");
425
+ if (!integrationId) {
426
+ throw new Error("Integration ID is required");
427
+ }
428
+ if (!data || typeof data !== "object") {
429
+ throw new Error("Connector payload is required");
430
+ }
431
+ if (!data.projectId) {
432
+ throw new Error("projectId is required");
433
+ }
434
+ if (!data.repository) {
435
+ throw new Error("repository is required");
436
+ }
437
+ try {
438
+ const response = await this._request(`/integrations/${integrationId}/connectors/github`, {
439
+ method: "POST",
440
+ body: JSON.stringify(data),
441
+ methodName: "createGitHubConnector"
442
+ });
443
+ if (response.success) {
444
+ return response.data;
445
+ }
446
+ throw new Error(response.message);
447
+ } catch (error) {
448
+ throw new Error(`Failed to create GitHub connector: ${error.message}`, { cause: error });
449
+ }
450
+ }
451
+ /**
452
+ * Update a GitHub connector.
453
+ *
454
+ * Mirrors: PATCH /integrations/:integrationId/connectors/github/:connectorId
455
+ */
456
+ async updateGitHubConnector(integrationId, connectorId, update = {}) {
457
+ this._requireReady("updateGitHubConnector");
458
+ if (!integrationId) {
459
+ throw new Error("Integration ID is required");
460
+ }
461
+ if (!connectorId) {
462
+ throw new Error("Connector ID is required");
463
+ }
464
+ if (!update || typeof update !== "object") {
465
+ throw new Error("Update payload is required");
466
+ }
467
+ try {
468
+ const response = await this._request(
469
+ `/integrations/${integrationId}/connectors/github/${connectorId}`,
470
+ {
471
+ method: "PATCH",
472
+ body: JSON.stringify(update),
473
+ methodName: "updateGitHubConnector"
474
+ }
475
+ );
476
+ if (response.success) {
477
+ return response.data;
478
+ }
479
+ throw new Error(response.message);
480
+ } catch (error) {
481
+ throw new Error(`Failed to update GitHub connector: ${error.message}`, { cause: error });
482
+ }
483
+ }
484
+ /**
485
+ * Delete a GitHub connector.
486
+ *
487
+ * Mirrors: DELETE /integrations/:integrationId/connectors/github/:connectorId
488
+ */
489
+ async deleteGitHubConnector(integrationId, connectorId) {
490
+ this._requireReady("deleteGitHubConnector");
491
+ if (!integrationId) {
492
+ throw new Error("Integration ID is required");
493
+ }
494
+ if (!connectorId) {
495
+ throw new Error("Connector ID is required");
496
+ }
497
+ try {
498
+ const response = await this._request(
499
+ `/integrations/${integrationId}/connectors/github/${connectorId}`,
500
+ {
501
+ method: "DELETE",
502
+ methodName: "deleteGitHubConnector"
503
+ }
504
+ );
505
+ if (response && response.success) {
506
+ return response.data;
507
+ }
508
+ if (response == null) {
509
+ return null;
510
+ }
511
+ throw new Error(response.message);
512
+ } catch (error) {
513
+ throw new Error(`Failed to delete GitHub connector: ${error.message}`, { cause: error });
514
+ }
515
+ }
516
+ }
517
+ export {
518
+ IntegrationService
519
+ };
@@ -0,0 +1,43 @@
1
+ import { BaseService } from "./BaseService.js";
2
+ class MetricsService extends BaseService {
3
+ // ==================== METRICS METHODS ====================
4
+ /**
5
+ * Contribution heat-map stats.
6
+ *
7
+ * Mirrors: GET /metrics/contributions (MetricsController.getContributions)
8
+ */
9
+ async getContributions(options = {}) {
10
+ this._requireReady("getContributions");
11
+ const { projectId, userId, from, to } = options || {};
12
+ const queryParams = new URLSearchParams();
13
+ if (projectId != null) {
14
+ queryParams.append("projectId", String(projectId));
15
+ }
16
+ if (userId != null) {
17
+ queryParams.append("userId", String(userId));
18
+ }
19
+ if (from != null) {
20
+ queryParams.append("from", String(from));
21
+ }
22
+ if (to != null) {
23
+ queryParams.append("to", String(to));
24
+ }
25
+ const queryString = queryParams.toString();
26
+ const url = `/metrics/contributions${queryString ? `?${queryString}` : ""}`;
27
+ try {
28
+ const response = await this._request(url, {
29
+ method: "GET",
30
+ methodName: "getContributions"
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 get contribution stats: ${error.message}`, { cause: error });
38
+ }
39
+ }
40
+ }
41
+ export {
42
+ MetricsService
43
+ };