Skip to content

Commit dd0458c

Browse files
authored
chore: Enforce import types (#60)
1 parent 72efa22 commit dd0458c

40 files changed

+115
-80
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"require-await": "off",
2626
"@typescript-eslint/require-await": "error",
2727
"@typescript-eslint/naming-convention": "error",
28+
"import/no-cycle": "error",
29+
"import/no-self-import": "error",
30+
"@typescript-eslint/consistent-type-imports": "error",
2831
"import/order": [
2932
2,
3033
{

src/grpc/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { pluginV3 } from '@cloudquery/plugin-pb-javascript';
22
import grpc = require('@grpc/grpc-js');
33

4-
import { Plugin } from '../plugin/plugin.js';
4+
import type { Plugin } from '../plugin/plugin.js';
55
import { encodeTables, flattenTables } from '../schema/table.js';
66

77
export class MigrateTable extends pluginV3.cloudquery.plugin.v3.Sync.MessageMigrateTable {}

src/grpc/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { pluginV3, discovery1 } from '@cloudquery/plugin-pb-javascript';
22
import grpc = require('@grpc/grpc-js');
3-
import winston from 'winston';
3+
import type winston from 'winston';
44

5-
import { Plugin } from '../plugin/plugin.js';
5+
import type { Plugin } from '../plugin/plugin.js';
66

77
import { DiscoveryServer } from './discovery.js';
88
import { PluginServer } from './plugin.js';

src/memdb/delete-stale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeleteStale } from '../grpc/plugin.js';
1+
import type { DeleteStale } from '../grpc/plugin.js';
22

33
export type DeleteStaleFunction = (message: DeleteStale) => void;
44

src/memdb/memdb.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { default as Ajv } from 'ajv';
22

3-
import { Plugin, newPlugin, SyncOptions, TableOptions, NewClientFunction } from '../plugin/plugin.js';
3+
import type { Plugin, SyncOptions, TableOptions, NewClientFunction } from '../plugin/plugin.js';
4+
import { newPlugin } from '../plugin/plugin.js';
45
import { sync } from '../scheduler/scheduler.js';
5-
import { Table, filterTables } from '../schema/table.js';
6+
import type { Table } from '../schema/table.js';
7+
import { filterTables } from '../schema/table.js';
68

79
import { createDeleteStale } from './delete-stale.js';
810
import { createOverwrite } from './overwrite.js';

src/memdb/overwrite.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { StructRowProxy } from '@apache-arrow/esnext-esm';
1+
import type { StructRowProxy } from '@apache-arrow/esnext-esm';
22

3-
import { Table } from '../schema/table.js';
3+
import type { Table } from '../schema/table.js';
44

55
//eslint-disable-next-line @typescript-eslint/no-explicit-any
66
export type OverwriteFunction = (table: Table, primaryKeys: string[], record: StructRowProxy<any>) => void;

src/memdb/read.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReadStream, ReadRequest } from '../grpc/plugin.js';
1+
import type { ReadStream, ReadRequest } from '../grpc/plugin.js';
22
import { decodeTable } from '../schema/table.js';
33

44
//eslint-disable-next-line @typescript-eslint/no-explicit-any

src/memdb/write.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { WriteStream, WriteRequest } from '../grpc/plugin.js';
2-
import { Table, decodeTable, decodeRecord, getPrimaryKeys } from '../schema/table.js';
1+
import type { WriteStream, WriteRequest } from '../grpc/plugin.js';
2+
import type { Table } from '../schema/table.js';
3+
import { decodeTable, decodeRecord, getPrimaryKeys } from '../schema/table.js';
34

4-
import { DeleteStaleFunction } from './delete-stale.js';
5-
import { OverwriteFunction } from './overwrite.js';
5+
import type { DeleteStaleFunction } from './delete-stale.js';
6+
import type { OverwriteFunction } from './overwrite.js';
67

78
export const createWrite = (
89
//eslint-disable-next-line @typescript-eslint/no-explicit-any

src/plugin/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Logger } from 'winston';
1+
import type { Logger } from 'winston';
22

3-
import { SyncStream, ReadStream, WriteStream } from '../grpc/plugin.js';
4-
import { Table } from '../schema/table.js';
3+
import type { SyncStream, ReadStream, WriteStream } from '../grpc/plugin.js';
4+
import type { Table } from '../schema/table.js';
55

66
export type BackendOptions = {
77
tableName: string;

src/plugin/serve.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import test from 'ava';
22

33
import { newMemDBPlugin } from '../memdb/memdb.js';
44

5-
import { createServeCommand, ServeArguments } from './serve.js';
5+
import type { ServeArguments } from './serve.js';
6+
import { createServeCommand } from './serve.js';
67

78
const serve = createServeCommand(newMemDBPlugin()).exitProcess(false);
89

src/plugin/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { hideBin } from 'yargs/helpers';
44
import { startServer, Network } from '../grpc/server.js';
55
import { LogFormat, LogLevel, createLogger } from '../logger/logger.js';
66

7-
import { Plugin } from './plugin.js';
7+
import type { Plugin } from './plugin.js';
88

99
const TELEMETRY_LEVEL_CHOICES = ['none', 'errors', 'stats', 'all'] as const;
1010

src/scalar/bool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Bool as ArrowBool } from '@apache-arrow/esnext-esm';
22
import { boolean, isBooleanable } from 'boolean';
33

4-
import { Scalar } from './scalar.js';
4+
import type { Scalar } from './scalar.js';
55
import { isInvalid, NULL_VALUE } from './util.js';
66

77
export class Bool implements Scalar<boolean> {

src/scalar/date.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Date_ as ArrowDate, DateUnit } from '@apache-arrow/esnext-esm';
1+
import type { DataType, DateUnit } from '@apache-arrow/esnext-esm';
2+
import { Date_ as ArrowDate } from '@apache-arrow/esnext-esm';
23
import { DateTime } from 'luxon';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Date implements Scalar<DateTime> {

src/scalar/float32.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { DataType, Float32 as ArrowFloat32 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Float32 as ArrowFloat32 } from '@apache-arrow/esnext-esm';
23

3-
import { Scalar } from './scalar.js';
4+
import type { Scalar } from './scalar.js';
45
import { isInvalid, NULL_VALUE } from './util.js';
56

67
export class Float32 implements Scalar<number> {

src/scalar/float64.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { DataType, Float64 as ArrowFloat64 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Float64 as ArrowFloat64 } from '@apache-arrow/esnext-esm';
23

3-
import { Scalar } from './scalar.js';
4+
import type { Scalar } from './scalar.js';
45
import { isInvalid, NULL_VALUE } from './util.js';
56

67
export class Float64 implements Scalar<number> {

src/scalar/int16.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Int16 as ArrowInt16 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Int16 as ArrowInt16 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Int16 implements Scalar<bigint> {

src/scalar/int32.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Int32 as ArrowInt32 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Int32 as ArrowInt32 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Int32 implements Scalar<bigint> {

src/scalar/int64.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Int64 as ArrowInt64 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Int64 as ArrowInt64 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Int64 implements Scalar<bigint> {

src/scalar/json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Utf8 as ArrowString } from '@apache-arrow/esnext-esm';
22

3-
import { Nullable } from '../schema/types.js';
3+
import type { Nullable } from '../schema/types.js';
44

5-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
66
import { isInvalid, NULL_VALUE } from './util.js';
77

88
const validate = (value: string) => {

src/scalar/list.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { DataType, List as ArrowList } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { List as ArrowList } from '@apache-arrow/esnext-esm';
23

3-
import { Scalar } from './scalar.js';
4+
import type { Scalar } from './scalar.js';
45
import { isInvalid, NULL_VALUE } from './util.js';
56

67
type TVector<T extends Scalar<unknown>> = T[];

src/scalar/text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Utf8 as ArrowString } from '@apache-arrow/esnext-esm';
22

3-
import { Scalar } from './scalar.js';
3+
import type { Scalar } from './scalar.js';
44
import { isInvalid, NULL_VALUE } from './util.js';
55

66
export class Text implements Scalar<string> {

src/scalar/timestamp.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Timestamp as ArrowTimestamp, TimeUnit } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Timestamp as ArrowTimestamp, TimeUnit } from '@apache-arrow/esnext-esm';
23
import { DateTime } from 'luxon';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Timestamp implements Scalar<DateTime> {

src/scalar/uint16.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Uint16 as ArrowUint16 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Uint16 as ArrowUint16 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Uint16 implements Scalar<bigint> {

src/scalar/uint32.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Uint32 as ArrowUint32 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Uint32 as ArrowUint32 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Uint32 implements Scalar<bigint> {

src/scalar/uint64.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { DataType, Uint64 as ArrowUint64 } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Uint64 as ArrowUint64 } from '@apache-arrow/esnext-esm';
23
import { bigIntToNumber } from '@apache-arrow/esnext-esm/util/bigint.js';
34

4-
import { Scalar } from './scalar.js';
5+
import type { Scalar } from './scalar.js';
56
import { isInvalid, NULL_VALUE } from './util.js';
67

78
export class Uint64 implements Scalar<bigint> {

src/scalar/uuid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { FixedSizeBinary } from '@apache-arrow/esnext-esm';
22
import { parse, stringify } from 'uuid';
33

4-
import { Nullable } from '../schema/types.js';
4+
import type { Nullable } from '../schema/types.js';
55

6-
import { Scalar } from './scalar.js';
6+
import type { Scalar } from './scalar.js';
77
import { isInvalid, NULL_VALUE } from './util.js';
88

99
export class UUID implements Scalar<Nullable<Uint8Array>> {

src/scheduler/cqid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
33
import { v4 as uuidv4, v5 as uuidv5, NIL as NIL_UUID } from 'uuid';
44

55
import { cqIDColumn } from '../schema/meta.js';
6-
import { Resource } from '../schema/resource.js';
6+
import type { Resource } from '../schema/resource.js';
77
import { getPrimaryKeys } from '../schema/table.js';
88

99
export const setCQId = (resource: Resource, deterministicCQId: boolean, generator: () => string = uuidv4) => {

src/scheduler/scheduler.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import { Duplex } from 'node:stream';
22

33
import pMap from 'p-map';
44
import pTimeout from 'p-timeout';
5-
import { Logger } from 'winston';
5+
import type { Logger } from 'winston';
66

7-
import { SyncStream, SyncResponse, MigrateTable, Insert } from '../grpc/plugin.js';
8-
import { Column } from '../schema/column.js';
9-
import { ClientMeta } from '../schema/meta.js';
7+
import type { SyncStream } from '../grpc/plugin.js';
8+
import { SyncResponse, MigrateTable, Insert } from '../grpc/plugin.js';
9+
import type { Column } from '../schema/column.js';
10+
import type { ClientMeta } from '../schema/meta.js';
1011
import { Resource, encodeResource } from '../schema/resource.js';
11-
import { Table, encodeTable, flattenTables } from '../schema/table.js';
12-
import { Nullable } from '../schema/types.js';
12+
import type { Table } from '../schema/table.js';
13+
import { encodeTable, flattenTables } from '../schema/table.js';
14+
import type { Nullable } from '../schema/types.js';
1315

1416
import { setCQId } from './cqid.js';
1517

src/schema/column.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { isDeepStrictEqual } from 'node:util';
22

3-
import { DataType, Field, Utf8 } from '@apache-arrow/esnext-esm';
3+
import type { DataType } from '@apache-arrow/esnext-esm';
4+
import { Field, Utf8 } from '@apache-arrow/esnext-esm';
45

5-
import { ExtensionType, isExtensionType } from '../types/extensions.js';
6+
import type { ExtensionType } from '../types/extensions.js';
7+
import { isExtensionType } from '../types/extensions.js';
68

79
import * as arrow from './arrow.js';
8-
import { ClientMeta } from './meta.js';
9-
import { Resource } from './resource.js';
10+
import type { ClientMeta } from './meta.js';
11+
import type { Resource } from './resource.js';
1012

1113
export type ColumnResolver = (meta: ClientMeta, resource: Resource, c: Column) => Promise<void>;
1214

src/schema/meta.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { Utf8, TimeNanosecond } from '@apache-arrow/esnext-esm';
22

33
import { UUIDType } from '../types/uuid.js';
44

5-
import { Column, createColumn, ColumnResolver } from './column.js';
6-
import { Resource } from './resource.js';
7-
import { Table, getPrimaryKeys } from './table.js';
5+
import type { Column, ColumnResolver } from './column.js';
6+
import { createColumn } from './column.js';
7+
import type { Resource } from './resource.js';
8+
import type { Table } from './table.js';
9+
import { getPrimaryKeys } from './table.js';
810

911
export type ClientMeta = {
1012
id: () => string;

src/schema/resolvers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getProperty } from 'dot-prop';
22

3-
import { ColumnResolver } from './column.js';
3+
import type { ColumnResolver } from './column.js';
44

55
export const pathResolver = (path: string): ColumnResolver => {
66
return (_, resource, c) => {

src/schema/resource.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { tableToIPC, Table as ArrowTable, RecordBatch, vectorFromArray } from '@apache-arrow/esnext-esm';
22

3-
import { Scalar, Vector, newScalar } from '../scalar/scalar.js';
3+
import type { Scalar, Vector } from '../scalar/scalar.js';
4+
import { newScalar } from '../scalar/scalar.js';
45
import { isExtensionType } from '../types/extensions.js';
56

67
import { cqIDColumn } from './meta.js';
7-
import { Table, toArrowSchema } from './table.js';
8-
import { Nullable } from './types.js';
8+
import type { Table } from './table.js';
9+
import { toArrowSchema } from './table.js';
10+
import type { Nullable } from './types.js';
911

1012
export class Resource {
1113
item: unknown;

src/schema/table.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { Writable } from 'node:stream';
1+
import type { Writable } from 'node:stream';
22

3-
import { Table as ArrowTable, tableFromIPC, tableToIPC, Schema, RecordBatch } from '@apache-arrow/esnext-esm';
3+
import type { RecordBatch } from '@apache-arrow/esnext-esm';
4+
import { Table as ArrowTable, tableFromIPC, tableToIPC, Schema } from '@apache-arrow/esnext-esm';
45
import { isMatch } from 'matcher';
56

67
import * as arrow from './arrow.js';
7-
import { Column, fromArrowField, toArrowField } from './column.js';
8-
import { ClientMeta } from './meta.js';
9-
import { Resource } from './resource.js';
10-
import { Nullable } from './types.js';
8+
import type { Column } from './column.js';
9+
import { fromArrowField, toArrowField } from './column.js';
10+
import type { ClientMeta } from './meta.js';
11+
import type { Resource } from './resource.js';
12+
import type { Nullable } from './types.js';
1113

1214
export type TableResolver = (clientMeta: ClientMeta, parent: Nullable<Resource>, stream: Writable) => Promise<void>;
1315
export type RowResolver = (clientMeta: ClientMeta, resource: Resource) => Promise<void>;

src/transformers/openapi.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Utf8, Int64, Bool } from '@apache-arrow/esnext-esm';
22
import test from 'ava';
33

4-
import { Column, createColumn } from '../schema/column.js';
4+
import type { Column } from '../schema/column.js';
5+
import { createColumn } from '../schema/column.js';
56
import { JSONType } from '../types/json.js';
67

78
import { oapiDefinitionToColumns } from './openapi.js';

src/transformers/openapi.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { DataType, Utf8, Int64, Bool } from '@apache-arrow/esnext-esm';
1+
import type { DataType } from '@apache-arrow/esnext-esm';
2+
import { Utf8, Int64, Bool } from '@apache-arrow/esnext-esm';
23

3-
import { Column, createColumn } from '../schema/column.js';
4+
import type { Column } from '../schema/column.js';
5+
import { createColumn } from '../schema/column.js';
46
import { JSONType } from '../types/json.js';
57

68
interface OAPIProperty {

0 commit comments

Comments
 (0)