@andrebuzeli/git-mcp 4.0.21 → 5.0.0

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 (65) hide show
  1. package/README.md +59 -32
  2. package/dist/config.d.ts +0 -2
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +0 -27
  5. package/dist/config.js.map +1 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +54 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/providers/gitea-provider.d.ts +5 -5
  11. package/dist/providers/gitea-provider.d.ts.map +1 -1
  12. package/dist/providers/gitea-provider.js +75 -220
  13. package/dist/providers/gitea-provider.js.map +1 -1
  14. package/dist/providers/github-provider.d.ts +0 -48
  15. package/dist/providers/github-provider.d.ts.map +1 -1
  16. package/dist/providers/github-provider.js +805 -849
  17. package/dist/providers/github-provider.js.map +1 -1
  18. package/dist/providers/provider-factory.d.ts +1 -1
  19. package/dist/providers/provider-factory.d.ts.map +1 -1
  20. package/dist/providers/provider-factory.js +4 -14
  21. package/dist/providers/provider-factory.js.map +1 -1
  22. package/dist/providers/types.d.ts +1 -1
  23. package/dist/providers/types.d.ts.map +1 -1
  24. package/dist/server.d.ts.map +1 -1
  25. package/dist/server.js +91 -37
  26. package/dist/server.js.map +1 -1
  27. package/dist/tools/git-files.d.ts.map +1 -1
  28. package/dist/tools/git-files.js +103 -5
  29. package/dist/tools/git-files.js.map +1 -1
  30. package/dist/tools/git-sync.d.ts.map +1 -1
  31. package/dist/tools/git-sync.js +104 -6
  32. package/dist/tools/git-sync.js.map +1 -1
  33. package/dist/tools/git-workflow.d.ts +55 -0
  34. package/dist/tools/git-workflow.d.ts.map +1 -1
  35. package/dist/tools/git-workflow.js +660 -7
  36. package/dist/tools/git-workflow.js.map +1 -1
  37. package/dist/utils/auto-detection.js +1 -1
  38. package/dist/utils/auto-detection.js.map +1 -1
  39. package/dist/utils/configuration-error-generator.d.ts +41 -0
  40. package/dist/utils/configuration-error-generator.d.ts.map +1 -0
  41. package/dist/utils/configuration-error-generator.js +168 -0
  42. package/dist/utils/configuration-error-generator.js.map +1 -0
  43. package/dist/utils/configuration-validator.d.ts +67 -0
  44. package/dist/utils/configuration-validator.d.ts.map +1 -0
  45. package/dist/utils/configuration-validator.js +257 -0
  46. package/dist/utils/configuration-validator.js.map +1 -0
  47. package/dist/utils/multi-provider-error-handler.d.ts +75 -0
  48. package/dist/utils/multi-provider-error-handler.d.ts.map +1 -0
  49. package/dist/utils/multi-provider-error-handler.js +276 -0
  50. package/dist/utils/multi-provider-error-handler.js.map +1 -0
  51. package/dist/utils/multi-provider-operation-handler.d.ts +113 -0
  52. package/dist/utils/multi-provider-operation-handler.d.ts.map +1 -0
  53. package/dist/utils/multi-provider-operation-handler.js +303 -0
  54. package/dist/utils/multi-provider-operation-handler.js.map +1 -0
  55. package/dist/utils/operation-error-handler.d.ts +69 -0
  56. package/dist/utils/operation-error-handler.d.ts.map +1 -0
  57. package/dist/utils/operation-error-handler.js +277 -0
  58. package/dist/utils/operation-error-handler.js.map +1 -0
  59. package/dist/utils/provider-operation-handler.d.ts +80 -0
  60. package/dist/utils/provider-operation-handler.d.ts.map +1 -0
  61. package/dist/utils/provider-operation-handler.js +201 -0
  62. package/dist/utils/provider-operation-handler.js.map +1 -0
  63. package/dist/utils/response-helper.js +1 -1
  64. package/dist/utils/response-helper.js.map +1 -1
  65. package/package.json +60 -60
@@ -317,22 +317,35 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
317
317
  return this.normalizeBranch(data);
318
318
  }
319
319
  async createBranch(owner, repo, branchName, fromBranch) {
320
- // GitHub não tem endpoint direto para criar branch, mas podemos usar o endpoint de arquivos
321
- // Para simplicidade, retornamos um mock por enquanto
322
- return {
323
- name: branchName,
324
- commit: {
325
- sha: 'mock-sha',
326
- url: `https://api.github.com/repos/${owner}/${repo}/git/commits/mock-sha`
327
- },
328
- protected: false,
329
- raw: { name: branchName, from: fromBranch }
330
- };
320
+ try {
321
+ // Get the source branch to get the commit SHA
322
+ const sourceBranch = await this.getBranch(owner, repo, fromBranch);
323
+ // Create the new branch reference
324
+ const data = await this.post(`/repos/${owner}/${repo}/git/refs`, {
325
+ ref: `refs/heads/${branchName}`,
326
+ sha: sourceBranch.commit.sha
327
+ });
328
+ return this.normalizeBranch({
329
+ name: branchName,
330
+ commit: {
331
+ sha: sourceBranch.commit.sha,
332
+ url: data.object?.url || `https://api.github.com/repos/${owner}/${repo}/git/commits/${sourceBranch.commit.sha}`
333
+ },
334
+ protected: false
335
+ });
336
+ }
337
+ catch (error) {
338
+ throw new Error(`Failed to create branch '${branchName}': ${error instanceof Error ? error.message : String(error)}`);
339
+ }
331
340
  }
332
341
  async deleteBranch(owner, repo, branch) {
333
- // GitHub não tem endpoint direto para deletar branch
334
- // Retornamos true para simplicidade
335
- return true;
342
+ try {
343
+ await this.delete(`/repos/${owner}/${repo}/git/refs/heads/${branch}`);
344
+ return true;
345
+ }
346
+ catch (error) {
347
+ throw new Error(`Failed to delete branch '${branch}': ${error instanceof Error ? error.message : String(error)}`);
348
+ }
336
349
  }
337
350
  async getFile(owner, repo, path, ref) {
338
351
  const params = ref ? { ref } : {};
@@ -504,35 +517,15 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
504
517
  return this.normalizeRelease(data);
505
518
  }
506
519
  async createRelease(owner, repo, releaseData) {
507
- try {
508
- const data = await this.post(`/repos/${owner}/${repo}/releases`, {
509
- tag_name: releaseData.tag_name,
510
- name: releaseData.name || releaseData.tag_name,
511
- body: releaseData.body || '',
512
- draft: releaseData.draft || false,
513
- prerelease: releaseData.prerelease || false,
514
- target_commitish: releaseData.target_commitish || 'main'
515
- });
516
- return this.normalizeRelease(data);
517
- }
518
- catch (error) {
519
- console.warn('[GITHUB] Falha ao criar release:', error.message);
520
- // Retorna release mock se falhar
521
- return {
522
- id: Date.now(),
523
- tag_name: releaseData.tag_name,
524
- name: releaseData.name || releaseData.tag_name,
525
- body: releaseData.body || '',
526
- draft: releaseData.draft || false,
527
- prerelease: releaseData.prerelease || false,
528
- created_at: new Date().toISOString(),
529
- published_at: releaseData.draft ? undefined : new Date().toISOString(),
530
- html_url: `https://github.com/${owner}/${repo}/releases/tag/${releaseData.tag_name}`,
531
- tarball_url: `https://api.github.com/repos/${owner}/${repo}/tarball/${releaseData.tag_name}`,
532
- zipball_url: `https://api.github.com/repos/${owner}/${repo}/zipball/${releaseData.tag_name}`,
533
- raw: { mock: true, error: error.message }
534
- };
535
- }
520
+ const data = await this.post(`/repos/${owner}/${repo}/releases`, {
521
+ tag_name: releaseData.tag_name,
522
+ name: releaseData.name || releaseData.tag_name,
523
+ body: releaseData.body || '',
524
+ draft: releaseData.draft || false,
525
+ prerelease: releaseData.prerelease || false,
526
+ target_commitish: releaseData.target_commitish || 'main'
527
+ });
528
+ return this.normalizeRelease(data);
536
529
  }
537
530
  async updateRelease(owner, repo, releaseId, updates) {
538
531
  const data = await this.patch(`/repos/${owner}/${repo}/releases/${releaseId}`, updates);
@@ -551,68 +544,36 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
551
544
  return this.normalizeTag(data);
552
545
  }
553
546
  async createTag(owner, repo, tagData) {
554
- try {
555
- // Primeiro cria o objeto tag
556
- const tagObject = await this.post(`/repos/${owner}/${repo}/git/tags`, {
557
- tag: tagData.tag_name,
558
- message: tagData.message || `Tag ${tagData.tag_name}`,
559
- object: tagData.target,
560
- type: 'commit'
561
- });
562
- // Depois cria a referência da tag
563
- const tagRef = await this.post(`/repos/${owner}/${repo}/git/refs`, {
564
- ref: `refs/tags/${tagData.tag_name}`,
565
- sha: tagObject.sha
566
- });
567
- return this.normalizeTag({
568
- name: tagData.tag_name,
569
- commit: {
570
- sha: tagObject.sha,
571
- url: tagObject.url
572
- },
573
- zipball_url: `https://api.github.com/repos/${owner}/${repo}/zipball/${tagData.tag_name}`,
574
- tarball_url: `https://api.github.com/repos/${owner}/${repo}/tarball/${tagData.tag_name}`,
575
- ...tagObject
576
- });
577
- }
578
- catch (error) {
579
- console.warn('[GITHUB] Falha ao criar tag:', error.message);
580
- // Retorna tag mock se falhar
581
- return {
582
- name: tagData.tag_name,
583
- commit: {
584
- sha: 'mock-sha-' + Date.now(),
585
- url: `https://api.github.com/repos/${owner}/${repo}/git/commits/mock-sha`
586
- },
587
- zipball_url: `https://api.github.com/repos/${owner}/${repo}/zipball/${tagData.tag_name}`,
588
- tarball_url: `https://api.github.com/repos/${owner}/${repo}/tarball/${tagData.tag_name}`,
589
- raw: { mock: true, error: error.message }
590
- };
591
- }
547
+ // First create the tag object
548
+ const tagObject = await this.post(`/repos/${owner}/${repo}/git/tags`, {
549
+ tag: tagData.tag_name,
550
+ message: tagData.message || `Tag ${tagData.tag_name}`,
551
+ object: tagData.target,
552
+ type: 'commit'
553
+ });
554
+ // Then create the tag reference
555
+ const tagRef = await this.post(`/repos/${owner}/${repo}/git/refs`, {
556
+ ref: `refs/tags/${tagData.tag_name}`,
557
+ sha: tagObject.sha
558
+ });
559
+ return this.normalizeTag({
560
+ name: tagData.tag_name,
561
+ commit: {
562
+ sha: tagObject.sha,
563
+ url: tagObject.url
564
+ },
565
+ zipball_url: `https://api.github.com/repos/${owner}/${repo}/zipball/${tagData.tag_name}`,
566
+ tarball_url: `https://api.github.com/repos/${owner}/${repo}/tarball/${tagData.tag_name}`,
567
+ ...tagObject
568
+ });
592
569
  }
593
570
  async deleteTag(owner, repo, tag) {
594
571
  await this.delete(`/repos/${owner}/${repo}/git/refs/tags/${tag}`);
595
572
  return true;
596
573
  }
597
574
  async getCurrentUser() {
598
- try {
599
- const data = await this.get('/user');
600
- return this.normalizeUser(data);
601
- }
602
- catch (error) {
603
- // Se falhar, retorna usuário mock para evitar falhas em cascata
604
- console.warn('[GITHUB] Falha ao obter usuário atual:', error.message);
605
- return {
606
- id: 1,
607
- login: 'current-user',
608
- name: 'Usuário Atual',
609
- email: 'user@example.com',
610
- avatar_url: 'https://example.com/avatar.png',
611
- html_url: 'https://example.com/user',
612
- type: 'User',
613
- raw: { mock: true, error: error.message }
614
- };
615
- }
575
+ const data = await this.get('/user');
576
+ return this.normalizeUser(data);
616
577
  }
617
578
  async getUser(username) {
618
579
  const data = await this.get(`/users/${username}`);
@@ -633,59 +594,17 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
633
594
  return data.items.map((user) => this.normalizeUser(user));
634
595
  }
635
596
  async getUserOrganizations(username, page = 1, limit = 30) {
636
- try {
637
- const data = await this.get(`/users/${username}/orgs`, { page, per_page: limit });
638
- return data.map((org) => this.normalizeOrganization(org));
639
- }
640
- catch (error) {
641
- console.warn('[GITHUB] getUserOrganizations falhou:', error.message);
642
- // Retorna dados mockados se falhar
643
- return [{
644
- id: 1,
645
- login: 'mock-org',
646
- name: 'Organização Mock',
647
- description: 'Organização de exemplo',
648
- avatar_url: 'https://example.com/org-avatar.png',
649
- html_url: 'https://example.com/org',
650
- location: 'São Paulo',
651
- website: 'https://example.com',
652
- public_repos: 5,
653
- public_members: 3,
654
- raw: { mock: true, error: error.message }
655
- }];
656
- }
597
+ const data = await this.get(`/users/${username}/orgs`, { page, per_page: limit });
598
+ return data.map((org) => this.normalizeOrganization(org));
657
599
  }
658
600
  async getUserRepositories(username, page = 1, limit = 30) {
659
- try {
660
- const data = await this.get(`/users/${username}/repos`, {
661
- page,
662
- per_page: limit,
663
- sort: 'updated',
664
- direction: 'desc'
665
- });
666
- return data.map((repo) => this.normalizeRepository(repo));
667
- }
668
- catch (error) {
669
- console.warn('[GITHUB] getUserRepositories falhou:', error.message);
670
- // Retorna dados mockados se falhar
671
- return [{
672
- id: 1,
673
- name: 'mock-repo',
674
- full_name: `${username}/mock-repo`,
675
- description: 'Repositório mockado',
676
- private: false,
677
- html_url: 'https://example.com/repo',
678
- clone_url: 'https://example.com/repo.git',
679
- default_branch: 'main',
680
- created_at: new Date().toISOString(),
681
- updated_at: new Date().toISOString(),
682
- owner: {
683
- login: username,
684
- type: 'User'
685
- },
686
- raw: { mock: true, error: error.message }
687
- }];
688
- }
601
+ const data = await this.get(`/users/${username}/repos`, {
602
+ page,
603
+ per_page: limit,
604
+ sort: 'updated',
605
+ direction: 'desc'
606
+ });
607
+ return data.map((repo) => this.normalizeRepository(repo));
689
608
  }
690
609
  async listWebhooks(owner, repo, page = 1, limit = 30) {
691
610
  const data = await this.get(`/repos/${owner}/${repo}/hooks`, { page, per_page: limit });
@@ -774,623 +693,655 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
774
693
  }
775
694
  async getTrafficStats(params) {
776
695
  const { owner, repo, metricType } = params;
777
- try {
778
- let endpoint = '';
779
- switch (metricType) {
780
- case 'views':
781
- endpoint = `/repos/${owner}/${repo}/traffic/views`;
782
- break;
783
- case 'clones':
784
- endpoint = `/repos/${owner}/${repo}/traffic/clones`;
785
- break;
786
- case 'popular':
787
- endpoint = `/repos/${owner}/${repo}/traffic/popular/paths`;
788
- break;
789
- case 'referrers':
790
- endpoint = `/repos/${owner}/${repo}/traffic/popular/referrers`;
791
- break;
792
- default:
793
- endpoint = `/repos/${owner}/${repo}/traffic/views`;
794
- }
795
- return await this.get(endpoint);
796
- }
797
- catch (error) {
798
- // GitHub traffic stats requer permissão especial e pode não estar disponível
799
- return {
800
- error: 'Traffic stats not available',
801
- message: 'Repository traffic statistics require special permissions or may not be available for this repository',
802
- metricType,
803
- available: false
804
- };
805
- }
806
- }
807
- async cloneRepository(params) {
808
- throw new Error('Funcionalidade não suportada por este provider: Provider não implementa cloneRepository');
809
- }
810
- async archiveRepository(params) {
811
- throw new Error('Funcionalidade não suportada por este provider: Provider não implementa archiveRepository');
812
- }
813
- async transferRepository(params) {
814
- const { owner, repo, newOwner } = params;
815
- const data = await this.post(`/repos/${owner}/${repo}/transfer`, { new_owner: newOwner });
816
- return data.owner.login === newOwner;
817
- }
818
- async createFromTemplate(params) {
819
- const { templateOwner, templateRepo, name, ...options } = params;
820
- const data = await this.post(`/repos/${templateOwner}/${templateRepo}/generate`, {
821
- name,
822
- ...options
823
- });
824
- return this.normalizeRepository(data);
825
- }
826
- async mirrorRepository(params) {
827
- throw new Error('Funcionalidade não suportada por este provider: Provider não implementa mirrorRepository');
828
- }
829
- // Implementações para analytics e outras funcionalidades
830
- async analyzeContributors(params) {
831
- const { owner, repo } = params;
832
- try {
833
- const contributors = await this.get(`/repos/${owner}/${repo}/contributors`);
834
- return {
835
- totalContributors: contributors.length,
836
- contributors: contributors.map(c => ({
837
- login: c.login,
838
- contributions: c.contributions,
839
- type: c.type
840
- })),
841
- period: 'all_time'
842
- };
843
- }
844
- catch (error) {
845
- return {
846
- error: 'Contributors analysis failed',
847
- message: 'Could not retrieve contributor information',
848
- available: false
849
- };
850
- }
851
- }
852
- async getActivityStats(params) {
853
- const { owner, repo } = params;
854
- try {
855
- const commits = await this.get(`/repos/${owner}/${repo}/commits?per_page=100`);
856
- const issues = await this.get(`/repos/${owner}/${repo}/issues?state=all&per_page=100`);
857
- return {
858
- recentCommits: commits.length,
859
- totalIssues: issues.length,
860
- openIssues: issues.filter(i => i.state === 'open').length,
861
- closedIssues: issues.filter(i => i.state === 'closed').length,
862
- activity: commits.length > 10 ? 'high' : commits.length > 5 ? 'medium' : 'low'
863
- };
864
- }
865
- catch (error) {
866
- return {
867
- error: 'Activity stats failed',
868
- message: 'Could not retrieve activity information',
869
- available: false
870
- };
871
- }
872
- }
873
- async getRepositoryInsights(params) {
874
- const { owner, repo } = params;
875
- try {
876
- const repoData = await this.get(`/repos/${owner}/${repo}`);
877
- return {
878
- insights: {
879
- stars: repoData.stargazers_count,
880
- forks: repoData.forks_count,
881
- watchers: repoData.watchers_count,
882
- language: repoData.language,
883
- size: repoData.size,
884
- created: repoData.created_at,
885
- updated: repoData.updated_at,
886
- isArchived: repoData.archived,
887
- isDisabled: repoData.disabled,
888
- license: repoData.license?.name,
889
- topics: repoData.topics || []
890
- }
891
- };
892
- }
893
- catch (error) {
894
- return {
895
- error: 'Repository insights failed',
896
- message: 'Could not retrieve repository insights',
897
- available: false
898
- };
899
- }
900
- }
901
- // Implementações para funcionalidades faltantes
902
- async createDeployment(params) {
903
- const { owner, repo, ref, environment, description, task, auto_merge, required_contexts, payload } = params;
904
- try {
905
- const deploymentData = {
906
- ref,
907
- environment: environment || 'production',
908
- description: description || 'Deployment created via API',
909
- auto_merge: auto_merge || false,
910
- required_contexts: required_contexts || []
911
- };
912
- if (task)
913
- deploymentData.task = task;
914
- if (payload)
915
- deploymentData.payload = payload;
916
- const data = await this.post(`/repos/${owner}/${repo}/deployments`, deploymentData);
917
- return {
918
- id: data.id,
919
- ref: data.ref,
920
- environment: data.environment,
921
- description: data.description,
922
- created_at: data.created_at,
923
- statuses_url: data.statuses_url,
924
- repository_url: data.repository_url,
925
- url: data.url
926
- };
927
- }
928
- catch (error) {
929
- throw new Error(`Falha ao criar deployment: ${error instanceof Error ? error.message : String(error)}`);
696
+ let endpoint = '';
697
+ switch (metricType) {
698
+ case 'views':
699
+ endpoint = `/repos/${owner}/${repo}/traffic/views`;
700
+ break;
701
+ case 'clones':
702
+ endpoint = `/repos/${owner}/${repo}/traffic/clones`;
703
+ break;
704
+ case 'popular':
705
+ endpoint = `/repos/${owner}/${repo}/traffic/popular/paths`;
706
+ break;
707
+ case 'referrers':
708
+ endpoint = `/repos/${owner}/${repo}/traffic/popular/referrers`;
709
+ break;
710
+ default:
711
+ endpoint = `/repos/${owner}/${repo}/traffic/views`;
712
+ }
713
+ return await this.get(endpoint);
714
+ error: 'Traffic stats not available',
715
+ message;
716
+ 'Repository traffic statistics require special permissions or may not be available for this repository',
717
+ metricType,
718
+ available;
719
+ false;
720
+ }
721
+ ;
722
+ }
723
+ exports.GitHubProvider = GitHubProvider;
724
+ async;
725
+ cloneRepository(params, any);
726
+ Promise < any > {
727
+ throw: new Error('Funcionalidade não suportada por este provider: Provider não implementa cloneRepository')
728
+ };
729
+ async;
730
+ archiveRepository(params, any);
731
+ Promise < any > {
732
+ throw: new Error('Funcionalidade não suportada por este provider: Provider não implementa archiveRepository')
733
+ };
734
+ async;
735
+ transferRepository(params, any);
736
+ Promise < any > {
737
+ const: { owner, repo, newOwner } = params,
738
+ const: data = await this.post(`/repos/${owner}/${repo}/transfer`, { new_owner: newOwner }),
739
+ return: data.owner.login === newOwner
740
+ };
741
+ async;
742
+ createFromTemplate(params, any);
743
+ Promise < any > {
744
+ const: { templateOwner, templateRepo, name, ...options } = params,
745
+ const: data = await this.post(`/repos/${templateOwner}/${templateRepo}/generate`, {
746
+ name,
747
+ ...options
748
+ }),
749
+ return: this.normalizeRepository(data)
750
+ };
751
+ async;
752
+ mirrorRepository(params, any);
753
+ Promise < any > {
754
+ throw: new Error('Funcionalidade não suportada por este provider: Provider não implementa mirrorRepository')
755
+ };
756
+ // Implementações para analytics e outras funcionalidades
757
+ async;
758
+ analyzeContributors(params, any);
759
+ Promise < any > {
760
+ const: { owner, repo } = params,
761
+ try: {
762
+ const: contributors = await this.get(`/repos/${owner}/${repo}/contributors`),
763
+ return: {
764
+ totalContributors: contributors.length,
765
+ contributors: contributors.map(c => ({
766
+ login: c.login,
767
+ contributions: c.contributions,
768
+ type: c.type
769
+ })),
770
+ period: 'all_time'
930
771
  }
772
+ }, catch(error) {
773
+ return {
774
+ error: 'Contributors analysis failed',
775
+ message: 'Could not retrieve contributor information',
776
+ available: false
777
+ };
931
778
  }
932
- async updateDeploymentStatus(params) {
933
- const { owner, repo, deployment_id, state, log_url, environment_url, description } = params;
934
- try {
935
- const statusData = {
936
- state,
937
- log_url: log_url || '',
938
- environment_url: environment_url || '',
939
- description: description || `Status updated to ${state}`
940
- };
941
- const data = await this.post(`/repos/${owner}/${repo}/deployments/${deployment_id}/statuses`, statusData);
942
- return {
943
- id: data.id,
944
- state: data.state,
945
- description: data.description,
946
- environment: data.environment,
947
- target_url: data.target_url,
948
- log_url: data.log_url,
949
- environment_url: data.environment_url,
950
- created_at: data.created_at,
951
- updated_at: data.updated_at,
952
- deployment_url: data.deployment_url,
953
- repository_url: data.repository_url
954
- };
955
- }
956
- catch (error) {
957
- throw new Error(`Falha ao atualizar status do deployment: ${error instanceof Error ? error.message : String(error)}`);
958
- }
779
+ };
780
+ async;
781
+ getActivityStats(params, any);
782
+ Promise < any > {
783
+ const: { owner, repo } = params,
784
+ try: {
785
+ const: commits = await this.get(`/repos/${owner}/${repo}/commits?per_page=100`),
786
+ const: issues = await this.get(`/repos/${owner}/${repo}/issues?state=all&per_page=100`),
787
+ return: {
788
+ recentCommits: commits.length,
789
+ totalIssues: issues.length,
790
+ openIssues: issues.filter(i => i.state === 'open').length,
791
+ closedIssues: issues.filter(i => i.state === 'closed').length,
792
+ activity: commits.length > 10 ? 'high' : commits.length > 5 ? 'medium' : 'low'
793
+ }
794
+ }, catch(error) {
795
+ return {
796
+ error: 'Activity stats failed',
797
+ message: 'Could not retrieve activity information',
798
+ available: false
799
+ };
959
800
  }
960
- async manageSecurityAlerts(params) {
961
- const { owner, repo, action, alert_number, dismiss_reason, dismiss_comment } = params;
962
- try {
963
- if (action === 'dismiss') {
964
- const dismissData = {
965
- dismissed_reason: dismiss_reason || 'tolerable_risk'
966
- };
967
- if (dismiss_comment)
968
- dismissData.dismissed_comment = dismiss_comment;
969
- const data = await this.patch(`/repos/${owner}/${repo}/dependabot/alerts/${alert_number}`, dismissData);
970
- return {
971
- number: data.number,
972
- state: data.state,
973
- dismissed_reason: data.dismissed_reason,
974
- dismissed_comment: data.dismissed_comment,
975
- dismissed_at: data.dismissed_at,
976
- dismissed_by: data.dismissed_by
977
- };
978
- }
979
- else if (action === 'reopen') {
980
- const data = await this.patch(`/repos/${owner}/${repo}/dependabot/alerts/${alert_number}`, {
981
- state: 'open'
982
- });
983
- return {
984
- number: data.number,
985
- state: data.state,
986
- created_at: data.created_at,
987
- updated_at: data.updated_at
988
- };
801
+ };
802
+ async;
803
+ getRepositoryInsights(params, any);
804
+ Promise < any > {
805
+ const: { owner, repo } = params,
806
+ try: {
807
+ const: repoData = await this.get(`/repos/${owner}/${repo}`),
808
+ return: {
809
+ insights: {
810
+ stars: repoData.stargazers_count,
811
+ forks: repoData.forks_count,
812
+ watchers: repoData.watchers_count,
813
+ language: repoData.language,
814
+ size: repoData.size,
815
+ created: repoData.created_at,
816
+ updated: repoData.updated_at,
817
+ isArchived: repoData.archived,
818
+ isDisabled: repoData.disabled,
819
+ license: repoData.license?.name,
820
+ topics: repoData.topics || []
989
821
  }
990
- else {
991
- throw new Error(`Ação não suportada: ${action}`);
992
- }
993
- }
994
- catch (error) {
995
- throw new Error(`Falha ao gerenciar alertas de segurança: ${error instanceof Error ? error.message : String(error)}`);
996
- }
997
- }
998
- async listSecurityVulnerabilities(params) {
999
- const { owner, repo, state, severity, ecosystem, package_name } = params;
1000
- try {
1001
- const queryParams = {};
1002
- if (state)
1003
- queryParams.state = state;
1004
- if (severity)
1005
- queryParams.severity = severity;
1006
- if (ecosystem)
1007
- queryParams.ecosystem = ecosystem;
1008
- if (package_name)
1009
- queryParams.package = package_name;
1010
- const data = await this.get(`/repos/${owner}/${repo}/dependabot/alerts`, queryParams);
1011
- return {
1012
- total_count: data.length,
1013
- vulnerabilities: data.map(alert => ({
1014
- number: alert.number,
1015
- state: alert.state,
1016
- severity: alert.security_advisory?.severity,
1017
- summary: alert.security_advisory?.summary,
1018
- description: alert.security_advisory?.description,
1019
- created_at: alert.created_at,
1020
- updated_at: alert.updated_at,
1021
- dismissed_at: alert.dismissed_at,
1022
- dismissed_reason: alert.dismissed_reason,
1023
- dismissed_comment: alert.dismissed_comment,
1024
- dismissed_by: alert.dismissed_by,
1025
- dependency: {
1026
- package: alert.dependency?.package?.name,
1027
- ecosystem: alert.dependency?.package?.ecosystem,
1028
- manifest_path: alert.dependency?.manifest_path
1029
- }
1030
- }))
1031
- };
1032
- }
1033
- catch (error) {
1034
- return {
1035
- total_count: 0,
1036
- vulnerabilities: [],
1037
- note: 'Vulnerabilidades não disponíveis neste provider'
1038
- };
1039
- }
1040
- }
1041
- async createWorkflow(params) {
1042
- const { owner, repo, name, description, workflow_content } = params;
1043
- try {
1044
- // Criar o arquivo de workflow
1045
- const workflowPath = `.github/workflows/${name.toLowerCase().replace(/\s+/g, '-')}.yml`;
1046
- const data = await this.createFile(owner, repo, workflowPath, workflow_content, `Add ${name} workflow`);
1047
- return {
1048
- id: `workflow-${Date.now()}`,
1049
- name,
1050
- path: workflowPath,
1051
- state: 'active',
1052
- created_at: new Date().toISOString(),
1053
- updated_at: new Date().toISOString(),
1054
- url: data.html_url,
1055
- html_url: data.html_url
1056
- };
1057
- }
1058
- catch (error) {
1059
- throw new Error(`Falha ao criar workflow: ${error instanceof Error ? error.message : String(error)}`);
1060
- }
1061
- }
1062
- async triggerWorkflow(params) {
1063
- const { owner, repo, workflow_id, ref, inputs } = params;
1064
- try {
1065
- const triggerData = {
1066
- ref: ref || 'main'
1067
- };
1068
- if (inputs)
1069
- triggerData.inputs = inputs;
1070
- const data = await this.post(`/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`, triggerData);
1071
- return {
1072
- success: true,
1073
- message: 'Workflow triggered successfully',
1074
- workflow_id,
1075
- ref,
1076
- inputs
1077
- };
1078
- }
1079
- catch (error) {
1080
- throw new Error(`Falha ao disparar workflow: ${error instanceof Error ? error.message : String(error)}`);
1081
- }
1082
- }
1083
- async getWorkflowStatus(params) {
1084
- const { owner, repo, run_id } = params;
1085
- try {
1086
- const data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}`);
1087
- return {
1088
- id: data.id,
1089
- name: data.name,
1090
- status: data.status,
1091
- conclusion: data.conclusion,
1092
- workflow_id: data.workflow_id,
1093
- head_branch: data.head_branch,
1094
- head_sha: data.head_sha,
1095
- run_number: data.run_number,
1096
- event: data.event,
1097
- created_at: data.created_at,
1098
- updated_at: data.updated_at,
1099
- run_started_at: data.run_started_at,
1100
- jobs_url: data.jobs_url,
1101
- logs_url: data.logs_url,
1102
- check_suite_url: data.check_suite_url,
1103
- artifacts_url: data.artifacts_url,
1104
- cancel_url: data.cancel_url,
1105
- rerun_url: data.rerun_url,
1106
- workflow_url: data.workflow_url,
1107
- head_commit: data.head_commit,
1108
- repository: data.repository,
1109
- head_repository: data.head_repository
1110
- };
1111
- }
1112
- catch (error) {
1113
- throw new Error(`Falha ao obter status do workflow: ${error instanceof Error ? error.message : String(error)}`);
1114
822
  }
823
+ }, catch(error) {
824
+ return {
825
+ error: 'Repository insights failed',
826
+ message: 'Could not retrieve repository insights',
827
+ available: false
828
+ };
1115
829
  }
1116
- async getWorkflowLogs(params) {
1117
- const { owner, repo, run_id, job_id, step_number } = params;
1118
- try {
1119
- let endpoint = `/repos/${owner}/${repo}/actions/runs/${run_id}/logs`;
1120
- if (job_id) {
1121
- endpoint = `/repos/${owner}/${repo}/actions/jobs/${job_id}/logs`;
1122
- if (step_number) {
1123
- endpoint += `?step=${step_number}`;
830
+ };
831
+ // Implementações para funcionalidades faltantes
832
+ async;
833
+ createDeployment(params, any);
834
+ Promise < any > {
835
+ const: { owner, repo, ref, environment, description, task, auto_merge, required_contexts, payload } = params,
836
+ try: {
837
+ const: deploymentData, any = {
838
+ ref,
839
+ environment: environment || 'production',
840
+ description: description || 'Deployment created via API',
841
+ auto_merge: auto_merge || false,
842
+ required_contexts: required_contexts || []
843
+ },
844
+ if(task) { }, deploymentData, : .task = task,
845
+ if(payload) { }, deploymentData, : .payload = payload,
846
+ const: data = await this.post(`/repos/${owner}/${repo}/deployments`, deploymentData),
847
+ return: {
848
+ id: data.id,
849
+ ref: data.ref,
850
+ environment: data.environment,
851
+ description: data.description,
852
+ created_at: data.created_at,
853
+ statuses_url: data.statuses_url,
854
+ repository_url: data.repository_url,
855
+ url: data.url
856
+ }
857
+ }, catch(error) {
858
+ throw new Error(`Falha ao criar deployment: ${error instanceof Error ? error.message : String(error)}`);
859
+ }
860
+ };
861
+ async;
862
+ updateDeploymentStatus(params, any);
863
+ Promise < any > {
864
+ const: { owner, repo, deployment_id, state, log_url, environment_url, description } = params,
865
+ try: {
866
+ const: statusData, any = {
867
+ state,
868
+ log_url: log_url || '',
869
+ environment_url: environment_url || '',
870
+ description: description || `Status updated to ${state}`
871
+ },
872
+ const: data = await this.post(`/repos/${owner}/${repo}/deployments/${deployment_id}/statuses`, statusData),
873
+ return: {
874
+ id: data.id,
875
+ state: data.state,
876
+ description: data.description,
877
+ environment: data.environment,
878
+ target_url: data.target_url,
879
+ log_url: data.log_url,
880
+ environment_url: data.environment_url,
881
+ created_at: data.created_at,
882
+ updated_at: data.updated_at,
883
+ deployment_url: data.deployment_url,
884
+ repository_url: data.repository_url
885
+ }
886
+ }, catch(error) {
887
+ throw new Error(`Falha ao atualizar status do deployment: ${error instanceof Error ? error.message : String(error)}`);
888
+ }
889
+ };
890
+ async;
891
+ manageSecurityAlerts(params, any);
892
+ Promise < any > {
893
+ const: { owner, repo, action, alert_number, dismiss_reason, dismiss_comment } = params,
894
+ try: {
895
+ if(action) { }
896
+ } === 'dismiss'
897
+ };
898
+ {
899
+ const dismissData = {
900
+ dismissed_reason: dismiss_reason || 'tolerable_risk'
901
+ };
902
+ if (dismiss_comment)
903
+ dismissData.dismissed_comment = dismiss_comment;
904
+ const data = await this.patch(`/repos/${owner}/${repo}/dependabot/alerts/${alert_number}`, dismissData);
905
+ return {
906
+ number: data.number,
907
+ state: data.state,
908
+ dismissed_reason: data.dismissed_reason,
909
+ dismissed_comment: data.dismissed_comment,
910
+ dismissed_at: data.dismissed_at,
911
+ dismissed_by: data.dismissed_by
912
+ };
913
+ }
914
+ if (action === 'reopen') {
915
+ const data = await this.patch(`/repos/${owner}/${repo}/dependabot/alerts/${alert_number}`, {
916
+ state: 'open'
917
+ });
918
+ return {
919
+ number: data.number,
920
+ state: data.state,
921
+ created_at: data.created_at,
922
+ updated_at: data.updated_at
923
+ };
924
+ }
925
+ else {
926
+ throw new Error(`Ação não suportada: ${action}`);
927
+ }
928
+ try { }
929
+ catch (error) {
930
+ throw new Error(`Falha ao gerenciar alertas de segurança: ${error instanceof Error ? error.message : String(error)}`);
931
+ }
932
+ async;
933
+ listSecurityVulnerabilities(params, any);
934
+ Promise < any > {
935
+ const: { owner, repo, state, severity, ecosystem, package_name } = params,
936
+ try: {
937
+ const: queryParams, any = {},
938
+ if(state) { }, queryParams, : .state = state,
939
+ if(severity) { }, queryParams, : .severity = severity,
940
+ if(ecosystem) { }, queryParams, : .ecosystem = ecosystem,
941
+ if(package_name) { }, queryParams, : .package = package_name,
942
+ const: data = await this.get(`/repos/${owner}/${repo}/dependabot/alerts`, queryParams),
943
+ return: {
944
+ total_count: data.length,
945
+ vulnerabilities: data.map(alert => ({
946
+ number: alert.number,
947
+ state: alert.state,
948
+ severity: alert.security_advisory?.severity,
949
+ summary: alert.security_advisory?.summary,
950
+ description: alert.security_advisory?.description,
951
+ created_at: alert.created_at,
952
+ updated_at: alert.updated_at,
953
+ dismissed_at: alert.dismissed_at,
954
+ dismissed_reason: alert.dismissed_reason,
955
+ dismissed_comment: alert.dismissed_comment,
956
+ dismissed_by: alert.dismissed_by,
957
+ dependency: {
958
+ package: alert.dependency?.package?.name,
959
+ ecosystem: alert.dependency?.package?.ecosystem,
960
+ manifest_path: alert.dependency?.manifest_path
1124
961
  }
1125
- }
1126
- const data = await this.get(endpoint);
1127
- return {
1128
- logs: data,
1129
- run_id,
1130
- job_id,
1131
- step_number,
1132
- downloaded_at: new Date().toISOString()
1133
- };
1134
- }
1135
- catch (error) {
1136
- throw new Error(`Falha ao obter logs do workflow: ${error instanceof Error ? error.message : String(error)}`);
1137
- }
1138
- }
1139
- async listWorkflowArtifacts(params) {
1140
- const { owner, repo, run_id } = params;
1141
- try {
1142
- const data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}/artifacts`);
1143
- return {
1144
- total_count: data.total_count,
1145
- artifacts: data.artifacts.map((artifact) => ({
1146
- id: artifact.id,
1147
- node_id: artifact.node_id,
1148
- name: artifact.name,
1149
- size_in_bytes: artifact.size_in_bytes,
1150
- url: artifact.url,
1151
- archive_download_url: artifact.archive_download_url,
1152
- expired: artifact.expired,
1153
- created_at: artifact.created_at,
1154
- updated_at: artifact.updated_at,
1155
- expires_at: artifact.expires_at
1156
- }))
1157
- };
1158
- }
1159
- catch (error) {
1160
- return {
1161
- total_count: 0,
1162
- artifacts: [],
1163
- note: 'Artefatos não disponíveis'
1164
- };
1165
- }
1166
- }
1167
- async downloadArtifact(params) {
1168
- const { owner, repo, artifact_id, download_path } = params;
1169
- try {
1170
- const data = await this.get(`/repos/${owner}/${repo}/actions/artifacts/${artifact_id}/zip`);
1171
- return {
1172
- success: true,
1173
- artifact_id,
1174
- download_path,
1175
- downloaded_at: new Date().toISOString(),
1176
- message: 'Artefato baixado com sucesso'
1177
- };
1178
- }
1179
- catch (error) {
1180
- throw new Error(`Falha ao baixar artefato: ${error instanceof Error ? error.message : String(error)}`);
1181
- }
1182
- }
1183
- async listSecrets(params) {
1184
- const { owner, repo } = params;
1185
- try {
1186
- const data = await this.get(`/repos/${owner}/${repo}/actions/secrets`);
1187
- return {
1188
- total_count: data.total_count,
1189
- secrets: data.secrets.map((secret) => ({
1190
- name: secret.name,
1191
- created_at: secret.created_at,
1192
- updated_at: secret.updated_at
1193
- }))
1194
- };
1195
- }
1196
- catch (error) {
1197
- return {
1198
- total_count: 0,
1199
- secrets: [],
1200
- note: 'Secrets não disponíveis'
1201
- };
1202
- }
1203
- }
1204
- async listJobs(params) {
1205
- const { owner, repo, run_id } = params;
1206
- try {
1207
- const data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}/jobs`);
1208
- return {
1209
- total_count: data.total_count,
1210
- jobs: data.jobs.map((job) => ({
1211
- id: job.id,
1212
- run_id: job.run_id,
1213
- run_url: job.run_url,
1214
- node_id: job.node_id,
1215
- head_sha: job.head_sha,
1216
- url: job.url,
1217
- html_url: job.html_url,
1218
- status: job.status,
1219
- conclusion: job.conclusion,
1220
- started_at: job.started_at,
1221
- completed_at: job.completed_at,
1222
- name: job.name,
1223
- steps: job.steps,
1224
- check_run_url: job.check_run_url,
1225
- labels: job.labels,
1226
- runner_id: job.runner_id,
1227
- runner_name: job.runner_name,
1228
- runner_group_id: job.runner_group_id,
1229
- runner_group_name: job.runner_group_name
1230
- }))
1231
- };
1232
- }
1233
- catch (error) {
1234
- return {
1235
- total_count: 0,
1236
- jobs: [],
1237
- note: 'Jobs não disponíveis'
1238
- };
1239
- }
1240
- }
1241
- /**
1242
- * Compara dois commits
1243
- */
1244
- async compareCommits(owner, repo, base, head) {
1245
- try {
1246
- const response = await this.get(`/repos/${owner}/${repo}/compare/${base}...${head}`);
1247
- return {
1248
- status: response.status,
1249
- ahead_by: response.ahead_by || 0,
1250
- behind_by: response.behind_by || 0,
1251
- total_commits: response.total_commits || 0,
1252
- commits: response.commits || [],
1253
- files: response.files || [],
1254
- merge_base_commit: response.merge_base_commit || null
1255
- };
1256
- }
1257
- catch (error) {
1258
- throw new Error(`Erro ao comparar commits: ${error instanceof Error ? error.message : String(error)}`);
1259
- }
1260
- }
1261
- /**
1262
- * Compara duas branches
1263
- */
1264
- async compareBranches(owner, repo, baseBranch, headBranch) {
1265
- try {
1266
- return await this.compareCommits(owner, repo, baseBranch, headBranch);
1267
- }
1268
- catch (error) {
1269
- throw new Error(`Erro ao comparar branches: ${error instanceof Error ? error.message : String(error)}`);
1270
- }
1271
- }
1272
- /**
1273
- * Obtém URL do repositório GitHub
1274
- */
1275
- getRepositoryUrl(owner, repo) {
1276
- return `https://github.com/${owner}/${repo}.git`;
1277
- }
1278
- // Packages - GitHub tem suporte completo para packages
1279
- async listPackages(owner, repo, page = 1, limit = 30) {
1280
- try {
1281
- const data = await this.get(`/repos/${owner}/${repo}/packages`, {
1282
- package_type: 'npm', // Default to npm packages
1283
- page,
1284
- per_page: limit
1285
- });
1286
- return data.map((pkg) => ({
1287
- id: pkg.id.toString(),
1288
- name: pkg.name,
1289
- version: pkg.version || 'latest',
1290
- description: pkg.description || '',
1291
- type: pkg.package_type || 'npm',
1292
- html_url: pkg.html_url || `https://github.com/${owner}/${repo}/packages/${pkg.package_type}/${pkg.name}`,
1293
- created_at: pkg.created_at,
1294
- updated_at: pkg.updated_at,
1295
- downloads_count: pkg.downloads_count || 0,
1296
- size: pkg.size_in_bytes || 0,
1297
- raw: pkg
1298
- }));
1299
- }
1300
- catch (error) {
1301
- console.warn('[GITHUB] Erro ao listar packages:', error.message);
1302
- return [];
1303
- }
1304
- }
1305
- async getPackage(owner, repo, packageId) {
1306
- try {
1307
- const data = await this.get(`/repos/${owner}/${repo}/packages/${packageId}`);
1308
- return {
1309
- id: data.id.toString(),
1310
- name: data.name,
1311
- version: data.version || 'latest',
1312
- description: data.description || '',
1313
- type: data.package_type || 'npm',
1314
- html_url: data.html_url || `https://github.com/${owner}/${repo}/packages/${data.package_type}/${data.name}`,
1315
- created_at: data.created_at,
1316
- updated_at: data.updated_at,
1317
- downloads_count: data.downloads_count || 0,
1318
- size: data.size_in_bytes || 0,
1319
- raw: data
1320
- };
1321
- }
1322
- catch (error) {
1323
- throw new Error(`Pacote não encontrado: ${error.message}`);
1324
- }
1325
- }
1326
- async createPackage(owner, repo, packageData) {
1327
- try {
1328
- // GitHub packages são criados automaticamente ao fazer publish
1329
- // Esta é uma operação simulada
1330
- console.warn('[GITHUB] Pacotes são criados automaticamente ao fazer publish. Esta operação é simulada.');
1331
- return {
1332
- id: Date.now().toString(),
1333
- name: packageData.name,
1334
- version: packageData.version || '1.0.0',
1335
- description: packageData.description || '',
1336
- type: packageData.type || 'npm',
1337
- html_url: `https://github.com/${owner}/${repo}/packages/${packageData.type}/${packageData.name}`,
1338
- created_at: new Date().toISOString(),
1339
- updated_at: new Date().toISOString(),
1340
- downloads_count: 0,
1341
- size: 0,
1342
- raw: packageData
1343
- };
1344
- }
1345
- catch (error) {
1346
- throw new Error(`Não foi possível criar pacote: ${error.message}`);
962
+ }))
1347
963
  }
964
+ }, catch(error) {
965
+ return {
966
+ total_count: 0,
967
+ vulnerabilities: [],
968
+ note: 'Vulnerabilidades não disponíveis neste provider'
969
+ };
1348
970
  }
1349
- async updatePackage(owner, repo, packageId, updates) {
1350
- try {
1351
- // GitHub packages têm metadados limitados para atualização
1352
- console.warn('[GITHUB] Atualização de packages é limitada no GitHub.');
1353
- throw new Error('GitHub não suporta atualização direta de metadados de packages');
1354
- }
1355
- catch (error) {
1356
- throw new Error(`Não foi possível atualizar pacote: ${error.message}`);
1357
- }
971
+ };
972
+ async;
973
+ createWorkflow(params, any);
974
+ Promise < any > {
975
+ const: { owner, repo, name, description, workflow_content } = params,
976
+ try: {
977
+ // Criar o arquivo de workflow
978
+ const: workflowPath = `.github/workflows/${name.toLowerCase().replace(/\s+/g, '-')}.yml`,
979
+ const: data = await this.createFile(owner, repo, workflowPath, workflow_content, `Add ${name} workflow`),
980
+ return: {
981
+ id: `workflow-${Date.now()}`,
982
+ name,
983
+ path: workflowPath,
984
+ state: 'active',
985
+ created_at: new Date().toISOString(),
986
+ updated_at: new Date().toISOString(),
987
+ url: data.html_url,
988
+ html_url: data.html_url
989
+ }
990
+ }, catch(error) {
991
+ throw new Error(`Falha ao criar workflow: ${error instanceof Error ? error.message : String(error)}`);
992
+ }
993
+ };
994
+ async;
995
+ triggerWorkflow(params, any);
996
+ Promise < any > {
997
+ const: { owner, repo, workflow_id, ref, inputs } = params,
998
+ try: {
999
+ const: triggerData, any = {
1000
+ ref: ref || 'main'
1001
+ },
1002
+ if(inputs) { }, triggerData, : .inputs = inputs,
1003
+ const: data = await this.post(`/repos/${owner}/${repo}/actions/workflows/${workflow_id}/dispatches`, triggerData),
1004
+ return: {
1005
+ success: true,
1006
+ message: 'Workflow triggered successfully',
1007
+ workflow_id,
1008
+ ref,
1009
+ inputs
1010
+ }
1011
+ }, catch(error) {
1012
+ throw new Error(`Falha ao disparar workflow: ${error instanceof Error ? error.message : String(error)}`);
1013
+ }
1014
+ };
1015
+ async;
1016
+ getWorkflowStatus(params, any);
1017
+ Promise < any > {
1018
+ const: { owner, repo, run_id } = params,
1019
+ try: {
1020
+ const: data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}`),
1021
+ return: {
1022
+ id: data.id,
1023
+ name: data.name,
1024
+ status: data.status,
1025
+ conclusion: data.conclusion,
1026
+ workflow_id: data.workflow_id,
1027
+ head_branch: data.head_branch,
1028
+ head_sha: data.head_sha,
1029
+ run_number: data.run_number,
1030
+ event: data.event,
1031
+ created_at: data.created_at,
1032
+ updated_at: data.updated_at,
1033
+ run_started_at: data.run_started_at,
1034
+ jobs_url: data.jobs_url,
1035
+ logs_url: data.logs_url,
1036
+ check_suite_url: data.check_suite_url,
1037
+ artifacts_url: data.artifacts_url,
1038
+ cancel_url: data.cancel_url,
1039
+ rerun_url: data.rerun_url,
1040
+ workflow_url: data.workflow_url,
1041
+ head_commit: data.head_commit,
1042
+ repository: data.repository,
1043
+ head_repository: data.head_repository
1044
+ }
1045
+ }, catch(error) {
1046
+ throw new Error(`Falha ao obter status do workflow: ${error instanceof Error ? error.message : String(error)}`);
1047
+ }
1048
+ };
1049
+ async;
1050
+ getWorkflowLogs(params, any);
1051
+ Promise < any > {
1052
+ const: { owner, repo, run_id, job_id, step_number } = params,
1053
+ try: {
1054
+ let, endpoint = `/repos/${owner}/${repo}/actions/runs/${run_id}/logs`,
1055
+ if(job_id) {
1056
+ endpoint = `/repos/${owner}/${repo}/actions/jobs/${job_id}/logs`;
1057
+ if (step_number) {
1058
+ endpoint += `?step=${step_number}`;
1059
+ }
1060
+ },
1061
+ const: data = await this.get(endpoint),
1062
+ return: {
1063
+ logs: data,
1064
+ run_id,
1065
+ job_id,
1066
+ step_number,
1067
+ downloaded_at: new Date().toISOString()
1068
+ }
1069
+ }, catch(error) {
1070
+ throw new Error(`Falha ao obter logs do workflow: ${error instanceof Error ? error.message : String(error)}`);
1071
+ }
1072
+ };
1073
+ async;
1074
+ listWorkflowArtifacts(params, any);
1075
+ Promise < any > {
1076
+ const: { owner, repo, run_id } = params,
1077
+ try: {
1078
+ const: data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}/artifacts`),
1079
+ return: {
1080
+ total_count: data.total_count,
1081
+ artifacts: data.artifacts.map((artifact) => ({
1082
+ id: artifact.id,
1083
+ node_id: artifact.node_id,
1084
+ name: artifact.name,
1085
+ size_in_bytes: artifact.size_in_bytes,
1086
+ url: artifact.url,
1087
+ archive_download_url: artifact.archive_download_url,
1088
+ expired: artifact.expired,
1089
+ created_at: artifact.created_at,
1090
+ updated_at: artifact.updated_at,
1091
+ expires_at: artifact.expires_at
1092
+ }))
1093
+ }
1094
+ }, catch(error) {
1095
+ return {
1096
+ total_count: 0,
1097
+ artifacts: [],
1098
+ note: 'Artefatos não disponíveis'
1099
+ };
1358
1100
  }
1359
- async deletePackage(owner, repo, packageId) {
1360
- try {
1361
- await this.delete(`/repos/${owner}/${repo}/packages/${packageId}`);
1362
- return true;
1363
- }
1364
- catch (error) {
1365
- throw new Error(`Não foi possível deletar pacote: ${error.message}`);
1366
- }
1101
+ };
1102
+ async;
1103
+ downloadArtifact(params, any);
1104
+ Promise < any > {
1105
+ const: { owner, repo, artifact_id, download_path } = params,
1106
+ try: {
1107
+ const: data = await this.get(`/repos/${owner}/${repo}/actions/artifacts/${artifact_id}/zip`),
1108
+ return: {
1109
+ success: true,
1110
+ artifact_id,
1111
+ download_path,
1112
+ downloaded_at: new Date().toISOString(),
1113
+ message: 'Artefato baixado com sucesso'
1114
+ }
1115
+ }, catch(error) {
1116
+ throw new Error(`Falha ao baixar artefato: ${error instanceof Error ? error.message : String(error)}`);
1117
+ }
1118
+ };
1119
+ async;
1120
+ listSecrets(params, any);
1121
+ Promise < any > {
1122
+ const: { owner, repo } = params,
1123
+ try: {
1124
+ const: data = await this.get(`/repos/${owner}/${repo}/actions/secrets`),
1125
+ return: {
1126
+ total_count: data.total_count,
1127
+ secrets: data.secrets.map((secret) => ({
1128
+ name: secret.name,
1129
+ created_at: secret.created_at,
1130
+ updated_at: secret.updated_at
1131
+ }))
1132
+ }
1133
+ }, catch(error) {
1134
+ return {
1135
+ total_count: 0,
1136
+ secrets: [],
1137
+ note: 'Secrets não disponíveis'
1138
+ };
1367
1139
  }
1368
- async publishPackage(owner, repo, packageId) {
1369
- try {
1370
- console.warn('[GITHUB] Publish de packages é feito automaticamente via GitHub Actions ou CLI.');
1371
- // Esta é uma operação simulada - na prática seria feito via Actions
1372
- return true;
1373
- }
1374
- catch (error) {
1375
- throw new Error(`Não foi possível publicar pacote: ${error.message}`);
1376
- }
1140
+ };
1141
+ async;
1142
+ listJobs(params, any);
1143
+ Promise < any > {
1144
+ const: { owner, repo, run_id } = params,
1145
+ try: {
1146
+ const: data = await this.get(`/repos/${owner}/${repo}/actions/runs/${run_id}/jobs`),
1147
+ return: {
1148
+ total_count: data.total_count,
1149
+ jobs: data.jobs.map((job) => ({
1150
+ id: job.id,
1151
+ run_id: job.run_id,
1152
+ run_url: job.run_url,
1153
+ node_id: job.node_id,
1154
+ head_sha: job.head_sha,
1155
+ url: job.url,
1156
+ html_url: job.html_url,
1157
+ status: job.status,
1158
+ conclusion: job.conclusion,
1159
+ started_at: job.started_at,
1160
+ completed_at: job.completed_at,
1161
+ name: job.name,
1162
+ steps: job.steps,
1163
+ check_run_url: job.check_run_url,
1164
+ labels: job.labels,
1165
+ runner_id: job.runner_id,
1166
+ runner_name: job.runner_name,
1167
+ runner_group_id: job.runner_group_id,
1168
+ runner_group_name: job.runner_group_name
1169
+ }))
1170
+ }
1171
+ }, catch(error) {
1172
+ return {
1173
+ total_count: 0,
1174
+ jobs: [],
1175
+ note: 'Jobs não disponíveis'
1176
+ };
1377
1177
  }
1378
- async downloadPackage(owner, repo, packageId) {
1379
- try {
1380
- // GitHub packages podem ser baixados via npm, yarn, etc.
1381
- // Retornamos a URL de instalação
1382
- const pkg = await this.getPackage(owner, repo, packageId);
1383
- return `npm install @${owner}/${pkg.name}@${pkg.version}`;
1384
- }
1385
- catch (error) {
1386
- throw new Error(`Não foi possível obter download: ${error.message}`);
1178
+ };
1179
+ /**
1180
+ * Compara dois commits
1181
+ */
1182
+ async;
1183
+ compareCommits(owner, string, repo, string, base, string, head, string);
1184
+ Promise < any > {
1185
+ try: {
1186
+ const: response = await this.get(`/repos/${owner}/${repo}/compare/${base}...${head}`),
1187
+ return: {
1188
+ status: response.status,
1189
+ ahead_by: response.ahead_by || 0,
1190
+ behind_by: response.behind_by || 0,
1191
+ total_commits: response.total_commits || 0,
1192
+ commits: response.commits || [],
1193
+ files: response.files || [],
1194
+ merge_base_commit: response.merge_base_commit || null
1195
+ }
1196
+ }, catch(error) {
1197
+ throw new Error(`Erro ao comparar commits: ${error instanceof Error ? error.message : String(error)}`);
1198
+ }
1199
+ };
1200
+ /**
1201
+ * Compara duas branches
1202
+ */
1203
+ async;
1204
+ compareBranches(owner, string, repo, string, baseBranch, string, headBranch, string);
1205
+ Promise < any > {
1206
+ try: {
1207
+ return: await this.compareCommits(owner, repo, baseBranch, headBranch)
1208
+ }, catch(error) {
1209
+ throw new Error(`Erro ao comparar branches: ${error instanceof Error ? error.message : String(error)}`);
1210
+ }
1211
+ };
1212
+ /**
1213
+ * Obtém URL do repositório GitHub
1214
+ */
1215
+ getRepositoryUrl(owner, string, repo, string);
1216
+ string;
1217
+ {
1218
+ return `https://github.com/${owner}/${repo}.git`;
1219
+ }
1220
+ // Packages - GitHub tem suporte completo para packages
1221
+ async;
1222
+ listPackages(owner, string, repo, string, page, number = 1, limit, number = 30);
1223
+ Promise < any[] > {
1224
+ try: {
1225
+ const: data = await this.get(`/repos/${owner}/${repo}/packages`, {
1226
+ package_type: 'npm', // Default to npm packages
1227
+ page,
1228
+ per_page: limit
1229
+ }),
1230
+ return: data.map((pkg) => ({
1231
+ id: pkg.id.toString(),
1232
+ name: pkg.name,
1233
+ version: pkg.version || 'latest',
1234
+ description: pkg.description || '',
1235
+ type: pkg.package_type || 'npm',
1236
+ html_url: pkg.html_url || `https://github.com/${owner}/${repo}/packages/${pkg.package_type}/${pkg.name}`,
1237
+ created_at: pkg.created_at,
1238
+ updated_at: pkg.updated_at,
1239
+ downloads_count: pkg.downloads_count || 0,
1240
+ size: pkg.size_in_bytes || 0,
1241
+ raw: pkg
1242
+ }))
1243
+ }, catch(error) {
1244
+ console.warn('[GITHUB] Erro ao listar packages:', error.message);
1245
+ return [];
1246
+ }
1247
+ };
1248
+ async;
1249
+ getPackage(owner, string, repo, string, packageId, string);
1250
+ Promise < any > {
1251
+ try: {
1252
+ const: data = await this.get(`/repos/${owner}/${repo}/packages/${packageId}`),
1253
+ return: {
1254
+ id: data.id.toString(),
1255
+ name: data.name,
1256
+ version: data.version || 'latest',
1257
+ description: data.description || '',
1258
+ type: data.package_type || 'npm',
1259
+ html_url: data.html_url || `https://github.com/${owner}/${repo}/packages/${data.package_type}/${data.name}`,
1260
+ created_at: data.created_at,
1261
+ updated_at: data.updated_at,
1262
+ downloads_count: data.downloads_count || 0,
1263
+ size: data.size_in_bytes || 0,
1264
+ raw: data
1387
1265
  }
1388
- }
1389
- // Projects - GitHub tem suporte completo para projects (v2)
1390
- async listProjects(owner, repo, page = 1, limit = 30) {
1391
- try {
1392
- // Usar GraphQL para Projects v2 (nova API)
1393
- const query = `
1266
+ }, catch(error) {
1267
+ throw new Error(`Pacote não encontrado: ${error.message}`);
1268
+ }
1269
+ };
1270
+ async;
1271
+ createPackage(owner, string, repo, string, packageData, any);
1272
+ Promise < any > {
1273
+ try: {
1274
+ // GitHub packages são criados automaticamente ao fazer publish
1275
+ // Esta é uma operação simulada
1276
+ console, : .warn('[GITHUB] Pacotes são criados automaticamente ao fazer publish. Esta operação é simulada.'),
1277
+ return: {
1278
+ id: Date.now().toString(),
1279
+ name: packageData.name,
1280
+ version: packageData.version || '1.0.0',
1281
+ description: packageData.description || '',
1282
+ type: packageData.type || 'npm',
1283
+ html_url: `https://github.com/${owner}/${repo}/packages/${packageData.type}/${packageData.name}`,
1284
+ created_at: new Date().toISOString(),
1285
+ updated_at: new Date().toISOString(),
1286
+ downloads_count: 0,
1287
+ size: 0,
1288
+ raw: packageData
1289
+ }
1290
+ }, catch(error) {
1291
+ throw new Error(`Não foi possível criar pacote: ${error.message}`);
1292
+ }
1293
+ };
1294
+ async;
1295
+ updatePackage(owner, string, repo, string, packageId, string, updates, any);
1296
+ Promise < any > {
1297
+ try: {
1298
+ // GitHub packages têm metadados limitados para atualização
1299
+ console, : .warn('[GITHUB] Atualização de packages é limitada no GitHub.'),
1300
+ throw: new Error('GitHub não suporta atualização direta de metadados de packages')
1301
+ }, catch(error) {
1302
+ throw new Error(`Não foi possível atualizar pacote: ${error.message}`);
1303
+ }
1304
+ };
1305
+ async;
1306
+ deletePackage(owner, string, repo, string, packageId, string);
1307
+ Promise < boolean > {
1308
+ try: {
1309
+ await, this: .delete(`/repos/${owner}/${repo}/packages/${packageId}`),
1310
+ return: true
1311
+ }, catch(error) {
1312
+ throw new Error(`Não foi possível deletar pacote: ${error.message}`);
1313
+ }
1314
+ };
1315
+ async;
1316
+ publishPackage(owner, string, repo, string, packageId, string);
1317
+ Promise < boolean > {
1318
+ try: {
1319
+ console, : .warn('[GITHUB] Publish de packages é feito automaticamente via GitHub Actions ou CLI.'),
1320
+ // Esta é uma operação simulada - na prática seria feito via Actions
1321
+ return: true
1322
+ }, catch(error) {
1323
+ throw new Error(`Não foi possível publicar pacote: ${error.message}`);
1324
+ }
1325
+ };
1326
+ async;
1327
+ downloadPackage(owner, string, repo, string, packageId, string);
1328
+ Promise < string > {
1329
+ try: {
1330
+ // GitHub packages podem ser baixados via npm, yarn, etc.
1331
+ // Retornamos a URL de instalação
1332
+ const: pkg = await this.getPackage(owner, repo, packageId),
1333
+ return: `npm install @${owner}/${pkg.name}@${pkg.version}`
1334
+ }, catch(error) {
1335
+ throw new Error(`Não foi possível obter download: ${error.message}`);
1336
+ }
1337
+ };
1338
+ // Projects - GitHub tem suporte completo para projects (v2)
1339
+ async;
1340
+ listProjects(owner, string, repo, string, page, number = 1, limit, number = 30);
1341
+ Promise < any[] > {
1342
+ try: {
1343
+ // Usar GraphQL para Projects v2 (nova API)
1344
+ const: query = `
1394
1345
  query($owner: String!, $repo: String!, $first: Int!) {
1395
1346
  repository(owner: $owner, name: $repo) {
1396
1347
  projectsV2(first: $first) {
@@ -1415,25 +1366,26 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
1415
1366
  }
1416
1367
  }
1417
1368
  }
1418
- `;
1419
- const variables = {
1420
- owner,
1421
- repo,
1422
- first: limit
1423
- };
1424
- // GitHub Projects v2 requer GraphQL, mas nossa implementação atual não tem suporte GraphQL
1425
- // Por enquanto, retornamos lista vazia e informamos sobre a limitação
1426
- console.warn('[GITHUB] GitHub Projects v2 requer GraphQL API. Funcionalidade limitada.');
1427
- return [];
1428
- }
1429
- catch (error) {
1430
- console.warn('[GITHUB] Erro ao listar projects v2:', error.message);
1431
- return [];
1432
- }
1433
- }
1434
- async getProject(owner, repo, projectId) {
1435
- try {
1436
- const query = `
1369
+ `,
1370
+ const: variables = {
1371
+ owner,
1372
+ repo,
1373
+ first: limit
1374
+ },
1375
+ // GitHub Projects v2 requer GraphQL, mas nossa implementação atual não tem suporte GraphQL
1376
+ // Por enquanto, retornamos lista vazia e informamos sobre a limitação
1377
+ console, : .warn('[GITHUB] GitHub Projects v2 requer GraphQL API. Funcionalidade limitada.'),
1378
+ return: []
1379
+ }, catch(error) {
1380
+ console.warn('[GITHUB] Erro ao listar projects v2:', error.message);
1381
+ return [];
1382
+ }
1383
+ };
1384
+ async;
1385
+ getProject(owner, string, repo, string, projectId, string);
1386
+ Promise < any > {
1387
+ try: {
1388
+ const: query = `
1437
1389
  query($projectId: ID!) {
1438
1390
  node(id: $projectId) {
1439
1391
  ... on ProjectV2 {
@@ -1456,80 +1408,84 @@ class GitHubProvider extends base_provider_js_1.BaseVcsProvider {
1456
1408
  }
1457
1409
  }
1458
1410
  }
1459
- `;
1460
- // GitHub Projects v2 requer GraphQL, mas nossa implementação atual não tem suporte GraphQL
1461
- throw new Error('GitHub Projects v2 requer GraphQL API. Use a interface web do GitHub.');
1462
- }
1463
- catch (error) {
1464
- throw new Error(`Projeto não encontrado: ${error.message}`);
1465
- }
1466
- }
1467
- async createProject(owner, repo, projectData) {
1468
- try {
1469
- // GitHub descontinuou projetos clássicos. Projects v2 só podem ser criados via interface web
1470
- // ou usando GraphQL com permissões especiais
1471
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1472
- }
1473
- catch (error) {
1474
- throw new Error(`Não foi possível criar projeto: ${error.message}`);
1475
- }
1476
- }
1477
- async updateProject(owner, repo, projectId, updates) {
1478
- try {
1479
- // Projetos clássicos foram descontinuados
1480
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1481
- }
1482
- catch (error) {
1483
- throw new Error(`Não foi possível atualizar projeto: ${error.message}`);
1484
- }
1485
- }
1486
- async deleteProject(owner, repo, projectId) {
1487
- try {
1488
- // Projetos clássicos foram descontinuados
1489
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1490
- }
1491
- catch (error) {
1492
- throw new Error(`Não foi possível deletar projeto: ${error.message}`);
1493
- }
1494
- }
1495
- async addProjectItem(owner, repo, projectId, item) {
1496
- try {
1497
- // Projetos clássicos foram descontinuados
1498
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1499
- }
1500
- catch (error) {
1501
- throw new Error(`Não foi possível adicionar item: ${error.message}`);
1502
- }
1503
- }
1504
- async updateProjectItem(owner, repo, projectId, itemId, updates) {
1505
- try {
1506
- // Projetos clássicos foram descontinuados
1507
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1508
- }
1509
- catch (error) {
1510
- throw new Error(`Não foi possível atualizar item: ${error.message}`);
1511
- }
1512
- }
1513
- async deleteProjectItem(owner, repo, projectId, itemId) {
1514
- try {
1515
- // Projetos clássicos foram descontinuados
1516
- throw new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub');
1517
- }
1518
- catch (error) {
1519
- throw new Error(`Não foi possível deletar item: ${error.message}`);
1520
- }
1521
- }
1522
- async listProjectItems(owner, repo, projectId, page = 1, limit = 30) {
1523
- try {
1524
- // Projetos clássicos foram descontinuados
1525
- // Para Projects v2, seria necessário GraphQL, mas por enquanto retornamos vazio
1526
- return [];
1527
- }
1528
- catch (error) {
1529
- console.warn('[GITHUB] Erro ao listar items do projeto:', error.message);
1530
- return [];
1531
- }
1532
- }
1533
- }
1534
- exports.GitHubProvider = GitHubProvider;
1411
+ `,
1412
+ // GitHub Projects v2 requer GraphQL, mas nossa implementação atual não tem suporte GraphQL
1413
+ throw: new Error('GitHub Projects v2 requer GraphQL API. Use a interface web do GitHub.')
1414
+ }, catch(error) {
1415
+ throw new Error(`Projeto não encontrado: ${error.message}`);
1416
+ }
1417
+ };
1418
+ async;
1419
+ createProject(owner, string, repo, string, projectData, any);
1420
+ Promise < any > {
1421
+ try: {
1422
+ // GitHub descontinuou projetos clássicos. Projects v2 só podem ser criados via interface web
1423
+ // ou usando GraphQL com permissões especiais
1424
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1425
+ }, catch(error) {
1426
+ throw new Error(`Não foi possível criar projeto: ${error.message}`);
1427
+ }
1428
+ };
1429
+ async;
1430
+ updateProject(owner, string, repo, string, projectId, string, updates, any);
1431
+ Promise < any > {
1432
+ try: {
1433
+ // Projetos clássicos foram descontinuados
1434
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1435
+ }, catch(error) {
1436
+ throw new Error(`Não foi possível atualizar projeto: ${error.message}`);
1437
+ }
1438
+ };
1439
+ async;
1440
+ deleteProject(owner, string, repo, string, projectId, string);
1441
+ Promise < boolean > {
1442
+ try: {
1443
+ // Projetos clássicos foram descontinuados
1444
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1445
+ }, catch(error) {
1446
+ throw new Error(`Não foi possível deletar projeto: ${error.message}`);
1447
+ }
1448
+ };
1449
+ async;
1450
+ addProjectItem(owner, string, repo, string, projectId, string, item, any);
1451
+ Promise < any > {
1452
+ try: {
1453
+ // Projetos clássicos foram descontinuados
1454
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1455
+ }, catch(error) {
1456
+ throw new Error(`Não foi possível adicionar item: ${error.message}`);
1457
+ }
1458
+ };
1459
+ async;
1460
+ updateProjectItem(owner, string, repo, string, projectId, string, itemId, string, updates, any);
1461
+ Promise < any > {
1462
+ try: {
1463
+ // Projetos clássicos foram descontinuados
1464
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1465
+ }, catch(error) {
1466
+ throw new Error(`Não foi possível atualizar item: ${error.message}`);
1467
+ }
1468
+ };
1469
+ async;
1470
+ deleteProjectItem(owner, string, repo, string, projectId, string, itemId, string);
1471
+ Promise < boolean > {
1472
+ try: {
1473
+ // Projetos clássicos foram descontinuados
1474
+ throw: new Error('GitHub descontinuou projetos clássicos. Use Projects v2 via interface web do GitHub')
1475
+ }, catch(error) {
1476
+ throw new Error(`Não foi possível deletar item: ${error.message}`);
1477
+ }
1478
+ };
1479
+ async;
1480
+ listProjectItems(owner, string, repo, string, projectId, string, page, number = 1, limit, number = 30);
1481
+ Promise < any[] > {
1482
+ try: {
1483
+ // Projetos clássicos foram descontinuados
1484
+ // Para Projects v2, seria necessário GraphQL, mas por enquanto retornamos vazio
1485
+ return: []
1486
+ }, catch(error) {
1487
+ console.warn('[GITHUB] Erro ao listar items do projeto:', error.message);
1488
+ return [];
1489
+ }
1490
+ };
1535
1491
  //# sourceMappingURL=github-provider.js.map