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