Comparing version 0.3.1-alpha to 0.3.2-alpha
@@ -26,4 +26,6 @@ export declare enum APIValidationState { | ||
updatedAt: string | null; | ||
resources: APICategoryResource[]; | ||
creator: APIBaseUserData | null; | ||
} | ||
export type APIResourceCategory = Omit<APICategoryData, "resources" | "creator">; | ||
export interface APICommentData { | ||
@@ -46,3 +48,3 @@ id: string; | ||
attachments: APIResourceAttachmentData[]; | ||
categories: Partial<APICategoryData>[]; | ||
categories: APIResourceCategory[]; | ||
comments: APIResourceCommentData[]; | ||
@@ -52,2 +54,4 @@ validationStates: APIResourceValidationStateData[]; | ||
} | ||
export type APICategoryResource = Omit<APIResourceData, "attachments" | "categories" | "comments" | "validationStates" | "userLikes">; | ||
export type APIUserResource = APICategoryResource; | ||
export interface APIUserFollowData { | ||
@@ -84,3 +88,3 @@ id: string; | ||
isBanned: boolean; | ||
resources: Partial<APIResourceData>[]; | ||
resources: APIUserResource[]; | ||
resourceLikes: Partial<APIUserLikeData>[]; | ||
@@ -87,0 +91,0 @@ userFollows: Partial<APIUserFollowData>[]; |
@@ -15,2 +15,3 @@ import User from "./User"; | ||
createdAt: Date; | ||
data: APIResourceAttachmentData; | ||
/** User who have create this attachment */ | ||
@@ -17,0 +18,0 @@ user: User | null; |
@@ -15,2 +15,3 @@ import { __extends } from "tslib"; | ||
_this.createdAt = new Date(data.createdAt); | ||
_this.data = data; | ||
_this.user = user; | ||
@@ -17,0 +18,0 @@ _this.resource = resource; |
@@ -8,2 +8,4 @@ import User from "./User"; | ||
export default class Category extends Base { | ||
/** API data */ | ||
data: APICategoryData; | ||
/** Name of this category */ | ||
@@ -10,0 +12,0 @@ name: string; |
@@ -11,2 +11,3 @@ import { __extends } from "tslib"; | ||
_this = _super.call(this, client, data === null || data === void 0 ? void 0 : data.id, "/categories") || this; | ||
_this.data = data; | ||
_this.name = data.name; | ||
@@ -13,0 +14,0 @@ _this.isVisible = data.isVisible; |
@@ -8,2 +8,4 @@ import Base from "./Base"; | ||
export default class Comment extends Base { | ||
/** API data */ | ||
data: APIResourceCommentData; | ||
/** Message of the user */ | ||
@@ -10,0 +12,0 @@ comment: string; |
@@ -10,2 +10,3 @@ import { __extends } from "tslib"; | ||
_this = _super.call(this, client, data.id, "/comments") || this; | ||
_this.data = data; | ||
_this.resource = resource; | ||
@@ -12,0 +13,0 @@ _this.user = data.user ? (_b = _this.client.users.cache.get((_a = data.user) === null || _a === void 0 ? void 0 : _a.id)) !== null && _b !== void 0 ? _b : null : null; |
@@ -12,2 +12,4 @@ import { APIResourceData } from "../@types"; | ||
export default class Resource extends Base { | ||
/** API data */ | ||
data: APIResourceData; | ||
/** The resource's title */ | ||
@@ -14,0 +16,0 @@ title: string; |
@@ -16,2 +16,3 @@ import { __extends } from "tslib"; | ||
_this = _super.call(this, client, data.id, "/resources") || this; | ||
_this.data = data; | ||
_this.title = data.title; | ||
@@ -18,0 +19,0 @@ _this.description = data.description; |
@@ -7,2 +7,4 @@ import Base from "./Base"; | ||
export default class User extends Base { | ||
/** API data */ | ||
data: APIUserData; | ||
/** User's email */ | ||
@@ -9,0 +11,0 @@ email: string; |
@@ -9,2 +9,3 @@ import { __extends } from "tslib"; | ||
var _this = _super.call(this, client, data.id, "/users") || this; | ||
_this.data = data; | ||
_this.email = data.email; | ||
@@ -11,0 +12,0 @@ _this.roles = data.roles; |
@@ -8,2 +8,4 @@ import Base from "./Base"; | ||
export default class UserLike extends Base { | ||
/** API data */ | ||
data: APIResourceUserLikeData; | ||
/** User who has like */ | ||
@@ -10,0 +12,0 @@ user: User | null; |
@@ -10,2 +10,3 @@ import { __extends } from "tslib"; | ||
_this = _super.call(this, client, data.id, "/user_likes") || this; | ||
_this.data = data; | ||
_this.resource = resource; | ||
@@ -12,0 +13,0 @@ _this.user = (_a = _this.client.users.cache.get(data.user.id)) !== null && _a !== void 0 ? _a : null; |
@@ -8,2 +8,4 @@ import User from "./User"; | ||
export default class ValidationState extends Base { | ||
/** API data */ | ||
data: APIValidationStateData; | ||
/** Value of the state */ | ||
@@ -10,0 +12,0 @@ state: APIValidationState; |
@@ -10,2 +10,3 @@ import { __extends } from "tslib"; | ||
_this = _super.call(this, client, data.id, "/validation_states") || this; | ||
_this.data = data; | ||
_this.state = data.state; | ||
@@ -12,0 +13,0 @@ _this.updatedAt = data.updatedAt ? new Date(data.updatedAt) : null; |
@@ -11,2 +11,4 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(category: Category); | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
} |
import { __extends } from "tslib"; | ||
import { Collection } from "@discordjs/collection"; | ||
import BaseManager from "./BaseManager"; | ||
@@ -8,5 +9,16 @@ var CategoryRessourceManager = /** @class */ (function (_super) { | ||
_this.category = category; | ||
_this.cache = _this.client.resources.cache.filter(function (r) { return r.categories.cache.has(category.id); }); | ||
_this.cache = new Collection(); | ||
_this.refresh(); | ||
return _this; | ||
} | ||
/** Refresh this cache */ | ||
CategoryRessourceManager.prototype.refresh = function () { | ||
for (var _i = 0, _a = this.category.data.resources; _i < _a.length; _i++) { | ||
var r = _a[_i]; | ||
var resource = this.client.resources.cache.get(r.id); | ||
if (resource) { | ||
this.cache.set(resource.id, resource); | ||
} | ||
} | ||
}; | ||
return CategoryRessourceManager; | ||
@@ -13,0 +25,0 @@ }(BaseManager)); |
@@ -11,2 +11,4 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(resource: Resource); | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
/** Add a new category for this resource */ | ||
@@ -13,0 +15,0 @@ add(category: Category): Promise<Resource>; |
import { __awaiter, __extends, __generator } from "tslib"; | ||
import { Collection } from "@discordjs/collection"; | ||
import BaseManager from "./BaseManager"; | ||
@@ -8,5 +9,16 @@ var ResourceCategoryManager = /** @class */ (function (_super) { | ||
_this.resource = resource; | ||
_this.cache = _this.client.categories.cache.filter(function (c) { return c.resources.cache.has(resource.id); }); | ||
_this.cache = new Collection(); | ||
_this.refresh(); | ||
return _this; | ||
} | ||
/** Refresh this cache */ | ||
ResourceCategoryManager.prototype.refresh = function () { | ||
for (var _i = 0, _a = this.resource.data.categories; _i < _a.length; _i++) { | ||
var c = _a[_i]; | ||
var category = this.client.categories.cache.get(c.id); | ||
if (category) { | ||
this.cache.set(category.id, category); | ||
} | ||
} | ||
}; | ||
/** Add a new category for this resource */ | ||
@@ -13,0 +25,0 @@ ResourceCategoryManager.prototype.add = function (category) { |
@@ -11,2 +11,4 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(user: User); | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
} |
@@ -11,2 +11,12 @@ import { __extends } from "tslib"; | ||
} | ||
/** Refresh this cache */ | ||
UserResourceManager.prototype.refresh = function () { | ||
for (var _i = 0, _a = this.user.data.resources; _i < _a.length; _i++) { | ||
var r = _a[_i]; | ||
var resource = this.client.resources.cache.get(r.id); | ||
if (resource) { | ||
this.cache.set(resource.id, resource); | ||
} | ||
} | ||
}; | ||
return UserResourceManager; | ||
@@ -13,0 +23,0 @@ }(BaseManager)); |
{ | ||
"name": "rr-apilib", | ||
"version": "0.3.1-alpha", | ||
"version": "0.3.2-alpha", | ||
"description": "Library for interact with RR-API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162150
2313