2017-11-16 15:17:15 +03:00
|
|
|
import Parser from './parser';
|
|
|
|
import Collector from './collector';
|
2017-12-01 22:39:03 +03:00
|
|
|
import type {Type} from './types';
|
2017-12-16 17:03:08 +03:00
|
|
|
import generateJsonSchema from './generators/jsonSchema';
|
|
|
|
import type {Schema} from './generators/jsonSchema';
|
2017-11-16 15:17:15 +03:00
|
|
|
|
|
|
|
// @see babel#6805.
|
|
|
|
//export {Parser, Collector};
|
|
|
|
|
2017-12-16 17:03:08 +03:00
|
|
|
export default function (path: string): {+types: Type[], +schema: Schema} {
|
2017-11-16 15:17:15 +03:00
|
|
|
const parser = new Parser;
|
|
|
|
const collector = new Collector(parser);
|
|
|
|
|
|
|
|
collector.collect(path);
|
|
|
|
|
2017-12-02 11:01:37 +03:00
|
|
|
const fund = collector.finish();
|
|
|
|
|
|
|
|
return {
|
2017-12-16 17:03:08 +03:00
|
|
|
types: Array.from(fund.takeAll()),
|
|
|
|
schema: generateJsonSchema(fund),
|
2017-12-02 11:01:37 +03:00
|
|
|
};
|
2017-11-16 15:17:15 +03:00
|
|
|
}
|