{"_id":"@aaryav/js-client-rest","name":"@aaryav/js-client-rest","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@aaryav/js-client-rest","version":"2.0.0","engines":{"node":">=18.0.0","pnpm":">=8"},"repository":{"type":"git","url":"git+https://github.com/arya/arya-js.git","directory":"packages/js-client-rest"},"bugs":{"url":"https://github.com/arya/arya-js/issues"},"homepage":"https://github.com/arya/arya-js#readme","license":"Apache-2.0","type":"module","exports":{".":{"types":"./dist/types/index.d.ts","browser":"./dist/browser/index.js","require":"./dist/cjs/index.js","default":"./dist/esm/index.js"}},"types":"./dist/types/index.d.ts","browser":"./dist/browser/index.js","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","publishConfig":{"access":"public"},"sideEffects":false,"config":{"openapi_schema_remote":"https://raw.githubusercontent.com/arya/arya/master/docs/redoc/master/openapi.json"},"dependencies":{"openapi-typescript-fetch":"2.1.0","@sevinf/maybe":"0.5.0","undici":"~5.28.5"},"devDependencies":{"@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-replace":"^5.0.2","@total-typescript/ts-reset":"^0.4.2","@types/semver":"7.5.7","openapi-typescript":"^6.2.6","semver":"7.6.0","ts-prune":"^0.10.3","vitest":"^0.31.4"},"peerDependencies":{"typescript":">=4.7"},"scripts":{"build":"pnpm tsc:build && pnpm bundle","test":"vitest","test:integration":"vitest run --config vitest.integration.config.ts","pre-check":"pnpm tsc:check && pnpm tsc:deadcode && pnpm lint && pnpm test run","pre-commit":"pnpm tsc:check && pnpm tsc:deadcode && pnpm lint-staged && pnpm test run","tsc:deadcode":"ts-prune -e -i 'src/openapi|src/index.ts|vitest.config.ts|vitest.integration.config.ts'","tsc:check":"tsc --noEmit","tsc:build":"pnpm clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json","bundle":"rollup -c rollup.config.js","lint":"eslint src","clean":"rimraf ./dist","codegen:openapi-typescript":"openapi-typescript $npm_package_config_openapi_schema_remote --output src/openapi/generated_schema.ts"},"_id":"@aaryav/js-client-rest@2.0.0","description":"This repository contains the REST client for the [Arya](https://github.com/arya/arya) vector search engine.","_integrity":"sha512-xycQ8z6021bG22Ehx8q9ip2JLJj36eAPAa17M+MATURrtYnA2cMqh1rff56Nylyst85a5/AmsxZVJjXivEkY3g==","_resolved":"/private/var/folders/t0/62pch4m55wgfy0_tt7864qzc0000gn/T/f5c05a1558fe89de641aad18bcf3674c/aaryav-js-client-rest-2.0.0.tgz","_from":"file:aaryav-js-client-rest-2.0.0.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-xycQ8z6021bG22Ehx8q9ip2JLJj36eAPAa17M+MATURrtYnA2cMqh1rff56Nylyst85a5/AmsxZVJjXivEkY3g==","shasum":"c18e1369a3bd63ada7d4b2e3dc249c9bc771450c","tarball":"https://registry.npmjs.org/@aaryav/js-client-rest/-/js-client-rest-2.0.0.tgz","fileCount":50,"unpackedSize":3826532,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDC/L+juLdYOeYf/dTXiMSovtE/Ey7dI8rlwGzU2H9PKAIhALvlp+bTjK0LFGnWiRxhs00R+pOzTeIOzVHn5OP+OioR"}]},"_npmUser":{"name":"vasutech","email":"vasutech@gmail.com"},"directories":{},"maintainers":[{"name":"vasutech","email":"vasutech@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/js-client-rest_2.0.0_1745084865526_0.7679226535057502"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-19T17:47:45.460Z","2.0.0":"2025-04-19T17:47:45.746Z","modified":"2025-04-19T17:47:46.000Z"},"maintainers":[{"name":"vasutech","email":"vasutech@gmail.com"}],"description":"This repository contains the REST client for the [Arya](https://github.com/arya/arya) vector search engine.","homepage":"https://github.com/arya/arya-js#readme","repository":{"type":"git","url":"git+https://github.com/arya/arya-js.git","directory":"packages/js-client-rest"},"bugs":{"url":"https://github.com/arya/arya-js/issues"},"license":"Apache-2.0","readme":"# JavaScript Arya REST Client\n\nThis repository contains the REST client for the [Arya](https://github.com/arya/arya) vector search engine.\n\n## Installation\n\n```shell\nnpm install @arya/js-client-rest\n# or\nyarn add @arya/js-client-rest\n# or\npnpm i @arya/js-client-rest\n```\n\n## Usage\n\nRun the Arya Docker container:\n\n```shell\ndocker run -p 6333:6333 arya/arya\n```\n\n### Instantiate a client\n\n```ts\nimport {AryaClient} from '@arya/js-client-rest';\n\nconst client = new AryaClient({host: '127.0.0.1', port: 6333});\n// or\nconst client = new AryaClient({url: 'http://127.0.0.1:6333'});\n```\n\n### Make requests\n\nUsing one of the available facade methods:\n\n```ts\ntry {\n    const result = await client.getCollections();\n    console.log('List of collections:', result.collections);\n} catch (err) {\n    console.error('Could not get collections:', err);\n}\n```\n\nOr directly using an endpoint from the API:\n\n```ts\nawait client.api('collections').getCollections();\n```\n\n### Typed Error Handling\n\nA non-ok fetch response throws a generic `ApiError`\n\nBut an Openapi document can declare a different response type for each status code, or a default error response type.\n\nThese can be accessed via a discriminated union on status, as in code snippet below:\n\n```ts\nconst findPetsByStatus = fetcher.path('/pet/findByStatus').method('get').create();\nconst addPet = fetcher.path('/pet').method('post').create();\n\ntry {\n    const collection = await client.getCollection('bom-ada-002');\n    // ...\n} catch (e) {\n    // check which operation threw the exception\n    if (e instanceof client.getCollection.Error) {\n        // get discriminated union error { status, data }\n        const error = e.getActualType();\n        // sort case's logic\n        if (error.status === 400) {\n            error.data.status.error; // only available for a 4xx responses\n        } else if (error.status === 500) {\n            error.data.status.error; // only available for a 500 response\n        } else {\n            error.data.result;\n            // ...\n        }\n    }\n}\n```\n\n## Support\n\nThe REST implementation relies on the native [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), which is available in Deno and Node.js (starting on v18.0.0 without experimental flag). The Deno implementation [supports HTTP/2](https://deno.com/blog/every-web-api-in-deno#fetch-request-response-and-headers) whereas Node.js is still lagging on the spec and provide only HTTP 1.1 support (this is due to the fact that under the hood Node.js still relies on [undici](https://github.com/nodejs/undici)).\n\n## Releases\n\nMajor and minor versions align with Arya's engine releases, whilst patch are reserved for fixes regarding the current minor release. Check out [RELEASE.md](../../RELEASE.md) for more info on release guidelines.\n\n## Contributing\n\nThese are the most relevant scripts for development:\n\n-   `pnpm build`: builds and bundles from TypeScript sources\n-   `pnpm pre-check`: type-checks sources\n-   `pnpm pre-commit`: same as pre-check, but for git hooks (husky)\n-   `pnpm test`: run unit tests\n-   `pnpm test:integration`: runs integration tests against a locally running Arya docker container\n-   `pnpm codegen:openapi-typescript`: updates generated TS schema from the latest openapi.json remote\n","readmeFilename":"README.md","_rev":"1-839afcc7a3f79868748c9c44ac45e1de"}