@backstage/catalog-client 0.7.0 → 0.7.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,14 @@
1
1
  # @backstage/catalog-client
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix for the previous release with missing type declarations.
8
+ - Updated dependencies
9
+ - @backstage/catalog-model@0.10.1
10
+ - @backstage/errors@0.2.2
11
+
3
12
  ## 0.7.0
4
13
 
5
14
  ### Minor Changes
@@ -0,0 +1,324 @@
1
+ import { Entity, LocationSpec, EntityName } from '@backstage/catalog-model';
2
+
3
+ /**
4
+ * This symbol can be used in place of a value when passed to filters in e.g.
5
+ * {@link CatalogClient.getEntities}, to signify that you want to filter on the
6
+ * presence of that key no matter what its value is.
7
+ *
8
+ * @public
9
+ */
10
+ declare const CATALOG_FILTER_EXISTS: unique symbol;
11
+ /**
12
+ * The request type for {@link CatalogClient.getEntities}.
13
+ *
14
+ * @public
15
+ */
16
+ interface GetEntitiesRequest {
17
+ /**
18
+ * If given, return only entities that match the given patterns.
19
+ *
20
+ * @remarks
21
+ *
22
+ * If multiple filter sets are given as an array, then there is effectively an
23
+ * OR between each filter set.
24
+ *
25
+ * Within one filter set, there is effectively an AND between the various
26
+ * keys.
27
+ *
28
+ * Within one key, if there are more than one value, then there is effectively
29
+ * an OR between them.
30
+ *
31
+ * Example: For an input of
32
+ *
33
+ * ```
34
+ * [
35
+ * { kind: ['API', 'Component'] },
36
+ * { 'metadata.name': 'a', 'metadata.namespace': 'b' }
37
+ * ]
38
+ * ```
39
+ *
40
+ * This effectively means
41
+ *
42
+ * ```
43
+ * (kind = EITHER 'API' OR 'Component')
44
+ * OR
45
+ * (metadata.name = 'a' AND metadata.namespace = 'b' )
46
+ * ```
47
+ *
48
+ * Each key is a dot separated path in each object.
49
+ *
50
+ * As a value you can also pass in the symbol `CATALOG_FILTER_EXISTS`
51
+ * (exported from this package), which means that you assert on the existence
52
+ * of that key, no matter what its value is.
53
+ */
54
+ filter?: Record<string, string | symbol | (string | symbol)[]>[] | Record<string, string | symbol | (string | symbol)[]> | undefined;
55
+ /**
56
+ * If given, return only the parts of each entity that match those dot
57
+ * separated paths in each object.
58
+ *
59
+ * @remarks
60
+ *
61
+ * Example: For an input of `['kind', 'metadata.annotations']`, then response
62
+ * objects will be shaped like
63
+ *
64
+ * ```
65
+ * {
66
+ * "kind": "Component",
67
+ * "metadata": {
68
+ * "annotations": {
69
+ * "foo": "bar"
70
+ * }
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ fields?: string[] | undefined;
76
+ /**
77
+ * If given, skips over the first N items in the result set.
78
+ */
79
+ offset?: number;
80
+ /**
81
+ * If given, returns at most N items from the result set.
82
+ */
83
+ limit?: number;
84
+ /**
85
+ * If given, skips over all items before that cursor as returned by a previous
86
+ * request.
87
+ */
88
+ after?: string;
89
+ }
90
+ /**
91
+ * The response type for {@link CatalogClient.getEntities}.
92
+ *
93
+ * @public
94
+ */
95
+ interface GetEntitiesResponse {
96
+ items: Entity[];
97
+ }
98
+ /**
99
+ * The request type for {@link CatalogClient.getEntityAncestors}.
100
+ *
101
+ * @public
102
+ */
103
+ interface GetEntityAncestorsRequest {
104
+ entityRef: string;
105
+ }
106
+ /**
107
+ * The response type for {@link CatalogClient.getEntityAncestors}.
108
+ *
109
+ * @public
110
+ */
111
+ interface GetEntityAncestorsResponse {
112
+ rootEntityRef: string;
113
+ items: Array<{
114
+ entity: Entity;
115
+ parentEntityRefs: string[];
116
+ }>;
117
+ }
118
+ /**
119
+ * Options you can pass into a catalog request for additional information.
120
+ *
121
+ * @public
122
+ */
123
+ interface CatalogRequestOptions {
124
+ token?: string;
125
+ }
126
+ /**
127
+ * Entity location for a specific entity.
128
+ *
129
+ * @public
130
+ */
131
+ declare type Location = {
132
+ id: string;
133
+ } & LocationSpec;
134
+ /**
135
+ * The request type for {@link CatalogClient.addLocation}.
136
+ *
137
+ * @public
138
+ */
139
+ declare type AddLocationRequest = {
140
+ type?: string;
141
+ target: string;
142
+ dryRun?: boolean;
143
+ presence?: 'optional' | 'required';
144
+ };
145
+ /**
146
+ * The response type for {@link CatalogClient.addLocation}.
147
+ *
148
+ * @public
149
+ */
150
+ declare type AddLocationResponse = {
151
+ location: Location;
152
+ entities: Entity[];
153
+ exists?: boolean;
154
+ };
155
+ /**
156
+ * A client for interacting with the Backstage software catalog through its API.
157
+ *
158
+ * @public
159
+ */
160
+ interface CatalogApi {
161
+ /**
162
+ * Lists catalog entities.
163
+ *
164
+ * @param request - Request parameters
165
+ * @param options - Additional options
166
+ */
167
+ getEntities(request?: GetEntitiesRequest, options?: CatalogRequestOptions): Promise<GetEntitiesResponse>;
168
+ /**
169
+ * Gets entity ancestor information, i.e. the hierarchy of parent entities
170
+ * whose processing resulted in a given entity appearing in the catalog.
171
+ *
172
+ * @param request - Request parameters
173
+ * @param options - Additional options
174
+ */
175
+ getEntityAncestors(request: GetEntityAncestorsRequest, options?: CatalogRequestOptions): Promise<GetEntityAncestorsResponse>;
176
+ /**
177
+ * Gets a single entity from the catalog by its ref (kind, namespace, name)
178
+ * triplet.
179
+ *
180
+ * @param name - A complete entity ref
181
+ * @param options - Additional options
182
+ */
183
+ getEntityByName(name: EntityName, options?: CatalogRequestOptions): Promise<Entity | undefined>;
184
+ /**
185
+ * Removes a single entity from the catalog by entity UID.
186
+ *
187
+ * @param uid - An entity UID
188
+ * @param options - Additional options
189
+ */
190
+ removeEntityByUid(uid: string, options?: CatalogRequestOptions): Promise<void>;
191
+ /**
192
+ * Refreshes (marks for reprocessing) an entity in the catalog.
193
+ *
194
+ * @param entityRef - An entity ref on string form (e.g.
195
+ * 'component/default:my-component')
196
+ * @param options - Additional options
197
+ */
198
+ refreshEntity(entityRef: string, options?: CatalogRequestOptions): Promise<void>;
199
+ /**
200
+ * Gets a registered location by its ID.
201
+ *
202
+ * @param id - A location ID
203
+ * @param options - Additional options
204
+ */
205
+ getLocationById(id: string, options?: CatalogRequestOptions): Promise<Location | undefined>;
206
+ /**
207
+ * Gets a registered location by its ref.
208
+ *
209
+ * @param locationRef - A location ref, e.g. "url:https://github.com/..."
210
+ * @param options - Additional options
211
+ */
212
+ getLocationByRef(locationRef: string, options?: CatalogRequestOptions): Promise<Location | undefined>;
213
+ /**
214
+ * Registers a new location.
215
+ *
216
+ * @param location - Request parameters
217
+ * @param options - Additional options
218
+ */
219
+ addLocation(location: AddLocationRequest, options?: CatalogRequestOptions): Promise<AddLocationResponse>;
220
+ /**
221
+ * Removes a registered Location by its ID.
222
+ *
223
+ * @param id - A location ID
224
+ * @param options - Additional options
225
+ */
226
+ removeLocationById(id: string, options?: CatalogRequestOptions): Promise<void>;
227
+ }
228
+
229
+ /**
230
+ * A frontend and backend compatible client for communicating with the Backstage
231
+ * software catalog.
232
+ *
233
+ * @public
234
+ */
235
+ declare class CatalogClient implements CatalogApi {
236
+ private readonly discoveryApi;
237
+ private readonly fetchApi;
238
+ constructor(options: {
239
+ discoveryApi: {
240
+ getBaseUrl(pluginId: string): Promise<string>;
241
+ };
242
+ fetchApi?: {
243
+ fetch: typeof fetch;
244
+ };
245
+ });
246
+ /**
247
+ * {@inheritdoc CatalogApi.getEntityAncestors}
248
+ */
249
+ getEntityAncestors(request: GetEntityAncestorsRequest, options?: CatalogRequestOptions): Promise<GetEntityAncestorsResponse>;
250
+ /**
251
+ * {@inheritdoc CatalogApi.getLocationById}
252
+ */
253
+ getLocationById(id: string, options?: CatalogRequestOptions): Promise<Location | undefined>;
254
+ /**
255
+ * {@inheritdoc CatalogApi.getEntities}
256
+ */
257
+ getEntities(request?: GetEntitiesRequest, options?: CatalogRequestOptions): Promise<GetEntitiesResponse>;
258
+ /**
259
+ * {@inheritdoc CatalogApi.getEntityByName}
260
+ */
261
+ getEntityByName(compoundName: EntityName, options?: CatalogRequestOptions): Promise<Entity | undefined>;
262
+ /**
263
+ * {@inheritdoc CatalogApi.refreshEntity}
264
+ */
265
+ refreshEntity(entityRef: string, options?: CatalogRequestOptions): Promise<void>;
266
+ /**
267
+ * {@inheritdoc CatalogApi.addLocation}
268
+ */
269
+ addLocation({ type, target, dryRun, presence }: AddLocationRequest, options?: CatalogRequestOptions): Promise<AddLocationResponse>;
270
+ /**
271
+ * @deprecated please use getLocationByRef instead
272
+ */
273
+ getOriginLocationByEntity(entity: Entity, options?: CatalogRequestOptions): Promise<Location | undefined>;
274
+ /**
275
+ * @deprecated please use getLocationByRef instead
276
+ */
277
+ getLocationByEntity(entity: Entity, options?: CatalogRequestOptions): Promise<Location | undefined>;
278
+ /**
279
+ * {@inheritdoc CatalogApi.getLocationByRef}
280
+ */
281
+ getLocationByRef(locationRef: string, options?: CatalogRequestOptions): Promise<Location | undefined>;
282
+ /**
283
+ * {@inheritdoc CatalogApi.removeLocationById}
284
+ */
285
+ removeLocationById(id: string, options?: CatalogRequestOptions): Promise<void>;
286
+ /**
287
+ * {@inheritdoc CatalogApi.removeEntityByUid}
288
+ */
289
+ removeEntityByUid(uid: string, options?: CatalogRequestOptions): Promise<void>;
290
+ private requestIgnored;
291
+ private requestRequired;
292
+ private requestOptional;
293
+ }
294
+
295
+ /**
296
+ * The entity `status.items[].type` for the status of the processing engine in
297
+ * regards to an entity.
298
+ *
299
+ * @public
300
+ */
301
+ declare const ENTITY_STATUS_CATALOG_PROCESSING_TYPE = "backstage.io/catalog-processing";
302
+
303
+ /**
304
+ * @public
305
+ * @deprecated use GetEntitiesRequest instead
306
+ */
307
+ declare type CatalogEntitiesRequest = GetEntitiesRequest;
308
+ /**
309
+ * @public
310
+ * @deprecated use GetEntitiesResponse instead
311
+ */
312
+ declare type CatalogListResponse<_Entity> = GetEntitiesResponse;
313
+ /**
314
+ * @public
315
+ * @deprecated use GetEntityAncestorsRequest instead
316
+ */
317
+ declare type CatalogEntityAncestorsRequest = GetEntityAncestorsRequest;
318
+ /**
319
+ * @public
320
+ * @deprecated use GetEntityAncestorsResponse instead
321
+ */
322
+ declare type CatalogEntityAncestorsResponse = GetEntityAncestorsResponse;
323
+
324
+ export { AddLocationRequest, AddLocationResponse, CATALOG_FILTER_EXISTS, CatalogApi, CatalogClient, CatalogEntitiesRequest, CatalogEntityAncestorsRequest, CatalogEntityAncestorsResponse, CatalogListResponse, CatalogRequestOptions, ENTITY_STATUS_CATALOG_PROCESSING_TYPE, GetEntitiesRequest, GetEntitiesResponse, GetEntityAncestorsRequest, GetEntityAncestorsResponse, Location };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/catalog-client",
3
3
  "description": "An isomorphic client for the catalog backend",
4
- "version": "0.7.0",
4
+ "version": "0.7.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -33,8 +33,8 @@
33
33
  "clean": "backstage-cli package clean"
34
34
  },
35
35
  "dependencies": {
36
- "@backstage/catalog-model": "^0.10.0",
37
- "@backstage/errors": "^0.2.1",
36
+ "@backstage/catalog-model": "^0.10.1",
37
+ "@backstage/errors": "^0.2.2",
38
38
  "cross-fetch": "^3.1.5"
39
39
  },
40
40
  "devDependencies": {
@@ -45,6 +45,6 @@
45
45
  "files": [
46
46
  "dist"
47
47
  ],
48
- "gitHead": "4805c3d13ce9bfc369e53c271b1b95e722b3b4dc",
48
+ "gitHead": "e244b348c473700e7d5e5fbcef38bd9f9fd1d0ba",
49
49
  "module": "dist/index.esm.js"
50
50
  }