diff --git a/.changeset/rotten-melons-carry.md b/.changeset/rotten-melons-carry.md new file mode 100644 index 0000000000..5e9f849d2f --- /dev/null +++ b/.changeset/rotten-melons-carry.md @@ -0,0 +1,8 @@ +--- +'@backstage/config': patch +'@backstage/core-app-api': patch +'@backstage/core-plugin-api': patch +'@backstage/plugin-scaffolder-backend': patch +--- + +Start using the new `@backstage/core-types` package. Initially, this means using the `Observable` and `Json*` types from there. The types also remain in their old places but deprecated, and will be removed in a future release. diff --git a/packages/config/api-report.md b/packages/config/api-report.md index 9948aa1e29..116231ac72 100644 --- a/packages/config/api-report.md +++ b/packages/config/api-report.md @@ -3,10 +3,15 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import type { JsonArray as JsonArray_2 } from '@backstage/core-types'; +import { JsonObject as JsonObject_2 } from '@backstage/core-types'; +import type { JsonPrimitive as JsonPrimitive_2 } from '@backstage/core-types'; +import { JsonValue as JsonValue_2 } from '@backstage/core-types'; + // @public export type AppConfig = { context: string; - data: JsonObject; + data: JsonObject_2; filteredKeys?: string[]; }; @@ -17,8 +22,8 @@ export type Config = { }; has(key: string): boolean; keys(): string[]; - get(key?: string): T; - getOptional(key?: string): T | undefined; + get(key?: string): T; + getOptional(key?: string): T | undefined; getConfig(key: string): Config; getOptionalConfig(key: string): Config | undefined; getConfigArray(key: string): Config[]; @@ -36,7 +41,7 @@ export type Config = { // @public export class ConfigReader implements Config { constructor( - data: JsonObject | undefined, + data: JsonObject_2 | undefined, context?: string, fallback?: ConfigReader | undefined, prefix?: string, @@ -44,7 +49,7 @@ export class ConfigReader implements Config { // (undocumented) static fromConfigs(configs: AppConfig[]): ConfigReader; // (undocumented) - get(key?: string): T; + get(key?: string): T; // (undocumented) getBoolean(key: string): boolean; // (undocumented) @@ -54,7 +59,7 @@ export class ConfigReader implements Config { // (undocumented) getNumber(key: string): number; // (undocumented) - getOptional(key?: string): T | undefined; + getOptional(key?: string): T | undefined; // (undocumented) getOptionalBoolean(key: string): boolean | undefined; // (undocumented) @@ -77,17 +82,15 @@ export class ConfigReader implements Config { keys(): string[]; } -// @public -export interface JsonArray extends Array {} +// @public @deprecated +export type JsonArray = JsonArray_2; -// @public -export type JsonObject = { - [key in string]?: JsonValue; -}; +// @public @deprecated +export type JsonObject = JsonObject_2; -// @public -export type JsonPrimitive = number | string | boolean | null; +// @public @deprecated +export type JsonPrimitive = JsonPrimitive_2; -// @public -export type JsonValue = JsonObject | JsonArray | JsonPrimitive; +// @public @deprecated +export type JsonValue = JsonValue_2; ``` diff --git a/packages/config/package.json b/packages/config/package.json index ffa2404300..7cd39eb2b0 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -30,6 +30,7 @@ "clean": "backstage-cli clean" }, "dependencies": { + "@backstage/core-types": "^0.1.0", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/config/src/deprecatedTypes.ts b/packages/config/src/deprecatedTypes.ts new file mode 100644 index 0000000000..17876f60eb --- /dev/null +++ b/packages/config/src/deprecatedTypes.ts @@ -0,0 +1,55 @@ +/* + * Copyright 2021 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. + */ + +// Temporarily re-export the JSON types from @backstage/core-types +import type { + JsonArray as CoreJsonArray, + JsonObject as CoreJsonObject, + JsonPrimitive as CoreJsonPrimitive, + JsonValue as CoreJsonValue, +} from '@backstage/core-types'; + +/** + * A type representing all allowed JSON primitive values. + * + * @public + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type JsonPrimitive = CoreJsonPrimitive; + +/** + * A type representing all allowed JSON object values. + * + * @public + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type JsonObject = CoreJsonObject; + +/** + * A type representing all allowed JSON array values. + * + * @public + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type JsonArray = CoreJsonArray; + +/** + * A type representing all allowed JSON values. + * + * @public + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type JsonValue = CoreJsonValue; diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 59b5e8fff8..c8800d0ad2 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -20,12 +20,11 @@ * @packageDocumentation */ -export { ConfigReader } from './reader'; export type { - AppConfig, - Config, JsonArray, JsonObject, JsonPrimitive, JsonValue, -} from './types'; +} from './deprecatedTypes'; +export { ConfigReader } from './reader'; +export type { AppConfig, Config } from './types'; diff --git a/packages/config/src/reader.ts b/packages/config/src/reader.ts index 92ca0eede3..fee1b34569 100644 --- a/packages/config/src/reader.ts +++ b/packages/config/src/reader.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AppConfig, Config, JsonValue, JsonObject } from './types'; +import { JsonValue, JsonObject } from '@backstage/core-types'; +import { AppConfig, Config } from './types'; import cloneDeep from 'lodash/cloneDeep'; import mergeWith from 'lodash/mergeWith'; diff --git a/packages/config/src/types.ts b/packages/config/src/types.ts index d5f551cd69..e98dee9fa7 100644 --- a/packages/config/src/types.ts +++ b/packages/config/src/types.ts @@ -14,33 +14,7 @@ * limitations under the License. */ -/** - * A type representing all allowed JSON primitive values. - * - * @public - */ -export type JsonPrimitive = number | string | boolean | null; - -/** - * A type representing all allowed JSON object values. - * - * @public - */ -export type JsonObject = { [key in string]?: JsonValue }; - -/** - * A type representing all allowed JSON array values. - * - * @public - */ -export interface JsonArray extends Array {} - -/** - * A type representing all allowed JSON values. - * - * @public - */ -export type JsonValue = JsonObject | JsonArray | JsonPrimitive; +import { JsonObject, JsonValue } from '@backstage/core-types'; /** * A serialized form of configuration data that carries additional context. diff --git a/packages/core-app-api/api-report.md b/packages/core-app-api/api-report.md index 22d5092aa6..bfeaa7f678 100644 --- a/packages/core-app-api/api-report.md +++ b/packages/core-app-api/api-report.md @@ -40,6 +40,7 @@ import { microsoftAuthApiRef } from '@backstage/core-plugin-api'; import { OAuthApi } from '@backstage/core-plugin-api'; import { OAuthRequestApi } from '@backstage/core-plugin-api'; import { Observable } from '@backstage/core-plugin-api'; +import { Observable as Observable_2 } from '@backstage/core-types'; import { oktaAuthApiRef } from '@backstage/core-plugin-api'; import { oneloginAuthApiRef } from '@backstage/core-plugin-api'; import { OpenIdConnectApi } from '@backstage/core-plugin-api'; @@ -326,7 +327,7 @@ export const defaultConfigLoader: AppConfigLoader; export class ErrorAlerter implements ErrorApi { constructor(alertApi: AlertApi, errorApi: ErrorApi); // (undocumented) - error$(): Observable<{ + error$(): Observable_2<{ error: { name: string; message: string; diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index 4d1fe4fffd..765cdaa21c 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -8,9 +8,12 @@ import { BackstageTheme } from '@backstage/theme'; import { ComponentType } from 'react'; import { Config } from '@backstage/config'; +import { Observable as Observable_2 } from '@backstage/core-types'; +import { Observer as Observer_2 } from '@backstage/core-types'; import { default as React_2 } from 'react'; import { ReactElement } from 'react'; import { ReactNode } from 'react'; +import { Subscription as Subscription_2 } from '@backstage/core-types'; import { SvgIconProps } from '@material-ui/core'; // Warning: (ae-missing-release-tag) "AlertApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -18,7 +21,7 @@ import { SvgIconProps } from '@material-ui/core'; // @public export type AlertApi = { post(alert: AlertMessage): void; - alert$(): Observable; + alert$(): Observable_2; }; // Warning: (ae-missing-release-tag) "alertApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -201,7 +204,7 @@ export type AppTheme = { // @public export type AppThemeApi = { getInstalledThemes(): AppTheme[]; - activeThemeId$(): Observable; + activeThemeId$(): Observable_2; getActiveThemeId(): string | undefined; setActiveThemeId(themeId?: string): void; }; @@ -471,7 +474,7 @@ export interface ElementCollection { // @public export type ErrorApi = { post(error: Error_2, context?: ErrorContext): void; - error$(): Observable<{ + error$(): Observable_2<{ error: Error_2; context?: ErrorContext; }>; @@ -667,7 +670,7 @@ export type OAuthRequestApi = { createAuthRequester( options: AuthRequesterOptions, ): AuthRequester; - authRequest$(): Observable; + authRequest$(): Observable_2; }; // Warning: (ae-missing-release-tag) "oauthRequestApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -682,25 +685,13 @@ export type OAuthScope = string | string[]; // Warning: (ae-missing-release-tag) "Observable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // -// @public -export type Observable = { - [Symbol.observable](): Observable; - subscribe(observer: Observer): Subscription; - subscribe( - onNext?: (value: T) => void, - onError?: (error: Error) => void, - onComplete?: () => void, - ): Subscription; -}; +// @public @deprecated +export type Observable = Observable_2; // Warning: (ae-missing-release-tag) "Observer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // -// @public -export type Observer = { - next?(value: T): void; - error?(error: Error): void; - complete?(): void; -}; +// @public @deprecated +export type Observer = Observer_2; // Warning: (ae-missing-release-tag) "oidcAuthApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -829,7 +820,7 @@ export const samlAuthApiRef: ApiRef< export type SessionApi = { signIn(): Promise; signOut(): Promise; - sessionState$(): Observable; + sessionState$(): Observable_2; }; // Warning: (ae-missing-release-tag) "SessionState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -874,7 +865,7 @@ export interface StorageApi { get(key: string): T | undefined; // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' - observe$(key: string): Observable>; + observe$(key: string): Observable_2>; // Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen // Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}' remove(key: string): Promise; @@ -908,11 +899,8 @@ export type SubRouteRef = { // Warning: (ae-missing-release-tag) "Subscription" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // -// @public -export type Subscription = { - unsubscribe(): void; - readonly closed: boolean; -}; +// @public @deprecated +export type Subscription = Subscription_2; // Warning: (ae-missing-release-tag) "TypesToApiRefs" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // diff --git a/packages/core-plugin-api/package.json b/packages/core-plugin-api/package.json index 5c8daec606..fbb2760e59 100644 --- a/packages/core-plugin-api/package.json +++ b/packages/core-plugin-api/package.json @@ -30,6 +30,7 @@ }, "dependencies": { "@backstage/config": "^0.1.9", + "@backstage/core-types": "^0.1.0", "@backstage/theme": "^0.2.9", "@backstage/version-bridge": "^0.1.0", "@material-ui/core": "^4.12.2", diff --git a/packages/core-plugin-api/src/apis/definitions/AlertApi.ts b/packages/core-plugin-api/src/apis/definitions/AlertApi.ts index aac2283973..ecd12c533a 100644 --- a/packages/core-plugin-api/src/apis/definitions/AlertApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/AlertApi.ts @@ -13,8 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { createApiRef, ApiRef } from '../system'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; export type AlertMessage = { message: string; diff --git a/packages/core-plugin-api/src/apis/definitions/AppThemeApi.ts b/packages/core-plugin-api/src/apis/definitions/AppThemeApi.ts index 3ff9ddce98..8608b53593 100644 --- a/packages/core-plugin-api/src/apis/definitions/AppThemeApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/AppThemeApi.ts @@ -16,7 +16,7 @@ import { ApiRef, createApiRef } from '../system'; import { BackstageTheme } from '@backstage/theme'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; /** * Describes a theme provided by the app. diff --git a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts index dc63e28e1a..6fd47ac966 100644 --- a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts @@ -15,7 +15,7 @@ */ import { ApiRef, createApiRef } from '../system'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; /** * Mirrors the JavaScript Error class, for the purpose of diff --git a/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts b/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts index 3fe7f26bc0..43351edaf8 100644 --- a/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/OAuthRequestApi.ts @@ -15,7 +15,7 @@ */ import { IconComponent } from '../../icons/types'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; import { ApiRef, createApiRef } from '../system'; /** diff --git a/packages/core-plugin-api/src/apis/definitions/StorageApi.ts b/packages/core-plugin-api/src/apis/definitions/StorageApi.ts index 9332c80f0f..7951403040 100644 --- a/packages/core-plugin-api/src/apis/definitions/StorageApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/StorageApi.ts @@ -15,7 +15,7 @@ */ import { ApiRef, createApiRef } from '../system'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; export type StorageValueChange = { key: string; diff --git a/packages/core-plugin-api/src/apis/definitions/auth.ts b/packages/core-plugin-api/src/apis/definitions/auth.ts index a78414048c..314f2955cf 100644 --- a/packages/core-plugin-api/src/apis/definitions/auth.ts +++ b/packages/core-plugin-api/src/apis/definitions/auth.ts @@ -15,7 +15,7 @@ */ import { ApiRef, createApiRef } from '../system'; -import { Observable } from '../../types'; +import { Observable } from '@backstage/core-types'; /** * This file contains declarations for common interfaces of auth-related APIs. diff --git a/packages/core-plugin-api/src/deprecatedTypes.ts b/packages/core-plugin-api/src/deprecatedTypes.ts new file mode 100644 index 0000000000..598f666317 --- /dev/null +++ b/packages/core-plugin-api/src/deprecatedTypes.ts @@ -0,0 +1,47 @@ +/* + * 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. + */ + +import { + Observer as CoreObserver, + Subscription as CoreSubscription, + Observable as CoreObservable, +} from '@backstage/core-types'; + +/** + * Observer interface for consuming an Observer, see TC39. + * + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type Observer = CoreObserver; + +/** + * Subscription returned when subscribing to an Observable, see TC39. + * + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type Subscription = CoreSubscription; + +/** + * Observable sequence of values and errors, see TC39. + * + * https://github.com/tc39/proposal-observable + * + * This is used as a common return type for observable values and can be created + * using many different observable implementations, such as zen-observable or RxJS 5. + * + * @deprecated Please use the same type from `@backstage/core-types` instead + */ +export type Observable = CoreObservable; diff --git a/packages/core-plugin-api/src/index.ts b/packages/core-plugin-api/src/index.ts index 782416c4d0..7a4f2e72ba 100644 --- a/packages/core-plugin-api/src/index.ts +++ b/packages/core-plugin-api/src/index.ts @@ -27,4 +27,4 @@ export * from './extensions'; export * from './icons'; export * from './plugin'; export * from './routing'; -export * from './types'; +export * from './deprecatedTypes'; diff --git a/packages/core-types/.eslintrc.js b/packages/core-types/.eslintrc.js new file mode 100644 index 0000000000..13573efa9c --- /dev/null +++ b/packages/core-types/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: [require.resolve('@backstage/cli/config/eslint')], +}; diff --git a/packages/core-types/README.md b/packages/core-types/README.md new file mode 100644 index 0000000000..52bd1fa7a5 --- /dev/null +++ b/packages/core-types/README.md @@ -0,0 +1,9 @@ +# Common core types used within Backstage + +Contains some common types that are used widely within the rest of the Backstage project and in plugins. + +This package will be imported both by the frontend and backend. + +## Links + +- [The Backstage homepage](https://backstage.io) diff --git a/packages/core-types/api-report.md b/packages/core-types/api-report.md new file mode 100644 index 0000000000..bd4d145a10 --- /dev/null +++ b/packages/core-types/api-report.md @@ -0,0 +1,49 @@ +## API Report File for "@backstage/core-types" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +// @public +export interface JsonArray extends Array {} + +// @public +export type JsonObject = { + [key in string]?: JsonValue; +}; + +// @public +export type JsonPrimitive = number | string | boolean | null; + +// @public +export type JsonValue = JsonObject | JsonArray | JsonPrimitive; + +// Warning: (ae-missing-release-tag) "Observable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type Observable = { + [Symbol.observable](): Observable; + subscribe(observer: Observer): Subscription; + subscribe( + onNext?: (value: T) => void, + onError?: (error: Error) => void, + onComplete?: () => void, + ): Subscription; +}; + +// Warning: (ae-missing-release-tag) "Observer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type Observer = { + next?(value: T): void; + error?(error: Error): void; + complete?(): void; +}; + +// Warning: (ae-missing-release-tag) "Subscription" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export type Subscription = { + unsubscribe(): void; + readonly closed: boolean; +}; +``` diff --git a/packages/core-types/package.json b/packages/core-types/package.json new file mode 100644 index 0000000000..ce6fc05fb4 --- /dev/null +++ b/packages/core-types/package.json @@ -0,0 +1,39 @@ +{ + "name": "@backstage/core-types", + "description": "Common core types used within Backstage", + "version": "0.1.0", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "private": false, + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "homepage": "https://backstage.io", + "repository": { + "type": "git", + "url": "https://github.com/backstage/backstage", + "directory": "packages/core-types" + }, + "keywords": [ + "backstage" + ], + "scripts": { + "build": "backstage-cli build", + "lint": "backstage-cli lint", + "test": "backstage-cli test", + "prepack": "backstage-cli prepack", + "postpack": "backstage-cli postpack", + "clean": "backstage-cli clean" + }, + "dependencies": {}, + "devDependencies": { + "@backstage/cli": "^0.7.11" + }, + "files": [ + "dist" + ] +} diff --git a/packages/core-types/src/index.ts b/packages/core-types/src/index.ts new file mode 100644 index 0000000000..9e7a33c5f2 --- /dev/null +++ b/packages/core-types/src/index.ts @@ -0,0 +1,24 @@ +/* + * 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. + */ + +/** + * Common core types used within Backstage + * + * @packageDocumentation + */ + +export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from './json'; +export type { Observable, Observer, Subscription } from './observable'; diff --git a/packages/core-types/src/json.ts b/packages/core-types/src/json.ts new file mode 100644 index 0000000000..bcbaaa1030 --- /dev/null +++ b/packages/core-types/src/json.ts @@ -0,0 +1,43 @@ +/* + * Copyright 2021 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. + */ + +/** + * A type representing all allowed JSON primitive values. + * + * @public + */ +export type JsonPrimitive = number | string | boolean | null; + +/** + * A type representing all allowed JSON object values. + * + * @public + */ +export type JsonObject = { [key in string]?: JsonValue }; + +/** + * A type representing all allowed JSON array values. + * + * @public + */ +export interface JsonArray extends Array {} + +/** + * A type representing all allowed JSON values. + * + * @public + */ +export type JsonValue = JsonObject | JsonArray | JsonPrimitive; diff --git a/packages/core-plugin-api/src/types.ts b/packages/core-types/src/observable.ts similarity index 93% rename from packages/core-plugin-api/src/types.ts rename to packages/core-types/src/observable.ts index fff4cb1515..367fa087e0 100644 --- a/packages/core-plugin-api/src/types.ts +++ b/packages/core-types/src/observable.ts @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Backstage Authors + * Copyright 2021 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. @@ -14,10 +14,6 @@ * limitations under the License. */ -/** - * This file contains non-react related core types used throughout Backstage. - */ - /** * Observer interface for consuming an Observer, see TC39. */ diff --git a/packages/core-types/src/setupTests.ts b/packages/core-types/src/setupTests.ts new file mode 100644 index 0000000000..d3232290a7 --- /dev/null +++ b/packages/core-types/src/setupTests.ts @@ -0,0 +1,17 @@ +/* + * 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 {}; diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index ef4defcc50..9dd86eeddc 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -15,7 +15,9 @@ import { createPullRequest } from 'octokit-plugin-create-pull-request'; import { Entity } from '@backstage/catalog-model'; import express from 'express'; import { JsonObject } from '@backstage/config'; +import { JsonObject as JsonObject_2 } from '@backstage/core-types'; import { JsonValue } from '@backstage/config'; +import { JsonValue as JsonValue_2 } from '@backstage/core-types'; import { LocationSpec } from '@backstage/catalog-model'; import { Logger as Logger_2 } from 'winston'; import { Octokit } from '@octokit/rest'; @@ -183,7 +185,7 @@ export function createRouter(options: RouterOptions): Promise; // @public (undocumented) export const createTemplateAction: < Input extends Partial<{ - [name: string]: JsonValue | Partial | undefined; + [name: string]: JsonValue_2 | Partial | undefined; }>, >( templateAction: TemplateAction,