All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.src.preview-storage-client.js Maven / Gradle / Ivy

The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreviewStorageClient = void 0;
const clients_1 = require("@gomomento/sdk-core/dist/src/internal/clients");
const storage_control_client_1 = require("./internal/storage-control-client");
const storage_data_client_1 = require("./internal/storage-data-client");
const index_1 = require("./index");
const sdk_core_1 = require("@gomomento/sdk-core");
/**
 * A client for interacting with the Momento Storage service.
 * Warning: This client is in preview and may change in future releases.
 */
class PreviewStorageClient extends clients_1.AbstractStorageClient {
    constructor(props) {
        var _a, _b;
        const allProps = {
            configuration: (_a = props === null || props === void 0 ? void 0 : props.configuration) !== null && _a !== void 0 ? _a : getDefaultStorageClientConfiguration(),
            credentialProvider: (_b = props === null || props === void 0 ? void 0 : props.credentialProvider) !== null && _b !== void 0 ? _b : (0, sdk_core_1.getDefaultCredentialProvider)(),
        };
        const controlClient = createControlClient(allProps);
        const dataClient = createDataClient(allProps);
        super([dataClient], controlClient);
    }
    close() {
        this.dataClients.forEach(client => client.close());
        this.controlClient.close();
    }
}
exports.PreviewStorageClient = PreviewStorageClient;
function createControlClient(props) {
    return new storage_control_client_1.StorageControlClient(props);
}
function createDataClient(props) {
    return new storage_data_client_1.StorageDataClient(props);
}
function getDefaultStorageClientConfiguration() {
    const config = index_1.StorageConfigurations.Laptop.latest();
    const logger = config.getLoggerFactory().getLogger('StorageClient');
    logger.info('No configuration provided to StorageClient. Using default "Laptop" configuration, suitable for development. For production use, consider specifying an explicit configuration.');
    return config;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJldmlldy1zdG9yYWdlLWNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcmV2aWV3LXN0b3JhZ2UtY2xpZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDJFQUl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