How to use the botbuilder-lg.ImportResolver.fileResolver function in botbuilder-lg

To help you get started, we’ve selected a few botbuilder-lg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-generation / src / utils.ts View on Github external
export function checkTemplate(template: Template): LGDiagnostic[] {
  const text = textFromTemplate(template);
  return staticChecker.checkText(text, '', ImportResolver.fileResolver).filter(diagnostic => {
    // ignore non-exist references in template body.
    return diagnostic.Message.includes('does not have an evaluator') === false;
  });
}
github microsoft / BotFramework-Composer / Composer / packages / client / src / utils / lgUtil.ts View on Github external
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/**
 * lgUtil.ts is a single place use lg-parser handle lg file operation.
 * it's designed have no state, input text file, output text file.
 *
 */

import { LGParser, StaticChecker, DiagnosticSeverity, ImportResolver, Diagnostic, LGTemplate } from 'botbuilder-lg';
import get from 'lodash/get';

const lgStaticChecker = new StaticChecker();

const lgImportResolver = ImportResolver.fileResolver;

export interface Template {
  name: string;
  parameters?: string[];
  body: string;
}

export function isValid(diagnostics: Diagnostic[]): boolean {
  return diagnostics.every(d => d.severity !== DiagnosticSeverity.Error);
}

export function check(content: string, id = ''): Diagnostic[] {
  return lgStaticChecker.checkText(content, id, lgImportResolver);
}

export function parse(content: string, id = ''): LGTemplate[] {