UNPKG

@elsikora/nestjs-crud-automator

Version:

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

40 lines (37 loc) 1.36 kB
'use strict'; var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js'); var cache_class = require('../../resolver/cache.class.js'); var common = require('@nestjs/common'); exports.ApiAuthorizationIamDocumentCache = class ApiAuthorizationIamDocumentCache { CACHE = new cache_class.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("::"); } }; exports.ApiAuthorizationIamDocumentCache = tslib_es6.__decorate([ common.Injectable() ], exports.ApiAuthorizationIamDocumentCache); //# sourceMappingURL=cache.class.js.map