@book000/pixivts
Version:
pixiv Unofficial API Library for TypeScript
53 lines • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PixivIllustItemCheck = void 0;
const utils_1 = require("../utils");
const checks_1 = require("../checks");
const pixiv_common_1 = require("./pixiv-common");
class PixivIllustItemCheck extends checks_1.BaseSimpleCheck {
checks() {
return {
id: (data) => typeof data.id === 'number',
title: (data) => typeof data.title === 'string',
type: (data) => typeof data.type === 'string' &&
['illust', 'manga', 'ugoira'].includes(data.type),
image_urls: (data) => typeof data.image_urls === 'object' &&
new pixiv_common_1.ImageUrlsCheck().throwIfFailed(data.image_urls),
caption: (data) => typeof data.caption === 'string',
restrict: (data) => typeof data.restrict === 'number',
user: (data) => typeof data.user === 'object' &&
new pixiv_common_1.PixivUserCheck().throwIfFailed(data.user),
tags: (data) => typeof data.tags === 'object' &&
Array.isArray(data.tags) &&
data.tags.every((tag) => new pixiv_common_1.TagCheck().throwIfFailed(tag)),
tools: (data) => typeof data.tools === 'object' &&
Array.isArray(data.tools) &&
data.tools.every((tool) => typeof tool === 'string') &&
data.tools.length <= 3,
create_date: (data) => typeof data.create_date === 'string',
page_count: (data) => typeof data.page_count === 'number',
width: (data) => typeof data.width === 'number',
height: (data) => typeof data.height === 'number',
sanity_level: (data) => typeof data.sanity_level === 'number',
meta_single_page: (data) => typeof data.meta_single_page === 'object' &&
((0, utils_1.isEmptyObject)(data.meta_single_page) ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
data.meta_single_page.original_image_url !== undefined),
meta_pages: (data) => typeof data.meta_pages === 'object' &&
Array.isArray(data.meta_pages) &&
data.meta_pages.every((metaPage) => typeof metaPage.image_urls === 'object' &&
new pixiv_common_1.ImageUrlsCheck().throwIfFailed(metaPage.image_urls)),
total_view: (data) => typeof data.total_view === 'number',
total_bookmarks: (data) => typeof data.total_bookmarks === 'number',
is_bookmarked: (data) => typeof data.is_bookmarked === 'boolean',
visible: (data) => typeof data.visible === 'boolean',
is_muted: (data) => typeof data.is_muted === 'boolean',
total_comments: (data) => data.total_comments === undefined ||
typeof data.total_comments === 'number',
illust_ai_type: (data) => typeof data.illust_ai_type === 'number',
illust_book_style: (data) => typeof data.illust_book_style === 'number',
};
}
}
exports.PixivIllustItemCheck = PixivIllustItemCheck;
//# sourceMappingURL=pixiv-illust.js.map