Skip to content

Commit

Permalink
fix(forestadmin-client): bump lru-cache to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Thenkei committed Jun 21, 2023
1 parent 3a37f51 commit 203f5e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
3 changes: 1 addition & 2 deletions packages/forestadmin-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"eventsource": "2.0.2",
"json-api-serializer": "^2.6.6",
"jsonwebtoken": "^9.0.0",
"lru-cache": "^7.14.1",
"lru-cache": "^10.0.0",
"object-hash": "^3.0.0",
"openid-client": "^5.3.1",
"superagent": "^8.0.6"
Expand All @@ -35,7 +35,6 @@
"@forestadmin/datasource-toolkit": "1.5.0",
"@types/json-api-serializer": "^2.6.3",
"@types/jsonwebtoken": "^9.0.1",
"@types/lru-cache": "^7.10.10",
"@types/superagent": "^4.1.16"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LruCache from 'lru-cache';
import { LRUCache } from 'lru-cache';

import { hashChartRequest, hashServerCharts } from './hash-chart';
import isSegmentQueryAllowed from './is-segment-query-authorized';
Expand All @@ -23,17 +23,17 @@ export type RenderingPermission = {
};

export default class RenderingPermissionService {
private readonly permissionsByRendering: LruCache<string, RenderingPermission>;
private readonly permissionsByRendering: LRUCache<string, RenderingPermission>;

constructor(
private readonly options: ForestAdminClientOptionsWithDefaults,
private readonly userPermissions: UserPermissionService,
private readonly forestAdminServerInterface: ForestAdminServerInterface,
) {
this.permissionsByRendering = new LruCache({
this.permissionsByRendering = new LRUCache({
max: 256,
ttl: this.options.permissionsCacheDurationInSeconds * 1000,
fetchMethod: renderingId => this.loadPermissions(Number(renderingId)),
fetchMethod: async renderingId => this.loadPermissions(Number(renderingId)),
});
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export default class RenderingPermissionService {
userId: number | string;
allowRetry: boolean;
}): Promise<RawTree> {
const [permissions, userInfo]: [RenderingPermission, UserPermissionV4] = await Promise.all([
const [permissions, userInfo] = await Promise.all([
this.permissionsByRendering.fetch(`${renderingId}`),
this.userPermissions.getUserInfo(userId),
]);
Expand Down Expand Up @@ -125,9 +125,7 @@ export default class RenderingPermissionService {
segmentQuery: string;
allowRetry: boolean;
}): Promise<boolean> {
const permissions: RenderingPermission = await this.permissionsByRendering.fetch(
`${renderingId}`,
);
const permissions = await this.permissionsByRendering.fetch(`${renderingId}`);

const collectionPermissions = permissions?.collections?.[collectionName];

Expand Down Expand Up @@ -266,9 +264,7 @@ export default class RenderingPermissionService {
}

public async getTeam(renderingId: number | string): Promise<Team> {
const permissions: RenderingPermission = await this.permissionsByRendering.fetch(
`${renderingId}`,
);
const permissions = await this.permissionsByRendering.fetch(`${renderingId}`);

return permissions.team;
}
Expand Down
20 changes: 9 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3562,13 +3562,6 @@
dependencies:
"@types/koa" "*"

"@types/lru-cache@^7.10.10":
version "7.10.10"
resolved "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-7.10.10.tgz"
integrity sha512-nEpVRPWW9EBmx2SCfNn3ClYxPL7IktPX12HhIoSc/H5mMjdeW3+YsXIpseLQ2xF35+OcpwKQbEUw5VtqE4PDNA==
dependencies:
lru-cache "*"

"@types/luxon@^3.2.0":
version "3.2.0"
resolved "https://registry.npmjs.org/@types/luxon/-/luxon-3.2.0.tgz"
Expand Down Expand Up @@ -8585,10 +8578,10 @@ longest-streak@^2.0.0:
resolved "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz"
integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==

lru-cache@*, lru-cache@^7.14.0, lru-cache@^7.14.1, lru-cache@^7.4.4, lru-cache@^7.5.1, lru-cache@^7.7.1:
version "7.14.1"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-7.14.1.tgz"
integrity sha512-ysxwsnTKdAx96aTRdhDOCQfDgbHnt8SK0KY8SEjO0wHinhWOFTESbjVCMPbU1uGXg/ch4lifqx0wfjOawU2+WA==
lru-cache@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.0.0.tgz#b9e2a6a72a129d81ab317202d93c7691df727e61"
integrity sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==

lru-cache@^5.1.1:
version "5.1.1"
Expand All @@ -8604,6 +8597,11 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lru-cache@^7.14.0, lru-cache@^7.14.1, lru-cache@^7.4.4, lru-cache@^7.5.1, lru-cache@^7.7.1:
version "7.14.1"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-7.14.1.tgz"
integrity sha512-ysxwsnTKdAx96aTRdhDOCQfDgbHnt8SK0KY8SEjO0wHinhWOFTESbjVCMPbU1uGXg/ch4lifqx0wfjOawU2+WA==

lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz"
Expand Down

0 comments on commit 203f5e6

Please sign in to comment.