Compare commits

...

2 commits

Author SHA1 Message Date
Pat Gavlin cf6076d6b0 fix, baselines, CL 2021-11-17 11:21:33 -08:00
Luke Hoban ae70447a18 Allow optional inputs to be Input<T | undefined>
The Node.js runtime accepts `Output<undefined>` values as inputs to
optional parameters, but the TypeScript typing currently does not
allow these. This extends the TypeScript typings to allow
`Output<undefined>` values as inputs to optional input properties.

I cannot think of any way in which this is breaking or would regress
any aspect of the TypeScript experience, other than making the `.d.ts`
files a little "noisier".

Fixes #6175.
2021-11-17 08:55:04 -08:00
58 changed files with 201 additions and 149 deletions

View file

@ -1,4 +1,10 @@
### Improvements
- [sdk/nodejs] - Type optional input properties as `Input<T | undefined> | undefined` instead of
`Input<T> | undefined`. This allows users to pass `Output<T | undefined>` for optional input
properties.
[#6323](https://github.com/pulumi/pulumi/pull/6323)
- Adds CI detector for Buildkite
[#7933](https://github.com/pulumi/pulumi/pull/7933)

View file

@ -60,5 +60,5 @@ export class ModuleResource extends pulumi.CustomResource {
* The set of arguments for constructing a ModuleResource resource.
*/
export interface ModuleResourceArgs {
thing?: pulumi.Input<inputs.TopLevelArgs>;
thing?: pulumi.Input<inputs.TopLevelArgs | undefined>;
}

View file

@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
export interface TopLevelArgs {
buzz?: pulumi.Input<string>;
buzz?: pulumi.Input<string | undefined>;
}

View file

@ -65,7 +65,7 @@ export interface NurseryArgs {
/**
* The sizes of trees available
*/
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>}>;
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>} | undefined>;
/**
* The varieties available
*/

View file

@ -75,16 +75,16 @@ export class RubberTree extends pulumi.CustomResource {
}
export interface RubberTreeState {
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
}
/**
* The set of arguments for constructing a RubberTree resource.
*/
export interface RubberTreeArgs {
container?: pulumi.Input<inputs.ContainerArgs>;
container?: pulumi.Input<inputs.ContainerArgs | undefined>;
diameter: pulumi.Input<enums.tree.v1.Diameter>;
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
size?: pulumi.Input<enums.tree.v1.TreeSize>;
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
size?: pulumi.Input<enums.tree.v1.TreeSize | undefined>;
type: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
}

View file

@ -5,8 +5,8 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types";
export interface ContainerArgs {
brightness?: pulumi.Input<enums.ContainerBrightness>;
color?: pulumi.Input<enums.ContainerColor | string>;
material?: pulumi.Input<string>;
brightness?: pulumi.Input<enums.ContainerBrightness | undefined>;
color?: pulumi.Input<enums.ContainerColor | string | undefined>;
material?: pulumi.Input<string | undefined>;
size: pulumi.Input<enums.ContainerSize>;
}

View file

@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
}
export interface ArgFunctionOutputArgs {
name?: pulumi.Input<pulumiRandom.RandomPet>;
name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
}

View file

@ -64,6 +64,6 @@ export class Cat extends pulumi.CustomResource {
* The set of arguments for constructing a Cat resource.
*/
export interface CatArgs {
age?: pulumi.Input<number>;
pet?: pulumi.Input<inputs.PetArgs>;
age?: pulumi.Input<number | undefined>;
pet?: pulumi.Input<inputs.PetArgs | undefined>;
}

View file

@ -83,9 +83,9 @@ export class Component extends pulumi.CustomResource {
* The set of arguments for constructing a Component resource.
*/
export interface ComponentArgs {
metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>;
metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>;
metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>;
metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs | undefined>;
metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[] | undefined>;
metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>} | undefined>;
requiredMetadata: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>;
requiredMetadataArray: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>;
requiredMetadataMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>;

View file

@ -7,10 +7,10 @@ import { input as inputs, output as outputs } from "../types";
import * as pulumiRandom from "@pulumi/random";
export interface PetArgs {
age?: pulumi.Input<number>;
name?: pulumi.Input<pulumiRandom.RandomPet>;
nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>;
nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>;
age?: pulumi.Input<number | undefined>;
name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[] | undefined>;
nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>} | undefined>;
requiredName: pulumi.Input<pulumiRandom.RandomPet>;
requiredNameArray: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>;
requiredNameMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>;

View file

@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource.
*/
export interface ResourceArgs {
baz?: pulumi.Input<string>;
baz?: pulumi.Input<string | undefined>;
}

View file

@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource.
*/
export interface ResourceArgs {
bar?: pulumi.Input<string>;
bar?: pulumi.Input<string | undefined>;
}

View file

@ -65,9 +65,9 @@ export interface ListConfigurationsOutputArgs {
/**
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
*/
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>;
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
/**
* $skipToken is supported on list of configurations, which provides the next page in the list of configurations.
*/
skipToken?: pulumi.Input<string>;
skipToken?: pulumi.Input<string | undefined>;
}

View file

@ -66,11 +66,11 @@ export interface ListProductFamiliesOutputArgs {
/**
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
*/
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>;
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
/**
* $expand is supported on configurations parameter for product, which provides details on the configurations for the product.
*/
expand?: pulumi.Input<string>;
expand?: pulumi.Input<string | undefined>;
/**
* Dictionary of filterable properties on product family.
*/
@ -78,5 +78,5 @@ export interface ListProductFamiliesOutputArgs {
/**
* $skipToken is supported on list of product families, which provides the next page in the list of product families.
*/
skipToken?: pulumi.Input<string>;
skipToken?: pulumi.Input<string | undefined>;
}

View file

@ -11,7 +11,7 @@ export interface ConfigurationFiltersArgs {
/**
* Filters specific to product
*/
filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[]>;
filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[] | undefined>;
/**
* Product hierarchy information
*/
@ -57,7 +57,7 @@ export interface CustomerSubscriptionDetailsArgs {
/**
* Location placement Id of a subscription
*/
locationPlacementId?: pulumi.Input<string>;
locationPlacementId?: pulumi.Input<string | undefined>;
/**
* Quota ID of a subscription
*/
@ -65,7 +65,7 @@ export interface CustomerSubscriptionDetailsArgs {
/**
* List of registered feature flags for subscription
*/
registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[]>;
registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[] | undefined>;
}
/**
@ -89,11 +89,11 @@ export interface CustomerSubscriptionRegisteredFeaturesArgs {
/**
* Name of subscription registered feature
*/
name?: pulumi.Input<string>;
name?: pulumi.Input<string | undefined>;
/**
* State of subscription registered feature
*/
state?: pulumi.Input<string>;
state?: pulumi.Input<string | undefined>;
}
/**
@ -153,18 +153,18 @@ export interface HierarchyInformationArgs {
/**
* Represents configuration name that uniquely identifies configuration
*/
configurationName?: pulumi.Input<string>;
configurationName?: pulumi.Input<string | undefined>;
/**
* Represents product family name that uniquely identifies product family
*/
productFamilyName?: pulumi.Input<string>;
productFamilyName?: pulumi.Input<string | undefined>;
/**
* Represents product line name that uniquely identifies product line
*/
productLineName?: pulumi.Input<string>;
productLineName?: pulumi.Input<string | undefined>;
/**
* Represents product name that uniquely identifies product
*/
productName?: pulumi.Input<string>;
productName?: pulumi.Input<string | undefined>;
}

View file

@ -88,13 +88,13 @@ export interface GetAmiIdsOutputArgs {
* Limit search to users with *explicit* launch
* permission on the image. Valid items are the numeric account ID or `self`.
*/
executableUsers?: pulumi.Input<pulumi.Input<string>[]>;
executableUsers?: pulumi.Input<pulumi.Input<string>[] | undefined>;
/**
* One or more name/value pairs to filter off of. There
* are several valid keys, for a full reference, check out
* [describe-images in the AWS CLI reference][1].
*/
filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[]>;
filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[] | undefined>;
/**
* A regex string to apply to the AMI list returned
* by AWS. This allows more advanced filtering not supported from the AWS API.
@ -102,7 +102,7 @@ export interface GetAmiIdsOutputArgs {
* impact if the result is large. It is recommended to combine this with other
* options to narrow down the list AWS returns.
*/
nameRegex?: pulumi.Input<string>;
nameRegex?: pulumi.Input<string | undefined>;
/**
* List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g. `amazon`, `aws-marketplace`, `microsoft`).
*/
@ -110,5 +110,5 @@ export interface GetAmiIdsOutputArgs {
/**
* Used to sort AMIs by creation time.
*/
sortAscending?: pulumi.Input<boolean>;
sortAscending?: pulumi.Input<boolean | undefined>;
}

View file

@ -61,7 +61,7 @@ export interface ListStorageAccountKeysOutputArgs {
/**
* Specifies type of the key to be listed. Possible value is kerb.
*/
expand?: pulumi.Input<string>;
expand?: pulumi.Input<string | undefined>;
/**
* The name of the resource group within the user's subscription. The name is case insensitive.
*/

View file

@ -45,9 +45,9 @@ export interface FuncWithAllOptionalInputsOutputArgs {
/**
* Property A
*/
a?: pulumi.Input<string>;
a?: pulumi.Input<string | undefined>;
/**
* Property B
*/
b?: pulumi.Input<string>;
b?: pulumi.Input<string | undefined>;
}

View file

@ -36,5 +36,5 @@ export function funcWithDefaultValueOutput(args: FuncWithDefaultValueOutputArgs,
export interface FuncWithDefaultValueOutputArgs {
a: pulumi.Input<string>;
b?: pulumi.Input<string>;
b?: pulumi.Input<string | undefined>;
}

View file

@ -36,6 +36,6 @@ export function funcWithDictParamOutput(args?: FuncWithDictParamOutputArgs, opts
}
export interface FuncWithDictParamOutputArgs {
a?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
b?: pulumi.Input<string>;
a?: pulumi.Input<{[key: string]: pulumi.Input<string>} | undefined>;
b?: pulumi.Input<string | undefined>;
}

View file

@ -36,6 +36,6 @@ export function funcWithListParamOutput(args?: FuncWithListParamOutputArgs, opts
}
export interface FuncWithListParamOutputArgs {
a?: pulumi.Input<pulumi.Input<string>[]>;
b?: pulumi.Input<string>;
a?: pulumi.Input<pulumi.Input<string>[] | undefined>;
b?: pulumi.Input<string | undefined>;
}

View file

@ -65,5 +65,5 @@ export interface GetBastionShareableLinkOutputArgs {
/**
* List of VM references.
*/
vms?: pulumi.Input<pulumi.Input<inputs.BastionShareableLinkArgs>[]>;
vms?: pulumi.Input<pulumi.Input<inputs.BastionShareableLinkArgs>[] | undefined>;
}

View file

@ -74,7 +74,7 @@ export interface GetIntegrationRuntimeObjectMetadatumOutputArgs {
/**
* Metadata path.
*/
metadataPath?: pulumi.Input<string>;
metadataPath?: pulumi.Input<string | undefined>;
/**
* The resource group name.
*/

View file

@ -61,7 +61,7 @@ export interface ListStorageAccountKeysOutputArgs {
/**
* Specifies type of the key to be listed. Possible value is kerb.
*/
expand?: pulumi.Input<string>;
expand?: pulumi.Input<string | undefined>;
/**
* The name of the resource group within the user's subscription. The name is case insensitive.
*/

View file

@ -98,11 +98,11 @@ export class ModuleResource extends pulumi.CustomResource {
* The set of arguments for constructing a ModuleResource resource.
*/
export interface ModuleResourceArgs {
optional_bool?: pulumi.Input<boolean>;
optional_const?: pulumi.Input<"val">;
optional_enum?: pulumi.Input<enums.EnumThing>;
optional_number?: pulumi.Input<number>;
optional_string?: pulumi.Input<string>;
optional_bool?: pulumi.Input<boolean | undefined>;
optional_const?: pulumi.Input<"val" | undefined>;
optional_enum?: pulumi.Input<enums.EnumThing | undefined>;
optional_number?: pulumi.Input<number | undefined>;
optional_string?: pulumi.Input<string | undefined>;
plain_optional_bool?: boolean;
plain_optional_const?: "val";
plain_optional_number?: number;

View file

@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
export interface FooArgs {
a?: pulumi.Input<boolean>;
a?: pulumi.Input<boolean | undefined>;
}

View file

@ -48,5 +48,5 @@ export interface ProviderArgs {
/**
* this is a relaxed string enum which can also be set via env var
*/
favoriteColor?: pulumi.Input<string | enums.Color>;
favoriteColor?: pulumi.Input<string | enums.Color | undefined>;
}

View file

@ -63,6 +63,6 @@ export class Person extends pulumi.CustomResource {
* The set of arguments for constructing a Person resource.
*/
export interface PersonArgs {
name?: pulumi.Input<string>;
pets?: pulumi.Input<pulumi.Input<inputs.PetArgs>[]>;
name?: pulumi.Input<string | undefined>;
pets?: pulumi.Input<pulumi.Input<inputs.PetArgs>[] | undefined>;
}

View file

@ -59,5 +59,5 @@ export class Pet extends pulumi.CustomResource {
* The set of arguments for constructing a Pet resource.
*/
export interface PetArgs {
name?: pulumi.Input<string>;
name?: pulumi.Input<string | undefined>;
}

View file

@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
export interface PetArgs {
name?: pulumi.Input<string>;
name?: pulumi.Input<string | undefined>;
}

View file

@ -63,6 +63,6 @@ export class Person extends pulumi.CustomResource {
* The set of arguments for constructing a Person resource.
*/
export interface PersonArgs {
name?: pulumi.Input<string>;
pets?: pulumi.Input<pulumi.Input<inputs.PetArgs>[]>;
name?: pulumi.Input<string | undefined>;
pets?: pulumi.Input<pulumi.Input<inputs.PetArgs>[] | undefined>;
}

View file

@ -59,5 +59,5 @@ export class Pet extends pulumi.CustomResource {
* The set of arguments for constructing a Pet resource.
*/
export interface PetArgs {
name?: pulumi.Input<string>;
name?: pulumi.Input<string | undefined>;
}

View file

@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
export interface PetArgs {
name?: pulumi.Input<string>;
name?: pulumi.Input<string | undefined>;
}

View file

@ -65,7 +65,7 @@ export interface NurseryArgs {
/**
* The sizes of trees available
*/
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>}>;
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>} | undefined>;
/**
* The varieties available
*/

View file

@ -75,16 +75,16 @@ export class RubberTree extends pulumi.CustomResource {
}
export interface RubberTreeState {
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
}
/**
* The set of arguments for constructing a RubberTree resource.
*/
export interface RubberTreeArgs {
container?: pulumi.Input<inputs.ContainerArgs>;
container?: pulumi.Input<inputs.ContainerArgs | undefined>;
diameter: pulumi.Input<enums.tree.v1.Diameter>;
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
size?: pulumi.Input<enums.tree.v1.TreeSize>;
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
size?: pulumi.Input<enums.tree.v1.TreeSize | undefined>;
type: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
}

View file

@ -5,8 +5,8 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types";
export interface ContainerArgs {
brightness?: pulumi.Input<enums.ContainerBrightness>;
color?: pulumi.Input<enums.ContainerColor | string>;
material?: pulumi.Input<string>;
brightness?: pulumi.Input<enums.ContainerBrightness | undefined>;
color?: pulumi.Input<enums.ContainerColor | string | undefined>;
material?: pulumi.Input<string | undefined>;
size: pulumi.Input<enums.ContainerSize>;
}

View file

@ -61,8 +61,8 @@ export namespace Foo {
* The set of arguments for the Foo.getKubeconfig method.
*/
export interface GetKubeconfigArgs {
profileName?: pulumi.Input<string>;
roleArn?: pulumi.Input<string>;
profileName?: pulumi.Input<string | undefined>;
roleArn?: pulumi.Input<string | undefined>;
}
/**

View file

@ -91,16 +91,16 @@ export namespace Foo {
* The set of arguments for the Foo.bar method.
*/
export interface BarArgs {
baz?: pulumi.Input<inputs.nested.BazArgs>;
baz?: pulumi.Input<inputs.nested.BazArgs | undefined>;
bazPlain?: inputs.nested.BazArgs;
bazRequired: pulumi.Input<inputs.nested.BazArgs>;
boolValue?: pulumi.Input<boolean>;
boolValue?: pulumi.Input<boolean | undefined>;
boolValuePlain?: boolean;
boolValueRequired: pulumi.Input<boolean>;
name?: pulumi.Input<pulumiRandom.RandomPet>;
name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
namePlain?: pulumiRandom.RandomPet;
nameRequired: pulumi.Input<pulumiRandom.RandomPet>;
stringValue?: pulumi.Input<string>;
stringValue?: pulumi.Input<string | undefined>;
stringValuePlain?: string;
stringValueRequired: pulumi.Input<string>;
}

View file

@ -11,7 +11,7 @@ export namespace nested {
}
export interface BazArgs {
hello?: pulumi.Input<string>;
world?: pulumi.Input<string>;
hello?: pulumi.Input<string | undefined>;
world?: pulumi.Input<string | undefined>;
}
}

View file

@ -89,5 +89,5 @@ export interface ComponentArgs {
d?: number;
e: string;
f?: string;
foo?: pulumi.Input<inputs.FooArgs>;
foo?: pulumi.Input<inputs.FooArgs | undefined>;
}

View file

@ -91,5 +91,5 @@ export interface ComponentArgs {
d?: number;
e: string;
f?: string;
foo?: pulumi.Input<inputs.FooArgs>;
foo?: pulumi.Input<inputs.FooArgs | undefined>;
}

View file

@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
}
export interface ArgFunctionOutputArgs {
arg1?: pulumi.Input<Resource>;
arg1?: pulumi.Input<Resource | undefined>;
}

View file

@ -49,5 +49,5 @@ export class OtherResource extends pulumi.ComponentResource {
* The set of arguments for constructing a OtherResource resource.
*/
export interface OtherResourceArgs {
foo?: pulumi.Input<Resource>;
foo?: pulumi.Input<Resource | undefined>;
}

View file

@ -59,5 +59,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource.
*/
export interface ResourceArgs {
bar?: pulumi.Input<string>;
bar?: pulumi.Input<string | undefined>;
}

View file

@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
}
export interface ArgFunctionOutputArgs {
arg1?: pulumi.Input<Resource>;
arg1?: pulumi.Input<Resource | undefined>;
}

View file

@ -49,5 +49,5 @@ export class OtherResource extends pulumi.ComponentResource {
* The set of arguments for constructing a OtherResource resource.
*/
export interface OtherResourceArgs {
foo?: pulumi.Input<Resource>;
foo?: pulumi.Input<Resource | undefined>;
}

View file

@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource.
*/
export interface ResourceArgs {
bar?: pulumi.Input<string>;
bar?: pulumi.Input<string | undefined>;
}

View file

@ -68,7 +68,7 @@ export class TypeUses extends pulumi.CustomResource {
* The set of arguments for constructing a TypeUses resource.
*/
export interface TypeUsesArgs {
bar?: pulumi.Input<inputs.SomeOtherObjectArgs>;
baz?: pulumi.Input<inputs.ObjectWithNodeOptionalInputsArgs>;
foo?: pulumi.Input<inputs.ObjectArgs>;
bar?: pulumi.Input<inputs.SomeOtherObjectArgs | undefined>;
baz?: pulumi.Input<inputs.ObjectWithNodeOptionalInputsArgs | undefined>;
foo?: pulumi.Input<inputs.ObjectArgs | undefined>;
}

View file

@ -7,28 +7,28 @@ import { input as inputs, output as outputs } from "../types";
import {Resource} from "..";
export interface ConfigMapArgs {
config?: pulumi.Input<string>;
config?: pulumi.Input<string | undefined>;
}
export interface ObjectArgs {
bar?: pulumi.Input<string>;
configs?: pulumi.Input<pulumi.Input<inputs.ConfigMapArgs>[]>;
foo?: pulumi.Input<Resource>;
bar?: pulumi.Input<string | undefined>;
configs?: pulumi.Input<pulumi.Input<inputs.ConfigMapArgs>[] | undefined>;
foo?: pulumi.Input<Resource | undefined>;
/**
* List of lists of other objects
*/
others?: pulumi.Input<pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>[]>;
others?: pulumi.Input<pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>[] | undefined>;
/**
* Mapping from string to list of some other object
*/
stillOthers?: pulumi.Input<{[key: string]: pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>}>;
stillOthers?: pulumi.Input<{[key: string]: pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>} | undefined>;
}
export interface ObjectWithNodeOptionalInputsArgs {
bar?: pulumi.Input<number>;
foo?: pulumi.Input<string>;
bar?: pulumi.Input<number | undefined>;
foo?: pulumi.Input<string | undefined>;
}
export interface SomeOtherObjectArgs {
baz?: pulumi.Input<string>;
baz?: pulumi.Input<string | undefined>;
}

View file

@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
}
export interface ArgFunctionOutputArgs {
arg1?: pulumi.Input<Resource>;
arg1?: pulumi.Input<Resource | undefined>;
}

View file

@ -51,5 +51,5 @@ export class OtherResource extends pulumi.ComponentResource {
*/
export interface OtherResourceArgs {
bar?: pulumi.Input<string>[];
foo?: pulumi.Input<Resource>;
foo?: pulumi.Input<Resource | undefined>;
}

View file

@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource.
*/
export interface ResourceArgs {
bar?: pulumi.Input<string>;
bar?: pulumi.Input<string | undefined>;
}

View file

@ -71,8 +71,8 @@ export class TypeUses extends pulumi.CustomResource {
* The set of arguments for constructing a TypeUses resource.
*/
export interface TypeUsesArgs {
bar?: pulumi.Input<inputs.SomeOtherObjectArgs>;
baz?: pulumi.Input<inputs.ObjectWithNodeOptionalInputsArgs>;
foo?: pulumi.Input<inputs.ObjectArgs>;
qux?: pulumi.Input<enums.RubberTreeVariety>;
bar?: pulumi.Input<inputs.SomeOtherObjectArgs | undefined>;
baz?: pulumi.Input<inputs.ObjectWithNodeOptionalInputsArgs | undefined>;
foo?: pulumi.Input<inputs.ObjectArgs | undefined>;
qux?: pulumi.Input<enums.RubberTreeVariety | undefined>;
}

View file

@ -7,28 +7,28 @@ import { input as inputs, output as outputs, enums } from "../types";
import {Resource} from "..";
export interface ConfigMapArgs {
config?: pulumi.Input<string>;
config?: pulumi.Input<string | undefined>;
}
export interface ObjectArgs {
bar?: pulumi.Input<string>;
configs?: pulumi.Input<pulumi.Input<inputs.ConfigMapArgs>[]>;
foo?: pulumi.Input<Resource>;
bar?: pulumi.Input<string | undefined>;
configs?: pulumi.Input<pulumi.Input<inputs.ConfigMapArgs>[] | undefined>;
foo?: pulumi.Input<Resource | undefined>;
/**
* List of lists of other objects
*/
others?: pulumi.Input<pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>[]>;
others?: pulumi.Input<pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>[] | undefined>;
/**
* Mapping from string to list of some other object
*/
stillOthers?: pulumi.Input<{[key: string]: pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>}>;
stillOthers?: pulumi.Input<{[key: string]: pulumi.Input<pulumi.Input<inputs.SomeOtherObjectArgs>[]>} | undefined>;
}
export interface ObjectWithNodeOptionalInputsArgs {
bar?: pulumi.Input<number>;
foo?: pulumi.Input<string>;
bar?: pulumi.Input<number | undefined>;
foo?: pulumi.Input<string | undefined>;
}
export interface SomeOtherObjectArgs {
baz?: pulumi.Input<string>;
baz?: pulumi.Input<string | undefined>;
}

View file

@ -58,7 +58,7 @@
"plain": "map[string]string"
},
"nodejs": {
"input": "pulumi.Input<{[key: string]: pulumi.Input<string>}> | undefined",
"input": "pulumi.Input<{[key: string]: pulumi.Input<string>} | undefined> | undefined",
"plain": "{[key: string]: string} | undefined"
},
"python": {
@ -114,7 +114,7 @@
"plain": "pulumi.Archive"
},
"nodejs": {
"input": "pulumi.Input<pulumi.asset.Archive> | undefined",
"input": "pulumi.Input<pulumi.asset.Archive | undefined> | undefined",
"plain": "pulumi.asset.Archive | undefined"
},
"python": {
@ -139,7 +139,7 @@
"plain": "pulumi.AssetOrArchive"
},
"nodejs": {
"input": "pulumi.Input<pulumi.asset.Asset | pulumi.asset.Archive> | undefined",
"input": "pulumi.Input<pulumi.asset.Asset | pulumi.asset.Archive | undefined> | undefined",
"plain": "pulumi.asset.Asset | pulumi.asset.Archive | undefined"
},
"python": {
@ -164,7 +164,7 @@
"plain": "*bool"
},
"nodejs": {
"input": "pulumi.Input<boolean> | undefined",
"input": "pulumi.Input<boolean | undefined> | undefined",
"plain": "boolean | undefined"
},
"python": {
@ -189,7 +189,7 @@
"plain": "*int"
},
"nodejs": {
"input": "pulumi.Input<number> | undefined",
"input": "pulumi.Input<number | undefined> | undefined",
"plain": "number | undefined"
},
"python": {
@ -239,7 +239,7 @@
"plain": "*float64"
},
"nodejs": {
"input": "pulumi.Input<number> | undefined",
"input": "pulumi.Input<number | undefined> | undefined",
"plain": "number | undefined"
},
"python": {
@ -464,7 +464,7 @@
"plain": "*string"
},
"nodejs": {
"input": "pulumi.Input<string> | undefined",
"input": "pulumi.Input<string | undefined> | undefined",
"plain": "string | undefined"
},
"python": {
@ -508,7 +508,7 @@
"plain": "map[string]string"
},
"nodejs": {
"input": "pulumi.Input<{[key: string]: pulumi.Input<string>}> | undefined",
"input": "pulumi.Input<{[key: string]: pulumi.Input<string>} | undefined> | undefined",
"plain": "{[key: string]: string} | undefined"
},
"python": {
@ -549,7 +549,7 @@
"plain": "interface{}"
},
"nodejs": {
"input": "pulumi.Input<outputs.ObjectArgs | any[]> | undefined",
"input": "pulumi.Input<outputs.ObjectArgs | any[] | undefined> | undefined",
"plain": "outputs.Object | any[] | undefined"
},
"python": {

View file

@ -39,6 +39,14 @@ func Identifier(id string) TypeAst {
return &idType{id}
}
// IsIdentifier returns true if the AST node is an identifier.
func IsIdentifier(t TypeAst) (string, bool) {
if i, ok := t.(*idType); ok {
return i.id, true
}
return "", false
}
// Builds a `T[]` type from a `T` type.
func Array(t TypeAst) TypeAst {
return &arrayType{t}
@ -60,6 +68,14 @@ func Union(t ...TypeAst) TypeAst {
return &unionType{t[0], t[1], t[2:]}
}
// IsUnion returns true if the AST node is a union.
func IsUnion(t TypeAst) ([]TypeAst, bool) {
if union, ok := t.(*unionType); ok {
return union.all(), true
}
return nil, false
}
// Normalizes by unnesting unions `A | (B | C) => A | B | C`.
func Normalize(ast TypeAst) TypeAst {
return transform(ast, func(t TypeAst) TypeAst {

View file

@ -277,16 +277,38 @@ func tokenToFunctionName(tok string) string {
func (mod *modContext) typeAst(t schema.Type, input bool, constValue interface{}) tstypes.TypeAst {
switch t := t.(type) {
case *schema.OptionalType:
// Treat optional(input(T)) as optional(input(optional(T))).
elementType := t.ElementType
if input, isInput := elementType.(*schema.InputType); isInput {
elementType = &schema.InputType{
ElementType: &schema.OptionalType{
ElementType: input.ElementType,
},
}
}
return tstypes.Union(
mod.typeAst(t.ElementType, input, constValue),
mod.typeAst(elementType, input, constValue),
tstypes.Identifier("undefined"),
)
case *schema.InputType:
typ := mod.typeString(codegen.SimplifyInputUnion(t.ElementType), input, constValue)
if typ == "any" {
return tstypes.Identifier("any")
elementType := t.ElementType
optional, isOptional := elementType.(*schema.OptionalType)
if isOptional {
elementType = optional.ElementType
}
return tstypes.Identifier(fmt.Sprintf("pulumi.Input<%s>", typ))
typ := mod.typeAst(codegen.SimplifyInputUnion(elementType), input, constValue)
if id, ok := tstypes.IsIdentifier(typ); ok && id == "any" {
return typ
}
if isOptional {
typ = tstypes.Union(typ, tstypes.Identifier("undefined"))
}
typeArgument := tstypes.TypeLiteral(tstypes.Normalize(typ))
return tstypes.Identifier(fmt.Sprintf("pulumi.Input<%s>", typeArgument))
case *schema.EnumType:
return tstypes.Identifier(mod.objectType(nil, nil, t.Token, input, false, true))
case *schema.ArrayType:
@ -410,13 +432,15 @@ func (mod *modContext) genPlainType(w io.Writer, name, comment string, propertie
prefix = "readonly "
}
sigil, propertyType := "", p.Type
if !p.IsRequired() {
sigil, propertyType = "?", codegen.RequiredType(p)
sigil, typ := "", mod.typeAst(p.Type, input, p.ConstValue)
if types, ok := tstypes.IsUnion(typ); ok {
if id, ok := tstypes.IsIdentifier(types[len(types)-1]); ok && id == "undefined" {
sigil, typ = "?", tstypes.Union(types[:len(types)-1]...)
}
}
typ := mod.typeString(propertyType, input, p.ConstValue)
fmt.Fprintf(w, "%s %s%s%s: %s;\n", indent, prefix, p.Name, sigil, typ)
typLit := tstypes.TypeLiteral(tstypes.Normalize(typ))
fmt.Fprintf(w, "%s %s%s%s: %s;\n", indent, prefix, p.Name, sigil, typLit)
}
fmt.Fprintf(w, "%s}\n", indent)
}

View file

@ -13,8 +13,8 @@
// limitations under the License.
import * as assert from "assert";
import { ComponentResource, CustomResource, DependencyResource, Inputs, Output, Resource, ResourceOptions, runtime,
secret } from "../../index";
import { ComponentResource, CustomResource, DependencyResource, Input, Inputs, Output, Resource, ResourceOptions,
output, runtime, secret } from "../../index";
import { asyncTest } from "../util";
const gstruct = require("google-protobuf/google/protobuf/struct_pb.js");
@ -114,7 +114,9 @@ type TestBoolEnum = (typeof TestBoolEnum)[keyof typeof TestBoolEnum];
interface TestInputs {
aNum: number;
bStr: string;
bStrInput: Input<string>;
cUnd: undefined;
cUndInput: Input<undefined>;
dArr: Promise<Array<any>>;
id: string;
urn: string;
@ -207,16 +209,18 @@ describe("runtime", () => {
it("marshals basic properties correctly", asyncTest(async () => {
const inputs: TestInputs = {
"aNum": 42,
"bStr": "a string",
"cUnd": undefined,
"dArr": Promise.resolve([ "x", 42, Promise.resolve(true), Promise.resolve(undefined) ]),
"id": "foo",
"urn": "bar",
"strEnum": TestStrEnum.Foo,
"intEnum": TestIntEnum.One,
"numEnum": TestNumEnum.One,
"boolEnum": TestBoolEnum.One,
aNum: 42,
bStr: "a string",
bStrInput: output("a string"),
cUnd: undefined,
cUndInput: output(undefined),
dArr: Promise.resolve([ "x", 42, Promise.resolve(true), Promise.resolve(undefined) ]),
id: "foo",
urn: "bar",
strEnum: TestStrEnum.Foo,
intEnum: TestIntEnum.One,
numEnum: TestNumEnum.One,
boolEnum: TestBoolEnum.One,
};
// Serialize and then deserialize all the properties, checking that they round-trip as expected.
const transfer = gstruct.Struct.fromJavaScript(
@ -224,7 +228,9 @@ describe("runtime", () => {
const result = runtime.deserializeProperties(transfer);
assert.strictEqual(result.aNum, 42);
assert.strictEqual(result.bStr, "a string");
assert.strictEqual(result.bStrInput, "a string");
assert.strictEqual(result.cUnd, undefined);
assert.strictEqual(result.cUndInput, undefined);
assert.deepStrictEqual(result.dArr, [ "x", 42, true, null ]);
assert.strictEqual(result.id, "foo");
assert.strictEqual(result.urn, "bar");