feat: adding relation filter (#11)

This commit is contained in:
paranarimasu
2021-08-30 23:41:45 -05:00
committed by GitHub
parent 0bc2157f3f
commit 977f99be84
13 changed files with 135 additions and 72 deletions
+1
View File
@@ -55,6 +55,7 @@ GET /api/anime/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -47,6 +47,7 @@ GET /api/animesynonym/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -61,6 +61,7 @@ GET /api/animetheme/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -55,6 +55,7 @@ GET /api/animethemeentry/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -49,6 +49,7 @@ GET /api/artist/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -52,6 +52,7 @@ GET /api/image/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+60 -8
View File
@@ -90,10 +90,10 @@ The AnimeThemes API Resource Objects relationships are included as top-level mem
{
anime: {
...
synonyms: [
animesynonyms: [
...
],
themes: [
animethemes: [
...
],
series: [
@@ -155,10 +155,10 @@ The AnimeThemes API does **NOT** support fetching resources or relationships.
{
anime: {
...
synonyms: [
animesynonyms: [
...
],
themes: [
animethemes: [
...
],
series: [
@@ -179,11 +179,11 @@ The AnimeThemes API does **NOT** support fetching resources or relationships.
The AnimeThemes API supports inclusion of related resources for every endpoint unless otherwise specified.
```json
// /api/anime/{slug}?include=themes,series
// /api/anime/{slug}?include=animethemes,series
{
anime: {
...
themes: [
animethemes: [
...
],
series: [
@@ -340,10 +340,10 @@ The AnimeThemes API supports an offset pagination strategy for every endpoint th
}
```
For endpoints that produce responses of mixed typed top-level members, the AnimeThemes.moe supports a limit pagination strategy. For these endpoints, the AnimeThemes API support the `limit` query parameter.
For endpoints that produce responses of mixed typed top-level members, the AnimeThemes.moe supports a limit pagination strategy. For these endpoints, the AnimeThemes API support the `page[limit]` query parameter.
```json
// /api/search?q={query}&limit=1
// /api/search?q={query}&page[limit]=1
{
search: {
anime: [
@@ -498,4 +498,56 @@ If the multi-value logical operator is not specified, the filter shall exclude t
```sh
# This will match anime where the year is in {2000,2001,2002}
/api/anime?filter[year]=2000,2001,2002
```
**Special Filters**
Trashed Filter
```sh
# This filter will include soft-deleted anime that are excluded by default
/api/anime?filter[trashed]=with
```
```sh
# This filter will return only soft-deleted anime
/api/anime?filter[trashed]=only
```
```sh
# This filter will return only anime that are not soft-deleted
# This is the default behavior
/api/anime?filter[trashed]=without
```
Has Filter
```sh
# This filter will return anime that have at least one related resource
/api/anime?filter[has]=resources
```
```sh
# This filter will return anime that have at least 3 related resources
/api/anime?filter[has][3]=resources
```
```sh
# This filter will return anime that have exactly 5 related resources
/api/anime?filter[has][eq][5]=resources
```
```sh
# This filter will return anime that have at least one related resource or related series
/api/anime?filter[has][or]=resources,series
```
```sh
# This filter will return anime that have at least one related resource or one related series
/api/anime?filter[has][or]=resources,series
```
```sh
# This filter will return anime that have at least one related resource of site MyAnimeList and external_id 41457
/api/anime?filter[has]=resources&filter[site]=MyAnimeList&filter[external_id]=41457
```
+1
View File
@@ -50,6 +50,7 @@ GET /api/resource/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -49,6 +49,7 @@ GET /api/series/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -47,6 +47,7 @@ GET /api/song/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -49,6 +49,7 @@ GET /api/studio/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+1
View File
@@ -69,6 +69,7 @@ GET /api/video/
| updated_at | Filter resources on the resource last modified date |
| deleted_at | Filter resources on the resource deletion date |
| trashed | Filter resources on trashed (deleted) status {With, Without, Only} |
| has | Filter resources on relations within allowed include paths |
## Response
+64 -64
View File
@@ -1671,9 +1671,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "16.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz",
"integrity": "sha512-ncRdc45SoYJ2H4eWU9ReDfp3vtFqDYhjOsKlFFUDEn8V1Bgr2RjYal8YT5byfadWIRluhPFU6JiDOl0H6Sl87A==",
"version": "16.7.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.8.tgz",
"integrity": "sha512-8upnoQU0OPzbIkm+ZMM0zCeFCkw2s3mS0IWdx0+AAaWqm4fkBb0UJp8Edl7FVKRamYbpJC/aVsHpKWBIbiC7Zg==",
"dev": true
},
"node_modules/@types/q": {
@@ -3691,9 +3691,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001251",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz",
"integrity": "sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==",
"version": "1.0.30001252",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001252.tgz",
"integrity": "sha512-I56jhWDGMtdILQORdusxBOH+Nl/KgQSdDmpJezYddnAkVOmnoU8zwjTV9xAjMIYxr0iPreEAVylCGcmHCjfaOw==",
"dev": true,
"funding": {
"type": "opencollective",
@@ -4443,9 +4443,9 @@
}
},
"node_modules/core-js": {
"version": "3.16.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.2.tgz",
"integrity": "sha512-P0KPukO6OjMpjBtHSceAZEWlDD1M2Cpzpg6dBbrjFqFhBHe/BwhxaP820xKOjRn/lZRQirrCusIpLS/n2sgXLQ==",
"version": "3.16.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.4.tgz",
"integrity": "sha512-Tq4GVE6XCjE+hcyW6hPy0ofN3hwtLudz5ZRdrlCnsnD/xkm/PWQRudzYHiKgZKUcefV6Q57fhDHjZHJP5dpfSg==",
"dev": true,
"hasInstallScript": true,
"funding": {
@@ -4454,12 +4454,12 @@
}
},
"node_modules/core-js-compat": {
"version": "3.16.2",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.2.tgz",
"integrity": "sha512-4lUshXtBXsdmp8cDWh6KKiHUg40AjiuPD3bOWkNVsr1xkAhpUqCjaZ8lB1bKx9Gb5fXcbRbFJ4f4qpRIRTuJqQ==",
"version": "3.16.4",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.4.tgz",
"integrity": "sha512-IzCSomxRdahCYb6G3HiN6pl3JCiM0NMunRcNa1pIeC7g17Vd6Ue3AT9anQiENPIm/svThUVer1pIbLMDERIsFw==",
"dev": true,
"dependencies": {
"browserslist": "^4.16.7",
"browserslist": "^4.16.8",
"semver": "7.0.0"
},
"funding": {
@@ -5264,9 +5264,9 @@
"dev": true
},
"node_modules/domhandler": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz",
"integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==",
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz",
"integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==",
"dev": true,
"dependencies": {
"domelementtype": "^2.2.0"
@@ -5360,9 +5360,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.3.814",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.814.tgz",
"integrity": "sha512-0mH03cyjh6OzMlmjauGg0TLd87ErIJqWiYxMcOLKf5w6p0YEOl7DJAj7BDlXEFmCguY5CQaKVOiMjAMODO2XDw==",
"version": "1.3.824",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.824.tgz",
"integrity": "sha512-Fk+5aD0HDi9i9ZKt9n2VPOZO1dQy7PV++hz2wJ/KIn+CvVfu4fny39squHtyVDPuHNuoJGAZIbuReEklqYIqfA==",
"dev": true
},
"node_modules/elliptic": {
@@ -6107,9 +6107,9 @@
"dev": true
},
"node_modules/find-cache-dir": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
"integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz",
"integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==",
"dev": true,
"dependencies": {
"commondir": "^1.0.1",
@@ -6880,9 +6880,9 @@
]
},
"node_modules/htmlparser2/node_modules/domutils": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz",
"integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
"integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
"dev": true,
"dependencies": {
"dom-serializer": "^1.0.1",
@@ -10710,9 +10710,9 @@
]
},
"node_modules/renderkid/node_modules/domutils": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz",
"integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
"integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
"dev": true,
"dependencies": {
"dom-serializer": "^1.0.1",
@@ -11467,9 +11467,9 @@
}
},
"node_modules/sockjs-client": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.1.tgz",
"integrity": "sha512-VnVAb663fosipI/m6pqRXakEOw7nvd7TUgdr3PlR/8V2I95QIdwT8L4nMxhyU8SmDBHYXU1TOElaKOmKLfYzeQ==",
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.2.tgz",
"integrity": "sha512-ZzRxPBISQE7RpzlH4tKJMQbHM9pabHluk0WBaxAQ+wm/UieeBVBou0p4wVnSQGN9QmpAZygQ0cDIypWuqOFmFQ==",
"dev": true,
"dependencies": {
"debug": "^3.2.6",
@@ -11477,7 +11477,7 @@
"faye-websocket": "^0.11.3",
"inherits": "^2.0.4",
"json3": "^3.3.3",
"url-parse": "^1.5.1"
"url-parse": "^1.5.3"
}
},
"node_modules/sockjs-client/node_modules/debug": {
@@ -15313,9 +15313,9 @@
"dev": true
},
"@types/node": {
"version": "16.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz",
"integrity": "sha512-ncRdc45SoYJ2H4eWU9ReDfp3vtFqDYhjOsKlFFUDEn8V1Bgr2RjYal8YT5byfadWIRluhPFU6JiDOl0H6Sl87A==",
"version": "16.7.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.8.tgz",
"integrity": "sha512-8upnoQU0OPzbIkm+ZMM0zCeFCkw2s3mS0IWdx0+AAaWqm4fkBb0UJp8Edl7FVKRamYbpJC/aVsHpKWBIbiC7Zg==",
"dev": true
},
"@types/q": {
@@ -17019,9 +17019,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30001251",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz",
"integrity": "sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==",
"version": "1.0.30001252",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001252.tgz",
"integrity": "sha512-I56jhWDGMtdILQORdusxBOH+Nl/KgQSdDmpJezYddnAkVOmnoU8zwjTV9xAjMIYxr0iPreEAVylCGcmHCjfaOw==",
"dev": true
},
"caseless": {
@@ -17641,18 +17641,18 @@
}
},
"core-js": {
"version": "3.16.2",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.2.tgz",
"integrity": "sha512-P0KPukO6OjMpjBtHSceAZEWlDD1M2Cpzpg6dBbrjFqFhBHe/BwhxaP820xKOjRn/lZRQirrCusIpLS/n2sgXLQ==",
"version": "3.16.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.4.tgz",
"integrity": "sha512-Tq4GVE6XCjE+hcyW6hPy0ofN3hwtLudz5ZRdrlCnsnD/xkm/PWQRudzYHiKgZKUcefV6Q57fhDHjZHJP5dpfSg==",
"dev": true
},
"core-js-compat": {
"version": "3.16.2",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.2.tgz",
"integrity": "sha512-4lUshXtBXsdmp8cDWh6KKiHUg40AjiuPD3bOWkNVsr1xkAhpUqCjaZ8lB1bKx9Gb5fXcbRbFJ4f4qpRIRTuJqQ==",
"version": "3.16.4",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.16.4.tgz",
"integrity": "sha512-IzCSomxRdahCYb6G3HiN6pl3JCiM0NMunRcNa1pIeC7g17Vd6Ue3AT9anQiENPIm/svThUVer1pIbLMDERIsFw==",
"dev": true,
"requires": {
"browserslist": "^4.16.7",
"browserslist": "^4.16.8",
"semver": "7.0.0"
},
"dependencies": {
@@ -18322,9 +18322,9 @@
"dev": true
},
"domhandler": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz",
"integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==",
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz",
"integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==",
"dev": true,
"requires": {
"domelementtype": "^2.2.0"
@@ -18402,9 +18402,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.3.814",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.814.tgz",
"integrity": "sha512-0mH03cyjh6OzMlmjauGg0TLd87ErIJqWiYxMcOLKf5w6p0YEOl7DJAj7BDlXEFmCguY5CQaKVOiMjAMODO2XDw==",
"version": "1.3.824",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.824.tgz",
"integrity": "sha512-Fk+5aD0HDi9i9ZKt9n2VPOZO1dQy7PV++hz2wJ/KIn+CvVfu4fny39squHtyVDPuHNuoJGAZIbuReEklqYIqfA==",
"dev": true
},
"elliptic": {
@@ -19021,9 +19021,9 @@
}
},
"find-cache-dir": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
"integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz",
"integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==",
"dev": true,
"requires": {
"commondir": "^1.0.1",
@@ -19609,9 +19609,9 @@
"dev": true
},
"domutils": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz",
"integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
"integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
"dev": true,
"requires": {
"dom-serializer": "^1.0.1",
@@ -22729,9 +22729,9 @@
"dev": true
},
"domutils": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz",
"integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz",
"integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==",
"dev": true,
"requires": {
"dom-serializer": "^1.0.1",
@@ -23374,9 +23374,9 @@
}
},
"sockjs-client": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.1.tgz",
"integrity": "sha512-VnVAb663fosipI/m6pqRXakEOw7nvd7TUgdr3PlR/8V2I95QIdwT8L4nMxhyU8SmDBHYXU1TOElaKOmKLfYzeQ==",
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.5.2.tgz",
"integrity": "sha512-ZzRxPBISQE7RpzlH4tKJMQbHM9pabHluk0WBaxAQ+wm/UieeBVBou0p4wVnSQGN9QmpAZygQ0cDIypWuqOFmFQ==",
"dev": true,
"requires": {
"debug": "^3.2.6",
@@ -23384,7 +23384,7 @@
"faye-websocket": "^0.11.3",
"inherits": "^2.0.4",
"json3": "^3.3.3",
"url-parse": "^1.5.1"
"url-parse": "^1.5.3"
},
"dependencies": {
"debug": {