How to use the thingtalk.Compiler function in thingtalk

To help you get started, we’ve selected a few thingtalk 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 stanford-oval / almond-dialog-agent / test / mock.js View on Github external
program.rules[0].actions[0].isInvocation &&
                  program.rules[0].actions[0].invocation.selector.isBuiltin &&
                  program.rules[0].actions[0].invocation.channel === 'return'))
                return null;
        }

        const code = program.prettyprint();
        console.log('MOCK: App ' + options.name + ' with code ' + code + ' loaded');
        this._apps[options.uniqueId] = {
            name: options.name,
            description: options.description,
            code: code,
            state: options,
            uniqueId: options.uniqueId
        };
        var compiler = new ThingTalk.Compiler(this._schemas);

        const queue = new AsyncQueue();
        let _resolve, _reject;
        new Promise((resolve, reject) => {
            _resolve = resolve;
            _reject = reject;
        });
        queue.push({ item: { isDone: true }, resolve: _resolve, reject: _reject });
        return compiler.compileCode(code).then(() => {
            return {
                mainOutput: queue
            };
        });
    }
}