{"_id":"@csberger/gatsby-source-apiserver","_rev":"1-62b79d1c5be15684185b08343a71bc12","name":"@csberger/gatsby-source-apiserver","dist-tags":{"latest":"2.1.3"},"versions":{"2.1.3":{"name":"@csberger/gatsby-source-apiserver","version":"2.1.3","description":"Gatsby plugin to handle any third party api data intake.","main":"index.js","scripts":{"build":"babel src --out-dir . --ignore __tests__","watch":"babel -w src --out-dir . --ignore __tests__","prepublish":"cross-env NODE_ENV=production npm run build"},"homepage":"https://github.com/thinhle-agilityio/gatsby-source-apiserver#readme","keywords":["gatsby","gatsby-plugin","gatsby-source-plugin"],"author":{"name":"Christopher Berger","email":"contact@christopherberger.info"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/csberge/gatsby-source-apiserver.git"},"devDependencies":{"babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","babel-preset-stage-2":"^6.24.1","cross-env":"^5.1.4"},"dependencies":{"axios":"^0.19.0","babel-cli":"^6.26.0","babel-runtime":"^6.26.0","chalk":"^2.3.2","crypto":"^1.0.1","deep-map-keys":"^1.2.0","json-stringify-safe":"^5.0.1","nanoid":"^1.0.2"},"gitHead":"0f1d50d6beef0e537e6f1a67f758b16d809636bb","bugs":{"url":"https://github.com/csberge/gatsby-source-apiserver/issues"},"_id":"@csberger/gatsby-source-apiserver@2.1.3","_npmVersion":"6.2.0","_nodeVersion":"10.0.0","_npmUser":{"name":"csberger","email":"contact@christopherberger.info"},"dist":{"integrity":"sha512-DGolCrmG902eU7RVMS/wnYCR3TZjKIsPRLTPRZl3d5TuE7VY9Lu9ySenO5mjaW2LRL6Z4/J+B5dXsnTfkXlCrA==","shasum":"561288739ddb2dc46db0e5f0a602e4f3a639d441","tarball":"https://registry.npmjs.org/@csberger/gatsby-source-apiserver/-/gatsby-source-apiserver-2.1.3.tgz","fileCount":15,"unpackedSize":114752,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdjZrUCRA9TVsSAnZWagAAcxQP+QF3PBwnDGOi/fw5WJm3\n+dix8R1w5yERGMCS3FdGoqIyOpittiVLQo7KDRs/Kah0Wg7PZYxTWcsGAcua\nlk/oGTvUMQbOtZyWSq6JGFuaTpQEFTo0qZKelmX/2+CrNiuGDaa9K9Ul0i1c\nmQx0F2nsKpy2LZEpZ4BmNCxQbBqcEBkzNu2pFKZokibpiv12BdEXzmhVo4dd\npgs5sd1YmRxjNbmzAV+T6uwZByixa3AjpzCTqjay++aso3EVZnZ2OalBAStH\nNrILj/VwKOuPUld+8z9YapL2/w64zobFf6Q3nyXOAdUC0KQzPFqbDM61/Uci\nC7cFP8AUaN2/NguEvO4KTbK6yp4f00OLvrzBtfEx+bsST+/bj6fvRNirUVAq\nrvjAfv7eQnac+YU8i7LEVha7mWwiDkGnKFT2IUv1PMrpBpFoghuDYnlVN3Gg\ntSHUCI/bV2X/h4BQ/olvy0ptz8zveeusXKaUqFEjyg+R0wPvIfFirY1R3InB\nJ/S85Wfb9JA9p9d1JkBrPI8tieBMlXz2Ir2kVRR779Gqw0WziautKCK2PSNb\nC0hsjv2f4AjmWs7KSNRXkX432ZYy+U7u3K3eQRrmBhlWnV2yIdV39EVz+bXO\nNxWo5f+/HKG1QufFnP1iZRujRgOOHCN7CGRtUlhvGhnAQdm/1NRdk0re6WbQ\n1FJT\r\n=8nhw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCiXLIv2UmG799/sqT50i1d2ZJUpPI9Iat1ZtHQa0CFIQIhALYHH7ECnxM3ghSVLPbMy6Pu35bxzP+gWAhQqStf9ush"}]},"maintainers":[{"name":"csberger","email":"contact@christopherberger.info"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-source-apiserver_2.1.3_1569561300209_0.17512652824105568"},"_hasShrinkwrap":false}},"time":{"created":"2019-09-27T05:14:59.963Z","2.1.3":"2019-09-27T05:15:00.357Z","modified":"2022-04-05T02:01:38.106Z"},"maintainers":[{"name":"csberger","email":"contact@christopherberger.info"}],"description":"Gatsby plugin to handle any third party api data intake.","homepage":"https://github.com/thinhle-agilityio/gatsby-source-apiserver#readme","keywords":["gatsby","gatsby-plugin","gatsby-source-plugin"],"repository":{"type":"git","url":"git+https://github.com/csberge/gatsby-source-apiserver.git"},"author":{"name":"Christopher Berger","email":"contact@christopherberger.info"},"bugs":{"url":"https://github.com/csberge/gatsby-source-apiserver/issues"},"license":"MIT","readme":"# gatsby-source-apiserver\n\nA gatsby source plugin for pulling in third party api data.\n\n## Features\n\n- Pulls data from configured api url\n- Uses custom name to allow for multiple instances of plugin\n- Option to download the json data to a configurable path\n- Option to only download the json data, and skip inserting it into GraphQL\n- Supports simple authentication through axios\n\n## Install\n\n```\nnpm install --save gatsby-source-apiserver\n```\n\nMigrate for Gatsby-v2 release:\n\nPlease checkout version `2.0.0` or `next`\n\n```\nnpm install --save gatsby-source-apiserver@next\n```\n\n## Change logs\n\n- `2.1.3`:\n  - Add ability to refresh node in development by `ENABLE_GATSBY_REFRESH_ENDPOINT` env. [See more](https://www.gatsbyjs.org/docs/environment-variables/#reserved-environment-variables)\n- `2.1.2`:\n  - Upgrade axios to 0.19.0 to fix DoS vulnerability\n  - Fix BoundActionCreators depracation warning\n- `2.1.1`:\n  - Support multiple entities for multiple api servers, pls take a look at attribute `entitiesArray`\n  - Add request params\n  - Support Auth0\n- `2.0.0`: Support gatsby-v2\n\n## How to use\n\n```javascript\n// Place configuration options in your gatsby-config.js\n\nplugins: [\n  {\n    resolve: \"gatsby-source-apiserver\",\n    options: {\n      // Type prefix of entities from server\n      typePrefix: \"internal__\",\n\n      // The url, this should be the endpoint you are attempting to pull data from\n      url: `http://yourapi.com/api/v1/posts`,\n\n      method: \"post\",\n\n      headers: {\n        \"Content-Type\": \"application/json\"\n      },\n\n      // Request body\n      data: {},\n\n      // Name of the data to be downloaded.  Will show in graphQL or be saved to a file\n      // using this name. i.e. posts.json\n      name: `posts`,\n\n      // Nested level of entities in response object, example: `data.posts`\n      entityLevel: `data.posts`,\n\n      // Define schemaType to normalize blank values\n      // example:\n      // const postType = {\n      //   id: 1,\n      //   name: 'String',\n      //   published: true,\n      //   object: {a: 1, b: '2', c: false},\n      //   array: [{a: 1, b: '2', c: false}]\n      // }\n      schemaType: postType,\n\n      // Request parameters\n      // Only available from version 2.1.0\n      params: {\n        per_page: 1\n      },\n\n      // Simple authentication, optional\n      auth: {\n        username: \"myusername\",\n        password: \"supersecretpassword1234\"\n      },\n\n      // Advanced authentication for Auth0\n      // Only available from version 2.1.0\n      auth0Config: {\n        method: \"POST\",\n        url: \"https://MyAuth0Domain/oauth/token\",\n        headers: { \"content-type\": \"application/json\" },\n        data: {\n          grant_type: \"password\",\n          username: \"myusername\",\n          password: \"PassAWordHere\",\n          audience: \"Auth0APIAudience\",\n          scope: \"openid\",\n          client_id: \"AUTH0_CLIENT_ID\",\n          client_secret: \"AUTH0_SECRET\"\n        },\n        json: true\n      },\n\n      // Optional payload key name if your api returns your payload in a different key\n      // Default will use the full response from the http request of the url\n      payloadKey: `body`,\n\n      // Optionally save the JSON data to a file locally\n      // Default is false\n      localSave: false,\n\n      //  Required folder path where the data should be saved if using localSave option\n      //  This folder must already exist\n      path: `${__dirname}/src/data/auth/`,\n\n      // Optionally include some output when building\n      // Default is false\n      verboseOutput: true, // For debugging purposes\n\n      // Optionally skip creating nodes in graphQL.  Use this if you only want\n      // The data to be saved locally\n      // Default is false\n      skipCreateNode: false, // skip import to graphQL, only use if localSave is all you want\n\n      // Optionally re-source data when it changes and\n      // `gatsby develop` is running.\n      // Requires `ENABLE_GATSBY_REFRESH_ENDPOINT=true`.\n      // See https://www.gatsbyjs.org/docs/environment-variables/#reserved-environment-variables\n      // Default is false\n      enableDevRefresh: true,\n\n      // Optionally override key used to re-source data\n      // when `gatsby develop` is running.\n      // Requires `enableDevRefresh: true`.\n      // See setting directly above this one.\n      // See also https://github.com/gatsbyjs/gatsby/issues/14653\n      // Default is `id`\n      refreshId: `id`,\n\n      // Pass an array containing any number of the entity configuration properties (except verbose, auth0Config),\n      // any not specified are defaulted to the general properties that are specified\n      // Only available from version 2.1.0\n      entitiesArray: [\n        {\n          url: `http://yourapi.com/api/v1/posts`,\n          method: \"post\",\n          headers: {\n            \"Content-Type\": \"application/json\"\n          },\n          name: `posts`\n        }\n      ]\n    }\n  }\n];\n```\n\n## How to query\n\nData will be available at the following points in GraphQL.\n\n`all<TypePrefix><Name>` or `<TypePrefix><Name>` where `TypePrefix` and `Name` is replaced by the name entered in the\nconfiguration options.\n\n## Dummy Node\n\nThis plugin will automatically add a dummy node to initialize Gatsby Graphql Schema, in order to avoid GraphQL errors when some fields are missing.\n\nThe dummy node will have `id: 'dummy'` and you will probably want to exclude it from `createPage()`:\n\n```jsx\n<ul>\n  {data.allPosts.edges\n    .filter(({ node }) => node.id !== \"dummy\")\n    .map(({ node }, index) => (\n      <li key={index}>{node.name}</li>\n    ))}\n</ul>\n```\n\nor filter it out from your GraphQL query:\n\n```graphql\nquery {\n    internalAllPosts(filter: {id: {ne: \"dummy\"}}) {\n        // ...\n    }\n}\n```\n\nNote: make sure you pass option `schemaType` to make dummy node works.\n\n### Conflicting keys\n\nSome of the returned keys may be transformed if they conflict with restricted keys used for\nGraphQL such as the following `['id', 'children', 'parent', 'fields', 'internal']`\n\nThese conflicting keys will now show up as `alternative_id`\n","readmeFilename":"README.md"}