Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(forestadmin-client): bump lru-cache to latest version #709

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3305,13 +3305,6 @@
dependencies:
"@types/koa" "*"

"@types/lru-cache@^7.10.10":
version "7.10.10"
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-7.10.10.tgz#3fa937c35ff4b3f6753d5737915c9bf8e693a713"
integrity sha512-nEpVRPWW9EBmx2SCfNn3ClYxPL7IktPX12HhIoSc/H5mMjdeW3+YsXIpseLQ2xF35+OcpwKQbEUw5VtqE4PDNA==
dependencies:
lru-cache "*"

"@types/luxon@^3.2.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-3.3.0.tgz#a61043a62c0a72696c73a0a305c544c96501e006"
Expand Down Expand Up @@ -8675,10 +8668,10 @@ longest-streak@^2.0.0:
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4"
integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==

lru-cache@*, lru-cache@^9.1.1:
version "9.1.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.2.tgz#255fdbc14b75589d6d0e73644ca167a8db506835"
integrity sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==
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 @@ -8704,6 +8697,11 @@ lru-cache@^8.0.0:
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-8.0.5.tgz#983fe337f3e176667f8e567cfcce7cb064ea214e"
integrity sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==

lru-cache@^9.1.1:
version "9.1.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.2.tgz#255fdbc14b75589d6d0e73644ca167a8db506835"
integrity sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ==

lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
Expand Down