Comparing version 0.6.1-alpha to 0.7.0-alpha
@@ -78,3 +78,2 @@ export declare enum APIValidationState { | ||
id: string; | ||
email: string; | ||
roles: APIUserRole[]; | ||
@@ -92,2 +91,5 @@ name: string; | ||
export type APIBaseUserData = Omit<APIUserData, "resources" | "resourceLikes" | "userFollows" | "userFollowers">; | ||
export interface APIUserAuthenticatedData extends APIUserData { | ||
email: string; | ||
} | ||
export interface APIValidationStateData { | ||
@@ -94,0 +96,0 @@ id: string; |
@@ -20,3 +20,3 @@ import User from "./User"; | ||
resource: Resource; | ||
constructor(client: Client, resource: Resource, user: User | null, data: APIResourceAttachmentData); | ||
constructor(client: Client, resource: Resource, data: APIResourceAttachmentData); | ||
_patch(data: APIResourceAttachmentData): void; | ||
@@ -23,0 +23,0 @@ /** Return data for api request */ |
@@ -9,3 +9,3 @@ import { __extends } from "tslib"; | ||
__extends(Attachment, _super); | ||
function Attachment(client, resource, user, data) { | ||
function Attachment(client, resource, data) { | ||
var _this = _super.call(this, client, data.id, "/attachments") || this; | ||
@@ -17,4 +17,4 @@ _this.fileUrl = data.fileUrl; | ||
_this.data = data; | ||
_this.user = user; | ||
_this.resource = resource; | ||
_this.user = resource.user; | ||
return _this; | ||
@@ -21,0 +21,0 @@ } |
@@ -9,4 +9,2 @@ import Base from "./Base"; | ||
data: APIUserData; | ||
/** User's email */ | ||
email: string; | ||
/** User's roles */ | ||
@@ -31,3 +29,2 @@ roles: APIUserRole[]; | ||
id: string; | ||
email: string; | ||
name: string; | ||
@@ -34,0 +31,0 @@ firstname: string; |
@@ -10,3 +10,2 @@ import { __extends } from "tslib"; | ||
_this.data = data; | ||
_this.email = data.email; | ||
_this.roles = data.roles; | ||
@@ -22,3 +21,2 @@ _this.name = data.name; | ||
this.data = data; | ||
this.email = data.email; | ||
this.roles = data.roles; | ||
@@ -39,3 +37,2 @@ this.name = data.name; | ||
id: this.id, | ||
email: this.email, | ||
name: this.name, | ||
@@ -42,0 +39,0 @@ firstname: this.firstname, |
@@ -1,2 +0,2 @@ | ||
import User from "../class/User"; | ||
import UserAuthenticated from "../class/UserAuthenticated"; | ||
import Client from "./Client"; | ||
@@ -17,3 +17,3 @@ export interface LoginResponse { | ||
*/ | ||
me: User | null; | ||
me: UserAuthenticated | null; | ||
/** Token of user connected */ | ||
@@ -28,3 +28,3 @@ token: string | null; | ||
/** Fetch current user from API */ | ||
fetchCurrentUser(): Promise<User>; | ||
fetchCurrentUser(): Promise<UserAuthenticated>; | ||
/** Throw error if user is not connected (for protected routes) */ | ||
@@ -31,0 +31,0 @@ checkAuth(): void; |
import { __awaiter, __generator } from "tslib"; | ||
import User from "../class/User"; | ||
import UserAuthenticated from "../class/UserAuthenticated"; | ||
/** | ||
@@ -34,3 +34,3 @@ * Auth client for the lib. | ||
data = _a.sent(); | ||
this.me = new User(this.client, data); | ||
this.me = new UserAuthenticated(this.client, data); | ||
return [2 /*return*/, this.me]; | ||
@@ -37,0 +37,0 @@ } |
@@ -40,6 +40,6 @@ import { __awaiter, __generator } from "tslib"; | ||
_a.sent(); | ||
return [4 /*yield*/, this.resources.fetchAll()]; | ||
return [4 /*yield*/, this.validations.fetchAll()]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, this.validations.fetchAll()]; | ||
return [4 /*yield*/, this.resources.fetchAll()]; | ||
case 4: | ||
@@ -46,0 +46,0 @@ _a.sent(); |
@@ -29,4 +29,5 @@ export { default as Client, ClientConfig } from './client/Client'; | ||
export { default as User } from "./class/User"; | ||
export { default as UserAuthenticated } from "./class/UserAuthenticated"; | ||
export { default as UserLike } from "./class/UserLike"; | ||
export { default as ValidationState } from "./class/ValidationState"; | ||
export * from "./@types"; |
@@ -33,2 +33,3 @@ // Export Clients | ||
export { default as User } from "./class/User"; | ||
export { default as UserAuthenticated } from "./class/UserAuthenticated"; | ||
export { default as UserLike } from "./class/UserLike"; | ||
@@ -35,0 +36,0 @@ export { default as ValidationState } from "./class/ValidationState"; |
@@ -11,4 +11,5 @@ import { Collection } from "@discordjs/collection"; | ||
constructor(category: Category); | ||
getValidateResources(): Collection<string, Resource>; | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
} |
import { __extends } from "tslib"; | ||
import { Collection } from "@discordjs/collection"; | ||
import BaseManager from "./BaseManager"; | ||
import { APIValidationState } from "../@types"; | ||
var CategoryRessourceManager = /** @class */ (function (_super) { | ||
@@ -13,2 +14,12 @@ __extends(CategoryRessourceManager, _super); | ||
} | ||
CategoryRessourceManager.prototype.getValidateResources = function () { | ||
var finalCache = new Collection(); | ||
this.cache.forEach(function (r) { | ||
var last = r.validations.getLastValidationState(); | ||
if (last && last.state === APIValidationState.Validated) { | ||
finalCache.set(r.id, r); | ||
} | ||
}); | ||
return finalCache; | ||
}; | ||
/** Refresh this cache */ | ||
@@ -15,0 +26,0 @@ CategoryRessourceManager.prototype.refresh = function () { |
@@ -17,3 +17,3 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
var a = _a[_i]; | ||
this.cache.set(a.id, new Attachment(this.client, this.resource, this.resource.user, a)); | ||
this.cache.set(a.id, new Attachment(this.client, this.resource, a)); | ||
} | ||
@@ -30,3 +30,3 @@ }; | ||
attachData = _a.sent(); | ||
attachment = new Attachment(this.client, this.resource, this.client.auth.me, attachData); | ||
attachment = new Attachment(this.client, this.resource, attachData); | ||
this.cache.set(attachment.id, attachment); | ||
@@ -33,0 +33,0 @@ return [2 /*return*/, this.resource]; |
{ | ||
"name": "rr-apilib", | ||
"version": "0.6.1-alpha", | ||
"version": "0.7.0-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
192221
109
2786