"use strict";
var Storage = (function () {
    function Storage(strategyCls, options) {
        this._strategy = new strategyCls(options);
    }
    Storage.prototype.get = function (key) {
        return this._strategy.get(key);
    };
    Storage.prototype.getJson = function (key) {
        return this.get(key).then(function (value) {
            try {
                return JSON.parse(value);
            }
            catch (e) {
                console.warn('Storage getJson(): unable to parse value for key', key, ' as JSON');
                throw e;
            }
        });
    };
    Storage.prototype.setJson = function (key, value) {
        try {
            return this.set(key, JSON.stringify(value));
        }
        catch (e) {
            return Promise.reject(e);
        }
    };
    Storage.prototype.set = function (key, value) {
        return this._strategy.set(key, value);
    };
    Storage.prototype.remove = function (key) {
        return this._strategy.remove(key);
    };
    Storage.prototype.query = function (query, params) {
        return this._strategy.query(query, params);
    };
    Storage.prototype.clear = function () {
        return this._strategy.clear();
    };
    return Storage;
}());
exports.Storage = Storage;
var StorageEngine = (function () {
    function StorageEngine(options) {
        if (options === void 0) { options = {}; }
    }
    StorageEngine.prototype.get = function (key) {
        throw Error('get() not implemented for this storage engine');
    };
    StorageEngine.prototype.set = function (key, value) {
        throw Error('set() not implemented for this storage engine');
    };
    StorageEngine.prototype.remove = function (key) {
        throw Error('remove() not implemented for this storage engine');
    };
    StorageEngine.prototype.query = function (query, params) {
        throw Error('query() not implemented for this storage engine');
    };
    StorageEngine.prototype.clear = function () {
        throw Error('clear() not implemented for this storage engine');
    };
    return StorageEngine;
}());
exports.StorageEngine = StorageEngine;
