{"expireTime":9007200821600205000,"key":"gatsby-plugin-mdx-entire-payload-63d7008a814b0ca6d1419788f6c241af-","val":{"mdast":{"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":"Sometimes data can exist in a partially normalized state. E.g. a user object has a friend key,\nbut instead of the data giving you the whole object it just returns a user id in its place.","position":{"start":{"line":2,"column":1,"offset":1},"end":{"line":3,"column":92,"offset":187},"indent":[1]}}],"position":{"start":{"line":2,"column":1,"offset":1},"end":{"line":3,"column":92,"offset":187},"indent":[1]}},{"type":"code","lang":"js","meta":null,"value":"// User\n{\n    id: '123',\n    name: 'foo',\n    friend: '456'\n}","position":{"start":{"line":5,"column":1,"offset":189},"end":{"line":12,"column":4,"offset":260},"indent":[1,1,1,1,1,1,1]}},{"type":"paragraph","children":[{"type":"text","value":"As long as you already have the friend normalized into state, the Value schemas lets you \ndenormalize ","position":{"start":{"line":14,"column":1,"offset":262},"end":{"line":15,"column":13,"offset":364},"indent":[1]}},{"type":"inlineCode","value":"friend","position":{"start":{"line":15,"column":13,"offset":364},"end":{"line":15,"column":21,"offset":372},"indent":[]}},{"type":"text","value":" as a user.","position":{"start":{"line":15,"column":21,"offset":372},"end":{"line":15,"column":32,"offset":383},"indent":[]}}],"position":{"start":{"line":14,"column":1,"offset":262},"end":{"line":15,"column":32,"offset":383},"indent":[1]}},{"type":"heading","depth":2,"children":[{"type":"text","value":"Params","position":{"start":{"line":18,"column":4,"offset":389},"end":{"line":18,"column":10,"offset":395},"indent":[]}}],"position":{"start":{"line":18,"column":1,"offset":386},"end":{"line":18,"column":10,"offset":395},"indent":[]}},{"type":"code","lang":"js","meta":null,"value":"new IdSchema(\n    name: Schema,\n    options?: {\n        create: (value) => entity\n    }\n);","position":{"start":{"line":19,"column":1,"offset":396},"end":{"line":26,"column":4,"offset":496},"indent":[1,1,1,1,1,1,1]}},{"type":"heading","depth":3,"children":[{"type":"text","value":"shape","position":{"start":{"line":28,"column":5,"offset":502},"end":{"line":28,"column":10,"offset":507},"indent":[]}}],"position":{"start":{"line":28,"column":1,"offset":498},"end":{"line":28,"column":11,"offset":508},"indent":[]}},{"type":"paragraph","children":[{"type":"strong","children":[{"type":"text","value":"type:","position":{"start":{"line":29,"column":3,"offset":511},"end":{"line":29,"column":8,"offset":516},"indent":[]}}],"position":{"start":{"line":29,"column":1,"offset":509},"end":{"line":29,"column":10,"offset":518},"indent":[]}},{"type":"text","value":" ","position":{"start":{"line":29,"column":10,"offset":518},"end":{"line":29,"column":11,"offset":519},"indent":[]}},{"type":"inlineCode","value":"Schema","position":{"start":{"line":29,"column":11,"offset":519},"end":{"line":29,"column":19,"offset":527},"indent":[]}},{"type":"text","value":"  ","position":{"start":{"line":29,"column":19,"offset":527},"end":{"line":29,"column":21,"offset":529},"indent":[]}}],"position":{"start":{"line":29,"column":1,"offset":509},"end":{"line":29,"column":21,"offset":529},"indent":[]}},{"type":"paragraph","children":[{"type":"text","value":"The Schema that this value represents.","position":{"start":{"line":31,"column":1,"offset":531},"end":{"line":31,"column":39,"offset":569},"indent":[]}}],"position":{"start":{"line":31,"column":1,"offset":531},"end":{"line":31,"column":39,"offset":569},"indent":[]}},{"type":"code","lang":"js","meta":null,"value":"const user = new EntitySchema('user');\nconst friend = IdSchema(user);\nuser.shape = new ObjectSchema({friend});","position":{"start":{"line":33,"column":1,"offset":571},"end":{"line":37,"column":4,"offset":691},"indent":[1,1,1,1]}},{"type":"heading","depth":2,"children":[{"type":"text","value":"options.create","position":{"start":{"line":39,"column":4,"offset":696},"end":{"line":39,"column":18,"offset":710},"indent":[]}}],"position":{"start":{"line":39,"column":1,"offset":693},"end":{"line":39,"column":18,"offset":710},"indent":[]}},{"type":"paragraph","children":[{"type":"strong","children":[{"type":"text","value":"type:","position":{"start":{"line":40,"column":3,"offset":713},"end":{"line":40,"column":8,"offset":718},"indent":[]}}],"position":{"start":{"line":40,"column":1,"offset":711},"end":{"line":40,"column":10,"offset":720},"indent":[]}},{"type":"text","value":" ","position":{"start":{"line":40,"column":10,"offset":720},"end":{"line":40,"column":11,"offset":721},"indent":[]}},{"type":"inlineCode","value":"(id: string) => *","position":{"start":{"line":40,"column":11,"offset":721},"end":{"line":40,"column":30,"offset":740},"indent":[]}},{"type":"break","position":{"start":{"line":40,"column":30,"offset":740},"end":{"line":41,"column":1,"offset":743},"indent":[1]}},{"type":"strong","children":[{"type":"text","value":"default:","position":{"start":{"line":41,"column":3,"offset":745},"end":{"line":41,"column":11,"offset":753},"indent":[]}}],"position":{"start":{"line":41,"column":1,"offset":743},"end":{"line":41,"column":13,"offset":755},"indent":[]}},{"type":"text","value":" ","position":{"start":{"line":41,"column":13,"offset":755},"end":{"line":41,"column":14,"offset":756},"indent":[]}},{"type":"inlineCode","value":"(value) => ({id: value})","position":{"start":{"line":41,"column":14,"offset":756},"end":{"line":41,"column":40,"offset":782},"indent":[]}},{"type":"text","value":"  ","position":{"start":{"line":41,"column":40,"offset":782},"end":{"line":41,"column":42,"offset":784},"indent":[]}}],"position":{"start":{"line":40,"column":1,"offset":711},"end":{"line":41,"column":42,"offset":784},"indent":[1]}},{"type":"paragraph","children":[{"type":"text","value":"By default the IdSchema constructs a faux entity by placing the value on the ","position":{"start":{"line":43,"column":1,"offset":786},"end":{"line":43,"column":78,"offset":863},"indent":[]}},{"type":"inlineCode","value":"id","position":{"start":{"line":43,"column":78,"offset":863},"end":{"line":43,"column":82,"offset":867},"indent":[]}},{"type":"text","value":" key of an \nobject. If your entity has a different ","position":{"start":{"line":43,"column":82,"offset":867},"end":{"line":44,"column":40,"offset":918},"indent":[1]}},{"type":"inlineCode","value":"idAttribute","position":{"start":{"line":44,"column":40,"offset":918},"end":{"line":44,"column":53,"offset":931},"indent":[]}},{"type":"text","value":" function you can replace this to match.","position":{"start":{"line":44,"column":53,"offset":931},"end":{"line":44,"column":93,"offset":971},"indent":[]}}],"position":{"start":{"line":43,"column":1,"offset":786},"end":{"line":44,"column":93,"offset":971},"indent":[1]}},{"type":"code","lang":"js","meta":null,"value":"const user = new EntitySchema('user', {\n    idAtribute: user => user.email\n});\n\nconst friend = IdSchema(user, {\n    shape: id => ({email: id})\n});\nuser.shape = new ObjectSchema({friend});","position":{"start":{"line":46,"column":1,"offset":973},"end":{"line":55,"column":4,"offset":1170},"indent":[1,1,1,1,1,1,1,1,1]}},{"type":"heading","depth":2,"children":[{"type":"text","value":"Methods","position":{"start":{"line":59,"column":4,"offset":1177},"end":{"line":59,"column":11,"offset":1184},"indent":[]}}],"position":{"start":{"line":59,"column":1,"offset":1174},"end":{"line":59,"column":11,"offset":1184},"indent":[]}},{"type":"heading","depth":3,"children":[{"type":"text","value":".normalize()","position":{"start":{"line":61,"column":5,"offset":1190},"end":{"line":61,"column":17,"offset":1202},"indent":[]}}],"position":{"start":{"line":61,"column":1,"offset":1186},"end":{"line":61,"column":17,"offset":1202},"indent":[]}},{"type":"jsx","value":"<Normalize />","position":{"start":{"line":62,"column":1,"offset":1203},"end":{"line":62,"column":14,"offset":1216},"indent":[]}},{"type":"heading","depth":3,"children":[{"type":"text","value":".denormalize()","position":{"start":{"line":64,"column":5,"offset":1222},"end":{"line":64,"column":19,"offset":1236},"indent":[]}}],"position":{"start":{"line":64,"column":1,"offset":1218},"end":{"line":64,"column":19,"offset":1236},"indent":[]}},{"type":"jsx","value":"<Denormalize />","position":{"start":{"line":65,"column":1,"offset":1237},"end":{"line":65,"column":16,"offset":1252},"indent":[]}},{"type":"export","value":"export const _frontmatter = {\"title\":\"Id Schema\",\"group\":\"Enty\"}","position":{"start":{"line":68,"column":1,"offset":1255},"end":{"line":68,"column":65,"offset":1319},"indent":[]}}],"position":{"start":{"line":1,"column":1,"offset":0},"end":{"line":68,"column":65,"offset":1319}}},"scopeImports":["import React from 'react'"],"scopeIdentifiers":["React"],"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Id Schema\",\n  \"group\": \"Enty\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar Normalize = makeShortcode(\"Normalize\");\nvar Denormalize = makeShortcode(\"Denormalize\");\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"Sometimes data can exist in a partially normalized state. E.g. a user object has a friend key,\\nbut instead of the data giving you the whole object it just returns a user id in its place.\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"// User\\n{\\n    id: '123',\\n    name: 'foo',\\n    friend: '456'\\n}\\n\")), mdx(\"p\", null, \"As long as you already have the friend normalized into state, the Value schemas lets you\\ndenormalize \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"friend\"), \" as a user.\"), mdx(\"h2\", null, \"Params\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"new IdSchema(\\n    name: Schema,\\n    options?: {\\n        create: (value) => entity\\n    }\\n);\\n\")), mdx(\"h3\", null, \"shape\"), mdx(\"p\", null, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"type:\"), \" \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Schema\"), \"  \"), mdx(\"p\", null, \"The Schema that this value represents.\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"const user = new EntitySchema('user');\\nconst friend = IdSchema(user);\\nuser.shape = new ObjectSchema({friend});\\n\")), mdx(\"h2\", null, \"options.create\"), mdx(\"p\", null, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"type:\"), \" \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(id: string) => *\"), mdx(\"br\", {\n    parentName: \"p\"\n  }), \"\\n\", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"default:\"), \" \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"(value) => ({id: value})\"), \"  \"), mdx(\"p\", null, \"By default the IdSchema constructs a faux entity by placing the value on the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"id\"), \" key of an\\nobject. If your entity has a different \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"idAttribute\"), \" function you can replace this to match.\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"const user = new EntitySchema('user', {\\n    idAtribute: user => user.email\\n});\\n\\nconst friend = IdSchema(user, {\\n    shape: id => ({email: id})\\n});\\nuser.shape = new ObjectSchema({friend});\\n\")), mdx(\"h2\", null, \"Methods\"), mdx(\"h3\", null, \".normalize()\"), mdx(Normalize, {\n    mdxType: \"Normalize\"\n  }), mdx(\"h3\", null, \".denormalize()\"), mdx(Denormalize, {\n    mdxType: \"Denormalize\"\n  }));\n}\n;\nMDXContent.isMDXComponent = true;","rawMDXOutput":"/* @jsx mdx */\nimport { mdx } from '@mdx-js/react';\n/* @jsx mdx */\n\nexport const _frontmatter = {\n  \"title\": \"Id Schema\",\n  \"group\": \"Enty\"\n};\nconst makeShortcode = name => function MDXDefaultShortcode(props) {\n  console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\")\n  return <div {...props}/>\n};\nconst Normalize = makeShortcode(\"Normalize\");\nconst Denormalize = makeShortcode(\"Denormalize\");\nconst layoutProps = {\n  _frontmatter\n};\nconst MDXLayout = \"wrapper\"\nexport default function MDXContent({\n  components,\n  ...props\n}) {\n  return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\"MDXLayout\">\n    <p>{`Sometimes data can exist in a partially normalized state. E.g. a user object has a friend key,\nbut instead of the data giving you the whole object it just returns a user id in its place.`}</p>\n    <pre><code parentName=\"pre\" {...{\n        \"className\": \"language-js\"\n      }}>{`// User\n{\n    id: '123',\n    name: 'foo',\n    friend: '456'\n}\n`}</code></pre>\n    <p>{`As long as you already have the friend normalized into state, the Value schemas lets you\ndenormalize `}<inlineCode parentName=\"p\">{`friend`}</inlineCode>{` as a user.`}</p>\n    <h2>{`Params`}</h2>\n    <pre><code parentName=\"pre\" {...{\n        \"className\": \"language-js\"\n      }}>{`new IdSchema(\n    name: Schema,\n    options?: {\n        create: (value) => entity\n    }\n);\n`}</code></pre>\n    <h3>{`shape`}</h3>\n    <p><strong parentName=\"p\">{`type:`}</strong>{` `}<inlineCode parentName=\"p\">{`Schema`}</inlineCode>{`  `}</p>\n    <p>{`The Schema that this value represents.`}</p>\n    <pre><code parentName=\"pre\" {...{\n        \"className\": \"language-js\"\n      }}>{`const user = new EntitySchema('user');\nconst friend = IdSchema(user);\nuser.shape = new ObjectSchema({friend});\n`}</code></pre>\n    <h2>{`options.create`}</h2>\n    <p><strong parentName=\"p\">{`type:`}</strong>{` `}<inlineCode parentName=\"p\">{`(id: string) => *`}</inlineCode><br parentName=\"p\"></br>{`\n`}<strong parentName=\"p\">{`default:`}</strong>{` `}<inlineCode parentName=\"p\">{`(value) => ({id: value})`}</inlineCode>{`  `}</p>\n    <p>{`By default the IdSchema constructs a faux entity by placing the value on the `}<inlineCode parentName=\"p\">{`id`}</inlineCode>{` key of an\nobject. If your entity has a different `}<inlineCode parentName=\"p\">{`idAttribute`}</inlineCode>{` function you can replace this to match.`}</p>\n    <pre><code parentName=\"pre\" {...{\n        \"className\": \"language-js\"\n      }}>{`const user = new EntitySchema('user', {\n    idAtribute: user => user.email\n});\n\nconst friend = IdSchema(user, {\n    shape: id => ({email: id})\n});\nuser.shape = new ObjectSchema({friend});\n`}</code></pre>\n    <h2>{`Methods`}</h2>\n    <h3>{`.normalize()`}</h3>\n    <Normalize mdxType=\"Normalize\" />\n    <h3>{`.denormalize()`}</h3>\n    <Denormalize mdxType=\"Denormalize\" />\n\n    </MDXLayout>;\n}\n\n;\nMDXContent.isMDXComponent = true;"}}