Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
}
// 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[] {