Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 86aa4bd

Browse files
fix: deps, enable consistent-type-imports
1 parent d3cbbf5 commit 86aa4bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+938
-1024
lines changed

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// prettier-ignore
22
module.exports = [
33
...require('@naturalcycles/dev-lib/cfg/eslint.config'),
4+
{
5+
rules: {
6+
'@typescript-eslint/consistent-type-imports': 2,
7+
},
8+
},
49
]

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
},
1515
"devDependencies": {
1616
"@naturalcycles/bench-lib": "^3",
17-
"@naturalcycles/dev-lib": "^16",
17+
"@naturalcycles/dev-lib": "^17",
1818
"@types/node": "^22",
1919
"@vitest/coverage-v8": "^3",
20+
"tsx": "^4",
2021
"vitest": "^3"
2122
},
2223
"files": [

scripts/cannon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
3-
yarn tsn cannon
3+
yarn tsx scripts/cannon.ts
44
55
*/
66

scripts/ndjsonTest.script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
3-
DEBUG=nc* yarn tsn ndjsonTest.script.ts
3+
yarn tsx scripts/ndjsonTest.script.ts
44
55
*/
66

scripts/vitest.script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
3-
yarn tsn vitest.script.ts
3+
yarn tsx scripts/vitest.script.ts
44
55
*/
66

src/adapter/cachedb/cache.db.model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2-
import { CommonDB } from '../../common.db'
3-
import {
1+
import type { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2+
import type { CommonDB } from '../../common.db'
3+
import type {
44
CommonDBCreateOptions,
55
CommonDBOptions,
66
CommonDBSaveOptions,

src/adapter/cachedb/cache.db.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { Readable } from 'node:stream'
2-
import {
3-
_isTruthy,
2+
import type {
43
JsonSchemaObject,
54
JsonSchemaRootObject,
65
ObjectWithId,
76
StringMap,
87
} from '@naturalcycles/js-lib'
9-
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
8+
import { _isTruthy } from '@naturalcycles/js-lib'
9+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
1010
import { BaseCommonDB } from '../../base.common.db'
11-
import { CommonDB, commonDBFullSupport, CommonDBSupport } from '../../common.db'
12-
import { RunQueryResult } from '../../db.model'
13-
import { DBQuery } from '../../query/dbQuery'
14-
import {
11+
import type { CommonDB, CommonDBSupport } from '../../common.db'
12+
import { commonDBFullSupport } from '../../common.db'
13+
import type { RunQueryResult } from '../../db.model'
14+
import type { DBQuery } from '../../query/dbQuery'
15+
import type {
1516
CacheDBCfg,
1617
CacheDBCreateOptions,
1718
CacheDBOptions,

src/adapter/cachedb/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CacheDB } from './cache.db'
2-
import {
2+
import type {
33
CacheDBCfg,
44
CacheDBCreateOptions,
55
CacheDBOptions,

src/adapter/file/file.db.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2-
import { DBSaveBatchOperation } from '../../db.model'
1+
import type { CommonLogger, ObjectWithId } from '@naturalcycles/js-lib'
2+
import type { DBSaveBatchOperation } from '../../db.model'
33
import type { DBQueryOrder } from '../../query/dbQuery'
44

55
export interface FileDBPersistencePlugin {

src/adapter/file/file.db.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { JsonSchemaRootObject, ObjectWithId, UnixTimestampMillis } from '@naturalcycles/js-lib'
12
import {
23
_assert,
34
_by,
@@ -8,28 +9,21 @@ import {
89
_sortObjectDeep,
910
_stringMapValues,
1011
generateJsonSchemaFromData,
11-
JsonSchemaRootObject,
1212
localTime,
13-
ObjectWithId,
14-
UnixTimestampMillis,
1513
} from '@naturalcycles/js-lib'
16-
import { dimGrey, readableCreate, ReadableTyped } from '@naturalcycles/nodejs-lib'
17-
import {
18-
BaseCommonDB,
19-
commonDBFullSupport,
20-
CommonDBSupport,
21-
DBSaveBatchOperation,
22-
queryInMemory,
23-
} from '../..'
24-
import { CommonDB } from '../../common.db'
25-
import {
14+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
15+
import { dimGrey, readableCreate } from '@naturalcycles/nodejs-lib'
16+
import type { CommonDBSupport, DBSaveBatchOperation } from '../..'
17+
import { BaseCommonDB, commonDBFullSupport, queryInMemory } from '../..'
18+
import type { CommonDB } from '../../common.db'
19+
import type {
2620
CommonDBOptions,
2721
CommonDBSaveOptions,
2822
CommonDBStreamOptions,
2923
RunQueryResult,
3024
} from '../../db.model'
31-
import { DBQuery } from '../../query/dbQuery'
32-
import { FileDBCfg } from './file.db.model'
25+
import type { DBQuery } from '../../query/dbQuery'
26+
import type { FileDBCfg } from './file.db.model'
3327

3428
/**
3529
* Provides barebone implementation for "whole file" based CommonDB.

src/adapter/file/inMemory.persistence.plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { _by, ObjectWithId, StringMap } from '@naturalcycles/js-lib'
2-
import { DBSaveBatchOperation } from '../../db.model'
3-
import { FileDBPersistencePlugin } from './file.db.model'
1+
import type { ObjectWithId, StringMap } from '@naturalcycles/js-lib'
2+
import { _by } from '@naturalcycles/js-lib'
3+
import type { DBSaveBatchOperation } from '../../db.model'
4+
import type { FileDBPersistencePlugin } from './file.db.model'
45

56
/**
67
* Mostly useful for testing.

src/adapter/file/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FileDB } from './file.db'
2-
import { FileDBCfg, FileDBPersistencePlugin } from './file.db.model'
2+
import type { FileDBCfg, FileDBPersistencePlugin } from './file.db.model'
33
import { LocalFilePersistencePlugin } from './localFile.persistence.plugin'
44

55
export type { FileDBCfg, FileDBPersistencePlugin }

src/adapter/file/localFile.persistence.plugin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Readable } from 'node:stream'
2-
import { ObjectWithId, pMap } from '@naturalcycles/js-lib'
2+
import type { ObjectWithId } from '@naturalcycles/js-lib'
3+
import { pMap } from '@naturalcycles/js-lib'
34
import { _pipeline, fs2 } from '@naturalcycles/nodejs-lib'
4-
import { DBSaveBatchOperation } from '../../db.model'
5-
import { FileDBPersistencePlugin } from './file.db.model'
5+
import type { DBSaveBatchOperation } from '../../db.model'
6+
import type { FileDBPersistencePlugin } from './file.db.model'
67

78
export interface LocalFilePersistencePluginCfg {
89
/**

src/adapter/file/noop.persistence.plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ObjectWithId } from '@naturalcycles/js-lib'
2-
import { DBSaveBatchOperation } from '../../db.model'
3-
import { FileDBPersistencePlugin } from './file.db.model'
1+
import type { ObjectWithId } from '@naturalcycles/js-lib'
2+
import type { DBSaveBatchOperation } from '../../db.model'
3+
import type { FileDBPersistencePlugin } from './file.db.model'
44

55
export class NoopPersistencePlugin implements FileDBPersistencePlugin {
66
async ping(): Promise<void> {}

src/adapter/inmemory/inMemory.db.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { Readable } from 'node:stream'
2+
import type {
3+
AnyObjectWithId,
4+
CommonLogger,
5+
JsonSchemaObject,
6+
JsonSchemaRootObject,
7+
ObjectWithId,
8+
StringMap,
9+
} from '@naturalcycles/js-lib'
210
import {
311
_assert,
412
_by,
@@ -8,42 +16,28 @@ import {
816
_sortObjectDeep,
917
_stringMapEntries,
1018
_stringMapValues,
11-
AnyObjectWithId,
12-
CommonLogger,
1319
generateJsonSchemaFromData,
14-
JsonSchemaObject,
15-
JsonSchemaRootObject,
1620
localTime,
17-
ObjectWithId,
1821
pMap,
19-
StringMap,
2022
} from '@naturalcycles/js-lib'
21-
import {
22-
_pipeline,
23-
bufferReviver,
24-
dimGrey,
25-
fs2,
26-
ReadableTyped,
27-
yellow,
28-
} from '@naturalcycles/nodejs-lib'
29-
import {
23+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
24+
import { _pipeline, bufferReviver, dimGrey, fs2, yellow } from '@naturalcycles/nodejs-lib'
25+
import type {
3026
CommonDB,
31-
commonDBFullSupport,
3227
CommonDBSupport,
3328
CommonDBTransactionOptions,
34-
CommonDBType,
3529
DBOperation,
3630
DBTransactionFn,
37-
queryInMemory,
3831
} from '../..'
39-
import {
32+
import { commonDBFullSupport, CommonDBType, queryInMemory } from '../..'
33+
import type {
4034
CommonDBCreateOptions,
4135
CommonDBOptions,
4236
CommonDBSaveOptions,
4337
DBTransaction,
4438
RunQueryResult,
4539
} from '../../db.model'
46-
import { DBQuery } from '../../query/dbQuery'
40+
import type { DBQuery } from '../../query/dbQuery'
4741

4842
export interface InMemoryDBCfg {
4943
/**

src/adapter/inmemory/inMemoryKeyValueDB.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { Readable } from 'node:stream'
2-
import { StringMap } from '@naturalcycles/js-lib'
3-
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
4-
import { CommonDBCreateOptions } from '../../db.model'
5-
import {
6-
CommonKeyValueDB,
7-
commonKeyValueDBFullSupport,
8-
IncrementTuple,
9-
KeyValueDBTuple,
10-
} from '../../kv/commonKeyValueDB'
2+
import type { StringMap } from '@naturalcycles/js-lib'
3+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
4+
import type { CommonDBCreateOptions } from '../../db.model'
5+
import type { CommonKeyValueDB, IncrementTuple, KeyValueDBTuple } from '../../kv/commonKeyValueDB'
6+
import { commonKeyValueDBFullSupport } from '../../kv/commonKeyValueDB'
117

128
export interface InMemoryKeyValueDBCfg {}
139

src/adapter/inmemory/queryInMemory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { _get, _pick, ObjectWithId } from '@naturalcycles/js-lib'
2-
import { DBQuery, DBQueryFilterOperator } from '../../query/dbQuery'
1+
import type { ObjectWithId } from '@naturalcycles/js-lib'
2+
import { _get, _pick } from '@naturalcycles/js-lib'
3+
import type { DBQuery, DBQueryFilterOperator } from '../../query/dbQuery'
34

45
type FilterFn = (v: any, val: any) => boolean
56
const FILTER_FNS: Record<DBQueryFilterOperator, FilterFn> = {

src/base.common.db.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import {
1+
import type {
22
JsonSchemaObject,
33
JsonSchemaRootObject,
44
ObjectWithId,
55
StringMap,
66
} from '@naturalcycles/js-lib'
7-
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
8-
import { CommonDB, CommonDBSupport, CommonDBType } from './common.db'
9-
import {
7+
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
8+
import type { CommonDB, CommonDBSupport } from './common.db'
9+
import { CommonDBType } from './common.db'
10+
import type {
1011
CommonDBOptions,
1112
CommonDBSaveOptions,
1213
CommonDBTransactionOptions,
1314
DBTransactionFn,
1415
RunQueryResult,
1516
} from './db.model'
16-
import { DBQuery } from './query/dbQuery'
17+
import type { DBQuery } from './query/dbQuery'
1718
import { FakeDBTransaction } from './transaction/dbTransaction.util'
1819

1920
/**

src/common.db.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {
1+
import type {
22
JsonSchemaObject,
33
JsonSchemaRootObject,
44
ObjectWithId,
55
StringMap,
66
} from '@naturalcycles/js-lib'
77
import type { ReadableTyped } from '@naturalcycles/nodejs-lib'
8-
import {
8+
import type {
99
CommonDBCreateOptions,
1010
CommonDBOptions,
1111
CommonDBReadOptions,
@@ -15,7 +15,7 @@ import {
1515
DBTransactionFn,
1616
RunQueryResult,
1717
} from './db.model'
18-
import { DBQuery } from './query/dbQuery'
18+
import type { DBQuery } from './query/dbQuery'
1919

2020
export enum CommonDBType {
2121
'document' = 'document',

src/commondao/common.dao.model.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import {
1+
import type {
22
BaseDBEntity,
33
CommonLogger,
44
ErrorMode,
55
NumberOfMilliseconds,
66
Promisable,
77
UnixTimestamp,
8-
ZodError,
9-
ZodSchema,
108
} from '@naturalcycles/js-lib'
11-
import {
9+
import type { ZodError, ZodSchema } from '@naturalcycles/js-lib/dist/zod/index.js'
10+
import type {
1211
AjvSchema,
1312
AjvValidationError,
1413
JoiValidationError,
1514
ObjectSchema,
1615
TransformLogProgressOptions,
1716
TransformMapOptions,
1817
} from '@naturalcycles/nodejs-lib'
19-
import { CommonDB } from '../common.db'
20-
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
18+
import type { CommonDB } from '../common.db'
19+
import type { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
2120

2221
export interface CommonDaoHooks<BM extends BaseDBEntity, DBM extends BaseDBEntity, ID = BM['id']> {
2322
/**

src/commondao/common.dao.test.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { MOCK_TS_2018_06_21, mockTime } from '@naturalcycles/dev-lib/dist/testing'
2+
import type { BaseDBEntity, UnixTimestamp } from '@naturalcycles/js-lib'
23
import {
34
_deepFreeze,
45
_omit,
56
_range,
67
_sortBy,
7-
BaseDBEntity,
88
ErrorMode,
99
pExpectedError,
1010
pExpectedErrorString,
1111
pTry,
12-
UnixTimestamp,
1312
} from '@naturalcycles/js-lib'
1413
import {
1514
AjvSchema,
@@ -20,22 +19,17 @@ import {
2019
import { beforeEach, describe, expect, test, vi } from 'vitest'
2120
import { InMemoryDB } from '../adapter/inmemory/inMemory.db'
2221
import { DBLibError } from '../cnst'
22+
import type { TestItemBM, TestItemDBM } from '../testing'
2323
import {
2424
createTestItemBM,
2525
createTestItemsBM,
2626
TEST_TABLE,
27-
TestItemBM,
2827
testItemBMJsonSchema,
2928
testItemBMSchema,
30-
TestItemDBM,
3129
} from '../testing'
3230
import { CommonDao } from './common.dao'
33-
import {
34-
CommonDaoCfg,
35-
CommonDaoLogLevel,
36-
CommonDaoOptions,
37-
CommonDaoSaveBatchOptions,
38-
} from './common.dao.model'
31+
import type { CommonDaoCfg, CommonDaoOptions, CommonDaoSaveBatchOptions } from './common.dao.model'
32+
import { CommonDaoLogLevel } from './common.dao.model'
3933

4034
let throwError = false
4135

0 commit comments

Comments
 (0)