github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/nodejs/gen_intrinsics.go (about) 1 // Copyright 2016-2020, Pulumi Corporation. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package nodejs 16 17 import ( 18 "github.com/pulumi/pulumi/pkg/v3/codegen/hcl2/model" 19 ) 20 21 const ( 22 // intrinsicAwait is the name of the await intrinsic. 23 intrinsicAwait = "__await" 24 // intrinsicInterpolate is the name of the interpolate intrinsic. 25 intrinsicInterpolate = "__interpolate" 26 ) 27 28 // newAwaitCall creates a new call to the await intrinsic. 29 func newAwaitCall(promise model.Expression) model.Expression { 30 // TODO(pdg): unions 31 promiseType, ok := promise.Type().(*model.PromiseType) 32 if !ok { 33 return promise 34 } 35 36 return &model.FunctionCallExpression{ 37 Name: intrinsicAwait, 38 Signature: model.StaticFunctionSignature{ 39 Parameters: []model.Parameter{{ 40 Name: "promise", 41 Type: promiseType, 42 }}, 43 ReturnType: promiseType.ElementType, 44 }, 45 Args: []model.Expression{promise}, 46 } 47 } 48 49 // newInterpolateCall creates a new call to the interpolate intrinsic that represents a template literal that uses the 50 // pulumi.interpolate function. 51 func newInterpolateCall(args []model.Expression) *model.FunctionCallExpression { 52 return &model.FunctionCallExpression{ 53 Name: intrinsicInterpolate, 54 Signature: model.StaticFunctionSignature{ 55 VarargsParameter: &model.Parameter{Name: "args", Type: model.DynamicType}, 56 ReturnType: model.NewOutputType(model.StringType), 57 }, 58 Args: args, 59 } 60 }