@octopusdeploy/step-inputs
Advanced tools
Comparing version 0.0.2 to 0.1.0
# @octopusdeploy/step-inputs | ||
## 0.1.0 | ||
### Minor Changes | ||
- 622d034: Update types based on the latest changes from portal | ||
## 0.0.2 | ||
@@ -4,0 +10,0 @@ |
@@ -33,7 +33,7 @@ import type { Discriminator } from "./Discriminator"; | ||
}; | ||
export declare type InputPathForProperty<PropertyType> = [PropertyType] extends [Discriminator<infer D>] ? D : [PropertyType] extends [SensitiveValue] ? ConvertibleInputPathToValue<PropertyType> : [PropertyType] extends [PackageReference] ? ConvertibleInputPathToValue<PropertyType> : [PropertyType] extends [Array<infer ArrayItem>] ? Array<InputPaths<ArrayItem>> & InputPathToArray<ArrayItem> : [PropertyType] extends [object] ? InputPaths<PropertyType> : [PropertyType] extends [PropertyType] ? ConvertibleInputPathToValue<PropertyType> : never; | ||
export declare type InputPaths<T> = ObjectWithInputPaths<T> & InputPathToObject<T>; | ||
export declare type ObjectWithInputPaths<T> = { | ||
[K in keyof T]: InputPathForProperty<T[K]>; | ||
export declare type InputPaths<PropertyType> = [PropertyType] extends [Discriminator<infer D>] ? D : [PropertyType] extends [SensitiveValue] ? ConvertibleInputPathToValue<PropertyType> : [PropertyType] extends [PackageReference] ? ConvertibleInputPathToValue<PropertyType> : [PropertyType] extends [Array<infer ArrayItem>] ? Array<ObjectInputPathsAndPathToObject<ArrayItem>> & InputPathToArray<ArrayItem> : [PropertyType] extends [object] ? ObjectInputPathsAndPathToObject<PropertyType> : [PropertyType] extends [PropertyType] ? ConvertibleInputPathToValue<PropertyType> : never; | ||
export declare type ObjectInputPathsAndPathToObject<T> = ObjectInputPaths<T> & InputPathToObject<T>; | ||
export declare type ObjectInputPaths<T> = { | ||
[K in keyof T]: InputPaths<T[K]>; | ||
}; | ||
export declare type IsAssignableTo<T, U> = [T] extends [U] ? "true" : "false"; |
{ | ||
"name": "@octopusdeploy/step-inputs", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "The step UI", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
// simple property maps to a path with one segment | ||
import { ConvertibleInputPathToValue, InputPathForProperty, InputPaths, InputPathToArray, InputPathToObject } from "../InputPaths"; | ||
import { ConvertibleInputPathToValue, InputPaths, ObjectInputPathsAndPathToObject, InputPathToArray, InputPathToObject } from "../InputPaths"; | ||
import { SensitiveValue } from "../SensitiveValues"; | ||
@@ -7,18 +7,26 @@ import { PackageReference } from "../PackageReference"; | ||
assert<IsExactly<InputPaths<{ foo: string }>, { foo: ConvertibleInputPathToValue<string> } & InputPathToObject<{ foo: string }>>>(); | ||
assert<IsExactly<InputPaths<{ foo: number }>, { foo: ConvertibleInputPathToValue<number> } & InputPathToObject<{ foo: number }>>>(); | ||
assert<IsExactly<ObjectInputPathsAndPathToObject<{ foo: string }>, { foo: ConvertibleInputPathToValue<string> } & InputPathToObject<{ foo: string }>>>(); | ||
assert<IsExactly<ObjectInputPathsAndPathToObject<{ foo: number }>, { foo: ConvertibleInputPathToValue<number> } & InputPathToObject<{ foo: number }>>>(); | ||
// works for sensitive values | ||
assert<IsExactly<InputPaths<{ foo: SensitiveValue }>, { foo: ConvertibleInputPathToValue<SensitiveValue> } & InputPathToObject<{ foo: SensitiveValue }>>>(); | ||
assert< | ||
IsExactly< | ||
ObjectInputPathsAndPathToObject<{ foo: SensitiveValue }>, | ||
{ foo: ConvertibleInputPathToValue<SensitiveValue> } & InputPathToObject<{ foo: SensitiveValue }> | ||
> | ||
>(); | ||
// works for package selection | ||
assert< | ||
IsExactly<InputPaths<{ foo: PackageReference }>, { foo: ConvertibleInputPathToValue<PackageReference> } & InputPathToObject<{ foo: PackageReference }>> | ||
IsExactly< | ||
ObjectInputPathsAndPathToObject<{ foo: PackageReference }>, | ||
{ foo: ConvertibleInputPathToValue<PackageReference> } & InputPathToObject<{ foo: PackageReference }> | ||
> | ||
>(); | ||
// works for optional types | ||
assert<IsExactly<InputPathForProperty<number | undefined>, ConvertibleInputPathToValue<number | undefined>>>(); | ||
assert<IsExactly<InputPaths<number | undefined>, ConvertibleInputPathToValue<number | undefined>>>(); | ||
assert< | ||
IsExactly< | ||
InputPaths<{ foo: number | undefined }>, | ||
ObjectInputPathsAndPathToObject<{ foo: number | undefined }>, | ||
{ foo: ConvertibleInputPathToValue<number | undefined> } & InputPathToObject<{ foo: number | undefined }> | ||
@@ -31,3 +39,3 @@ > | ||
IsExactly< | ||
InputPaths<{ foo: { bar: string } }>, | ||
ObjectInputPathsAndPathToObject<{ foo: { bar: string } }>, | ||
{ foo: { bar: ConvertibleInputPathToValue<string> } & InputPathToObject<{ bar: string }> } & InputPathToObject<{ foo: { bar: string } }> | ||
@@ -38,3 +46,3 @@ > | ||
IsExactly< | ||
InputPaths<{ foo: { bar: { baz: string } } }>, | ||
ObjectInputPathsAndPathToObject<{ foo: { bar: { baz: string } } }>, | ||
{ | ||
@@ -47,3 +55,3 @@ foo: { bar: { baz: ConvertibleInputPathToValue<string> } & InputPathToObject<{ baz: string }> } & InputPathToObject<{ bar: { baz: string } }>; | ||
// discriminators for union types are preserved | ||
assert<IsExactly<InputPaths<{ foo: Discriminator<"foo"> }>, { foo: "foo" } & InputPathToObject<{ foo: Discriminator<"foo"> }>>>(); | ||
assert<IsExactly<ObjectInputPathsAndPathToObject<{ foo: Discriminator<"foo"> }>, { foo: "foo" } & InputPathToObject<{ foo: Discriminator<"foo"> }>>>(); | ||
@@ -75,3 +83,3 @@ // distributing across unions of interfaces and types behaves the same | ||
IsExactly< | ||
InputPaths<{ foo: FirstType | SecondType }>, | ||
ObjectInputPathsAndPathToObject<{ foo: FirstType | SecondType }>, | ||
{ | ||
@@ -88,3 +96,3 @@ foo: | ||
IsExactly< | ||
InputPaths<{ foo: FirstInterface | SecondInterface }>, | ||
ObjectInputPathsAndPathToObject<{ foo: FirstInterface | SecondInterface }>, | ||
{ | ||
@@ -101,3 +109,3 @@ foo: | ||
IsExactly< | ||
InputPathForProperty<FirstType | SecondType>, | ||
InputPaths<FirstType | SecondType>, | ||
| ({ type: "bar"; bar: ConvertibleInputPathToValue<string> } & InputPathToObject<FirstType | SecondType>) | ||
@@ -109,3 +117,3 @@ | ({ type: "baz"; baz: ConvertibleInputPathToValue<string> } & InputPathToObject<FirstType | SecondType>) | ||
IsExactly< | ||
InputPathForProperty<FirstInterface | SecondInterface>, | ||
InputPaths<FirstInterface | SecondInterface>, | ||
| ({ type: "bar"; bar: ConvertibleInputPathToValue<string> } & InputPathToObject<FirstInterface | SecondInterface>) | ||
@@ -119,3 +127,3 @@ | ({ type: "baz"; baz: ConvertibleInputPathToValue<string> } & InputPathToObject<FirstInterface | SecondInterface>) | ||
IsExactly< | ||
InputPaths<{ foo: Array<{ bar: string }> }>, | ||
ObjectInputPathsAndPathToObject<{ foo: Array<{ bar: string }> }>, | ||
{ | ||
@@ -122,0 +130,0 @@ foo: Array<{ bar: ConvertibleInputPathToValue<string> } & InputPathToObject<{ bar: string }>> & InputPathToArray<{ bar: string }>; |
@@ -30,3 +30,3 @@ import type { Discriminator } from "./Discriminator"; | ||
export type InputPathForProperty<PropertyType> = [PropertyType] extends [Discriminator<infer D>] | ||
export type InputPaths<PropertyType> = [PropertyType] extends [Discriminator<infer D>] | ||
? D | ||
@@ -38,5 +38,5 @@ : [PropertyType] extends [SensitiveValue] | ||
: [PropertyType] extends [Array<infer ArrayItem>] | ||
? Array<InputPaths<ArrayItem>> & InputPathToArray<ArrayItem> // eslint-disable-next-line @typescript-eslint/ban-types | ||
? Array<ObjectInputPathsAndPathToObject<ArrayItem>> & InputPathToArray<ArrayItem> // eslint-disable-next-line @typescript-eslint/ban-types | ||
: [PropertyType] extends [object] // Extending from object seems to be the only way to ensure that this type maps the same way across both types and interfaces // eslint-disable-next-line @typescript-eslint/ban-types | ||
? InputPaths<PropertyType> | ||
? ObjectInputPathsAndPathToObject<PropertyType> | ||
: [PropertyType] extends [PropertyType] | ||
@@ -46,5 +46,5 @@ ? ConvertibleInputPathToValue<PropertyType> | ||
export type InputPaths<T> = ObjectWithInputPaths<T> & InputPathToObject<T>; | ||
export type ObjectWithInputPaths<T> = { | ||
[K in keyof T]: InputPathForProperty<T[K]>; | ||
export type ObjectInputPathsAndPathToObject<T> = ObjectInputPaths<T> & InputPathToObject<T>; | ||
export type ObjectInputPaths<T> = { | ||
[K in keyof T]: InputPaths<T[K]>; | ||
}; | ||
@@ -51,0 +51,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20575
335