|
|
|
@ -264,11 +264,16 @@ function createSimpleOutput(val: any) {
|
|
|
|
|
* In this example, taking a dependency on d3 means a resource will depend on all the resources of
|
|
|
|
|
* d1 and d2.
|
|
|
|
|
*/
|
|
|
|
|
// This overload is effectively the same as the next. However, it handles `tuples` properly, instead
|
|
|
|
|
// of treating them as arrays. Specifically, if you had `[Output<number>, Output<string>]` it would
|
|
|
|
|
// give you `Output<[number, string]>` instead of `Output<(number | string)[]>`.
|
|
|
|
|
export function all<T extends unknown[]>(xs: T | []): Output<UnwrappedObject<T>>;
|
|
|
|
|
export function all<T extends object>(val: T): Output<UnwrappedObject<T>>;
|
|
|
|
|
// tslint:disable:max-line-length
|
|
|
|
|
export function all<T>(val: Record<string, Input<T>>): Output<Record<string, Unwrap<T>>>;
|
|
|
|
|
export function all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined, Input<T4> | undefined, Input<T5> | undefined, Input<T6> | undefined, Input<T7> | undefined, Input<T8> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>, Unwrap<T4>, Unwrap<T5>, Unwrap<T6>, Unwrap<T7>, Unwrap<T8>]>;
|
|
|
|
|
export function all<T1, T2, T3, T4, T5, T6, T7>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined, Input<T4> | undefined, Input<T5> | undefined, Input<T6> | undefined, Input<T7> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>, Unwrap<T4>, Unwrap<T5>, Unwrap<T6>, Unwrap<T7>]>;
|
|
|
|
|
export function all<T1, T2, T3, T4, T5, T6>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined, Input<T4> | undefined, Input<T5> | undefined, Input<T6> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>, Unwrap<T4>, Unwrap<T5>, Unwrap<T6>]>;
|
|
|
|
|
export function all<T1, T2, T3, T4, T5>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined, Input<T4> | undefined, Input<T5> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>, Unwrap<T4>, Unwrap<T5>]>;
|
|
|
|
|
export function all<T1, T2, T3, T4>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined, Input<T4> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>, Unwrap<T4>]>;
|
|
|
|
|
export function all<T1, T2, T3>(values: [Input<T1> | undefined, Input<T2> | undefined, Input<T3> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>, Unwrap<T3>]>;
|
|
|
|
|
export function all<T1, T2>(values: [Input<T1> | undefined, Input<T2> | undefined]): Output<[Unwrap<T1>, Unwrap<T2>]>;
|
|
|
|
|
export function all<T>(ds: (Input<T> | undefined)[]): Output<Unwrap<T>[]>;
|
|
|
|
|
export function all<T>(val: Input<T>[] | Record<string, Input<T>>): Output<any> {
|
|
|
|
|
if (val instanceof Array) {
|
|
|
|
|
const allOutputs = val.map(v => output(v));
|
|
|
|
@ -319,6 +324,61 @@ export type Input<T> = T | Promise<T> | Output<T>;
|
|
|
|
|
*/
|
|
|
|
|
export type Inputs = Record<string, Input<any>>;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The 'Wrap' type allows us to express the operation of taking a simple POJO type and augmenting it
|
|
|
|
|
* so that any values at any levels can be given as Promises or Outputs instead. Note that this
|
|
|
|
|
* wrapping is 'deep'. So, if you had:
|
|
|
|
|
*
|
|
|
|
|
* `type X = { A: { B: { C: boolean } } }`
|
|
|
|
|
*
|
|
|
|
|
* Then `Wrap<X>` would be equivalent to:
|
|
|
|
|
*
|
|
|
|
|
* `... = Input<{ A: Input<{ B: Input<{ C: Input<boolean> }> }> }>`
|
|
|
|
|
*
|
|
|
|
|
* This would then allow someone to pass in values where any of the top level object, or the 'A',
|
|
|
|
|
* 'B', or 'C' properties could be any mix of normal JavaScript values, [Promise]s, or [Output]s.
|
|
|
|
|
*
|
|
|
|
|
* The primary purpose of this type is to serve as the input type to a [Resource]. [Resource]s
|
|
|
|
|
* should define a simple POJO type defining what they accept, and then take in a
|
|
|
|
|
* `WrappedObject<ThatType>` as their arg. i.e.:
|
|
|
|
|
*
|
|
|
|
|
* ```ts
|
|
|
|
|
* interface CertificateArgs {
|
|
|
|
|
* readonly certificateBody: string;
|
|
|
|
|
* readonly certificateChain: string;
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* class Certificate extends pulumi.CustomResource {
|
|
|
|
|
* // ...
|
|
|
|
|
* constructor(name: string, args?: pulumi.WrappedObject<CertificateArgs>, opts?: pulumi.CustomResourceOptions);
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*
|
|
|
|
|
* This allows for a simple way to define the data that is needed, while giving maximum flexibility
|
|
|
|
|
* to the caller to pass in acceptable values.
|
|
|
|
|
*/
|
|
|
|
|
export type Wrap<T> =
|
|
|
|
|
// These first four values are to prevent TS from distributing Wrap over a union type
|
|
|
|
|
// if we can avoid it. i.e. if we have `T = string | number` then we want to get
|
|
|
|
|
// `Input<string | number>` not, `Input<string> | Input<number>`. The last four values
|
|
|
|
|
// are to catch things (even for union types if the first four don't match). i.e.
|
|
|
|
|
// if we have `T = string | Resource` then we get `Input<string> | Resource` not `never`.
|
|
|
|
|
[T] extends [Resource] ? T :
|
|
|
|
|
[T] extends [primitive] ? Input<T> :
|
|
|
|
|
[T] extends [Array<infer U1>] ? Input<WrappedArray<U1>> :
|
|
|
|
|
[T] extends [object] ? Input<WrappedObject<T>> :
|
|
|
|
|
T extends Resource ? T :
|
|
|
|
|
T extends primitive ? Input<T> :
|
|
|
|
|
T extends Array<infer U2> ? Input<WrappedArray<U2>> :
|
|
|
|
|
T extends object ? Input<WrappedObject<T>> :
|
|
|
|
|
never;
|
|
|
|
|
|
|
|
|
|
export interface WrappedArray<T> extends Array<Wrap<T>> { }
|
|
|
|
|
|
|
|
|
|
export type WrappedObject<T> = {
|
|
|
|
|
[P in keyof T]: Wrap<Exclude<T[P], undefined>>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The 'Unwrap' type allows us to express the operation of taking a type, with potentially deeply
|
|
|
|
|
* nested Promises and Outputs and to then get that same type with all the Promises and Outputs
|
|
|
|
|