@backstage/plugin-catalog-backend 0.21.4 → 0.21.5
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 +19 -0
- package/dist/index.d.ts +1144 -0
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 0.21.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix for the previous release with missing type declarations.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-common@0.10.9
|
|
10
|
+
- @backstage/catalog-client@0.7.1
|
|
11
|
+
- @backstage/catalog-model@0.10.1
|
|
12
|
+
- @backstage/config@0.1.15
|
|
13
|
+
- @backstage/errors@0.2.2
|
|
14
|
+
- @backstage/integration@0.7.4
|
|
15
|
+
- @backstage/search-common@0.2.4
|
|
16
|
+
- @backstage/types@0.1.3
|
|
17
|
+
- @backstage/plugin-catalog-common@0.1.4
|
|
18
|
+
- @backstage/plugin-permission-common@0.5.1
|
|
19
|
+
- @backstage/plugin-permission-node@0.5.1
|
|
20
|
+
- @backstage/plugin-scaffolder-common@0.2.1
|
|
21
|
+
|
|
3
22
|
## 0.21.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1144 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
3
|
+
import { Entity, LocationSpec, EntityRelationSpec, ResourceEntityV1alpha1, EntityPolicy, Validators } from '@backstage/catalog-model';
|
|
4
|
+
import { Config } from '@backstage/config';
|
|
5
|
+
import { JsonValue, JsonObject } from '@backstage/types';
|
|
6
|
+
import { ScmIntegrationRegistry, BitbucketIntegration, GithubCredentialsProvider, GitHubIntegrationConfig } from '@backstage/integration';
|
|
7
|
+
import { Organizations } from 'aws-sdk';
|
|
8
|
+
import { Account } from 'aws-sdk/clients/organizations';
|
|
9
|
+
import { Logger } from 'winston';
|
|
10
|
+
import { UrlReader, PluginEndpointDiscovery, TokenManager, PluginDatabaseManager } from '@backstage/backend-common';
|
|
11
|
+
import * as _backstage_plugin_permission_common from '@backstage/plugin-permission-common';
|
|
12
|
+
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
13
|
+
import { IndexableDocument, DocumentCollator } from '@backstage/search-common';
|
|
14
|
+
import { GetEntitiesRequest, CatalogApi, Location } from '@backstage/catalog-client';
|
|
15
|
+
import express, { Router } from 'express';
|
|
16
|
+
import * as _backstage_plugin_permission_node from '@backstage/plugin-permission-node';
|
|
17
|
+
import { PermissionRule } from '@backstage/plugin-permission-node';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A filter expression for entities.
|
|
21
|
+
*
|
|
22
|
+
* Any (at least one) of the outer sets must match, within which all of the
|
|
23
|
+
* individual filters must match.
|
|
24
|
+
*/
|
|
25
|
+
declare type EntityFilter = {
|
|
26
|
+
allOf: EntityFilter[];
|
|
27
|
+
} | {
|
|
28
|
+
anyOf: EntityFilter[];
|
|
29
|
+
} | {
|
|
30
|
+
not: EntityFilter;
|
|
31
|
+
} | EntitiesSearchFilter;
|
|
32
|
+
/**
|
|
33
|
+
* A pagination rule for entities.
|
|
34
|
+
*/
|
|
35
|
+
declare type EntityPagination = {
|
|
36
|
+
limit?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
after?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Matches rows in the entities_search table.
|
|
42
|
+
*/
|
|
43
|
+
declare type EntitiesSearchFilter = {
|
|
44
|
+
/**
|
|
45
|
+
* The key to match on.
|
|
46
|
+
*
|
|
47
|
+
* Matches are always case insensitive.
|
|
48
|
+
*/
|
|
49
|
+
key: string;
|
|
50
|
+
/**
|
|
51
|
+
* Match on plain equality of values.
|
|
52
|
+
*
|
|
53
|
+
* Match on values that are equal to any of the given array items. Matches are
|
|
54
|
+
* always case insensitive.
|
|
55
|
+
*/
|
|
56
|
+
values?: string[];
|
|
57
|
+
};
|
|
58
|
+
declare type PageInfo = {
|
|
59
|
+
hasNextPage: false;
|
|
60
|
+
} | {
|
|
61
|
+
hasNextPage: true;
|
|
62
|
+
endCursor: string;
|
|
63
|
+
};
|
|
64
|
+
declare type EntitiesRequest = {
|
|
65
|
+
filter?: EntityFilter;
|
|
66
|
+
fields?: (entity: Entity) => Entity;
|
|
67
|
+
pagination?: EntityPagination;
|
|
68
|
+
authorizationToken?: string;
|
|
69
|
+
};
|
|
70
|
+
declare type EntitiesResponse = {
|
|
71
|
+
entities: Entity[];
|
|
72
|
+
pageInfo: PageInfo;
|
|
73
|
+
};
|
|
74
|
+
/** @public */
|
|
75
|
+
declare type EntityAncestryResponse = {
|
|
76
|
+
rootEntityRef: string;
|
|
77
|
+
items: Array<{
|
|
78
|
+
entity: Entity;
|
|
79
|
+
parentEntityRefs: string[];
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
/** @public */
|
|
83
|
+
declare type EntitiesCatalog = {
|
|
84
|
+
/**
|
|
85
|
+
* Fetch entities.
|
|
86
|
+
*
|
|
87
|
+
* @param request - Request options
|
|
88
|
+
*/
|
|
89
|
+
entities(request?: EntitiesRequest): Promise<EntitiesResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* Removes a single entity.
|
|
92
|
+
*
|
|
93
|
+
* @param uid - The metadata.uid of the entity
|
|
94
|
+
*/
|
|
95
|
+
removeEntityByUid(uid: string, options?: {
|
|
96
|
+
authorizationToken?: string;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the full ancestry tree upward along reference edges.
|
|
100
|
+
*
|
|
101
|
+
* @param entityRef - An entity reference to the root of the tree
|
|
102
|
+
*/
|
|
103
|
+
entityAncestry(entityRef: string, options?: {
|
|
104
|
+
authorizationToken?: string;
|
|
105
|
+
}): Promise<EntityAncestryResponse>;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Rules to apply to catalog entities.
|
|
110
|
+
*
|
|
111
|
+
* An undefined list of matchers means match all, an empty list of matchers means match none.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
declare type CatalogRule = {
|
|
116
|
+
allow: Array<{
|
|
117
|
+
kind: string;
|
|
118
|
+
}>;
|
|
119
|
+
locations?: Array<{
|
|
120
|
+
target?: string;
|
|
121
|
+
type: string;
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Decides whether an entity from a given location is allowed to enter the
|
|
126
|
+
* catalog, according to some rule set.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
declare type CatalogRulesEnforcer = {
|
|
131
|
+
isAllowed(entity: Entity, location: LocationSpec): boolean;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Implements the default catalog rule set, consuming the config keys
|
|
135
|
+
* `catalog.rules` and `catalog.locations.[].rules`.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
declare class DefaultCatalogRulesEnforcer implements CatalogRulesEnforcer {
|
|
140
|
+
private readonly rules;
|
|
141
|
+
/**
|
|
142
|
+
* Default rules used by the catalog.
|
|
143
|
+
*
|
|
144
|
+
* Denies any location from specifying user or group entities.
|
|
145
|
+
*/
|
|
146
|
+
static readonly defaultRules: CatalogRule[];
|
|
147
|
+
/**
|
|
148
|
+
* Loads catalog rules from config.
|
|
149
|
+
*
|
|
150
|
+
* This reads `catalog.rules` and defaults to the default rules if no value is present.
|
|
151
|
+
* The value of the config should be a list of config objects, each with a single `allow`
|
|
152
|
+
* field which in turn is a list of entity kinds to allow.
|
|
153
|
+
*
|
|
154
|
+
* If there is no matching rule to allow an ingested entity, it will be rejected by the catalog.
|
|
155
|
+
*
|
|
156
|
+
* It also reads in rules from `catalog.locations`, where each location can have a list
|
|
157
|
+
* of rules for that specific location, specified in a `rules` field.
|
|
158
|
+
*
|
|
159
|
+
* For example:
|
|
160
|
+
*
|
|
161
|
+
* ```yaml
|
|
162
|
+
* catalog:
|
|
163
|
+
* rules:
|
|
164
|
+
* - allow: [Component, API]
|
|
165
|
+
*
|
|
166
|
+
* locations:
|
|
167
|
+
* - type: url
|
|
168
|
+
* target: https://github.com/org/repo/blob/master/users.yaml
|
|
169
|
+
* rules:
|
|
170
|
+
* - allow: [User, Group]
|
|
171
|
+
* - type: url
|
|
172
|
+
* target: https://github.com/org/repo/blob/master/systems.yaml
|
|
173
|
+
* rules:
|
|
174
|
+
* - allow: [System]
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
static fromConfig(config: Config): DefaultCatalogRulesEnforcer;
|
|
178
|
+
constructor(rules: CatalogRule[]);
|
|
179
|
+
/**
|
|
180
|
+
* Checks wether a specific entity/location combination is allowed
|
|
181
|
+
* according to the configured rules.
|
|
182
|
+
*/
|
|
183
|
+
isAllowed(entity: Entity, location: LocationSpec): boolean;
|
|
184
|
+
private matchLocation;
|
|
185
|
+
private matchEntity;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare type CatalogProcessor = {
|
|
189
|
+
/**
|
|
190
|
+
* A unique identifier for the Catalog Processor.
|
|
191
|
+
* It's strongly recommended to implement getProcessorName as this method will be required in the future.
|
|
192
|
+
*/
|
|
193
|
+
getProcessorName?(): string;
|
|
194
|
+
/**
|
|
195
|
+
* Reads the contents of a location.
|
|
196
|
+
*
|
|
197
|
+
* @param location - The location to read
|
|
198
|
+
* @param optional - Whether a missing target should trigger an error
|
|
199
|
+
* @param emit - A sink for items resulting from the read
|
|
200
|
+
* @param parser - A parser, that is able to take the raw catalog descriptor
|
|
201
|
+
* data and turn it into the actual result pieces.
|
|
202
|
+
* @param cache - A cache for storing values local to this processor and the current entity.
|
|
203
|
+
* @returns True if handled by this processor, false otherwise
|
|
204
|
+
*/
|
|
205
|
+
readLocation?(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser, cache: CatalogProcessorCache): Promise<boolean>;
|
|
206
|
+
/**
|
|
207
|
+
* Pre-processes an emitted entity, after it has been emitted but before it
|
|
208
|
+
* has been validated.
|
|
209
|
+
*
|
|
210
|
+
* This type of processing usually involves enriching the entity with
|
|
211
|
+
* additional data, and the input entity may actually still be incomplete
|
|
212
|
+
* when the processor is invoked.
|
|
213
|
+
*
|
|
214
|
+
* @param entity - The (possibly partial) entity to process
|
|
215
|
+
* @param location - The location that the entity came from
|
|
216
|
+
* @param emit - A sink for auxiliary items resulting from the processing
|
|
217
|
+
* @param originLocation - The location that the entity originally came from.
|
|
218
|
+
* While location resolves to the direct parent location, originLocation
|
|
219
|
+
* tells which location was used to start the ingestion loop.
|
|
220
|
+
* @param cache - A cache for storing values local to this processor and the current entity.
|
|
221
|
+
* @returns The same entity or a modified version of it
|
|
222
|
+
*/
|
|
223
|
+
preProcessEntity?(entity: Entity, location: LocationSpec, emit: CatalogProcessorEmit, originLocation: LocationSpec, cache: CatalogProcessorCache): Promise<Entity>;
|
|
224
|
+
/**
|
|
225
|
+
* Validates the entity as a known entity kind, after it has been pre-
|
|
226
|
+
* processed and has passed through basic overall validation.
|
|
227
|
+
*
|
|
228
|
+
* @param entity - The entity to validate
|
|
229
|
+
* @returns Resolves to true, if the entity was of a kind that was known and
|
|
230
|
+
* handled by this processor, and was found to be valid. Resolves to false,
|
|
231
|
+
* if the entity was not of a kind that was known by this processor.
|
|
232
|
+
* Rejects to an Error describing the problem, if the entity was of a kind
|
|
233
|
+
* that was known by this processor and was not valid.
|
|
234
|
+
*/
|
|
235
|
+
validateEntityKind?(entity: Entity): Promise<boolean>;
|
|
236
|
+
/**
|
|
237
|
+
* Post-processes an emitted entity, after it has been validated.
|
|
238
|
+
*
|
|
239
|
+
* @param entity - The entity to process
|
|
240
|
+
* @param location - The location that the entity came from
|
|
241
|
+
* @param emit - A sink for auxiliary items resulting from the processing
|
|
242
|
+
* @param cache - A cache for storing values local to this processor and the current entity.
|
|
243
|
+
* @returns The same entity or a modified version of it
|
|
244
|
+
*/
|
|
245
|
+
postProcessEntity?(entity: Entity, location: LocationSpec, emit: CatalogProcessorEmit, cache: CatalogProcessorCache): Promise<Entity>;
|
|
246
|
+
/**
|
|
247
|
+
* Handles an emitted error.
|
|
248
|
+
*
|
|
249
|
+
* @param error - The error
|
|
250
|
+
* @param location - The location where the error occurred
|
|
251
|
+
* @param emit - A sink for items resulting from this handling
|
|
252
|
+
* @returns Nothing
|
|
253
|
+
*/
|
|
254
|
+
handleError?(error: Error, location: LocationSpec, emit: CatalogProcessorEmit): Promise<void>;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* A parser, that is able to take the raw catalog descriptor data and turn it
|
|
258
|
+
* into the actual result pieces. The default implementation performs a YAML
|
|
259
|
+
* document parsing.
|
|
260
|
+
*/
|
|
261
|
+
declare type CatalogProcessorParser = (options: {
|
|
262
|
+
data: Buffer;
|
|
263
|
+
location: LocationSpec;
|
|
264
|
+
}) => AsyncIterable<CatalogProcessorResult>;
|
|
265
|
+
/**
|
|
266
|
+
* A cache for storing data during processing.
|
|
267
|
+
*
|
|
268
|
+
* The values stored in the cache are always local to each processor, meaning
|
|
269
|
+
* no processor can see cache values from other processors.
|
|
270
|
+
*
|
|
271
|
+
* The cache instance provided to the CatalogProcessor is also scoped to the
|
|
272
|
+
* entity being processed, meaning that each processor run can't see cache
|
|
273
|
+
* values from processing runs for other entities.
|
|
274
|
+
*
|
|
275
|
+
* Values that are set during a processing run will only be visible in the directly
|
|
276
|
+
* following run. The cache will be overwritten every run unless no new cache items
|
|
277
|
+
* are written, in which case the existing values remain in the cache.
|
|
278
|
+
*
|
|
279
|
+
* @public
|
|
280
|
+
*/
|
|
281
|
+
interface CatalogProcessorCache {
|
|
282
|
+
/**
|
|
283
|
+
* Retrieve a value from the cache.
|
|
284
|
+
*/
|
|
285
|
+
get<ItemType extends JsonValue>(key: string): Promise<ItemType | undefined>;
|
|
286
|
+
/**
|
|
287
|
+
* Store a value in the cache.
|
|
288
|
+
*/
|
|
289
|
+
set<ItemType extends JsonValue>(key: string, value: ItemType): Promise<void>;
|
|
290
|
+
}
|
|
291
|
+
declare type CatalogProcessorEmit = (generated: CatalogProcessorResult) => void;
|
|
292
|
+
declare type CatalogProcessorLocationResult = {
|
|
293
|
+
type: 'location';
|
|
294
|
+
location: LocationSpec;
|
|
295
|
+
optional: boolean;
|
|
296
|
+
};
|
|
297
|
+
declare type CatalogProcessorEntityResult = {
|
|
298
|
+
type: 'entity';
|
|
299
|
+
entity: Entity;
|
|
300
|
+
location: LocationSpec;
|
|
301
|
+
};
|
|
302
|
+
declare type CatalogProcessorRelationResult = {
|
|
303
|
+
type: 'relation';
|
|
304
|
+
relation: EntityRelationSpec;
|
|
305
|
+
entityRef?: string;
|
|
306
|
+
};
|
|
307
|
+
declare type CatalogProcessorErrorResult = {
|
|
308
|
+
type: 'error';
|
|
309
|
+
error: Error;
|
|
310
|
+
location: LocationSpec;
|
|
311
|
+
};
|
|
312
|
+
declare type CatalogProcessorResult = CatalogProcessorLocationResult | CatalogProcessorEntityResult | CatalogProcessorRelationResult | CatalogProcessorErrorResult;
|
|
313
|
+
|
|
314
|
+
declare function notFoundError(atLocation: LocationSpec, message: string): CatalogProcessorResult;
|
|
315
|
+
declare function inputError(atLocation: LocationSpec, message: string): CatalogProcessorResult;
|
|
316
|
+
declare function generalError(atLocation: LocationSpec, message: string): CatalogProcessorResult;
|
|
317
|
+
declare function location(newLocation: LocationSpec, optional: boolean): CatalogProcessorResult;
|
|
318
|
+
declare function entity(atLocation: LocationSpec, newEntity: Entity): CatalogProcessorResult;
|
|
319
|
+
declare function relation(spec: EntityRelationSpec): CatalogProcessorResult;
|
|
320
|
+
|
|
321
|
+
declare const results_d_notFoundError: typeof notFoundError;
|
|
322
|
+
declare const results_d_inputError: typeof inputError;
|
|
323
|
+
declare const results_d_generalError: typeof generalError;
|
|
324
|
+
declare const results_d_location: typeof location;
|
|
325
|
+
declare const results_d_entity: typeof entity;
|
|
326
|
+
declare const results_d_relation: typeof relation;
|
|
327
|
+
declare namespace results_d {
|
|
328
|
+
export {
|
|
329
|
+
results_d_notFoundError as notFoundError,
|
|
330
|
+
results_d_inputError as inputError,
|
|
331
|
+
results_d_generalError as generalError,
|
|
332
|
+
results_d_location as location,
|
|
333
|
+
results_d_entity as entity,
|
|
334
|
+
results_d_relation as relation,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare type Options$1 = {
|
|
339
|
+
integrations: ScmIntegrationRegistry;
|
|
340
|
+
};
|
|
341
|
+
declare class AnnotateLocationEntityProcessor implements CatalogProcessor {
|
|
342
|
+
private readonly options;
|
|
343
|
+
constructor(options: Options$1);
|
|
344
|
+
preProcessEntity(entity: Entity, location: LocationSpec, _: CatalogProcessorEmit, originLocation: LocationSpec): Promise<Entity>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare class AnnotateScmSlugEntityProcessor implements CatalogProcessor {
|
|
348
|
+
private readonly opts;
|
|
349
|
+
constructor(opts: {
|
|
350
|
+
scmIntegrationRegistry: ScmIntegrationRegistry;
|
|
351
|
+
});
|
|
352
|
+
static fromConfig(config: Config): AnnotateScmSlugEntityProcessor;
|
|
353
|
+
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The configuration parameters for a single AWS Organization Processor
|
|
358
|
+
*/
|
|
359
|
+
declare type AwsOrganizationProviderConfig = {
|
|
360
|
+
/**
|
|
361
|
+
* The role to assume for the processor.
|
|
362
|
+
*/
|
|
363
|
+
roleArn?: string;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* A processor for ingesting AWS Accounts from AWS Organizations.
|
|
368
|
+
*
|
|
369
|
+
* If custom authentication is needed, it can be achieved by configuring the global AWS.credentials object.
|
|
370
|
+
*/
|
|
371
|
+
declare class AwsOrganizationCloudAccountProcessor implements CatalogProcessor {
|
|
372
|
+
logger: Logger;
|
|
373
|
+
organizations: Organizations;
|
|
374
|
+
provider: AwsOrganizationProviderConfig;
|
|
375
|
+
static fromConfig(config: Config, options: {
|
|
376
|
+
logger: Logger;
|
|
377
|
+
}): AwsOrganizationCloudAccountProcessor;
|
|
378
|
+
private static buildCredentials;
|
|
379
|
+
constructor(options: {
|
|
380
|
+
provider: AwsOrganizationProviderConfig;
|
|
381
|
+
logger: Logger;
|
|
382
|
+
});
|
|
383
|
+
normalizeName(name: string): string;
|
|
384
|
+
extractInformationFromArn(arn: string): {
|
|
385
|
+
accountId: string;
|
|
386
|
+
organizationId: string;
|
|
387
|
+
};
|
|
388
|
+
getAwsAccounts(): Promise<Account[]>;
|
|
389
|
+
mapAccountToComponent(account: Account): ResourceEntityV1alpha1;
|
|
390
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
declare class AwsS3DiscoveryProcessor implements CatalogProcessor {
|
|
394
|
+
private readonly reader;
|
|
395
|
+
constructor(reader: UrlReader);
|
|
396
|
+
readLocation(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser): Promise<boolean>;
|
|
397
|
+
private doRead;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
declare type BitbucketRepositoryParser = (options: {
|
|
401
|
+
integration: BitbucketIntegration;
|
|
402
|
+
target: string;
|
|
403
|
+
logger: Logger;
|
|
404
|
+
}) => AsyncIterable<CatalogProcessorResult>;
|
|
405
|
+
|
|
406
|
+
declare class BitbucketDiscoveryProcessor implements CatalogProcessor {
|
|
407
|
+
private readonly integrations;
|
|
408
|
+
private readonly parser;
|
|
409
|
+
private readonly logger;
|
|
410
|
+
static fromConfig(config: Config, options: {
|
|
411
|
+
parser?: BitbucketRepositoryParser;
|
|
412
|
+
logger: Logger;
|
|
413
|
+
}): BitbucketDiscoveryProcessor;
|
|
414
|
+
constructor(options: {
|
|
415
|
+
integrations: ScmIntegrationRegistry;
|
|
416
|
+
parser?: BitbucketRepositoryParser;
|
|
417
|
+
logger: Logger;
|
|
418
|
+
});
|
|
419
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
420
|
+
private processCloudRepositories;
|
|
421
|
+
private processOrganisationRepositories;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
declare class BuiltinKindsEntityProcessor implements CatalogProcessor {
|
|
425
|
+
private readonly validators;
|
|
426
|
+
validateEntityKind(entity: Entity): Promise<boolean>;
|
|
427
|
+
postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
declare class CodeOwnersProcessor implements CatalogProcessor {
|
|
431
|
+
private readonly integrations;
|
|
432
|
+
private readonly logger;
|
|
433
|
+
private readonly reader;
|
|
434
|
+
static fromConfig(config: Config, options: {
|
|
435
|
+
logger: Logger;
|
|
436
|
+
reader: UrlReader;
|
|
437
|
+
}): CodeOwnersProcessor;
|
|
438
|
+
constructor(options: {
|
|
439
|
+
integrations: ScmIntegrationRegistry;
|
|
440
|
+
logger: Logger;
|
|
441
|
+
reader: UrlReader;
|
|
442
|
+
});
|
|
443
|
+
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
declare class FileReaderProcessor implements CatalogProcessor {
|
|
447
|
+
readLocation(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser): Promise<boolean>;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Extracts repositories out of a GitHub org.
|
|
452
|
+
*
|
|
453
|
+
* The following will create locations for all projects which have a catalog-info.yaml
|
|
454
|
+
* on the default branch. The first is shorthand for the second.
|
|
455
|
+
*
|
|
456
|
+
* target: "https://github.com/backstage"
|
|
457
|
+
* or
|
|
458
|
+
* target: https://github.com/backstage/*\/blob/-/catalog-info.yaml
|
|
459
|
+
*
|
|
460
|
+
* You may also explicitly specify the source branch:
|
|
461
|
+
*
|
|
462
|
+
* target: https://github.com/backstage/*\/blob/main/catalog-info.yaml
|
|
463
|
+
**/
|
|
464
|
+
declare class GithubDiscoveryProcessor implements CatalogProcessor {
|
|
465
|
+
private readonly integrations;
|
|
466
|
+
private readonly logger;
|
|
467
|
+
private readonly githubCredentialsProvider;
|
|
468
|
+
static fromConfig(config: Config, options: {
|
|
469
|
+
logger: Logger;
|
|
470
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
471
|
+
}): GithubDiscoveryProcessor;
|
|
472
|
+
constructor(options: {
|
|
473
|
+
integrations: ScmIntegrationRegistry;
|
|
474
|
+
logger: Logger;
|
|
475
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
476
|
+
});
|
|
477
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Extracts repositories out of an Azure DevOps org.
|
|
482
|
+
*
|
|
483
|
+
* The following will create locations for all projects which have a catalog-info.yaml
|
|
484
|
+
* on the default branch. The first is shorthand for the second.
|
|
485
|
+
*
|
|
486
|
+
* target: "https://dev.azure.com/org/project"
|
|
487
|
+
* or
|
|
488
|
+
* target: https://dev.azure.com/org/project?path=/catalog-info.yaml
|
|
489
|
+
*
|
|
490
|
+
* You may also explicitly specify a single repo:
|
|
491
|
+
*
|
|
492
|
+
* target: https://dev.azure.com/org/project/_git/repo
|
|
493
|
+
**/
|
|
494
|
+
declare class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
|
|
495
|
+
private readonly integrations;
|
|
496
|
+
private readonly logger;
|
|
497
|
+
static fromConfig(config: Config, options: {
|
|
498
|
+
logger: Logger;
|
|
499
|
+
}): AzureDevOpsDiscoveryProcessor;
|
|
500
|
+
constructor(options: {
|
|
501
|
+
integrations: ScmIntegrationRegistry;
|
|
502
|
+
logger: Logger;
|
|
503
|
+
});
|
|
504
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Extracts teams and users out of a GitHub org.
|
|
509
|
+
*/
|
|
510
|
+
declare class GithubOrgReaderProcessor implements CatalogProcessor {
|
|
511
|
+
private readonly integrations;
|
|
512
|
+
private readonly logger;
|
|
513
|
+
private readonly githubCredentialsProvider;
|
|
514
|
+
static fromConfig(config: Config, options: {
|
|
515
|
+
logger: Logger;
|
|
516
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
517
|
+
}): GithubOrgReaderProcessor;
|
|
518
|
+
constructor(options: {
|
|
519
|
+
integrations: ScmIntegrationRegistry;
|
|
520
|
+
logger: Logger;
|
|
521
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
522
|
+
});
|
|
523
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
524
|
+
private createClient;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* The configuration parameters for a multi-org GitHub processor.
|
|
529
|
+
*/
|
|
530
|
+
declare type GithubMultiOrgConfig = Array<{
|
|
531
|
+
/**
|
|
532
|
+
* The name of the GitHub org to process.
|
|
533
|
+
*/
|
|
534
|
+
name: string;
|
|
535
|
+
/**
|
|
536
|
+
* The namespace of the group created for this org.
|
|
537
|
+
*/
|
|
538
|
+
groupNamespace: string;
|
|
539
|
+
/**
|
|
540
|
+
* The namespace of the users created for this org. If not specified defaults to undefined.
|
|
541
|
+
*/
|
|
542
|
+
userNamespace: string | undefined;
|
|
543
|
+
}>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @alpha
|
|
547
|
+
* Extracts teams and users out of a multiple GitHub orgs namespaced per org.
|
|
548
|
+
*
|
|
549
|
+
* Be aware that this processor may not be compatible with future org structures in the catalog.
|
|
550
|
+
*/
|
|
551
|
+
declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
|
552
|
+
private readonly integrations;
|
|
553
|
+
private readonly orgs;
|
|
554
|
+
private readonly logger;
|
|
555
|
+
private readonly githubCredentialsProvider;
|
|
556
|
+
static fromConfig(config: Config, options: {
|
|
557
|
+
logger: Logger;
|
|
558
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
559
|
+
}): GithubMultiOrgReaderProcessor;
|
|
560
|
+
constructor(options: {
|
|
561
|
+
integrations: ScmIntegrationRegistry;
|
|
562
|
+
logger: Logger;
|
|
563
|
+
orgs: GithubMultiOrgConfig;
|
|
564
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
565
|
+
});
|
|
566
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
567
|
+
private getAllOrgs;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Extracts repositories out of an GitLab instance.
|
|
572
|
+
*/
|
|
573
|
+
declare class GitLabDiscoveryProcessor implements CatalogProcessor {
|
|
574
|
+
private readonly integrations;
|
|
575
|
+
private readonly logger;
|
|
576
|
+
private readonly cache;
|
|
577
|
+
static fromConfig(config: Config, options: {
|
|
578
|
+
logger: Logger;
|
|
579
|
+
}): GitLabDiscoveryProcessor;
|
|
580
|
+
private constructor();
|
|
581
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
582
|
+
updateLastActivity(): Promise<string | undefined>;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
declare type LocationEntityProcessorOptions = {
|
|
586
|
+
integrations: ScmIntegrationRegistry;
|
|
587
|
+
};
|
|
588
|
+
declare class LocationEntityProcessor implements CatalogProcessor {
|
|
589
|
+
private readonly options;
|
|
590
|
+
constructor(options: LocationEntityProcessorOptions);
|
|
591
|
+
postProcessEntity(entity: Entity, location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
declare type PlaceholderResolverRead = (url: string) => Promise<Buffer>;
|
|
595
|
+
declare type PlaceholderResolverResolveUrl = (url: string, base: string) => string;
|
|
596
|
+
declare type PlaceholderResolverParams = {
|
|
597
|
+
key: string;
|
|
598
|
+
value: JsonValue;
|
|
599
|
+
baseUrl: string;
|
|
600
|
+
read: PlaceholderResolverRead;
|
|
601
|
+
resolveUrl: PlaceholderResolverResolveUrl;
|
|
602
|
+
};
|
|
603
|
+
declare type PlaceholderResolver = (params: PlaceholderResolverParams) => Promise<JsonValue>;
|
|
604
|
+
declare type PlaceholderProcessorOptions = {
|
|
605
|
+
resolvers: Record<string, PlaceholderResolver>;
|
|
606
|
+
reader: UrlReader;
|
|
607
|
+
integrations: ScmIntegrationRegistry;
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* Traverses raw entity JSON looking for occurrences of $-prefixed placeholders
|
|
611
|
+
* that it then fills in with actual data.
|
|
612
|
+
*/
|
|
613
|
+
declare class PlaceholderProcessor implements CatalogProcessor {
|
|
614
|
+
private readonly options;
|
|
615
|
+
constructor(options: PlaceholderProcessorOptions);
|
|
616
|
+
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
declare class StaticLocationProcessor implements StaticLocationProcessor {
|
|
620
|
+
private readonly staticLocations;
|
|
621
|
+
static fromConfig(config: Config): StaticLocationProcessor;
|
|
622
|
+
constructor(staticLocations: LocationSpec[]);
|
|
623
|
+
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
declare type Options = {
|
|
627
|
+
reader: UrlReader;
|
|
628
|
+
logger: Logger;
|
|
629
|
+
};
|
|
630
|
+
declare class UrlReaderProcessor implements CatalogProcessor {
|
|
631
|
+
private readonly options;
|
|
632
|
+
constructor(options: Options);
|
|
633
|
+
getProcessorName(): string;
|
|
634
|
+
readLocation(location: LocationSpec, optional: boolean, emit: CatalogProcessorEmit, parser: CatalogProcessorParser, cache: CatalogProcessorCache): Promise<boolean>;
|
|
635
|
+
private doRead;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
declare function parseEntityYaml(data: Buffer, location: LocationSpec): Iterable<CatalogProcessorResult>;
|
|
639
|
+
|
|
640
|
+
declare type EntityProcessingRequest = {
|
|
641
|
+
entity: Entity;
|
|
642
|
+
state?: JsonObject;
|
|
643
|
+
};
|
|
644
|
+
declare type EntityProcessingResult = {
|
|
645
|
+
ok: true;
|
|
646
|
+
state: JsonObject;
|
|
647
|
+
completedEntity: Entity;
|
|
648
|
+
deferredEntities: DeferredEntity[];
|
|
649
|
+
relations: EntityRelationSpec[];
|
|
650
|
+
errors: Error[];
|
|
651
|
+
} | {
|
|
652
|
+
ok: false;
|
|
653
|
+
errors: Error[];
|
|
654
|
+
};
|
|
655
|
+
interface CatalogProcessingOrchestrator {
|
|
656
|
+
process(request: EntityProcessingRequest): Promise<EntityProcessingResult>;
|
|
657
|
+
}
|
|
658
|
+
declare type DeferredEntity = {
|
|
659
|
+
entity: Entity;
|
|
660
|
+
locationKey?: string;
|
|
661
|
+
};
|
|
662
|
+
interface CatalogProcessingEngine {
|
|
663
|
+
start(): Promise<void>;
|
|
664
|
+
stop(): Promise<void>;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
declare class DefaultCatalogProcessingOrchestrator implements CatalogProcessingOrchestrator {
|
|
668
|
+
private readonly options;
|
|
669
|
+
constructor(options: {
|
|
670
|
+
processors: CatalogProcessor[];
|
|
671
|
+
integrations: ScmIntegrationRegistry;
|
|
672
|
+
logger: Logger;
|
|
673
|
+
parser: CatalogProcessorParser;
|
|
674
|
+
policy: EntityPolicy;
|
|
675
|
+
rulesEnforcer: CatalogRulesEnforcer;
|
|
676
|
+
});
|
|
677
|
+
process(request: EntityProcessingRequest): Promise<EntityProcessingResult>;
|
|
678
|
+
private processSingleEntity;
|
|
679
|
+
private runPreProcessStep;
|
|
680
|
+
/**
|
|
681
|
+
* Enforce entity policies making sure that entities conform to a general schema
|
|
682
|
+
*/
|
|
683
|
+
private runPolicyStep;
|
|
684
|
+
/**
|
|
685
|
+
* Validate the given entity
|
|
686
|
+
*/
|
|
687
|
+
private runValidateStep;
|
|
688
|
+
/**
|
|
689
|
+
* Backwards compatible processing of location entities
|
|
690
|
+
*/
|
|
691
|
+
private runSpecialLocationStep;
|
|
692
|
+
/**
|
|
693
|
+
* Main processing step of the entity
|
|
694
|
+
*/
|
|
695
|
+
private runPostProcessStep;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Function that returns the catalog refresh interval in seconds.
|
|
700
|
+
*/
|
|
701
|
+
declare type RefreshIntervalFunction = () => number;
|
|
702
|
+
/**
|
|
703
|
+
* Creates a function that returns a random refresh interval between minSeconds and maxSeconds.
|
|
704
|
+
* @returns A {@link RefreshIntervalFunction} that provides the next refresh interval
|
|
705
|
+
*/
|
|
706
|
+
declare function createRandomRefreshInterval(options: {
|
|
707
|
+
minSeconds: number;
|
|
708
|
+
maxSeconds: number;
|
|
709
|
+
}): RefreshIntervalFunction;
|
|
710
|
+
|
|
711
|
+
declare type EntityProviderMutation = {
|
|
712
|
+
type: 'full';
|
|
713
|
+
entities: DeferredEntity[];
|
|
714
|
+
} | {
|
|
715
|
+
type: 'delta';
|
|
716
|
+
added: DeferredEntity[];
|
|
717
|
+
removed: DeferredEntity[];
|
|
718
|
+
};
|
|
719
|
+
interface EntityProviderConnection {
|
|
720
|
+
applyMutation(mutation: EntityProviderMutation): Promise<void>;
|
|
721
|
+
}
|
|
722
|
+
interface EntityProvider {
|
|
723
|
+
getProviderName(): string;
|
|
724
|
+
connect(connection: EntityProviderConnection): Promise<void>;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
declare class GitHubOrgEntityProvider implements EntityProvider {
|
|
728
|
+
private options;
|
|
729
|
+
private connection?;
|
|
730
|
+
private githubCredentialsProvider;
|
|
731
|
+
static fromConfig(config: Config, options: {
|
|
732
|
+
id: string;
|
|
733
|
+
orgUrl: string;
|
|
734
|
+
logger: Logger;
|
|
735
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
736
|
+
}): GitHubOrgEntityProvider;
|
|
737
|
+
constructor(options: {
|
|
738
|
+
id: string;
|
|
739
|
+
orgUrl: string;
|
|
740
|
+
gitHubConfig: GitHubIntegrationConfig;
|
|
741
|
+
logger: Logger;
|
|
742
|
+
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
743
|
+
});
|
|
744
|
+
getProviderName(): string;
|
|
745
|
+
connect(connection: EntityProviderConnection): Promise<void>;
|
|
746
|
+
read(): Promise<void>;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Makes all keys of an entire hierarchy optional.
|
|
751
|
+
*/
|
|
752
|
+
declare type RecursivePartial<T> = {
|
|
753
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
declare type LocationAnalyzer = {
|
|
757
|
+
/**
|
|
758
|
+
* Generates an entity configuration for given git repository. It's used for
|
|
759
|
+
* importing new component to the backstage app.
|
|
760
|
+
*
|
|
761
|
+
* @param location - Git repository to analyze and generate config for.
|
|
762
|
+
*/
|
|
763
|
+
analyzeLocation(location: AnalyzeLocationRequest): Promise<AnalyzeLocationResponse>;
|
|
764
|
+
};
|
|
765
|
+
declare type AnalyzeLocationRequest = {
|
|
766
|
+
location: LocationSpec;
|
|
767
|
+
};
|
|
768
|
+
declare type AnalyzeLocationResponse = {
|
|
769
|
+
existingEntityFiles: AnalyzeLocationExistingEntity[];
|
|
770
|
+
generateEntities: AnalyzeLocationGenerateEntity[];
|
|
771
|
+
};
|
|
772
|
+
declare type AnalyzeLocationExistingEntity = {
|
|
773
|
+
location: LocationSpec;
|
|
774
|
+
isRegistered: boolean;
|
|
775
|
+
entity: Entity;
|
|
776
|
+
};
|
|
777
|
+
declare type AnalyzeLocationGenerateEntity = {
|
|
778
|
+
entity: RecursivePartial<Entity>;
|
|
779
|
+
fields: AnalyzeLocationEntityField[];
|
|
780
|
+
};
|
|
781
|
+
declare type AnalyzeLocationEntityField = {
|
|
782
|
+
field: string;
|
|
783
|
+
state: 'analysisSuggestedValue' | 'analysisSuggestedNoValue' | 'needsUserInput';
|
|
784
|
+
value: string | null;
|
|
785
|
+
description: string;
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
interface CatalogEntityDocument extends IndexableDocument {
|
|
789
|
+
componentType: string;
|
|
790
|
+
namespace: string;
|
|
791
|
+
kind: string;
|
|
792
|
+
lifecycle: string;
|
|
793
|
+
owner: string;
|
|
794
|
+
}
|
|
795
|
+
declare class DefaultCatalogCollator implements DocumentCollator {
|
|
796
|
+
protected discovery: PluginEndpointDiscovery;
|
|
797
|
+
protected locationTemplate: string;
|
|
798
|
+
protected filter?: GetEntitiesRequest['filter'];
|
|
799
|
+
protected readonly catalogClient: CatalogApi;
|
|
800
|
+
readonly type: string;
|
|
801
|
+
readonly visibilityPermission: _backstage_plugin_permission_common.Permission;
|
|
802
|
+
protected tokenManager: TokenManager;
|
|
803
|
+
static fromConfig(_config: Config, options: {
|
|
804
|
+
discovery: PluginEndpointDiscovery;
|
|
805
|
+
tokenManager: TokenManager;
|
|
806
|
+
filter?: GetEntitiesRequest['filter'];
|
|
807
|
+
}): DefaultCatalogCollator;
|
|
808
|
+
constructor(options: {
|
|
809
|
+
discovery: PluginEndpointDiscovery;
|
|
810
|
+
tokenManager: TokenManager;
|
|
811
|
+
locationTemplate?: string;
|
|
812
|
+
filter?: GetEntitiesRequest['filter'];
|
|
813
|
+
catalogClient?: CatalogApi;
|
|
814
|
+
});
|
|
815
|
+
protected applyArgsToFormat(format: string, args: Record<string, string>): string;
|
|
816
|
+
private isUserEntity;
|
|
817
|
+
private getDocumentText;
|
|
818
|
+
execute(): Promise<CatalogEntityDocument[]>;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Runs a function repeatedly, with a fixed wait between invocations.
|
|
823
|
+
*
|
|
824
|
+
* Supports async functions, and silently ignores exceptions and rejections.
|
|
825
|
+
*
|
|
826
|
+
* @param fn - The function to run. May return a Promise.
|
|
827
|
+
* @param delayMs - The delay between a completed function invocation and the
|
|
828
|
+
* next.
|
|
829
|
+
* @returns A function that, when called, stops the invocation loop.
|
|
830
|
+
*/
|
|
831
|
+
declare function runPeriodically(fn: () => any, delayMs: number): () => void;
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Returns a string with the elapsed time since the start of an operation,
|
|
835
|
+
* with some human friendly precision, e.g. "133ms" or "14.5s".
|
|
836
|
+
*
|
|
837
|
+
* @param startTimestamp - The timestamp (from process.hrtime()) at the start ot
|
|
838
|
+
* the operation
|
|
839
|
+
*/
|
|
840
|
+
declare function durationText(startTimestamp: [number, number]): string;
|
|
841
|
+
|
|
842
|
+
interface LocationService {
|
|
843
|
+
createLocation(spec: LocationSpec, dryRun: boolean, options?: {
|
|
844
|
+
authorizationToken?: string;
|
|
845
|
+
}): Promise<{
|
|
846
|
+
location: Location;
|
|
847
|
+
entities: Entity[];
|
|
848
|
+
exists?: boolean;
|
|
849
|
+
}>;
|
|
850
|
+
listLocations(options?: {
|
|
851
|
+
authorizationToken?: string;
|
|
852
|
+
}): Promise<Location[]>;
|
|
853
|
+
getLocation(id: string, options?: {
|
|
854
|
+
authorizationToken?: string;
|
|
855
|
+
}): Promise<Location>;
|
|
856
|
+
deleteLocation(id: string, options?: {
|
|
857
|
+
authorizationToken?: string;
|
|
858
|
+
}): Promise<void>;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Options for requesting a refresh of entities in the catalog.
|
|
862
|
+
*
|
|
863
|
+
* @public
|
|
864
|
+
*/
|
|
865
|
+
declare type RefreshOptions = {
|
|
866
|
+
/** The reference to a single entity that should be refreshed */
|
|
867
|
+
entityRef: string;
|
|
868
|
+
authorizationToken?: string;
|
|
869
|
+
};
|
|
870
|
+
/**
|
|
871
|
+
* A service that manages refreshes of entities in the catalog.
|
|
872
|
+
*
|
|
873
|
+
* @public
|
|
874
|
+
*/
|
|
875
|
+
interface RefreshService {
|
|
876
|
+
/**
|
|
877
|
+
* Request a refresh of entities in the catalog.
|
|
878
|
+
*/
|
|
879
|
+
refresh(options: RefreshOptions): Promise<void>;
|
|
880
|
+
}
|
|
881
|
+
interface LocationStore {
|
|
882
|
+
createLocation(spec: LocationSpec): Promise<Location>;
|
|
883
|
+
listLocations(): Promise<Location[]>;
|
|
884
|
+
getLocation(id: string): Promise<Location>;
|
|
885
|
+
deleteLocation(id: string): Promise<void>;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Options used by {@link createRouter}.
|
|
890
|
+
*
|
|
891
|
+
* @public
|
|
892
|
+
*/
|
|
893
|
+
interface RouterOptions {
|
|
894
|
+
entitiesCatalog?: EntitiesCatalog;
|
|
895
|
+
locationAnalyzer?: LocationAnalyzer;
|
|
896
|
+
locationService: LocationService;
|
|
897
|
+
refreshService?: RefreshService;
|
|
898
|
+
logger: Logger;
|
|
899
|
+
config: Config;
|
|
900
|
+
permissionIntegrationRouter?: express.Router;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Creates a catalog router.
|
|
904
|
+
*
|
|
905
|
+
* @public
|
|
906
|
+
*/
|
|
907
|
+
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
908
|
+
|
|
909
|
+
declare type CatalogEnvironment = {
|
|
910
|
+
logger: Logger;
|
|
911
|
+
database: PluginDatabaseManager;
|
|
912
|
+
config: Config;
|
|
913
|
+
reader: UrlReader;
|
|
914
|
+
permissions: PermissionAuthorizer;
|
|
915
|
+
};
|
|
916
|
+
/**
|
|
917
|
+
* A builder that helps wire up all of the component parts of the catalog.
|
|
918
|
+
*
|
|
919
|
+
* The touch points where you can replace or extend behavior are as follows:
|
|
920
|
+
*
|
|
921
|
+
* - Entity policies can be added or replaced. These are automatically run
|
|
922
|
+
* after the processors' pre-processing steps. All policies are given the
|
|
923
|
+
* chance to inspect the entity, and all of them have to pass in order for
|
|
924
|
+
* the entity to be considered valid from an overall point of view.
|
|
925
|
+
* - Placeholder resolvers can be replaced or added. These run on the raw
|
|
926
|
+
* structured data between the parsing and pre-processing steps, to replace
|
|
927
|
+
* dollar-prefixed entries with their actual values (like $file).
|
|
928
|
+
* - Field format validators can be replaced. These check the format of
|
|
929
|
+
* individual core fields such as metadata.name, to ensure that they adhere
|
|
930
|
+
* to certain rules.
|
|
931
|
+
* - Processors can be added or replaced. These implement the functionality of
|
|
932
|
+
* reading, parsing, validating, and processing the entity data before it is
|
|
933
|
+
* persisted in the catalog.
|
|
934
|
+
*
|
|
935
|
+
* @public
|
|
936
|
+
*/
|
|
937
|
+
declare class CatalogBuilder {
|
|
938
|
+
private readonly env;
|
|
939
|
+
private entityPolicies;
|
|
940
|
+
private entityPoliciesReplace;
|
|
941
|
+
private placeholderResolvers;
|
|
942
|
+
private fieldFormatValidators;
|
|
943
|
+
private entityProviders;
|
|
944
|
+
private processors;
|
|
945
|
+
private processorsReplace;
|
|
946
|
+
private parser;
|
|
947
|
+
private refreshInterval;
|
|
948
|
+
private locationAnalyzer;
|
|
949
|
+
private permissionRules;
|
|
950
|
+
/**
|
|
951
|
+
* Creates a catalog builder.
|
|
952
|
+
*/
|
|
953
|
+
static create(env: CatalogEnvironment): CatalogBuilder;
|
|
954
|
+
private constructor();
|
|
955
|
+
/**
|
|
956
|
+
* Adds policies that are used to validate entities between the pre-
|
|
957
|
+
* processing and post-processing stages. All such policies must pass for the
|
|
958
|
+
* entity to be considered valid.
|
|
959
|
+
*
|
|
960
|
+
* If what you want to do is to replace the rules for what format is allowed
|
|
961
|
+
* in various core entity fields (such as metadata.name), you may want to use
|
|
962
|
+
* {@link CatalogBuilder#setFieldFormatValidators} instead.
|
|
963
|
+
*
|
|
964
|
+
* @param policies - One or more policies
|
|
965
|
+
*/
|
|
966
|
+
addEntityPolicy(...policies: EntityPolicy[]): CatalogBuilder;
|
|
967
|
+
/**
|
|
968
|
+
* Refresh interval determines how often entities should be refreshed.
|
|
969
|
+
* Seconds provided will be multiplied by 1.5
|
|
970
|
+
* The default refresh duration is 100-150 seconds.
|
|
971
|
+
* setting this too low will potentially deplete request quotas to upstream services.
|
|
972
|
+
*/
|
|
973
|
+
setRefreshIntervalSeconds(seconds: number): CatalogBuilder;
|
|
974
|
+
/**
|
|
975
|
+
* Overwrites the default refresh interval function used to spread
|
|
976
|
+
* entity updates in the catalog.
|
|
977
|
+
*/
|
|
978
|
+
setRefreshInterval(refreshInterval: RefreshIntervalFunction): CatalogBuilder;
|
|
979
|
+
/**
|
|
980
|
+
* Overwrites the default location analyzer.
|
|
981
|
+
*/
|
|
982
|
+
setLocationAnalyzer(locationAnalyzer: LocationAnalyzer): CatalogBuilder;
|
|
983
|
+
/**
|
|
984
|
+
* Sets what policies to use for validation of entities between the pre-
|
|
985
|
+
* processing and post-processing stages. All such policies must pass for the
|
|
986
|
+
* entity to be considered valid.
|
|
987
|
+
*
|
|
988
|
+
* If what you want to do is to replace the rules for what format is allowed
|
|
989
|
+
* in various core entity fields (such as metadata.name), you may want to use
|
|
990
|
+
* {@link CatalogBuilder#setFieldFormatValidators} instead.
|
|
991
|
+
*
|
|
992
|
+
* This function replaces the default set of policies; use with care.
|
|
993
|
+
*
|
|
994
|
+
* @param policies - One or more policies
|
|
995
|
+
*/
|
|
996
|
+
replaceEntityPolicies(policies: EntityPolicy[]): CatalogBuilder;
|
|
997
|
+
/**
|
|
998
|
+
* Adds, or overwrites, a handler for placeholders (e.g. $file) in entity
|
|
999
|
+
* definition files.
|
|
1000
|
+
*
|
|
1001
|
+
* @param key - The key that identifies the placeholder, e.g. "file"
|
|
1002
|
+
* @param resolver - The resolver that gets values for this placeholder
|
|
1003
|
+
*/
|
|
1004
|
+
setPlaceholderResolver(key: string, resolver: PlaceholderResolver): CatalogBuilder;
|
|
1005
|
+
/**
|
|
1006
|
+
* Sets the validator function to use for one or more special fields of an
|
|
1007
|
+
* entity. This is useful if the default rules for formatting of fields are
|
|
1008
|
+
* not sufficient.
|
|
1009
|
+
*
|
|
1010
|
+
* This function has no effect if used together with
|
|
1011
|
+
* {@link CatalogBuilder#replaceEntityPolicies}.
|
|
1012
|
+
*
|
|
1013
|
+
* @param validators - The (subset of) validators to set
|
|
1014
|
+
*/
|
|
1015
|
+
setFieldFormatValidators(validators: Partial<Validators>): CatalogBuilder;
|
|
1016
|
+
/**
|
|
1017
|
+
* Adds or replaces entity providers. These are responsible for bootstrapping
|
|
1018
|
+
* the list of entities out of original data sources. For example, there is
|
|
1019
|
+
* one entity source for the config locations, and one for the database
|
|
1020
|
+
* stored locations. If you ingest entities out of a third party system, you
|
|
1021
|
+
* may want to implement that in terms of an entity provider as well.
|
|
1022
|
+
*
|
|
1023
|
+
* @param providers - One or more entity providers
|
|
1024
|
+
*/
|
|
1025
|
+
addEntityProvider(...providers: EntityProvider[]): CatalogBuilder;
|
|
1026
|
+
/**
|
|
1027
|
+
* Adds entity processors. These are responsible for reading, parsing, and
|
|
1028
|
+
* processing entities before they are persisted in the catalog.
|
|
1029
|
+
*
|
|
1030
|
+
* @param processors - One or more processors
|
|
1031
|
+
*/
|
|
1032
|
+
addProcessor(...processors: CatalogProcessor[]): CatalogBuilder;
|
|
1033
|
+
/**
|
|
1034
|
+
* Sets what entity processors to use. These are responsible for reading,
|
|
1035
|
+
* parsing, and processing entities before they are persisted in the catalog.
|
|
1036
|
+
*
|
|
1037
|
+
* This function replaces the default set of processors, consider using with
|
|
1038
|
+
* {@link CatalogBuilder#getDefaultProcessors}; use with care.
|
|
1039
|
+
*
|
|
1040
|
+
* @param processors - One or more processors
|
|
1041
|
+
*/
|
|
1042
|
+
replaceProcessors(processors: CatalogProcessor[]): CatalogBuilder;
|
|
1043
|
+
/**
|
|
1044
|
+
* Returns the default list of entity processors. These are responsible for reading,
|
|
1045
|
+
* parsing, and processing entities before they are persisted in the catalog. Changing
|
|
1046
|
+
* the order of processing can give more control to custom processors.
|
|
1047
|
+
*
|
|
1048
|
+
* Consider using with {@link CatalogBuilder#replaceProcessors}
|
|
1049
|
+
*
|
|
1050
|
+
*/
|
|
1051
|
+
getDefaultProcessors(): CatalogProcessor[];
|
|
1052
|
+
/**
|
|
1053
|
+
* Sets up the catalog to use a custom parser for entity data.
|
|
1054
|
+
*
|
|
1055
|
+
* This is the function that gets called immediately after some raw entity
|
|
1056
|
+
* specification data has been read from a remote source, and needs to be
|
|
1057
|
+
* parsed and emitted as structured data.
|
|
1058
|
+
*
|
|
1059
|
+
* @param parser - The custom parser
|
|
1060
|
+
*/
|
|
1061
|
+
setEntityDataParser(parser: CatalogProcessorParser): CatalogBuilder;
|
|
1062
|
+
/**
|
|
1063
|
+
* Adds additional permission rules. Permission rules are used to evaluate
|
|
1064
|
+
* catalog resources against queries. See
|
|
1065
|
+
* {@link @backstage/plugin-permission-node#PermissionRule}.
|
|
1066
|
+
*
|
|
1067
|
+
* @param permissionRules - Additional permission rules
|
|
1068
|
+
*/
|
|
1069
|
+
addPermissionRules(...permissionRules: PermissionRule<Entity, EntitiesSearchFilter, unknown[]>[]): void;
|
|
1070
|
+
/**
|
|
1071
|
+
* Wires up and returns all of the component parts of the catalog
|
|
1072
|
+
*/
|
|
1073
|
+
build(): Promise<{
|
|
1074
|
+
entitiesCatalog: EntitiesCatalog;
|
|
1075
|
+
locationAnalyzer: LocationAnalyzer;
|
|
1076
|
+
processingEngine: CatalogProcessingEngine;
|
|
1077
|
+
locationService: LocationService;
|
|
1078
|
+
router: Router;
|
|
1079
|
+
}>;
|
|
1080
|
+
private buildEntityPolicy;
|
|
1081
|
+
private buildProcessors;
|
|
1082
|
+
private checkDeprecatedReaderProcessors;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* These conditions are used when creating conditional decisions that are returned
|
|
1087
|
+
* by authorization policies.
|
|
1088
|
+
* @public
|
|
1089
|
+
*/
|
|
1090
|
+
declare const catalogConditions: _backstage_plugin_permission_node.Conditions<{
|
|
1091
|
+
hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [annotation: string]>;
|
|
1092
|
+
hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [label: string]>;
|
|
1093
|
+
hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
1094
|
+
hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
1095
|
+
isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [kinds: string[]]>;
|
|
1096
|
+
isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [claims: string[]]>;
|
|
1097
|
+
}>;
|
|
1098
|
+
/**
|
|
1099
|
+
* `createCatalogPolicyDecision` can be used when authoring policies to create
|
|
1100
|
+
* conditional decisions.
|
|
1101
|
+
*
|
|
1102
|
+
* ```
|
|
1103
|
+
* // MyAuthorizationPolicy.ts
|
|
1104
|
+
* ...
|
|
1105
|
+
* import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';
|
|
1106
|
+
*
|
|
1107
|
+
* class MyAuthorizationPolicy implements PermissionPolicy {
|
|
1108
|
+
* async handle(request, user) {
|
|
1109
|
+
* ...
|
|
1110
|
+
*
|
|
1111
|
+
* return createCatalogPolicyDecision({
|
|
1112
|
+
* anyOf: [...insert conditions here...],
|
|
1113
|
+
* });
|
|
1114
|
+
* }
|
|
1115
|
+
* }
|
|
1116
|
+
* ```
|
|
1117
|
+
* @public
|
|
1118
|
+
*/
|
|
1119
|
+
declare const createCatalogPolicyDecision: (conditions: _backstage_plugin_permission_common.PermissionCriteria<_backstage_plugin_permission_common.PermissionCondition<unknown[]>>) => _backstage_plugin_permission_node.ConditionalPolicyDecision;
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Helper function for creating correctly-typed
|
|
1123
|
+
* {@link @backstage/plugin-permission-node#PermissionRule}s for the
|
|
1124
|
+
* catalog-backend.
|
|
1125
|
+
*
|
|
1126
|
+
* @public
|
|
1127
|
+
*/
|
|
1128
|
+
declare const createCatalogPermissionRule: <TParams extends unknown[]>(rule: _backstage_plugin_permission_node.PermissionRule<Entity, EntitiesSearchFilter, TParams>) => _backstage_plugin_permission_node.PermissionRule<Entity, EntitiesSearchFilter, TParams>;
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* These permission rules can be used to conditionally filter catalog entities
|
|
1132
|
+
* or describe a user's access to the entities.
|
|
1133
|
+
* @public
|
|
1134
|
+
*/
|
|
1135
|
+
declare const permissionRules: {
|
|
1136
|
+
hasAnnotation: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [annotation: string]>;
|
|
1137
|
+
hasLabel: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [label: string]>;
|
|
1138
|
+
hasMetadata: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
1139
|
+
hasSpec: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
1140
|
+
isEntityKind: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [kinds: string[]]>;
|
|
1141
|
+
isEntityOwner: _backstage_plugin_permission_node.PermissionRule<_backstage_catalog_model.Entity, EntitiesSearchFilter, [claims: string[]]>;
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
export { AnalyzeLocationEntityField, AnalyzeLocationExistingEntity, AnalyzeLocationGenerateEntity, AnalyzeLocationRequest, AnalyzeLocationResponse, AnnotateLocationEntityProcessor, AnnotateScmSlugEntityProcessor, AwsOrganizationCloudAccountProcessor, AwsOrganizationProviderConfig, AwsS3DiscoveryProcessor, AzureDevOpsDiscoveryProcessor, BitbucketDiscoveryProcessor, BitbucketRepositoryParser, BuiltinKindsEntityProcessor, CatalogBuilder, CatalogEntityDocument, CatalogEnvironment, CatalogProcessingEngine, CatalogProcessingOrchestrator, CatalogProcessor, CatalogProcessorCache, CatalogProcessorEmit, CatalogProcessorEntityResult, CatalogProcessorErrorResult, CatalogProcessorLocationResult, CatalogProcessorParser, CatalogProcessorRelationResult, CatalogProcessorResult, CatalogRule, CatalogRulesEnforcer, CodeOwnersProcessor, DefaultCatalogCollator, DefaultCatalogProcessingOrchestrator, DefaultCatalogRulesEnforcer, DeferredEntity, EntitiesCatalog, EntitiesRequest, EntitiesResponse, EntitiesSearchFilter, EntityAncestryResponse, EntityFilter, EntityPagination, EntityProcessingRequest, EntityProcessingResult, EntityProvider, EntityProviderConnection, EntityProviderMutation, FileReaderProcessor, GitHubOrgEntityProvider, GitLabDiscoveryProcessor, GithubDiscoveryProcessor, GithubMultiOrgReaderProcessor, GithubOrgReaderProcessor, LocationAnalyzer, LocationEntityProcessor, LocationEntityProcessorOptions, LocationService, LocationStore, PageInfo, PlaceholderProcessor, PlaceholderProcessorOptions, PlaceholderResolver, PlaceholderResolverParams, PlaceholderResolverRead, PlaceholderResolverResolveUrl, RecursivePartial, RefreshIntervalFunction, RefreshOptions, RefreshService, RouterOptions, StaticLocationProcessor, UrlReaderProcessor, catalogConditions, createCatalogPermissionRule, createCatalogPolicyDecision, createRandomRefreshInterval, createRouter, durationText, parseEntityYaml, permissionRules, results_d as results, runPeriodically };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend",
|
|
3
3
|
"description": "The Backstage backend plugin that provides the Backstage catalog",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.5",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"clean": "backstage-cli package clean"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-common": "^0.10.
|
|
37
|
-
"@backstage/catalog-client": "^0.7.
|
|
38
|
-
"@backstage/catalog-model": "^0.10.
|
|
39
|
-
"@backstage/config": "^0.1.
|
|
40
|
-
"@backstage/errors": "^0.2.
|
|
41
|
-
"@backstage/integration": "^0.7.
|
|
42
|
-
"@backstage/plugin-catalog-common": "^0.1.
|
|
43
|
-
"@backstage/plugin-permission-common": "^0.5.
|
|
44
|
-
"@backstage/plugin-permission-node": "^0.5.
|
|
45
|
-
"@backstage/plugin-scaffolder-common": "^0.2.
|
|
46
|
-
"@backstage/search-common": "^0.2.
|
|
47
|
-
"@backstage/types": "^0.1.
|
|
36
|
+
"@backstage/backend-common": "^0.10.9",
|
|
37
|
+
"@backstage/catalog-client": "^0.7.1",
|
|
38
|
+
"@backstage/catalog-model": "^0.10.1",
|
|
39
|
+
"@backstage/config": "^0.1.15",
|
|
40
|
+
"@backstage/errors": "^0.2.2",
|
|
41
|
+
"@backstage/integration": "^0.7.4",
|
|
42
|
+
"@backstage/plugin-catalog-common": "^0.1.4",
|
|
43
|
+
"@backstage/plugin-permission-common": "^0.5.1",
|
|
44
|
+
"@backstage/plugin-permission-node": "^0.5.1",
|
|
45
|
+
"@backstage/plugin-scaffolder-common": "^0.2.1",
|
|
46
|
+
"@backstage/search-common": "^0.2.4",
|
|
47
|
+
"@backstage/types": "^0.1.3",
|
|
48
48
|
"@octokit/graphql": "^4.5.8",
|
|
49
49
|
"@types/express": "^4.17.6",
|
|
50
50
|
"aws-sdk": "^2.840.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@backstage/backend-test-utils": "^0.1.18",
|
|
73
73
|
"@backstage/cli": "^0.14.0",
|
|
74
|
-
"@backstage/plugin-permission-common": "^0.5.
|
|
74
|
+
"@backstage/plugin-permission-common": "^0.5.1",
|
|
75
75
|
"@backstage/test-utils": "^0.2.5",
|
|
76
76
|
"@types/core-js": "^2.5.4",
|
|
77
77
|
"@types/git-url-parse": "^9.0.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"config.d.ts"
|
|
92
92
|
],
|
|
93
93
|
"configSchema": "config.d.ts",
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "e244b348c473700e7d5e5fbcef38bd9f9fd1d0ba"
|
|
95
95
|
}
|