From 422eee24d9e1484f2d4a1c2e8f474f45a3e70334 Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Tue, 20 Sep 2022 19:09:35 +0100 Subject: [PATCH 01/25] added get latest facts from tech-insighs Signed-off-by: Alisson Fabiano --- plugins/tech-insights/api-report.md | 33 ++++++++++ plugins/tech-insights/package.json | 1 + .../tech-insights/src/api/TechInsightsApi.ts | 6 +- .../src/api/TechInsightsClient.ts | 66 +++++++++---------- plugins/tech-insights/src/api/types.ts | 27 ++++++++ plugins/tech-insights/src/index.ts | 2 +- yarn.lock | 8 +++ 7 files changed, 108 insertions(+), 35 deletions(-) diff --git a/plugins/tech-insights/api-report.md b/plugins/tech-insights/api-report.md index 03155a5958..b40bf9fe92 100644 --- a/plugins/tech-insights/api-report.md +++ b/plugins/tech-insights/api-report.md @@ -10,8 +10,10 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { BulkCheckResponse } from '@backstage/plugin-tech-insights-common'; import { CheckResult } from '@backstage/plugin-tech-insights-common'; import { CompoundEntityRef } from '@backstage/catalog-model'; +import { DateTime } from 'luxon'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { IdentityApi } from '@backstage/core-plugin-api'; +import { JsonValue } from '@backstage/types'; import { default as React_2 } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; @@ -51,6 +53,27 @@ export const EntityTechInsightsScorecardContent: (props: { checksId?: string[] | undefined; }) => JSX.Element; +// @public +export interface InsightFact { + // (undocumented) + [factId: string]: { + timestamp: string; + version: string; + facts: Record< + string, + | number + | string + | boolean + | DateTime + | number[] + | string[] + | boolean[] + | DateTime[] + | JsonValue + >; + }; +} + // @public export const jsonRulesEngineCheckResultRenderer: CheckResultRenderer; @@ -61,6 +84,11 @@ export interface TechInsightsApi { // (undocumented) getCheckResultRenderers: (types: string[]) => CheckResultRenderer[]; // (undocumented) + getLatestFacts( + entity: CompoundEntityRef, + facts: string[], + ): Promise; + // (undocumented) runBulkChecks( entities: CompoundEntityRef[], checks?: Check[], @@ -87,6 +115,11 @@ export class TechInsightsClient implements TechInsightsApi { // (undocumented) getCheckResultRenderers(types: string[]): CheckResultRenderer[]; // (undocumented) + getLatestFacts( + entity: CompoundEntityRef, + facts: string[], + ): Promise; + // (undocumented) runBulkChecks( entities: CompoundEntityRef[], checks?: Check[], diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index dad3263f10..06be8fd415 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -38,6 +38,7 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", + "luxon": "^3.0.3", "react-use": "^17.2.4" }, "peerDependencies": { diff --git a/plugins/tech-insights/src/api/TechInsightsApi.ts b/plugins/tech-insights/src/api/TechInsightsApi.ts index 8ab1090304..79754d53b1 100644 --- a/plugins/tech-insights/src/api/TechInsightsApi.ts +++ b/plugins/tech-insights/src/api/TechInsightsApi.ts @@ -19,7 +19,7 @@ import { CheckResult, BulkCheckResponse, } from '@backstage/plugin-tech-insights-common'; -import { Check } from './types'; +import { Check, InsightFact } from './types'; import { CheckResultRenderer } from '../components/CheckResultRenderer'; import { CompoundEntityRef } from '@backstage/catalog-model'; @@ -48,4 +48,8 @@ export interface TechInsightsApi { entities: CompoundEntityRef[], checks?: Check[], ): Promise; + getLatestFacts( + entity: CompoundEntityRef, + facts: string[], + ): Promise; } diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index 8db5de3945..bcfb045d00 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -19,7 +19,7 @@ import { BulkCheckResponse, CheckResult, } from '@backstage/plugin-tech-insights-common'; -import { Check } from './types'; +import { Check, InsightFact } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; import { ResponseError } from '@backstage/errors'; import { CompoundEntityRef } from '@backstage/catalog-model'; @@ -45,76 +45,76 @@ export class TechInsightsClient implements TechInsightsApi { this.renderers = options.renderers; } + async getLatestFacts( + entity: CompoundEntityRef, + facts: string[], + ): Promise { + const { namespace, kind, name } = entity; + const entityQuery = `entity=${encodeURIComponent( + kind.toLocaleLowerCase('en-US'), + )}:${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`; + const idsQuery = facts.map(id => `ids[]=${id}`).join('&'); + return await this.api( + `/facts/latest?${entityQuery}&${idsQuery}`, + ); + } + getCheckResultRenderers(types: string[]): CheckResultRenderer[] { const renderers = this.renderers ?? [jsonRulesEngineCheckResultRenderer]; return renderers.filter(d => types.includes(d.type)); } async getAllChecks(): Promise { - const url = await this.discoveryApi.getBaseUrl('tech-insights'); - const { token } = await this.identityApi.getCredentials(); - const response = await fetch(`${url}/checks`, { - headers: token - ? { - Authorization: `Bearer ${token}`, - } - : undefined, - }); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - return await response.json(); + return this.api('/checks'); } async runChecks( entityParams: CompoundEntityRef, checks?: string[], ): Promise { - const url = await this.discoveryApi.getBaseUrl('tech-insights'); - const { token } = await this.identityApi.getCredentials(); const { namespace, kind, name } = entityParams; const requestBody = { checks }; - const response = await fetch( - `${url}/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent( + return this.api( + `/checks/run/${encodeURIComponent(namespace)}/${encodeURIComponent( kind, )}/${encodeURIComponent(name)}`, { method: 'POST', body: JSON.stringify(requestBody), - headers: { - 'Content-Type': 'application/json', - ...(token && { Authorization: `Bearer ${token}` }), - }, }, ); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - return await response.json(); } async runBulkChecks( entities: CompoundEntityRef[], checks?: Check[], ): Promise { - const url = await this.discoveryApi.getBaseUrl('tech-insights'); - const { token } = await this.identityApi.getCredentials(); const checkIds = checks ? checks.map(check => check.id) : []; const requestBody = { entities, checks: checkIds.length > 0 ? checkIds : undefined, }; - const response = await fetch(`${url}/checks/run`, { + return this.api('/checks/run', { method: 'POST', body: JSON.stringify(requestBody), + }); + } + + private async api(path: string, init?: RequestInit): Promise { + const url = await this.discoveryApi.getBaseUrl('tech-insights'); + const { token } = await this.identityApi.getCredentials(); + + return fetch(`${url}${path}`, { + ...init, headers: { 'Content-Type': 'application/json', ...(token && { Authorization: `Bearer ${token}` }), }, + }).then(async response => { + if (!response.ok) { + throw await ResponseError.fromResponse(response); + } + return response.json() as Promise; }); - if (!response.ok) { - throw await ResponseError.fromResponse(response); - } - return await response.json(); } } diff --git a/plugins/tech-insights/src/api/types.ts b/plugins/tech-insights/src/api/types.ts index 10dfa06420..b69d4d6264 100644 --- a/plugins/tech-insights/src/api/types.ts +++ b/plugins/tech-insights/src/api/types.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +import { DateTime } from 'luxon'; +import { JsonValue } from '@backstage/types'; + /** * Represents a single check defined on the TechInsights backend. * @@ -26,3 +29,27 @@ export type Check = { description: string; factIds: string[]; }; + +/** + * Represents a Fact defined on the TechInsights backend. + * + * @public + */ +export interface InsightFact { + [factId: string]: { + timestamp: string; + version: string; + facts: Record< + string, + | number + | string + | boolean + | DateTime + | number[] + | string[] + | boolean[] + | DateTime[] + | JsonValue + >; + }; +} diff --git a/plugins/tech-insights/src/index.ts b/plugins/tech-insights/src/index.ts index f3dd05c3aa..ae2f9d53a7 100644 --- a/plugins/tech-insights/src/index.ts +++ b/plugins/tech-insights/src/index.ts @@ -20,7 +20,7 @@ export { } from './plugin'; export { techInsightsApiRef, TechInsightsClient } from './api'; -export type { TechInsightsApi, Check } from './api'; +export type { TechInsightsApi, Check, InsightFact } from './api'; export { BooleanCheck } from './components/BooleanCheck'; export { jsonRulesEngineCheckResultRenderer } from './components/CheckResultRenderer'; export type { CheckResultRenderer } from './components/CheckResultRenderer'; diff --git a/yarn.lock b/yarn.lock index 919949a804..f0186e432e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6936,6 +6936,7 @@ __metadata: "@testing-library/user-event": ^14.0.0 "@types/node": ^16.11.26 cross-fetch: ^3.1.5 + luxon: ^3.0.3 msw: ^0.47.0 react-use: ^17.2.4 peerDependencies: @@ -29340,6 +29341,13 @@ __metadata: languageName: node linkType: hard +"luxon@npm:^3.0.3": + version: 3.0.3 + resolution: "luxon@npm:3.0.3" + checksum: 67d143f102f520761c4202086579a5cf30b230ea299da27cacb31e9f9d372cadef90f14cbe7e2621b70825b267fe00128b8176ed8b7172b48f77a403a662d5aa + languageName: node + linkType: hard + "lz-string@npm:^1.4.4": version: 1.4.4 resolution: "lz-string@npm:1.4.4" From a60a6807bd69e95cbbf665cb39b264a3b551b6ab Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Tue, 20 Sep 2022 19:19:00 +0100 Subject: [PATCH 02/25] added changeset Signed-off-by: Alisson Fabiano --- .changeset/lovely-peaches-fold.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-peaches-fold.md diff --git a/.changeset/lovely-peaches-fold.md b/.changeset/lovely-peaches-fold.md new file mode 100644 index 0000000000..729a8c733a --- /dev/null +++ b/.changeset/lovely-peaches-fold.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-tech-insights': minor +--- + +making available the search for the last FACTS executed From a616c11d7880934f7a3279dd1ae64b215967fa86 Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Wed, 21 Sep 2022 09:16:12 +0100 Subject: [PATCH 03/25] addded luxon type dependency Signed-off-by: Alisson Fabiano --- plugins/tech-insights/package.json | 1 + yarn.lock | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index 06be8fd415..23c5fc0742 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -54,6 +54,7 @@ "@testing-library/jest-dom": "^5.10.1", "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", + "@types/luxon": "^3.0.1", "@types/node": "^16.11.26", "cross-fetch": "^3.1.5", "msw": "^0.47.0" diff --git a/yarn.lock b/yarn.lock index f0186e432e..116e774711 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6934,6 +6934,7 @@ __metadata: "@testing-library/jest-dom": ^5.10.1 "@testing-library/react": ^12.1.3 "@testing-library/user-event": ^14.0.0 + "@types/luxon": ^3.0.1 "@types/node": ^16.11.26 cross-fetch: ^3.1.5 luxon: ^3.0.3 @@ -14475,6 +14476,13 @@ __metadata: languageName: node linkType: hard +"@types/luxon@npm:^3.0.1": + version: 3.0.1 + resolution: "@types/luxon@npm:3.0.1" + checksum: a81444f9b474ea9b3063ab4cc68b917a2634e38b4e229f86c78c35023a32bf5e8d1044d7c229c011291662c976cb6c4cf109dc3d2077c571790a31779a554178 + languageName: node + linkType: hard + "@types/markdown-it@npm:^12.2.3": version: 12.2.3 resolution: "@types/markdown-it@npm:12.2.3" From 3e32883ad8b6155368d71e33188ca8cd371f5293 Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Wed, 21 Sep 2022 09:36:36 +0100 Subject: [PATCH 04/25] move from devDependencies to dependencies: @types/luxon Signed-off-by: Alisson Fabiano --- plugins/tech-insights/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index 23c5fc0742..3903881daa 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -38,6 +38,7 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", + "@types/luxon": "^3.0.1", "luxon": "^3.0.3", "react-use": "^17.2.4" }, @@ -54,7 +55,6 @@ "@testing-library/jest-dom": "^5.10.1", "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", - "@types/luxon": "^3.0.1", "@types/node": "^16.11.26", "cross-fetch": "^3.1.5", "msw": "^0.47.0" From b102cdbfc6f15938f45c22167a9026537b87d67f Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Thu, 22 Sep 2022 15:07:48 +0100 Subject: [PATCH 05/25] refactoring some codes, names and dependency Signed-off-by: Alisson Fabiano --- plugins/tech-insights/api-report.md | 26 ++---------- plugins/tech-insights/package.json | 3 +- .../tech-insights/src/api/TechInsightsApi.ts | 7 +--- .../src/api/TechInsightsClient.ts | 41 ++++++++++--------- plugins/tech-insights/src/api/types.ts | 16 +------- plugins/tech-insights/src/index.ts | 2 +- yarn.lock | 26 +++++------- 7 files changed, 42 insertions(+), 79 deletions(-) diff --git a/plugins/tech-insights/api-report.md b/plugins/tech-insights/api-report.md index b40bf9fe92..2d25d6d39d 100644 --- a/plugins/tech-insights/api-report.md +++ b/plugins/tech-insights/api-report.md @@ -10,7 +10,6 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { BulkCheckResponse } from '@backstage/plugin-tech-insights-common'; import { CheckResult } from '@backstage/plugin-tech-insights-common'; import { CompoundEntityRef } from '@backstage/catalog-model'; -import { DateTime } from 'luxon'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { IdentityApi } from '@backstage/core-plugin-api'; import { JsonValue } from '@backstage/types'; @@ -54,23 +53,12 @@ export const EntityTechInsightsScorecardContent: (props: { }) => JSX.Element; // @public -export interface InsightFact { +export interface InsightFacts { // (undocumented) [factId: string]: { timestamp: string; version: string; - facts: Record< - string, - | number - | string - | boolean - | DateTime - | number[] - | string[] - | boolean[] - | DateTime[] - | JsonValue - >; + facts: Record; }; } @@ -84,10 +72,7 @@ export interface TechInsightsApi { // (undocumented) getCheckResultRenderers: (types: string[]) => CheckResultRenderer[]; // (undocumented) - getLatestFacts( - entity: CompoundEntityRef, - facts: string[], - ): Promise; + getFacts(entity: CompoundEntityRef, facts: string[]): Promise; // (undocumented) runBulkChecks( entities: CompoundEntityRef[], @@ -115,10 +100,7 @@ export class TechInsightsClient implements TechInsightsApi { // (undocumented) getCheckResultRenderers(types: string[]): CheckResultRenderer[]; // (undocumented) - getLatestFacts( - entity: CompoundEntityRef, - facts: string[], - ): Promise; + getFacts(entity: CompoundEntityRef, facts: string[]): Promise; // (undocumented) runBulkChecks( entities: CompoundEntityRef[], diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index 3903881daa..7d1d091095 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -38,8 +38,7 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", - "@types/luxon": "^3.0.1", - "luxon": "^3.0.3", + "qs": "^6.11.0", "react-use": "^17.2.4" }, "peerDependencies": { diff --git a/plugins/tech-insights/src/api/TechInsightsApi.ts b/plugins/tech-insights/src/api/TechInsightsApi.ts index 79754d53b1..166f1d2782 100644 --- a/plugins/tech-insights/src/api/TechInsightsApi.ts +++ b/plugins/tech-insights/src/api/TechInsightsApi.ts @@ -19,7 +19,7 @@ import { CheckResult, BulkCheckResponse, } from '@backstage/plugin-tech-insights-common'; -import { Check, InsightFact } from './types'; +import { Check, InsightFacts } from './types'; import { CheckResultRenderer } from '../components/CheckResultRenderer'; import { CompoundEntityRef } from '@backstage/catalog-model'; @@ -48,8 +48,5 @@ export interface TechInsightsApi { entities: CompoundEntityRef[], checks?: Check[], ): Promise; - getLatestFacts( - entity: CompoundEntityRef, - facts: string[], - ): Promise; + getFacts(entity: CompoundEntityRef, facts: string[]): Promise; } diff --git a/plugins/tech-insights/src/api/TechInsightsClient.ts b/plugins/tech-insights/src/api/TechInsightsClient.ts index bcfb045d00..9bdeb119f9 100644 --- a/plugins/tech-insights/src/api/TechInsightsClient.ts +++ b/plugins/tech-insights/src/api/TechInsightsClient.ts @@ -19,15 +19,19 @@ import { BulkCheckResponse, CheckResult, } from '@backstage/plugin-tech-insights-common'; -import { Check, InsightFact } from './types'; +import { Check, InsightFacts } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; import { ResponseError } from '@backstage/errors'; -import { CompoundEntityRef } from '@backstage/catalog-model'; +import { + CompoundEntityRef, + stringifyEntityRef, +} from '@backstage/catalog-model'; import { CheckResultRenderer, jsonRulesEngineCheckResultRenderer, } from '../components/CheckResultRenderer'; +import qs from 'qs'; /** @public */ export class TechInsightsClient implements TechInsightsApi { @@ -45,18 +49,15 @@ export class TechInsightsClient implements TechInsightsApi { this.renderers = options.renderers; } - async getLatestFacts( + async getFacts( entity: CompoundEntityRef, facts: string[], - ): Promise { - const { namespace, kind, name } = entity; - const entityQuery = `entity=${encodeURIComponent( - kind.toLocaleLowerCase('en-US'), - )}:${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`; - const idsQuery = facts.map(id => `ids[]=${id}`).join('&'); - return await this.api( - `/facts/latest?${entityQuery}&${idsQuery}`, - ); + ): Promise { + const query = qs.stringify({ + entity: stringifyEntityRef(entity), + ids: facts, + }); + return await this.api(`/facts/latest?${query}`); } getCheckResultRenderers(types: string[]): CheckResultRenderer[] { @@ -104,13 +105,15 @@ export class TechInsightsClient implements TechInsightsApi { const url = await this.discoveryApi.getBaseUrl('tech-insights'); const { token } = await this.identityApi.getCredentials(); - return fetch(`${url}${path}`, { - ...init, - headers: { - 'Content-Type': 'application/json', - ...(token && { Authorization: `Bearer ${token}` }), - }, - }).then(async response => { + const request = new Request(`${url}${path}`, init); + if (!request.headers.has('content-type')) { + request.headers.set('content-type', 'application/json'); + } + if (token && !request.headers.has('authorization')) { + request.headers.set('authorization', `Bearer ${token}`); + } + + return fetch(request).then(async response => { if (!response.ok) { throw await ResponseError.fromResponse(response); } diff --git a/plugins/tech-insights/src/api/types.ts b/plugins/tech-insights/src/api/types.ts index b69d4d6264..ac1f2e44ee 100644 --- a/plugins/tech-insights/src/api/types.ts +++ b/plugins/tech-insights/src/api/types.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { DateTime } from 'luxon'; import { JsonValue } from '@backstage/types'; /** @@ -35,21 +34,10 @@ export type Check = { * * @public */ -export interface InsightFact { +export interface InsightFacts { [factId: string]: { timestamp: string; version: string; - facts: Record< - string, - | number - | string - | boolean - | DateTime - | number[] - | string[] - | boolean[] - | DateTime[] - | JsonValue - >; + facts: Record; }; } diff --git a/plugins/tech-insights/src/index.ts b/plugins/tech-insights/src/index.ts index ae2f9d53a7..9e075df038 100644 --- a/plugins/tech-insights/src/index.ts +++ b/plugins/tech-insights/src/index.ts @@ -20,7 +20,7 @@ export { } from './plugin'; export { techInsightsApiRef, TechInsightsClient } from './api'; -export type { TechInsightsApi, Check, InsightFact } from './api'; +export type { TechInsightsApi, Check, InsightFacts } from './api'; export { BooleanCheck } from './components/BooleanCheck'; export { jsonRulesEngineCheckResultRenderer } from './components/CheckResultRenderer'; export type { CheckResultRenderer } from './components/CheckResultRenderer'; diff --git a/yarn.lock b/yarn.lock index 116e774711..03e3a36d0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6934,11 +6934,10 @@ __metadata: "@testing-library/jest-dom": ^5.10.1 "@testing-library/react": ^12.1.3 "@testing-library/user-event": ^14.0.0 - "@types/luxon": ^3.0.1 "@types/node": ^16.11.26 cross-fetch: ^3.1.5 - luxon: ^3.0.3 msw: ^0.47.0 + qs: ^6.11.0 react-use: ^17.2.4 peerDependencies: "@types/react": ^16.13.1 || ^17.0.0 @@ -14476,13 +14475,6 @@ __metadata: languageName: node linkType: hard -"@types/luxon@npm:^3.0.1": - version: 3.0.1 - resolution: "@types/luxon@npm:3.0.1" - checksum: a81444f9b474ea9b3063ab4cc68b917a2634e38b4e229f86c78c35023a32bf5e8d1044d7c229c011291662c976cb6c4cf109dc3d2077c571790a31779a554178 - languageName: node - linkType: hard - "@types/markdown-it@npm:^12.2.3": version: 12.2.3 resolution: "@types/markdown-it@npm:12.2.3" @@ -29349,13 +29341,6 @@ __metadata: languageName: node linkType: hard -"luxon@npm:^3.0.3": - version: 3.0.3 - resolution: "luxon@npm:3.0.3" - checksum: 67d143f102f520761c4202086579a5cf30b230ea299da27cacb31e9f9d372cadef90f14cbe7e2621b70825b267fe00128b8176ed8b7172b48f77a403a662d5aa - languageName: node - linkType: hard - "lz-string@npm:^1.4.4": version: 1.4.4 resolution: "lz-string@npm:1.4.4" @@ -34244,6 +34229,15 @@ __metadata: languageName: node linkType: hard +"qs@npm:^6.11.0": + version: 6.11.0 + resolution: "qs@npm:6.11.0" + dependencies: + side-channel: ^1.0.4 + checksum: 6e1f29dd5385f7488ec74ac7b6c92f4d09a90408882d0c208414a34dd33badc1a621019d4c799a3df15ab9b1d0292f97c1dd71dc7c045e69f81a8064e5af7297 + languageName: node + linkType: hard + "qs@npm:~6.5.2": version: 6.5.2 resolution: "qs@npm:6.5.2" From d589951d9cca05363fbab938bf2bad1eaa9cf150 Mon Sep 17 00:00:00 2001 From: Alisson Fabiano Date: Fri, 23 Sep 2022 09:35:34 +0100 Subject: [PATCH 06/25] chore: bump version as patch Signed-off-by: Alisson Fabiano --- .changeset/lovely-peaches-fold.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lovely-peaches-fold.md b/.changeset/lovely-peaches-fold.md index 729a8c733a..dcff35f4d7 100644 --- a/.changeset/lovely-peaches-fold.md +++ b/.changeset/lovely-peaches-fold.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-tech-insights': minor +'@backstage/plugin-tech-insights': patch --- making available the search for the last FACTS executed From 6ab850318de7b92a3fc77c88520883f6b9836fad Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Fri, 16 Sep 2022 13:17:54 -0400 Subject: [PATCH 07/25] Location url was incorrect Signed-off-by: Taras --- packages/catalog-client/src/CatalogClient.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/catalog-client/src/CatalogClient.test.ts b/packages/catalog-client/src/CatalogClient.test.ts index 6c9c68efa2..5a344f49a3 100644 --- a/packages/catalog-client/src/CatalogClient.test.ts +++ b/packages/catalog-client/src/CatalogClient.test.ts @@ -322,7 +322,7 @@ describe('CatalogClient', () => { name: '', }, }, - 'http://example.com', + 'url:http://example.com', ), ).toMatchObject({ valid: false, @@ -350,7 +350,7 @@ describe('CatalogClient', () => { name: 'good', }, }, - 'http://example.com', + 'url:http://example.com', ), ).toMatchObject({ valid: true, @@ -373,7 +373,7 @@ describe('CatalogClient', () => { name: 'good', }, }, - 'http://example.com', + 'url:http://example.com', ), ).rejects.toThrow(/Request failed with 500 Error/); }); From 312e61a45141ccc7fc24ebebe5d34cc400feed53 Mon Sep 17 00:00:00 2001 From: Taras Date: Fri, 23 Sep 2022 10:51:08 -0400 Subject: [PATCH 08/25] Rename location to locationRef Signed-off-by: Taras --- packages/catalog-client/api-report.md | 4 ++-- packages/catalog-client/src/CatalogClient.ts | 4 ++-- packages/catalog-client/src/types/api.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/catalog-client/api-report.md b/packages/catalog-client/api-report.md index 0ad77ce39c..85fc389af7 100644 --- a/packages/catalog-client/api-report.md +++ b/packages/catalog-client/api-report.md @@ -68,7 +68,7 @@ export interface CatalogApi { ): Promise; validateEntity( entity: Entity, - location: string, + locationRef: string, options?: CatalogRequestOptions, ): Promise; } @@ -130,7 +130,7 @@ export class CatalogClient implements CatalogApi { ): Promise; validateEntity( entity: Entity, - location: string, + locationRef: string, options?: CatalogRequestOptions, ): Promise; } diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index f2b4186bfb..d67392d80d 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -359,7 +359,7 @@ export class CatalogClient implements CatalogApi { */ async validateEntity( entity: Entity, - location: string, + locationRef: string, options?: CatalogRequestOptions, ): Promise { const response = await this.fetchApi.fetch( @@ -370,7 +370,7 @@ export class CatalogClient implements CatalogApi { ...(options?.token && { Authorization: `Bearer ${options?.token}` }), }, method: 'POST', - body: JSON.stringify({ entity, location }), + body: JSON.stringify({ entity, location: locationRef }), }, ); diff --git a/packages/catalog-client/src/types/api.ts b/packages/catalog-client/src/types/api.ts index f483c3454c..d3d02022f3 100644 --- a/packages/catalog-client/src/types/api.ts +++ b/packages/catalog-client/src/types/api.ts @@ -405,11 +405,11 @@ export interface CatalogApi { * Validate entity and its location. * * @param entity - Entity to validate - * @param location - URL location of the entity + * @param locationRef - Location ref in format `url:http://example.com/file` */ validateEntity( entity: Entity, - location: string, + locationRef: string, options?: CatalogRequestOptions, ): Promise; } From 4f2ac624b4a69cab1097a0933cd2e7ab1bdc65bc Mon Sep 17 00:00:00 2001 From: Taras Date: Fri, 23 Sep 2022 10:59:20 -0400 Subject: [PATCH 09/25] Added changeset for renamed argument Signed-off-by: Taras --- .changeset/plenty-kids-fetch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/plenty-kids-fetch.md diff --git a/.changeset/plenty-kids-fetch.md b/.changeset/plenty-kids-fetch.md new file mode 100644 index 0000000000..6a31b4db20 --- /dev/null +++ b/.changeset/plenty-kids-fetch.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-client': patch +--- + +Renamed argument in `validateEntity` from `location` to `locationRef` From 719ccbb963f437020350f72a4e835b5aadec9724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 27 Sep 2022 12:06:24 +0200 Subject: [PATCH 10/25] filter ownership by references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/old-needles-brake.md | 6 ++++++ .../src/hooks/useEntityGitHubRepositories.ts | 11 ++++------- .../src/hooks/useUserRepositories.tsx | 12 ++++-------- 3 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 .changeset/old-needles-brake.md diff --git a/.changeset/old-needles-brake.md b/.changeset/old-needles-brake.md new file mode 100644 index 0000000000..eea2bf6539 --- /dev/null +++ b/.changeset/old-needles-brake.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-github-issues': patch +'@backstage/plugin-github-pull-requests-board': patch +--- + +Properly filter on relations instead of the spec, when finding by owner diff --git a/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts b/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts index 242de514ca..d7b60575ad 100644 --- a/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts +++ b/plugins/github-issues/src/hooks/useEntityGitHubRepositories.ts @@ -13,13 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Entity } from '@backstage/catalog-model'; + +import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; -import { - catalogApiRef, - humanizeEntityRef, - useEntity, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react'; import { useCallback, useEffect, useState } from 'react'; const GITHUB_PROJECT_SLUG_ANNOTATION = 'github.com/project-slug'; @@ -48,7 +45,7 @@ export function useEntityGitHubRepositories() { const entitiesList = await catalogApi.getEntities({ filter: { kind: ['Component', 'API'], - 'spec.owner': humanizeEntityRef(entity, { defaultKind: 'group' }), + 'relations.ownedBy': stringifyEntityRef(entity), }, }); diff --git a/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx b/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx index b905811aea..ed0d3580f0 100644 --- a/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx +++ b/plugins/github-pull-requests-board/src/hooks/useUserRepositories.tsx @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import { stringifyEntityRef } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; -import { - catalogApiRef, - humanizeEntityRef, - useEntity, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, useEntity } from '@backstage/plugin-catalog-react'; import { useCallback, useEffect, useState } from 'react'; import { getProjectNameFromEntity } from '../utils/functions'; @@ -29,9 +27,7 @@ export function useUserRepositories() { const getRepositoriesNames = useCallback(async () => { const entitiesList = await catalogApi.getEntities({ - filter: { - 'spec.owner': humanizeEntityRef(teamEntity, { defaultKind: 'group' }), - }, + filter: { 'relations.ownedBy': stringifyEntityRef(teamEntity) }, }); const entitiesNames: string[] = entitiesList.items.map(componentEntity => From 2cd4b2e55862d9a6ab411ec8ac598511ce5e7a6c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:15:25 +0000 Subject: [PATCH 11/25] Update dependency @swc/core to v1.3.3 Signed-off-by: Renovate Bot --- storybook/yarn.lock | 110 ++++++++++++++++++++++---------------------- yarn.lock | 110 ++++++++++++++++++++++---------------------- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/storybook/yarn.lock b/storybook/yarn.lock index 4a5d57c5b2..1597d0728c 100644 --- a/storybook/yarn.lock +++ b/storybook/yarn.lock @@ -2977,126 +2977,126 @@ __metadata: languageName: node linkType: hard -"@swc/core-android-arm-eabi@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-android-arm-eabi@npm:1.3.2" +"@swc/core-android-arm-eabi@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-android-arm-eabi@npm:1.3.3" dependencies: "@swc/wasm": 1.2.122 conditions: os=android & cpu=arm languageName: node linkType: hard -"@swc/core-android-arm64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-android-arm64@npm:1.3.2" +"@swc/core-android-arm64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-android-arm64@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-darwin-arm64@npm:1.3.2" +"@swc/core-darwin-arm64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-darwin-arm64@npm:1.3.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-darwin-x64@npm:1.3.2" +"@swc/core-darwin-x64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-darwin-x64@npm:1.3.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-freebsd-x64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-freebsd-x64@npm:1.3.2" +"@swc/core-freebsd-x64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-freebsd-x64@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.2" +"@swc/core-linux-arm-gnueabihf@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm64-gnu@npm:1.3.2" +"@swc/core-linux-arm64-gnu@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm64-gnu@npm:1.3.3" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm64-musl@npm:1.3.2" +"@swc/core-linux-arm64-musl@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm64-musl@npm:1.3.3" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-x64-gnu@npm:1.3.2" +"@swc/core-linux-x64-gnu@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-x64-gnu@npm:1.3.3" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-x64-musl@npm:1.3.2" +"@swc/core-linux-x64-musl@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-x64-musl@npm:1.3.3" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-arm64-msvc@npm:1.3.2" +"@swc/core-win32-arm64-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-arm64-msvc@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-ia32-msvc@npm:1.3.2" +"@swc/core-win32-ia32-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-ia32-msvc@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-x64-msvc@npm:1.3.2" +"@swc/core-win32-x64-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-x64-msvc@npm:1.3.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard "@swc/core@npm:^1.2.239": - version: 1.3.2 - resolution: "@swc/core@npm:1.3.2" + version: 1.3.3 + resolution: "@swc/core@npm:1.3.3" dependencies: - "@swc/core-android-arm-eabi": 1.3.2 - "@swc/core-android-arm64": 1.3.2 - "@swc/core-darwin-arm64": 1.3.2 - "@swc/core-darwin-x64": 1.3.2 - "@swc/core-freebsd-x64": 1.3.2 - "@swc/core-linux-arm-gnueabihf": 1.3.2 - "@swc/core-linux-arm64-gnu": 1.3.2 - "@swc/core-linux-arm64-musl": 1.3.2 - "@swc/core-linux-x64-gnu": 1.3.2 - "@swc/core-linux-x64-musl": 1.3.2 - "@swc/core-win32-arm64-msvc": 1.3.2 - "@swc/core-win32-ia32-msvc": 1.3.2 - "@swc/core-win32-x64-msvc": 1.3.2 + "@swc/core-android-arm-eabi": 1.3.3 + "@swc/core-android-arm64": 1.3.3 + "@swc/core-darwin-arm64": 1.3.3 + "@swc/core-darwin-x64": 1.3.3 + "@swc/core-freebsd-x64": 1.3.3 + "@swc/core-linux-arm-gnueabihf": 1.3.3 + "@swc/core-linux-arm64-gnu": 1.3.3 + "@swc/core-linux-arm64-musl": 1.3.3 + "@swc/core-linux-x64-gnu": 1.3.3 + "@swc/core-linux-x64-musl": 1.3.3 + "@swc/core-win32-arm64-msvc": 1.3.3 + "@swc/core-win32-ia32-msvc": 1.3.3 + "@swc/core-win32-x64-msvc": 1.3.3 dependenciesMeta: "@swc/core-android-arm-eabi": optional: true @@ -3126,7 +3126,7 @@ __metadata: optional: true bin: swcx: run_swcx.js - checksum: c2c83d0e6b4c56d65fb3723aa0be5e777823a6efe5b12702d4d44827a6c6dd8fac3c5dec7ff45222c7b22b4084bffc846f8497d697e61a1706817977256a65dc + checksum: bead8463cd7c11e2cd87d3835045e4a245e755409e912a40c575026a0475cc0010fa6ef48936ea5f7e62c84cdc63c21a83d61755813f2ba9b565d397fad7c5f5 languageName: node linkType: hard diff --git a/yarn.lock b/yarn.lock index ab32864850..39c676a57e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12184,126 +12184,126 @@ __metadata: languageName: node linkType: hard -"@swc/core-android-arm-eabi@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-android-arm-eabi@npm:1.3.2" +"@swc/core-android-arm-eabi@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-android-arm-eabi@npm:1.3.3" dependencies: "@swc/wasm": 1.2.122 conditions: os=android & cpu=arm languageName: node linkType: hard -"@swc/core-android-arm64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-android-arm64@npm:1.3.2" +"@swc/core-android-arm64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-android-arm64@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-darwin-arm64@npm:1.3.2" +"@swc/core-darwin-arm64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-darwin-arm64@npm:1.3.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-darwin-x64@npm:1.3.2" +"@swc/core-darwin-x64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-darwin-x64@npm:1.3.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-freebsd-x64@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-freebsd-x64@npm:1.3.2" +"@swc/core-freebsd-x64@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-freebsd-x64@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.2" +"@swc/core-linux-arm-gnueabihf@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm64-gnu@npm:1.3.2" +"@swc/core-linux-arm64-gnu@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm64-gnu@npm:1.3.3" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-arm64-musl@npm:1.3.2" +"@swc/core-linux-arm64-musl@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-arm64-musl@npm:1.3.3" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-x64-gnu@npm:1.3.2" +"@swc/core-linux-x64-gnu@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-x64-gnu@npm:1.3.3" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-linux-x64-musl@npm:1.3.2" +"@swc/core-linux-x64-musl@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-linux-x64-musl@npm:1.3.3" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-arm64-msvc@npm:1.3.2" +"@swc/core-win32-arm64-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-arm64-msvc@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-ia32-msvc@npm:1.3.2" +"@swc/core-win32-ia32-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-ia32-msvc@npm:1.3.3" dependencies: "@swc/wasm": 1.2.130 conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.3.2": - version: 1.3.2 - resolution: "@swc/core-win32-x64-msvc@npm:1.3.2" +"@swc/core-win32-x64-msvc@npm:1.3.3": + version: 1.3.3 + resolution: "@swc/core-win32-x64-msvc@npm:1.3.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard "@swc/core@npm:^1.2.239": - version: 1.3.2 - resolution: "@swc/core@npm:1.3.2" + version: 1.3.3 + resolution: "@swc/core@npm:1.3.3" dependencies: - "@swc/core-android-arm-eabi": 1.3.2 - "@swc/core-android-arm64": 1.3.2 - "@swc/core-darwin-arm64": 1.3.2 - "@swc/core-darwin-x64": 1.3.2 - "@swc/core-freebsd-x64": 1.3.2 - "@swc/core-linux-arm-gnueabihf": 1.3.2 - "@swc/core-linux-arm64-gnu": 1.3.2 - "@swc/core-linux-arm64-musl": 1.3.2 - "@swc/core-linux-x64-gnu": 1.3.2 - "@swc/core-linux-x64-musl": 1.3.2 - "@swc/core-win32-arm64-msvc": 1.3.2 - "@swc/core-win32-ia32-msvc": 1.3.2 - "@swc/core-win32-x64-msvc": 1.3.2 + "@swc/core-android-arm-eabi": 1.3.3 + "@swc/core-android-arm64": 1.3.3 + "@swc/core-darwin-arm64": 1.3.3 + "@swc/core-darwin-x64": 1.3.3 + "@swc/core-freebsd-x64": 1.3.3 + "@swc/core-linux-arm-gnueabihf": 1.3.3 + "@swc/core-linux-arm64-gnu": 1.3.3 + "@swc/core-linux-arm64-musl": 1.3.3 + "@swc/core-linux-x64-gnu": 1.3.3 + "@swc/core-linux-x64-musl": 1.3.3 + "@swc/core-win32-arm64-msvc": 1.3.3 + "@swc/core-win32-ia32-msvc": 1.3.3 + "@swc/core-win32-x64-msvc": 1.3.3 dependenciesMeta: "@swc/core-android-arm-eabi": optional: true @@ -12333,7 +12333,7 @@ __metadata: optional: true bin: swcx: run_swcx.js - checksum: c2c83d0e6b4c56d65fb3723aa0be5e777823a6efe5b12702d4d44827a6c6dd8fac3c5dec7ff45222c7b22b4084bffc846f8497d697e61a1706817977256a65dc + checksum: bead8463cd7c11e2cd87d3835045e4a245e755409e912a40c575026a0475cc0010fa6ef48936ea5f7e62c84cdc63c21a83d61755813f2ba9b565d397fad7c5f5 languageName: node linkType: hard From f469ecc5cc6a0c696b3dfe5fbe2c02dcd6ba8a34 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:25:36 +0000 Subject: [PATCH 12/25] Update dependency graphql-ws to v5.11.2 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ab32864850..20bd90d06c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23685,11 +23685,11 @@ __metadata: linkType: hard "graphql-ws@npm:^5.4.1, graphql-ws@npm:^5.9.0": - version: 5.10.1 - resolution: "graphql-ws@npm:5.10.1" + version: 5.11.2 + resolution: "graphql-ws@npm:5.11.2" peerDependencies: graphql: ">=0.11 <=16" - checksum: ad8eb8a6823a32a7bd9bc6ec73a0b244f503e50318ef5db1312f1d09c5f0b0e4505ad75b08f06e4c40c6935cf5170444b19347b7b83222b4e1af01401418cb91 + checksum: 2c94b06c1919217dc15a0556474673de7aabcc7179a2982a87ded51856c105e4f4ee6d54a6c135a0a7f55d85a5997a6a15cff514959258885814adec6a61ff00 languageName: node linkType: hard From 9a5726a48d1f44feb4b7cc4fd8f518f190459ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 27 Sep 2022 15:51:31 +0200 Subject: [PATCH 13/25] nerfed qs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/tech-insights/package.json | 2 +- yarn.lock | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/tech-insights/package.json b/plugins/tech-insights/package.json index 7d1d091095..89d19cc248 100644 --- a/plugins/tech-insights/package.json +++ b/plugins/tech-insights/package.json @@ -38,7 +38,7 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", - "qs": "^6.11.0", + "qs": "^6.9.4", "react-use": "^17.2.4" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 03e3a36d0b..0cdb5f55f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6937,7 +6937,7 @@ __metadata: "@types/node": ^16.11.26 cross-fetch: ^3.1.5 msw: ^0.47.0 - qs: ^6.11.0 + qs: ^6.9.4 react-use: ^17.2.4 peerDependencies: "@types/react": ^16.13.1 || ^17.0.0 @@ -34229,15 +34229,6 @@ __metadata: languageName: node linkType: hard -"qs@npm:^6.11.0": - version: 6.11.0 - resolution: "qs@npm:6.11.0" - dependencies: - side-channel: ^1.0.4 - checksum: 6e1f29dd5385f7488ec74ac7b6c92f4d09a90408882d0c208414a34dd33badc1a621019d4c799a3df15ab9b1d0292f97c1dd71dc7c045e69f81a8064e5af7297 - languageName: node - linkType: hard - "qs@npm:~6.5.2": version: 6.5.2 resolution: "qs@npm:6.5.2" From 6e05d57fdf3fcb92a8b6aac2ae63c81f7a11c554 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 27 Sep 2022 14:04:44 +0000 Subject: [PATCH 14/25] chore(deps): update dependency @types/tar to v6.1.3 Signed-off-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7776d00e77..57a331f80f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14598,12 +14598,12 @@ __metadata: linkType: hard "@types/tar@npm:^6.1.1": - version: 6.1.2 - resolution: "@types/tar@npm:6.1.2" + version: 6.1.3 + resolution: "@types/tar@npm:6.1.3" dependencies: "@types/node": "*" minipass: ^3.3.5 - checksum: 57e625e2db29e3b9c6d8d06774758cf6e4caa2096f4144f7c0fdb2760e1150146d2a86f0eb80b4d2e1ba0ecf07f06303775054c4f4d22bea5d51e8b54cdd0fd8 + checksum: 3a221f74adfcef8555b9c4cc951907dfd567630744ffe5211da1b44caf2a4c3b02297b73c9fb02d171e93a7a7c74fb15c1826e3f0438f0e5e8f4c790db59ddcf languageName: node linkType: hard From 174f02a00a0678f8645bbbdcdc9082ed245c3329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 27 Sep 2022 17:10:43 +0200 Subject: [PATCH 15/25] fix installation instructions for user-settings that were stale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/loud-dots-sit.md | 5 +++++ plugins/user-settings/README.md | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/loud-dots-sit.md diff --git a/.changeset/loud-dots-sit.md b/.changeset/loud-dots-sit.md new file mode 100644 index 0000000000..fa6175358e --- /dev/null +++ b/.changeset/loud-dots-sit.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-user-settings': patch +--- + +Update installation instructions diff --git a/plugins/user-settings/README.md b/plugins/user-settings/README.md index abe66120fe..b240c2bbd3 100644 --- a/plugins/user-settings/README.md +++ b/plugins/user-settings/README.md @@ -29,11 +29,11 @@ import { Settings as SidebarSettings } from '@backstage/plugin-user-settings'; Add the page to the App routing: ```ts -import { Router as SettingsRouter } from '@backstage/plugin-user-settings'; +import { UserSettingsPage } from '@backstage/plugin-user-settings'; const AppRoutes = () => ( - } /> + }> ); ``` From f7cbfb97edd8ea5d01961a538b36aa585869cb98 Mon Sep 17 00:00:00 2001 From: Jussi Hallila Date: Wed, 28 Sep 2022 11:17:55 +0200 Subject: [PATCH 16/25] Modify router endpoint to handle singular and collections of request params similarly. Signed-off-by: Jussi Hallila --- .changeset/twelve-melons-notice.md | 5 + .../src/service/router.test.ts | 129 +++++++++++------- .../src/service/router.ts | 19 ++- 3 files changed, 104 insertions(+), 49 deletions(-) create mode 100644 .changeset/twelve-melons-notice.md diff --git a/.changeset/twelve-melons-notice.md b/.changeset/twelve-melons-notice.md new file mode 100644 index 0000000000..621d6325a7 --- /dev/null +++ b/.changeset/twelve-melons-notice.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-tech-insights-backend': patch +--- + +Modify router endpoint to handle singular and collections of request params similarly. diff --git a/plugins/tech-insights-backend/src/service/router.test.ts b/plugins/tech-insights-backend/src/service/router.test.ts index 8513973598..6935338a56 100644 --- a/plugins/tech-insights-backend/src/service/router.test.ts +++ b/plugins/tech-insights-backend/src/service/router.test.ts @@ -87,59 +87,94 @@ describe('Tech Insights router tests', () => { app = express().use(router); }); - - it('should be able to retrieve latest schemas', async () => { - await request(app).get('/fact-schemas').expect(200); - expect(latestSchemasMock).toHaveBeenCalled(); + describe('/fact-schemas', () => { + it('should be able to retrieve latest schemas', async () => { + await request(app).get('/fact-schemas').expect(200); + expect(latestSchemasMock).toHaveBeenCalled(); + }); }); - it('should not contain check endpoints when checker not present', async () => { - await request(app).get('/checks').expect(404); - await request(app).post('/checks/a/a/a').expect(404); + describe('/checks', () => { + it('should not contain check endpoints when checker not present', async () => { + await request(app).get('/checks').expect(404); + await request(app).post('/checks/a/a/a').expect(404); + }); }); - it('should be able to parse id request params for fact retrieval', async () => { - await request(app) - .get('/facts/latest') - .query({ - entity: 'a:a/a', - ids: ['firstId', 'secondId'], - }) - .expect(200); - expect(latestFactsByIdsMock).toHaveBeenCalledWith( - ['firstId', 'secondId'], - 'a:a/a', - ); + describe('/facts/latest', () => { + it('should be able to parse id request params for fact retrieval', async () => { + await request(app) + .get('/facts/latest') + .query({ + entity: 'a:a/a', + ids: ['firstId', 'secondId'], + }) + .expect(200); + expect(latestFactsByIdsMock).toHaveBeenCalledWith( + ['firstId', 'secondId'], + 'a:a/a', + ); + }); + it('should handle singular ids in query params correctly', async () => { + await request(app) + .get('/facts/latest') + .query({ + entity: 'a:a/a', + ids: ['secondId'], + }) + .expect(200); + expect(latestFactsByIdsMock).toHaveBeenCalledWith(['secondId'], 'a:a/a'); + }); }); - it('should be able to parse datetime request params for fact retrieval', async () => { - await request(app) - .get('/facts/range') - .query({ - entity: 'a:a/a', - ids: ['firstId', 'secondId'], - startDatetime: '2021-12-12T12:12:12', - endDatetime: '2022-11-11T11:11:11', - }) - .expect(200); - expect(factsBetweenTimestampsByIdsMock).toHaveBeenCalledWith( - ['firstId', 'secondId'], - 'a:a/a', - DateTime.fromISO('2021-12-12T12:12:12.000+00:00'), - DateTime.fromISO('2022-11-11T11:11:11.000+00:00'), - ); - }); + describe('/facts/range', () => { + it('should be able to parse datetime request params for fact retrieval', async () => { + await request(app) + .get('/facts/range') + .query({ + entity: 'a:a/a', + ids: ['firstId', 'secondId'], + startDatetime: '2021-12-12T12:12:12', + endDatetime: '2022-11-11T11:11:11', + }) + .expect(200); + expect(factsBetweenTimestampsByIdsMock).toHaveBeenCalledWith( + ['firstId', 'secondId'], + 'a:a/a', + DateTime.fromISO('2021-12-12T12:12:12.000+00:00'), + DateTime.fromISO('2022-11-11T11:11:11.000+00:00'), + ); + }); - it('should respond gracefully on parsing errors', async () => { - await request(app) - .get('/facts/range') - .query({ - entity: 'a:a/a', - ids: ['firstId', 'secondId'], - startDatetime: '2021-12-1222T12:12:12', - endDatetime: '2022-1122-11T11:11:11', - }) - .expect(422); - expect(latestFactsByIdsMock).toHaveBeenCalledTimes(0); + it('should respond gracefully on parsing errors', async () => { + await request(app) + .get('/facts/range') + .query({ + entity: 'a:a/a', + ids: ['firstId', 'secondId'], + startDatetime: '2021-12-1222T12:12:12', + endDatetime: '2022-1122-11T11:11:11', + }) + .expect(422); + expect(latestFactsByIdsMock).toHaveBeenCalledTimes(0); + }); + + it('should handle singular ids in query params correctly', async () => { + await request(app) + .get('/facts/range') + .query({ + entity: 'a:a/a', + ids: ['firstId'], + startDatetime: '2021-12-12T12:12:12', + endDatetime: '2022-11-11T11:11:11', + }) + .expect(200); + expect(factsBetweenTimestampsByIdsMock).toHaveBeenCalledWith( + ['firstId'], + 'a:a/a', + DateTime.fromISO('2021-12-12T12:12:12.000+00:00'), + DateTime.fromISO('2022-11-11T11:11:11.000+00:00'), + ); + }); }); }); diff --git a/plugins/tech-insights-backend/src/service/router.ts b/plugins/tech-insights-backend/src/service/router.ts index 4b93bf4d60..a7f48bc3a2 100644 --- a/plugins/tech-insights-backend/src/service/router.ts +++ b/plugins/tech-insights-backend/src/service/router.ts @@ -132,7 +132,15 @@ export async function createRouter< router.get('/facts/latest', async (req, res) => { const { entity } = req.query; const { namespace, kind, name } = parseEntityRef(entity as string); - const ids = req.query.ids as string[]; + + if (!req.query.ids) { + return res + .status(422) + .send({ error: 'Failed to parse ids from request' }); + } + const ids = Array.isArray(req.query.ids) + ? (req.query.ids as string[]) + : ([req.query.ids] as string[]); return res.send( await techInsightsStore.getLatestFactsByIds( ids, @@ -148,7 +156,14 @@ export async function createRouter< const { entity } = req.query; const { namespace, kind, name } = parseEntityRef(entity as string); - const ids = req.query.ids as string[]; + if (!req.query.ids) { + return res + .status(422) + .send({ error: 'Failed to parse ids from request' }); + } + const ids = Array.isArray(req.query.ids) + ? (req.query.ids as string[]) + : ([req.query.ids] as string[]); const startDatetime = DateTime.fromISO(req.query.startDatetime as string); const endDatetime = DateTime.fromISO(req.query.endDatetime as string); if (!startDatetime.isValid || !endDatetime.isValid) { From 74d13e677dbf8cbe75d6bf1ac3d344e89ee87e28 Mon Sep 17 00:00:00 2001 From: Jussi Hallila Date: Wed, 28 Sep 2022 11:25:07 +0200 Subject: [PATCH 17/25] Fix changeset to read English instead of nerd English. Signed-off-by: Jussi Hallila --- .changeset/twelve-melons-notice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/twelve-melons-notice.md b/.changeset/twelve-melons-notice.md index 621d6325a7..4a91642426 100644 --- a/.changeset/twelve-melons-notice.md +++ b/.changeset/twelve-melons-notice.md @@ -2,4 +2,4 @@ '@backstage/plugin-tech-insights-backend': patch --- -Modify router endpoint to handle singular and collections of request params similarly. +Modify router endpoint to handle singular and collections of request parameters similarly. From 91d9311ce38656c21d601a5a3671bacce938895c Mon Sep 17 00:00:00 2001 From: Jussi Hallila Date: Wed, 28 Sep 2022 12:02:15 +0200 Subject: [PATCH 18/25] Change to a simple logic. Signed-off-by: Jussi Hallila --- plugins/tech-insights-backend/src/service/router.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/tech-insights-backend/src/service/router.ts b/plugins/tech-insights-backend/src/service/router.ts index a7f48bc3a2..0df7080db5 100644 --- a/plugins/tech-insights-backend/src/service/router.ts +++ b/plugins/tech-insights-backend/src/service/router.ts @@ -138,9 +138,7 @@ export async function createRouter< .status(422) .send({ error: 'Failed to parse ids from request' }); } - const ids = Array.isArray(req.query.ids) - ? (req.query.ids as string[]) - : ([req.query.ids] as string[]); + const ids = [req.query.ids].flat() as string[]; return res.send( await techInsightsStore.getLatestFactsByIds( ids, @@ -161,9 +159,7 @@ export async function createRouter< .status(422) .send({ error: 'Failed to parse ids from request' }); } - const ids = Array.isArray(req.query.ids) - ? (req.query.ids as string[]) - : ([req.query.ids] as string[]); + const ids = [req.query.ids].flat() as string[]; const startDatetime = DateTime.fromISO(req.query.startDatetime as string); const endDatetime = DateTime.fromISO(req.query.endDatetime as string); if (!startDatetime.isValid || !endDatetime.isValid) { From 3cf87c1d114e08fb1233d2466bfbf36e023f8565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 28 Sep 2022 12:03:43 +0200 Subject: [PATCH 19/25] forgot a slash ... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/user-settings/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/user-settings/README.md b/plugins/user-settings/README.md index b240c2bbd3..ce07d76257 100644 --- a/plugins/user-settings/README.md +++ b/plugins/user-settings/README.md @@ -33,7 +33,7 @@ import { UserSettingsPage } from '@backstage/plugin-user-settings'; const AppRoutes = () => ( - }> + } /> ); ``` From e4f0a96424999384730c83a794dedd7d8abbec4e Mon Sep 17 00:00:00 2001 From: NishkarshRaj Date: Wed, 28 Sep 2022 12:58:20 +0000 Subject: [PATCH 20/25] Making the GitLab repoUrl picker description clearer Signed-off-by: NishkarshRaj --- .changeset/brave-peaches-brush.md | 5 +++++ .../src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/brave-peaches-brush.md diff --git a/.changeset/brave-peaches-brush.md b/.changeset/brave-peaches-brush.md new file mode 100644 index 0000000000..9ed20031a9 --- /dev/null +++ b/.changeset/brave-peaches-brush.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Making the descrition of the GitLab repoUrl owner more clearer. diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx index c628b364b9..ebe9109431 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx @@ -66,8 +66,7 @@ export const GitlabRepoPicker = (props: { )} - The organization, groups, subgroups, user, project (also known as - namespaces in gitlab), that this repo will belong to + GitLab namespace where this repository will belong to. It can be the name of organization, group, subgroup, user, or the project. From 35b38d256a1487fdf647920544a6661f167b9d42 Mon Sep 17 00:00:00 2001 From: Nishkarsh Raj Date: Wed, 28 Sep 2022 14:13:14 +0100 Subject: [PATCH 21/25] Update brave-peaches-brush.md Signed-off-by: Nishkarsh Raj --- .changeset/brave-peaches-brush.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/brave-peaches-brush.md b/.changeset/brave-peaches-brush.md index 9ed20031a9..f0661ba818 100644 --- a/.changeset/brave-peaches-brush.md +++ b/.changeset/brave-peaches-brush.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': patch --- -Making the descrition of the GitLab repoUrl owner more clearer. +Making the description of the GitLab repoUrl owner field more clearer by focusing it refers to the GitLab namespace. From d02dc3375c3e23411e53fd69f68af6ec54f96616 Mon Sep 17 00:00:00 2001 From: Nishkarsh Raj Date: Wed, 28 Sep 2022 14:29:52 +0100 Subject: [PATCH 22/25] Prettier got angry :) Signed-off-by: Nishkarsh Raj --- .../src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx index ebe9109431..fbcc13c846 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx @@ -66,7 +66,8 @@ export const GitlabRepoPicker = (props: { )} - GitLab namespace where this repository will belong to. It can be the name of organization, group, subgroup, user, or the project. + GitLab namespace where this repository will belong to. It can be the + name of organization, group, subgroup, user, or the project. From 58528fb833b48448a9f8bd35e44bc967d0d841e2 Mon Sep 17 00:00:00 2001 From: Pedro Nastasi Date: Wed, 28 Sep 2022 11:15:05 -0300 Subject: [PATCH 23/25] Be less restrictive with unknown keys on query endpoint Signed-off-by: Pedro Nastasi --- .../search-backend/src/service/router.test.ts | 23 ++++++++++++++++++- plugins/search-backend/src/service/router.ts | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/plugins/search-backend/src/service/router.test.ts b/plugins/search-backend/src/service/router.test.ts index 1437e65b84..100dee9117 100644 --- a/plugins/search-backend/src/service/router.test.ts +++ b/plugins/search-backend/src/service/router.test.ts @@ -18,7 +18,9 @@ import { getVoidLogger } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { IndexBuilder } from '@backstage/plugin-search-backend-node'; -import { SearchEngine } from '@backstage/plugin-search-common'; +import { + SearchEngine, +} from '@backstage/plugin-search-common'; import express from 'express'; import request from 'supertest'; @@ -148,6 +150,25 @@ describe('createRouter', () => { }); }); + it('is less restrictive with unknown keys on query endpoint', async () => { + const queryString = + 'term=test&%5BdocType%5D%5B0%5D=Service&filters%5BdocType%5D%5B0%5D=filter1&unknownKey1%5B2%5D=unknownValue1&unknownKey1%5B3%5D=unknownValue2&unknownKey2=unknownValue1&pageCursor'; + const response = await request(app).get(`/query?${queryString}`); + const firstArg: Object = { + docType: ['Service'], + filters: { docType: ['filter1'] }, + pageCursor: '', + term: 'test', + unknownKey1: ['unknownValue1', 'unknownValue2'], + unknownKey2: 'unknownValue1', + }; + const secondArg = { + token: undefined, + }; + expect(response.status).toEqual(200); + expect(mockSearchEngine.query).toHaveBeenCalledWith(firstArg, secondArg); + }); + describe('search result filtering', () => { beforeAll(async () => { const logger = getVoidLogger(); diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index cf9abff675..87da80d8f5 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -133,7 +133,7 @@ export async function createRouter( req: express.Request, res: express.Response, ) => { - const parseResult = requestSchema.safeParse(req.query); + const parseResult = requestSchema.passthrough().safeParse(req.query); if (!parseResult.success) { throw new InputError(`Invalid query string: ${parseResult.error}`); From 16c853a6ed4092ccb628090daf0987385a3b478c Mon Sep 17 00:00:00 2001 From: Pedro Nastasi Date: Wed, 28 Sep 2022 11:16:41 -0300 Subject: [PATCH 24/25] changeset Signed-off-by: Pedro Nastasi --- .changeset/mean-spiders-design.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/mean-spiders-design.md diff --git a/.changeset/mean-spiders-design.md b/.changeset/mean-spiders-design.md new file mode 100644 index 0000000000..3704c9fca9 --- /dev/null +++ b/.changeset/mean-spiders-design.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend': minor +--- + +Be less restrictive with unknown keys on query endpoint From 65c8a72b5481c2f49a000be5c3cbb2625f996358 Mon Sep 17 00:00:00 2001 From: Pedro Nastasi Date: Wed, 28 Sep 2022 11:43:39 -0300 Subject: [PATCH 25/25] bugfix: prettier Signed-off-by: Pedro Nastasi --- plugins/search-backend/src/service/router.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/search-backend/src/service/router.test.ts b/plugins/search-backend/src/service/router.test.ts index 100dee9117..f26f191ecd 100644 --- a/plugins/search-backend/src/service/router.test.ts +++ b/plugins/search-backend/src/service/router.test.ts @@ -18,9 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { IndexBuilder } from '@backstage/plugin-search-backend-node'; -import { - SearchEngine, -} from '@backstage/plugin-search-common'; +import { SearchEngine } from '@backstage/plugin-search-common'; import express from 'express'; import request from 'supertest';