Merge pull request #10181 from backstage/rugvip/norep

catalog-backend: removed RecursivePartial export
This commit is contained in:
Patrik Oldsberg
2022-03-14 20:08:09 +01:00
committed by GitHub
11 changed files with 50 additions and 38 deletions
+15
View File
@@ -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<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object
? RecursivePartial<T[P]>
: T[P];
};
```
+5
View File
@@ -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`.
@@ -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.
@@ -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>): UserEntity {
@@ -53,3 +53,11 @@ export function mapStringAttr(
}
}
}
export type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object
? RecursivePartial<T[P]>
: T[P];
};
-9
View File
@@ -762,15 +762,6 @@ export const processingResult: Readonly<{
readonly relation: (spec: EntityRelationSpec) => CatalogProcessorResult;
}>;
// @public
export type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
? RecursivePartial<U>[]
: T[P] extends object
? RecursivePartial<T[P]>
: T[P];
};
// @public
export type RefreshOptions = {
entityRef: string;
-1
View File
@@ -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';
@@ -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(
@@ -16,7 +16,7 @@
/**
* Makes all keys of an entire hierarchy optional.
* @public
* @ignore
*/
export type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[]
-17
View File
@@ -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';
+18 -7
View File
@@ -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);