@backstage/plugin-catalog-backend-module-github 0.0.0-nightly-20221018030035 → 0.0.0-nightly-20221021024853

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/CHANGELOG.md CHANGED
@@ -1,6 +1,37 @@
1
1
  # @backstage/plugin-catalog-backend-module-github
2
2
 
3
- ## 0.0.0-nightly-20221018030035
3
+ ## 0.0.0-nightly-20221021024853
4
+
5
+ ### Minor Changes
6
+
7
+ - f64d66a45c: Added the ability for the GitHub discovery provider to validate that catalog files exist before emitting them.
8
+
9
+ Users can now set the `validateLocationsExist` property to `true` in their GitHub discovery configuration to opt in to this feature.
10
+ This feature only works with `catalogPath`s that do not contain wildcards.
11
+
12
+ When `validateLocationsExist` is set to `true`, the GitHub discovery provider will retrieve the object from the
13
+ repository at the provided `catalogPath`.
14
+ If this file exists and is non-empty, then it will be emitted as a location for further processing.
15
+ If this file does not exist or is empty, then it will not be emitted.
16
+ Not emitting locations that do not exist allows for far fewer calls to the GitHub API to validate locations that do not exist.
17
+
18
+ ### Patch Changes
19
+
20
+ - c1784a4980: Replaces in-code uses of `GitHub` with `Github` and deprecates old versions.
21
+ - Updated dependencies
22
+ - @backstage/backend-common@0.0.0-nightly-20221021024853
23
+ - @backstage/plugin-catalog-backend@0.0.0-nightly-20221021024853
24
+ - @backstage/integration@0.0.0-nightly-20221021024853
25
+ - @backstage/backend-plugin-api@0.0.0-nightly-20221021024853
26
+ - @backstage/backend-tasks@0.0.0-nightly-20221021024853
27
+ - @backstage/plugin-catalog-node@0.0.0-nightly-20221021024853
28
+ - @backstage/catalog-client@0.0.0-nightly-20221021024853
29
+ - @backstage/catalog-model@0.0.0-nightly-20221021024853
30
+ - @backstage/config@0.0.0-nightly-20221021024853
31
+ - @backstage/errors@0.0.0-nightly-20221021024853
32
+ - @backstage/types@1.0.0
33
+
34
+ ## 0.1.8
4
35
 
5
36
  ### Patch Changes
6
37
 
@@ -9,7 +40,7 @@
9
40
  Please find how to configure the schedule at the config at
10
41
  https://backstage.io/docs/integrations/github/discovery
11
42
 
12
- - 7022aebf35: Added `GitHubLocationAnalyzer`. This can be used to add to the `CatalogBuilder`. When added this will be used by `RepoLocationAnalyzer` to figure out if the given URL that you are trying to import from the /catalog-import page already contains catalog-info.yaml files.
43
+ - 7022aebf35: Added `GithubLocationAnalyzer`. This can be used to add to the `CatalogBuilder`. When added this will be used by `RepoLocationAnalyzer` to figure out if the given URL that you are trying to import from the /catalog-import page already contains catalog-info.yaml files.
13
44
  - 51046b58b0: Use schedule from config at backend module.
14
45
 
15
46
  Also, it removes `GithubEntityProviderCatalogModuleOptions`
@@ -17,18 +48,33 @@
17
48
  like at other similar modules.
18
49
 
19
50
  - 7edb5909e8: Add missing config schema for the `GitHubEntityProvider`.
51
+ - be9474b103: Replaces in-code uses of `GitHub` by `Github` and deprecates old versions.
52
+
53
+ Deprecates
54
+
55
+ - `GitHubEntityProvider` replaced by `GithubEntityProvider`
56
+ - `GitHubLocationAnalyzer` replaced by `GithubLocationAnalyzer`
57
+ - `GitHubLocationAnalyzerOptions` replaced by `GithubLocationAnalyzerOptions`
58
+ - `GitHubOrgEntityProvider` replaced by `GithubOrgEntityProvider`
59
+ - `GitHubOrgEntityProviderOptions` replaced by `GithubOrgEntityProviderOptions`
60
+
61
+ Renames
62
+
63
+ - `GitHubLocationAnalyzer` to `GithubLocationAnalyzer`
64
+ - `GitHubLocationAnalyzerOptions` to `GithubLocationAnalyzerOptions`
65
+
20
66
  - a35a27df70: Updated the `moduleId` of the experimental module export.
21
67
  - Updated dependencies
22
- - @backstage/plugin-catalog-node@0.0.0-nightly-20221018030035
23
- - @backstage/catalog-model@0.0.0-nightly-20221018030035
24
- - @backstage/backend-common@0.0.0-nightly-20221018030035
25
- - @backstage/plugin-catalog-backend@0.0.0-nightly-20221018030035
26
- - @backstage/backend-tasks@0.0.0-nightly-20221018030035
27
- - @backstage/backend-plugin-api@0.0.0-nightly-20221018030035
28
- - @backstage/catalog-client@0.0.0-nightly-20221018030035
29
- - @backstage/config@0.0.0-nightly-20221018030035
30
- - @backstage/errors@0.0.0-nightly-20221018030035
31
- - @backstage/integration@0.0.0-nightly-20221018030035
68
+ - @backstage/plugin-catalog-node@1.2.0
69
+ - @backstage/catalog-model@1.1.2
70
+ - @backstage/backend-common@0.15.2
71
+ - @backstage/plugin-catalog-backend@1.5.0
72
+ - @backstage/backend-tasks@0.3.6
73
+ - @backstage/backend-plugin-api@0.1.3
74
+ - @backstage/catalog-client@1.1.1
75
+ - @backstage/config@1.0.3
76
+ - @backstage/errors@1.1.2
77
+ - @backstage/integration@1.3.2
32
78
  - @backstage/types@1.0.0
33
79
 
34
80
  ## 0.1.8-next.2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-github",
3
- "version": "0.0.0-nightly-20221018030035",
3
+ "version": "0.0.0-nightly-20221021024853",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
package/config.d.ts CHANGED
@@ -50,7 +50,7 @@ export interface Config {
50
50
 
51
51
  providers?: {
52
52
  /**
53
- * GitHubEntityProvider configuration
53
+ * GithubEntityProvider configuration
54
54
  *
55
55
  * Uses "default" as default id for the single config variant.
56
56
  */
@@ -13,7 +13,7 @@ import { Entity } from '@backstage/catalog-model';
13
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
14
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
15
15
  import { GithubCredentialsProvider } from '@backstage/integration';
16
- import { GitHubIntegrationConfig } from '@backstage/integration';
16
+ import { GithubIntegrationConfig } from '@backstage/integration';
17
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
18
18
  import { Logger } from 'winston';
19
19
  import { PluginEndpointDiscovery } from '@backstage/backend-common';
@@ -55,6 +55,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
55
55
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
56
56
  }
57
57
 
58
+ /**
59
+ * @public
60
+ * @deprecated Use {@link GithubEntityProvider} instead.
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly delegate;
64
+ static fromConfig(config: Config, options: {
65
+ logger: Logger;
66
+ schedule?: TaskRunner;
67
+ scheduler?: PluginTaskScheduler;
68
+ }): GitHubEntityProvider[];
69
+ private constructor();
70
+ connect(connection: EntityProviderConnection): Promise<void>;
71
+ getProviderName(): string;
72
+ refresh(logger: Logger): Promise<void>;
73
+ }
74
+
58
75
  /**
59
76
  * Discovers catalog files located in [GitHub](https://github.com).
60
77
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -63,7 +80,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
63
80
  *
64
81
  * @public
65
82
  */
66
- export declare class GitHubEntityProvider implements EntityProvider {
83
+ export declare class GithubEntityProvider implements EntityProvider {
67
84
  private readonly config;
68
85
  private readonly logger;
69
86
  private readonly integration;
@@ -74,7 +91,7 @@ export declare class GitHubEntityProvider implements EntityProvider {
74
91
  logger: Logger;
75
92
  schedule?: TaskRunner;
76
93
  scheduler?: PluginTaskScheduler;
77
- }): GitHubEntityProvider[];
94
+ }): GithubEntityProvider[];
78
95
  private constructor();
79
96
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
80
97
  getProviderName(): string;
@@ -89,17 +106,17 @@ export declare class GitHubEntityProvider implements EntityProvider {
89
106
  }
90
107
 
91
108
  /**
92
- * Registers the GitHubEntityProvider with the catalog processing extension point.
109
+ * Registers the {@link GithubEntityProvider} with the catalog processing extension point.
93
110
  *
94
111
  * @alpha
95
112
  */
96
113
  export declare const githubEntityProviderCatalogModule: (options?: undefined) => BackendFeature;
97
114
 
98
115
  /** @public */
99
- export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
116
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
100
117
  private readonly catalogClient;
101
118
  private readonly config;
102
- constructor(options: GitHubLocationAnalyzerOptions);
119
+ constructor(options: GithubLocationAnalyzerOptions);
103
120
  supports(url: string): boolean;
104
121
  analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
105
122
  existing: {
@@ -114,7 +131,7 @@ export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
114
131
  }
115
132
 
116
133
  /** @public */
117
- export declare type GitHubLocationAnalyzerOptions = {
134
+ export declare type GithubLocationAnalyzerOptions = {
118
135
  config: Config;
119
136
  discovery: PluginEndpointDiscovery;
120
137
  };
@@ -165,21 +182,29 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
165
182
  private getAllOrgs;
166
183
  }
167
184
 
185
+ /**
186
+ * @public
187
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
188
+ */
189
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
190
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
191
+ }
192
+
168
193
  /**
169
194
  * Ingests org data (users and groups) from GitHub.
170
195
  *
171
196
  * @public
172
197
  */
173
- export declare class GitHubOrgEntityProvider implements EntityProvider {
198
+ export declare class GithubOrgEntityProvider implements EntityProvider {
174
199
  private options;
175
200
  private readonly credentialsProvider;
176
201
  private connection?;
177
202
  private scheduleFn?;
178
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
203
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
179
204
  constructor(options: {
180
205
  id: string;
181
206
  orgUrl: string;
182
- gitHubConfig: GitHubIntegrationConfig;
207
+ gitHubConfig: GithubIntegrationConfig;
183
208
  logger: Logger;
184
209
  githubCredentialsProvider?: GithubCredentialsProvider;
185
210
  });
@@ -198,11 +223,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
198
223
  }
199
224
 
200
225
  /**
201
- * Options for {@link GitHubOrgEntityProvider}.
226
+ * @public
227
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
228
+ */
229
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
230
+
231
+ /**
232
+ * Options for {@link GithubOrgEntityProvider}.
202
233
  *
203
234
  * @public
204
235
  */
205
- export declare interface GitHubOrgEntityProviderOptions {
236
+ export declare interface GithubOrgEntityProviderOptions {
206
237
  /**
207
238
  * A unique, stable identifier for this provider.
208
239
  *
@@ -244,7 +275,7 @@ export declare interface GitHubOrgEntityProviderOptions {
244
275
  *
245
276
  * @remarks
246
277
  *
247
- * Consider using {@link GitHubOrgEntityProvider} instead.
278
+ * Consider using {@link GithubOrgEntityProvider} instead.
248
279
  *
249
280
  * @public
250
281
  */
@@ -13,7 +13,7 @@ import { Entity } from '@backstage/catalog-model';
13
13
  import { EntityProvider } from '@backstage/plugin-catalog-backend';
14
14
  import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
15
15
  import { GithubCredentialsProvider } from '@backstage/integration';
16
- import { GitHubIntegrationConfig } from '@backstage/integration';
16
+ import { GithubIntegrationConfig } from '@backstage/integration';
17
17
  import { LocationSpec } from '@backstage/plugin-catalog-backend';
18
18
  import { Logger } from 'winston';
19
19
  import { PluginEndpointDiscovery } from '@backstage/backend-common';
@@ -55,6 +55,23 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
55
55
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
56
56
  }
57
57
 
58
+ /**
59
+ * @public
60
+ * @deprecated Use {@link GithubEntityProvider} instead.
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly delegate;
64
+ static fromConfig(config: Config, options: {
65
+ logger: Logger;
66
+ schedule?: TaskRunner;
67
+ scheduler?: PluginTaskScheduler;
68
+ }): GitHubEntityProvider[];
69
+ private constructor();
70
+ connect(connection: EntityProviderConnection): Promise<void>;
71
+ getProviderName(): string;
72
+ refresh(logger: Logger): Promise<void>;
73
+ }
74
+
58
75
  /**
59
76
  * Discovers catalog files located in [GitHub](https://github.com).
60
77
  * The provider will search your GitHub account and register catalog files matching the configured path
@@ -63,7 +80,7 @@ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
63
80
  *
64
81
  * @public
65
82
  */
66
- export declare class GitHubEntityProvider implements EntityProvider {
83
+ export declare class GithubEntityProvider implements EntityProvider {
67
84
  private readonly config;
68
85
  private readonly logger;
69
86
  private readonly integration;
@@ -74,7 +91,7 @@ export declare class GitHubEntityProvider implements EntityProvider {
74
91
  logger: Logger;
75
92
  schedule?: TaskRunner;
76
93
  scheduler?: PluginTaskScheduler;
77
- }): GitHubEntityProvider[];
94
+ }): GithubEntityProvider[];
78
95
  private constructor();
79
96
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
80
97
  getProviderName(): string;
@@ -91,10 +108,10 @@ export declare class GitHubEntityProvider implements EntityProvider {
91
108
  /* Excluded from this release type: githubEntityProviderCatalogModule */
92
109
 
93
110
  /** @public */
94
- export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
111
+ export declare class GithubLocationAnalyzer implements ScmLocationAnalyzer {
95
112
  private readonly catalogClient;
96
113
  private readonly config;
97
- constructor(options: GitHubLocationAnalyzerOptions);
114
+ constructor(options: GithubLocationAnalyzerOptions);
98
115
  supports(url: string): boolean;
99
116
  analyze({ url, catalogFilename }: AnalyzeOptions): Promise<{
100
117
  existing: {
@@ -109,7 +126,7 @@ export declare class GitHubLocationAnalyzer implements ScmLocationAnalyzer {
109
126
  }
110
127
 
111
128
  /** @public */
112
- export declare type GitHubLocationAnalyzerOptions = {
129
+ export declare type GithubLocationAnalyzerOptions = {
113
130
  config: Config;
114
131
  discovery: PluginEndpointDiscovery;
115
132
  };
@@ -160,21 +177,29 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
160
177
  private getAllOrgs;
161
178
  }
162
179
 
180
+ /**
181
+ * @public
182
+ * @deprecated Use {@link GithubOrgEntityProvider} instead.
183
+ */
184
+ export declare class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
185
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
186
+ }
187
+
163
188
  /**
164
189
  * Ingests org data (users and groups) from GitHub.
165
190
  *
166
191
  * @public
167
192
  */
168
- export declare class GitHubOrgEntityProvider implements EntityProvider {
193
+ export declare class GithubOrgEntityProvider implements EntityProvider {
169
194
  private options;
170
195
  private readonly credentialsProvider;
171
196
  private connection?;
172
197
  private scheduleFn?;
173
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
198
+ static fromConfig(config: Config, options: GithubOrgEntityProviderOptions): GithubOrgEntityProvider;
174
199
  constructor(options: {
175
200
  id: string;
176
201
  orgUrl: string;
177
- gitHubConfig: GitHubIntegrationConfig;
202
+ gitHubConfig: GithubIntegrationConfig;
178
203
  logger: Logger;
179
204
  githubCredentialsProvider?: GithubCredentialsProvider;
180
205
  });
@@ -193,11 +218,17 @@ export declare class GitHubOrgEntityProvider implements EntityProvider {
193
218
  }
194
219
 
195
220
  /**
196
- * Options for {@link GitHubOrgEntityProvider}.
221
+ * @public
222
+ * @deprecated Use {@link GithubOrgEntityProviderOptions} instead.
223
+ */
224
+ export declare type GitHubOrgEntityProviderOptions = GithubOrgEntityProviderOptions;
225
+
226
+ /**
227
+ * Options for {@link GithubOrgEntityProvider}.
197
228
  *
198
229
  * @public
199
230
  */
200
- export declare interface GitHubOrgEntityProviderOptions {
231
+ export declare interface GithubOrgEntityProviderOptions {
201
232
  /**
202
233
  * A unique, stable identifier for this provider.
203
234
  *
@@ -239,7 +270,7 @@ export declare interface GitHubOrgEntityProviderOptions {
239
270
  *
240
271
  * @remarks
241
272
  *
242
- * Consider using {@link GitHubOrgEntityProvider} instead.
273
+ * Consider using {@link GithubOrgEntityProvider} instead.
243
274
  *
244
275
  * @public
245
276
  */
package/dist/index.cjs.js CHANGED
@@ -38,7 +38,7 @@ function _interopNamespace(e) {
38
38
  var parseGitUrl__default = /*#__PURE__*/_interopDefaultLegacy(parseGitUrl);
39
39
  var uuid__namespace = /*#__PURE__*/_interopNamespace(uuid);
40
40
 
41
- class GitHubLocationAnalyzer {
41
+ class GithubLocationAnalyzer {
42
42
  constructor(options) {
43
43
  this.config = options.config;
44
44
  this.catalogClient = new catalogClient.CatalogClient({ discoveryApi: options.discovery });
@@ -244,14 +244,28 @@ async function getOrganizationTeams(client, org, orgNamespace) {
244
244
  );
245
245
  return { groups, groupMemberUsers };
246
246
  }
247
- async function getOrganizationRepositories(client, org) {
247
+ async function getOrganizationRepositories(client, org, catalogPath) {
248
+ let relativeCatalogPathRef;
249
+ if (catalogPath.startsWith("/")) {
250
+ relativeCatalogPathRef = catalogPath.substring(1);
251
+ } else {
252
+ relativeCatalogPathRef = catalogPath;
253
+ }
254
+ const catalogPathRef = `HEAD:${relativeCatalogPathRef}`;
248
255
  const query = `
249
- query repositories($org: String!, $cursor: String) {
256
+ query repositories($org: String!, $catalogPathRef: String!, $cursor: String) {
250
257
  repositoryOwner(login: $org) {
251
258
  login
252
259
  repositories(first: 100, after: $cursor) {
253
260
  nodes {
254
261
  name
262
+ catalogInfoFile: object(expression: $catalogPathRef) {
263
+ __typename
264
+ ... on Blob {
265
+ id
266
+ text
267
+ }
268
+ }
255
269
  url
256
270
  isArchived
257
271
  repositoryTopics(first: 100) {
@@ -282,7 +296,7 @@ async function getOrganizationRepositories(client, org) {
282
296
  return (_a = r.repositoryOwner) == null ? void 0 : _a.repositories;
283
297
  },
284
298
  (x) => x,
285
- { org }
299
+ { org, catalogPathRef }
286
300
  );
287
301
  return { repositories };
288
302
  }
@@ -372,7 +386,7 @@ function assignGroupsToUsers(users, groupMemberUsers) {
372
386
  }
373
387
  }
374
388
 
375
- function parseGitHubOrgUrl(urlString) {
389
+ function parseGithubOrgUrl(urlString) {
376
390
  const path = new URL(urlString).pathname.substr(1).split("/");
377
391
  if (path.length === 1 && path[0].length) {
378
392
  return { org: decodeURIComponent(path[0]) };
@@ -459,7 +473,11 @@ class GithubDiscoveryProcessor {
459
473
  });
460
474
  const startTimestamp = Date.now();
461
475
  this.logger.info(`Reading GitHub repositories from ${location.target}`);
462
- const { repositories } = await getOrganizationRepositories(client, org);
476
+ const { repositories } = await getOrganizationRepositories(
477
+ client,
478
+ org,
479
+ catalogPath
480
+ );
463
481
  const matching = repositories.filter(
464
482
  (r) => !r.isArchived && repoSearchPath.test(r.name)
465
483
  );
@@ -641,7 +659,7 @@ class GithubOrgReaderProcessor {
641
659
  return false;
642
660
  }
643
661
  const { client, tokenType } = await this.createClient(location.target);
644
- const { org } = parseGitHubOrgUrl(location.target);
662
+ const { org } = parseGithubOrgUrl(location.target);
645
663
  const startTimestamp = Date.now();
646
664
  this.logger.info("Reading GitHub users and groups");
647
665
  const { users } = await getOrganizationUsers(client, org, tokenType);
@@ -698,7 +716,7 @@ function readProviderConfigs(config) {
698
716
  });
699
717
  }
700
718
  function readProviderConfig(id, config) {
701
- var _a, _b;
719
+ var _a, _b, _c;
702
720
  const organization = config.getString("organization");
703
721
  const catalogPath = (_a = config.getOptionalString("catalogPath")) != null ? _a : DEFAULT_CATALOG_PATH;
704
722
  const host = (_b = config.getOptionalString("host")) != null ? _b : "github.com";
@@ -710,6 +728,13 @@ function readProviderConfig(id, config) {
710
728
  const topicFilterExclude = config == null ? void 0 : config.getOptionalStringArray(
711
729
  "filters.topic.exclude"
712
730
  );
731
+ const validateLocationsExist = (_c = config == null ? void 0 : config.getOptionalBoolean("validateLocationsExist")) != null ? _c : false;
732
+ const catalogPathContainsWildcard = catalogPath.includes("*");
733
+ if (validateLocationsExist && catalogPathContainsWildcard) {
734
+ throw Error(
735
+ `Error while processing GitHub provider config. The catalog path ${catalogPath} contains a wildcard, which is incompatible with validation of locations existing before emitting them. Ensure that validateLocationsExist is set to false.`
736
+ );
737
+ }
713
738
  const schedule = config.has("schedule") ? backendTasks.readTaskScheduleDefinitionFromConfig(config.getConfig("schedule")) : void 0;
714
739
  return {
715
740
  id,
@@ -724,7 +749,8 @@ function readProviderConfig(id, config) {
724
749
  exclude: topicFilterExclude
725
750
  }
726
751
  },
727
- schedule
752
+ schedule,
753
+ validateLocationsExist
728
754
  };
729
755
  }
730
756
  function compileRegExp(pattern) {
@@ -738,7 +764,7 @@ function compileRegExp(pattern) {
738
764
  return new RegExp(fullLinePattern);
739
765
  }
740
766
 
741
- class GitHubEntityProvider {
767
+ class GithubEntityProvider {
742
768
  static fromConfig(config, options) {
743
769
  if (!options.schedule && !options.scheduler) {
744
770
  throw new Error("Either schedule or scheduler must be provided.");
@@ -759,7 +785,7 @@ class GitHubEntityProvider {
759
785
  );
760
786
  }
761
787
  const taskRunner = (_a = options.schedule) != null ? _a : options.scheduler.createScheduledTaskRunner(providerConfig.schedule);
762
- return new GitHubEntityProvider(
788
+ return new GithubEntityProvider(
763
789
  providerConfig,
764
790
  integration,
765
791
  options.logger,
@@ -790,7 +816,7 @@ class GitHubEntityProvider {
790
816
  id: taskId,
791
817
  fn: async () => {
792
818
  const logger = this.logger.child({
793
- class: GitHubEntityProvider.prototype.constructor.name,
819
+ class: GithubEntityProvider.prototype.constructor.name,
794
820
  taskId,
795
821
  taskInstanceId: uuid__namespace.v4()
796
822
  });
@@ -809,7 +835,7 @@ class GitHubEntityProvider {
809
835
  }
810
836
  const targets = await this.findCatalogFiles();
811
837
  const matchingTargets = this.matchesFilters(targets);
812
- const entities = matchingTargets.map((repository) => this.createLocationUrl(repository)).map(GitHubEntityProvider.toLocationSpec).map((location) => {
838
+ const entities = matchingTargets.map((repository) => this.createLocationUrl(repository)).map(GithubEntityProvider.toLocationSpec).map((location) => {
813
839
  return {
814
840
  locationKey: this.getProviderName(),
815
841
  entity: pluginCatalogBackend.locationSpecToLocationEntity({ location })
@@ -826,6 +852,7 @@ class GitHubEntityProvider {
826
852
  async findCatalogFiles() {
827
853
  const organization = this.config.organization;
828
854
  const host = this.integration.host;
855
+ const catalogPath = this.config.catalogPath;
829
856
  const orgUrl = `https://${host}/${organization}`;
830
857
  const { headers } = await this.githubCredentialsProvider.getCredentials({
831
858
  url: orgUrl
@@ -836,8 +863,15 @@ class GitHubEntityProvider {
836
863
  });
837
864
  const { repositories } = await getOrganizationRepositories(
838
865
  client,
839
- organization
866
+ organization,
867
+ catalogPath
840
868
  );
869
+ if (this.config.validateLocationsExist) {
870
+ return repositories.filter((repository) => {
871
+ var _a;
872
+ return ((_a = repository.catalogInfoFile) == null ? void 0 : _a.__typename) === "Blob" && repository.catalogInfoFile.text !== "";
873
+ });
874
+ }
841
875
  return repositories;
842
876
  }
843
877
  matchesFilters(repositories) {
@@ -868,7 +902,7 @@ class GitHubEntityProvider {
868
902
  }
869
903
  }
870
904
 
871
- class GitHubOrgEntityProvider {
905
+ class GithubOrgEntityProvider {
872
906
  constructor(options) {
873
907
  this.options = options;
874
908
  this.credentialsProvider = options.githubCredentialsProvider || integration.SingleInstanceGithubCredentialsProvider.create(this.options.gitHubConfig);
@@ -885,7 +919,7 @@ class GitHubOrgEntityProvider {
885
919
  const logger = options.logger.child({
886
920
  target: options.orgUrl
887
921
  });
888
- const provider = new GitHubOrgEntityProvider({
922
+ const provider = new GithubOrgEntityProvider({
889
923
  id: options.id,
890
924
  orgUrl: options.orgUrl,
891
925
  logger,
@@ -896,7 +930,7 @@ class GitHubOrgEntityProvider {
896
930
  return provider;
897
931
  }
898
932
  getProviderName() {
899
- return `GitHubOrgEntityProvider:${this.options.id}`;
933
+ return `GithubOrgEntityProvider:${this.options.id}`;
900
934
  }
901
935
  async connect(connection) {
902
936
  var _a;
@@ -917,7 +951,7 @@ class GitHubOrgEntityProvider {
917
951
  baseUrl: this.options.gitHubConfig.apiBaseUrl,
918
952
  headers
919
953
  });
920
- const { org } = parseGitHubOrgUrl(this.options.orgUrl);
954
+ const { org } = parseGithubOrgUrl(this.options.orgUrl);
921
955
  const { users } = await getOrganizationUsers(client, org, tokenType);
922
956
  const { groups, groupMemberUsers } = await getOrganizationTeams(
923
957
  client,
@@ -949,7 +983,7 @@ class GitHubOrgEntityProvider {
949
983
  id,
950
984
  fn: async () => {
951
985
  const logger = this.options.logger.child({
952
- class: GitHubOrgEntityProvider.prototype.constructor.name,
986
+ class: GithubOrgEntityProvider.prototype.constructor.name,
953
987
  taskId: id,
954
988
  taskInstanceId: uuid__namespace.v4()
955
989
  });
@@ -1008,7 +1042,7 @@ const githubEntityProviderCatalogModule = backendPluginApi.createBackendModule({
1008
1042
  },
1009
1043
  async init({ catalog, config, logger, scheduler }) {
1010
1044
  catalog.addEntityProvider(
1011
- GitHubEntityProvider.fromConfig(config, {
1045
+ GithubEntityProvider.fromConfig(config, {
1012
1046
  logger: backendPluginApi.loggerToWinstonLogger(logger),
1013
1047
  scheduler
1014
1048
  })
@@ -1018,11 +1052,47 @@ const githubEntityProviderCatalogModule = backendPluginApi.createBackendModule({
1018
1052
  }
1019
1053
  });
1020
1054
 
1055
+ class GitHubOrgEntityProvider extends GithubOrgEntityProvider {
1056
+ static fromConfig(config, options) {
1057
+ options.logger.warn(
1058
+ "[Deprecated] Use GithubOrgEntityProvider instead of GitHubOrgEntityProvider."
1059
+ );
1060
+ return GithubOrgEntityProvider.fromConfig(
1061
+ config,
1062
+ options
1063
+ );
1064
+ }
1065
+ }
1066
+ class GitHubEntityProvider {
1067
+ constructor(delegate) {
1068
+ this.delegate = delegate;
1069
+ }
1070
+ static fromConfig(config, options) {
1071
+ options.logger.warn(
1072
+ "[Deprecated] Please use GithubEntityProvider instead of GitHubEntityProvider."
1073
+ );
1074
+ return GithubEntityProvider.fromConfig(config, options).map(
1075
+ (delegate) => new GitHubEntityProvider(delegate)
1076
+ );
1077
+ }
1078
+ connect(connection) {
1079
+ return this.delegate.connect(connection);
1080
+ }
1081
+ getProviderName() {
1082
+ return this.delegate.getProviderName();
1083
+ }
1084
+ refresh(logger) {
1085
+ return this.delegate.refresh(logger);
1086
+ }
1087
+ }
1088
+
1021
1089
  exports.GitHubEntityProvider = GitHubEntityProvider;
1022
- exports.GitHubLocationAnalyzer = GitHubLocationAnalyzer;
1023
1090
  exports.GitHubOrgEntityProvider = GitHubOrgEntityProvider;
1024
1091
  exports.GithubDiscoveryProcessor = GithubDiscoveryProcessor;
1092
+ exports.GithubEntityProvider = GithubEntityProvider;
1093
+ exports.GithubLocationAnalyzer = GithubLocationAnalyzer;
1025
1094
  exports.GithubMultiOrgReaderProcessor = GithubMultiOrgReaderProcessor;
1095
+ exports.GithubOrgEntityProvider = GithubOrgEntityProvider;
1026
1096
  exports.GithubOrgReaderProcessor = GithubOrgReaderProcessor;
1027
1097
  exports.githubEntityProviderCatalogModule = githubEntityProviderCatalogModule;
1028
1098
  //# sourceMappingURL=index.cjs.js.map