diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 810762041e05..435216de24ed 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1497,7 +1497,7 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{} referencesNestedTypes := mod.getImports(variables, externalImports, imports) - mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(w, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) fmt.Fprintf(w, "declare var exports: any;\n") @@ -1537,64 +1537,80 @@ func (mod *modContext) genConfig(w io.Writer, variables []*schema.Property) erro return nil } -func (mod *modContext) getRelativePath(dirRoot string) string { - var currPath string - if dirRoot == "" { - currPath = mod.mod - } else { - currPath = dirRoot - } - rel, err := filepath.Rel(currPath, "") +// getRelativePath returns a path to the top level of the package +// relative to directory passed in. You must pass in the name +// of a directory. If you provide a file name, like "index.ts", it's assumed +// to be a directory named "index.ts". +// It's a thin wrapper around the standard library's implementation. +func getRelativePath(dirname string) string { + var rel, err = filepath.Rel(dirname, "") contract.Assert(err == nil) return path.Dir(filepath.ToSlash(rel)) } -func (mod *modContext) sdkImports(nested, utilities bool, dirRoot string) []string { - imports := []string{"import * as pulumi from \"@pulumi/pulumi\";"} +// The parameter dirRoot is used as the relative path +func (mod *modContext) getRelativePath() string { + return getRelativePath(mod.mod) +} - // TODO: Skip writing sdkImports for types.inputs/types.outputs as special case. - relRoot := mod.getRelativePath(dirRoot) - // If this file is generating inputs in /types/, then it will be one level - // lower than otherwise. - // if typegen { - // relRoot = path.Join("..", relRoot) - // } - fmt.Printf("Mod: %s -- relRoot: %s\n", mod.mod, relRoot) - if nested { - // TODO: If we're nested, we need to know HOW FAR we're nested! - // this is only for nested TYPE outputs/inputs. Those are - // potentially nested but ALSO nested wthin the types file, - // which makes matters worse since they could be nested even deeper. - imports = append(imports, []string{ - fmt.Sprintf(`import * as inputs from "%s/types/input";`, relRoot), - fmt.Sprintf(`import * as outputs from "%s/types/output";`, relRoot), - }...) +// sdkImports generates the imports at the top of a source file. +// This function is only intended to be called from resource files and +// at the index. For files nested in the `/types` folder, call +// sdkImportsForTypes instead. +func (mod *modContext) sdkImports(nested, utilities bool) []string { + return mod.sdkImportsWithPath(nested, utilities, mod.mod) +} - if mod.pkg.Language["nodejs"].(NodePackageInfo).ContainsEnums { - code := `import * as enums from "%s/types/enums";` - if lookupNodePackageInfo(mod.pkg).UseTypeOnlyReferences { - code = `import type * as enums from "%s/types/enums";` - } - imports = append(imports, fmt.Sprintf(code, relRoot)) - } +// sdkImportsWithPath generates the import functions at the top of each file. +// If nested is true, then the file is assumed not to be at the top-level i.e. +// it's located in a subfolder of the root, perhaps deeply nested. +// If utilities is true, then utility functions are imported. +// dirpath injects the directory name of the input file relative to the root of the package. +func (mod *modContext) sdkImportsWithPath(nested, utilities bool, dirpath string) []string { + // All files need to import the SDK. + var imports = []string{"import * as pulumi from \"@pulumi/pulumi\";"} + var relRoot = getRelativePath(dirpath) + // Add nested imports if enabled. + if nested { + imports = append(imports, mod.genNestedImports(relRoot)...) } - + // Add utility imports if enabled. if utilities { - imports = append(imports, mod.utilitiesImport()) + imports = append(imports, mod.utilitiesImport(relRoot)) } return imports } -func (mod *modContext) utilitiesImport() string { - relRoot := mod.getRelativePath("") +func (mod *modContext) utilitiesImport(relRoot string) string { return fmt.Sprintf("import * as utilities from \"%s/utilities\";", relRoot) } +// relRoot is the path that ajoins this module or file with the top-level +// of the repo. For example, if this file was located in "./foo/index.ts", +// then relRoot would be "..", since that's the path to the top-level directory. +func (mod *modContext) genNestedImports(relRoot string) []string { + // Always import all input and output types. + var imports = []string{ + fmt.Sprintf(`import * as inputs from "%s/types/input";`, relRoot), + fmt.Sprintf(`import * as outputs from "%s/types/output";`, relRoot), + } + // Next, if there are enums, then we import them too. + if mod.pkg.Language["nodejs"].(NodePackageInfo).ContainsEnums { + code := `import * as enums from "%s/types/enums";` + if lookupNodePackageInfo(mod.pkg).UseTypeOnlyReferences { + code = `import type * as enums from "%s/types/enums";` + } + imports = append(imports, fmt.Sprintf(code, relRoot)) + } + return imports +} + +// the parameter defaultNs is expected to be the top-level namespace. +// If its nil, then we skip importing types files, since they will not exist. func (mod *modContext) buildImports() (codegen.StringSet, map[string]codegen.StringSet) { var externalImports = codegen.NewStringSet() var imports = map[string]codegen.StringSet{} - var hasDefaultObjects bool for _, t := range mod.types { if t.IsOverlay { // This type is generated by the provider, so no further action is required. @@ -1602,14 +1618,6 @@ func (mod *modContext) buildImports() (codegen.StringSet, map[string]codegen.Str } mod.getImports(t, externalImports, imports) - if codegen.IsProvideDefaultsFuncRequired(t) { - hasDefaultObjects = true - } - } - // Instantiating the default might require an environmental variable. This - // uses utilities. - if hasDefaultObjects { - externalImports.Add(fmt.Sprintf("import * as utilities from \"%s/utilities\";", mod.getRelativePath(""))) } return externalImports, imports } @@ -1618,11 +1626,11 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { var ( inputFiles, outputFiles []*ioFile err error - // Fetch the collection of imports needed by these modules. - externalImports, imports = mod.buildImports() // Build a file tree out of the types, then emit them. namespaces = mod.getNamespaces() - buildCtx = func(input bool) *ioContext { + // Fetch the collection of imports needed by these modules. + externalImports, imports = mod.buildImports() + buildCtx = func(input bool) *ioContext { return &ioContext{ mod: mod, input: input, @@ -1634,6 +1642,11 @@ func (mod *modContext) genTypes() ([]*ioFile, error) { inputCtx = buildCtx(true) outputCtx = buildCtx(false) ) + // If there are no namespaces, then we generate empty + // input and output files. + if namespaces[""] == nil { + return nil, fmt.Errorf("Encountered a nil top-level namespace. The top-level namespace cannot be nil, even if it is empty.") + } // Iterate through the namespaces, generating one per node in the tree. if inputFiles, err = namespaces[""].intoIOFiles(inputCtx, "./types"); err != nil { return nil, err @@ -1686,12 +1699,12 @@ type ioContext struct { // The parameters in ctx are stable regardless of the depth of recursion, // but parent is expected to change with each recursive call. func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, error) { - // We generate the input and output namespaces when there are enums, regardless of i - // they are empty. + // We generate the input and output namespaces when there are enums, + // regardless of whether they are empty. if ns == nil { - panic("TODO: The caller needs to check if this is nil or not first.") + return nil, fmt.Errorf("Generating IO files for a nil namespace") } - fmt.Println(ns.Debug()) + // Declare a new file to store the contents exposed at this directory level. var dirRoot = path.Join(parent, ns.name) var filename string @@ -1700,10 +1713,14 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro } else { filename = path.Join(dirRoot, "output.ts") } - fmt.Printf("Generating namespace into IO file: %s\n", filename) var file = newIOFile(filename) // We start every file with the header information. - ctx.mod.genHeader(file.writer(), ctx.mod.sdkImports(true, false, dirRoot), ctx.externalImports, ctx.imports) + ctx.mod.genHeader( + file.writer(), + ctx.mod.sdkImportsWithPath(true, true, dirRoot), + ctx.externalImports, + ctx.imports, + ) // We want to organize the items in the source file by alphabetical order. sort.Slice(ns.types, func(i, j int) bool { return tokenToName(ns.types[i].Token) < tokenToName(ns.types[j].Token) @@ -1733,13 +1750,14 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro return ns.children[i].name < ns.children[j].name }) for i, child := range ns.children { + // Defensive coding: child should never be null, but + // child.intoIOFiles will break if it is. + if child == nil { + continue + } // At this level, we export any nested definitions from // the next level. - var fullPath = path.Join(dirRoot, child.name) - fmt.Printf("-----> Exporting file %s with parent %s\n", fullPath, dirRoot) - //fmt.Fprintf(file.writer(), "export * as %s from \"%s\";\n", child.name, fullPath) fmt.Fprintf(file.writer(), "export * as %s from \"./%s\";\n", child.name, child.name) - // fmt.Fprintf(file.writer(), "export type { %s };", child.name) nestedFiles, err := child.intoIOFiles(ctx, dirRoot) if err != nil { return nil, err @@ -1837,6 +1855,14 @@ func (mod *modContext) getNamespaces() map[string]*namespace { ns.types = append(ns.types, t) } + // We need to ensure the top-level namespace is always populated, even + // if there are no types to export. + if _, ok := namespaces[""]; !ok { + namespaces[""] = &namespace{ + name: "", + } + } + return namespaces } @@ -2027,7 +2053,7 @@ func (mod *modContext) gen(fs fs) error { referencesNestedTypes := mod.getImportsForResource(r, externalImports, imports, r) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) rinfo, err := mod.genResource(buffer, r) if err != nil { @@ -2049,7 +2075,7 @@ func (mod *modContext) gen(fs fs) error { referencesNestedTypes := mod.getImports(f, externalImports, imports) buffer := &bytes.Buffer{} - mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true, ""), externalImports, imports) + mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) funInfo, err := mod.genFunction(buffer, f) if err != nil { @@ -2129,10 +2155,10 @@ func (mod *modContext) genIndex(exports []fileInfo) string { var imports []string // Include the SDK import if we'll be registering module resources. if len(mod.resources) != 0 { - imports = mod.sdkImports(false, true, "") + imports = mod.sdkImports(false, true) } else if len(children) > 0 || len(mod.functions) > 0 { // Even if there are no resources, exports ref utilities. - imports = append(imports, mod.utilitiesImport()) + imports = append(imports, mod.utilitiesImport(mod.getRelativePath())) } mod.genHeader(w, imports, nil, nil) @@ -2167,7 +2193,7 @@ func (mod *modContext) genIndex(exports []fileInfo) string { } else if len(mod.enums) > 0 { fmt.Fprintf(w, "\n") fmt.Fprintf(w, "// Export enums:\n") - rel := mod.getRelativePath("") + rel := mod.getRelativePath() var filePath string if mod.mod == "" { filePath = "" diff --git a/pkg/codegen/nodejs/gen_test.go b/pkg/codegen/nodejs/gen_test.go index 0edbd1d69835..35e6878acd87 100644 --- a/pkg/codegen/nodejs/gen_test.go +++ b/pkg/codegen/nodejs/gen_test.go @@ -237,48 +237,50 @@ func Test_isStringType(t *testing.T) { } } -// This test asserts that modContext.getRelativePath() -// returns the right relative path, regardless of whether -// the file is a resource definition or an Input/Output declaration -// from /types/ +// This test asserts that getRelativePath() +// returns the right relative path. This smoke test +// functions to pin the expected behavior to prevent regressions. func TestGetRelativePath(t *testing.T) { t.Parallel() type TestCase struct { - mod string - dirRoot string + filename string expected string } + // Recall that arguments are assumed to be directory names, + // even if they contain an extension. var cases = []TestCase{ { - mod: "foo", - dirRoot: "", + filename: "foo.ts", expected: "..", }, { - mod: "foo/bar", - dirRoot: "", + filename: "foo/bar", expected: "../..", }, { - mod: "types/accessanalyzer/input", - dirRoot: "", + filename: "types/accessanalyzer/input", expected: "../../..", }, { - mod: "input", - dirRoot: "types/accessanalyzer", + filename: "types/accessanalyzer/nested/input.ts", + expected: "../../../..", + }, { + filename: "types", + expected: "..", + }, { + filename: "./types/aws", expected: "../..", - }, - } + }, { + filename: "./types", + expected: "..", + }} for _, tc := range cases { - var ctx = &modContext{mod: tc.mod} - var observed = ctx.getRelativePath(tc.dirRoot) + var observed = getRelativePath(tc.filename) require.Equal( t, tc.expected, observed, - "Case (%s, %s): Expected %s, Observed %s", - tc.mod, - tc.dirRoot, + "Case (%s): Expected %s, Observed %s", + tc.filename, tc.expected, observed, ) } -} +} \ No newline at end of file diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json index 6d9fbb678803..bb356f455c4b 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/codegen-manifest.json @@ -8,6 +8,9 @@ "provider.ts", "scripts/install-pulumi-plugin.js", "tsconfig.json", + "types/documentdb/index.ts", + "types/documentdb/input.ts", + "types/documentdb/output.ts", "types/index.ts", "types/input.ts", "types/output.ts", diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json index db69a22a00ce..e21743ea2c3a 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/tsconfig.json @@ -17,6 +17,9 @@ "documentdb/sqlResourceSqlContainer.ts", "index.ts", "provider.ts", + "types/documentdb/index.ts", + "types/documentdb/input.ts", + "types/documentdb/output.ts", "types/index.ts", "types/input.ts", "types/output.ts", diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts new file mode 100644 index 000000000000..e8e567507ec0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/input.ts @@ -0,0 +1,7 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts new file mode 100644 index 000000000000..7f74aa6e3685 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/documentdb/output.ts @@ -0,0 +1,35 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + +export interface CompositePathResponse { + /** + * Sort order for composite paths. + */ + order?: string; + /** + * The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) + */ + path?: string; +} + +/** + * Cosmos DB indexing policy + */ +export interface IndexingPolicyResponse { + /** + * List of composite path list + */ + compositeIndexes?: outputs.documentdb.CompositePathResponse[][]; +} + +export interface SqlContainerGetPropertiesResponseResource { + /** + * The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container + */ + indexingPolicy?: outputs.documentdb.IndexingPolicyResponse; +} + diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts index 311e0b376968..2f582458b852 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/input.ts @@ -5,5 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace documentdb { -} +export * as documentdb from "./documentdb"; diff --git a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts index a57a6887c16c..2f582458b852 100644 --- a/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/azure-native-nested-types/nodejs/types/output.ts @@ -5,33 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace documentdb { - export interface CompositePathResponse { - /** - * Sort order for composite paths. - */ - order?: string; - /** - * The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*) - */ - path?: string; - } - - /** - * Cosmos DB indexing policy - */ - export interface IndexingPolicyResponse { - /** - * List of composite path list - */ - compositeIndexes?: outputs.documentdb.CompositePathResponse[][]; - } - - export interface SqlContainerGetPropertiesResponseResource { - /** - * The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container - */ - indexingPolicy?: outputs.documentdb.IndexingPolicyResponse; - } - -} +export * as documentdb from "./documentdb"; diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/input.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/cyclic-types/nodejs/types/output.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts index 5e35f2f8f160..fcefd058f114 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/input.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface ContainerArgs { diff --git a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts index a1c27174dff9..2ed273ed9dc5 100644 --- a/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/dashed-import-schema/nodejs/types/output.ts @@ -5,7 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; - import * as utilities from "../utilities"; export interface Container { diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts index 2ffa9d559dff..bdcafac05b74 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/input.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; /** * Configuration filters diff --git a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts index 5cb5a6753c21..e9b2c5a7c92f 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-edgeorder/nodejs/types/output.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; /** * Availability information of a product system. diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts index df48c5253e10..1c3b957d84ae 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetAmiIdsFilter { name: string; diff --git a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts index 4d2e3f38de57..ff7bb8563a2a 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs-tfbridge20/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetAmiIdsFilter { name: string; diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts index b7e782170aa2..d46e0bbb393d 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; /** * Bastion Shareable Link. diff --git a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts index 37867af15a5f..bdd2962eebc3 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/output-funcs/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; /** * Ssis environment reference. diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-and-default/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json index b3e8bd48b335..dbddbd48ce95 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/codegen-manifest.json @@ -11,6 +11,12 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json index 9ed19d14809e..59d7de2a223a 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/tsconfig.json @@ -20,6 +20,12 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts index 289f4e94771d..b921cb21ffc8 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/input.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -146,40 +145,6 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export namespace mod1 { - /** - * A test for namespaces (mod 1) - */ - export interface TypArgs { - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - val: (val.val) ?? (utilities.getEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") || "mod1"), - }; - } -} +export * as mod1 from "./mod1"; -export namespace mod2 { - /** - * A test for namespaces (mod 2) - */ - export interface TypArgs { - mod1?: pulumi.Input; - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), - val: (val.val) ?? "mod2", - }; - } -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts new file mode 100644 index 000000000000..de43fdfec91a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/input.ts @@ -0,0 +1,23 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 1) + */ +export interface TypArgs { + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + val: (val.val) ?? (utilities.getEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") || "mod1"), + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod1/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts new file mode 100644 index 000000000000..0b64bcae655a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/input.ts @@ -0,0 +1,25 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 2) + */ +export interface TypArgs { + mod1?: pulumi.Input; + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod2", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/mod2/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts index dc79a613d6d5..d105f0cd511d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-defaults/nodejs/types/output.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -33,8 +32,6 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export namespace mod1 { -} +export * as mod1 from "./mod1"; -export namespace mod2 { -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json index b3e8bd48b335..dbddbd48ce95 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json @@ -11,6 +11,12 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json index 9ed19d14809e..59d7de2a223a 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json @@ -20,6 +20,12 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/mod1/index.ts", + "types/mod1/input.ts", + "types/mod1/output.ts", + "types/mod2/index.ts", + "types/mod2/input.ts", + "types/mod2/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts index e127fd599940..b921cb21ffc8 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -146,40 +145,6 @@ export function typArgsProvideDefaults(val: TypArgs): TypArgs { val: (val.val) ?? "mod main", }; } -export namespace mod1 { - /** - * A test for namespaces (mod 1) - */ - export interface TypArgs { - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - val: (val.val) ?? "mod1", - }; - } -} +export * as mod1 from "./mod1"; -export namespace mod2 { - /** - * A test for namespaces (mod 2) - */ - export interface TypArgs { - mod1?: pulumi.Input; - val?: pulumi.Input; - } - /** - * typArgsProvideDefaults sets the appropriate defaults for TypArgs - */ - export function typArgsProvideDefaults(val: TypArgs): TypArgs { - return { - ...val, - mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), - val: (val.val) ?? "mod2", - }; - } -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts new file mode 100644 index 000000000000..effc6a0be847 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/input.ts @@ -0,0 +1,23 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 1) + */ +export interface TypArgs { + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + val: (val.val) ?? "mod1", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod1/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts new file mode 100644 index 000000000000..0b64bcae655a --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/input.ts @@ -0,0 +1,25 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + +/** + * A test for namespaces (mod 2) + */ +export interface TypArgs { + mod1?: pulumi.Input; + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod2", + }; +} diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts new file mode 100644 index 000000000000..e0c860f46c12 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/mod2/output.ts @@ -0,0 +1,8 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts index dc79a613d6d5..d105f0cd511d 100644 --- a/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts @@ -4,7 +4,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; - import * as utilities from "../utilities"; /** @@ -33,8 +32,6 @@ export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): Kube }; } -export namespace mod1 { -} +export * as mod1 from "./mod1"; -export namespace mod2 { -} +export * as mod2 from "./mod2"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json index ee4317032e08..d0d1a142860e 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/codegen-manifest.json @@ -9,6 +9,9 @@ "provider.ts", "scripts/install-pulumi-plugin.js", "tsconfig.json", + "types/config/index.ts", + "types/config/input.ts", + "types/config/output.ts", "types/enums/index.ts", "types/index.ts", "types/input.ts", diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json index 016bd0182259..788808e643db 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/tsconfig.json @@ -18,6 +18,9 @@ "funcWithAllOptionalInputs.ts", "index.ts", "provider.ts", + "types/config/index.ts", + "types/config/input.ts", + "types/config/output.ts", "types/enums/index.ts", "types/index.ts", "types/input.ts", diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts new file mode 100644 index 000000000000..3fd1c4e5dae1 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/input.ts @@ -0,0 +1,9 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as enums from "../../types/enums"; +import * as utilities from "../../utilities"; + diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts new file mode 100644 index 000000000000..69a6e8b1b030 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/config/output.ts @@ -0,0 +1,14 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; +import * as enums from "../../types/enums"; +import * as utilities from "../../utilities"; + +export interface Sandwich { + bread?: string; + veggies?: string[]; +} + diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts index a43cbaa66807..bcc09cf19d72 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/input.ts @@ -5,6 +5,6 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; -export namespace config { -} +export * as config from "./config"; diff --git a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts index 80f20da1edf0..8f4da74f3123 100644 --- a/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/provider-config-schema/nodejs/types/output.ts @@ -5,16 +5,11 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; export interface Child { age?: number; name?: string; } -export namespace config { - export interface Sandwich { - bread?: string; - veggies?: string[]; - } - -} +export * as config from "./config"; diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts index a277306fc819..efe5fda0c738 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/input.ts @@ -4,4 +4,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts index 7990bed12f46..7eac2cbfeb91 100644 --- a/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/regress-8403/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; export interface GetCustomDbRolesResult { } diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/input.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts index 176b5ce13afe..b9997a16405a 100644 --- a/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/regress-node-8110/nodejs/types/output.ts @@ -5,4 +5,5 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts index 2712424d1c1a..6966d245b39d 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/input.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Cat, Dog} from ".."; diff --git a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts index f77f44dd45f3..273422fbe3a2 100644 --- a/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/replace-on-change/nodejs/types/output.ts @@ -4,6 +4,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; +import * as utilities from "../utilities"; import {Cat, Dog} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json index 8551e38dfec7..55f5e9b24910 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/codegen-manifest.json @@ -10,6 +10,9 @@ "tsconfig.json", "types/index.ts", "types/input.ts", + "types/nested/index.ts", + "types/nested/input.ts", + "types/nested/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json index 0ccbcc941419..92462c9bac74 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/tsconfig.json @@ -19,6 +19,9 @@ "provider.ts", "types/index.ts", "types/input.ts", + "types/nested/index.ts", + "types/nested/input.ts", + "types/nested/output.ts", "types/output.ts", "utilities.ts" ] diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts index 5b9eb68ed95b..ff187ea5a197 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/input.ts @@ -5,14 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace nested { - export interface Baz { - hello?: string; - world?: string; - } - - export interface BazArgs { - hello?: pulumi.Input; - world?: pulumi.Input; - } -} +export * as nested from "./nested"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts new file mode 100644 index 000000000000..38514e5494d6 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/index.ts @@ -0,0 +1,5 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +export * from "./input"; +export * from "./output"; diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts new file mode 100644 index 000000000000..5bf1070627fb --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/input.ts @@ -0,0 +1,16 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + +export interface Baz { + hello?: string; + world?: string; +} + +export interface BazArgs { + hello?: pulumi.Input; + world?: pulumi.Input; +} diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts new file mode 100644 index 000000000000..e8e567507ec0 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/nested/output.ts @@ -0,0 +1,7 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +import * as pulumi from "@pulumi/pulumi"; +import * as inputs from "../../types/input"; +import * as outputs from "../../types/output"; + diff --git a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts index c2c4ef2f51ae..ff187ea5a197 100644 --- a/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-methods-schema/nodejs/types/output.ts @@ -5,5 +5,4 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; -export namespace nested { -} +export * as nested from "./nested"; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts index dec6c211cb5b..774b7916ca54 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/input.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; import {Resource} from ".."; diff --git a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts index 6a2c459d4f55..06d28a71e5cc 100644 --- a/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts +++ b/pkg/codegen/testing/test/testdata/simple-yaml-schema/nodejs/types/output.ts @@ -5,6 +5,7 @@ import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; import * as enums from "../types/enums"; +import * as utilities from "../utilities"; import {Resource} from "..";