Skip to content

Commit

Permalink
Modular core type (#2462)
Browse files Browse the repository at this point in the history
* generic network module types

* export alias

* common changelog

* Update packages/types-core/src/project/modulars/types.ts

Co-authored-by: Scott Twiname <[email protected]>

* fix ds type

* apply export type check

---------

Co-authored-by: Scott Twiname <[email protected]>
  • Loading branch information
jiqiang90 and stwiname authored Jun 23, 2024
1 parent 9af0971 commit 3c4dd4b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/common-substrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Add alias `parseProjectManifest`, also follow type of `INetworkCommonModule` (#2462)

## [3.8.1] - 2024-06-21
### Fixed
- Fix `EventFilter` incorrectly extend `BlockFilter`, lead dictionary error (#2463)
Expand Down
10 changes: 10 additions & 0 deletions packages/common-substrate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
// SPDX-License-Identifier: GPL-3.0

export * from './project';

import {SubstrateCustomDatasource, SubstrateDatasource, SubstrateRuntimeDatasource} from '@subql/types';
import {INetworkCommonModule} from '@subql/types-core';
import * as p from './project';

// This provides a compiled time check to ensure that the correct exports are provided
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _ = {
...p,
} satisfies INetworkCommonModule<SubstrateDatasource, SubstrateRuntimeDatasource, SubstrateCustomDatasource>;
3 changes: 3 additions & 0 deletions packages/common-substrate/src/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ export * from './models';
export * from './types';
export * from './utils';
export * from './versioned';

import {parseSubstrateProjectManifest} from './load';
export {parseSubstrateProjectManifest as parseProjectManifest};
3 changes: 3 additions & 0 deletions packages/types-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Add generic network module types (#2462)

## [0.8.0] - 2024-06-21
### Changed
- Reader interface not returning undefined
Expand Down
1 change: 1 addition & 0 deletions packages/types-core/src/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './types';
export * from './versioned';
export * from './readers';
export * from './datasourceProcessors';
export * from './modulars';
4 changes: 4 additions & 0 deletions packages/types-core/src/project/modulars/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

export * from './types';
14 changes: 14 additions & 0 deletions packages/types-core/src/project/modulars/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {BaseCustomDataSource, BaseDataSource, IProjectManifest} from '../index';

export interface INetworkCommonModule<
D extends BaseCustomDataSource | BaseDataSource = BaseDataSource,
RDS extends D = D,
CDS extends D = D,
> {
parseProjectManifest(raw: unknown): IProjectManifest<D>;
isRuntimeDs(ds: D): ds is RDS;
isCustomDs(ds: D): ds is CDS;
}

0 comments on commit 3c4dd4b

Please sign in to comment.