From 5b1e5785703da215391e942d52e8e87fc3f1b671 Mon Sep 17 00:00:00 2001 From: Jay Ji Date: Mon, 29 Aug 2022 11:29:26 +1200 Subject: [PATCH] fix node-core import in node (#1272) --- packages/node/src/app.module.ts | 2 +- packages/node/src/configure/configure.module.ts | 10 ++++++++-- packages/node/src/indexer/api.service.test.ts | 2 +- packages/node/src/indexer/api.service.ts | 7 +++++-- packages/node/src/indexer/dynamic-ds.service.ts | 3 +-- packages/node/src/indexer/fetch.module.ts | 6 +++--- packages/node/src/indexer/fetch.service.spec.ts | 3 +-- packages/node/src/indexer/fetch.service.test.ts | 2 +- packages/node/src/indexer/fetch.service.ts | 13 +++++++++---- packages/node/src/indexer/indexer.manager.spec.ts | 10 +++++++--- packages/node/src/indexer/indexer.manager.ts | 8 +++++--- packages/node/src/indexer/indexer.module.ts | 5 ++--- packages/node/src/indexer/project.service.test.ts | 4 +--- packages/node/src/indexer/project.service.ts | 15 +++++++++------ packages/node/src/indexer/sandbox.service.spec.ts | 2 +- packages/node/src/indexer/sandbox.service.ts | 11 +++++++---- .../indexer/worker/block-dispatcher.service.ts | 14 +++++++++----- packages/node/src/indexer/worker/worker.module.ts | 2 +- .../node/src/indexer/worker/worker.service.ts | 3 +-- packages/node/src/indexer/worker/worker.ts | 3 +-- packages/node/src/meta/meta.module.ts | 2 +- packages/node/src/meta/meta.service.ts | 4 ++-- 22 files changed, 77 insertions(+), 54 deletions(-) diff --git a/packages/node/src/app.module.ts b/packages/node/src/app.module.ts index edee9e3e52..8bdcb17ae2 100644 --- a/packages/node/src/app.module.ts +++ b/packages/node/src/app.module.ts @@ -4,7 +4,7 @@ import { Module } from '@nestjs/common'; import { EventEmitterModule } from '@nestjs/event-emitter'; import { ScheduleModule } from '@nestjs/schedule'; -import { DbModule } from '@subql/node-core/db'; +import { DbModule } from '@subql/node-core'; import { ConfigureModule } from './configure/configure.module'; import { FetchModule } from './indexer/fetch.module'; import { MetaModule } from './meta/meta.module'; diff --git a/packages/node/src/configure/configure.module.ts b/packages/node/src/configure/configure.module.ts index a6d71fce27..551803c22c 100644 --- a/packages/node/src/configure/configure.module.ts +++ b/packages/node/src/configure/configure.module.ts @@ -6,8 +6,14 @@ import path from 'path'; import { DynamicModule, Global, Module } from '@nestjs/common'; import { getProjectRootAndManifest, IPFS_REGEX } from '@subql/common'; import { SubstrateProjectNetworkConfig } from '@subql/common-substrate'; -import { getYargsOption, getLogger, setLevel } from '@subql/node-core'; -import { IConfig, MinConfig, NodeConfig } from '@subql/node-core/configure'; +import { + IConfig, + MinConfig, + NodeConfig, + getYargsOption, + getLogger, + setLevel, +} from '@subql/node-core'; import { camelCase, last, omitBy, isNil } from 'lodash'; import { SubqueryProject } from './SubqueryProject'; const logger = getLogger('configure'); diff --git a/packages/node/src/indexer/api.service.test.ts b/packages/node/src/indexer/api.service.test.ts index f4dc7aac72..aa65827526 100644 --- a/packages/node/src/indexer/api.service.test.ts +++ b/packages/node/src/indexer/api.service.test.ts @@ -5,7 +5,7 @@ import { INestApplication } from '@nestjs/common'; import { EventEmitterModule } from '@nestjs/event-emitter'; import { Test } from '@nestjs/testing'; import { BlockHash, RuntimeVersion } from '@polkadot/types/interfaces'; -import { delay } from '@subql/node-core/utils'; +import { delay } from '@subql/node-core'; import { SubstrateBlock } from '@subql/types'; import { GraphQLSchema } from 'graphql'; import { SubqueryProject } from '../configure/SubqueryProject'; diff --git a/packages/node/src/indexer/api.service.ts b/packages/node/src/indexer/api.service.ts index 6c04385947..ab772344c0 100644 --- a/packages/node/src/indexer/api.service.ts +++ b/packages/node/src/indexer/api.service.ts @@ -7,8 +7,11 @@ import { ApiPromise, WsProvider } from '@polkadot/api'; import { ApiOptions, RpcMethodResult } from '@polkadot/api/types'; import { RuntimeVersion } from '@polkadot/types/interfaces'; import { AnyFunction, DefinitionRpcExt } from '@polkadot/types/types'; -import { getLogger } from '@subql/node-core'; -import { IndexerEvent, NetworkMetadataPayload } from '@subql/node-core/events'; +import { + IndexerEvent, + NetworkMetadataPayload, + getLogger, +} from '@subql/node-core'; import { SubstrateBlock } from '@subql/types'; import { SubqueryProject } from '../configure/SubqueryProject'; import { ApiAt } from './types'; diff --git a/packages/node/src/indexer/dynamic-ds.service.ts b/packages/node/src/indexer/dynamic-ds.service.ts index 14fafc906d..2e5f74741b 100644 --- a/packages/node/src/indexer/dynamic-ds.service.ts +++ b/packages/node/src/indexer/dynamic-ds.service.ts @@ -4,8 +4,7 @@ import assert from 'assert'; import { Injectable } from '@nestjs/common'; import { isCustomDs, isRuntimeDs } from '@subql/common-substrate'; -import { getLogger } from '@subql/node-core'; -import { MetadataRepo } from '@subql/node-core/indexer/entities'; +import { getLogger, MetadataRepo } from '@subql/node-core'; import { Transaction } from 'sequelize/types'; import { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject'; import { DsProcessorService } from './ds-processor.service'; diff --git a/packages/node/src/indexer/fetch.module.ts b/packages/node/src/indexer/fetch.module.ts index 5f3078963d..4499928020 100644 --- a/packages/node/src/indexer/fetch.module.ts +++ b/packages/node/src/indexer/fetch.module.ts @@ -2,14 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 import { Module } from '@nestjs/common'; -import { DbModule } from '@subql/node-core/db'; import { BenchmarkService, MmrService, StoreService, PoiService, -} from '@subql/node-core/indexer'; -import { getYargsOption } from '@subql/node-core/yargs'; + getYargsOption, + DbModule, +} from '@subql/node-core'; import { ApiService } from './api.service'; import { DictionaryService } from './dictionary.service'; import { DsProcessorService } from './ds-processor.service'; diff --git a/packages/node/src/indexer/fetch.service.spec.ts b/packages/node/src/indexer/fetch.service.spec.ts index 91c55be18a..765a5ee7c1 100644 --- a/packages/node/src/indexer/fetch.service.spec.ts +++ b/packages/node/src/indexer/fetch.service.spec.ts @@ -10,8 +10,7 @@ import { SubstrateDatasourceKind, SubstrateHandlerKind, } from '@subql/common-substrate'; -import { NodeConfig } from '@subql/node-core/configure'; -import { IndexerEvent } from '@subql/node-core/events'; +import { IndexerEvent, NodeConfig } from '@subql/node-core'; import { GraphQLSchema } from 'graphql'; import { SubqueryProject } from '../configure/SubqueryProject'; import { calcInterval, fetchBlocksBatches } from '../utils/substrate'; diff --git a/packages/node/src/indexer/fetch.service.test.ts b/packages/node/src/indexer/fetch.service.test.ts index 45f10f480b..b900a30574 100644 --- a/packages/node/src/indexer/fetch.service.test.ts +++ b/packages/node/src/indexer/fetch.service.test.ts @@ -12,7 +12,7 @@ import { SubstrateDatasourceKind, SubstrateHandlerKind, } from '@subql/common-substrate'; -import { NodeConfig } from '@subql/node-core/configure'; +import { NodeConfig } from '@subql/node-core'; import { GraphQLSchema } from 'graphql'; import { SubqueryProject } from '../configure/SubqueryProject'; import * as SubstrateUtil from '../utils/substrate'; diff --git a/packages/node/src/indexer/fetch.service.ts b/packages/node/src/indexer/fetch.service.ts index 009ef15157..8620c64c35 100644 --- a/packages/node/src/indexer/fetch.service.ts +++ b/packages/node/src/indexer/fetch.service.ts @@ -21,10 +21,15 @@ import { SubstrateRuntimeHandlerFilter, SubstrateBlockFilter, } from '@subql/common-substrate'; -import { getYargsOption, getLogger, profiler } from '@subql/node-core'; -import { NodeConfig } from '@subql/node-core/configure'; -import { IndexerEvent } from '@subql/node-core/events'; -import { delay, checkMemoryUsage } from '@subql/node-core/utils'; +import { + delay, + checkMemoryUsage, + NodeConfig, + IndexerEvent, + getYargsOption, + getLogger, + profiler, +} from '@subql/node-core'; import { DictionaryQueryEntry, SubstrateBlock, diff --git a/packages/node/src/indexer/indexer.manager.spec.ts b/packages/node/src/indexer/indexer.manager.spec.ts index 0cdff31c91..f997d3efd6 100644 --- a/packages/node/src/indexer/indexer.manager.spec.ts +++ b/packages/node/src/indexer/indexer.manager.spec.ts @@ -6,9 +6,13 @@ import { SubstrateDatasourceKind, SubstrateHandlerKind, } from '@subql/common-substrate'; -import { NodeConfig } from '@subql/node-core/configure'; -import { SubqueryFactory } from '@subql/node-core/entities'; -import { StoreService, PoiService, MmrService } from '@subql/node-core/indexer'; +import { + StoreService, + PoiService, + MmrService, + SubqueryFactory, + NodeConfig, +} from '@subql/node-core'; import { GraphQLSchema } from 'graphql'; import { Sequelize } from 'sequelize'; import { SubqueryProject } from '../configure/SubqueryProject'; diff --git a/packages/node/src/indexer/indexer.manager.ts b/packages/node/src/indexer/indexer.manager.ts index 8fc7607ce5..87b8d3f62f 100644 --- a/packages/node/src/indexer/indexer.manager.ts +++ b/packages/node/src/indexer/indexer.manager.ts @@ -18,14 +18,16 @@ import { SubstrateRuntimeHandlerInputMap, } from '@subql/common-substrate'; import { + PoiBlock, + StoreService, + PoiService, + SubqueryRepo, + NodeConfig, getYargsOption, getLogger, profiler, profilerWrap, } from '@subql/node-core'; -import { NodeConfig } from '@subql/node-core/configure'; -import { SubqueryRepo } from '@subql/node-core/entities'; -import { PoiBlock, StoreService, PoiService } from '@subql/node-core/indexer'; import { SubstrateBlock, SubstrateEvent, diff --git a/packages/node/src/indexer/indexer.module.ts b/packages/node/src/indexer/indexer.module.ts index 4b97dbd463..9c5157e6cc 100644 --- a/packages/node/src/indexer/indexer.module.ts +++ b/packages/node/src/indexer/indexer.module.ts @@ -3,13 +3,12 @@ import { Module } from '@nestjs/common'; import { EventEmitter2 } from '@nestjs/event-emitter'; -import { DbModule } from '@subql/node-core/db'; import { - BenchmarkService, + DbModule, StoreService, PoiService, MmrService, -} from '@subql/node-core/indexer'; +} from '@subql/node-core'; import { SubqueryProject } from '../configure/SubqueryProject'; import { ApiService } from './api.service'; import { DictionaryService } from './dictionary.service'; diff --git a/packages/node/src/indexer/project.service.test.ts b/packages/node/src/indexer/project.service.test.ts index 357431fd26..157ea594a1 100644 --- a/packages/node/src/indexer/project.service.test.ts +++ b/packages/node/src/indexer/project.service.test.ts @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { Test } from '@nestjs/testing'; -import { NodeConfig } from '@subql/node-core/configure'; -import { DbModule } from '@subql/node-core/db'; -import { SubqueryRepo } from '@subql/node-core/entities'; +import { SubqueryRepo, DbModule, NodeConfig } from '@subql/node-core'; import { GraphQLSchema } from 'graphql'; import { Sequelize } from 'sequelize'; import { SubqueryProject } from '../configure/SubqueryProject'; diff --git a/packages/node/src/indexer/project.service.ts b/packages/node/src/indexer/project.service.ts index d4504683b0..40615d420c 100644 --- a/packages/node/src/indexer/project.service.ts +++ b/packages/node/src/indexer/project.service.ts @@ -6,15 +6,18 @@ import fs from 'fs'; import { isMainThread } from 'worker_threads'; import { Inject, Injectable } from '@nestjs/common'; import { EventEmitter2 } from '@nestjs/event-emitter'; -import { getYargsOption, getLogger } from '@subql/node-core'; -import { NodeConfig } from '@subql/node-core/configure'; -import { SubqueryRepo } from '@subql/node-core/entities'; -import { IndexerEvent } from '@subql/node-core/events'; -import { StoreService, PoiService, MmrService } from '@subql/node-core/indexer'; import { MetadataFactory, MetadataRepo, -} from '@subql/node-core/indexer/entities'; + SubqueryRepo, + NodeConfig, + IndexerEvent, + StoreService, + PoiService, + MmrService, + getYargsOption, + getLogger, +} from '@subql/node-core'; import { getAllEntitiesRelations } from '@subql/utils'; import { QueryTypes, Sequelize } from 'sequelize'; import { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject'; diff --git a/packages/node/src/indexer/sandbox.service.spec.ts b/packages/node/src/indexer/sandbox.service.spec.ts index 7205116dcf..652f9169df 100644 --- a/packages/node/src/indexer/sandbox.service.spec.ts +++ b/packages/node/src/indexer/sandbox.service.spec.ts @@ -3,7 +3,7 @@ import fs from 'fs'; import * as path from 'path'; -import { NodeConfig } from '@subql/node-core/configure'; +import { NodeConfig } from '@subql/node-core'; import { IndexerSandbox } from './sandbox.service'; describe('sandbox for subql-node', () => { diff --git a/packages/node/src/indexer/sandbox.service.ts b/packages/node/src/indexer/sandbox.service.ts index 05486ae798..4e870ce6cf 100644 --- a/packages/node/src/indexer/sandbox.service.ts +++ b/packages/node/src/indexer/sandbox.service.ts @@ -7,10 +7,13 @@ import { isDatasourceV0_2_0, SubstrateDataSource, } from '@subql/common-substrate'; -import { getYargsOption, getLogger } from '@subql/node-core'; -import { NodeConfig } from '@subql/node-core/configure'; -import { StoreService } from '@subql/node-core/indexer'; -import { timeout } from '@subql/node-core/utils'; +import { + timeout, + NodeConfig, + StoreService, + getYargsOption, + getLogger, +} from '@subql/node-core'; import { Store } from '@subql/types'; import { levelFilter } from '@subql/utils'; import { merge } from 'lodash'; diff --git a/packages/node/src/indexer/worker/block-dispatcher.service.ts b/packages/node/src/indexer/worker/block-dispatcher.service.ts index 4de8dbe819..ec7462665f 100644 --- a/packages/node/src/indexer/worker/block-dispatcher.service.ts +++ b/packages/node/src/indexer/worker/block-dispatcher.service.ts @@ -8,11 +8,15 @@ import { EventEmitter2 } from '@nestjs/event-emitter'; import { Interval } from '@nestjs/schedule'; import { RuntimeVersion } from '@polkadot/types/interfaces'; import { hexToU8a, u8aEq } from '@polkadot/util'; -import { delay, getYargsOption, profilerWrap } from '@subql/node-core'; -import { NodeConfig } from '@subql/node-core/configure'; -import { IndexerEvent } from '@subql/node-core/events'; -import { Worker } from '@subql/node-core/indexer'; -import { getLogger } from '@subql/node-core/logger'; +import { + getLogger, + NodeConfig, + IndexerEvent, + Worker, + delay, + getYargsOption, + profilerWrap, +} from '@subql/node-core'; import { SubstrateBlock } from '@subql/types'; import chalk from 'chalk'; import { last } from 'lodash'; diff --git a/packages/node/src/indexer/worker/worker.module.ts b/packages/node/src/indexer/worker/worker.module.ts index cc5c6456f9..f2f0e681ff 100644 --- a/packages/node/src/indexer/worker/worker.module.ts +++ b/packages/node/src/indexer/worker/worker.module.ts @@ -4,7 +4,7 @@ import { Module } from '@nestjs/common'; import { EventEmitterModule } from '@nestjs/event-emitter'; import { ScheduleModule } from '@nestjs/schedule'; -import { DbModule } from '@subql/node-core/db'; +import { DbModule } from '@subql/node-core'; import { ConfigureModule } from '../../configure/configure.module'; import { IndexerModule } from '../indexer.module'; diff --git a/packages/node/src/indexer/worker/worker.service.ts b/packages/node/src/indexer/worker/worker.service.ts index d3a8718420..64edfe8aa5 100644 --- a/packages/node/src/indexer/worker/worker.service.ts +++ b/packages/node/src/indexer/worker/worker.service.ts @@ -4,8 +4,7 @@ import { threadId } from 'node:worker_threads'; import { Injectable } from '@nestjs/common'; import { RuntimeVersion } from '@polkadot/types/interfaces'; -import { NodeConfig } from '@subql/node-core/configure'; -import { getLogger } from '@subql/node-core/logger'; +import { NodeConfig, getLogger } from '@subql/node-core'; import { AutoQueue } from '../../utils/autoQueue'; import { fetchBlocksBatches } from '../../utils/substrate'; import { ApiService } from '../api.service'; diff --git a/packages/node/src/indexer/worker/worker.ts b/packages/node/src/indexer/worker/worker.ts index 0a651420b0..bb588b998d 100644 --- a/packages/node/src/indexer/worker/worker.ts +++ b/packages/node/src/indexer/worker/worker.ts @@ -5,8 +5,7 @@ import assert from 'assert'; import { threadId } from 'node:worker_threads'; import { INestApplication } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; -import { registerWorker } from '@subql/node-core/indexer'; -import { getLogger, NestLogger } from '@subql/node-core/logger'; +import { registerWorker, getLogger, NestLogger } from '@subql/node-core'; import { IndexerManager } from '../indexer.manager'; import { WorkerModule } from './worker.module'; import { diff --git a/packages/node/src/meta/meta.module.ts b/packages/node/src/meta/meta.module.ts index dbefe2810a..27fb68d903 100644 --- a/packages/node/src/meta/meta.module.ts +++ b/packages/node/src/meta/meta.module.ts @@ -9,7 +9,7 @@ import { HealthController, HealthService, MmrQueryController, -} from '@subql/node-core/meta'; +} from '@subql/node-core'; import { makeGaugeProvider, PrometheusModule, diff --git a/packages/node/src/meta/meta.service.ts b/packages/node/src/meta/meta.service.ts index ae75a38159..1a561dc58a 100644 --- a/packages/node/src/meta/meta.service.ts +++ b/packages/node/src/meta/meta.service.ts @@ -12,8 +12,8 @@ import { ProcessBlockPayload, ProcessedBlockCountPayload, TargetBlockPayload, -} from '@subql/node-core/events'; -import { StoreService } from '@subql/node-core/indexer'; + StoreService, +} from '@subql/node-core'; const UPDATE_HEIGHT_INTERVAL = 60000;