import { Construct } from 'constructs' ; import * as cdk from "aws-cdk-lib" ; import { Function as Fn } from "aws-cdk-lib/aws-lambda" ; import { Stack } from "./Stack" ; const JSII_RTTI_SYMBOL_1 = Symbol . for ( "jsii.rtti" ) ; export interface SSTConstructMetadata < T extends string = string , D extends Record < string , any > = Record < string , any > > { type : T ; data : D ; } export interface SSTConstruct { getConstructMetadata ( ) : SSTConstructMetadata ; } export function getFunctionRef ( fn ? ) { if ( ! fn ) return undefined ; if ( ! ( fn instanceof Fn ) ) return undefined ; return { node : fn . node . addr , stack : Stack . of ( fn ) . node . id , } ; } export function isConstruct ( construct ) { return isSSTConstruct ( construct ) || isCDKConstruct ( construct ) ; } export function isStackConstruct ( construct ) { return isCDKConstructOf ( construct , "aws-cdk-lib.Stack" ) ; } export function isSSTConstruct ( construct ) { return "getConstructMetadata" in construct ; } export function isCDKConstructOf ( construct , moduleName ) { const fqn = construct ?. constructor ?. [ JSII_RTTI_SYMBOL_1 ] ?. fqn ; return ( typeof fqn === "string" ) && fqn === moduleName ; } export function isCDKConstruct ( construct ) { const fqn = construct ?. constructor ?. [ JSII_RTTI_SYMBOL_1 ] ?. fqn ; return typeof fqn === "string" && ( fqn . startsWith ( "@aws-cdk/" ) || fqn . startsWith ( "aws-cdk-lib" ) ) ; }