@backstage/integration 0.6.10 → 0.7.2

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/index.d.ts CHANGED
@@ -397,17 +397,6 @@ declare function readGitHubIntegrationConfig(config: Config): GitHubIntegrationC
397
397
  */
398
398
  declare function readGitHubIntegrationConfigs(configs: Config[]): GitHubIntegrationConfig[];
399
399
 
400
- /**
401
- * Corresponds to a Github installation which internally could hold several GitHub Apps.
402
- *
403
- * @public
404
- */
405
- declare class GithubAppCredentialsMux {
406
- private readonly apps;
407
- constructor(config: GitHubIntegrationConfig);
408
- getAllInstallations(): Promise<RestEndpointMethodTypes['apps']['listInstallations']['response']['data']>;
409
- getAppToken(owner: string, repo?: string): Promise<string | undefined>;
410
- }
411
400
  /**
412
401
  * The type of credentials produced by the credential provider.
413
402
  *
@@ -427,38 +416,12 @@ declare type GithubCredentials = {
427
416
  type: GithubCredentialType;
428
417
  };
429
418
  /**
430
- * Handles the creation and caching of credentials for GitHub integrations.
419
+ * This allows implementations to be provided to retrieve GitHub credentials.
431
420
  *
432
421
  * @public
433
- * @remarks
434
422
  *
435
- * TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
436
423
  */
437
- declare class GithubCredentialsProvider {
438
- private readonly githubAppCredentialsMux;
439
- private readonly token?;
440
- static create(config: GitHubIntegrationConfig): GithubCredentialsProvider;
441
- private constructor();
442
- /**
443
- * Returns {@link GithubCredentials} for a given URL.
444
- *
445
- * @remarks
446
- *
447
- * Consecutive calls to this method with the same URL will return cached
448
- * credentials.
449
- *
450
- * The shortest lifetime for a token returned is 10 minutes.
451
- *
452
- * @example
453
- * ```ts
454
- * const { token, headers } = await getCredentials({
455
- * url: 'github.com/backstage/foobar'
456
- * })
457
- * ```
458
- *
459
- * @param opts - The organization or repository URL
460
- * @returns A promise of {@link GithubCredentials}.
461
- */
424
+ interface GithubCredentialsProvider {
462
425
  getCredentials(opts: {
463
426
  url: string;
464
427
  }): Promise<GithubCredentials>;
@@ -491,6 +454,79 @@ declare function getGitHubRequestOptions(config: GitHubIntegrationConfig, creden
491
454
  headers: Record<string, string>;
492
455
  };
493
456
 
457
+ /**
458
+ * The configuration parameters for a single AWS S3 provider.
459
+ *
460
+ * @public
461
+ */
462
+ declare type AwsS3IntegrationConfig = {
463
+ /**
464
+ * Host, derived from endpoint, and defaults to amazonaws.com
465
+ */
466
+ host: string;
467
+ /**
468
+ * (Optional) AWS Endpoint.
469
+ * The endpoint URI to send requests to. The default endpoint is built from the configured region.
470
+ * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
471
+ *
472
+ * Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566
473
+ */
474
+ endpoint?: string;
475
+ /**
476
+ * (Optional) Whether to use path style URLs when communicating with S3.
477
+ * Defaults to false.
478
+ * This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.
479
+ */
480
+ s3ForcePathStyle?: boolean;
481
+ /**
482
+ * (Optional) User access key id
483
+ */
484
+ accessKeyId?: string;
485
+ /**
486
+ * (Optional) User secret access key
487
+ */
488
+ secretAccessKey?: string;
489
+ /**
490
+ * (Optional) ARN of role to be assumed
491
+ */
492
+ roleArn?: string;
493
+ };
494
+ /**
495
+ * Reads a single Aws S3 integration config.
496
+ *
497
+ * @param config - The config object of a single integration
498
+ * @public
499
+ */
500
+ declare function readAwsS3IntegrationConfig(config: Config): AwsS3IntegrationConfig;
501
+ /**
502
+ * Reads a set of AWS S3 integration configs, and inserts some defaults for
503
+ * public Amazon AWS if not specified.
504
+ *
505
+ * @param configs - The config objects of the integrations
506
+ * @public
507
+ */
508
+ declare function readAwsS3IntegrationConfigs(configs: Config[]): AwsS3IntegrationConfig[];
509
+
510
+ /**
511
+ * Integrates with AWS S3 or compatible solutions.
512
+ *
513
+ * @public
514
+ */
515
+ declare class AwsS3Integration implements ScmIntegration {
516
+ private readonly integrationConfig;
517
+ static factory: ScmIntegrationsFactory<AwsS3Integration>;
518
+ get type(): string;
519
+ get title(): string;
520
+ get config(): AwsS3IntegrationConfig;
521
+ constructor(integrationConfig: AwsS3IntegrationConfig);
522
+ resolveUrl(options: {
523
+ url: string;
524
+ base: string;
525
+ lineNumber?: number | undefined;
526
+ }): string;
527
+ resolveEditUrl(url: string): string;
528
+ }
529
+
494
530
  /**
495
531
  * A GitHub based integration.
496
532
  *
@@ -526,12 +562,12 @@ declare function replaceGitHubUrlType(url: string, type: 'blob' | 'tree' | 'edit
526
562
  */
527
563
  declare type GitLabIntegrationConfig = {
528
564
  /**
529
- * The host of the target that this matches on, e.g. "gitlab.com".
565
+ * The host of the target that this matches on, e.g. `gitlab.com`.
530
566
  */
531
567
  host: string;
532
568
  /**
533
569
  * The base URL of the API of this provider, e.g.
534
- * "https://gitlab.com/api/v4", with no trailing slash.
570
+ * `https://gitlab.com/api/v4`, with no trailing slash.
535
571
  *
536
572
  * May be omitted specifically for public GitLab; then it will be deduced.
537
573
  */
@@ -543,10 +579,10 @@ declare type GitLabIntegrationConfig = {
543
579
  */
544
580
  token?: string;
545
581
  /**
546
- * The baseUrl of this provider, e.g. "https://gitlab.com", which is passed
582
+ * The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed
547
583
  * into the GitLab client.
548
584
  *
549
- * If no baseUrl is provided, it will default to https://${host}
585
+ * If no baseUrl is provided, it will default to `https://${host}`
550
586
  */
551
587
  baseUrl: string;
552
588
  };
@@ -566,34 +602,6 @@ declare function readGitLabIntegrationConfig(config: Config): GitLabIntegrationC
566
602
  */
567
603
  declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrationConfig[];
568
604
 
569
- /**
570
- * Given a URL pointing to a file on a provider, returns a URL that is suitable
571
- * for fetching the contents of the data.
572
- *
573
- * @remarks
574
- *
575
- * Converts
576
- * from: https://gitlab.example.com/a/b/blob/master/c.yaml
577
- * to: https://gitlab.example.com/a/b/raw/master/c.yaml
578
- * -or-
579
- * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath
580
- * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch
581
- *
582
- * @param url - A URL pointing to a file
583
- * @param config - The relevant provider config
584
- * @public
585
- */
586
- declare function getGitLabFileFetchUrl(url: string, config: GitLabIntegrationConfig): Promise<string>;
587
- /**
588
- * Gets the request options necessary to make requests to a given provider.
589
- *
590
- * @param config - The relevant provider config
591
- * @public
592
- */
593
- declare function getGitLabRequestOptions(config: GitLabIntegrationConfig): {
594
- headers: Record<string, string>;
595
- };
596
-
597
605
  /**
598
606
  * A GitLab based integration.
599
607
  *
@@ -614,102 +622,6 @@ declare class GitLabIntegration implements ScmIntegration {
614
622
  resolveEditUrl(url: string): string;
615
623
  }
616
624
 
617
- /**
618
- * The configuration parameters for a single Google Cloud Storage provider.
619
- *
620
- * @public
621
- */
622
- declare type GoogleGcsIntegrationConfig = {
623
- /**
624
- * Service account email used to authenticate requests.
625
- */
626
- clientEmail?: string;
627
- /**
628
- * Service account private key used to authenticate requests.
629
- */
630
- privateKey?: string;
631
- };
632
- /**
633
- * Reads a single Google GCS integration config.
634
- *
635
- * @param config - The config object of a single integration
636
- * @public
637
- */
638
- declare function readGoogleGcsIntegrationConfig(config: Config): GoogleGcsIntegrationConfig;
639
-
640
- /**
641
- * The configuration parameters for a single AWS S3 provider.
642
- *
643
- * @public
644
- */
645
- declare type AwsS3IntegrationConfig = {
646
- /**
647
- * The host of the target that this matches on, e.g. "amazonaws.com"
648
- *
649
- * Currently only "amazonaws.com" is supported.
650
- */
651
- host: string;
652
- /**
653
- * accessKeyId
654
- */
655
- accessKeyId?: string;
656
- /**
657
- * secretAccessKey
658
- */
659
- secretAccessKey?: string;
660
- /**
661
- * roleArn
662
- */
663
- roleArn?: string;
664
- };
665
- /**
666
- * Reads a single Aws S3 integration config.
667
- *
668
- * @param config - The config object of a single integration
669
- * @public
670
- */
671
- declare function readAwsS3IntegrationConfig(config: Config): AwsS3IntegrationConfig;
672
- /**
673
- * Reads a set of AWS S3 integration configs, and inserts some defaults for
674
- * public Amazon AWS if not specified.
675
- *
676
- * @param configs - The config objects of the integrations
677
- * @public
678
- */
679
- declare function readAwsS3IntegrationConfigs(configs: Config[]): AwsS3IntegrationConfig[];
680
-
681
- /**
682
- * Integrates with AWS S3 or compatible solutions.
683
- *
684
- * @public
685
- */
686
- declare class AwsS3Integration implements ScmIntegration {
687
- private readonly integrationConfig;
688
- static factory: ScmIntegrationsFactory<AwsS3Integration>;
689
- get type(): string;
690
- get title(): string;
691
- get config(): AwsS3IntegrationConfig;
692
- constructor(integrationConfig: AwsS3IntegrationConfig);
693
- resolveUrl(options: {
694
- url: string;
695
- base: string;
696
- lineNumber?: number | undefined;
697
- }): string;
698
- resolveEditUrl(url: string): string;
699
- }
700
-
701
- /**
702
- * Default implementation of {@link ScmIntegration} `resolveUrl`, that only
703
- * works with URL pathname based providers.
704
- *
705
- * @public
706
- */
707
- declare function defaultScmResolveUrl(options: {
708
- url: string;
709
- base: string;
710
- lineNumber?: number;
711
- }): string;
712
-
713
625
  /**
714
626
  * Holds all registered SCM integrations, of all types.
715
627
  *
@@ -761,6 +673,159 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
761
673
  resolveEditUrl(url: string): string;
762
674
  }
763
675
 
676
+ /**
677
+ * Handles the creation and caching of credentials for GitHub integrations.
678
+ *
679
+ * @public
680
+ * @remarks
681
+ *
682
+ * TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
683
+ */
684
+ declare class DefaultGithubCredentialsProvider implements GithubCredentialsProvider {
685
+ private readonly providers;
686
+ static fromIntegrations(integrations: ScmIntegrationRegistry): DefaultGithubCredentialsProvider;
687
+ private constructor();
688
+ /**
689
+ * Returns {@link GithubCredentials} for a given URL.
690
+ *
691
+ * @remarks
692
+ *
693
+ * Consecutive calls to this method with the same URL will return cached
694
+ * credentials.
695
+ *
696
+ * The shortest lifetime for a token returned is 10 minutes.
697
+ *
698
+ * @example
699
+ * ```ts
700
+ * const { token, headers } = await getCredentials({
701
+ * url: 'https://github.com/backstage/foobar'
702
+ * })
703
+ *
704
+ * const { token, headers } = await getCredentials({
705
+ * url: 'https://github.com/backstage'
706
+ * })
707
+ * ```
708
+ *
709
+ * @param opts - The organization or repository URL
710
+ * @returns A promise of {@link GithubCredentials}.
711
+ */
712
+ getCredentials(opts: {
713
+ url: string;
714
+ }): Promise<GithubCredentials>;
715
+ }
716
+
717
+ /**
718
+ * Corresponds to a Github installation which internally could hold several GitHub Apps.
719
+ *
720
+ * @public
721
+ */
722
+ declare class GithubAppCredentialsMux {
723
+ private readonly apps;
724
+ constructor(config: GitHubIntegrationConfig);
725
+ getAllInstallations(): Promise<RestEndpointMethodTypes['apps']['listInstallations']['response']['data']>;
726
+ getAppToken(owner: string, repo?: string): Promise<string | undefined>;
727
+ }
728
+ /**
729
+ * Handles the creation and caching of credentials for GitHub integrations.
730
+ *
731
+ * @public
732
+ * @remarks
733
+ *
734
+ * TODO: Possibly move this to a backend only package so that it's not used in the frontend by mistake
735
+ */
736
+ declare class SingleInstanceGithubCredentialsProvider implements GithubCredentialsProvider {
737
+ private readonly githubAppCredentialsMux;
738
+ private readonly token?;
739
+ static create: (config: GitHubIntegrationConfig) => GithubCredentialsProvider;
740
+ private constructor();
741
+ /**
742
+ * Returns {@link GithubCredentials} for a given URL.
743
+ *
744
+ * @remarks
745
+ *
746
+ * Consecutive calls to this method with the same URL will return cached
747
+ * credentials.
748
+ *
749
+ * The shortest lifetime for a token returned is 10 minutes.
750
+ *
751
+ * @example
752
+ * ```ts
753
+ * const { token, headers } = await getCredentials({
754
+ * url: 'github.com/backstage/foobar'
755
+ * })
756
+ * ```
757
+ *
758
+ * @param opts - The organization or repository URL
759
+ * @returns A promise of {@link GithubCredentials}.
760
+ */
761
+ getCredentials(opts: {
762
+ url: string;
763
+ }): Promise<GithubCredentials>;
764
+ }
765
+
766
+ /**
767
+ * Given a URL pointing to a file on a provider, returns a URL that is suitable
768
+ * for fetching the contents of the data.
769
+ *
770
+ * @remarks
771
+ *
772
+ * Converts
773
+ * from: https://gitlab.example.com/a/b/blob/master/c.yaml
774
+ * to: https://gitlab.example.com/a/b/raw/master/c.yaml
775
+ * -or-
776
+ * from: https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/filepath
777
+ * to: https://gitlab.com/api/v4/projects/projectId/repository/files/filepath?ref=branch
778
+ *
779
+ * @param url - A URL pointing to a file
780
+ * @param config - The relevant provider config
781
+ * @public
782
+ */
783
+ declare function getGitLabFileFetchUrl(url: string, config: GitLabIntegrationConfig): Promise<string>;
784
+ /**
785
+ * Gets the request options necessary to make requests to a given provider.
786
+ *
787
+ * @param config - The relevant provider config
788
+ * @public
789
+ */
790
+ declare function getGitLabRequestOptions(config: GitLabIntegrationConfig): {
791
+ headers: Record<string, string>;
792
+ };
793
+
794
+ /**
795
+ * The configuration parameters for a single Google Cloud Storage provider.
796
+ *
797
+ * @public
798
+ */
799
+ declare type GoogleGcsIntegrationConfig = {
800
+ /**
801
+ * Service account email used to authenticate requests.
802
+ */
803
+ clientEmail?: string;
804
+ /**
805
+ * Service account private key used to authenticate requests.
806
+ */
807
+ privateKey?: string;
808
+ };
809
+ /**
810
+ * Reads a single Google GCS integration config.
811
+ *
812
+ * @param config - The config object of a single integration
813
+ * @public
814
+ */
815
+ declare function readGoogleGcsIntegrationConfig(config: Config): GoogleGcsIntegrationConfig;
816
+
817
+ /**
818
+ * Default implementation of {@link ScmIntegration} `resolveUrl`, that only
819
+ * works with URL pathname based providers.
820
+ *
821
+ * @public
822
+ */
823
+ declare function defaultScmResolveUrl(options: {
824
+ url: string;
825
+ base: string;
826
+ lineNumber?: number;
827
+ }): string;
828
+
764
829
  /**
765
830
  * The set of supported integrations.
766
831
  *
@@ -798,4 +863,4 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
798
863
  resolveEditUrl(url: string): string;
799
864
  }
800
865
 
801
- export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };
866
+ export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, DefaultGithubCredentialsProvider, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabRequestOptions, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType };