UNPKG

botbuilder-dialogs

Version:

A dialog stack based conversation manager for Microsoft BotBuilder.

54 lines 1.76 kB
"use strict"; /** * @module botbuilder-dialogs */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DialogContextMemoryScope = void 0; const memoryScope_1 = require("./memoryScope"); const scopePath_1 = require("../scopePath"); /** * `DialogContextMemoryScope` maps 'dialogcontext' -> properties. */ class DialogContextMemoryScope extends memoryScope_1.MemoryScope { /** * Initializes a new instance of the `DialogContextMemoryScope` class. */ constructor() { super(scopePath_1.ScopePath.dialogContext, false); } /** * Gets the backing memory for this scope. * * @param dc The `DialogContext` object for this turn. * @returns Memory for the scope. */ getMemory(dc) { const stack = []; let currentDc = dc; // go to leaf node while (currentDc.child) { currentDc = currentDc.child; } while (currentDc) { for (let i = currentDc.stack.length - 1; i >= 0; i--) { const item = currentDc.stack[i]; // filter out ActionScope items because they are internal bookkeeping. if (!item.id.startsWith('ActionScope[')) { stack.push(item.id); } } currentDc = currentDc.parent; } return { stack, activeDialog: dc.activeDialog && dc.activeDialog.id, parent: dc.parent && dc.parent.activeDialog && dc.parent.activeDialog.id, }; } } exports.DialogContextMemoryScope = DialogContextMemoryScope; //# sourceMappingURL=dialogContextMemoryScope.js.map