Comparing version 0.7.0-alpha to 0.8.0-alpha
@@ -1,2 +0,1 @@ | ||
import User from "./User"; | ||
import Base from "./Base"; | ||
@@ -16,7 +15,7 @@ import Resource from "./Resource"; | ||
data: APIResourceAttachmentData; | ||
/** User who have create this attachment */ | ||
user: User | null; | ||
/** Resource of this attachment */ | ||
resource: Resource; | ||
constructor(client: Client, resource: Resource, data: APIResourceAttachmentData); | ||
/** User who have create this attachment */ | ||
get creator(): import("./User").default | null; | ||
_patch(data: APIResourceAttachmentData): void; | ||
@@ -23,0 +22,0 @@ /** Return data for api request */ |
@@ -17,5 +17,12 @@ import { __extends } from "tslib"; | ||
_this.resource = resource; | ||
_this.user = resource.user; | ||
return _this; | ||
} | ||
Object.defineProperty(Attachment.prototype, "creator", { | ||
/** User who have create this attachment */ | ||
get: function () { | ||
return this.resource.creator; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Attachment.prototype._patch = function (data) { | ||
@@ -22,0 +29,0 @@ this.data = data; |
@@ -1,2 +0,1 @@ | ||
import User from "./User"; | ||
import Base from "./Base"; | ||
@@ -18,11 +17,9 @@ import Client from "../client/Client"; | ||
updatedAt: Date | null; | ||
/** User have created this category */ | ||
creator: User | null; | ||
/** Linked resource */ | ||
resources: CategoryResourceManager; | ||
constructor(client: Client, data: APICategoryData); | ||
/** User have created this category */ | ||
get creator(): import("./User").default | null; | ||
private getCreator; | ||
_patch(data: APICategoryData): void; | ||
/** Refresh all category managers */ | ||
refresh(): void; | ||
/** Return data for api request */ | ||
@@ -29,0 +26,0 @@ toJSON(): { |
@@ -8,5 +8,3 @@ import { __extends } from "tslib"; | ||
function Category(client, data) { | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, client, data.id, "/categories") || this; | ||
var _this = _super.call(this, client, data.id, "/categories") || this; | ||
_this.data = data; | ||
@@ -17,6 +15,13 @@ _this.name = data.name; | ||
_this.updatedAt = data.updatedAt ? new Date(data.updatedAt) : null; | ||
_this.creator = _this.getCreator((_a = _this.data.creator) === null || _a === void 0 ? void 0 : _a.id); | ||
_this.resources = new CategoryResourceManager(_this); | ||
return _this; | ||
} | ||
Object.defineProperty(Category.prototype, "creator", { | ||
/** User have created this category */ | ||
get: function () { | ||
return this.getCreator(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Category.prototype.getCreator = function (id) { | ||
@@ -27,3 +32,2 @@ var _a; | ||
Category.prototype._patch = function (data) { | ||
var _a; | ||
this.data = data; | ||
@@ -34,11 +38,4 @@ this.name = data.name; | ||
this.updatedAt = data.updatedAt ? new Date(data.updatedAt) : null; | ||
this.creator = this.getCreator((_a = this.data.creator) === null || _a === void 0 ? void 0 : _a.id); | ||
this.resources = new CategoryResourceManager(this); | ||
}; | ||
/** Refresh all category managers */ | ||
Category.prototype.refresh = function () { | ||
var _a; | ||
this.resources.refresh(); | ||
this.creator = this.getCreator((_a = this.data.creator) === null || _a === void 0 ? void 0 : _a.id); | ||
}; | ||
/** Return data for api request */ | ||
@@ -45,0 +42,0 @@ Category.prototype.toJSON = function () { |
import Base from "./Base"; | ||
import User from "./User"; | ||
import Resource from "./Resource"; | ||
@@ -16,5 +15,5 @@ import Client from "../client/Client"; | ||
resource: Resource; | ||
constructor(client: Client, resource: Resource, data: APIResourceCommentData); | ||
/** Creator of this comment */ | ||
user: User | null; | ||
constructor(client: Client, resource: Resource, data: APIResourceCommentData); | ||
get user(): import("./User").default | null; | ||
_patch(data: APIResourceCommentData): void; | ||
@@ -21,0 +20,0 @@ /** Return data for api request */ |
@@ -7,8 +7,5 @@ import { __extends } from "tslib"; | ||
function Comment(client, resource, data) { | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, client, data.id, "/comments") || this; | ||
var _this = _super.call(this, client, data.id, "/comments") || this; | ||
_this.data = data; | ||
_this.resource = resource; | ||
_this.user = data.user ? (_a = _this.client.users.cache.get(data.user.id)) !== null && _a !== void 0 ? _a : null : null; | ||
_this.comment = data.comment; | ||
@@ -18,8 +15,16 @@ _this.createdAt = new Date(data.createdAt); | ||
} | ||
Object.defineProperty(Comment.prototype, "user", { | ||
/** Creator of this comment */ | ||
get: function () { | ||
var _a, _b; | ||
var id = (_a = this.data.user) === null || _a === void 0 ? void 0 : _a.id; | ||
return id ? (_b = this.client.users.cache.get(id)) !== null && _b !== void 0 ? _b : null : null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Comment.prototype._patch = function (data) { | ||
var _a; | ||
this.data = data; | ||
this.comment = data.comment; | ||
this.createdAt = new Date(data.createdAt); | ||
this.user = data.user ? (_a = this.client.users.cache.get(data.user.id)) !== null && _a !== void 0 ? _a : null : null; | ||
}; | ||
@@ -26,0 +31,0 @@ /** Return data for api request */ |
import { APIResourceData } from "../@types"; | ||
import Base from "./Base"; | ||
import User from "./User"; | ||
import Client from "../client/Client"; | ||
@@ -24,4 +23,2 @@ import ResourceAttachmentManager from "../managers/ResourceAttachmentManager"; | ||
isPublic: boolean; | ||
/**Resource's creator */ | ||
user: User | null; | ||
/** Resource's attachments manager */ | ||
@@ -38,6 +35,9 @@ attachments: ResourceAttachmentManager; | ||
constructor(client: Client, data: APIResourceData); | ||
/** @deprecated */ | ||
get user(): import("./User").default | null; | ||
get creator(): import("./User").default | null; | ||
private getCreator; | ||
get isLiked(): boolean; | ||
/** Refresh all resource managers */ | ||
refresh(): void; | ||
isLiked(): boolean; | ||
like(): Promise<Resource> | undefined; | ||
@@ -44,0 +44,0 @@ unlike(): Promise<Resource> | undefined; |
@@ -13,5 +13,3 @@ import { __extends } from "tslib"; | ||
function Resource(client, data) { | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, client, data.id, "/resources") || this; | ||
var _this = _super.call(this, client, data.id, "/resources") || this; | ||
_this.data = data; | ||
@@ -23,3 +21,2 @@ _this.title = data.title; | ||
_this.isPublic = data.isPublic; | ||
_this.user = _this.getCreator((_a = data.user) === null || _a === void 0 ? void 0 : _a.id); | ||
_this.attachments = new ResourceAttachmentManager(_this); | ||
@@ -32,2 +29,17 @@ _this.categories = new ResourceCategoryManager(_this); | ||
} | ||
Object.defineProperty(Resource.prototype, "user", { | ||
/** @deprecated */ | ||
get: function () { | ||
return this.getCreator(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Resource.prototype, "creator", { | ||
get: function () { | ||
return this.getCreator(); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Resource.prototype.getCreator = function (id) { | ||
@@ -37,12 +49,14 @@ var _a; | ||
}; | ||
Object.defineProperty(Resource.prototype, "isLiked", { | ||
/* Check if the current user like this resource */ | ||
get: function () { | ||
return this.likes.getMeLike() ? true : false; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** Refresh all resource managers */ | ||
Resource.prototype.refresh = function () { | ||
var _a; | ||
this.categories.refresh(); | ||
this.user = this.getCreator((_a = this.data.user) === null || _a === void 0 ? void 0 : _a.id); | ||
}; | ||
/* Check if the current user like this resource */ | ||
Resource.prototype.isLiked = function () { | ||
return this.likes.getMeLike() ? true : false; | ||
}; | ||
/* Current user like this resource */ | ||
@@ -63,3 +77,2 @@ Resource.prototype.like = function () { | ||
Resource.prototype._patch = function (data) { | ||
var _a; | ||
this.data = data; | ||
@@ -71,3 +84,2 @@ this.title = data.title; | ||
this.isPublic = data.isPublic; | ||
this.user = this.getCreator((_a = data.user) === null || _a === void 0 ? void 0 : _a.id); | ||
this.attachments = new ResourceAttachmentManager(this); | ||
@@ -74,0 +86,0 @@ this.categories = new ResourceCategoryManager(this); |
@@ -23,4 +23,2 @@ import Base from "./Base"; | ||
_patch(data: APIUserData): void; | ||
/** Refresh all user managers */ | ||
refresh(): void; | ||
/** Return data for api request */ | ||
@@ -27,0 +25,0 @@ toJSON(): { |
@@ -27,6 +27,2 @@ import { __extends } from "tslib"; | ||
}; | ||
/** Refresh all user managers */ | ||
User.prototype.refresh = function () { | ||
this.resources.refresh(); | ||
}; | ||
/** Return data for api request */ | ||
@@ -33,0 +29,0 @@ User.prototype.toJSON = function () { |
import Base from "./Base"; | ||
import User from "./User"; | ||
import Resource from "./Resource"; | ||
@@ -12,10 +11,8 @@ import Client from "../client/Client"; | ||
userId: string; | ||
/** User who has liked */ | ||
user: User | null; | ||
/** Resource who has liked */ | ||
resource: Resource; | ||
constructor(client: Client, resource: Resource, data: APIResourceUserLikeData); | ||
/** User who has liked */ | ||
get user(): import("./User").default | null; | ||
_patch(data: APIResourceUserLikeData): void; | ||
/** Refresh all resource managers */ | ||
refresh(): void; | ||
/** Return data for api request */ | ||
@@ -22,0 +19,0 @@ toJSON(): { |
@@ -7,22 +7,21 @@ import { __extends } from "tslib"; | ||
function UserLike(client, resource, data) { | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, client, data.id, "/user_likes") || this; | ||
var _this = _super.call(this, client, data.id, "/user_likes") || this; | ||
_this.data = data; | ||
_this.resource = resource; | ||
_this.userId = _this.data.user.id; | ||
_this.user = (_a = _this.client.users.cache.get(_this.userId)) !== null && _a !== void 0 ? _a : null; | ||
return _this; | ||
} | ||
Object.defineProperty(UserLike.prototype, "user", { | ||
/** User who has liked */ | ||
get: function () { | ||
var _a; | ||
return (_a = this.client.users.cache.get(this.userId)) !== null && _a !== void 0 ? _a : null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
UserLike.prototype._patch = function (data) { | ||
var _a; | ||
this.data = data; | ||
this.userId = this.data.user.id; | ||
this.user = (_a = this.client.users.cache.get(this.userId)) !== null && _a !== void 0 ? _a : null; | ||
}; | ||
/** Refresh all resource managers */ | ||
UserLike.prototype.refresh = function () { | ||
var _a; | ||
this.user = (_a = this.client.users.cache.get(this.userId)) !== null && _a !== void 0 ? _a : null; | ||
}; | ||
/** Return data for api request */ | ||
@@ -29,0 +28,0 @@ UserLike.prototype.toJSON = function () { |
@@ -14,10 +14,9 @@ import User from "./User"; | ||
updatedAt: Date; | ||
constructor(client: Client, data: APIValidationStateData); | ||
/** User who intervened */ | ||
moderator: User | null; | ||
get moderator(): User | null; | ||
private getModerator; | ||
/** The linked resource */ | ||
resource: Resource | null; | ||
constructor(client: Client, data: APIValidationStateData); | ||
private getModerator; | ||
get resource(): Resource | null; | ||
_patch(data: APIValidationStateData): void; | ||
refresh(): void; | ||
/** Return data for api request */ | ||
@@ -24,0 +23,0 @@ toJSON(): { |
@@ -7,12 +7,17 @@ import { __extends } from "tslib"; | ||
function ValidationState(client, data) { | ||
var _this = this; | ||
var _a, _b, _c; | ||
_this = _super.call(this, client, data.id, "/validation_states") || this; | ||
var _this = _super.call(this, client, data.id, "/validation_states") || this; | ||
_this.data = data; | ||
_this.state = data.state.label; | ||
_this.updatedAt = new Date(data.updatedAt); | ||
_this.moderator = _this.getModerator((_a = data.moderator) === null || _a === void 0 ? void 0 : _a.id); | ||
_this.resource = ((_b = data.resource) === null || _b === void 0 ? void 0 : _b.id) ? (_c = _this.client.resources.cache.get(data.resource.id)) !== null && _c !== void 0 ? _c : null : null; | ||
return _this; | ||
} | ||
Object.defineProperty(ValidationState.prototype, "moderator", { | ||
/** User who intervened */ | ||
get: function () { | ||
var _a; | ||
return this.getModerator((_a = this.data.moderator) === null || _a === void 0 ? void 0 : _a.id); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
ValidationState.prototype.getModerator = function (id) { | ||
@@ -22,15 +27,17 @@ var _a; | ||
}; | ||
Object.defineProperty(ValidationState.prototype, "resource", { | ||
/** The linked resource */ | ||
get: function () { | ||
var _a, _b; | ||
var id = (_a = this.data.resource) === null || _a === void 0 ? void 0 : _a.id; | ||
return id ? (_b = this.client.resources.cache.get(id)) !== null && _b !== void 0 ? _b : null : null; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
ValidationState.prototype._patch = function (data) { | ||
var _a, _b, _c; | ||
this.data = data; | ||
this.state = data.state.label; | ||
this.updatedAt = new Date(data.updatedAt); | ||
this.moderator = this.getModerator((_a = data.moderator) === null || _a === void 0 ? void 0 : _a.id); | ||
this.resource = ((_b = data.resource) === null || _b === void 0 ? void 0 : _b.id) ? (_c = this.client.resources.cache.get(data.resource.id)) !== null && _c !== void 0 ? _c : null : null; | ||
}; | ||
ValidationState.prototype.refresh = function () { | ||
var _a, _b, _c; | ||
this.moderator = this.getModerator((_a = this.data.moderator) === null || _a === void 0 ? void 0 : _a.id); | ||
this.resource = ((_b = this.data.resource) === null || _b === void 0 ? void 0 : _b.id) ? (_c = this.client.resources.cache.get(this.data.resource.id)) !== null && _c !== void 0 ? _c : null : null; | ||
}; | ||
/** Return data for api request */ | ||
@@ -37,0 +44,0 @@ ValidationState.prototype.toJSON = function () { |
@@ -55,6 +55,3 @@ import { __awaiter, __generator } from "tslib"; | ||
Client.prototype.refresh = function () { | ||
this.users.cache.each(function (u) { return u.refresh(); }); | ||
this.categories.cache.each(function (c) { return c.refresh(); }); | ||
this.resources.cache.each(function (r) { return r.refresh(); }); | ||
this.validations.cache.each(function (v) { return v.refresh(); }); | ||
}; | ||
@@ -61,0 +58,0 @@ return Client; |
@@ -8,8 +8,6 @@ import { Collection } from "@discordjs/collection"; | ||
category: Category; | ||
constructor(category: Category); | ||
/** Resources cache from the category */ | ||
cache: Collection<string, Resource>; | ||
constructor(category: Category); | ||
get cache(): Collection<string, Resource>; | ||
getValidateResources(): Collection<string, Resource>; | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
} |
@@ -10,6 +10,15 @@ import { __extends } from "tslib"; | ||
_this.category = category; | ||
_this.cache = new Collection(); | ||
_this.refresh(); | ||
return _this; | ||
} | ||
Object.defineProperty(CategoryRessourceManager.prototype, "cache", { | ||
/** Resources cache from the category */ | ||
get: function () { | ||
var _this = this; | ||
return this.client.resources.cache.filter(function (r) { | ||
return r.categories.cache.has(_this.category.id); | ||
}); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
CategoryRessourceManager.prototype.getValidateResources = function () { | ||
@@ -25,12 +34,2 @@ var finalCache = new Collection(); | ||
}; | ||
/** 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; | ||
@@ -37,0 +36,0 @@ }(BaseManager)); |
@@ -18,13 +18,3 @@ import { __awaiter, __extends, __generator } from "tslib"; | ||
if (existing) { | ||
var oldCategories = existing.categories.cache; | ||
existing._patch(data); | ||
var newCategories = existing.categories.cache; | ||
// Remove resource from old categories | ||
oldCategories.difference(newCategories).forEach(function (c) { | ||
c.resources.cache.delete(existing.id); | ||
}); | ||
// add resource to new categories | ||
newCategories.difference(oldCategories).forEach(function (c) { | ||
c.resources.cache.set(existing.id, existing); | ||
}); | ||
return existing; | ||
@@ -31,0 +21,0 @@ } |
@@ -9,13 +9,11 @@ import Resource from "../class/Resource"; | ||
resource: Resource; | ||
constructor(resource: Resource); | ||
/** Validation state cache for this resource */ | ||
cache: Collection<string, ValidationState>; | ||
constructor(resource: Resource); | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
get cache(): Collection<string, ValidationState>; | ||
/** Get last validation state */ | ||
getLastValidationState(): ValidationState | null; | ||
/** Create a new validation state for this resource */ | ||
create(validation: ValidationStateBuilder): Promise<Resource>; | ||
create(validation: ValidationStateBuilder): Promise<ValidationState>; | ||
/** Delete an existing validation state for this resource */ | ||
update(validation: ValidationState): Promise<Resource>; | ||
update(validation: ValidationState): Promise<ValidationState>; | ||
} |
@@ -1,4 +0,3 @@ | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import { __extends } from "tslib"; | ||
import BaseManager from "./BaseManager"; | ||
import { Collection } from "@discordjs/collection"; | ||
var ResourceValidationStateManager = /** @class */ (function (_super) { | ||
@@ -9,16 +8,13 @@ __extends(ResourceValidationStateManager, _super); | ||
_this.resource = resource; | ||
_this.cache = new Collection(); | ||
_this.refresh(); | ||
return _this; | ||
} | ||
/** Refresh this cache */ | ||
ResourceValidationStateManager.prototype.refresh = function () { | ||
for (var _i = 0, _a = this.resource.data.validationStates; _i < _a.length; _i++) { | ||
var c = _a[_i]; | ||
var validationState = this.client.validations.cache.get(c.id); | ||
if (validationState) { | ||
this.cache.set(validationState.id, validationState); | ||
} | ||
} | ||
}; | ||
Object.defineProperty(ResourceValidationStateManager.prototype, "cache", { | ||
/** Validation state cache for this resource */ | ||
get: function () { | ||
var _this = this; | ||
return this.client.validations.cache.filter(function (v) { var _a; return ((_a = v.resource) === null || _a === void 0 ? void 0 : _a.id) === _this.resource.id; }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** Get last validation state */ | ||
@@ -37,29 +33,7 @@ ResourceValidationStateManager.prototype.getLastValidationState = function () { | ||
ResourceValidationStateManager.prototype.create = function (validation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.validations.create(validation.setResource(this.resource))]; | ||
case 1: | ||
data = _a.sent(); | ||
this.cache.set(data.id, data); | ||
return [2 /*return*/, this.resource]; | ||
} | ||
}); | ||
}); | ||
return this.client.validations.create(validation.setResource(this.resource)); | ||
}; | ||
/** Delete an existing validation state for this resource */ | ||
ResourceValidationStateManager.prototype.update = function (validation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.validations.update(validation)]; | ||
case 1: | ||
data = _a.sent(); | ||
this.cache.set(data.id, data); | ||
return [2 /*return*/, this.resource]; | ||
} | ||
}); | ||
}); | ||
return this.client.validations.update(validation); | ||
}; | ||
@@ -66,0 +40,0 @@ return ResourceValidationStateManager; |
@@ -9,5 +9,5 @@ import { Collection } from "@discordjs/collection"; | ||
user: User; | ||
constructor(user: User); | ||
/** Resources cache for this user */ | ||
cache: Collection<string, Resource>; | ||
constructor(user: User); | ||
get cache(): Collection<string, Resource>; | ||
/** Create a new resource for this user */ | ||
@@ -18,5 +18,3 @@ create(builder: ResourceBuilder): Promise<Resource>; | ||
/** Delete an existing resource for this user */ | ||
delete(resource: Resource): Promise<Resource>; | ||
/** Refresh this cache */ | ||
refresh(): void; | ||
delete(resource: Resource): Promise<void>; | ||
} |
@@ -1,3 +0,2 @@ | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import { Collection } from "@discordjs/collection"; | ||
import { __extends } from "tslib"; | ||
import BaseManager from "./BaseManager"; | ||
@@ -9,61 +8,25 @@ var UserResourceManager = /** @class */ (function (_super) { | ||
_this.user = user; | ||
_this.cache = new Collection(); | ||
_this.refresh(); | ||
return _this; | ||
} | ||
Object.defineProperty(UserResourceManager.prototype, "cache", { | ||
/** Resources cache for this user */ | ||
get: function () { | ||
var _this = this; | ||
return this.client.resources.cache.filter(function (r) { var _a; return ((_a = r.creator) === null || _a === void 0 ? void 0 : _a.id) === _this.user.id; }); | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** Create a new resource for this user */ | ||
UserResourceManager.prototype.create = function (builder) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resource; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.resources.create(builder)]; | ||
case 1: | ||
resource = _a.sent(); | ||
this.cache.set(resource.id, resource); | ||
return [2 /*return*/, resource]; | ||
} | ||
}); | ||
}); | ||
return this.client.resources.create(builder); | ||
}; | ||
/** Edit an existing resource for this user */ | ||
UserResourceManager.prototype.edit = function (resource) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var editResource; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.client.resources.edit(resource)]; | ||
case 1: | ||
editResource = _a.sent(); | ||
this.cache.set(editResource.id, editResource); | ||
return [2 /*return*/, editResource]; | ||
} | ||
}); | ||
}); | ||
return this.client.resources.edit(resource); | ||
}; | ||
/** Delete an existing resource for this user */ | ||
UserResourceManager.prototype.delete = function (resource) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.cache.delete(resource.id); | ||
return [4 /*yield*/, this.client.resources.delete(resource)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, resource]; | ||
} | ||
}); | ||
}); | ||
return this.client.resources.delete(resource); | ||
}; | ||
/** 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; | ||
@@ -70,0 +33,0 @@ }(BaseManager)); |
{ | ||
"name": "rr-apilib", | ||
"version": "0.7.0-alpha", | ||
"version": "0.8.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
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
184946
2715