UNPKG

@azure/cosmos

Version:
56 lines (55 loc) 2.27 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var EncryptionSettingsCache_exports = {}; __export(EncryptionSettingsCache_exports, { EncryptionSettingsCache: () => EncryptionSettingsCache }); module.exports = __toCommonJS(EncryptionSettingsCache_exports); var import_EncryptionSettings = require("../EncryptionSettings.js"); var import_EncryptionSettingForProperty = require("../EncryptionSettingForProperty.js"); class EncryptionSettingsCache { // key is databaseRid + '/' + containerRid cache; constructor() { this.cache = /* @__PURE__ */ new Map(); } async create(id, containerRid, partitionKeyPaths, clientEncryptionPolicy) { const encryptionSettings = new import_EncryptionSettings.EncryptionSettings(id, containerRid, partitionKeyPaths); if (!clientEncryptionPolicy) return; for (const includedPath of clientEncryptionPolicy.includedPaths) { const encryptionSettingForProperty = new import_EncryptionSettingForProperty.EncryptionSettingForProperty(includedPath); encryptionSettings.pathsToEncrypt.push(includedPath.path); encryptionSettings.setEncryptionSettingForProperty( includedPath.path, encryptionSettingForProperty ); } this.set(id, encryptionSettings); return encryptionSettings; } get(key) { return this.cache.get(key); } set(key, encryptionSettings) { this.cache.set(key, encryptionSettings); } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { EncryptionSettingsCache });