{"_id":"@davestewart/es-kit","_rev":"4-bfdb363557ac200dea285ea9baa293cb","name":"@davestewart/es-kit","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.0":{"name":"@davestewart/es-kit","version":"0.1.0","description":"A pick-and-mix utility library that simplifies writing Elasticsearch code","_id":"@davestewart/es-kit@0.1.0","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-PqFlcHl8tNnh7Z1PzvYmDv+BV/tI9GytxyVwnQlsMytX5xPvc02/jmnKPWRrTU7/59W61dcL1ToU1XI02a1rSA==","shasum":"6c23bc59e0320e2a5716d1547d5b77d079ca361e","tarball":"https://registry.npmjs.org/@davestewart/es-kit/-/es-kit-0.1.0.tgz","fileCount":1,"unpackedSize":152,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpBImCRA9TVsSAnZWagAAX8kQAJm4+z8dq3esgAxzuPkV\npCTGPdN2Sn+kVqvv6yWb5p0nhnuImbbL7DDmmfWpFuqawDBTVQRgAoYltrPt\nyHL2gcI+a8GNQS/0vSThZlwxaJ1c+v5iDNOCqavcOWMLC4Jtx0XDZqbyeCKZ\nw4XX3tDpjlFw2Trb4Dno+F03kGF+DfxsXROdlSrWTk7GcPe54HtJ2bBuUrzR\nQQ4dj1nTuZTysfsdL1uNgjOc7xPyNxmGO7iN8CtGQOUphSnJF1a27u2PDcOv\nEUi3JIprh+AuEE91uSHEyIvGh82t8ReprahIrduAALkPJyHh5gwFdodte6CR\nCQiHHaMaHIlv8RwdWdL4gC7uzrydhO9GJ1sbhOcdAa+f9xwOEv3c2KJo8F1+\nkl2/YXWS/YHfI/sYrwuc985uKcqsbDYxekkSOFuk6boO4xVF5W+OCpkulC+s\n5C8vTozWRiDwbPmqGX947b+TC4wsJAVNfRkpfXTZ8xNTh1d0yus7TB8v1YXZ\nOQrgyXCMK2iiiJ1QYaxlvjoPDhvUSlXbDJOC/VTQl/UffR659EsMs0N9mC13\nx3K3dK/MxV6iB+xLEW4tUB/g7c59X2IKv/BuU205blFj23eYul8ZzFrxbi3A\nFOVoCuL1NFsyhDF2M8EsRKKEOv9nYN0t8ho8ZERgrdAj2SUWLOPJ+1V3PCu/\nQywh\r\n=L6oL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIARm2uB9VVghivvhm4jkla+lGZ2L8nb9L9EGLMlVzK7xAiB8IkWw9nJIOcCTprz5iGm29hCgCIedvYk8My1bT4328g=="}]},"_npmUser":{"name":"davestewart","email":"dev@davestewart.co.uk"},"directories":{},"maintainers":[{"name":"davestewart","email":"dev@davestewart.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/es-kit_0.1.0_1638142502353_0.6438065286987587"},"_hasShrinkwrap":false},"0.2.1":{"name":"@davestewart/es-kit","version":"0.2.1","description":"A pick-and-mix utility library that simplifies writing Elasticsearch code","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/davestewart/es-kit.git"},"author":{"name":"Dave Stewart"},"license":"MIT","homepage":"https://github.com/davestewart/es-kit#readme","bugs":{"url":"https://github.com/davestewart/es-kit/issues"},"keywords":["elastic","elasticsearch","utility","dx"],"scripts":{"test":"jest ./tests --verbose","lint":"eslint src/** --ext .js --ext .ts","lint:fix":"npm run lint -- --fix","build":"node build.js","build:clean":"rimraf dist/*","build:types":"tsc --declaration --emitDeclarationOnly --outDir dist","build:watch":"npm run build -- --watch","prepare":"npm run build:clean && npm run build && npm run build:types"},"dependencies":{"@types/elasticsearch":"^5.0.40","semi":"^4.0.5"},"devDependencies":{"@elastic/elasticsearch":"^7.15.0","@typescript-eslint/eslint-plugin":"^5.4.0","@typescript-eslint/parser":"^5.4.0","esbuild":"^0.14.0","eslint":"^7.32.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.25.3","eslint-plugin-jest":"^25.3.0","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.1","jest":"^27.3.1","typescript":"^4.5.2"},"gitHead":"0456da1336929995f5baa94401b6de6aa6dd23ee","_id":"@davestewart/es-kit@0.2.1","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-B2/ryclxYA5jRjtkx8OnlYBODEgBX3XQCurxi1ugv5W4XILMQadkeWOqHwQuzBeGO3unt0vy03JSkt+MpHK7NQ==","shasum":"65c9db760285c4fed51e9f016c5567da19f371cd","tarball":"https://registry.npmjs.org/@davestewart/es-kit/-/es-kit-0.2.1.tgz","fileCount":19,"unpackedSize":72673,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhqNBgCRA9TVsSAnZWagAAMhoP/2Y29AO9jPpB98tHZ9+X\nFt1oFa+iXeOC7fIQTYflZ4yD41cFVijOVcC4qpmT1P+vr8WkgCcPkQgxWbTY\ngSD5uGUw5GEHGmuNqcChwSe0o6T55NIeJnOMm3EajiQjOU6lYI2OzoDE4wao\nlVsphSTfttmpTy5RO5K7Fi6wYVPNLqxTWiEB7aoISTB7mEignC3DfuC7qndX\nreBE0y9qP/HPhi/jWJtSrpkE6nzbOi8FBSECq5OUAjkHbPmKnDa+8+bW873J\nSM6ByT8BkUYjFPk7Lz4c5K/UiHhYneKbUhuJx+yvrMAKR4HNd/vH87CJOfc0\nKA9AyqYiOUZyUs2c+a3KIKx1MGpYy2D/Sfm67z3kRacu08PCCWMrqu10FO4X\njh9jjaN+sWoZ8EYu7Cbp6eDb/JxaOqowXNYg/dgfCLhTCHVmf1uOgX0ZdmZr\nDvLHxmw7q6rDmxoj6yAqDDqUEkhRekO6Xfk9ZBSyEyUuqSVkStfkwCQ6y/Ia\nrum/vi4PXcwdLE6rqJBaF8fRtBiK58yVlPMLEpkkNUbLIhZNNTLLM11Be3Lb\nXmm1dKFJRsTxGW/Hf/Cy+dqVQtGidTMVXf4IelUV4Rm6TTpUG2k35+xACkkZ\nHTvtMjLHbXEf5BQevwTwg1pEVbJ+EBcEX6AjmppAjpq6xBvdEoV1EXsy2usz\nYtEm\r\n=A55C\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD4n7saV0v9uP8yUqXE64hH0LMujVPMsup8xWg+1g/HjgIhAK++WsaF+jhKoVmn5K0cnE7Oc2oGar1ntE0NUKDIpF0B"}]},"_npmUser":{"name":"davestewart","email":"dev@davestewart.co.uk"},"directories":{},"maintainers":[{"name":"davestewart","email":"dev@davestewart.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/es-kit_0.2.1_1638453343916_0.6185637366923735"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-28T23:35:02.292Z","0.1.0":"2021-11-28T23:35:02.487Z","modified":"2022-04-05T03:05:22.639Z","0.2.0":"2021-11-30T20:59:30.537Z","0.2.1":"2021-12-02T13:55:44.064Z"},"maintainers":[{"name":"davestewart","email":"dev@davestewart.co.uk"}],"description":"A pick-and-mix utility library that simplifies writing Elasticsearch code","readme":"# ES Kit\n\n> ES Kit is a \"pick and mix\" library that simplifies writing Elasticsearch code\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/davestewart/es-kit/ff11c8dca141beaccd8a0d099785ba9cfbd226aa/assets/es-kit.svg\" alt=\"ES Kit logo\">\n</p>\n\n\n\n\n## Abstract\n\nElasticsearch's [JavaScript Client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html) provides a powerful way to call Elasticsearch [APIs](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html) but its inherent flexibility can be an issue:\n\n- complex request and response formats can lead to verbose, duplicate or fragile application code\n- if you're new to the API, documentation or terminology, it's difficult to know what code to write \n\nTo address this, ES Kit provides a constrained \"kit of parts\" in the form of reusable, atomic helper functions which fit together to reliably abstract the API lifecycle, making it quick, easy (and reasonably obvious how) to write clean, trial-and-error-free client code.\n\n## Who is this library for?\n\nWhilst primarily aimed at [simplifing Elasticsearch for new users](docs/elastic/README.md), ES Kit aims to be useful for any user:\n\n- **New users**: use the query functions and Api to get up and running quickly\n- **Improving users**: use the docs, query functions and helpers to learn how Elasticsearch fits together\n- **Experienced users**: customise the core helpers to build requests and parse responses in less overall code\n\n> **New users**: check the [Elasticsearch 101](docs/elastic/101.md) document for a valuable primer on how ES works differently to how you might expect and the [Elasticsearch tips](docs/elastic/tips.md) document on how to work *with* Elastic vs *against* it.\n\n## The kit\n\nES Kit comprises the following components:\n\n| Type                         | Purpose                                                      | Code example                      |\n| ---------------------------- | ------------------------------------------------------------ | --------------------------------- |\n| [Queries](docs/utilities/queries.md) | Build Elastic queries using simple functions                 | `_multiMatch('*', 'cat')`         |\n| [Helpers](docs/utilities/helpers.md) | Abstract key parts of the Elastic API lifecycle | `$paginate(res)`                  |\n| [Scripts](docs/utilities/scripts.md) | Build Elastic scripts from JavaScript functions     | `_removeFromArray('listIds', 24)` |\n| [Api](docs/api/README.md)         | Simplified interaction with Elasticsearch's APIs | `Api.search('contacts', params)`  |\n\nEach of the helpers, functions or classes aims to be simple, atomic and [transparent](src/modules); rather than a complex or overly-abstracted monolithic framework, these small self-contained units let you go all-in on abstraction or pick and mix what suits your development style or project.\n\nIf a helper doesn't fit your use case:\n\n-  write that bit of code yourself, and quickly move on\n- extend the [Helpers](docs/api/README.md) with your new code and use it again \n\n## Code examples\n\n### Quick and easy\n\nUse the [query](docs/utilities/queries.md) builder functions and [Api](docs/api/README.md) class to handle configuration, loading, parsing, pagination and error handling in a single line:\n\n```js\nreturn Api.search('contacts', _.should([\n  _.prefix('name', 'ke')\n  _.match('lists', 'sales'),\n  _.multiMatch('*', 'san diego'),\n]), { size: 20, from: 100 })\n```\n\n> **New users**: check the [Elastic tips](docs/elastic/tips.md) document to understand which queries to use and when  \n\nAdditionally, unlike Elasticsearch's APIs, ES Kit's [Api](docs/api/README.md) returns simplified, *consistent* response data across all Search and Document API requests, making it super-easy to get started without spending time worrying if you're doing it right or reinventing the wheel:\n\n```\n[\n  {\n    \"_id\" : \"ZRWBNH0Bk8QNffIJQWQp\",\n    \"name\" : \"Kelly Hill\",\n    \"notes\": \"Works in the San Diego area\"\n    \"lists\": [\n    \t\"sales\"\n    ]\n  },\n  {\n    \"_id\" : \"lCloSH0Bs3kx_70FRmtW\",\n    \"name\" : \"Kevin James\",\n    \"office\": \"San Diego\"\n    \"lists\": []\n  }\n]\n```\n\n### Fully customised\n\nES Kit is designed to be used as a kit of parts; there are helper functions to handle each stage of the request / response lifecycle.\n\nYou can create [scripts](docs/utilities/scripts.md) on the fly or pick from ES Kit's library (making [Painless](https://www.elastic.co/guide/en/elasticsearch/painless/master/index.html) relatively pain-free!):\n\n```js\nconst script = $.script(function (ctx, params) { ... }, { lists: 'sales' })\n```\n\nYou can build [request options](docs/utilities/helpers.md#requests) passing `query`, `script`, and  ` sort` options to the native client as you would normally:\n\n```js\nconst res = client.updateByQuery({ index: 'contacts', query, script, sort })\n```\n\nOr parse [response data](docs/utilities/helpers.md#responses) without writing lots of call-specific code:\n\n```js\nreturn $.paginate(res, options)\n```\n\n## Next steps\n\nInstall via NPM:\n\n```\nnpm i @davestewart/es-kit\n```\n\nThen, start writing code:\n\n- [ES Kit Documentation](docs/README.md)\n\nIf you're new to Elastic, get up to speed:\n\n- [Elastic Reference](docs/elastic/README.md)\n\n","readmeFilename":"README.md","homepage":"https://github.com/davestewart/es-kit#readme","keywords":["elastic","elasticsearch","utility","dx"],"repository":{"type":"git","url":"git+https://github.com/davestewart/es-kit.git"},"author":{"name":"Dave Stewart"},"bugs":{"url":"https://github.com/davestewart/es-kit/issues"},"license":"MIT"}