Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tslint fix #1677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Collection/RecordCache.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { CachedQueryResult } from '../adapters/type'
import type Model from '../Model'
import type { RecordId } from '../Model'
import type Collection from './index'
import type { CachedQueryResult } from '../adapters/type'
import type { TableName } from '../Schema'
import type { RawRecord } from '../RawRecord'
import type { TableName } from '../Schema'
import type Collection from './index'

type Instantiator<T> = (_: RawRecord) => T

Expand Down
12 changes: 6 additions & 6 deletions src/Collection/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// @flow
import { Observable, Subject } from '../utils/rx'
import type { ResultCallback } from '../utils/fp/Result'
import type { ArrayOrSpreadFn } from '../utils/fp'
import type { ResultCallback } from '../utils/fp/Result'
import { Observable, Subject } from '../utils/rx'
import type { Unsubscribe } from '../utils/subscriptions'

import Query from '../Query'
import type Database from '../Database'
import type Model from '../Model'
import type { RecordId } from '../Model'
import Query from '../Query'
import type { Clause } from '../QueryDescription'
import type { TableName, TableSchema } from '../Schema'
import { DirtyRaw } from '../RawRecord'
import type { TableName, TableSchema } from '../Schema'

import RecordCache from './RecordCache'

type CollectionChangeType = 'created' | 'updated' | 'destroyed'
export type CollectionChange<Record extends Model> = { record: Record; type: CollectionChangeType }
export type CollectionChangeSet<T extends Model> = CollectionChange<T>[]
export interface CollectionChange<Record extends Model> { record: Record; type: CollectionChangeType }
export type CollectionChangeSet<T extends Model> = Array<CollectionChange<T>>

export default class Collection<Record extends Model> {
database: Database
Expand Down
2 changes: 1 addition & 1 deletion src/Database/CollectionMap/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Model from '../../Model'
import Collection from '../../Collection'
import type Model from '../../Model'
import type { TableName } from '../../Schema'
import type Database from '../index'

Expand Down
4 changes: 2 additions & 2 deletions src/Database/WorkQueue.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type Model from '../Model'
import type Database from './index'
import { $ReadOnlyArray } from '../types';
import type Database from './index'

export interface ReaderInterface {
callReader<T>(reader: () => Promise<T>): Promise<T>;
Expand All @@ -11,7 +11,7 @@ export interface WriterInterface extends ReaderInterface {
batch(...records: $ReadOnlyArray<Model | Model[] | null | void | false>): Promise<void>;
}

type WorkQueueItem<T> = {
interface WorkQueueItem<T> {
work: (_: ReaderInterface | WriterInterface) => Promise<T>;
isWriter: boolean;
resolve: (value: T) => void;
Expand Down
8 changes: 4 additions & 4 deletions src/Database/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { Observable } from '../utils/rx'
import { Unsubscribe } from '../utils/subscriptions'

import type { DatabaseAdapter } from '../adapters/type'
import DatabaseAdapterCompat from '../adapters/compat'
import type Model from '../Model'
import type { DatabaseAdapter } from '../adapters/type'
import type Collection from '../Collection'
import type { CollectionChangeSet } from '../Collection'
import type { TableName, AppSchema } from '../Schema'
import type Model from '../Model'
import type { AppSchema, TableName } from '../Schema'

import CollectionMap from './CollectionMap'
import type LocalStorage from './LocalStorage'
import WorkQueue from './WorkQueue'
import type { ReaderInterface, WriterInterface } from './WorkQueue'

import { $ReadOnlyArray, $Exact, Class } from '../types'
import { $Exact, $ReadOnlyArray, Class } from '../types'

type DatabaseProps = $Exact<{
adapter: DatabaseAdapter
Expand Down
46 changes: 23 additions & 23 deletions src/Query/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Observable } from '../utils/rx'
import type { ArrayOrSpreadFn } from '../utils/fp'
import type { Unsubscribe, SharedSubscribable } from '../utils/subscriptions'
import { $Exact } from '../types'
import type { ArrayOrSpreadFn } from '../utils/fp'
import { Observable } from '../utils/rx'
import type { SharedSubscribable, Unsubscribe } from '../utils/subscriptions'

import type { Clause, QueryDescription } from '../QueryDescription'
import type Collection from '../Collection'
import type Model from '../Model'
import type { AssociationInfo, RecordId } from '../Model'
import type Collection from '../Collection'
import type { TableName, ColumnName } from '../Schema'
import type { Clause, QueryDescription } from '../QueryDescription'
import type { ColumnName, TableName } from '../Schema'

export type QueryAssociation = $Exact<{
from: TableName<any>
Expand All @@ -29,6 +29,20 @@ interface QueryCountProxy {
}

export default class Query<Record extends Model> {

get count(): QueryCountProxy

// MARK: - Internals

get modelClass(): Record

get table(): TableName<Record>

get secondaryTables(): Array<TableName<any>>

get allTables(): Array<TableName<any>>

get associations(): QueryAssociation[]
// Used by withObservables to differentiate between object types
static _wmelonTag: string

Expand All @@ -44,12 +58,12 @@ export default class Query<Record extends Model> {

_cachedCountThrottledSubscribable: SharedSubscribable<number>

// Note: Don't use this directly, use Collection.query(...)
constructor(collection: Collection<Record>, clauses: Clause[])

// Creates a new Query that extends the clauses of this query
extend: ArrayOrSpreadFn<Clause, Query<Record>>

// Note: Don't use this directly, use Collection.query(...)
constructor(collection: Collection<Record>, clauses: Clause[])

pipe<T>(transform: (_: this) => T): T

// Queries database and returns an array of matching records
Expand All @@ -70,8 +84,6 @@ export default class Query<Record extends Model> {
// Queries database and returns the number of matching records
fetchCount(): Promise<number>

get count(): QueryCountProxy

// Emits the number of matching records, then emits a new count every time it changes
// Note: By default, the Observable is throttled!
observeCount(isThrottled?: boolean): Observable<number>
Expand All @@ -98,18 +110,6 @@ export default class Query<Record extends Model> {
// Destroys all records matching the query
destroyAllPermanently(): Promise<void>

// MARK: - Internals

get modelClass(): Record

get table(): TableName<Record>

get secondaryTables(): TableName<any>[]

get allTables(): TableName<any>[]

get associations(): QueryAssociation[]

// Serialized version of Query (e.g. for sending to web worker)
serialize(): SerializedQuery
}
6 changes: 3 additions & 3 deletions src/QueryDescription/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { $RE } from '../types'

import type { TableName, ColumnName } from '../Schema'
import type { ColumnName, TableName } from '../Schema'

export type NonNullValue = number | string | boolean
export type NonNullValues = number[] | string[] | boolean[]
Expand Down Expand Up @@ -65,7 +65,7 @@ export type Skip = $RE<{
}>
export type JoinTables = $RE<{
type: 'joinTables'
tables: TableName<any>[]
tables: Array<TableName<any>>
}>
export type NestedJoinTable = $RE<{
type: 'nestedJoinTable'
Expand Down Expand Up @@ -95,7 +95,7 @@ export type Clause =
type NestedJoinTableDef = $RE<{ from: TableName<any>; to: TableName<any> }>
export type QueryDescription = $RE<{
where: Where[]
joinTables: TableName<any>[]
joinTables: Array<TableName<any>>
nestedJoinTables: NestedJoinTableDef[]
sortBy: SortBy[]
take?: number
Expand Down
6 changes: 3 additions & 3 deletions src/RawRecord/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { ColumnName, ColumnSchema, TableSchema } from '../Schema'
import type { RecordId, SyncStatus } from '../Model'
import type { ColumnName, ColumnSchema, TableSchema } from '../Schema'


// Raw object representing a model record, coming from an untrusted source
// (disk, sync, user data). Before it can be used to create a Model instance
// it must be sanitized (with `sanitizedRaw`) into a RawRecord
export type DirtyRaw = { [key: string]: any }
export interface DirtyRaw { [key: string]: any }

// These fields are ALWAYS present in records of any collection.
type _RawRecord = {
interface _RawRecord {
id: RecordId
_status: SyncStatus
_changed: string
Expand Down
2 changes: 1 addition & 1 deletion src/Relation/helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable import/no-named-as-default */
import type { Observable } from '../utils/rx'

import type Relation from './index'
import type Model from '../Model'
import type Relation from './index'

export declare function createObservable<T extends Model>(relation: Relation<T>): Observable<T>
2 changes: 1 addition & 1 deletion src/Relation/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { $NonMaybeType, $Exact, $Call } from '../types'
import { $Call, $Exact, $NonMaybeType } from '../types'
import type { Observable } from '../utils/rx'

import type Model from '../Model'
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ColumnSchema = $RE<{
isIndexed?: boolean
}>

export type ColumnMap = { [name: ColumnName]: ColumnSchema }
export interface ColumnMap { [name: ColumnName]: ColumnSchema }

export type TableSchemaSpec = $Exact<{
name: TableName<any>
Expand All @@ -31,7 +31,7 @@ export type TableSchema = $RE<{
unsafeSql?: (_: string) => string
}>

type TableMap = { [name: TableName<any>]: TableSchema }
interface TableMap { [name: TableName<any>]: TableSchema }

export type SchemaVersion = number

Expand Down
8 changes: 4 additions & 4 deletions src/Schema/migrations/getSyncChanges/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// @flow

import type { ColumnName, SchemaVersion, TableName } from '../../index'
import type { SchemaMigrations } from '../index'
import type { TableName, ColumnName, SchemaVersion } from '../../index'

import { $Exact } from '../../../types'

export type MigrationSyncChanges = $Exact<{
from: SchemaVersion
tables: TableName<any>[]
columns: $Exact<{
tables: Array<TableName<any>>
columns: Array<$Exact<{
table: TableName<any>
columns: ColumnName[]
}>[]
}>>
}> | null

export default function getSyncChanges(
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/migrations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { $RE, $Exact } from '../../types'
import type { ColumnSchema, TableName, TableSchema, TableSchemaSpec, SchemaVersion } from '../index'
import type { $Exact, $RE } from '../../types'
import type { ColumnSchema, SchemaVersion, TableName, TableSchema, TableSchemaSpec } from '../index'

export type CreateTableMigrationStep = $RE<{
type: 'create_table'
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/migrations/stepsForMigration.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { $Exact } from '../../types'

import type { SchemaMigrations, MigrationStep } from './index'
import type { SchemaVersion } from '../index'
import type { MigrationStep, SchemaMigrations } from './index'

export function stepsForMigration({
migrations: schemaMigrations,
Expand Down
8 changes: 4 additions & 4 deletions src/adapters/compat.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { RecordId } from '../Model'
import type { SerializedQuery } from '../Query'
import type { TableName, AppSchema } from '../Schema'
import type { AppSchema, TableName } from '../Schema'
import type { SchemaMigrations } from '../Schema/migrations'
import type { RecordId } from '../Model'

import type {
DatabaseAdapter,
BatchOperation,
CachedFindResult,
CachedQueryResult,
BatchOperation,
DatabaseAdapter,
UnsafeExecuteOperations,
} from './type'

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/lokijs/common.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Result } from '../../utils/fp/Result'
import type { CachedQueryResult, CachedFindResult } from '../type'
import type { RecordId } from '../../Model'
import { $Exact } from '../../types'
import { type Result } from '../../utils/fp/Result'
import type { CachedFindResult, CachedQueryResult } from '../type'

export type WorkerExecutorType =
| 'setUp'
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/lokijs/dispatcher.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ResultCallback } from '../../utils/fp/Result'
import type {
WorkerExecutorType,
CloneMethod,
WorkerExecutorPayload,
WorkerExecutorType,
WorkerResponseData,
CloneMethod,
} from './common'

type WorkerAction = {
interface WorkerAction {
id: number,
callback: ResultCallback<WorkerResponseData>,
}
Expand Down
14 changes: 7 additions & 7 deletions src/adapters/lokijs/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { LokiMemoryAdapter } from './type'
import type { ResultCallback } from '../../utils/fp/Result'
import type { LokiMemoryAdapter } from './type'

import type { RecordId } from '../../Model'
import type { TableName, AppSchema } from '../../Schema'
import type { SerializedQuery } from '../../Query'
import type { DirtyRaw } from '../../RawRecord'
import type { AppSchema, TableName } from '../../Schema'
import type { SchemaMigrations } from '../../Schema/migrations'
import type { SerializedQuery } from '../../Query'
import type {
DatabaseAdapter,
CachedQueryResult,
CachedFindResult,
BatchOperation,
CachedFindResult,
CachedQueryResult,
DatabaseAdapter,
UnsafeExecuteOperations,
} from '../type'

Expand Down Expand Up @@ -63,7 +63,7 @@ export type LokiAdapterOptions = $Exact<{
onFetchStart?: () => void
// Collections (by table name) that Loki should deserialize lazily. This is only profitable for
// collections that are most likely not required for launch - making everything lazy makes it slower
lazyCollections?: TableName<any>[]
lazyCollections?: Array<TableName<any>>
}>
// -- internal --
_testLokiAdapter?: LokiMemoryAdapter
Expand Down
14 changes: 7 additions & 7 deletions src/adapters/sqlite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import type { ResultCallback } from '../../utils/fp/Result'

import type { RecordId } from '../../Model'
import type { SerializedQuery } from '../../Query'
import type { TableName, AppSchema, SchemaVersion } from '../../Schema'
import type { SchemaMigrations, MigrationStep } from '../../Schema/migrations'
import type { AppSchema, SchemaVersion, TableName } from '../../Schema'
import type { MigrationStep, SchemaMigrations} from '../../Schema/migrations'
import type {
DatabaseAdapter,
CachedQueryResult,
CachedFindResult,
BatchOperation,
CachedFindResult,
CachedQueryResult,
DatabaseAdapter,
UnsafeExecuteOperations,
} from '../type'
import type {
DispatcherType,
MigrationEvents,
SQL,
SQLiteAdapterOptions,
SQLiteArg,
SQLiteQuery,
SqliteDispatcher,
MigrationEvents,
SQLiteQuery,
} from './type'

import { $Shape } from '../../types'
Expand Down
Loading
Loading