@backstage/plugin-catalog-backend-module-incremental-ingestion 0.5.2 → 0.5.3-next.1

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,22 +1,36 @@
1
1
  # @backstage/plugin-catalog-backend-module-incremental-ingestion
2
2
 
3
- ## 0.5.2
3
+ ## 0.5.3-next.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - Updated dependencies
8
- - @backstage/backend-common@0.24.1
9
- - @backstage/plugin-catalog-backend@1.25.2
10
- - @backstage/plugin-events-node@0.3.10
11
- - @backstage/backend-plugin-api@0.8.1
12
- - @backstage/plugin-catalog-node@1.12.6
8
+ - @backstage/backend-common@0.25.0-next.1
9
+ - @backstage/plugin-catalog-backend@1.25.3-next.1
10
+ - @backstage/backend-plugin-api@0.9.0-next.1
11
+ - @backstage/catalog-model@1.6.0
12
+ - @backstage/config@1.2.0
13
+ - @backstage/errors@1.2.4
14
+ - @backstage/plugin-catalog-node@1.12.7-next.1
15
+ - @backstage/plugin-events-node@0.4.0-next.1
16
+ - @backstage/plugin-permission-common@0.8.1
13
17
 
14
- ## 0.5.1
18
+ ## 0.5.3-next.0
15
19
 
16
20
  ### Patch Changes
17
21
 
22
+ - d425fc4: Modules, plugins, and services are now `BackendFeature`, not a function that returns a feature.
23
+ - 4b28e39: Updated the README to include documentation for the new backend support
18
24
  - Updated dependencies
19
- - @backstage/plugin-catalog-backend@1.25.1
25
+ - @backstage/backend-plugin-api@0.9.0-next.0
26
+ - @backstage/backend-common@0.25.0-next.0
27
+ - @backstage/plugin-catalog-backend@1.25.3-next.0
28
+ - @backstage/plugin-events-node@0.4.0-next.0
29
+ - @backstage/plugin-catalog-node@1.12.7-next.0
30
+ - @backstage/catalog-model@1.6.0
31
+ - @backstage/config@1.2.0
32
+ - @backstage/errors@1.2.4
33
+ - @backstage/plugin-permission-common@0.8.1
20
34
 
21
35
  ## 0.5.0
22
36
 
package/README.md CHANGED
@@ -42,57 +42,25 @@ The Incremental Entity Provider backend is designed for data sources that provid
42
42
  ## Installation
43
43
 
44
44
  1. Install `@backstage/plugin-catalog-backend-module-incremental-ingestion` with `yarn --cwd packages/backend add @backstage/plugin-catalog-backend-module-incremental-ingestion` from the Backstage root directory.
45
- 2. In your catalog.ts, import `IncrementalCatalogBuilder` from `@backstage/plugin-catalog-backend-module-incremental-ingestion` and instantiate it with `await IncrementalCatalogBuilder.create(env, builder)`. You have to pass `builder` into `IncrementalCatalogBuilder.create` function because `IncrementalCatalogBuilder` will convert an `IncrementalEntityProvider` into an `EntityProvider` and call `builder.addEntityProvider`.
46
45
 
47
- ```ts
48
- const builder = CatalogBuilder.create(env);
49
- // incremental builder receives builder because it'll register
50
- // incremental entity providers with the builder
51
- const incrementalBuilder = await IncrementalCatalogBuilder.create(env, builder);
52
- ```
46
+ 2. Add the following code to the `packages/backend/src/index.ts` file:
53
47
 
54
- 3. After building the regular `CatalogBuilder`, build the incremental builder:
48
+ ```diff
49
+ + import { catalogModuleCustomIncrementalIngestionProvider } from './extensions/catalogCustomIncrementalIngestion';
55
50
 
56
- ```ts
57
- // Must be run first to ensure CatalogBuilder database migrations run before Incremental Entity Provider database migrations
58
- const { processingEngine, router } = await builder.build();
59
51
 
60
- // Returns an optional - but highly recommended - set of administrative routes
61
- const { incrementalAdminRouter } = await incrementBuilder.build();
62
- ```
52
+ const backend = createBackend();
63
53
 
64
- The final result should look something like this,
54
+ + backend.add(
55
+ + import(
56
+ + '@backstage/plugin-catalog-backend-module-incremental-ingestion/alpha'
57
+ + ),
58
+ + );
65
59
 
66
- ```ts
67
- import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
68
- import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
69
- import { IncrementalCatalogBuilder } from '@backstage/plugin-catalog-backend-module-incremental-ingestion';
70
- import { Router } from 'express';
71
- import { Duration } from 'luxon';
72
- import { PluginEnvironment } from '../types';
73
-
74
- export default async function createPlugin(
75
- env: PluginEnvironment,
76
- ): Promise<Router> {
77
- const builder = CatalogBuilder.create(env);
78
- // incremental builder receives builder because it'll register
79
- // incremental entity providers with the builder
80
- const incrementalBuilder = await IncrementalCatalogBuilder.create(
81
- env,
82
- builder,
83
- );
84
-
85
- builder.addProcessor(new ScaffolderEntitiesProcessor());
86
-
87
- const { processingEngine, router } = await builder.build();
88
- const { incrementalAdminRouter } = await incrementalBuilder.build();
89
-
90
- router.use(incrementalAdminRouter);
91
-
92
- await processingEngine.start();
93
-
94
- return router;
95
- }
60
+ // We have created this in section **Adding an Incremental Entity Provider to the catalog**
61
+ + backend.add(catalogModuleCustomIncrementalIngestionProvider);
62
+
63
+ backend.start();
96
64
  ```
97
65
 
98
66
  ## Administrative Routes
@@ -116,7 +84,7 @@ In all cases, `:provider` is the name of the incremental entity provider.
116
84
 
117
85
  ## Writing an Incremental Entity Provider
118
86
 
119
- To create an Incremental Entity Provider, you need to know how to retrieve a single page of the data that you wish to ingest into the Backstage catalog. If the API has pagination and you know how to make a paginated request to that API, you'll be able to implement an Incremental Entity Provider for this API. For more information about compatibility, check out the <a href="#requirements">requirements</a> section of this page.
87
+ To create an Incremental Entity Provider, you need to know how to retrieve a single page of the data that you wish to ingest into the Backstage catalog. If the API has pagination and you know how to make a paginated request to that API, you'll be able to implement an Incremental Entity Provider for this API. For more information about compatibility, check out the [requirements](#requirements) section of this page.
120
88
 
121
89
  Here is the type definition for an Incremental Entity Provider.
122
90
 
@@ -309,45 +277,73 @@ Now that you have your new Incremental Entity Provider, we can connect it to the
309
277
 
310
278
  ## Adding an Incremental Entity Provider to the catalog
311
279
 
312
- We'll assume you followed the <a href="#installation">Installation</a> instructions. After you create your `incrementalBuilder`, you can instantiate your Entity Provider and pass it to the `addIncrementalEntityProvider` method.
280
+ We'll assume you followed the [Installation](#installation) instructions. Now create a module inside `packages/backend/src/extensions/catalogCustomIncrementalIngestion.ts`.
313
281
 
314
282
  ```ts
315
- const incrementalBuilder = await IncrementalCatalogBuilder.create(env, builder);
316
-
317
- // Assuming the token for the API comes from config
318
- const token = config.getString('myApiClient.token');
319
-
320
- const myEntityProvider = new MyIncrementalEntityProvider(token);
321
-
322
- incrementalBuilder.addIncrementalEntityProvider(myEntityProvider, {
323
- // How long should it attempt to read pages from the API in a
324
- // single burst? Keep this short. The Incremental Entity Provider
325
- // will attempt to read as many pages as it can in this time
326
- burstLength: { seconds: 3 },
327
-
328
- // How long should it wait between bursts?
329
- burstInterval: { seconds: 3 },
330
-
331
- // How long should it rest before re-ingesting again?
332
- restLength: { day: 1 },
333
-
334
- // Optional back-off configuration - how long should it wait to retry
335
- // in the event of an error?
336
- backoff: [{ seconds: 5 }, { seconds: 30 }, { minutes: 10 }, { hours: 3 }],
337
-
338
- // Optional. Use this to prevent removal of entities above a given
339
- // percentage. This can be helpful if a data source is flaky and
340
- // sometimes returns a successful status, but fewer than expected
341
- // assets to add or maintain in the catalog.
342
- rejectRemovalsAbovePercentage: 5,
343
-
344
- // Optional. Similar to rejectRemovalsAbovePercentage, except it
345
- // applies to complete, 100% failure of a data source. If true,
346
- // a data source that returns a successful status but does not
347
- // provide any assets to turn into entities will have its empty
348
- // data set rejected.
349
- rejectEmptySourceCollections: true,
350
- });
283
+ import {
284
+ coreServices,
285
+ createBackendModule,
286
+ } from '@backstage/backend-plugin-api';
287
+ import { incrementalIngestionProvidersExtensionPoint } from '@backstage/plugin-catalog-backend-module-incremental-ingestion/alpha';
288
+
289
+ export const catalogModuleCustomIncrementalIngestionProvider =
290
+ createBackendModule({
291
+ pluginId: 'catalog',
292
+ moduleId: 'custom-incremental-ingestion-provider',
293
+ register(env) {
294
+ env.registerInit({
295
+ deps: {
296
+ incrementalBuilder: incrementalIngestionProvidersExtensionPoint,
297
+ config: coreServices.rootConfig,
298
+ },
299
+ async init({ incrementalBuilder, config }) {
300
+ // Assuming the token for the API comes from config
301
+ const token = config.getString('myApiClient.token');
302
+ const myEntityProvider = new MyIncrementalEntityProvider(token);
303
+
304
+ const options = {
305
+ // How long should it attempt to read pages from the API in a
306
+ // single burst? Keep this short. The Incremental Entity Provider
307
+ // will attempt to read as many pages as it can in this time
308
+ burstLength: { seconds: 3 },
309
+
310
+ // How long should it wait between bursts?
311
+ burstInterval: { seconds: 3 },
312
+
313
+ // How long should it rest before re-ingesting again?
314
+ restLength: { day: 1 },
315
+
316
+ // Optional back-off configuration - how long should it wait to retry
317
+ // in the event of an error?
318
+ backoff: [
319
+ { seconds: 5 },
320
+ { seconds: 30 },
321
+ { minutes: 10 },
322
+ { hours: 3 },
323
+ ],
324
+
325
+ // Optional. Use this to prevent removal of entities above a given
326
+ // percentage. This can be helpful if a data source is flaky and
327
+ // sometimes returns a successful status, but fewer than expected
328
+ // assets to add or maintain in the catalog.
329
+ rejectRemovalsAbovePercentage: 5,
330
+
331
+ // Optional. Similar to rejectRemovalsAbovePercentage, except it
332
+ // applies to complete, 100% failure of a data source. If true,
333
+ // a data source that returns a successful status but does not
334
+ // provide any assets to turn into entities will have its empty
335
+ // data set rejected.
336
+ rejectEmptySourceCollections: true,
337
+ };
338
+
339
+ incrementalBuilder.addProvider({
340
+ provider: myEntityProvider,
341
+ options,
342
+ });
343
+ },
344
+ });
345
+ },
346
+ });
351
347
  ```
352
348
 
353
349
  That's it!!!
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-incremental-ingestion__alpha",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-next.1",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/dist/alpha.d.ts CHANGED
@@ -52,6 +52,6 @@ declare const incrementalIngestionProvidersExtensionPoint: _backstage_backend_pl
52
52
  *
53
53
  * @alpha
54
54
  */
55
- declare const catalogModuleIncrementalIngestionEntityProvider: _backstage_backend_plugin_api.BackendFeatureCompat;
55
+ declare const catalogModuleIncrementalIngestionEntityProvider: _backstage_backend_plugin_api.BackendFeature;
56
56
 
57
57
  export { type IncrementalIngestionProviderExtensionPoint, catalogModuleIncrementalIngestionEntityProvider as default, incrementalIngestionProvidersExtensionPoint };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-incremental-ingestion",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-next.1",
4
4
  "description": "An entity provider for streaming large asset sources into the catalog",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -50,14 +50,14 @@
50
50
  "test": "backstage-cli package test"
51
51
  },
52
52
  "dependencies": {
53
- "@backstage/backend-common": "^0.24.1",
54
- "@backstage/backend-plugin-api": "^0.8.1",
53
+ "@backstage/backend-common": "^0.25.0-next.1",
54
+ "@backstage/backend-plugin-api": "^0.9.0-next.1",
55
55
  "@backstage/catalog-model": "^1.6.0",
56
56
  "@backstage/config": "^1.2.0",
57
57
  "@backstage/errors": "^1.2.4",
58
- "@backstage/plugin-catalog-backend": "^1.25.2",
59
- "@backstage/plugin-catalog-node": "^1.12.6",
60
- "@backstage/plugin-events-node": "^0.3.10",
58
+ "@backstage/plugin-catalog-backend": "^1.25.3-next.1",
59
+ "@backstage/plugin-catalog-node": "^1.12.7-next.1",
60
+ "@backstage/plugin-events-node": "^0.4.0-next.1",
61
61
  "@backstage/plugin-permission-common": "^0.8.1",
62
62
  "@types/express": "^4.17.6",
63
63
  "@types/luxon": "^3.0.0",
@@ -68,8 +68,8 @@
68
68
  "uuid": "^9.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@backstage/backend-defaults": "^0.4.4",
72
- "@backstage/backend-test-utils": "^0.5.1",
73
- "@backstage/cli": "^0.27.0"
71
+ "@backstage/backend-defaults": "^0.5.0-next.1",
72
+ "@backstage/backend-test-utils": "^0.6.0-next.1",
73
+ "@backstage/cli": "^0.27.1-next.1"
74
74
  }
75
75
  }