{"_id":"@codechem/strapi-fluent-rest-api","_rev":"6-2dd32fe4d9adaf474c508ce4a8dce85c","name":"@codechem/strapi-fluent-rest-api","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.1":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.1","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.1","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"dist":{"shasum":"1a210d79de9b47586f410224f2e9e1b09aa378a3","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.1.tgz","fileCount":11,"integrity":"sha512-BZUiL75bhjNwIxwgYnFDpP7MFmVgN8HntOe4wgl3Q/mouqgdm30N0kx0/BPSnfI6CZZXcZrVbK39MsXGDAsn/g==","signatures":[{"sig":"MEQCICC9TenM4e/bBlrH36oF8KE7pQEQiIQ5GHYbYL25ZI2ZAiAlpX3iM52DzMAGjsAKZB3Cfa+90bZv6m8GdjHA0vrOBQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38794},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"52082e228c087a4c00a79d27fa8df161f75dd2a9","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.1_1732751063397_0.09182531773588587","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.2","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.2","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"dist":{"shasum":"ee48c8e288fb42ba3fdaf39e8644eeca73bfde1c","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.2.tgz","fileCount":12,"integrity":"sha512-AbNVfzelKP7aVnl+OwRprn05fCAW2w2+sw5Jp0n2aAO5sL0RZVnY+qKdJ0BnyEejBU99QP4bScsGA1A+5bkCqQ==","signatures":[{"sig":"MEYCIQCIRyfDWSHtZlYvr2ptq9ihPzSfi5U+mSly4wzQ+JsHGQIhAJadQOgvLEQakZvskyST6P7pUQbdbBH1yFmQZIioCpBY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47389},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ab068dff22d1cb4a68520ddc8cd09f44e3844f32","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"repository":{"url":"git+https://github.com/codechem/strapi-fluent-rest-api.git","type":"git"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.2_1732752280212_0.588674588759972","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.3","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.3","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"dist":{"shasum":"423eef192fd5a8b5ac54e8231cf6e43b423bbebd","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.3.tgz","fileCount":12,"integrity":"sha512-oRbDB2g9fOz30HqT37xyGOX2K6nnDhPDpxCFTqf5m0AvEMcmt1Ca+VWgXwIznZ0iemzZFiJhB6MW1S1SzHOytg==","signatures":[{"sig":"MEUCIDVX1lxRFZghxADNjM1+UCVGCb+R34lhsnHt+Bx0mU5nAiEAsGPMe+cQrofwaxU/1t4mFJIjrAhhlrhKArpYhrXuWM0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47389},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"cf647915c607713a5a7e25c80f4c8bed1463a4d5","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"repository":{"url":"git+https://github.com/codechem/strapi-fluent-rest-api.git","type":"git"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.3_1732824888564_0.683275571465151","host":"s3://npm-registry-packages"}},"0.0.4":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.4","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.4","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"dist":{"shasum":"de1021a661de989b45dafbab8444eff01b5310c9","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.4.tgz","fileCount":12,"integrity":"sha512-CdywHNGSFT2ElPOtf7kmbvMQH/zC/reg9eYo9YjMEw/5f7cZURYeovToD7pj7JXlUsrQ+73gaur6C2RHCaMBAA==","signatures":[{"sig":"MEUCIQCT8MEKJ4yLa+Uz4sI/Ac5BbQappLmwIRBEnO2TGaXZawIgMg3vFT+9TQp0nEK34KgudhxcK23JyKhzs27UHf3Zvvo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47386},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"302747eeb5b60356de022363a558e9e7547a12f1","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"repository":{"url":"git+https://github.com/codechem/strapi-fluent-rest-api.git","type":"git"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.4_1732825525569_0.9642686884667642","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.5","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.5","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"dist":{"shasum":"608bf261f8a82a145bd34ff9fb0b620dc092dab3","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.5.tgz","fileCount":12,"integrity":"sha512-1EXFaiWsPaUHnU/iFYDNBGR0Jdg6oA5c9co27dEbZN/OZnk2pFGLwyCI45yJnK3WaT1AxCk6kiSXLxa4BjmxsQ==","signatures":[{"sig":"MEQCIEgiuV7qm++f9gWh62zN2L+/AXaPgJtgatpz65y649hwAiAsjXFvzhXnMh8da3ZDmPyCwKC8GUIZHqOkjIXb197r5w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47386},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"4c50eb7cd644660170fec2640c1732b4b6658dfd","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"repository":{"url":"git+https://github.com/codechem/strapi-fluent-rest-api.git","type":"git"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.5_1732870302412_0.01838362438413066","host":"s3://npm-registry-packages"}},"0.0.6":{"name":"@codechem/strapi-fluent-rest-api","version":"0.0.6","author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","_id":"@codechem/strapi-fluent-rest-api@0.0.6","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"dist":{"shasum":"96ddc49a5f759dd9ddfd4ecfae8182c335b5e21f","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.6.tgz","fileCount":12,"integrity":"sha512-oKutabBpjhXqEfa456W8DYFQ1Oxj2kNiVuawZtrKkDbsqh4cksGkORIWhygHkh+Kc7WKMYjnY144xnUlAEthTg==","signatures":[{"sig":"MEUCIHPef9UqDpBm2q+R4Kjh94hjAQNexU3rG51vY/jTvXKJAiEAjG9yB7w6sPVHhQ2V8Q9qqhlklwFO8MCIk23D7eHyGUg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47389},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"7523e507edf0a040541cbd72f1821ba2cf0dc9e5","private":false,"scripts":{"dev":"tsc -w","test":"vitest","build":"tsc"},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"repository":{"url":"git+https://github.com/codechem/strapi-fluent-rest-api.git","type":"git"},"_npmVersion":"10.9.0","description":"Fluent API for Strapi REST API","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":true,"devDependencies":{"vitest":"^2.1.6","@types/qs":"^6.9.17","typescript":"^5.7.2","@types/lodash":"^4.17.13"},"peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/strapi-fluent-rest-api_0.0.6_1732878005355_0.7930554125286273","host":"s3://npm-registry-packages"}},"0.0.7":{"name":"@codechem/strapi-fluent-rest-api","private":false,"version":"0.0.7","repository":{"type":"git","url":"git+https://github.com/codechem/strapi-fluent-rest-api.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc -w","test":"vitest"},"author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","description":"Fluent API for Strapi REST API","peerDependencies":{"qs":"^6.13.1","lodash":"^4.17.21"},"devDependencies":{"@types/lodash":"^4.17.13","@types/qs":"^6.9.17","typescript":"^5.7.2","vitest":"^2.1.6"},"_id":"@codechem/strapi-fluent-rest-api@0.0.7","gitHead":"7523e507edf0a040541cbd72f1821ba2cf0dc9e5","bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-KSCR+XNItCdIJg3bFcIMO11U6n9/TF95SBs1hAPCFj5qHNndaLZswXL7S+TLnb/g6nhC9zXxnpEvc79FLLBz7Q==","shasum":"315581d77397c01b544069801db687616db6cf69","tarball":"https://registry.npmjs.org/@codechem/strapi-fluent-rest-api/-/strapi-fluent-rest-api-0.0.7.tgz","fileCount":12,"unpackedSize":49803,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJGodChs4a3+Zeogp5dVHL6hO2zYJmx1KWQbYEVq/uWAIgTDQ72Xf3dm/rbI757X13JEyYYZClmamiH7/tBjqCh8k="}]},"_npmUser":{"name":"iboshkov","email":"ilija@codechem.com"},"directories":{},"maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strapi-fluent-rest-api_0.0.7_1732888117517_0.2312309097500984"},"_hasShrinkwrap":true}},"time":{"created":"2024-11-27T23:44:23.323Z","modified":"2024-11-29T13:48:37.945Z","0.0.1":"2024-11-27T23:44:23.552Z","0.0.2":"2024-11-28T00:04:40.385Z","0.0.3":"2024-11-28T20:14:48.775Z","0.0.4":"2024-11-28T20:25:25.826Z","0.0.5":"2024-11-29T08:51:42.573Z","0.0.6":"2024-11-29T11:00:05.535Z","0.0.7":"2024-11-29T13:48:37.717Z"},"bugs":{"url":"https://github.com/codechem/strapi-fluent-rest-api/issues"},"author":{"name":"Ilija Boshkov","email":"ilija@codechem.com"},"license":"MIT","homepage":"https://github.com/codechem/strapi-fluent-rest-api#readme","repository":{"type":"git","url":"git+https://github.com/codechem/strapi-fluent-rest-api.git"},"description":"Fluent API for Strapi REST API","maintainers":[{"name":"ccadm","email":"costa@codechem.com"},{"name":"iboshkov","email":"ilija@codechem.com"},{"name":"stefan.popovski","email":"stefan@codechem.com"}],"readme":"# Strapi Fluent Query Builder\n\nStrapi Fluent Query Builder is a powerful library designed to simplify building dynamic queries for Strapi, a popular open-source headless CMS. The library provides a fluent API for constructing complex queries, including filtering, sorting, pagination, relation population, and more.\n\nWhile intended to be fully compatible with Strapi's REST API, this library is agnostic to Strapi and can be used with any RESTful API that follows similar conventions.\n\n## Features\n\n- **Fluent API**: Build queries using a clean, chainable API.\n- **Filters**: Support for multiple filter types (equality, inclusion, `contains`, logical operators like `$and`, `$or`, `$not`, and more).\n- **Sorting**: Sort by one or more fields, with both ascending and descending order.\n- **Pagination**: Control pagination with options for page size, starting index, page number, and total count.\n- **Relation Population**: Populate relations and nested relations with the ability to filter and select specific fields from related resources.\n- **Content Status**: Easily filter content based on status (`published`, `draft`).\n- **Localization**: Query content in different locales.\n- **Field Selection**: Select specific fields to reduce payload size and improve performance.\n- **Type Safety**: Built with TypeScript, ensuring full type safety across all query operations.\n\n## Installation\n\nTo install the library, use npm or yarn:\n\n```bash\nnpm install @codechem/strapi-fluent-rest-api\n```\n\nOr with yarn:\n\n```bash\nyarn add @codechem/strapi-fluent-rest-api\n```\n\n## Usage\n\n### Basic Query Building\n\nCreate a query builder instance using the `query` function, then chain methods to customize your query:\n\n```typescript\nimport { query } from '@codechem/strapi-fluent-rest-api';\n\nconst result = query('books')\n    .where('title.$contains', 'example')\n    .sort('createdAt', 'desc')\n    .page(1)\n    .pageSize(10)\n    .get();\n\nconsole.log(result);\n```\n\n### Filtering\n\nYou can apply filters using the `where` or `filter` methods. The `where` method allows you to specify a field and its value, while the `filter` method accepts a bulk filter object.\n\n```typescript\n// Using where method\nconst result = query('templates')\n    .where('title.$eq', 'test')\n    .where('status.$eq', 'published')\n    .get();\n\n// Using filter method\nconst result = query('templates').filter({\n    title: { $eq: 'test' },\n    status: { $eq: 'published' },\n    tags: { $in: [1, 2, 3] },\n}).get();\n```\n\nYou can also use logical operators such as `$and`, `$or`, and `$not` to combine multiple filters.\n\n```typescript\n// Using logical operators\nconst result = query('templates')\n    .and(\n        { title: { $eq: 'test' } },\n        { status: { $eq: 'published' } }\n    )\n    .or({ tags: { $in: [1, 2, 3] } })\n    .get();\n```\n\n### Sorting\n\nSort the query results by one or more fields using the `sort` method. You can specify the sort direction (`asc` or `desc`):\n\n```typescript\nconst result = query('templates')\n    .sort('createdAt', 'desc')\n    .sort('title', 'asc')\n    .get();\n```\n\n### Pagination\n\nControl pagination by using `page`, `pageSize`, `limit`, and `start` methods. You can also request the total count of results by using the `withCount` method:\n\n```typescript\nconst result = query('templates')\n    .page(1)\n    .pageSize(10)\n    .start(0)\n    .limit(10)\n    .withCount(true)\n    .get();\n```\n\n### Population of Relations\n\nYou can populate related resources using the `populate` method. To populate nested relations or apply filters to related resources, use `populateQ`:\n\n```typescript\n// Populate a single relation\nconst result = query('books').populate('user');\n\n// Populate multiple relations\nconst result = query('books').populate('user', 'readers.books');\n\n// Populate relations with filters\nconst result = query('books').populateQ('user', user => user.where('name.$eq', 'John Doe'));\n\n// Populate nested relations with filters\nconst result = query('books').populateQ(\n    query('user')\n        .where('name.$eq', 'John Doe')\n        .populateQ('friends', friend => friend..where('name.$eq', 'Jane Doe'))\n);\n```\n\n### Content Status & Localization\n\nYou can filter content based on its status (published or draft) using the `status`, `drafts`, and `published` methods:\n\n```typescript\nconst result = query('templates').published();  // Status: published\nconst result = query('templates').drafts();     // Status: draft\n```\n\nAdditionally, set the locale of the content with the `locale` method:\n\n```typescript\nconst result = query('templates').locale('mk');\n```\n\n### Field Selection\n\nReduce the response size by selecting only the fields you need with the `fields` or `select` method:\n\n```typescript\nconst result = query('templates').fields('id', 'title', 'description');\n```\n\n### Query String Generation\n\nYou can generate the full query string using the `qs` method, or generate the full URL with the `full` method, which includes the resource name and query string:\n\n```typescript\nconst queryString = query('templates')\n    .where('title.$eq', 'test')\n    .qs();\n\nconsole.log(queryString);  // Generated query string\n\nconst fullUrl = query('templates').full();\nconsole.log(fullUrl);  // Full URL with query string\n```\n\n## TypeScript Support\n\nThis library is written in TypeScript and aims to provide as much type safety as possible for query building, ensuring that you can use autocompletion and type checking while constructing your queries. More support for type safety is hopefully coming in the future.\n\n## Running Tests\n\nTo run the tests for this library, use the following command:\n\n```bash\nnpm test\n```\n\nThe library includes tests for various query operations, including filtering, sorting, pagination, and relation population.\n\n## Contributing\n\nContributions are welcome! If you have ideas for new features or improvements, please open an issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.\n","readmeFilename":"README.md"}