{"analyzedAt":"2022-07-07T06:51:57.221Z","collected":{"metadata":{"name":"ollivander","scope":"unscoped","version":"2.0.2","description":"Wonde API client for Node.js, browsers, and workers","keywords":["wonde"],"date":"2021-11-11T11:50:08.224Z","author":{"name":"Luke Carr","email":"me+oss@carr.sh","url":"https://carr.sh/"},"publisher":{"username":"lukecarr","email":"me@lukecarr.dev"},"maintainers":[{"username":"lukecarr","email":"me@lukecarr.dev"}],"repository":{"type":"git","url":"git+https://github.com/lukecarr/ollivander.git"},"links":{"npm":"https://www.npmjs.com/package/ollivander","homepage":"https://github.com/lukecarr/ollivander#readme","repository":"https://github.com/lukecarr/ollivander","bugs":"https://github.com/lukecarr/ollivander/issues"},"license":"MIT","dependencies":{"ohmyfetch":"^0.4.5"},"devDependencies":{"@commitlint/cli":"^14.1.0","@nuxtjs/eslint-config-typescript":"^7.0.2","@types/jest":"^27.0.2","@types/node":"^16.11.6","commitlint-config-gitmoji":"^2.2.5","eslint":"^8.2.0","gitmoji-changelog":"^2.2.1","husky":"^7.0.4","jest":"^27.3.1","lint-staged":"^11.2.6","nock":"^13.0.5","prettier":"^2.2.1","siroc":"^0.16.0","standard-version":"^9.3.2","ts-jest":"^27.0.7","typescript":"^4.1.2"},"releases":[{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":1},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":3},{"from":"2020-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":6}],"hasTestScript":true,"hasSelectiveFiles":true,"readme":"![ollivander](https://user-images.githubusercontent.com/24438483/126986699-8fcb4f2f-df8b-481c-bbf5-be307fb8c7b8.png)\n\n# 🪄 Ollivander\n\n> Wonde API client for Node.js, browsers, and workers\n\n[![npm](https://img.shields.io/npm/v/ollivander)](https://npmjs.com/package/ollivander)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/lukecarr/ollivander)](https://codeclimate.com/github/lukecarr/ollivander)\n[![npms.io (quality)](https://img.shields.io/npms-io/final-score/ollivander?label=npms.io%20score)](https://api.npms.io/v2/package/ollivander)\n[![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/ollivander)](#)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/ollivander)](https://bundlephobia.com/package/ollivander)\n\n- ⏳ **Promise-based API.** For all of that `async`/`await` goodness!\n- 🏫 **Multi-school support.** Make one request for multiple schools!\n- 📄 **Automatic pagination aggregation.** Wonde's paginated API responses are automatically aggregated into one!\n- 💪 **TypeScript.** Fully typed and self-documenting!\n\n## 🚀 Quick Start\n\n### Install\n\n```bash\n# npm\nnpm i ollivander\n\n# or yarn\nyarn add ollivander\n```\n\n### Import\n\n```js\n// ESM / TypeScript\nimport { $wonde } from \"ollivander\";\n\n// or CommonJS\nconst { $wonde } = require(\"ollivander\");\n```\n\n### Example Usage\n\nFetch all students for two schools:\n\n```js\nconst schools = await $wonde((school) => `/schools/${school}/students`, {\n  schools: [\"A123456789\", \"A987654321\"],\n  token: \"abc123\",\n});\n\nconsole.log(schools[\"A123456789\"]);\n// => Array of school A123456789's students\n```\n\n## 🏫 Single versus multi-school\n\n### Single school mode\n\n```js\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n});\n\nconsole.log(students);\n// => Array of school A123456789's students\n// => i.e. [ ... ]\n```\n\n### Multi-school mode\n\n```js\nconst schools = await $wonde((school) => `/schools/${school}/students`, {\n  schools: [\"A123456789\", \"A987654321\"],\n  token: \"abc123\",\n});\n\nconsole.log(schools);\n// => Object mapping schools to their array of students\n// => i.e. { 'A123456789': [ ... ], 'A987654321': [ ... ] }\n```\n\n## 💪 TypeScript Support\n\nWonde responses can be type assisted using generics:\n\n```ts\ntype Student = { ... };\n\nconst students = await $wonde<Student>(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n});\n\n// => Students now has type definitions\n```\n\n## ♻ Auto Retry\n\nOllivander can be configured to retry requests if an error is encountered:\n\n```js\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n  retry: 5, // => Request will retry 5 times before giving up\n});\n```\n\n> By default, requests will retry `1` time (except for `POST`, `PUT`, and `PATCH` requests, which will not retry).\n\n## 📂 HTTP Headers\n\nYou can supply additional HTTP headers to Wonde's API:\n\n```js\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n  headers: {\n    some: \"header\", // => This will be included in the request (including every paginated request)\n  },\n});\n```\n\n## ⛓ Includes\n\nYou can instruct Wonde's API to populate relationships with includes. Typically, this would be done with the `includes` search parameter, but Ollivander has a specific option for includes:\n\n```js\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n  includes: [\"classes\"], // => Each student object will include their respective classes\n});\n```\n\n## 🔢 Per Page\n\nWonde's API returns paginated responses for arrays of data. You can increase the number of resources returned per request (reducing the overall number of requests):\n\n```js\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  token: \"abc123\",\n  perPage: 200, // => Wonde's API caps this value at 200 (5000 when retrieving attendance sessions)\n});\n```\n\n> ⚠ It's important to remember that Ollivander will handle paginated responses from Wonde so you never need to make more than one request.\n>\n> However, increasing the `perPage` option will still reduce Ollivander's request time because of the overhead encountered when making a request to Wonde's API.\n\n## 🌍 Wonde Endpoints\n\nWonde's API has separate endpoints/base URLs for the UK and Australia/New Zealand. You can find these endpoints on Wonde's [API Reference](https://docs.wonde.com/docs/api/sync#domains), or import them as constants from Ollivander:\n\n```js\n// ESM / TypeScript\nimport {\n  UK,\n  REST_OF_THE_WORLD,\n  AUSTRALIA,\n  NEW_ZEALAND,\n} from \"ollivander/endpoints\";\n\n// or CommonJS\nconst {\n  UK,\n  REST_OF_THE_WORLD,\n  AUSTRALIA,\n  NEW_ZEALAND,\n} = require(\"ollivander/endpoints\");\n\nconst students = await $wonde(\"/schools/A123456789/students\", {\n  baseURL: AUSTRALIA,\n});\n```\n\n> By default, Ollivander will use Wonde's endpoint for the UK/Rest of the World.\n\n## ⚖ License\n\nOllivander is licensed under the [`MIT License`](LICENSE)."},"npm":{"downloads":[{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-06-30T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":3},{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":11},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":67},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":134},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":305}],"starsCount":0},"github":{"starsCount":0,"forksCount":0,"subscribersCount":1,"issues":{"count":6,"openCount":3,"distribution":{"3600":1,"10800":0,"32400":0,"97200":0,"291600":0,"874800":0,"2624400":0,"7873200":2,"23619600":2,"70858800":1,"212576400":0},"isDisabled":false},"contributors":[{"username":"lukecarr","commitsCount":33}],"commits":[{"from":"2022-06-30T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-06-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-04-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2022-01-08T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":0},{"from":"2021-07-07T00:00:00.000Z","to":"2022-07-07T00:00:00.000Z","count":34}]},"source":{"files":{"readmeSize":4953,"testsSize":0,"hasChangelog":true},"linters":["eslint","prettier"]}},"evaluation":{"quality":{"carefulness":0.9999999999999999,"tests":0,"health":1,"branding":0},"popularity":{"communityInterest":2,"downloadsCount":22.333333333333332,"downloadsAcceleration":-0.1400304414003044,"dependentsCount":0},"maintenance":{"releasesFrequency":0.9,"commitsFrequency":0.9,"openIssues":0.9,"issuesDistribution":0.9}},"score":{"final":0.5235906714576225,"detail":{"quality":0.55,"popularity":0.02466394163553859,"maintenance":0.9998808339576686}}}