{"version":3,"names":["_is","require","_validate","VISITOR_KEYS","exports","ALIAS_KEYS","FLIPPED_ALIAS_KEYS","NODE_FIELDS","BUILDER_KEYS","DEPRECATED_KEYS","NODE_PARENT_VALIDATIONS","getType","val","Array","isArray","validate","typeIs","typeName","assertNodeType","validateType","validateOptional","optional","validateOptionalType","arrayOf","elementType","chain","assertValueType","assertEach","arrayOfType","validateArrayOfType","callback","validator","node","key","i","length","subkey","v","process","env","BABEL_TYPES_8_BREAKING","validateChild","each","assertOneOf","values","indexOf","TypeError","JSON","stringify","oneOf","types","type","is","oneOfNodeTypes","assertNodeOrValueType","oneOfNodeOrValueTypes","valid","assertShape","shape","errors","property","Object","keys","validateField","error","push","message","join","shapeOf","assertOptionalChainStart","_current","current","callee","object","fns","args","fn","chainOf","Error","validTypeOpts","validFieldKeys","store","defineAliasedType","aliases","opts","defined","_store$opts$inherits$","_defined","inherits","slice","additional","filter","a","includes","unshift","defineType","fields","getOwnPropertyNames","field","def","default","deprecated","visitor","builder","k","deprecatedAlias","concat","undefined","forEach","alias"],"sources":["../../src/definitions/utils.ts"],"sourcesContent":["import is from \"../validators/is.ts\";\nimport { validateField, validateChild } from \"../validators/validate.ts\";\nimport type * as t from \"../index.ts\";\n\nexport const VISITOR_KEYS: Record = {};\nexport const ALIAS_KEYS: Partial> =\n {};\nexport const FLIPPED_ALIAS_KEYS: Record = {};\nexport const NODE_FIELDS: Record = {};\nexport const BUILDER_KEYS: Record = {};\nexport const DEPRECATED_KEYS: Record = {};\nexport const NODE_PARENT_VALIDATIONS: Record = {};\n\nfunction getType(val: any) {\n if (Array.isArray(val)) {\n return \"array\";\n } else if (val === null) {\n return \"null\";\n } else {\n return typeof val;\n }\n}\n\ntype NodeTypesWithoutComment = t.Node[\"type\"] | keyof t.Aliases;\n\ntype NodeTypes = NodeTypesWithoutComment | t.Comment[\"type\"];\n\ntype PrimitiveTypes = ReturnType;\n\ntype FieldDefinitions = {\n [x: string]: FieldOptions;\n};\n\ntype DefineTypeOpts = {\n fields?: FieldDefinitions;\n visitor?: Array;\n aliases?: Array;\n builder?: Array;\n inherits?: NodeTypes;\n deprecatedAlias?: string;\n validate?: Validator;\n};\n\nexport type Validator = (\n | { type: PrimitiveTypes }\n | { each: Validator }\n | { chainOf: Validator[] }\n | { oneOf: any[] }\n | { oneOfNodeTypes: NodeTypes[] }\n | { oneOfNodeOrValueTypes: (NodeTypes | PrimitiveTypes)[] }\n | { shapeOf: { [x: string]: FieldOptions } }\n | {}\n) &\n ((node: t.Node, key: string, val: any) => void);\n\nexport type FieldOptions = {\n default?: string | number | boolean | [];\n optional?: boolean;\n deprecated?: boolean;\n validate?: Validator;\n};\n\nexport function validate(validate: Validator): FieldOptions {\n return { validate };\n}\n\nexport function typeIs(typeName: NodeTypes | NodeTypes[]) {\n return typeof typeName === \"string\"\n ? assertNodeType(typeName)\n : assertNodeType(...typeName);\n}\n\nexport function validateType(typeName: NodeTypes | NodeTypes[]) {\n return validate(typeIs(typeName));\n}\n\nexport function validateOptional(validate: Validator): FieldOptions {\n return { validate, optional: true };\n}\n\nexport function validateOptionalType(\n typeName: NodeTypes | NodeTypes[],\n): FieldOptions {\n return { validate: typeIs(typeName), optional: true };\n}\n\nexport function arrayOf(elementType: Validator): Validator {\n return chain(assertValueType(\"array\"), assertEach(elementType));\n}\n\nexport function arrayOfType(typeName: NodeTypes | NodeTypes[]) {\n return arrayOf(typeIs(typeName));\n}\n\nexport function validateArrayOfType(typeName: NodeTypes | NodeTypes[]) {\n return validate(arrayOfType(typeName));\n}\n\nexport function assertEach(callback: Validator): Validator {\n function validator(node: t.Node, key: string, val: any) {\n if (!Array.isArray(val)) return;\n\n for (let i = 0; i < val.length; i++) {\n const subkey = `${key}[${i}]`;\n const v = val[i];\n callback(node, subkey, v);\n if (process.env.BABEL_TYPES_8_BREAKING) validateChild(node, subkey, v);\n }\n }\n validator.each = callback;\n return validator;\n}\n\nexport function assertOneOf(...values: Array): Validator {\n function validate(node: any, key: string, val: any) {\n if (values.indexOf(val) < 0) {\n throw new TypeError(\n `Property ${key} expected value to be one of ${JSON.stringify(\n values,\n )} but got ${JSON.stringify(val)}`,\n );\n }\n }\n\n validate.oneOf = values;\n\n return validate;\n}\n\nexport function assertNodeType(...types: NodeTypes[]): Validator {\n function validate(node: t.Node, key: string, val: any) {\n for (const type of types) {\n if (is(type, val)) {\n validateChild(node, key, val);\n return;\n }\n }\n\n throw new TypeError(\n `Property ${key} of ${\n node.type\n } expected node to be of a type ${JSON.stringify(\n types,\n )} but instead got ${JSON.stringify(val?.type)}`,\n );\n }\n\n validate.oneOfNodeTypes = types;\n\n return validate;\n}\n\nexport function assertNodeOrValueType(\n ...types: (NodeTypes | PrimitiveTypes)[]\n): Validator {\n function validate(node: t.Node, key: string, val: any) {\n for (const type of types) {\n if (getType(val) === type || is(type, val)) {\n validateChild(node, key, val);\n return;\n }\n }\n\n throw new TypeError(\n `Property ${key} of ${\n node.type\n } expected node to be of a type ${JSON.stringify(\n types,\n )} but instead got ${JSON.stringify(val?.type)}`,\n );\n }\n\n validate.oneOfNodeOrValueTypes = types;\n\n return validate;\n}\n\nexport function assertValueType(type: PrimitiveTypes): Validator {\n function validate(node: t.Node, key: string, val: any) {\n const valid = getType(val) === type;\n\n if (!valid) {\n throw new TypeError(\n `Property ${key} expected type of ${type} but got ${getType(val)}`,\n );\n }\n }\n\n validate.type = type;\n\n return validate;\n}\n\nexport function assertShape(shape: { [x: string]: FieldOptions }): Validator {\n function validate(node: t.Node, key: string, val: any) {\n const errors = [];\n for (const property of Object.keys(shape)) {\n try {\n validateField(node, property, val[property], shape[property]);\n } catch (error) {\n if (error instanceof TypeError) {\n errors.push(error.message);\n continue;\n }\n throw error;\n }\n }\n if (errors.length) {\n throw new TypeError(\n `Property ${key} of ${\n node.type\n } expected to have the following:\\n${errors.join(\"\\n\")}`,\n );\n }\n }\n\n validate.shapeOf = shape;\n\n return validate;\n}\n\nexport function assertOptionalChainStart(): Validator {\n function validate(node: t.Node) {\n let current = node;\n while (node) {\n const { type } = current;\n if (type === \"OptionalCallExpression\") {\n if (current.optional) return;\n current = current.callee;\n continue;\n }\n\n if (type === \"OptionalMemberExpression\") {\n if (current.optional) return;\n current = current.object;\n continue;\n }\n\n break;\n }\n\n throw new TypeError(\n `Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${current?.type}`,\n );\n }\n\n return validate;\n}\n\nexport function chain(...fns: Array): Validator {\n function validate(...args: Parameters) {\n for (const fn of fns) {\n fn(...args);\n }\n }\n validate.chainOf = fns;\n\n if (\n fns.length >= 2 &&\n \"type\" in fns[0] &&\n fns[0].type === \"array\" &&\n !(\"each\" in fns[1])\n ) {\n throw new Error(\n `An assertValueType(\"array\") validator can only be followed by an assertEach(...) validator.`,\n );\n }\n\n return validate;\n}\n\nconst validTypeOpts = [\n \"aliases\",\n \"builder\",\n \"deprecatedAlias\",\n \"fields\",\n \"inherits\",\n \"visitor\",\n \"validate\",\n];\nconst validFieldKeys = [\"default\", \"optional\", \"deprecated\", \"validate\"];\n\nconst store = {} as Record;\n\n// Wraps defineType to ensure these aliases are included.\nexport function defineAliasedType(...aliases: string[]) {\n return (type: string, opts: DefineTypeOpts = {}) => {\n let defined = opts.aliases;\n if (!defined) {\n if (opts.inherits) defined = store[opts.inherits].aliases?.slice();\n defined ??= [];\n opts.aliases = defined;\n }\n const additional = aliases.filter(a => !defined.includes(a));\n defined.unshift(...additional);\n defineType(type, opts);\n };\n}\n\nexport default function defineType(type: string, opts: DefineTypeOpts = {}) {\n const inherits = (opts.inherits && store[opts.inherits]) || {};\n\n let fields = opts.fields;\n if (!fields) {\n fields = {};\n if (inherits.fields) {\n const keys = Object.getOwnPropertyNames(inherits.fields);\n for (const key of keys) {\n const field = inherits.fields[key];\n const def = field.default;\n if (\n Array.isArray(def) ? def.length > 0 : def && typeof def === \"object\"\n ) {\n throw new Error(\n \"field defaults can only be primitives or empty arrays currently\",\n );\n }\n fields[key] = {\n default: Array.isArray(def) ? [] : def,\n optional: field.optional,\n deprecated: field.deprecated,\n validate: field.validate,\n };\n }\n }\n }\n\n const visitor: Array = opts.visitor || inherits.visitor || [];\n const aliases: Array = opts.aliases || inherits.aliases || [];\n const builder: Array =\n opts.builder || inherits.builder || opts.visitor || [];\n\n for (const k of Object.keys(opts)) {\n if (validTypeOpts.indexOf(k) === -1) {\n throw new Error(`Unknown type option \"${k}\" on ${type}`);\n }\n }\n\n if (opts.deprecatedAlias) {\n DEPRECATED_KEYS[opts.deprecatedAlias] = type as NodeTypesWithoutComment;\n }\n\n // ensure all field keys are represented in `fields`\n for (const key of visitor.concat(builder)) {\n fields[key] = fields[key] || {};\n }\n\n for (const key of Object.keys(fields)) {\n const field = fields[key];\n\n if (field.default !== undefined && builder.indexOf(key) === -1) {\n field.optional = true;\n }\n if (field.default === undefined) {\n field.default = null;\n } else if (!field.validate && field.default != null) {\n field.validate = assertValueType(getType(field.default));\n }\n\n for (const k of Object.keys(field)) {\n if (validFieldKeys.indexOf(k) === -1) {\n throw new Error(`Unknown field key \"${k}\" on ${type}.${key}`);\n }\n }\n }\n\n VISITOR_KEYS[type] = opts.visitor = visitor;\n BUILDER_KEYS[type] = opts.builder = builder;\n NODE_FIELDS[type] = opts.fields = fields;\n ALIAS_KEYS[type as NodeTypesWithoutComment] = opts.aliases = aliases;\n aliases.forEach(alias => {\n FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || [];\n FLIPPED_ALIAS_KEYS[alias].push(type as NodeTypesWithoutComment);\n });\n\n if (opts.validate) {\n NODE_PARENT_VALIDATIONS[type] = opts.validate;\n }\n\n store[type] = opts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAGO,MAAME,YAAsC,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAAC,CAAC;AACjD,MAAME,UAA8D,GAAAD,OAAA,CAAAC,UAAA,GACzE,CAAC,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