2021-03-27 23:34:47 +00:00
|
|
|
import { DEFAULT_SCHEMA } from 'js-yaml';
|
2019-11-13 14:01:51 +00:00
|
|
|
|
|
|
|
import { envType } from './type/Env';
|
2020-08-09 01:01:34 +00:00
|
|
|
import { createInclude, IncludeOptions } from './type/Include';
|
2019-11-13 14:01:51 +00:00
|
|
|
import { regexpType } from './type/Regexp';
|
|
|
|
import { streamType } from './type/Stream';
|
|
|
|
|
2020-08-09 01:01:34 +00:00
|
|
|
export interface SchemaOptions {
|
|
|
|
include: IncludeOptions;
|
|
|
|
}
|
|
|
|
|
2020-08-01 15:57:05 +00:00
|
|
|
/**
|
|
|
|
* Safe schema with additional library types added.
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
*/
|
2020-08-09 01:01:34 +00:00
|
|
|
export function createSchema(options: SchemaOptions) {
|
|
|
|
const includeType = createInclude(options.include);
|
2021-03-27 23:34:47 +00:00
|
|
|
const schema = DEFAULT_SCHEMA.extend([
|
2020-08-09 01:01:34 +00:00
|
|
|
envType,
|
|
|
|
includeType,
|
|
|
|
regexpType,
|
|
|
|
streamType,
|
|
|
|
]);
|
|
|
|
|
|
|
|
options.include.schema = schema;
|
2020-03-29 13:13:57 +00:00
|
|
|
|
2020-08-09 01:01:34 +00:00
|
|
|
return schema;
|
|
|
|
}
|