@codacy/codacy-mcp 0.6.1 → 0.6.3
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.
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { AccountService, OrganizationService, RepositoryService } from '../api/client/index.js';
|
|
2
|
+
const ORGANIZATIONS_ITERATION_LIMIT = 5;
|
|
2
3
|
const findOrganization = async (provider, organization, cursor) => {
|
|
3
4
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let currentCursor = cursor;
|
|
6
|
+
let hasMore = true;
|
|
7
|
+
let iteration = 0;
|
|
8
|
+
while (hasMore && iteration < ORGANIZATIONS_ITERATION_LIMIT) {
|
|
9
|
+
const { data: orgs, pagination } = await AccountService.listOrganizations(provider, currentCursor, 100);
|
|
10
|
+
const existingOrg = orgs.find(org => org.name === organization && org.provider === provider);
|
|
11
|
+
if (existingOrg) {
|
|
8
12
|
return {
|
|
9
|
-
success:
|
|
10
|
-
|
|
13
|
+
success: true,
|
|
14
|
+
organization: existingOrg,
|
|
11
15
|
};
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
if (!pagination?.cursor) {
|
|
18
|
+
hasMore = false;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
currentCursor = pagination.cursor;
|
|
22
|
+
}
|
|
23
|
+
iteration++;
|
|
14
24
|
}
|
|
15
25
|
return {
|
|
16
|
-
success:
|
|
17
|
-
|
|
26
|
+
success: false,
|
|
27
|
+
message: 'Organization not found',
|
|
18
28
|
};
|
|
19
29
|
}
|
|
20
30
|
catch (error) {
|