From 1ac65c4a813989c2ca979d9a8025ee6ae95554c4 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 26 Aug 2023 23:02:42 +0900
Subject: [PATCH] Put type param into options in search
---
example/typescript/src/mastodon/cancel.ts | 2 +-
example/typescript/src/misskey/cancel.ts | 2 +-
example/typescript/src/pleroma/cancel.ts | 2 +-
megalodon/src/friendica.ts | 12 ++++++++----
megalodon/src/mastodon.ts | 10 +++++++---
megalodon/src/megalodon.ts | 4 ++--
megalodon/src/misskey.ts | 6 +++---
megalodon/src/pleroma.ts | 12 ++++++++----
8 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/example/typescript/src/mastodon/cancel.ts b/example/typescript/src/mastodon/cancel.ts
index 03c1d9a67..3a882ca2a 100644
--- a/example/typescript/src/mastodon/cancel.ts
+++ b/example/typescript/src/mastodon/cancel.ts
@@ -13,7 +13,7 @@ const access_token: string = process.env.MASTODON_ACCESS_TOKEN
const client = generator('mastodon', BASE_URL, access_token)
client
- .search('whalebird', 'hashtags', { resolve: true })
+ .search('whalebird', { type: 'hashtags', resolve: true })
.then((resp: Response) => {
console.log(resp.data.hashtags)
})
diff --git a/example/typescript/src/misskey/cancel.ts b/example/typescript/src/misskey/cancel.ts
index 06ee17ef9..155bfd112 100644
--- a/example/typescript/src/misskey/cancel.ts
+++ b/example/typescript/src/misskey/cancel.ts
@@ -4,7 +4,7 @@ const access_token: string = process.env.MISSKEY_ACCESS_TOKEN!
const client = generator('misskey', 'https://misskey.io', access_token)
client
- .search('h3poteto', 'accounts')
+ .search('h3poteto', { type: 'accounts' })
.then(res => console.log(res.data))
.catch(err => {
if (isCancel(err)) {
diff --git a/example/typescript/src/pleroma/cancel.ts b/example/typescript/src/pleroma/cancel.ts
index 0234a2d0c..b83470ab6 100644
--- a/example/typescript/src/pleroma/cancel.ts
+++ b/example/typescript/src/pleroma/cancel.ts
@@ -7,7 +7,7 @@ const access_token: string = process.env.PLEROMA_ACCESS_TOKEN!
const client = generator('pleroma', BASE_URL, access_token)
client
- .search('whalebird', 'hashtags', { resolve: true })
+ .search('whalebird', { resolve: true })
.then((resp: Response) => {
console.log(resp.data.hashtags)
})
diff --git a/megalodon/src/friendica.ts b/megalodon/src/friendica.ts
index a3604356d..c5ee9d59c 100644
--- a/megalodon/src/friendica.ts
+++ b/megalodon/src/friendica.ts
@@ -2552,7 +2552,7 @@ export default class Friendica implements MegalodonInterface {
* GET /api/v2/search
*
* @param q The search query.
- * @param type Enum of search target.
+ * @param options.type Enum of search target.
* @param options.limit Maximum number of results to load, per type. Defaults to 20. Max 40.
* @param options.max_id Return results older than this id.
* @param options.min_id Return results immediately newer than this id.
@@ -2564,8 +2564,8 @@ export default class Friendica implements MegalodonInterface {
*/
public async search(
q: string,
- type: 'accounts' | 'hashtags' | 'statuses',
options?: {
+ type?: 'accounts' | 'hashtags' | 'statuses'
limit?: number
max_id?: string
min_id?: string
@@ -2577,10 +2577,14 @@ export default class Friendica implements MegalodonInterface {
}
): Promise> {
let params = {
- q,
- type
+ q
}
if (options) {
+ if (options.type) {
+ params = Object.assign(params, {
+ type: options.type
+ })
+ }
if (options.limit) {
params = Object.assign(params, {
limit: options.limit
diff --git a/megalodon/src/mastodon.ts b/megalodon/src/mastodon.ts
index cb45afb1b..d3e512e9a 100644
--- a/megalodon/src/mastodon.ts
+++ b/megalodon/src/mastodon.ts
@@ -2877,8 +2877,8 @@ export default class Mastodon implements MegalodonInterface {
*/
public async search(
q: string,
- type: 'accounts' | 'hashtags' | 'statuses',
options?: {
+ type?: 'accounts' | 'hashtags' | 'statuses'
limit?: number
max_id?: string
min_id?: string
@@ -2890,10 +2890,14 @@ export default class Mastodon implements MegalodonInterface {
}
): Promise> {
let params = {
- q,
- type
+ q
}
if (options) {
+ if (options.type) {
+ params = Object.assign(params, {
+ type: options.type
+ })
+ }
if (options.limit) {
params = Object.assign(params, {
limit: options.limit
diff --git a/megalodon/src/megalodon.ts b/megalodon/src/megalodon.ts
index 898e7cfb9..b2f62e4ad 100644
--- a/megalodon/src/megalodon.ts
+++ b/megalodon/src/megalodon.ts
@@ -1217,7 +1217,7 @@ export interface MegalodonInterface {
* Perform a search.
*
* @param q The search query.
- * @param type Enum of search target.
+ * @param options.type Enum of search target.
* @param options.limit Maximum number of results to load, per type. Defaults to 20. Max 40.
* @param options.max_id Return results older than this id.
* @param options.min_id Return results immediately newer than this id.
@@ -1229,8 +1229,8 @@ export interface MegalodonInterface {
*/
search(
q: string,
- type: 'accounts' | 'hashtags' | 'statuses',
options?: {
+ type?: 'accounts' | 'hashtags' | 'statuses'
limit?: number
max_id?: string
min_id?: string
diff --git a/megalodon/src/misskey.ts b/megalodon/src/misskey.ts
index 2e17cb84e..521cc041f 100644
--- a/megalodon/src/misskey.ts
+++ b/megalodon/src/misskey.ts
@@ -1951,8 +1951,8 @@ export default class Misskey implements MegalodonInterface {
// ======================================
public async search(
q: string,
- type: 'accounts' | 'hashtags' | 'statuses',
- options?: {
+ options: {
+ type: 'accounts' | 'hashtags' | 'statuses'
limit?: number
max_id?: string
min_id?: string
@@ -1963,7 +1963,7 @@ export default class Misskey implements MegalodonInterface {
exclude_unreviewed?: boolean
}
): Promise> {
- switch (type) {
+ switch (options.type) {
case 'accounts': {
let params = {
query: q
diff --git a/megalodon/src/pleroma.ts b/megalodon/src/pleroma.ts
index e44e677bd..892f21c4f 100644
--- a/megalodon/src/pleroma.ts
+++ b/megalodon/src/pleroma.ts
@@ -2880,7 +2880,7 @@ export default class Pleroma implements MegalodonInterface {
* GET /api/v2/search
*
* @param q The search query.
- * @param type Enum of search target.
+ * @param options.type Enum of search target.
* @param options.limit Maximum number of results to load, per type. Defaults to 20. Max 40.
* @param options.max_id Return results older than this id.
* @param options.min_id Return results immediately newer than this id.
@@ -2892,8 +2892,8 @@ export default class Pleroma implements MegalodonInterface {
*/
public async search(
q: string,
- type: 'accounts' | 'hashtags' | 'statuses',
options?: {
+ type?: 'accounts' | 'hashtags' | 'statuses'
limit?: number
max_id?: string
min_id?: string
@@ -2905,10 +2905,14 @@ export default class Pleroma implements MegalodonInterface {
}
): Promise> {
let params = {
- q,
- type
+ q
}
if (options) {
+ if (options.type) {
+ params = Object.assign(params, {
+ type: options.type
+ })
+ }
if (options.limit) {
params = Object.assign(params, {
limit: options.limit