From 0d515615af2e1de65c10e22db928d61fc7f06606 Mon Sep 17 00:00:00 2001 From: Tate Date: Fri, 1 Nov 2024 03:39:35 +0000 Subject: [PATCH] Rename the directory file to storeModelProvider; rename MetadataModel to MetadataEntity --- .../blockDispatcher/base-block-dispatcher.ts | 4 +- .../blockDispatcher/block-dispatcher.ts | 2 +- .../worker-block-dispatcher.spec.ts | 2 +- .../worker-block-dispatcher.ts | 2 +- packages/node-core/src/indexer/core.module.ts | 2 +- .../src/indexer/dynamic-ds.service.spec.ts | 2 +- .../src/indexer/dynamic-ds.service.ts | 2 +- .../src/indexer/entities/Metadata.entity.ts | 4 +- .../node-core/src/indexer/fetch.service.ts | 2 +- packages/node-core/src/indexer/index.ts | 2 +- .../src/indexer/poi/poi.service.spec.ts | 2 +- .../node-core/src/indexer/poi/poi.service.ts | 4 +- .../src/indexer/poi/poiSync.service.spec.ts | 2 +- .../src/indexer/poi/poiSync.service.ts | 2 +- .../node-core/src/indexer/project.service.ts | 2 +- .../node-core/src/indexer/store.service.ts | 2 +- packages/node-core/src/indexer/store/store.ts | 2 +- .../baseCache.service.ts | 0 .../baseStoreModel.service.ts | 0 .../cacheable.ts | 0 .../csvStore.service.spec.ts | 0 .../csvStore.service.ts | 5 +- .../index.ts | 0 .../metadata/cacheMetadata.spec.ts | 0 .../metadata/cacheMetadata.test.ts | 46 +++++++++---------- .../metadata/cacheMetadata.ts | 2 +- .../metadata/index.ts | 2 +- .../metadata/metadata.ts | 0 .../metadata/utils.ts | 0 .../model/cacheModel.spec.ts | 0 .../model/cacheModel.test.ts | 2 +- .../model/cacheModel.ts | 0 .../model/index.ts | 0 .../model/model.ts | 5 +- .../model/utils.ts | 2 +- .../poi/cachePoi.spec.ts | 0 .../poi/cachePoi.ts | 0 .../poi/index.ts | 0 .../poi/poi.ts | 0 .../setValueModel.spec.ts | 0 .../setValueModel.ts | 0 .../storeCache.service.spec.ts | 0 .../storeCache.service.ts | 0 .../storeModel.service.ts | 0 .../types.ts | 0 packages/node-core/src/indexer/test.runner.ts | 2 +- .../indexer/unfinalizedBlocks.service.spec.ts | 2 +- .../src/indexer/unfinalizedBlocks.service.ts | 2 +- 48 files changed, 58 insertions(+), 52 deletions(-) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/baseCache.service.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/baseStoreModel.service.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/cacheable.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/csvStore.service.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/csvStore.service.ts (96%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/index.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/cacheMetadata.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/cacheMetadata.test.ts (65%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/cacheMetadata.ts (99%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/index.ts (76%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/metadata.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/metadata/utils.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/cacheModel.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/cacheModel.test.ts (99%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/cacheModel.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/index.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/model.ts (96%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/model/utils.ts (95%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/poi/cachePoi.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/poi/cachePoi.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/poi/index.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/poi/poi.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/setValueModel.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/setValueModel.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/storeCache.service.spec.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/storeCache.service.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/storeModel.service.ts (100%) rename packages/node-core/src/indexer/{storeCache => storeModelProvider}/types.ts (100%) diff --git a/packages/node-core/src/indexer/blockDispatcher/base-block-dispatcher.ts b/packages/node-core/src/indexer/blockDispatcher/base-block-dispatcher.ts index 8371c0f4c7..b78a71584f 100644 --- a/packages/node-core/src/indexer/blockDispatcher/base-block-dispatcher.ts +++ b/packages/node-core/src/indexer/blockDispatcher/base-block-dispatcher.ts @@ -15,8 +15,8 @@ import {MonitorServiceInterface} from '../monitor.service'; import {PoiBlock, PoiSyncService} from '../poi'; import {SmartBatchService} from '../smartBatch.service'; import {StoreService} from '../store.service'; -import {IStoreModelProvider} from '../storeCache'; -import {IPoi} from '../storeCache/poi'; +import {IStoreModelProvider} from '../storeModelProvider'; +import {IPoi} from '../storeModelProvider/poi'; import {IBlock, IProjectService, ISubqueryProject} from '../types'; const logger = getLogger('BaseBlockDispatcherService'); diff --git a/packages/node-core/src/indexer/blockDispatcher/block-dispatcher.ts b/packages/node-core/src/indexer/blockDispatcher/block-dispatcher.ts index e549c5ab76..01ca467238 100644 --- a/packages/node-core/src/indexer/blockDispatcher/block-dispatcher.ts +++ b/packages/node-core/src/indexer/blockDispatcher/block-dispatcher.ts @@ -14,7 +14,7 @@ import {exitWithError, monitorWrite} from '../../process'; import {profilerWrap} from '../../profiler'; import {Queue, AutoQueue, delay, memoryLock, waitForBatchSize, isTaskFlushedError} from '../../utils'; import {StoreService} from '../store.service'; -import {IStoreModelProvider} from '../storeCache'; +import {IStoreModelProvider} from '../storeModelProvider'; import {IProjectService, ISubqueryProject} from '../types'; import {BaseBlockDispatcher, ProcessBlockResponse} from './base-block-dispatcher'; diff --git a/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.spec.ts b/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.spec.ts index a1ce276196..cc8e5da01e 100644 --- a/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.spec.ts +++ b/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.spec.ts @@ -5,7 +5,7 @@ import {EventEmitter2} from '@nestjs/event-emitter'; import {IProjectUpgradeService, NodeConfig} from '../../configure'; import {PoiSyncService} from '../poi'; import {StoreService} from '../store.service'; -import {StoreCacheService} from '../storeCache'; +import {StoreCacheService} from '../storeModelProvider'; import {IProjectService, ISubqueryProject} from '../types'; import {WorkerBlockDispatcher} from './worker-block-dispatcher'; diff --git a/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts b/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts index 88d3c60530..8b105e1272 100644 --- a/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts +++ b/packages/node-core/src/indexer/blockDispatcher/worker-block-dispatcher.ts @@ -15,7 +15,7 @@ import {monitorWrite} from '../../process'; import {AutoQueue, isTaskFlushedError} from '../../utils'; import {MonitorServiceInterface} from '../monitor.service'; import {StoreService} from '../store.service'; -import {IStoreModelProvider} from '../storeCache'; +import {IStoreModelProvider} from '../storeModelProvider'; import {ISubqueryProject, IProjectService} from '../types'; import {isBlockUnavailableError} from '../worker/utils'; import {BaseBlockDispatcher} from './base-block-dispatcher'; diff --git a/packages/node-core/src/indexer/core.module.ts b/packages/node-core/src/indexer/core.module.ts index 1a54c83348..53637925d5 100644 --- a/packages/node-core/src/indexer/core.module.ts +++ b/packages/node-core/src/indexer/core.module.ts @@ -15,7 +15,7 @@ import {MonitorService} from './monitor.service'; import {PoiService, PoiSyncService} from './poi'; import {SandboxService} from './sandbox.service'; import {StoreService} from './store.service'; -import {IStoreModelProvider, PlainStoreModelService, StoreCacheService} from './storeCache'; +import {IStoreModelProvider, PlainStoreModelService, StoreCacheService} from './storeModelProvider'; @Module({ providers: [ diff --git a/packages/node-core/src/indexer/dynamic-ds.service.spec.ts b/packages/node-core/src/indexer/dynamic-ds.service.spec.ts index fc3b0807bb..6c7ca7be7d 100644 --- a/packages/node-core/src/indexer/dynamic-ds.service.spec.ts +++ b/packages/node-core/src/indexer/dynamic-ds.service.spec.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0 import {DatasourceParams, DynamicDsService} from './dynamic-ds.service'; -import {CacheMetadataModel} from './storeCache'; +import {CacheMetadataModel} from './storeModelProvider'; import {ISubqueryProject} from './types'; class TestDynamicDsService extends DynamicDsService { diff --git a/packages/node-core/src/indexer/dynamic-ds.service.ts b/packages/node-core/src/indexer/dynamic-ds.service.ts index 5e214ebd49..9dae8d6245 100644 --- a/packages/node-core/src/indexer/dynamic-ds.service.ts +++ b/packages/node-core/src/indexer/dynamic-ds.service.ts @@ -5,7 +5,7 @@ import {Transaction} from '@subql/x-sequelize'; import {cloneDeep} from 'lodash'; import {getLogger} from '../logger'; import {exitWithError} from '../process'; -import {IMetadata} from './storeCache'; +import {IMetadata} from './storeModelProvider'; import {ISubqueryProject} from './types'; const logger = getLogger('dynamic-ds'); diff --git a/packages/node-core/src/indexer/entities/Metadata.entity.ts b/packages/node-core/src/indexer/entities/Metadata.entity.ts index e02224dee5..b3d7056442 100644 --- a/packages/node-core/src/indexer/entities/Metadata.entity.ts +++ b/packages/node-core/src/indexer/entities/Metadata.entity.ts @@ -39,10 +39,10 @@ export interface Metadata { value: MetadataKeys[keyof MetadataKeys]; } -export interface MetadataModel extends Model, Metadata {} +interface MetadataEntity extends Model, Metadata {} export type MetadataRepo = typeof Model & { - new (values?: unknown, options?: BuildOptions): MetadataModel; + new (values?: unknown, options?: BuildOptions): MetadataEntity; }; async function checkSchemaMetadata(sequelize: Sequelize, schema: string, chainId: string): Promise { diff --git a/packages/node-core/src/indexer/fetch.service.ts b/packages/node-core/src/indexer/fetch.service.ts index d2dd0ba0d8..82eefc5127 100644 --- a/packages/node-core/src/indexer/fetch.service.ts +++ b/packages/node-core/src/indexer/fetch.service.ts @@ -15,7 +15,7 @@ import {IBlockDispatcher} from './blockDispatcher'; import {mergeNumAndBlocksToNums} from './dictionary'; import {DictionaryService} from './dictionary/dictionary.service'; import {mergeNumAndBlocks} from './dictionary/utils'; -import {IStoreModelProvider} from './storeCache'; +import {IStoreModelProvider} from './storeModelProvider'; import {BypassBlocks, Header, IBlock, IProjectService} from './types'; import {IUnfinalizedBlocksServiceUtil} from './unfinalizedBlocks.service'; diff --git a/packages/node-core/src/indexer/index.ts b/packages/node-core/src/indexer/index.ts index a72711e53e..39791422b7 100644 --- a/packages/node-core/src/indexer/index.ts +++ b/packages/node-core/src/indexer/index.ts @@ -9,7 +9,7 @@ export * from './types'; export * from './StoreOperations'; export * from './store.service'; export * from './inMemoryCache.service'; -export * from './storeCache'; +export * from './storeModelProvider'; export * from './worker'; export * from './dictionary'; export * from './sandbox'; diff --git a/packages/node-core/src/indexer/poi/poi.service.spec.ts b/packages/node-core/src/indexer/poi/poi.service.spec.ts index 09b5ac54c9..8fc787f900 100644 --- a/packages/node-core/src/indexer/poi/poi.service.spec.ts +++ b/packages/node-core/src/indexer/poi/poi.service.spec.ts @@ -8,7 +8,7 @@ import {delay} from '@subql/common'; import {Sequelize, Transaction} from '@subql/x-sequelize'; import {NodeConfig} from '../../configure'; import {ProofOfIndex} from '../entities/Poi.entity'; -import {StoreCacheService} from '../storeCache'; +import {StoreCacheService} from '../storeModelProvider'; import {PoiService} from './poi.service'; jest.mock('@subql/x-sequelize', () => { diff --git a/packages/node-core/src/indexer/poi/poi.service.ts b/packages/node-core/src/indexer/poi/poi.service.ts index 5739580ba1..69acd96f87 100644 --- a/packages/node-core/src/indexer/poi/poi.service.ts +++ b/packages/node-core/src/indexer/poi/poi.service.ts @@ -9,8 +9,8 @@ import {sqlIterator} from '../../db'; import {getLogger} from '../../logger'; import {PoiRepo} from '../entities'; import {ProofOfIndex, ProofOfIndexHuman, SyncedProofOfIndex} from '../entities/Poi.entity'; -import {IStoreModelProvider} from '../storeCache'; -import {IPoi, CachePoiModel, PlainPoiModel} from '../storeCache/poi'; +import {IStoreModelProvider} from '../storeModelProvider'; +import {IPoi, CachePoiModel, PlainPoiModel} from '../storeModelProvider/poi'; const logger = getLogger('PoiService'); diff --git a/packages/node-core/src/indexer/poi/poiSync.service.spec.ts b/packages/node-core/src/indexer/poi/poiSync.service.spec.ts index d154b22777..fa30f84b18 100644 --- a/packages/node-core/src/indexer/poi/poiSync.service.spec.ts +++ b/packages/node-core/src/indexer/poi/poiSync.service.spec.ts @@ -8,7 +8,7 @@ import {range} from 'lodash'; import {NodeConfig} from '../../configure'; import {MetadataFactory, PoiFactory, ProofOfIndex} from '../../indexer'; import {Queue} from '../../utils'; -import {PlainPoiModel} from '../storeCache/poi'; +import {PlainPoiModel} from '../storeModelProvider/poi'; import {ISubqueryProject} from '../types'; import {PoiSyncService} from './poiSync.service'; diff --git a/packages/node-core/src/indexer/poi/poiSync.service.ts b/packages/node-core/src/indexer/poi/poiSync.service.ts index fb4e3451d3..93254b036d 100644 --- a/packages/node-core/src/indexer/poi/poiSync.service.ts +++ b/packages/node-core/src/indexer/poi/poiSync.service.ts @@ -14,7 +14,7 @@ import {exitWithError} from '../../process'; import {hasValue, Queue} from '../../utils'; import {Metadata, MetadataFactory, MetadataRepo} from '../entities'; import {PoiFactory, ProofOfIndex, SyncedProofOfIndex} from '../entities/Poi.entity'; -import {PlainPoiModel} from '../storeCache/poi'; +import {PlainPoiModel} from '../storeModelProvider/poi'; import {ISubqueryProject} from '../types'; import {PoiBlock} from './PoiBlock'; diff --git a/packages/node-core/src/indexer/project.service.ts b/packages/node-core/src/indexer/project.service.ts index 09048f666a..a632ae9edb 100644 --- a/packages/node-core/src/indexer/project.service.ts +++ b/packages/node-core/src/indexer/project.service.ts @@ -19,7 +19,7 @@ import {MetadataKeys} from './entities'; import {PoiSyncService} from './poi'; import {PoiService} from './poi/poi.service'; import {StoreService} from './store.service'; -import {isCachePolicy} from './storeCache'; +import {isCachePolicy} from './storeModelProvider'; import {ISubqueryProject, IProjectService, BypassBlocks} from './types'; import {IUnfinalizedBlocksService} from './unfinalizedBlocks.service'; diff --git a/packages/node-core/src/indexer/store.service.ts b/packages/node-core/src/indexer/store.service.ts index c31804ea94..e406d57959 100644 --- a/packages/node-core/src/indexer/store.service.ts +++ b/packages/node-core/src/indexer/store.service.ts @@ -38,7 +38,7 @@ import {exitWithError} from '../process'; import {camelCaseObjectKey, customCamelCaseGraphqlKey} from '../utils'; import {MetadataFactory, MetadataRepo, PoiFactory, PoiFactoryDeprecate, PoiRepo} from './entities'; import {Store} from './store'; -import {IMetadata, isCachePolicy, IStoreModelProvider} from './storeCache'; +import {IMetadata, isCachePolicy, IStoreModelProvider} from './storeModelProvider'; import {StoreOperations} from './StoreOperations'; import {ISubqueryProject} from './types'; diff --git a/packages/node-core/src/indexer/store/store.ts b/packages/node-core/src/indexer/store/store.ts index 87a4ca78eb..e157eed9d8 100644 --- a/packages/node-core/src/indexer/store/store.ts +++ b/packages/node-core/src/indexer/store/store.ts @@ -7,7 +7,7 @@ import {Transaction} from '@subql/x-sequelize'; import {NodeConfig} from '../../configure'; import {monitorWrite} from '../../process'; import {handledStringify} from '../../utils'; -import {IStoreModelProvider} from '../storeCache'; +import {IStoreModelProvider} from '../storeModelProvider'; import {StoreOperations} from '../StoreOperations'; import {OperationType} from '../types'; import {EntityClass} from './entity'; diff --git a/packages/node-core/src/indexer/storeCache/baseCache.service.ts b/packages/node-core/src/indexer/storeModelProvider/baseCache.service.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/baseCache.service.ts rename to packages/node-core/src/indexer/storeModelProvider/baseCache.service.ts diff --git a/packages/node-core/src/indexer/storeCache/baseStoreModel.service.ts b/packages/node-core/src/indexer/storeModelProvider/baseStoreModel.service.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/baseStoreModel.service.ts rename to packages/node-core/src/indexer/storeModelProvider/baseStoreModel.service.ts diff --git a/packages/node-core/src/indexer/storeCache/cacheable.ts b/packages/node-core/src/indexer/storeModelProvider/cacheable.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/cacheable.ts rename to packages/node-core/src/indexer/storeModelProvider/cacheable.ts diff --git a/packages/node-core/src/indexer/storeCache/csvStore.service.spec.ts b/packages/node-core/src/indexer/storeModelProvider/csvStore.service.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/csvStore.service.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/csvStore.service.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/csvStore.service.ts b/packages/node-core/src/indexer/storeModelProvider/csvStore.service.ts similarity index 96% rename from packages/node-core/src/indexer/storeCache/csvStore.service.ts rename to packages/node-core/src/indexer/storeModelProvider/csvStore.service.ts index 116310ac55..7b7ddadca8 100644 --- a/packages/node-core/src/indexer/storeCache/csvStore.service.ts +++ b/packages/node-core/src/indexer/storeModelProvider/csvStore.service.ts @@ -14,7 +14,10 @@ export class CsvStoreService implements Exporter { private stringifyStream: Stringifier; private readonly writeStream: fs.WriteStream; - constructor(private modelName: string, private outputPath: string) { + constructor( + private modelName: string, + private outputPath: string + ) { this.writeStream = fs.createWriteStream(this.getCsvFilePath(), {flags: 'a'}); this.stringifyStream = stringify({header: !this.fileExist}).on('error', (err) => { diff --git a/packages/node-core/src/indexer/storeCache/index.ts b/packages/node-core/src/indexer/storeModelProvider/index.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/index.ts rename to packages/node-core/src/indexer/storeModelProvider/index.ts diff --git a/packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.spec.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.test.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.test.ts similarity index 65% rename from packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.test.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.test.ts index 3255e07bbf..73594431de 100644 --- a/packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.test.ts +++ b/packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.test.ts @@ -1,10 +1,10 @@ // Copyright 2020-2024 SubQuery Pte Ltd authors & contributors // SPDX-License-Identifier: GPL-3.0 -import { Sequelize } from '@subql/x-sequelize'; -import { MetadataFactory, MetadataKeys, MetadataRepo } from '../../'; -import { DbOption } from '../../../'; -import { CacheMetadataModel } from './cacheMetadata'; +import {Sequelize} from '@subql/x-sequelize'; +import {MetadataFactory, MetadataKeys, MetadataRepo} from '../..'; +import {DbOption} from '../../..'; +import {CacheMetadataModel} from './cacheMetadata'; const option: DbOption = { host: process.env.DB_HOST ?? '127.0.0.1', @@ -49,7 +49,7 @@ describe('cacheMetadata integration', () => { }; afterAll(async () => { - await sequelize.dropSchema(schema, { logging: false }); + await sequelize.dropSchema(schema, {logging: false}); await sequelize.close(); }); @@ -70,18 +70,18 @@ describe('cacheMetadata integration', () => { describe('dynamicDatasources', () => { beforeEach(async () => { // Ensure value exits so we can update it - await metaDataRepo.bulkCreate([{ key: 'dynamicDatasources', value: [] }], { updateOnDuplicate: ['key', 'value'] }); + await metaDataRepo.bulkCreate([{key: 'dynamicDatasources', value: []}], {updateOnDuplicate: ['key', 'value']}); }); it('Appends dynamicDatasources correctly', async () => { - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'foo', startBlock: 1 }); - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'bar', startBlock: 2 }); - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'baz', startBlock: 3 }); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'foo', startBlock: 1}); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'bar', startBlock: 2}); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'baz', startBlock: 3}); const expected = [ - { templateName: 'foo', startBlock: 1 }, - { templateName: 'bar', startBlock: 2 }, - { templateName: 'baz', startBlock: 3 }, + {templateName: 'foo', startBlock: 1}, + {templateName: 'bar', startBlock: 2}, + {templateName: 'baz', startBlock: 3}, ]; await flush(); @@ -94,40 +94,40 @@ describe('cacheMetadata integration', () => { }); it('Allows overriding all dynamicDatasources', async () => { - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'foo', startBlock: 1 }); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'foo', startBlock: 1}); - cacheMetadataModel.set('dynamicDatasources', [{ templateName: 'bar', startBlock: 2 }]); + cacheMetadataModel.set('dynamicDatasources', [{templateName: 'bar', startBlock: 2}]); await flush(); const v = await queryMeta('dynamicDatasources'); - expect(v).toEqual([{ templateName: 'bar', startBlock: 2 }]); + expect(v).toEqual([{templateName: 'bar', startBlock: 2}]); }); it('Caches the dynamicDatasources correctly after using set', async () => { - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'foo', startBlock: 1 }); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'foo', startBlock: 1}); await flush(); const cacheV = await cacheMetadataModel.find('dynamicDatasources'); - expect(cacheV).toEqual([{ templateName: 'foo', startBlock: 1 }]); + expect(cacheV).toEqual([{templateName: 'foo', startBlock: 1}]); - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'bar', startBlock: 2 }); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'bar', startBlock: 2}); // await flush(); const cacheV2 = await cacheMetadataModel.find('dynamicDatasources'); expect(cacheV2).toEqual([ - { templateName: 'foo', startBlock: 1 }, - { templateName: 'bar', startBlock: 2 }, + {templateName: 'foo', startBlock: 1}, + {templateName: 'bar', startBlock: 2}, ]); }); it('Uses the correct cache values when using new and set', async () => { - cacheMetadataModel.setNewDynamicDatasource({ templateName: 'foo', startBlock: 1 }); + cacheMetadataModel.setNewDynamicDatasource({templateName: 'foo', startBlock: 1}); - cacheMetadataModel.set('dynamicDatasources', [{ templateName: 'bar', startBlock: 2 }]); + cacheMetadataModel.set('dynamicDatasources', [{templateName: 'bar', startBlock: 2}]); const cacheV = await cacheMetadataModel.find('dynamicDatasources'); - expect(cacheV).toEqual([{ templateName: 'bar', startBlock: 2 }]); + expect(cacheV).toEqual([{templateName: 'bar', startBlock: 2}]); }); }); }); diff --git a/packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.ts similarity index 99% rename from packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.ts index fcac1df9eb..d070a131c1 100644 --- a/packages/node-core/src/indexer/storeCache/metadata/cacheMetadata.ts +++ b/packages/node-core/src/indexer/storeModelProvider/metadata/cacheMetadata.ts @@ -167,7 +167,7 @@ export class CacheMetadataModel extends Cacheable implements IMetadata, ICachedM async runFlush(tx: Transaction, blockHeight?: number): Promise { const ops = Object.entries(this.setCache) .filter(([key]) => !specialKeys.includes(key as MetadataKey)) - .map(([key, value]) => ({key, value} as Metadata)); + .map(([key, value]) => ({key, value}) as Metadata); const lastProcessedHeightIdx = ops.findIndex((k) => k.key === 'lastProcessedHeight'); if (blockHeight !== undefined && lastProcessedHeightIdx >= 0) { diff --git a/packages/node-core/src/indexer/storeCache/metadata/index.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/index.ts similarity index 76% rename from packages/node-core/src/indexer/storeCache/metadata/index.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/index.ts index 961566f4d0..94df86710c 100644 --- a/packages/node-core/src/indexer/storeCache/metadata/index.ts +++ b/packages/node-core/src/indexer/storeModelProvider/metadata/index.ts @@ -2,4 +2,4 @@ // SPDX-License-Identifier: GPL-3.0 export * from './cacheMetadata'; -export { IMetadata } from './metadata'; +export {IMetadata} from './metadata'; diff --git a/packages/node-core/src/indexer/storeCache/metadata/metadata.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/metadata.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/metadata/metadata.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/metadata.ts diff --git a/packages/node-core/src/indexer/storeCache/metadata/utils.ts b/packages/node-core/src/indexer/storeModelProvider/metadata/utils.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/metadata/utils.ts rename to packages/node-core/src/indexer/storeModelProvider/metadata/utils.ts diff --git a/packages/node-core/src/indexer/storeCache/model/cacheModel.spec.ts b/packages/node-core/src/indexer/storeModelProvider/model/cacheModel.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/model/cacheModel.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/model/cacheModel.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/model/cacheModel.test.ts b/packages/node-core/src/indexer/storeModelProvider/model/cacheModel.test.ts similarity index 99% rename from packages/node-core/src/indexer/storeCache/model/cacheModel.test.ts rename to packages/node-core/src/indexer/storeModelProvider/model/cacheModel.test.ts index eff3b0b774..a7163ecfe5 100644 --- a/packages/node-core/src/indexer/storeCache/model/cacheModel.test.ts +++ b/packages/node-core/src/indexer/storeModelProvider/model/cacheModel.test.ts @@ -4,7 +4,7 @@ import {GraphQLModelsType} from '@subql/utils'; import {Sequelize, DataTypes, QueryTypes} from '@subql/x-sequelize'; import {cloneDeep, padStart} from 'lodash'; -import {DbOption, modelsTypeToModelAttributes, NodeConfig} from '../../../'; +import {DbOption, modelsTypeToModelAttributes, NodeConfig} from '../../..'; import {CachedModel} from './cacheModel'; const option: DbOption = { diff --git a/packages/node-core/src/indexer/storeCache/model/cacheModel.ts b/packages/node-core/src/indexer/storeModelProvider/model/cacheModel.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/model/cacheModel.ts rename to packages/node-core/src/indexer/storeModelProvider/model/cacheModel.ts diff --git a/packages/node-core/src/indexer/storeCache/model/index.ts b/packages/node-core/src/indexer/storeModelProvider/model/index.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/model/index.ts rename to packages/node-core/src/indexer/storeModelProvider/model/index.ts diff --git a/packages/node-core/src/indexer/storeCache/model/model.ts b/packages/node-core/src/indexer/storeModelProvider/model/model.ts similarity index 96% rename from packages/node-core/src/indexer/storeCache/model/model.ts rename to packages/node-core/src/indexer/storeModelProvider/model/model.ts index 5d8b9d74d1..822424b796 100644 --- a/packages/node-core/src/indexer/storeCache/model/model.ts +++ b/packages/node-core/src/indexer/storeModelProvider/model/model.ts @@ -21,7 +21,10 @@ export interface IModel { } export class PlainModel implements IModel { - constructor(readonly model: ModelStatic>, private readonly historical = true) {} + constructor( + readonly model: ModelStatic>, + private readonly historical = true + ) {} async get(id: string): Promise { const record = await this.model.findOne({ diff --git a/packages/node-core/src/indexer/storeCache/model/utils.ts b/packages/node-core/src/indexer/storeModelProvider/model/utils.ts similarity index 95% rename from packages/node-core/src/indexer/storeCache/model/utils.ts rename to packages/node-core/src/indexer/storeModelProvider/model/utils.ts index 9abb6b0ddf..5c1aa9c564 100644 --- a/packages/node-core/src/indexer/storeCache/model/utils.ts +++ b/packages/node-core/src/indexer/storeModelProvider/model/utils.ts @@ -23,4 +23,4 @@ export const getFullOptions = (options?: GetOptions): Required), ...options, - } as Required>); + }) as Required>; diff --git a/packages/node-core/src/indexer/storeCache/poi/cachePoi.spec.ts b/packages/node-core/src/indexer/storeModelProvider/poi/cachePoi.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/poi/cachePoi.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/poi/cachePoi.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/poi/cachePoi.ts b/packages/node-core/src/indexer/storeModelProvider/poi/cachePoi.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/poi/cachePoi.ts rename to packages/node-core/src/indexer/storeModelProvider/poi/cachePoi.ts diff --git a/packages/node-core/src/indexer/storeCache/poi/index.ts b/packages/node-core/src/indexer/storeModelProvider/poi/index.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/poi/index.ts rename to packages/node-core/src/indexer/storeModelProvider/poi/index.ts diff --git a/packages/node-core/src/indexer/storeCache/poi/poi.ts b/packages/node-core/src/indexer/storeModelProvider/poi/poi.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/poi/poi.ts rename to packages/node-core/src/indexer/storeModelProvider/poi/poi.ts diff --git a/packages/node-core/src/indexer/storeCache/setValueModel.spec.ts b/packages/node-core/src/indexer/storeModelProvider/setValueModel.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/setValueModel.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/setValueModel.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/setValueModel.ts b/packages/node-core/src/indexer/storeModelProvider/setValueModel.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/setValueModel.ts rename to packages/node-core/src/indexer/storeModelProvider/setValueModel.ts diff --git a/packages/node-core/src/indexer/storeCache/storeCache.service.spec.ts b/packages/node-core/src/indexer/storeModelProvider/storeCache.service.spec.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/storeCache.service.spec.ts rename to packages/node-core/src/indexer/storeModelProvider/storeCache.service.spec.ts diff --git a/packages/node-core/src/indexer/storeCache/storeCache.service.ts b/packages/node-core/src/indexer/storeModelProvider/storeCache.service.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/storeCache.service.ts rename to packages/node-core/src/indexer/storeModelProvider/storeCache.service.ts diff --git a/packages/node-core/src/indexer/storeCache/storeModel.service.ts b/packages/node-core/src/indexer/storeModelProvider/storeModel.service.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/storeModel.service.ts rename to packages/node-core/src/indexer/storeModelProvider/storeModel.service.ts diff --git a/packages/node-core/src/indexer/storeCache/types.ts b/packages/node-core/src/indexer/storeModelProvider/types.ts similarity index 100% rename from packages/node-core/src/indexer/storeCache/types.ts rename to packages/node-core/src/indexer/storeModelProvider/types.ts diff --git a/packages/node-core/src/indexer/test.runner.ts b/packages/node-core/src/indexer/test.runner.ts index 16eff11b22..1ac0492ccf 100644 --- a/packages/node-core/src/indexer/test.runner.ts +++ b/packages/node-core/src/indexer/test.runner.ts @@ -11,7 +11,7 @@ import {NodeConfig} from '../configure/NodeConfig'; import {getLogger} from '../logger'; import {TestSandbox} from './sandbox'; import {StoreService} from './store.service'; -import {isCachePolicy} from './storeCache'; +import {isCachePolicy} from './storeModelProvider'; import {IBlock, IIndexerManager} from './types'; const logger = getLogger('test-runner'); diff --git a/packages/node-core/src/indexer/unfinalizedBlocks.service.spec.ts b/packages/node-core/src/indexer/unfinalizedBlocks.service.spec.ts index c8848a67f3..a8fc670fe4 100644 --- a/packages/node-core/src/indexer/unfinalizedBlocks.service.spec.ts +++ b/packages/node-core/src/indexer/unfinalizedBlocks.service.spec.ts @@ -5,7 +5,7 @@ import {EventEmitter2} from '@nestjs/event-emitter'; import {SchedulerRegistry} from '@nestjs/schedule'; import {Header, IBlock} from '../indexer'; -import {StoreCacheService, CacheMetadataModel} from './storeCache'; +import {StoreCacheService, CacheMetadataModel} from './storeModelProvider'; import { METADATA_LAST_FINALIZED_PROCESSED_KEY, METADATA_UNFINALIZED_BLOCKS_KEY, diff --git a/packages/node-core/src/indexer/unfinalizedBlocks.service.ts b/packages/node-core/src/indexer/unfinalizedBlocks.service.ts index 3356cdfab3..51d20f3ecc 100644 --- a/packages/node-core/src/indexer/unfinalizedBlocks.service.ts +++ b/packages/node-core/src/indexer/unfinalizedBlocks.service.ts @@ -11,7 +11,7 @@ import {exitWithError} from '../process'; import {mainThreadOnly} from '../utils'; import {ProofOfIndex} from './entities'; import {PoiBlock} from './poi'; -import {IStoreModelProvider} from './storeCache'; +import {IStoreModelProvider} from './storeModelProvider'; const logger = getLogger('UnfinalizedBlocks');