333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
{"version":3,"sources":["../../src/metadata/RelationMetadata.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAWhD;;GAEG;AACH;IA8OI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,0BAAY,OAIX;QAxLD;;WAEG;QACH,iBAAY,GAAY,KAAK,CAAC;QAE9B;;WAEG;QACH,mBAAc,GAAY,KAAK,CAAC;QAEhC;;;WAGG;QACH,cAAS,GAAY,KAAK,CAAC;QAE3B;;WAEG;QACH,WAAM,GAAY,KAAK,CAAC;QAExB;;WAEG;QACH,YAAO,GAAY,KAAK,CAAC;QAEzB;;;;;WAKG;QACH,uBAAkB,GAAY,IAAI,CAAC;QAEnC;;WAEG;QACH,oBAAe,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACH,oBAAe,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACH,oBAAe,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACH,eAAU,GAAY,IAAI,CAAC;QAwB3B;;WAEG;QACH,aAAQ,GAAY,KAAK,CAAC;QAE1B;;WAEG;QACH,eAAU,GAAY,KAAK,CAAC;QAE5B;;;WAGG;QACH,oBAAe,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACH,qBAAgB,GAAY,KAAK,CAAC;QAElC;;;WAGG;QACH,uBAAkB,GAAY,KAAK,CAAC;QAEpC;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QAE7B;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QAE7B;;WAEG;QACH,iBAAY,GAAY,KAAK,CAAC;QAE9B;;;WAGG;QACH,sBAAiB,GAAY,KAAK,CAAC;QAEnC;;;WAGG;QACH,yBAAoB,GAAY,KAAK,CAAC;QA0BtC;;WAEG;QACH,gBAAW,GAAyB,EAAE,CAAC;QAEvC;;;;;;WAMG;QACH,gBAAW,GAAqB,EAAE,CAAC;QAEnC;;;;;WAKG;QACH,uBAAkB,GA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AAC,sBAAsB,GAAG,sBAAsB,CAAC;YACrE,IAAI,CAAC,aAAa,GAAG,sBAAsB,CAAC,SAAS,CAAC;SACzD;IACL,CAAC;IAED;;;OAGG;IACH,uDAA4B,GAA5B;QAEI,IAAI,IAAI,CAAC,+BAA+B,EAAE;YACtC,IAAM,wBAAwB,GAAG,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC;YAC1E,IAAI,OAAO,IAAI,CAAC,+BAA+B,KAAK,UAAU;gBAC1D,OAAO,IAAI,CAAC,+BAA+B,CAAC,wBAAwB,CAAC,CAAC;YAE1E,IAAI,OAAO,IAAI,CAAC,+BAA+B,KAAK,QAAQ;gBACxD,OAAO,IAAI,CAAC,+BAA+B,CAAC;SAEnD;aAAM,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,cAAc,CAAC,oBAAoB,EAAE;YACtE,OAAO,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,YAAY,CAAC;SAEhE;aAAM,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE;YACtE,OAAO,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC;SAC9D;QAED,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;OAEG;IACH,4CAAiB,GAAjB;QACI,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,MAAM;YAC3E,OAAO,IAAI,CAAC,YAAY,CAAC;QAE7B,OAAO,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC;IACzF,CAAC;IAEL,uBAAC;AAAD,CApgBA,AAogBC,IAAA;AApgBY,4CAAgB","file":"RelationMetadata.js","sourcesContent":["import {RelationType} from \"./types/RelationTypes\";\nimport {EntityMetadata} from \"./EntityMetadata\";\nimport {ForeignKeyMetadata} from \"./ForeignKeyMetadata\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {ColumnMetadata} from \"./ColumnMetadata\";\nimport {EmbeddedMetadata} from \"./EmbeddedMetadata\";\nimport {RelationMetadataArgs} from \"../metadata-args/RelationMetadataArgs\";\nimport {DeferrableType} from \"./types/DeferrableType\";\nimport {OnUpdateType} from \"./types/OnUpdateType\";\nimport {OnDeleteType} from \"./types/OnDeleteType\";\nimport {PropertyTypeFactory} from \"./types/PropertyTypeInFunction\";\n\n/**\n * Contains all information about some entity's relation.\n */\nexport class RelationMetadata {\n\n    // ---------------------------------------------------------------------\n    // Public Properties\n    // ---------------------------------------------------------------------\n\n    /**\n     * Entity metadata of the entity where this relation is placed.\n     *\n     * For example for @ManyToMany(type => Category) in Post, entityMetadata will be metadata of Post entity.\n     */\n    entityMetadata: EntityMetadata;\n\n    /**\n     * Entity metadata of the entity that is targeted by this relation.\n     *\n     * For example for @ManyToMany(type => Category) in Post, inverseEntityMetadata will be metadata of Category entity.\n     */\n    inverseEntityMetadata: EntityMetadata;\n\n    /**\n     * Entity metadata of the junction table.\n     * Junction tables have their own entity metadata objects.\n     * Defined only for many-to-many relations.\n     */\n    junctionEntityMetadata?: EntityMetadata;\n\n    /**\n     * Embedded metadata where this relation is.\n     * If this relation is not in embed then this property value is undefined.\n     */\n    embeddedMetadata?: EmbeddedMetadata;\n\n    /**\n     * Relation type, e.g. is it one-to-one, one-to-many, many-to-one or many-to-many.\n     */\n    relationType: RelationType;\n\n    /**\n     * Target entity to which this relation is applied.\n     * Target IS NOT equal to entityMetadata.target, because relation\n     *\n     * For example for @ManyToMany(type => Category) in Post, target will be Post.\n     * If @ManyToMany(type => Category) is in Counters which is embedded into Post, target will be Counters.\n     * If @ManyToMany(type => Category) is in abstract class BaseUser which Post extends, target will be BaseUser.\n     * Target can be string if its defined in entity schema instead of class.\n     */\n    target: Function|string;\n\n    /**\n     * Target's property name to which relation decorator is applied.\n     */\n    propertyName: string;\n\n    /**\n     * Gets full path to this column property (including relation name).\n     * Full path is relevant when column is used in embeds (one or multiple nested).\n     * For example it will return \"counters.subcounters.likes\".\n     * If property is not in embeds then it returns just property name of the column.\n     */\n    propertyPath: string;\n\n    /**\n     * Indicates if this is a parent (can be only many-to-one relation) relation in the tree tables.\n     */\n    isTreeParent: boolean = false;\n\n    /**\n     * Indicates if this is a children (can be only one-to-many relation) relation in the tree tables.\n     */\n    isTreeChildren: boolean = false;\n\n    /**\n     * Indicates if this relation's column is a primary key.\n     * Can be used only for many-to-one and owner one-to-one relations.\n     */\n    isPrimary: boolean = false;\n\n    /**\n     * Indicates if this relation is lazily loaded.\n     */\n    isLazy: boolean = false;\n\n    /**\n     * Indicates if this relation is eagerly loaded.\n     */\n    isEager: boolean = false;\n\n    /**\n     * Indicates if persistence is enabled for the relation.\n     * By default its enabled, but if you want to avoid any changes in the relation to be reflected in the database you can disable it.\n     * If its disabled you can only change a relation from inverse side of a relation or using relation query builder functionality.\n     * This is useful for performance optimization since its disabling avoid multiple extra queries during entity save.\n     */\n    persistenceEnabled: boolean = true;\n\n    /**\n     * If set to true then related objects are allowed to be inserted to the database.\n     */\n    isCascadeInsert: boolean = false;\n\n    /**\n     * If set to true then related objects are allowed to be updated in the database.\n     */\n    isCascadeUpdate: boolean = false;\n\n    /**\n     * If set to true then related objects are allowed to be remove from the database.\n     */\n    isCascadeRemove: boolean = false;\n\n    /**\n     * Indicates if relation column value can be nullable or not.\n     */\n    isNullable: boolean = true;\n\n    /**\n     * What to do with a relation on deletion of the row containing a foreign key.\n     */\n    onDelete?: OnDeleteType;\n\n    /**\n     * What to do with a relation on update of the row containing a foreign key.\n     */\n    onUpdate?: OnUpdateType;\n\n    /**\n     * What to do with a relation on update of the row containing a foreign key.\n     */\n    deferrable?: DeferrableType;\n\n    /**\n     * Gets the property's type to which this relation is applied.\n     *\n     * For example for @ManyToMany(type => Category) in Post, target will be Category.\n     */\n    type: Function|string;\n\n    /**\n     * Indicates if this side is an owner of this relation.\n     */\n    isOwning: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"one-to-one\".\n     */\n    isOneToOne: boolean = false;\n\n    /**\n     * Checks if this relation is owner side of the \"one-to-one\" relation.\n     * Owner side means this side of relation has a join column in the table.\n     */\n    isOneToOneOwner: boolean = false;\n\n    /**\n     * Checks if this relation has a join column (e.g. is it many-to-one or one-to-one owner side).\n     */\n    isWithJoinColumn: boolean = false;\n\n    /**\n     * Checks if this relation is NOT owner side of the \"one-to-one\" relation.\n     * NOT owner side means this side of relation does not have a join column in the table.\n     */\n    isOneToOneNotOwner: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"one-to-many\".\n     */\n    isOneToMany: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"many-to-one\".\n     */\n    isManyToOne: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"many-to-many\".\n     */\n    isManyToMany: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"many-to-many\", and is owner side of the relationship.\n     * Owner side means this side of relation has a join table.\n     */\n    isManyToManyOwner: boolean = false;\n\n    /**\n     * Checks if this relation's type is \"many-to-many\", and is NOT owner side of the relationship.\n     * Not owner side means this side of relation does not have a join table.\n     */\n    isManyToManyNotOwner: boolean = false;\n\n    /**\n     * Gets the property path of the inverse side of the relation.\n     */\n    inverseSidePropertyPath: string;\n\n    /**\n     * Inverse side of the relation set by user.\n     *\n     * Inverse side set in the relation can be either string - property name of the column on inverse side,\n     * either can be a function that accepts a map of properties with the object and returns one of them.\n     * Second approach is used to achieve type-safety.\n     */\n    givenInverseSidePropertyFactory: PropertyTypeFactory<any>;\n\n    /**\n     * Gets the relation metadata of the inverse side of this relation.\n     */\n    inverseRelation?: RelationMetadata;\n\n    /**\n     * Join table name.\n     */\n    joinTableName: string;\n\n    /**\n     * Foreign keys created for this relation.\n     */\n    foreignKeys: ForeignKeyMetadata[] = [];\n\n    /**\n     * Join table columns.\n     * Join columns can be obtained only from owner side of the relation.\n     * From non-owner side of the relation join columns will be empty.\n     * If this relation is a many-to-one/one-to-one then it takes join columns from the current entity.\n     * If this relation is many-to-many then it takes all owner join columns from the junction entity.\n     */\n    joinColumns: ColumnMetadata[] = [];\n\n    /**\n     * Inverse join table columns.\n     * Inverse join columns are supported only for many-to-many relations\n     * and can be obtained only from owner side of the relation.\n     * From non-owner side of the relation join columns will be undefined.\n     */\n    inverseJoinColumns: ColumnMetadata[] = [];\n\n    // ---------------------------------------------------------------------\n    // Constructor\n    // ---------------------------------------------------------------------\n\n    constructor(options: {\n        entityMetadata: EntityMetadata,\n        embeddedMetadata?: EmbeddedMetadata,\n        args: RelationMetadataArgs\n    }) {\n        this.entityMetadata = options.entityMetadata;\n        this.embeddedMetadata = options.embeddedMetadata!;\n        const args = options.args;\n        this.target = args.target;\n        this.propertyName = args.propertyName;\n        this.relationType = args.relationType;\n\n        if (args.inverseSideProperty)\n            this.givenInverseSidePropertyFactory = args.inverseSideProperty;\n\n        this.isLazy = args.isLazy || false;\n        this.isCascadeInsert = args.options.cascade === true || (args.options.cascade instanceof Array && args.options.cascade.indexOf(\"insert\") !== -1);\n        this.isCascadeUpdate = args.options.cascade === true || (args.options.cascade instanceof Array && args.options.cascade.indexOf(\"update\") !== -1);\n        this.isCascadeRemove = args.options.cascade === true || (args.options.cascade instanceof Array && args.options.cascade.indexOf(\"remove\") !== -1);\n        this.isPrimary = args.options.primary || false;\n        this.isNullable = args.options.nullable === false || this.isPrimary ? false : true;\n        this.onDelete = args.options.onDelete;\n        this.onUpdate = args.options.onUpdate;\n        this.deferrable = args.options.deferrable;\n        this.isEager = args.options.eager || false;\n        this.persistenceEnabled = args.options.persistence === false ? false : true;\n        this.isTreeParent = args.isTreeParent || false;\n        this.isTreeChildren = args.isTreeChildren || false;\n        this.type = args.type instanceof Function ? (args.type as () => any)() : args.type;\n\n        this.isOneToOne = this.relationType === \"one-to-one\";\n        this.isOneToMany = this.relationType === \"one-to-many\";\n        this.isManyToOne = this.relationType === \"many-to-one\";\n        this.isManyToMany = this.relationType === \"many-to-many\";\n        this.isOneToOneNotOwner = this.isOneToOne ? true : false;\n        this.isManyToManyNotOwner = this.isManyToMany ? true : false;\n    }\n\n    // ---------------------------------------------------------------------\n    // Public Methods\n    // ---------------------------------------------------------------------\n\n    /**\n     * Creates join column ids map from the given related entity ids array.\n     */\n    getRelationIdMap(entity: ObjectLiteral): ObjectLiteral|undefined {\n        const joinColumns = this.isOwning ? this.joinColumns : this.inverseRelation!.joinColumns;\n        const referencedColumns = joinColumns.map(joinColumn => joinColumn.referencedColumn!);\n        // console.log(\"entity\", entity);\n        // console.log(\"referencedColumns\", referencedColumns);\n        return EntityMetadata.getValueMap(entity, referencedColumns);\n    }\n\n    /**\n     * Ensures that given object is an entity id map.\n     * If given id is an object then it means its already id map.\n     * If given id isn't an object then it means its a value of the id column\n     * and it creates a new id map with this value and name of the primary column.\n     */\n    ensureRelationIdMap(id: any): ObjectLiteral {\n        if (id instanceof Object)\n            return id;\n\n        const joinColumns = this.isOwning ? this.joinColumns : this.inverseRelation!.joinColumns;\n        const referencedColumns = joinColumns.map(joinColumn => joinColumn.referencedColumn!);\n\n        if (referencedColumns.length > 1)\n            throw new Error(`Cannot create relation id map for a single value because relation contains multiple referenced columns.`);\n\n        return referencedColumns[0].createValueMap(id);\n    }\n\n    /**\n     * Extracts column value from the given entity.\n     * If column is in embedded (or recursive embedded) it extracts its value from there.\n     */\n    getEntityValue(entity: ObjectLiteral, getLazyRelationsPromiseValue: boolean = false): any|undefined {\n        if (entity === null || entity === undefined) return undefined;\n        // extract column value from embeddeds of entity if column is in embedded\n        if (this.embeddedMetadata) {\n\n            // example: post[data][information][counters].id where \"data\", \"information\" and \"counters\" are embeddeds\n            // we need to get value of \"id\" column from the post real entity object\n\n            // first step - we extract all parent properties of the entity relative to this column, e.g. [data, information, counters]\n            const propertyNames = [...this.embeddedMetadata.parentPropertyNames];\n\n            // next we need to access post[data][information][counters][this.propertyName] to get column value from the counters\n            // this recursive function takes array of generated property names and gets the post[data][information][counters] embed\n            const extractEmbeddedColumnValue = (propertyNames: string[], value: ObjectLiteral): any => {\n                const propertyName = propertyNames.shift();\n                if (propertyName) {\n                    if (value[propertyName]) {\n                        return extractEmbeddedColumnValue(propertyNames, value[propertyName]);\n                    }\n                    return undefined;\n                }\n                return value;\n            };\n\n            // once we get nested embed object we get its column, e.g. post[data][information][counters][this.propertyName]\n            const embeddedObject = extractEmbeddedColumnValue(propertyNames, entity);\n\n            if (this.isLazy) {\n                if (embeddedObject[\"__\" + this.propertyName + \"__\"] !== undefined)\n                    return embeddedObject[\"__\" + this.propertyName + \"__\"];\n\n                if (getLazyRelationsPromiseValue === true)\n                    return embeddedObject[this.propertyName];\n\n                return undefined;\n            }\n            return embeddedObject ? embeddedObject[this.isLazy ? \"__\" + this.propertyName + \"__\" : this.propertyName] : undefined;\n\n        } else { // no embeds - no problems. Simply return column name by property name of the entity\n            if (this.isLazy) {\n                if (entity[\"__\" + this.propertyName + \"__\"] !== undefined)\n                    return entity[\"__\" + this.propertyName + \"__\"];\n\n                if (getLazyRelationsPromiseValue === true)\n                    return entity[this.propertyName];\n\n                return undefined;\n            }\n            return entity[this.propertyName];\n        }\n    }\n\n    /**\n     * Sets given entity's relation's value.\n     * Using of this method helps to set entity relation's value of the lazy and non-lazy relations.\n     *\n     * If merge is set to true, it merges given value into currently\n     */\n    setEntityValue(entity: ObjectLiteral, value: any): void {\n        const propertyName = this.isLazy ? \"__\" + this.propertyName + \"__\" : this.propertyName;\n\n        if (this.embeddedMetadata) {\n\n            // first step - we extract all parent properties of the entity relative to this column, e.g. [data, information, counters]\n            const extractEmbeddedColumnValue = (embeddedMetadatas: EmbeddedMetadata[], map: ObjectLiteral): any => {\n                // if (!object[embeddedMetadata.propertyName])\n                //     object[embeddedMetadata.propertyName] = embeddedMetadata.create();\n\n                const embeddedMetadata = embeddedMetadatas.shift();\n                if (embeddedMetadata) {\n                    if (!map[embeddedMetadata.propertyName])\n                        map[embeddedMetadata.propertyName] = embeddedMetadata.create();\n\n                    extractEmbeddedColumnValue(embeddedMetadatas, map[embeddedMetadata.propertyName]);\n                    return map;\n                }\n                map[propertyName] = value;\n                return map;\n            };\n            return extractEmbeddedColumnValue([...this.embeddedMetadata.embeddedMetadataTree], entity);\n\n        } else {\n            entity[propertyName] = value;\n        }\n    }\n\n    /**\n     * Creates entity id map from the given entity ids array.\n     */\n    createValueMap(value: any) {\n\n        // extract column value from embeds of entity if column is in embedded\n        if (this.embeddedMetadata) {\n\n            // example: post[data][information][counters].id where \"data\", \"information\" and \"counters\" are embeddeds\n            // we need to get value of \"id\" column from the post real entity object and return it in a\n            // { data: { information: { counters: { id: ... } } } } format\n\n            // first step - we extract all parent properties of the entity relative to this column, e.g. [data, information, counters]\n            const propertyNames = [...this.embeddedMetadata.parentPropertyNames];\n\n            // now need to access post[data][information][counters] to get column value from the counters\n            // and on each step we need to create complex literal object, e.g. first { data },\n            // then { data: { information } }, then { data: { information: { counters } } },\n            // then { data: { information: { counters: [this.propertyName]: entity[data][information][counters][this.propertyName] } } }\n            // this recursive function helps doing that\n            const extractEmbeddedColumnValue = (propertyNames: string[], map: ObjectLiteral): any => {\n                const propertyName = propertyNames.shift();\n                if (propertyName) {\n                    map[propertyName] = {};\n                    extractEmbeddedColumnValue(propertyNames, map[propertyName]);\n                    return map;\n                }\n                map[this.propertyName] = value;\n                return map;\n            };\n            return extractEmbeddedColumnValue(propertyNames, {});\n\n        } else { // no embeds - no problems. Simply return column property name and its value of the entity\n            return { [this.propertyName]: value };\n        }\n    }\n\n    // ---------------------------------------------------------------------\n    // Builder Methods\n    // ---------------------------------------------------------------------\n\n    /**\n     * Builds some depend relation metadata properties.\n     * This builder method should be used only after embedded metadata tree was build.\n     */\n    build() {\n        this.propertyPath = this.buildPropertyPath();\n    }\n\n    /**\n     * Registers given foreign keys in the relation.\n     * This builder method should be used to register foreign key in the relation.\n     */\n    registerForeignKeys(...foreignKeys: ForeignKeyMetadata[]) {\n        this.foreignKeys.push(...foreignKeys);\n        this.joinColumns = this.foreignKeys[0] ? this.foreignKeys[0].columns : [];\n        this.inverseJoinColumns = this.foreignKeys[1] ? this.foreignKeys[1].columns : [];\n        this.isOwning = this.isManyToOne || ((this.isManyToMany || this.isOneToOne) && this.joinColumns.length > 0);\n        this.isOneToOneOwner = this.isOneToOne && this.isOwning;\n        this.isOneToOneNotOwner = this.isOneToOne && !this.isOwning;\n        this.isManyToManyOwner = this.isManyToMany && this.isOwning;\n        this.isManyToManyNotOwner = this.isManyToMany && !this.isOwning;\n        this.isWithJoinColumn = this.isManyToOne || this.isOneToOneOwner;\n    }\n\n    /**\n     * Registers a given junction entity metadata.\n     * This builder method can be called after junction entity metadata for the many-to-many relation was created.\n     */\n    registerJunctionEntityMetadata(junctionEntityMetadata: EntityMetadata) {\n        this.junctionEntityMetadata = junctionEntityMetadata;\n        this.joinTableName = junctionEntityMetadata.tableName;\n        if (this.inverseRelation) {\n            this.inverseRelation.junctionEntityMetadata = junctionEntityMetadata;\n            this.joinTableName = junctionEntityMetadata.tableName;\n        }\n    }\n\n    /**\n     * Builds inverse side property path based on given inverse side property factory.\n     * This builder method should be used only after properties map of the inverse entity metadata was build.\n     */\n    buildInverseSidePropertyPath(): string {\n\n        if (this.givenInverseSidePropertyFactory) {\n            const ownerEntityPropertiesMap = this.inverseEntityMetadata.propertiesMap;\n            if (typeof this.givenInverseSidePropertyFactory === \"function\")\n                return this.givenInverseSidePropertyFactory(ownerEntityPropertiesMap);\n\n            if (typeof this.givenInverseSidePropertyFactory === \"string\")\n                return this.givenInverseSidePropertyFactory;\n\n        } else if (this.isTreeParent && this.entityMetadata.treeChildrenRelation) {\n            return this.entityMetadata.treeChildrenRelation.propertyName;\n\n        } else if (this.isTreeChildren && this.entityMetadata.treeParentRelation) {\n            return this.entityMetadata.treeParentRelation.propertyName;\n        }\n\n        return \"\";\n    }\n\n    /**\n     * Builds relation's property path based on its embedded tree.\n     */\n    buildPropertyPath(): string {\n        if (!this.embeddedMetadata || !this.embeddedMetadata.parentPropertyNames.length)\n            return this.propertyName;\n\n        return this.embeddedMetadata.parentPropertyNames.join(\".\") + \".\" + this.propertyName;\n    }\n\n}\n"],"sourceRoot":".."}