introduce core-types

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-10-21 09:45:32 +02:00
parent 00da5e919f
commit 41c49884d2
27 changed files with 350 additions and 89 deletions
+19 -16
View File
@@ -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<T = JsonValue>(key?: string): T;
getOptional<T = JsonValue>(key?: string): T | undefined;
get<T = JsonValue_2>(key?: string): T;
getOptional<T = JsonValue_2>(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<T = JsonValue>(key?: string): T;
get<T = JsonValue_2>(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<T = JsonValue>(key?: string): T | undefined;
getOptional<T = JsonValue_2>(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<JsonValue> {}
// @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;
```
+1
View File
@@ -30,6 +30,7 @@
"clean": "backstage-cli clean"
},
"dependencies": {
"@backstage/core-types": "^0.1.0",
"lodash": "^4.17.21"
},
"devDependencies": {
+55
View File
@@ -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;
+3 -4
View File
@@ -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';
+2 -1
View File
@@ -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';
+1 -27
View File
@@ -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<JsonValue> {}
/**
* 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.