UNPKG

@elsikora/nestjs-crud-automator

Version:

A library for automating the creation of CRUD operations in NestJS.

40 lines (37 loc) 1.37 kB
import { __decorate } from '../../../../../external/tslib/tslib.es6.js'; import { ApiAuthorizationResolverCache } from '../../resolver/cache.class.js'; import { Injectable } from '@nestjs/common'; let ApiAuthorizationIamDocumentCache = class ApiAuthorizationIamDocumentCache { CACHE = new ApiAuthorizationResolverCache(); clear() { this.CACHE.clear(); } configure(options) { this.CACHE.configure(options); } get(ids) { const normalizedIds = this.normalizeIds(ids); if (normalizedIds.length === 0) { return undefined; } return this.CACHE.get(this.createDocumentCacheKey(normalizedIds)); } normalizeIds(ids) { return [...new Set(ids.filter((id) => typeof id === "string" && id.length > 0))].toSorted((left, right) => left.localeCompare(right)); } set(ids, documents) { const normalizedIds = this.normalizeIds(ids); if (normalizedIds.length === 0) { return; } this.CACHE.set(this.createDocumentCacheKey(normalizedIds), documents); } createDocumentCacheKey(normalizedIds) { return normalizedIds.join("::"); } }; ApiAuthorizationIamDocumentCache = __decorate([ Injectable() ], ApiAuthorizationIamDocumentCache); export { ApiAuthorizationIamDocumentCache }; //# sourceMappingURL=cache.class.js.map