@backstage/plugin-catalog-unprocessed-entities-common 0.0.11-next.0 → 0.0.12-next.0

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,27 @@
1
1
  # @backstage/plugin-catalog-unprocessed-entities-common
2
2
 
3
+ ## 0.0.12-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - df4d646: Moved types, API and client to the common package, allowing both frontend and
8
+ backend plugins to use the `CatalogUnprocessedEntitiesClient`.
9
+
10
+ The following types, clients and interfaces have been deprecated and should be
11
+ imported from the `@backstage/plugin-catalog-unprocessed-entities-common` instead:
12
+ `CatalogUnprocessedEntitiesApi`, `CatalogUnprocessedEntitiesApiResponse`, `UnprocessedEntity`,
13
+ `UnprocessedEntityCache`, `UnprocessedEntityError`, `CatalogUnprocessedEntitiesClient`.
14
+
15
+ All those types, clients and interfaces are re-exported temporarily in the
16
+ `@backstage/plugin-catalog-unprocessed-entities` package until cleaned up.
17
+
18
+ ## 0.0.11
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @backstage/plugin-permission-common@0.9.3
24
+
3
25
  ## 0.0.11-next.0
4
26
 
5
27
  ### Patch Changes
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+
5
+ class CatalogUnprocessedEntitiesClient {
6
+ discovery;
7
+ fetchApi;
8
+ constructor(discovery, fetchApi) {
9
+ this.discovery = discovery;
10
+ this.fetchApi = fetchApi ?? { fetch };
11
+ }
12
+ async fetch(method, path, options) {
13
+ const url = await this.discovery.getBaseUrl("catalog");
14
+ const resp = await this.fetchApi.fetch(`${url}/${path}`, {
15
+ method,
16
+ headers: {
17
+ ...options?.token ? { Authorization: `Bearer ${options.token}` } : {}
18
+ }
19
+ });
20
+ if (!resp.ok) {
21
+ throw await errors.ResponseError.fromResponse(resp);
22
+ }
23
+ return resp.status === 204 ? resp : await resp.json();
24
+ }
25
+ async pending(options) {
26
+ return await this.fetch("GET", "entities/unprocessed/pending", options);
27
+ }
28
+ async failed(options) {
29
+ return await this.fetch("GET", "entities/unprocessed/failed", options);
30
+ }
31
+ async delete(entityId, options) {
32
+ await this.fetch(
33
+ "DELETE",
34
+ `entities/unprocessed/delete/${entityId}`,
35
+ options
36
+ );
37
+ }
38
+ }
39
+
40
+ exports.CatalogUnprocessedEntitiesClient = CatalogUnprocessedEntitiesClient;
41
+ //# sourceMappingURL=api.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.cjs.js","sources":["../../src/api/api.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { CatalogUnprocessedEntitiesApiResponse } from '../types';\nimport { ResponseError } from '@backstage/errors';\n\n/**\n * Options you can pass into a catalog request for additional information.\n *\n * @public\n */\nexport interface UnprocessedEntitiesRequestOptions {\n token?: string;\n}\n\n/**\n * Interface for the CatalogUnprocessedEntitiesApi.\n *\n * @public\n */\nexport interface CatalogUnprocessedEntitiesApi {\n /**\n * Returns a list of entities with state 'pending'\n *\n * @param options - Additional options\n */\n pending(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse>;\n /**\n * Returns a list of entities with state 'failed'\n *\n * @param options - Additional options\n */\n failed(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse>;\n /**\n * Deletes an entity from the refresh_state table\n *\n * @param entityId - The ID of the entity to delete\n * @param options - Additional options\n */\n delete(\n entityId: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<void>;\n}\n\n/**\n * Default API implementation for the Catalog Unprocessed Entities plugin\n *\n * @public\n */\nexport class CatalogUnprocessedEntitiesClient\n implements CatalogUnprocessedEntitiesApi\n{\n private readonly discovery: { getBaseUrl(pluginId: string): Promise<string> };\n private readonly fetchApi: { fetch: typeof fetch };\n\n constructor(\n discovery: { getBaseUrl(pluginId: string): Promise<string> },\n fetchApi?: { fetch: typeof fetch },\n ) {\n this.discovery = discovery;\n this.fetchApi = fetchApi ?? { fetch };\n }\n\n private async fetch<T>(\n method: string,\n path: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<T> {\n const url = await this.discovery.getBaseUrl('catalog');\n const resp = await this.fetchApi.fetch(`${url}/${path}`, {\n method,\n headers: {\n ...(options?.token ? { Authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.status === 204 ? (resp as T) : await resp.json();\n }\n\n async pending(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse> {\n return await this.fetch('GET', 'entities/unprocessed/pending', options);\n }\n\n async failed(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse> {\n return await this.fetch('GET', 'entities/unprocessed/failed', options);\n }\n\n async delete(\n entityId: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<void> {\n await this.fetch(\n 'DELETE',\n `entities/unprocessed/delete/${entityId}`,\n options,\n );\n }\n}\n"],"names":["ResponseError"],"mappings":";;;;AAmEO,MAAM,gCAAA,CAEb;AAAA,EACmB,SAAA;AAAA,EACA,QAAA;AAAA,EAEjB,WAAA,CACE,WACA,QAAA,EACA;AACA,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AACjB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA,IAAY,EAAE,KAAA,EAAM;AAAA,EACtC;AAAA,EAEA,MAAc,KAAA,CACZ,MAAA,EACA,IAAA,EACA,OAAA,EACY;AACZ,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,SAAA,CAAU,WAAW,SAAS,CAAA;AACrD,IAAA,MAAM,IAAA,GAAO,MAAM,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA,EAAI;AAAA,MACvD,MAAA;AAAA,MACA,OAAA,EAAS;AAAA,QACP,GAAI,OAAA,EAAS,KAAA,GAAQ,EAAE,aAAA,EAAe,UAAU,OAAA,CAAQ,KAAK,CAAA,CAAA,EAAG,GAAI;AAAC;AACvE,KACD,CAAA;AAED,IAAA,IAAI,CAAC,KAAK,EAAA,EAAI;AACZ,MAAA,MAAM,MAAMA,oBAAA,CAAc,YAAA,CAAa,IAAI,CAAA;AAAA,IAC7C;AAEA,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA,GAAO,IAAA,GAAa,MAAM,KAAK,IAAA,EAAK;AAAA,EAC7D;AAAA,EAEA,MAAM,QACJ,OAAA,EACgD;AAChD,IAAA,OAAO,MAAM,IAAA,CAAK,KAAA,CAAM,KAAA,EAAO,gCAAgC,OAAO,CAAA;AAAA,EACxE;AAAA,EAEA,MAAM,OACJ,OAAA,EACgD;AAChD,IAAA,OAAO,MAAM,IAAA,CAAK,KAAA,CAAM,KAAA,EAAO,+BAA+B,OAAO,CAAA;AAAA,EACvE;AAAA,EAEA,MAAM,MAAA,CACJ,QAAA,EACA,OAAA,EACe;AACf,IAAA,MAAM,IAAA,CAAK,KAAA;AAAA,MACT,QAAA;AAAA,MACA,+BAA+B,QAAQ,CAAA,CAAA;AAAA,MACvC;AAAA,KACF;AAAA,EACF;AACF;;;;"}
@@ -0,0 +1,39 @@
1
+ import { ResponseError } from '@backstage/errors';
2
+
3
+ class CatalogUnprocessedEntitiesClient {
4
+ discovery;
5
+ fetchApi;
6
+ constructor(discovery, fetchApi) {
7
+ this.discovery = discovery;
8
+ this.fetchApi = fetchApi ?? { fetch };
9
+ }
10
+ async fetch(method, path, options) {
11
+ const url = await this.discovery.getBaseUrl("catalog");
12
+ const resp = await this.fetchApi.fetch(`${url}/${path}`, {
13
+ method,
14
+ headers: {
15
+ ...options?.token ? { Authorization: `Bearer ${options.token}` } : {}
16
+ }
17
+ });
18
+ if (!resp.ok) {
19
+ throw await ResponseError.fromResponse(resp);
20
+ }
21
+ return resp.status === 204 ? resp : await resp.json();
22
+ }
23
+ async pending(options) {
24
+ return await this.fetch("GET", "entities/unprocessed/pending", options);
25
+ }
26
+ async failed(options) {
27
+ return await this.fetch("GET", "entities/unprocessed/failed", options);
28
+ }
29
+ async delete(entityId, options) {
30
+ await this.fetch(
31
+ "DELETE",
32
+ `entities/unprocessed/delete/${entityId}`,
33
+ options
34
+ );
35
+ }
36
+ }
37
+
38
+ export { CatalogUnprocessedEntitiesClient };
39
+ //# sourceMappingURL=api.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.esm.js","sources":["../../src/api/api.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { CatalogUnprocessedEntitiesApiResponse } from '../types';\nimport { ResponseError } from '@backstage/errors';\n\n/**\n * Options you can pass into a catalog request for additional information.\n *\n * @public\n */\nexport interface UnprocessedEntitiesRequestOptions {\n token?: string;\n}\n\n/**\n * Interface for the CatalogUnprocessedEntitiesApi.\n *\n * @public\n */\nexport interface CatalogUnprocessedEntitiesApi {\n /**\n * Returns a list of entities with state 'pending'\n *\n * @param options - Additional options\n */\n pending(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse>;\n /**\n * Returns a list of entities with state 'failed'\n *\n * @param options - Additional options\n */\n failed(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse>;\n /**\n * Deletes an entity from the refresh_state table\n *\n * @param entityId - The ID of the entity to delete\n * @param options - Additional options\n */\n delete(\n entityId: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<void>;\n}\n\n/**\n * Default API implementation for the Catalog Unprocessed Entities plugin\n *\n * @public\n */\nexport class CatalogUnprocessedEntitiesClient\n implements CatalogUnprocessedEntitiesApi\n{\n private readonly discovery: { getBaseUrl(pluginId: string): Promise<string> };\n private readonly fetchApi: { fetch: typeof fetch };\n\n constructor(\n discovery: { getBaseUrl(pluginId: string): Promise<string> },\n fetchApi?: { fetch: typeof fetch },\n ) {\n this.discovery = discovery;\n this.fetchApi = fetchApi ?? { fetch };\n }\n\n private async fetch<T>(\n method: string,\n path: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<T> {\n const url = await this.discovery.getBaseUrl('catalog');\n const resp = await this.fetchApi.fetch(`${url}/${path}`, {\n method,\n headers: {\n ...(options?.token ? { Authorization: `Bearer ${options.token}` } : {}),\n },\n });\n\n if (!resp.ok) {\n throw await ResponseError.fromResponse(resp);\n }\n\n return resp.status === 204 ? (resp as T) : await resp.json();\n }\n\n async pending(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse> {\n return await this.fetch('GET', 'entities/unprocessed/pending', options);\n }\n\n async failed(\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<CatalogUnprocessedEntitiesApiResponse> {\n return await this.fetch('GET', 'entities/unprocessed/failed', options);\n }\n\n async delete(\n entityId: string,\n options?: UnprocessedEntitiesRequestOptions,\n ): Promise<void> {\n await this.fetch(\n 'DELETE',\n `entities/unprocessed/delete/${entityId}`,\n options,\n );\n }\n}\n"],"names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A,MACT,QAAA;AAAA,MACA,+BAA+B,QAAQ,CAAA,CAAA;AAAA,MACvC;AAAA,KACF;AAAA,EACF;AACF;;;;"}
package/dist/index.cjs.js CHANGED
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var api = require('./api/api.cjs.js');
3
4
  var permissions = require('./permissions.cjs.js');
4
5
 
5
6
 
6
7
 
8
+ exports.CatalogUnprocessedEntitiesClient = api.CatalogUnprocessedEntitiesClient;
7
9
  exports.unprocessedEntitiesDeletePermission = permissions.unprocessedEntitiesDeletePermission;
8
10
  exports.unprocessedEntitiesPermissions = permissions.unprocessedEntitiesPermissions;
9
11
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,106 @@
1
+ import { Entity } from '@backstage/catalog-model';
1
2
  import * as _backstage_plugin_permission_common from '@backstage/plugin-permission-common';
2
3
 
4
+ /**
5
+ * Unprocessed entity data stored in the database.
6
+ * @public
7
+ */
8
+ type UnprocessedEntity = {
9
+ entity_id: string;
10
+ entity_ref: string;
11
+ unprocessed_entity: Entity;
12
+ unprocessed_hash?: string;
13
+ processed_entity?: Entity;
14
+ result_hash?: string;
15
+ cache?: UnprocessedEntityCache;
16
+ next_update_at: string | Date;
17
+ last_discovery_at: string | Date;
18
+ errors?: UnprocessedEntityError[];
19
+ location_key?: string;
20
+ };
21
+ /**
22
+ * Unprocessed entity cache stored in the database.
23
+ * @public
24
+ */
25
+ type UnprocessedEntityCache = {
26
+ ttl: number;
27
+ cache: object;
28
+ };
29
+ /**
30
+ * Unprocessed entity error information stored in the database.
31
+ * @public
32
+ */
33
+ type UnprocessedEntityError = {
34
+ name: string;
35
+ message: string;
36
+ cause: {
37
+ name: string;
38
+ message: string;
39
+ stack: string;
40
+ };
41
+ };
42
+ /**
43
+ * Response expected by the {@link CatalogUnprocessedEntitiesApi}
44
+ *
45
+ * @public
46
+ */
47
+ type CatalogUnprocessedEntitiesApiResponse = {
48
+ entities: UnprocessedEntity[];
49
+ };
50
+
51
+ /**
52
+ * Options you can pass into a catalog request for additional information.
53
+ *
54
+ * @public
55
+ */
56
+ interface UnprocessedEntitiesRequestOptions {
57
+ token?: string;
58
+ }
59
+ /**
60
+ * Interface for the CatalogUnprocessedEntitiesApi.
61
+ *
62
+ * @public
63
+ */
64
+ interface CatalogUnprocessedEntitiesApi {
65
+ /**
66
+ * Returns a list of entities with state 'pending'
67
+ *
68
+ * @param options - Additional options
69
+ */
70
+ pending(options?: UnprocessedEntitiesRequestOptions): Promise<CatalogUnprocessedEntitiesApiResponse>;
71
+ /**
72
+ * Returns a list of entities with state 'failed'
73
+ *
74
+ * @param options - Additional options
75
+ */
76
+ failed(options?: UnprocessedEntitiesRequestOptions): Promise<CatalogUnprocessedEntitiesApiResponse>;
77
+ /**
78
+ * Deletes an entity from the refresh_state table
79
+ *
80
+ * @param entityId - The ID of the entity to delete
81
+ * @param options - Additional options
82
+ */
83
+ delete(entityId: string, options?: UnprocessedEntitiesRequestOptions): Promise<void>;
84
+ }
85
+ /**
86
+ * Default API implementation for the Catalog Unprocessed Entities plugin
87
+ *
88
+ * @public
89
+ */
90
+ declare class CatalogUnprocessedEntitiesClient implements CatalogUnprocessedEntitiesApi {
91
+ private readonly discovery;
92
+ private readonly fetchApi;
93
+ constructor(discovery: {
94
+ getBaseUrl(pluginId: string): Promise<string>;
95
+ }, fetchApi?: {
96
+ fetch: typeof fetch;
97
+ });
98
+ private fetch;
99
+ pending(options?: UnprocessedEntitiesRequestOptions): Promise<CatalogUnprocessedEntitiesApiResponse>;
100
+ failed(options?: UnprocessedEntitiesRequestOptions): Promise<CatalogUnprocessedEntitiesApiResponse>;
101
+ delete(entityId: string, options?: UnprocessedEntitiesRequestOptions): Promise<void>;
102
+ }
103
+
3
104
  /**
4
105
  * This permission is used to designate actions that involve removing an
5
106
  * unprocessed entity record from the refresh_state table.
@@ -14,4 +115,4 @@ declare const unprocessedEntitiesPermissions: {
14
115
  unprocessedEntitiesDeletePermission: _backstage_plugin_permission_common.BasicPermission;
15
116
  };
16
117
 
17
- export { unprocessedEntitiesDeletePermission, unprocessedEntitiesPermissions };
118
+ export { type CatalogUnprocessedEntitiesApi, type CatalogUnprocessedEntitiesApiResponse, CatalogUnprocessedEntitiesClient, type UnprocessedEntitiesRequestOptions, type UnprocessedEntity, type UnprocessedEntityCache, type UnprocessedEntityError, unprocessedEntitiesDeletePermission, unprocessedEntitiesPermissions };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,3 @@
1
+ export { CatalogUnprocessedEntitiesClient } from './api/api.esm.js';
1
2
  export { unprocessedEntitiesDeletePermission, unprocessedEntitiesPermissions } from './permissions.esm.js';
2
3
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-unprocessed-entities-common",
3
- "version": "0.0.11-next.0",
3
+ "version": "0.0.12-next.0",
4
4
  "description": "Common functionalities for the catalog-unprocessed-entities plugin",
5
5
  "backstage": {
6
6
  "role": "common-library",
@@ -37,10 +37,12 @@
37
37
  "test": "backstage-cli package test"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/plugin-permission-common": "0.9.3-next.0"
40
+ "@backstage/catalog-model": "1.7.6",
41
+ "@backstage/errors": "1.2.7",
42
+ "@backstage/plugin-permission-common": "0.9.3"
41
43
  },
42
44
  "devDependencies": {
43
- "@backstage/cli": "0.34.5-next.0"
45
+ "@backstage/cli": "0.34.6-next.1"
44
46
  },
45
47
  "typesVersions": {
46
48
  "*": {