From e86c9cd8de6fb6b73f3b5e185b4cc7a7afe81a83 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sat, 17 Dec 2022 22:05:41 +0330 Subject: [PATCH] fix(storage-engine): work with new types --- core/storage-engine/src/storage-engine.ts | 12 ++++++------ core/storage-engine/src/type.ts | 14 ++------------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/core/storage-engine/src/storage-engine.ts b/core/storage-engine/src/storage-engine.ts index 632ec2025..390f8a707 100644 --- a/core/storage-engine/src/storage-engine.ts +++ b/core/storage-engine/src/storage-engine.ts @@ -5,10 +5,10 @@ import exitHook from 'exit-hook'; import {readJsonFile, writeJsonFile} from './util.js'; -import type {DataStorage, AlwatrStorageEngineConfig, AlwatrDocumentObject} from './type.js'; +import type {AlwatrDocumentStorage, AlwatrStorageEngineConfig, AlwatrDocumentObject} from './type.js'; import type {AlwatrLogger} from '@alwatr/logger'; -export {DataStorage, AlwatrStorageEngineConfig, AlwatrDocumentObject}; +export {AlwatrDocumentStorage as DataStorage, AlwatrStorageEngineConfig, AlwatrDocumentObject}; alwatrRegisteredList.push({ name: '@alwatr/storage-engine', @@ -97,7 +97,7 @@ export class AlwatrStorageEngine; + _storage: AlwatrDocumentStorage; protected _logger: AlwatrLogger; protected _keys: Array | null = null; @@ -130,7 +130,7 @@ export class AlwatrStorageEngine { + protected get _newStorage(): AlwatrDocumentStorage { return { ok: true, meta: { @@ -160,10 +160,10 @@ export class AlwatrStorageEngine { + protected load(): AlwatrDocumentStorage { this._logger.logMethodArgs('load', {name: this.name, path: this.storagePath}); - const storage = readJsonFile>(this.storagePath); + const storage = readJsonFile>(this.storagePath); if (storage === null) { this._logger.incident('load', 'file_not_found', 'Storage path not found, empty storage loaded', { diff --git a/core/storage-engine/src/type.ts b/core/storage-engine/src/type.ts index ef183db50..252693243 100644 --- a/core/storage-engine/src/type.ts +++ b/core/storage-engine/src/type.ts @@ -1,17 +1,7 @@ -import type {AlwatrDocumentObject, AlwatrServiceResponseSuccessWithMeta} from '@alwatr/fetch/type.js'; +import type {AlwatrDocumentObject, AlwatrDocumentMeta, AlwatrDocumentStorage} from '@alwatr/fetch/type.js'; -export {AlwatrDocumentObject}; +export {AlwatrDocumentObject, AlwatrDocumentMeta, AlwatrDocumentStorage}; -export type StorageMeta = { - formatVersion: number; - reversion: number; - lastUpdated: number; - lastAutoId: number; -}; - -export type DataStorage = Readonly< - Omit, StorageMeta>, 'statusCode' | 'errorCode'> ->; export type AlwatrStorageEngineConfig = { /**