fix: review comments of naming

Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
Hellgren Heikki
2025-09-01 15:02:55 +03:00
parent acb2fdb38f
commit 713a875c5b
5 changed files with 27 additions and 10 deletions
+2 -2
View File
@@ -335,10 +335,10 @@ export type QueryEntitiesResponse = {
// @public
export type StreamEntitiesRequest = Omit<
QueryEntitiesRequest,
QueryEntitiesInitialRequest,
'limit' | 'offset'
> & {
batchSize?: number;
pageSize?: number;
};
// @public
+2 -4
View File
@@ -49,9 +49,7 @@ import type {
AnalyzeLocationRequest,
AnalyzeLocationResponse,
} from '@backstage/plugin-catalog-common';
// Number of entities to return in a single streamEntities request
const DEFAULT_STREAM_ENTITIES_LIMIT = 500;
import { DEFAULT_STREAM_ENTITIES_LIMIT } from './constants.ts';
/**
* A frontend and backend compatible client for communicating with the Backstage
@@ -483,7 +481,7 @@ export class CatalogClient implements CatalogApi {
options?: CatalogRequestOptions,
): AsyncIterable<Entity[]> {
let cursor: string | undefined = undefined;
const limit = request?.batchSize ?? DEFAULT_STREAM_ENTITIES_LIMIT;
const limit = request?.pageSize ?? DEFAULT_STREAM_ENTITIES_LIMIT;
do {
const res = await this.queryEntities(
cursor ? { ...request, cursor, limit } : { ...request, limit },
+17
View File
@@ -0,0 +1,17 @@
/*
* Copyright 2025 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const DEFAULT_STREAM_ENTITIES_LIMIT = 500;
@@ -49,6 +49,7 @@ import type {
AnalyzeLocationRequest,
AnalyzeLocationResponse,
} from '@backstage/plugin-catalog-common';
import { DEFAULT_STREAM_ENTITIES_LIMIT } from '../constants.ts';
function buildEntitySearch(entity: Entity) {
const rows = traverse(entity);
@@ -295,9 +296,10 @@ export class InMemoryCatalogClient implements CatalogApi {
request?: StreamEntitiesRequest,
): AsyncIterable<Entity[]> {
let cursor: string | undefined = undefined;
const limit = request?.pageSize ?? DEFAULT_STREAM_ENTITIES_LIMIT;
do {
const res = await this.queryEntities(
cursor ? { ...request, cursor } : request,
cursor ? { ...request, limit, cursor } : { ...request, limit },
);
yield res.items;
+3 -3
View File
@@ -471,13 +471,13 @@ export type QueryEntitiesResponse = {
* @public
*/
export type StreamEntitiesRequest = Omit<
QueryEntitiesRequest,
QueryEntitiesInitialRequest,
'limit' | 'offset'
> & {
/**
* The number of entities to fetch in each batch. Defaults to 500.
* The number of entities to fetch in each page. Defaults to 500.
*/
batchSize?: number;
pageSize?: number;
};
/**