BREAKING CHANGE(classes.ghost): Remove Settings and Webhooks browse/read APIs, remove noisy console.error logs, and update tests/docs
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiclient.xyz/ghost',
|
||||
version: '1.4.1',
|
||||
version: '2.0.0',
|
||||
description: 'An unofficial Ghost CMS API package enabling content and admin functionality for managing posts.'
|
||||
}
|
||||
|
@@ -43,7 +43,6 @@ export class Author {
|
||||
this.authorData = updatedAuthorData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating author:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -65,7 +65,6 @@ export class Ghost {
|
||||
});
|
||||
return postsData.map((postData: IPost) => new Post(this, postData));
|
||||
} catch (error) {
|
||||
console.error('Error fetching posts:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +74,6 @@ export class Ghost {
|
||||
const postData = await this.contentApi.posts.read({ id });
|
||||
return new Post(this, postData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching post with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +83,6 @@ export class Ghost {
|
||||
const createdPostData = await this.adminApi.posts.add(postData);
|
||||
return new Post(this, createdPostData);
|
||||
} catch (error) {
|
||||
console.error('Error creating post:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +107,6 @@ export class Ghost {
|
||||
|
||||
return tagsData;
|
||||
} catch (error) {
|
||||
console.error('Error fetching tags:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +116,6 @@ export class Ghost {
|
||||
const tagData = await this.contentApi.tags.read({ id });
|
||||
return new Tag(this, tagData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching tag with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +125,6 @@ export class Ghost {
|
||||
const tagData = await this.contentApi.tags.read({ slug });
|
||||
return new Tag(this, tagData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching tag with slug ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +134,6 @@ export class Ghost {
|
||||
const createdTagData = await this.adminApi.tags.add(tagData);
|
||||
return new Tag(this, createdTagData);
|
||||
} catch (error) {
|
||||
console.error('Error creating tag:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -159,7 +152,6 @@ export class Ghost {
|
||||
|
||||
return authorsData.map((author: IAuthor) => new Author(this, author));
|
||||
} catch (error) {
|
||||
console.error('Error fetching authors:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +161,6 @@ export class Ghost {
|
||||
const authorData = await this.contentApi.authors.read({ id });
|
||||
return new Author(this, authorData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching author with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -179,7 +170,6 @@ export class Ghost {
|
||||
const authorData = await this.contentApi.authors.read({ slug });
|
||||
return new Author(this, authorData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching author with slug ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -198,7 +188,6 @@ export class Ghost {
|
||||
|
||||
return pagesData.map((pageData: IPage) => new Page(this, pageData));
|
||||
} catch (error) {
|
||||
console.error('Error fetching pages:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +197,6 @@ export class Ghost {
|
||||
const pageData = await this.contentApi.pages.read({ id });
|
||||
return new Page(this, pageData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching page with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +206,6 @@ export class Ghost {
|
||||
const pageData = await this.contentApi.pages.read({ slug });
|
||||
return new Page(this, pageData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching page with slug ${slug}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -228,7 +215,6 @@ export class Ghost {
|
||||
const createdPageData = await this.adminApi.pages.add(pageData);
|
||||
return new Page(this, createdPageData);
|
||||
} catch (error) {
|
||||
console.error('Error creating page:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +229,6 @@ export class Ghost {
|
||||
});
|
||||
return postsData.map((postData: IPost) => new Post(this, postData));
|
||||
} catch (error) {
|
||||
console.error('Error searching posts:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +238,6 @@ export class Ghost {
|
||||
const result = await this.adminApi.images.upload({ file: filePath });
|
||||
return result.url;
|
||||
} catch (error) {
|
||||
console.error('Error uploading image:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +250,6 @@ export class Ghost {
|
||||
});
|
||||
return await Promise.all(updatePromises);
|
||||
} catch (error) {
|
||||
console.error('Error bulk updating posts:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -279,7 +262,6 @@ export class Ghost {
|
||||
});
|
||||
await Promise.all(deletePromises);
|
||||
} catch (error) {
|
||||
console.error('Error bulk deleting posts:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +284,6 @@ export class Ghost {
|
||||
|
||||
return postsData.map((postData: IPost) => new Post(this, postData));
|
||||
} catch (error) {
|
||||
console.error('Error fetching related posts:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +302,6 @@ export class Ghost {
|
||||
|
||||
return membersData.map((member: IMember) => new Member(this, member));
|
||||
} catch (error) {
|
||||
console.error('Error fetching members:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -331,7 +311,6 @@ export class Ghost {
|
||||
const memberData = await this.adminApi.members.read({ id });
|
||||
return new Member(this, memberData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching member with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -341,7 +320,6 @@ export class Ghost {
|
||||
const memberData = await this.adminApi.members.read({ email });
|
||||
return new Member(this, memberData);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching member with email ${email}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -351,43 +329,6 @@ export class Ghost {
|
||||
const createdMemberData = await this.adminApi.members.add(memberData);
|
||||
return new Member(this, createdMemberData);
|
||||
} catch (error) {
|
||||
console.error('Error creating member:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getSettings(): Promise<any> {
|
||||
try {
|
||||
return await this.adminApi.settings.browse();
|
||||
} catch (error) {
|
||||
console.error('Error fetching settings:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async updateSettings(settings: any[]): Promise<any> {
|
||||
try {
|
||||
return await this.adminApi.settings.edit(settings);
|
||||
} catch (error) {
|
||||
console.error('Error updating settings:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getWebhooks(): Promise<any[]> {
|
||||
try {
|
||||
return await this.adminApi.webhooks.browse();
|
||||
} catch (error) {
|
||||
console.error('Error fetching webhooks:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getWebhookById(id: string): Promise<any> {
|
||||
try {
|
||||
return await this.adminApi.webhooks.read({ id });
|
||||
} catch (error) {
|
||||
console.error(`Error fetching webhook with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -403,7 +344,6 @@ export class Ghost {
|
||||
try {
|
||||
return await this.adminApi.webhooks.add(webhookData);
|
||||
} catch (error) {
|
||||
console.error('Error creating webhook:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -412,7 +352,6 @@ export class Ghost {
|
||||
try {
|
||||
return await this.adminApi.webhooks.edit({ ...webhookData, id });
|
||||
} catch (error) {
|
||||
console.error('Error updating webhook:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -421,7 +360,6 @@ export class Ghost {
|
||||
try {
|
||||
await this.adminApi.webhooks.delete({ id });
|
||||
} catch (error) {
|
||||
console.error(`Error deleting webhook with id ${id}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -71,7 +71,6 @@ export class Member {
|
||||
this.memberData = updatedMemberData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating member:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +79,6 @@ export class Member {
|
||||
try {
|
||||
await this.ghostInstanceRef.adminApi.members.delete({ id: this.getId() });
|
||||
} catch (error) {
|
||||
console.error(`Error deleting member with id ${this.getId()}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,6 @@ export class Page {
|
||||
this.pageData = updatedPageData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating page:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +57,6 @@ export class Page {
|
||||
try {
|
||||
await this.ghostInstanceRef.adminApi.pages.delete({ id: this.getId() });
|
||||
} catch (error) {
|
||||
console.error(`Error deleting page with id ${this.getId()}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -124,7 +124,6 @@ export class Post {
|
||||
this.postData = updatedPostData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating post:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +132,6 @@ export class Post {
|
||||
try {
|
||||
await this.ghostInstanceRef.adminApi.posts.delete({ id: this.getId() });
|
||||
} catch (error) {
|
||||
console.error(`Error deleting post with id ${this.getId()}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@@ -39,7 +39,6 @@ export class Tag {
|
||||
this.tagData = updatedTagData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating tag:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +47,6 @@ export class Tag {
|
||||
try {
|
||||
await this.ghostInstanceRef.adminApi.tags.delete({ id: this.getId() });
|
||||
} catch (error) {
|
||||
console.error(`Error deleting tag with id ${this.getId()}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user