UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 5.11 kB
"use strict";var _a,_b,_c,_d;Object.defineProperty(exports,"__esModule",{value:!0}),exports.withResolved=exports.isResolvableObject=exports.JsonNull=exports.Tokenization=exports.Token=exports.TokenComparison=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),lazy_1=require("./lazy"),encoding_1=require("./private/encoding"),intrinsic_1=require("./private/intrinsic"),resolve_1=require("./private/resolve"),token_map_1=require("./private/token-map");class TokenComparison{constructor(){}}exports.TokenComparison=TokenComparison,_a=JSII_RTTI_SYMBOL_1,TokenComparison[_a]={fqn:"aws-cdk-lib.TokenComparison",version:"2.70.0"},TokenComparison.SAME=new TokenComparison,TokenComparison.DIFFERENT=new TokenComparison,TokenComparison.ONE_UNRESOLVED=new TokenComparison,TokenComparison.BOTH_UNRESOLVED=new TokenComparison;class Token{constructor(){}static isUnresolved(obj){return encoding_1.unresolved(obj)}static asString(value,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_EncodingOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.asString),error}return typeof value=="string"?value:token_map_1.TokenMap.instance().registerString(Token.asAny(value),options.displayHint)}static asNumber(value){return typeof value=="number"?value:token_map_1.TokenMap.instance().registerNumber(Token.asAny(value))}static asList(value,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_EncodingOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.asList),error}return Array.isArray(value)&&value.every(x=>typeof x=="string")?value:token_map_1.TokenMap.instance().registerList(Token.asAny(value),options.displayHint)}static asAny(value){return value=Tokenization.reverse(value)??value,isResolvableObject(value)?value:new intrinsic_1.Intrinsic(value)}static compareStrings(possibleToken1,possibleToken2){const firstIsUnresolved=Token.isUnresolved(possibleToken1),secondIsUnresolved=Token.isUnresolved(possibleToken2);return firstIsUnresolved&&secondIsUnresolved?TokenComparison.BOTH_UNRESOLVED:firstIsUnresolved||secondIsUnresolved?TokenComparison.ONE_UNRESOLVED:possibleToken1===possibleToken2?TokenComparison.SAME:TokenComparison.DIFFERENT}}exports.Token=Token,_b=JSII_RTTI_SYMBOL_1,Token[_b]={fqn:"aws-cdk-lib.Token",version:"2.70.0"};class Tokenization{constructor(){}static reverseString(s){return token_map_1.TokenMap.instance().splitString(s)}static reverseCompleteString(s){const fragments=Tokenization.reverseString(s);if(fragments.length!==1)throw new Error(`Tokenzation.reverseCompleteString: argument must not be a concatentation, got '${s}'`);return fragments.firstToken}static reverseNumber(n){return token_map_1.TokenMap.instance().lookupNumberToken(n)}static reverseList(l){return token_map_1.TokenMap.instance().lookupList(l)}static reverse(x,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_ReverseOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.reverse),error}if(Tokenization.isResolvable(x))return x;if(typeof x=="string"){if(options.failConcat===!1){const fragments=Tokenization.reverseString(x);return fragments.length===1?fragments.firstToken:void 0}return Tokenization.reverseCompleteString(x)}if(Array.isArray(x))return Tokenization.reverseList(x);if(typeof x=="number")return Tokenization.reverseNumber(x)}static resolve(obj,options){try{jsiiDeprecationWarnings.aws_cdk_lib_ResolveOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.resolve),error}return resolve_1.resolve(obj,{scope:options.scope,resolver:options.resolver,preparing:options.preparing??!1,removeEmpty:options.removeEmpty})}static isResolvable(obj){return isResolvableObject(obj)}static stringifyNumber(x){return Token.isUnresolved(x)?lazy_1.Lazy.uncachedString({produce:context=>{const resolved=context.resolve(x);return typeof resolved!="number"?resolved:`${resolved}`}}):typeof x!="number"?x:`${x}`}}exports.Tokenization=Tokenization,_c=JSII_RTTI_SYMBOL_1,Tokenization[_c]={fqn:"aws-cdk-lib.Tokenization",version:"2.70.0"};class JsonNull{constructor(){this.creationStack=[]}resolve(_ctx){try{jsiiDeprecationWarnings.aws_cdk_lib_IResolveContext(_ctx)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.resolve),error}return null}toJSON(){return null}toString(){return"null"}}exports.JsonNull=JsonNull,_d=JSII_RTTI_SYMBOL_1,JsonNull[_d]={fqn:"aws-cdk-lib.JsonNull",version:"2.70.0"},JsonNull.INSTANCE=new JsonNull;function isResolvableObject(x){return typeof x=="object"&&x!==null&&typeof x.resolve=="function"}exports.isResolvableObject=isResolvableObject;function withResolved(...args){if(args.length<2)return;const argArray=args.slice(0,args.length-1);argArray.some(Token.isUnresolved)||args[args.length-1].apply(arguments,argArray)}exports.withResolved=withResolved;