{"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","includes","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","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 | object\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.includes(val)) {\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.includes(k)) {\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.includes(key)) {\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.includes(k)) {\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,CAAC;AACG,MAAMC,kBAA6D,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