import { Resource } from "./resource"; /** * [output] takes any Input value and converts it into an Output, deeply unwrapping nested Input * values as necessary. * * The expected way to use this function is like so: * * ```ts * var transformed = pulumi.output(someVal).apply(unwrapped => { * // Do whatever you want now. 'unwrapped' will contain no outputs/promises inside * // here, so you can easily do whatever sort of transformation is most convenient. * }); * * // the result can be passed to another Resource. The dependency information will be * // properly maintained. * var someResource = new SomeResource(name, { data: transformed ... }); * ``` */ export declare function output(val: Input): Output>; export declare function output(val: Input | undefined): Output>; /** * [secret] behaves the same as [output] except the returned output is marked as containing sensitive data. */ export declare function secret(val: Input): Output>; export declare function secret(val: Input | undefined): Output>; /** * [unsecret] behaves the same as [output] except the returned output takes the existing output and unwraps the secret */ export declare function unsecret(val: Output): Output; export declare function isSecret(val: Output): Promise; /** * Allows for multiple Output objects to be combined into a single Output object. The single Output * will depend on the union of Resources that the individual dependencies depend on. * * This can be used in the following manner: * * ```ts * var d1: Output; * var d2: Output; * * var d3: Output = Output.all([d1, d2]).apply(([s, n]) => ...); * ``` * * In this example, taking a dependency on d3 means a resource will depend on all the resources of * d1 and d2. */ export declare function all(val: Record>): Output>>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap, Unwrap]>; export declare function all(values: [Input | undefined, Input | undefined]): Output<[Unwrap, Unwrap]>; export declare function all(ds: (Input | undefined)[]): Output[]>; /** * isUnknown returns true if the given value is unknown. */ export declare function isUnknown(val: any): boolean; /** * containsUnknowns returns true if the given value is or contains unknown values. */ export declare function containsUnknowns(value: any): boolean; /** * [Input] is a property input for a resource. It may be a promptly available T, a promise for one, * or the output from a existing Resource. */ export declare type Input = T | Promise | OutputInstance; /** * [Inputs] is a map of property name to property input, one for each resource property value. */ export declare type Inputs = Record>; /** * 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 * replaced with their wrapped type. Note that this Unwrapping is 'deep'. So if you had: * * `type X = { A: Promise<{ B: Output<{ c: Input }> }> }` * * Then `Unwrap` would be equivalent to: * * `... = { A: { B: { C: boolean } } }` * * Unwrapping sees through Promises, Outputs, Arrays and Objects. * * Note: due to TypeScript limitations there are some things that cannot be expressed. Specifically, * if you had a `Promise>` then the Unwrap type would not be able to undo both of those * wraps. In practice that should be ok. Values in an object graph should not wrap Outputs in * Promises. Instead, any code that needs to work Outputs and also be async should either create * the Output with the Promise (which will collapse into just an Output). Or, it should start with * an Output and call [apply] on it, passing in an async function. This will also collapse and just * produce an Output. * * In other words, this should not be used as the shape of an object: `{ a: Promise> }`. * It should always either be `{ a: Promise }` or just `{ a: Output<...> }`. */ export declare type Unwrap = T extends Promise ? UnwrapSimple : T extends OutputInstance ? UnwrapSimple : UnwrapSimple; declare type primitive = Function | string | number | boolean | undefined | null; /** * Handles encountering basic types when unwrapping. */ export declare type UnwrapSimple = T extends primitive ? T : T extends Resource ? T : T extends Array ? UnwrappedArray : T extends object ? UnwrappedObject : never; export interface UnwrappedArray extends Array> { } export declare type UnwrappedObject = { [P in keyof T]: Unwrap; }; /** * Instance side of the [Output] type. Exposes the deployment-time and run-time mechanisms * for working with the underlying value of an [Output]. */ export interface OutputInstance { /** * Transforms the data of the output with the provided func. The result remains a * Output so that dependent resources can be properly tracked. * * 'func' is not allowed to make resources. * * 'func' can return other Outputs. This can be handy if you have a Output * and you want to get a transitive dependency of it. i.e. * * ```ts * var d1: Output; * var d2 = d1.apply(v => v.x.y.OtherOutput); // getting an output off of 'v'. * ``` * * In this example, taking a dependency on d2 means a resource will depend on all the resources * of d1. It will *also* depend on the resources of v.x.y.OtherDep. * * Importantly, the Resources that d2 feels like it will depend on are the same resources as d1. * If you need have multiple Outputs and a single Output is needed that combines both * set of resources, then 'pulumi.all' should be used instead. * * This function will only be called execution of a 'pulumi up' request. It will not run * during 'pulumi preview' (as the values of resources are of course not known then). It is not * available for functions that end up executing in the cloud during runtime. To get the value * of the Output during cloud runtime execution, use `get()`. */ apply(func: (t: T) => Promise): Output; apply(func: (t: T) => OutputInstance): Output; apply(func: (t: T) => U): Output; /** * Retrieves the underlying value of this dependency. * * This function is only callable in code that runs in the cloud post-deployment. At this * point all Output values will be known and can be safely retrieved. During pulumi deployment * or preview execution this must not be called (and will throw). This is because doing so * would allow Output values to flow into Resources while losing the data that would allow * the dependency graph to be changed. */ get(): T; } /** * Static side of the [Output] type. Can be used to [create] Outputs as well as test * arbitrary values to see if they are [Output]s. */ export interface OutputConstructor { create(val: Input): Output>; create(val: Input | undefined): Output>; isInstance(obj: any): obj is Output; } /** * [Output] helps encode the relationship between Resources in a Pulumi application. Specifically an * [Output] holds onto a piece of Data and the Resource it was generated from. An [Output] value can * then be provided when constructing new Resources, allowing that new Resource to know both the * value as well as the Resource the value came from. This allows for a precise 'Resource * dependency graph' to be created, which properly tracks the relationship between resources. * * An [Output] is used in a Pulumi program differently depending on if the application is executing * at 'deployment time' (i.e. when actually running the 'pulumi' executable), or at 'run time' (i.e. * a piece of code running in some Cloud). * * At 'deployment time', the correct way to work with the underlying value is to call * [Output.apply(func)]. This allows the value to be accessed and manipulated, while still * resulting in an [Output] that is keeping track of [Resource]s appropriately. At deployment time * the underlying value may or may not exist (for example, if a preview is being performed). In * this case, the 'func' callback will not be executed, and calling [.apply] will immediately return * an [Output] that points to the [undefined] value. During a normal [update] though, the 'func' * callbacks should always be executed. * * At 'run time', the correct way to work with the underlying value is to simply call [Output.get] * which will be promptly return the entire value. This will be a simple JavaScript object that can * be manipulated as necessary. * * To ease with using [Output]s at 'deployment time', pulumi will 'lift' simple data properties of * an underlying value to the [Output] itself. For example: * * ```ts * const o: Output<{ name: string, age: number, orders: Order[] }> = ...; * const name : Output = o.name; * const age : Output = o.age; * const first: Output = o.orders[0]; * ``` * * Instead of having to write: * * ```ts * const o: Output<{ name: string, age: number, orders: Order[] }> = ...; * const name : Output = o.apply(v => v.name); * const age : Output = o.apply(v => v.age); * const first: Output = o.apply(v => v.orders[0]); * ``` */ export declare type Output = OutputInstance & Lifted; export declare const Output: OutputConstructor; /** * The [Lifted] type allows us to express the operation of taking a type, with potentially deeply * nested objects and arrays and to then get a type with the same properties, except whose property * types are now [Output]s of the original property type. * * For example: * * * `type X = { A: string, B: { c: boolean } }` * * Then `Lifted` would be equivalent to: * * `... = { A: Output, B: Output<{ C: Output }> }` * * [Lifted] is somewhat the opposite of [Unwrap]. It's primary purpose is to allow an instance of * [Output] to provide simple access to the properties of [SomeType] directly on the instance * itself (instead of haveing to use [.apply]). * * This lifting only happens through simple pojo objects and arrays. Functions, for example, are not * lifted. So you cannot do: * * ```ts * const o: Output = ...; * const c: Output = o.charCodeAt(0); * ``` * * Instead, you still need to write; * * ```ts * const o: Output = ...; * const c: Output = o.apply(v => v.charCodeAt(0)); * ``` */ export declare type Lifted = T extends string ? LiftedObject> : T extends Array ? LiftedArray : T extends object ? LiftedObject> : {}; declare type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]; export declare type LiftedObject = { [P in K]: T[P] extends OutputInstance ? Output : T[P] extends Promise ? Output : Output; }; export declare type LiftedArray = { /** * Gets the length of the array. This is a number one higher than the highest element defined * in an array. */ readonly length: Output; readonly [n: number]: Output; }; /** * [concat] takes a sequence of [Inputs], stringifies each, and concatenates all values into one * final string. Individual inputs can be any sort of [Input] value. i.e. they can be [Promise]s, * [Output]s, or just plain JavaScript values. This can be used like so: * * ```ts * // 'server' and 'loadBalancer' are both resources that expose [Output] properties. * let val: Output = pulumi.concat("http://", server.hostname, ":", loadBalancer.port); * ``` * */ export declare function concat(...params: Input[]): Output; /** * [interpolate] is similar to [concat] but is designed to be used as a tagged template expression. * i.e.: * * ```ts * // 'server' and 'loadBalancer' are both resources that expose [Output] properties. * let val: Output = pulumi.interpolate `http://${server.hostname}:${loadBalancer.port}` * ``` * * As with [concat] the 'placeholders' between `${}` can be any Inputs. i.e. they can be * [Promise]s, [Output]s, or just plain JavaScript values. */ export declare function interpolate(literals: TemplateStringsArray, ...placeholders: Input[]): Output; export {};