@backstage/plugin-catalog-node 1.21.0-next.0 → 2.0.0-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,5 +1,16 @@
1
1
  # @backstage/plugin-catalog-node
2
2
 
3
+ ## 2.0.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 42abfb1: Updated `catalogServiceMock.mock` to use `createServiceMock` from `@backstage/backend-test-utils`, replacing the internal copy of `simpleMock`. Added `@backstage/backend-test-utils` as an optional peer dependency.
8
+ - Updated dependencies
9
+ - @backstage/backend-test-utils@1.11.0-next.1
10
+ - @backstage/catalog-client@1.12.2-next.0
11
+ - @backstage/backend-plugin-api@1.7.0-next.1
12
+ - @backstage/plugin-permission-node@0.10.10-next.0
13
+
3
14
  ## 1.21.0-next.0
4
15
 
5
16
  ### Minor Changes
@@ -3,28 +3,8 @@
3
3
  var backendPluginApi = require('@backstage/backend-plugin-api');
4
4
  var testUtils = require('@backstage/catalog-client/testUtils');
5
5
  var pluginCatalogNode = require('@backstage/plugin-catalog-node');
6
+ var backendTestUtils = require('@backstage/backend-test-utils');
6
7
 
7
- function simpleMock(ref, mockFactory) {
8
- return (partialImpl) => {
9
- const mock = mockFactory();
10
- if (partialImpl) {
11
- for (const [key, impl] of Object.entries(partialImpl)) {
12
- if (typeof impl === "function") {
13
- mock[key].mockImplementation(impl);
14
- } else {
15
- mock[key] = impl;
16
- }
17
- }
18
- }
19
- return Object.assign(mock, {
20
- factory: backendPluginApi.createServiceFactory({
21
- service: ref,
22
- deps: {},
23
- factory: () => mock
24
- })
25
- });
26
- };
27
- }
28
8
  function catalogServiceMock(options) {
29
9
  return new testUtils.InMemoryCatalogClient(options);
30
10
  }
@@ -34,25 +14,28 @@ function catalogServiceMock(options) {
34
14
  deps: {},
35
15
  factory: () => new testUtils.InMemoryCatalogClient(options)
36
16
  });
37
- catalogServiceMock2.mock = simpleMock(pluginCatalogNode.catalogServiceRef, () => ({
38
- getEntities: jest.fn(),
39
- getEntitiesByRefs: jest.fn(),
40
- queryEntities: jest.fn(),
41
- getEntityAncestors: jest.fn(),
42
- getEntityByRef: jest.fn(),
43
- removeEntityByUid: jest.fn(),
44
- refreshEntity: jest.fn(),
45
- getEntityFacets: jest.fn(),
46
- getLocations: jest.fn(),
47
- getLocationById: jest.fn(),
48
- getLocationByRef: jest.fn(),
49
- addLocation: jest.fn(),
50
- removeLocationById: jest.fn(),
51
- getLocationByEntity: jest.fn(),
52
- validateEntity: jest.fn(),
53
- analyzeLocation: jest.fn(),
54
- streamEntities: jest.fn()
55
- }));
17
+ catalogServiceMock2.mock = backendTestUtils.createServiceMock(
18
+ pluginCatalogNode.catalogServiceRef,
19
+ () => ({
20
+ getEntities: jest.fn(),
21
+ getEntitiesByRefs: jest.fn(),
22
+ queryEntities: jest.fn(),
23
+ getEntityAncestors: jest.fn(),
24
+ getEntityByRef: jest.fn(),
25
+ removeEntityByUid: jest.fn(),
26
+ refreshEntity: jest.fn(),
27
+ getEntityFacets: jest.fn(),
28
+ getLocations: jest.fn(),
29
+ getLocationById: jest.fn(),
30
+ getLocationByRef: jest.fn(),
31
+ addLocation: jest.fn(),
32
+ removeLocationById: jest.fn(),
33
+ getLocationByEntity: jest.fn(),
34
+ validateEntity: jest.fn(),
35
+ analyzeLocation: jest.fn(),
36
+ streamEntities: jest.fn()
37
+ })
38
+ );
56
39
  })(catalogServiceMock || (catalogServiceMock = {}));
57
40
 
58
41
  exports.catalogServiceMock = catalogServiceMock;
@@ -1 +1 @@
1
- {"version":3,"file":"catalogServiceMock.cjs.js","sources":["../../src/testUtils/catalogServiceMock.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 createServiceFactory,\n ServiceFactory,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\n// eslint-disable-next-line @backstage/no-undeclared-imports\nimport { ServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogServiceMock } from './types';\n\n/** @internal */\nfunction simpleMock<TService>(\n ref: ServiceRef<TService, any>,\n mockFactory: () => jest.Mocked<TService>,\n): (partialImpl?: Partial<TService>) => ServiceMock<TService> {\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: createServiceFactory({\n service: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ServiceMock<TService>;\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 catalogServiceMock(options?: {\n entities?: Entity[];\n}): CatalogServiceMock {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogServiceMock {\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?: { entities?: Entity[] }) =>\n createServiceFactory({\n service: catalogServiceRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n }) as ServiceFactory<CatalogServiceMock, 'plugin', 'singleton'>;\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<CatalogServiceMock>(catalogServiceRef, () => ({\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 }));\n}\n"],"names":["createServiceFactory","InMemoryCatalogClient","catalogServiceMock","catalogServiceRef"],"mappings":";;;;;;AA6BA,SAAS,UAAA,CACP,KACA,WAAA,EAC4D;AAC5D,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,SAASA,qCAAA,CAAqB;AAAA,QAC5B,OAAA,EAAS,GAAA;AAAA,QACT,MAAM,EAAC;AAAA,QACP,SAAS,MAAM;AAAA,OAChB;AAAA,KACF,CAAA;AAAA,EACH,CAAA;AACF;AASO,SAAS,mBAAmB,OAAA,EAEZ;AACrB,EAAA,OAAO,IAAIC,gCAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUC,mBAAAA,KAAV;AAME,EAAMA,mBAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KACtBF,qCAAA,CAAqB;AAAA,IACnB,OAAA,EAASG,mCAAA;AAAA,IACT,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAIF,+BAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMC,mBAAAA,CAAA,IAAA,GAAO,UAAA,CAA+BC,mCAAA,EAAmB,OAAO;AAAA,IAC3E,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;AAAG,GAC1B,CAAE,CAAA;AAAA,CAAA,EAlCa,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"catalogServiceMock.cjs.js","sources":["../../src/testUtils/catalogServiceMock.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 createServiceFactory,\n ServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { createServiceMock } from '@backstage/backend-test-utils';\nimport { CatalogServiceMock } from './types';\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 catalogServiceMock(options?: {\n entities?: Entity[];\n}): CatalogServiceMock {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogServiceMock {\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?: { entities?: Entity[] }) =>\n createServiceFactory({\n service: catalogServiceRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n }) as ServiceFactory<CatalogServiceMock, 'plugin', 'singleton'>;\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 = createServiceMock<CatalogServiceMock>(\n catalogServiceRef,\n () => ({\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 }),\n );\n}\n"],"names":["InMemoryCatalogClient","catalogServiceMock","createServiceFactory","catalogServiceRef","createServiceMock"],"mappings":";;;;;;;AAiCO,SAAS,mBAAmB,OAAA,EAEZ;AACrB,EAAA,OAAO,IAAIA,gCAAsB,OAAO,CAAA;AAC1C;AAAA,CAOO,CAAUC,mBAAAA,KAAV;AAME,EAAMA,mBAAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KACtBC,qCAAA,CAAqB;AAAA,IACnB,OAAA,EAASC,mCAAA;AAAA,IACT,MAAM,EAAC;AAAA,IACP,OAAA,EAAS,MAAM,IAAIH,+BAAA,CAAsB,OAAO;AAAA,GACjD,CAAA;AAKI,EAAMC,oBAAA,IAAA,GAAOG,kCAAA;AAAA,IAClBD,mCAAA;AAAA,IACA,OAAO;AAAA,MACL,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,MACrB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,MAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,MACvB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,MAC5B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,MACxB,iBAAA,EAAmB,KAAK,EAAA,EAAG;AAAA,MAC3B,aAAA,EAAe,KAAK,EAAA,EAAG;AAAA,MACvB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,YAAA,EAAc,KAAK,EAAA,EAAG;AAAA,MACtB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,gBAAA,EAAkB,KAAK,EAAA,EAAG;AAAA,MAC1B,WAAA,EAAa,KAAK,EAAA,EAAG;AAAA,MACrB,kBAAA,EAAoB,KAAK,EAAA,EAAG;AAAA,MAC5B,mBAAA,EAAqB,KAAK,EAAA,EAAG;AAAA,MAC7B,cAAA,EAAgB,KAAK,EAAA,EAAG;AAAA,MACxB,eAAA,EAAiB,KAAK,EAAA,EAAG;AAAA,MACzB,cAAA,EAAgB,KAAK,EAAA;AAAG,KAC1B;AAAA,GACF;AAAA,CAAA,EArCe,kBAAA,KAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1,6 +1,6 @@
1
+ import * as _backstage_backend_test_utils from '@backstage/backend-test-utils';
1
2
  import { ServiceFactory } from '@backstage/backend-plugin-api';
2
3
  import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
3
- import { ServiceMock } from '@backstage/backend-test-utils';
4
4
  import { CatalogApi, GetEntitiesRequest, CatalogRequestOptions, GetEntitiesResponse, GetEntitiesByRefsRequest, GetEntitiesByRefsResponse, QueryEntitiesRequest, QueryEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, GetEntityFacetsRequest, GetEntityFacetsResponse, GetLocationsResponse, Location, AddLocationRequest, AddLocationResponse, ValidateEntityResponse, StreamEntitiesRequest } from '@backstage/catalog-client';
5
5
  import { AnalyzeLocationRequest, AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';
6
6
  import { CatalogService, CatalogServiceRequestOptions } from '@backstage/plugin-catalog-node';
@@ -64,7 +64,7 @@ declare namespace catalogServiceMock {
64
64
  * Creates a catalog client whose methods are mock functions, possibly with
65
65
  * some of them overloaded by the caller.
66
66
  */
67
- const mock: (partialImpl?: Partial<CatalogServiceMock> | undefined) => ServiceMock<CatalogServiceMock>;
67
+ const mock: (partialImpl?: Partial<CatalogServiceMock> | undefined) => _backstage_backend_test_utils.ServiceMock<CatalogServiceMock>;
68
68
  }
69
69
 
70
70
  export { catalogServiceMock };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-node",
3
- "version": "1.21.0-next.0",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "The plugin-catalog-node module for @backstage/plugin-catalog-backend",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -72,20 +72,28 @@
72
72
  "test": "backstage-cli package test"
73
73
  },
74
74
  "dependencies": {
75
- "@backstage/backend-plugin-api": "1.7.0-next.0",
76
- "@backstage/catalog-client": "1.12.1",
75
+ "@backstage/backend-plugin-api": "1.7.0-next.1",
76
+ "@backstage/catalog-client": "1.12.2-next.0",
77
77
  "@backstage/catalog-model": "1.7.6",
78
78
  "@backstage/errors": "1.2.7",
79
79
  "@backstage/plugin-catalog-common": "1.1.8-next.0",
80
- "@backstage/plugin-permission-common": "0.9.5-next.0",
81
- "@backstage/plugin-permission-node": "0.10.9-next.0",
80
+ "@backstage/plugin-permission-common": "0.9.6-next.0",
81
+ "@backstage/plugin-permission-node": "0.10.10-next.0",
82
82
  "@backstage/types": "1.2.2",
83
83
  "lodash": "^4.17.21",
84
84
  "yaml": "^2.0.0"
85
85
  },
86
+ "peerDependencies": {
87
+ "@backstage/backend-test-utils": "1.11.0-next.1"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "@backstage/backend-test-utils": {
91
+ "optional": true
92
+ }
93
+ },
86
94
  "devDependencies": {
87
- "@backstage/backend-test-utils": "1.10.4-next.0",
88
- "@backstage/cli": "0.35.3-next.0",
95
+ "@backstage/backend-test-utils": "1.11.0-next.1",
96
+ "@backstage/cli": "0.35.4-next.2",
89
97
  "msw": "^1.0.0"
90
98
  }
91
99
  }