lib/config-parser.js
function resolveKey(key, attrNode, options, context) {
    const resolvedKey = {};

    key.forEach(keyAttrPath => {
        const keyAttrNode = getLocalAttribute(keyAttrPath, attrNode, context);

        if (keyAttrNode.multiValued) {
            if (!options.allowMultiValued) {
                throw new ImplementationError(
                    `Key attribute "${keyAttrPath.join('.')}" ` + `must not be multiValued${context.errorContext}`
                );
            }
            if (key.length > 1) {
                throw new ImplementationError(
                    `Composite key attribute "${keyAttrPath.join('.')}" ` +
                        `must not be multiValued${context.errorContext}`
                );
            }
        }

        if (keyAttrNode.map) {
            Object.keys(keyAttrNode.map.default).forEach(dataSourceName => {
                if (!resolvedKey[dataSourceName]) resolvedKey[dataSourceName] = [];
                resolvedKey[dataSourceName].push(keyAttrNode.map.default[dataSourceName]);
            });
        }

        if (options.neededDataSources) {
            options.neededDataSources.forEach(neededDataSource => {
                if (!keyAttrNode.map || !keyAttrNode.map.default[neededDataSource]) {
                    throw new ImplementationError(
                        `Key attribute "${keyAttrPath.join('.')}" ` +
                            `is not mapped to "${neededDataSource}" DataSource${context.errorContext}`
                    );
                }
            });
        }
    });

    // remove DataSources with incomplete keys:
    Object.keys(resolvedKey).forEach(dataSourceName => {
        if (resolvedKey[dataSourceName].length !== key.length) {
            delete resolvedKey[dataSourceName];
        }
    });

    if (Object.keys(resolvedKey).length < 1) {
        throw new ImplementationError('Key is not mappable to a single DataSource' + context.errorContext);
    }

    return resolvedKey;
}
function resolveKey(key, attrNode, options, context) {
    const resolvedKey = {};

    key.forEach(keyAttrPath => {
        const keyAttrNode = getLocalAttribute(keyAttrPath, attrNode, context);

        if (keyAttrNode.multiValued) {
            if (!options.allowMultiValued) {
                throw new ImplementationError(
                    `Key attribute "${keyAttrPath.join('.')}" ` + `must not be multiValued${context.errorContext}`
                );
            }
            if (key.length > 1) {
                throw new ImplementationError(
                    `Composite key attribute "${keyAttrPath.join('.')}" ` +
                        `must not be multiValued${context.errorContext}`
                );
            }
        }

        if (keyAttrNode.map) {
            Object.keys(keyAttrNode.map.default).forEach(dataSourceName => {
                if (!resolvedKey[dataSourceName]) resolvedKey[dataSourceName] = [];
                resolvedKey[dataSourceName].push(keyAttrNode.map.default[dataSourceName]);
            });
        }

        if (options.neededDataSources) {
            options.neededDataSources.forEach(neededDataSource => {
                if (!keyAttrNode.map || !keyAttrNode.map.default[neededDataSource]) {
                    throw new ImplementationError(
                        `Key attribute "${keyAttrPath.join('.')}" ` +
                            `is not mapped to "${neededDataSource}" DataSource${context.errorContext}`
                    );
                }
            });
        }
    });

    // remove DataSources with incomplete keys:
    Object.keys(resolvedKey).forEach(dataSourceName => {
        if (resolvedKey[dataSourceName].length !== key.length) {
            delete resolvedKey[dataSourceName];
        }
    });

    if (Object.keys(resolvedKey).length < 1) {
        throw new ImplementationError('Key is not mappable to a single DataSource' + context.errorContext);
    }

    return resolvedKey;
}
function resolveKey ( key , attrNode , options , context ) { const resolvedKey = { } ; key . forEach ( keyAttrPath => { const keyAttrNode = getLocalAttribute ( keyAttrPath , attrNode , context ) ; if ( keyAttrNode . multiValued ) { if ( ! options . allowMultiValued ) { throw new ImplementationError ( ` ${ keyAttrPath . join ( '.' ) } ` + ` ${ context . errorContext } ` ) ; } if ( key . length > 1 ) { throw new ImplementationError ( ` ${ keyAttrPath . join ( '.' ) } ` + ` ${ context . errorContext } ` ) ; } } if ( keyAttrNode . map ) { Object . keys ( keyAttrNode . map . default ) . forEach ( dataSourceName => { if ( ! resolvedKey [ dataSourceName ] ) resolvedKey [ dataSourceName ] = [ ] ; resolvedKey [ dataSourceName ] . push ( keyAttrNode . map . default [ dataSourceName ] ) ; } ) ; } if ( options . neededDataSources ) { options . neededDataSources . forEach ( neededDataSource => { if ( ! keyAttrNode . map || ! keyAttrNode . map . default [ neededDataSource ] ) { throw new ImplementationError ( ` ${ keyAttrPath . join ( '.' ) } ` + ` ${ neededDataSource } ${ context . errorContext } ` ) ; } } ) ; } } ) ; // remove DataSources with incomplete keys: Object . keys ( resolvedKey ) . forEach ( dataSourceName => { if ( resolvedKey [ dataSourceName ] . length !== key . length ) { delete resolvedKey [ dataSourceName ] ; } } ) ; if ( Object . keys ( resolvedKey ) . length < 1 ) { throw new ImplementationError ( 'Key is not mappable to a single DataSource' + context . errorContext ) ; } return resolvedKey ; }
Resolve key attributes per DataSource.

@private
Resolve key attributes per DataSource .