"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.StorageServiceWithAttachBlobs = void 0;
const internal_1 = require("@fluidframework/telemetry-utils/internal");
/**
 * IRuntimeStorageService proxy which intercepts requests if they can be satisfied by the blobs received in the
 * attach message. We use this to avoid an unnecessary request to the storage service.
 */
class StorageServiceWithAttachBlobs {
    constructor(internalStorageService, attachBlobs) {
        this.internalStorageService = internalStorageService;
        this.attachBlobs = attachBlobs;
    }
    /**
     * {@link IRuntimeStorageService.policies}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    get policies() {
        return this.internalStorageService.policies;
    }
    async readBlob(id) {
        const blob = this.attachBlobs.get(id);
        if (blob !== undefined) {
            return blob;
        }
        // Note that it is intentional not to cache the result of this readBlob - we'll trust the real
        // IRuntimeStorageService to cache appropriately, no need to double-cache.
        return this.internalStorageService.readBlob(id);
    }
    /**
     * {@link IRuntimeStorageService.getSnapshotTree}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async getSnapshotTree(version, scenarioName) {
        return this.internalStorageService.getSnapshotTree(version, scenarioName);
    }
    /**
     * {@link IRuntimeStorageService.getSnapshot}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async getSnapshot(snapshotFetchOptions) {
        if (this.internalStorageService.getSnapshot !== undefined) {
            return this.internalStorageService.getSnapshot(snapshotFetchOptions);
        }
        throw new internal_1.UsageError("getSnapshot api should exist on internal storage in documentStorageServiceProxy class");
    }
    /**
     * {@link IRuntimeStorageService.getVersions}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async getVersions(
    // eslint-disable-next-line @rushstack/no-new-null
    versionId, count, scenarioName, fetchSource) {
        return this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource);
    }
    /**
     * {@link IRuntimeStorageService.uploadSummaryWithContext}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async uploadSummaryWithContext(summary, context) {
        return this.internalStorageService.uploadSummaryWithContext(summary, context);
    }
    /**
     * {@link IRuntimeStorageService.createBlob}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async createBlob(file) {
        return this.internalStorageService.createBlob(file);
    }
    /**
     * {@link IRuntimeStorageService.downloadSummary}.
     * @deprecated - This will be removed in a future release. The DataStore layer does not need this.
     */
    async downloadSummary(handle) {
        return this.internalStorageService.downloadSummary(handle);
    }
}
exports.StorageServiceWithAttachBlobs = StorageServiceWithAttachBlobs;
//# sourceMappingURL=storageServiceWithAttachBlobs.js.map