diff --git a/.changeset/polite-melons-clap.md b/.changeset/polite-melons-clap.md new file mode 100644 index 0000000000..a4356f8d21 --- /dev/null +++ b/.changeset/polite-melons-clap.md @@ -0,0 +1,15 @@ +--- +'@backstage/plugin-catalog-backend': minor +--- + +**BREAKING**: Removed the export of the `RecursivePartial` utility type. If you relied on this type it can be redefined like this: + +```ts +type RecursivePartial = { + [P in keyof T]?: T[P] extends (infer U)[] + ? RecursivePartial[] + : T[P] extends object + ? RecursivePartial + : T[P]; +}; +``` diff --git a/.changeset/strong-tomatoes-kneel.md b/.changeset/strong-tomatoes-kneel.md new file mode 100644 index 0000000000..bdddb91ae2 --- /dev/null +++ b/.changeset/strong-tomatoes-kneel.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-ldap': patch +--- + +Updated to no longer rely on the `RecursivePartial` export from `@backstage/plugin-catalog-backend`. diff --git a/plugins/catalog-backend-module-ldap/src/ldap/config.ts b/plugins/catalog-backend-module-ldap/src/ldap/config.ts index f4d589974f..370c9491b3 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/config.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/config.ts @@ -18,8 +18,8 @@ import { Config } from '@backstage/config'; import { JsonValue } from '@backstage/types'; import { SearchOptions } from 'ldapjs'; import mergeWith from 'lodash/mergeWith'; -import { RecursivePartial } from '@backstage/plugin-catalog-backend'; import { trimEnd } from 'lodash'; +import { RecursivePartial } from './util'; /** * The configuration parameters for a single LDAP provider. diff --git a/plugins/catalog-backend-module-ldap/src/ldap/read.test.ts b/plugins/catalog-backend-module-ldap/src/ldap/read.test.ts index 875ffb7029..3ded4635a0 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/read.test.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/read.test.ts @@ -17,7 +17,6 @@ import { GroupEntity, UserEntity } from '@backstage/catalog-model'; import { SearchEntry } from 'ldapjs'; import merge from 'lodash/merge'; -import { RecursivePartial } from '@backstage/plugin-catalog-backend'; import { LdapClient } from './client'; import { GroupConfig, UserConfig } from './config'; import { @@ -32,6 +31,7 @@ import { readLdapUsers, resolveRelations, } from './read'; +import { RecursivePartial } from './util'; import { ActiveDirectoryVendor, DefaultLdapVendor } from './vendors'; function user(data: RecursivePartial): UserEntity { diff --git a/plugins/catalog-backend-module-ldap/src/ldap/util.ts b/plugins/catalog-backend-module-ldap/src/ldap/util.ts index 21829cef35..0f443c1a86 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/util.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/util.ts @@ -53,3 +53,11 @@ export function mapStringAttr( } } } + +export type RecursivePartial = { + [P in keyof T]?: T[P] extends (infer U)[] + ? RecursivePartial[] + : T[P] extends object + ? RecursivePartial + : T[P]; +}; diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index b28ff55f8c..d880159a36 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -762,15 +762,6 @@ export const processingResult: Readonly<{ readonly relation: (spec: EntityRelationSpec) => CatalogProcessorResult; }>; -// @public -export type RecursivePartial = { - [P in keyof T]?: T[P] extends (infer U)[] - ? RecursivePartial[] - : T[P] extends object - ? RecursivePartial - : T[P]; -}; - // @public export type RefreshOptions = { entityRef: string; diff --git a/plugins/catalog-backend/src/index.ts b/plugins/catalog-backend/src/index.ts index 4c1e753300..437c1f4598 100644 --- a/plugins/catalog-backend/src/index.ts +++ b/plugins/catalog-backend/src/index.ts @@ -25,7 +25,6 @@ export * from './catalog'; export * from './ingestion'; export * from './modules'; export * from './search'; -export * from './util'; export * from './processing'; export * from './service'; export * from './permissions'; diff --git a/plugins/catalog-backend/src/service/request/parseEntityTransformParams.ts b/plugins/catalog-backend/src/service/request/parseEntityTransformParams.ts index 7474b12c11..9935da07a8 100644 --- a/plugins/catalog-backend/src/service/request/parseEntityTransformParams.ts +++ b/plugins/catalog-backend/src/service/request/parseEntityTransformParams.ts @@ -17,7 +17,7 @@ import { Entity } from '@backstage/catalog-model'; import { InputError } from '@backstage/errors'; import lodash from 'lodash'; -import { RecursivePartial } from '../../util'; +import { RecursivePartial } from '../../util/RecursivePartial'; import { parseStringsParam } from './common'; export function parseEntityTransformParams( diff --git a/plugins/catalog-backend/src/util/RecursivePartial.ts b/plugins/catalog-backend/src/util/RecursivePartial.ts index 92e1ab9296..c452836f34 100644 --- a/plugins/catalog-backend/src/util/RecursivePartial.ts +++ b/plugins/catalog-backend/src/util/RecursivePartial.ts @@ -16,7 +16,7 @@ /** * Makes all keys of an entire hierarchy optional. - * @public + * @ignore */ export type RecursivePartial = { [P in keyof T]?: T[P] extends (infer U)[] diff --git a/plugins/catalog-backend/src/util/index.ts b/plugins/catalog-backend/src/util/index.ts deleted file mode 100644 index 0b5a942e0c..0000000000 --- a/plugins/catalog-backend/src/util/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './RecursivePartial'; diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 0dd8dba6f8..fdcd754b64 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -143,24 +143,35 @@ ApiReportGenerator.generateReviewFileContent = ); } - // NOTE: we limit the @internal functionality to only apply to types that are declared - // in the same module as where they're being referenced from. This limitation makes - // the implementation here simpler but could be revisited if needed. - // The local name of the symbol within the file, rather than the exported name const localName = (sourceFile as any).identifiers?.get(symbolName); if (!localName) { - return true; + throw new Error( + `Unable to find local name of "${symbolName}" in ${sourceFile.fileName}`, + ); } + // The local AST node of the export that we're missing const local = (sourceFile as any).locals?.get(localName); if (!local) { return true; } + // Use the type checker to look up the actual declaration(s) rather than the one in the local file + const type = program.getTypeChecker().getDeclaredTypeOfSymbol(local); + if (!type) { + throw new Error( + `Unable to find type declaration of "${symbolName}" in ${sourceFile.fileName}`, + ); + } + const declarations = type.aliasSymbol?.declarations; + if (!declarations || declarations.length === 0) { + return true; + } + // If any of the TSDoc comments contain a @ignore tag, we ignore this message - const isIgnored = local.declarations.some(declaration => { - const tags = [declaration.jsDoc] + const isIgnored = declarations.some(declaration => { + const tags = [(declaration as any).jsDoc] .flat() .filter(Boolean) .flatMap((tagNode: any) => tagNode.tags);