From 730eb6f83f407682af7e8ca17707246823c0c564 Mon Sep 17 00:00:00 2001 From: Jaeeun Lee Date: Wed, 14 Jun 2023 16:05:24 -0400 Subject: [PATCH 1/4] Update type names for cursor and context in doc Signed-off-by: Jaeeun Lee --- .../README.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/catalog-backend-module-incremental-ingestion/README.md b/plugins/catalog-backend-module-incremental-ingestion/README.md index f85321e613..0612a1a40a 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/README.md +++ b/plugins/catalog-backend-module-incremental-ingestion/README.md @@ -121,7 +121,7 @@ To create an Incremental Entity Provider, you need to know how to retrieve a sin Here is the type definition for an Incremental Entity Provider. ```ts -interface IncrementalEntityProvider { +interface IncrementalEntityProvider { /** * This name must be unique between all of the entity providers * operating in the catalog. @@ -137,9 +137,9 @@ interface IncrementalEntityProvider { * the next page after this one. */ next( - context: TContext, - cursor?: TCursor, - ): Promise>; + context: Context, + cursor?: Cursor, + ): Promise>; /** * Do any setup and teardown necessary in order to provide the * context for fetching pages. This should always invoke `burst` in @@ -147,7 +147,7 @@ interface IncrementalEntityProvider { * * @param burst - a function which performs a series of iterations */ - around(burst: (context: TContext) => Promise): Promise; + around(burst: (context: Context) => Promise): Promise; } ``` @@ -175,17 +175,17 @@ import { IncrementalEntityProvider } from '@backstage/plugin-catalog-backend-mod // This will include your pagination information, let's say our API accepts a `page` parameter. // In this case, the cursor will include `page` -interface MyApiCursor { +interface Cursor { page: number; } // This interface describes the type of data that will be passed to your burst function. -interface MyContext { +interface Context { apiClient: MyApiClient; } export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { getProviderName() { return `MyIncrementalEntityProvider`; @@ -203,7 +203,7 @@ export class MyIncrementalEntityProvider return `MyIncrementalEntityProvider`; } - async around(burst: (context: MyContext) => Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(); await burst({ apiClient }); @@ -229,7 +229,7 @@ export class MyIncrementalEntityProvider return `MyIncrementalEntityProvider`; } - async around(burst: (context: MyContext) => Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(this.token); await burst({ apiClient }); @@ -240,7 +240,7 @@ export class MyIncrementalEntityProvider The last step is to implement the actual `next` method that will accept the cursor, call the API, process the result and return the result. ```ts -export class MyIncrementalEntityProvider implements IncrementalEntityProvider { +export class MyIncrementalEntityProvider implements IncrementalEntityProvider { token: string; @@ -253,14 +253,14 @@ export class MyIncrementalEntityProvider implements IncrementalEntityProvider Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(this.token) await burst({ apiClient }) } - async next(context: MyContext, cursor?: MyApiCursor = { page: 1 }): Promise> { + async next(context: Context, cursor?: Cursor = { page: 1 }): Promise> { const { apiClient } = context; // call your API with the current cursor From f90737fe531633278aaf2773b09fef88a69d41f3 Mon Sep 17 00:00:00 2001 From: Jaeeun Lee Date: Wed, 14 Jun 2023 19:07:20 -0400 Subject: [PATCH 2/4] Change Cursor and Context to TCursor and TContext Signed-off-by: Jaeeun Lee --- .../README.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/catalog-backend-module-incremental-ingestion/README.md b/plugins/catalog-backend-module-incremental-ingestion/README.md index 0612a1a40a..3ba32c454a 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/README.md +++ b/plugins/catalog-backend-module-incremental-ingestion/README.md @@ -121,7 +121,7 @@ To create an Incremental Entity Provider, you need to know how to retrieve a sin Here is the type definition for an Incremental Entity Provider. ```ts -interface IncrementalEntityProvider { +interface IncrementalEntityProvider { /** * This name must be unique between all of the entity providers * operating in the catalog. @@ -137,9 +137,9 @@ interface IncrementalEntityProvider { * the next page after this one. */ next( - context: Context, - cursor?: Cursor, - ): Promise>; + context: TContext, + cursor?: TCursor, + ): Promise>; /** * Do any setup and teardown necessary in order to provide the * context for fetching pages. This should always invoke `burst` in @@ -147,7 +147,7 @@ interface IncrementalEntityProvider { * * @param burst - a function which performs a series of iterations */ - around(burst: (context: Context) => Promise): Promise; + around(burst: (context: TContext) => Promise): Promise; } ``` @@ -175,17 +175,17 @@ import { IncrementalEntityProvider } from '@backstage/plugin-catalog-backend-mod // This will include your pagination information, let's say our API accepts a `page` parameter. // In this case, the cursor will include `page` -interface Cursor { +interface TCursor { page: number; } // This interface describes the type of data that will be passed to your burst function. -interface Context { +interface TContext { apiClient: MyApiClient; } export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { getProviderName() { return `MyIncrementalEntityProvider`; @@ -197,13 +197,13 @@ export class MyIncrementalEntityProvider ```ts export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { getProviderName() { return `MyIncrementalEntityProvider`; } - async around(burst: (context: Context) => Promise): Promise { + async around(burst: (context: TContext) => Promise): Promise { const apiClient = new MyApiClient(); await burst({ apiClient }); @@ -217,7 +217,7 @@ If you need to pass a token to your API, then you can create a constructor that ```ts export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { token: string; @@ -229,7 +229,7 @@ export class MyIncrementalEntityProvider return `MyIncrementalEntityProvider`; } - async around(burst: (context: Context) => Promise): Promise { + async around(burst: (context: TContext) => Promise): Promise { const apiClient = new MyApiClient(this.token); await burst({ apiClient }); @@ -240,7 +240,7 @@ export class MyIncrementalEntityProvider The last step is to implement the actual `next` method that will accept the cursor, call the API, process the result and return the result. ```ts -export class MyIncrementalEntityProvider implements IncrementalEntityProvider { +export class MyIncrementalEntityProvider implements IncrementalEntityProvider { token: string; @@ -253,14 +253,14 @@ export class MyIncrementalEntityProvider implements IncrementalEntityProvider Promise): Promise { + async around(burst: (context: TContext) => Promise): Promise { const apiClient = new MyApiClient(this.token) await burst({ apiClient }) } - async next(context: Context, cursor?: Cursor = { page: 1 }): Promise> { + async next(context: TContext, cursor?: TCursor = { page: 1 }): Promise> { const { apiClient } = context; // call your API with the current cursor From 53309661cb5cb450c5b4813abf4963b3cb7e9164 Mon Sep 17 00:00:00 2001 From: Jaeeun Lee Date: Wed, 14 Jun 2023 19:14:56 -0400 Subject: [PATCH 3/4] Create changesheet Signed-off-by: Jaeeun Lee --- .changeset/curvy-trainers-hide.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curvy-trainers-hide.md diff --git a/.changeset/curvy-trainers-hide.md b/.changeset/curvy-trainers-hide.md new file mode 100644 index 0000000000..32403a0f18 --- /dev/null +++ b/.changeset/curvy-trainers-hide.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch +--- + +Update installation guide to fix inconsistency in type names From 6d933bff036e1d4a71aeb3f82d62c881e3251dae Mon Sep 17 00:00:00 2001 From: Jaeeun Lee Date: Sun, 18 Jun 2023 15:23:15 -0400 Subject: [PATCH 4/4] Remove T prefix from type names after declaring interface Signed-off-by: Jaeeun Lee --- .../README.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/catalog-backend-module-incremental-ingestion/README.md b/plugins/catalog-backend-module-incremental-ingestion/README.md index 3ba32c454a..6ba3e7c3ca 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/README.md +++ b/plugins/catalog-backend-module-incremental-ingestion/README.md @@ -175,17 +175,17 @@ import { IncrementalEntityProvider } from '@backstage/plugin-catalog-backend-mod // This will include your pagination information, let's say our API accepts a `page` parameter. // In this case, the cursor will include `page` -interface TCursor { +interface Cursor { page: number; } // This interface describes the type of data that will be passed to your burst function. -interface TContext { +interface Context { apiClient: MyApiClient; } export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { getProviderName() { return `MyIncrementalEntityProvider`; @@ -197,13 +197,13 @@ export class MyIncrementalEntityProvider ```ts export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { getProviderName() { return `MyIncrementalEntityProvider`; } - async around(burst: (context: TContext) => Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(); await burst({ apiClient }); @@ -217,7 +217,7 @@ If you need to pass a token to your API, then you can create a constructor that ```ts export class MyIncrementalEntityProvider - implements IncrementalEntityProvider + implements IncrementalEntityProvider { token: string; @@ -229,7 +229,7 @@ export class MyIncrementalEntityProvider return `MyIncrementalEntityProvider`; } - async around(burst: (context: TContext) => Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(this.token); await burst({ apiClient }); @@ -240,7 +240,7 @@ export class MyIncrementalEntityProvider The last step is to implement the actual `next` method that will accept the cursor, call the API, process the result and return the result. ```ts -export class MyIncrementalEntityProvider implements IncrementalEntityProvider { +export class MyIncrementalEntityProvider implements IncrementalEntityProvider { token: string; @@ -253,14 +253,14 @@ export class MyIncrementalEntityProvider implements IncrementalEntityProvider Promise): Promise { + async around(burst: (context: Context) => Promise): Promise { const apiClient = new MyApiClient(this.token) await burst({ apiClient }) } - async next(context: TContext, cursor?: TCursor = { page: 1 }): Promise> { + async next(context: Context, cursor?: Cursor = { page: 1 }): Promise> { const { apiClient } = context; // call your API with the current cursor