UNPKG

botbuilder-dialogs

Version:

A dialog stack based conversation manager for Microsoft BotBuilder.

52 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AtPathResolver = void 0; /** * @module botbuilder-dialogs */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ const aliasPathResolver_1 = require("./aliasPathResolver"); /** * Maps @@ => turn.recognized.entitites.xxx[0] */ class AtPathResolver extends aliasPathResolver_1.AliasPathResolver { /** * Initializes a new instance of the [AtPathResolver](xref:botbuilder-dialogs.AtPathResolver) class. */ constructor() { super('@', ''); this._prefix = 'turn.recognized.entities.'; this._delims = ['.', '[']; } /** * Transforms the path. * * @param path Path to inspect. * @returns The transformed path. */ transformPath(path) { path = path.trim(); if (path.startsWith('@') && path.length > 1 && !path.startsWith('@@')) { let end = -1; for (let i = 0; i < this._delims.length; i++) { const indexOfDelim = path.indexOf(this._delims[i]); if (indexOfDelim >= 0) { end = indexOfDelim; break; } } if (end == -1) { end = path.length; } const property = path.substr(1, end - 1); const suffix = path.substr(end); path = `${this._prefix}${property}.first()${suffix}`; } return path; } } exports.AtPathResolver = AtPathResolver; //# sourceMappingURL=atPathResolver.js.map