Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0: Fix types remove most fetchMany #71

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions lib/Api/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Category<T = CategoryDataType[] | CategoryDataType> extends
* console.log(category);
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch multiple categories.
* @since 3.0.0
* @example
* import { Category } from "@quickdevelopment/wp-js";
*
* const categories = new Category();
*
* categories.fetchMany().then((categories) => {
* console.log(categories);
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Comment<T = CommentDataType[] | CommentDataType> extends WP
* console.log(comment);
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch multiple comments.
* @since 3.0.0
* @example
* import { Comment } from "@quickdevelopment/wp-js";
*
* const comments = new Comment();
*
* comments.fetchMany().then((comments) => {
* console.log(comments);
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Media<T = MediaDataType[] | MediaDataType> extends WPJSBase
* console.log(media)
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch multiple media.
* @since 3.0.0
* @example
* import {Media} from "@quickdevelopment/wp-js";
*
* const media = new Media();
*
* media.fetchMany().then((media) => {
* console.log(media)
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Page<T = PageDataType[] | PageDataType> extends WPJSBase<T>
* console.log(page)
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch multiple pages.
* @since 3.0.0
* @example
* import {Page} from "@quickdevelopment/wp-js";
*
* const pages = new Page();
*
* pages.fetchMany().then((pages) => {
* console.log(pages)
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,7 @@ export default class Post<T = PostDataType[] | PostDataType> extends WPJSBase<T>
* console.log(post)
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Get multiple posts.
* @since 3.0.0
* @example
* import {Post} from "@quickdevelopment/wp-js";
*
* const posts = new Post();
*
* posts.fetchMany().then((posts) => {
* console.log(posts)
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
19 changes: 1 addition & 18 deletions lib/Api/Status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,7 @@ export default class Status<T = StatusDataType[] | StatusDataType> extends WPJSB
* console.log(data);
* });
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch many statuses.
*
* @since 3.0.0
* @example
* import { Status } from '@quickdevelopment/wp-js';
*
* const status = new Status();
*
* status.fetchMany().then((data) => {
* console.log(data);
* });
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Tag<T = PostTagDataType[] | PostTagDataType> extends WPJSBa
* console.log(data);
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch many tags.
* @since 3.0.0
* @example
* import { Tag } from '@quickdevelopment/wp-js';
*
* const tag = new Tag();
*
* tag.fetchMany().then((data) => {
* console.log(data);
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
19 changes: 1 addition & 18 deletions lib/Api/Taxonomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,7 @@ export default class Taxonomy<T = TaxonomyDataType[] | TaxonomyDataType> extends
* console.log(data);
* });
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch many taxonomies.
*
* @since 3.0.0
* @example
* import { Taxonomy } from '@quickdevelopment/wp-js';
*
* const taxonomy = new Taxonomy();
*
* taxonomy.fetchMany().then((data) => {
* console.log(data);
* });
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/Type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,7 @@ export default class Type<T = TypeDataType[] | TypeDataType> extends WPJSBase<T>
* console.log(type);
* });
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Fetch multiple types.
* @since 3.0.0
* @example
* import { Type } from "@quickdevelopment/wp-js";
*
* const types = new Type();
*
* types.fetchMany().then((types) => {
* console.log(types);
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
18 changes: 1 addition & 17 deletions lib/Api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,7 @@ export default class User<T = UserDataType[] | UserDataType> extends WPJSBase<T>
* console.log(user);
* })
*/
public async fetch(): Promise<T> {
return this.get();
}

/**
* Get multiple users.
* @since 3.0.5
* @example
* import {User} from "@quickdevelopment/wp-js";
*
* const users = new User();
*
* users.fetchMany().then((users) => {
* console.log(users);
* })
*/
public async fetchMany(): Promise<T[]> {
public async fetch(): Promise<T | T[]> {
return this.get();
}
}
2 changes: 1 addition & 1 deletion lib/Base/WPJSBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class WPJSBase<T> extends WPJSSingleton {
* @protected
* @since 2.0.0
*/
protected fetch(): Promise<T> {
protected fetch(): Promise<T | T[]> {
return Promise.reject(
new Error('fetch() must be implemented.')
)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@quickdevelopment/wp-js",
"private": false,
"version": "3.0.7",
"version": "4.0.0",
"repository": "https://github.com/QuickDevelopment/wp-js",
"author": "QuickDevelopment",
"homepage": "https://github.com/QuickDevelopment/wp-js",
Expand Down