UNPKG

@elsikora/nestjs-crud-automator

Version:

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

44 lines (41 loc) 1.53 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.ApiAuthorizationIamAttachmentCache = class ApiAuthorizationIamAttachmentCache { CACHE = new cache_class.ApiAuthorizationResolverCache(); clear() { this.CACHE.clear(); } configure(options) { this.CACHE.configure(options); } get(principal) { return this.CACHE.get(this.createPrincipalCacheKey(principal)); } set(principal, attachments) { this.CACHE.set(this.createPrincipalCacheKey(principal), attachments); } createPrincipalCacheKey(principal) { return JSON.stringify(this.normalizeValue(principal)); } normalizeValue(value) { if (Array.isArray(value)) { return value.map((item) => this.normalizeValue(item)); } if (!value || typeof value !== "object") { return value; } const normalizedValue = {}; const recordValue = value; const sortedKeys = Object.keys(recordValue).toSorted((left, right) => left.localeCompare(right)); for (const key of sortedKeys) { normalizedValue[key] = this.normalizeValue(recordValue[key]); } return normalizedValue; } }; exports.ApiAuthorizationIamAttachmentCache = tslib_es6.__decorate([ common.Injectable() ], exports.ApiAuthorizationIamAttachmentCache); //# sourceMappingURL=cache.class.js.map