@backstage/plugin-catalog-react 1.20.2-next.1 → 1.21.0-next.2

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,5 +1,35 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.21.0-next.2
4
+
5
+ ### Minor Changes
6
+
7
+ - 0e9ec44: Introduced new `streamEntities` async generator method for the catalog.
8
+
9
+ Catalog API and Catalog Service now includes a `streamEntities` method that allows for streaming entities from the catalog.
10
+ This method is designed to handle large datasets efficiently by processing entities in a stream rather than loading them
11
+ all into memory at once. This is useful when you need to fetch a large number of entities but do not want to use pagination
12
+ or fetch all entities at once.
13
+
14
+ Example usage:
15
+
16
+ ```ts
17
+ const pageStream = catalogClient.streamEntities({ pageSize: 100 }, { token });
18
+ for await (const page of pageStream) {
19
+ // Handle page of entities
20
+ for (const entity of page) {
21
+ console.log(entity);
22
+ }
23
+ }
24
+ ```
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies
29
+ - @backstage/catalog-client@1.12.0-next.0
30
+ - @backstage/core-components@0.17.6-next.1
31
+ - @backstage/core-compat-api@0.5.2-next.2
32
+
3
33
  ## 1.20.2-next.1
4
34
 
5
35
  ### Patch Changes
@@ -48,7 +48,9 @@ function catalogApiMock(options) {
48
48
  removeLocationById: jest.fn(),
49
49
  getLocationByEntity: jest.fn(),
50
50
  validateEntity: jest.fn(),
51
- analyzeLocation: jest.fn()
51
+ analyzeLocation: jest.fn(),
52
+ streamEntities: jest.fn(),
53
+ streamEntityPages: jest.fn()
52
54
  }));
53
55
  })(catalogApiMock || (catalogApiMock = {}));
54
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"catalogApiMock.esm.js","sources":["../../src/testUtils/catalogApiMock.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiFactory,\n ApiRef,\n createApiFactory,\n} from '@backstage/frontend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { ApiMock } from '@backstage/frontend-test-utils';\n\n/** @internal */\nfunction simpleMock<TApi>(\n ref: ApiRef<TApi>,\n mockFactory: () => jest.Mocked<TApi>,\n): (partialImpl?: Partial<TApi>) => ApiMock<TApi> {\n return partialImpl => {\n const mock = mockFactory();\n if (partialImpl) {\n for (const [key, impl] of Object.entries(partialImpl)) {\n if (typeof impl === 'function') {\n (mock as any)[key].mockImplementation(impl);\n } else {\n (mock as any)[key] = impl;\n }\n }\n }\n return Object.assign(mock, {\n factory: createApiFactory({\n api: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ApiMock<TApi>;\n };\n}\n\n/**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n *\n * @public\n */\nexport function catalogApiMock(options?: { entities?: Entity[] }): CatalogApi {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogApiMock {\n /**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n */\n export const factory = (options?: {\n entities?: Entity[];\n }): ApiFactory<CatalogApi, CatalogApi, {}> =>\n createApiFactory({\n api: catalogApiRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n });\n /**\n * Creates a catalog client whose methods are mock functions, possibly with\n * some of them overloaded by the caller.\n */\n export const mock = simpleMock(catalogApiRef, () => ({\n getEntities: jest.fn(),\n getEntitiesByRefs: jest.fn(),\n queryEntities: jest.fn(),\n getEntityAncestors: jest.fn(),\n getEntityByRef: jest.fn(),\n removeEntityByUid: jest.fn(),\n refreshEntity: jest.fn(),\n getEntityFacets: jest.fn(),\n getLocations: jest.fn(),\n getLocationById: jest.fn(),\n getLocationByRef: jest.fn(),\n addLocation: jest.fn(),\n removeLocationById: jest.fn(),\n getLocationByEntity: jest.fn(),\n validateEntity: jest.fn(),\n analyzeLocation: jest.fn(),\n }));\n}\n"],"names":["catalogApiMock"],"mappings":";;;;AA4BA,SAAS,UAAA,CACP,KACA,WAAA,EACgD;AAChD,EAAA,OAAO,CAAA,WAAA,KAAe;AACpB,IAAA,MAAM,OAAO,WAAA,EAAY;AACzB,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACrD,QAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,UAAC,IAAA,CAAa,GAAG,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA;AAAA,QAC5C,CAAA,MAAO;AACL,UAAC,IAAA,CAAa,GAAG,CAAA,GAAI,IAAA;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AACA,IAAA,OAAO,MAAA,CAAO,OAAO,IAAA,EAAM;AAAA,MACzB,SAAS,gBAAA,CAAiB;AAAA,QACxB,GAAA,EAAK,GAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,SAAS,MAAM;AAAA,OAChB;AAAA,KACF,CAAA;AAAA,EACH,CAAA;AACF;AASO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,IAAI,sBAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUA,eAAAA,KAAV;AAME,EAAMA,eAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KAGtB,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,aAAA;AAAA,IACL,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,qBAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMA,eAAAA,CAAA,IAAA,GAAO,UAAA,CAAW,aAAA,EAAe,OAAO;AAAA,IACnD,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,YAAA,EAAc,KAAK,EAAA,EAAG;AAAA,IACtB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,gBAAA,EAAkB,KAAK,EAAA,EAAG;AAAA,IAC1B,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,mBAAA,EAAqB,KAAK,EAAA,EAAG;AAAA,IAC7B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,eAAA,EAAiB,KAAK,EAAA;AAAG,GAC3B,CAAE,CAAA;AAAA,CAAA,EAnCa,cAAA,KAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"catalogApiMock.esm.js","sources":["../../src/testUtils/catalogApiMock.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiFactory,\n ApiRef,\n createApiFactory,\n} from '@backstage/frontend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { ApiMock } from '@backstage/frontend-test-utils';\n\n/** @internal */\nfunction simpleMock<TApi>(\n ref: ApiRef<TApi>,\n mockFactory: () => jest.Mocked<TApi>,\n): (partialImpl?: Partial<TApi>) => ApiMock<TApi> {\n return partialImpl => {\n const mock = mockFactory();\n if (partialImpl) {\n for (const [key, impl] of Object.entries(partialImpl)) {\n if (typeof impl === 'function') {\n (mock as any)[key].mockImplementation(impl);\n } else {\n (mock as any)[key] = impl;\n }\n }\n }\n return Object.assign(mock, {\n factory: createApiFactory({\n api: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ApiMock<TApi>;\n };\n}\n\n/**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n *\n * @public\n */\nexport function catalogApiMock(options?: { entities?: Entity[] }): CatalogApi {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogApiMock {\n /**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n */\n export const factory = (options?: {\n entities?: Entity[];\n }): ApiFactory<CatalogApi, CatalogApi, {}> =>\n createApiFactory({\n api: catalogApiRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n });\n /**\n * Creates a catalog client whose methods are mock functions, possibly with\n * some of them overloaded by the caller.\n */\n export const mock = simpleMock(catalogApiRef, () => ({\n getEntities: jest.fn(),\n getEntitiesByRefs: jest.fn(),\n queryEntities: jest.fn(),\n getEntityAncestors: jest.fn(),\n getEntityByRef: jest.fn(),\n removeEntityByUid: jest.fn(),\n refreshEntity: jest.fn(),\n getEntityFacets: jest.fn(),\n getLocations: jest.fn(),\n getLocationById: jest.fn(),\n getLocationByRef: jest.fn(),\n addLocation: jest.fn(),\n removeLocationById: jest.fn(),\n getLocationByEntity: jest.fn(),\n validateEntity: jest.fn(),\n analyzeLocation: jest.fn(),\n streamEntities: jest.fn(),\n streamEntityPages: jest.fn(),\n }));\n}\n"],"names":["catalogApiMock"],"mappings":";;;;AA4BA,SAAS,UAAA,CACP,KACA,WAAA,EACgD;AAChD,EAAA,OAAO,CAAA,WAAA,KAAe;AACpB,IAAA,MAAM,OAAO,WAAA,EAAY;AACzB,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,KAAA,MAAW,CAAC,GAAA,EAAK,IAAI,KAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACrD,QAAA,IAAI,OAAO,SAAS,UAAA,EAAY;AAC9B,UAAC,IAAA,CAAa,GAAG,CAAA,CAAE,kBAAA,CAAmB,IAAI,CAAA;AAAA,QAC5C,CAAA,MAAO;AACL,UAAC,IAAA,CAAa,GAAG,CAAA,GAAI,IAAA;AAAA,QACvB;AAAA,MACF;AAAA,IACF;AACA,IAAA,OAAO,MAAA,CAAO,OAAO,IAAA,EAAM;AAAA,MACzB,SAAS,gBAAA,CAAiB;AAAA,QACxB,GAAA,EAAK,GAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,SAAS,MAAM;AAAA,OAChB;AAAA,KACF,CAAA;AAAA,EACH,CAAA;AACF;AASO,SAAS,eAAe,OAAA,EAA+C;AAC5E,EAAA,OAAO,IAAI,sBAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUA,eAAAA,KAAV;AAME,EAAMA,eAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KAGtB,gBAAA,CAAiB;AAAA,IACf,GAAA,EAAK,aAAA;AAAA,IACL,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAI,qBAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMA,eAAAA,CAAA,IAAA,GAAO,UAAA,CAAW,aAAA,EAAe,OAAO;AAAA,IACnD,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,IACvB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,YAAA,EAAc,KAAK,EAAA,EAAG;AAAA,IACtB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,gBAAA,EAAkB,KAAK,EAAA,EAAG;AAAA,IAC1B,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,IACrB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,IAC5B,mBAAA,EAAqB,KAAK,EAAA,EAAG;AAAA,IAC7B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,IACzB,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAA;AAAG,GAC7B,CAAE,CAAA;AAAA,CAAA,EArCa,cAAA,KAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "1.20.2-next.1",
3
+ "version": "1.21.0-next.2",
4
4
  "description": "A frontend library that helps other Backstage plugins interact with the catalog",
5
5
  "backstage": {
6
6
  "role": "web-library",
@@ -73,10 +73,10 @@
73
73
  "test": "backstage-cli package test"
74
74
  },
75
75
  "dependencies": {
76
- "@backstage/catalog-client": "1.11.0",
76
+ "@backstage/catalog-client": "1.12.0-next.0",
77
77
  "@backstage/catalog-model": "1.7.5",
78
- "@backstage/core-compat-api": "0.5.2-next.1",
79
- "@backstage/core-components": "0.17.6-next.0",
78
+ "@backstage/core-compat-api": "0.5.2-next.2",
79
+ "@backstage/core-components": "0.17.6-next.1",
80
80
  "@backstage/core-plugin-api": "1.10.9",
81
81
  "@backstage/errors": "1.2.7",
82
82
  "@backstage/frontend-plugin-api": "0.11.1-next.0",
@@ -100,7 +100,7 @@
100
100
  "zen-observable": "^0.10.0"
101
101
  },
102
102
  "devDependencies": {
103
- "@backstage/cli": "0.34.2-next.1",
103
+ "@backstage/cli": "0.34.2-next.2",
104
104
  "@backstage/core-app-api": "1.18.0",
105
105
  "@backstage/plugin-catalog-common": "1.1.5",
106
106
  "@backstage/plugin-scaffolder-common": "1.7.1-next.0",