Skip to content

Commit ecef678

Browse files
authored
Merge pull request #72 from ReactiveDB/upgrade-all
Upgrade all
2 parents bd7abbc + 0569375 commit ecef678

Some content is hidden

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

66 files changed

+3000
-4383
lines changed

package.json

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@
1111
"clean_dist_cjs": "rm -rf ./dist/cjs",
1212
"clean_dist_es": "rm -rf ./dist/es",
1313
"check_circular_dependencies": "madge ./dist/cjs --circular",
14-
"compile_cjs": " tsc dist/cjs/src/index.ts dist/cjs/src/proxy/index.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --noUnusedLocals --noUnusedParameters --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --importHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom",
15-
"compile_module_es": "tsc dist/es/src/index.ts dist/es/src/proxy/index.ts -m ES2015 --outDir dist/es --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --noUnusedLocals --noUnusedParameters --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --importHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom",
14+
"compile_cjs": " tsc dist/cjs/src/index.ts dist/cjs/src/proxy/index.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --noUnusedLocals --noUnusedParameters --strict --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --importHelpers --lib es5,es2015,es2016,es2017",
15+
"compile_module_es": "tsc dist/es/src/index.ts dist/es/src/proxy/index.ts -m ES2015 --outDir dist/es --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --noUnusedLocals --noUnusedParameters --strict --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --importHelpers --lib es5,es2015,es2016,es2017",
1616
"copy_src_cjs": "shx mkdir -p ./dist/cjs/src && shx cp -r ./src/* ./dist/cjs/src",
1717
"copy_src_es": "shx mkdir -p ./dist/es/src && shx cp -r ./src/* ./dist/es/src",
1818
"cover": "rm -rf ./.nyc_output ./coverage && NODE_ENV=test nyc --reporter=html --reporter=lcov --exclude=node_modules --exclude=spec-js/test --exclude=spec-js/src/storage/lovefield.js --exclude=spec-js/src/shared/Logger.js --exclude=spec-js/src/utils/option.js --exclude=spec-js/src/utils/valid.js --exclude=spec-js/src/addons/aggresive-optimizer.js tman --mocha spec-js/test/run.js && nyc report",
1919
"lint": "tslint -c tslint.json src/*.ts --project ./tsconfig.json \"src/**/*.ts\" \"./test/**/*.ts\" -e \"./test/e2e/*.ts\"",
20+
"precommit": "lint-staged",
2021
"publish_all": "ts-node ./tools/publish.ts",
2122
"start": "webpack-dev-server --inline --colors --progress --port 3000",
2223
"start-demo": "webpack-dev-server --config ./example/webpack.config.js --inline --colors --progress --port 3001 --open",
2324
"test": "npm run lint && NODE_ENV=test tman --mocha spec-js/test/run.js",
2425
"test_O1": "npm run lint && NODE_ENV=test optimize=true tman --mocha spec-js/test/run.js",
2526
"version": "ts-node tools/version.ts && git add .",
2627
"watch": "NODE_ENV=test ts-node ./tools/watch.ts & npm run watch_test",
27-
"watch_cjs": "tsc src/index.ts -m commonjs --outDir dist --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom -w",
28+
"watch_cjs": "tsc src/index.ts -m commonjs --outDir dist --sourcemap --target ES5 -d --diagnostics --pretty --strict --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers --lib es5,es2015,es2016,es2017 -w",
2829
"watch_test": "tsc -p test/tsconfig.json -w --diagnostics --pretty"
2930
},
3031
"keywords": [
@@ -61,37 +62,40 @@
6162
"license": "MIT",
6263
"devDependencies": {
6364
"@types/chai": "^4.1.2",
64-
"@types/node": "^9.4.7",
65+
"@types/node": "^10.5.5",
6566
"@types/shelljs": "^0.8.0",
6667
"@types/sinon": "^5.0.0",
67-
"@types/sinon-chai": "^2.7.29",
68+
"@types/sinon-chai": "^3.2.0",
6869
"chai": "^4.1.2",
6970
"coveralls": "^3.0.0",
70-
"css-loader": "^0.28.10",
71+
"css-loader": "^1.0.0",
7172
"extract-text-webpack-plugin": "^4.0.0-beta.0",
7273
"html-webpack-plugin": "^3.0.6",
74+
"husky": "^0.14.3",
75+
"lint-staged": "^7.2.0",
7376
"madge": "^3.0.1",
7477
"moment": "^2.21.0",
7578
"node-watch": "^0.5.8",
7679
"npm-run-all": "^4.1.2",
7780
"nyc": "^12.0.1",
81+
"prettier": "^1.14.0",
7882
"raw-loader": "^0.5.1",
79-
"rxjs": "^5.5.6",
83+
"rxjs": "^6.2.2",
8084
"shelljs": "^0.8.1",
8185
"shx": "^0.3.0",
82-
"sinon": "^5.0.0",
86+
"sinon": "^6.1.4",
8387
"sinon-chai": "^3.0.0",
8488
"source-map-loader": "^0.2.3",
8589
"style-loader": "^0.21.0",
8690
"tman": "^1.7.4",
8791
"ts-loader": "^4.0.1",
88-
"ts-node": "^6.0.0",
92+
"ts-node": "^7.0.0",
8993
"tslint": "^5.9.1",
9094
"tslint-eslint-rules": "^5.1.0",
9195
"tslint-loader": "^3.6.0",
9296
"typescript": "^3.0.1",
9397
"webpack": "^4.1.1",
94-
"webpack-cli": "^2.0.10",
98+
"webpack-cli": "^3.1.0",
9599
"webpack-dev-server": "^3.1.0"
96100
},
97101
"dependencies": {
@@ -100,8 +104,23 @@
100104
"nesthydrationjs": "^1.0.5"
101105
},
102106
"peerDependencies": {
103-
"rxjs": "^5.3.0",
107+
"rxjs": "^6.0.0",
104108
"tslib": "^1.9.0"
105109
},
106-
"typings": "./index.d.ts"
110+
"typings": "./index.d.ts",
111+
"prettier": {
112+
"printWidth": 120,
113+
"semi": false,
114+
"trailingComma": "all",
115+
"singleQuote": true,
116+
"arrowParens": "always",
117+
"parser": "typescript"
118+
},
119+
"lint-staged": {
120+
"*.ts": [
121+
"prettier --write",
122+
"tslint -c tslint.json -p tsconfig.json --fix",
123+
"git add"
124+
]
125+
}
107126
}

src/addons/aggresive-optimizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const compareFn = function(ctx: any, left: any, right: any) {
3333
export const aggresiveOptimizer = () => {
3434
lf.ObserverRegistry.Entry_.prototype.updateResults = function(newResults: any[]) {
3535
const oldList: any = (this.lastResults_ && this.lastResults_.entries) || []
36-
const newList: any = (newResults.entries) || []
36+
const newList: any = newResults.entries || []
3737

3838
const hasChanges = compareFn(this.diffCalculator_, oldList, newList)
3939
this.lastResults_ = newResults

src/exception/Exception.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
export class ReactiveDBException extends Error {
2-
32
constructor(message: string) {
43
super(message)
5-
this.name = 'ReactiveDBError';
6-
(Object as any).setPrototypeOf(this, ReactiveDBException.prototype)
4+
this.name = 'ReactiveDBError'
5+
Object.setPrototypeOf(this, ReactiveDBException.prototype)
76
}
8-
97
}

src/exception/database.ts

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,40 @@
11
import { ReactiveDBException } from './Exception'
22

3-
export const NonExistentTable =
4-
(tableName: string) => new ReactiveDBException(`Table: \`${tableName}\` cannot be found.`)
3+
export const NonExistentTable = (tableName: string) =>
4+
new ReactiveDBException(`Table: \`${tableName}\` cannot be found.`)
55

6-
export const UnmodifiableTable =
7-
() => new ReactiveDBException(`Method: defineSchema cannot be invoked since schema is existed or database is connected`)
6+
export const UnmodifiableTable = () =>
7+
new ReactiveDBException(`Method: defineSchema cannot be invoked since schema is existed or database is connected`)
88

9-
export const InvalidQuery =
10-
() => new ReactiveDBException('Only navigation properties were included in query.')
9+
export const InvalidQuery = () => new ReactiveDBException('Only navigation properties were included in query.')
1110

12-
export const AliasConflict =
13-
(column: string, tableName: string) => new ReactiveDBException(`Definition conflict, Column: \`${column}\` on table: ${tableName}.`)
11+
export const AliasConflict = (column: string, tableName: string) =>
12+
new ReactiveDBException(`Definition conflict, Column: \`${column}\` on table: ${tableName}.`)
1413

15-
export const GraphFailed =
16-
(err: Error) => new ReactiveDBException(`Graphify query result failed, due to: ${err.message}.`)
14+
export const GraphFailed = (err: Error) =>
15+
new ReactiveDBException(`Graphify query result failed, due to: ${err.message}.`)
1716

18-
export const NotImplemented =
19-
() => new ReactiveDBException('Not implemented yet.')
17+
export const NotImplemented = () => new ReactiveDBException('Not implemented yet.')
2018

21-
export const UnexpectedRelationship =
22-
() => new ReactiveDBException('Unexpected relationship was specified.')
19+
export const UnexpectedRelationship = () => new ReactiveDBException('Unexpected relationship was specified.')
2320

24-
export const InvalidType =
25-
(expect?: [string, string]) => {
26-
let message = 'Unexpected data type'
27-
if (expect) {
28-
message += `, expect ${expect[0]} but got ${expect[1]}`
29-
}
30-
return new ReactiveDBException(message + '.')
21+
export const InvalidType = (expect?: [string, string]) => {
22+
let message = 'Unexpected data type'
23+
if (expect) {
24+
message += `, expect ${expect[0]} but got ${expect[1]}`
3125
}
26+
return new ReactiveDBException(message + '.')
27+
}
3228

33-
export const UnexpectedTransactionUse =
34-
() => new ReactiveDBException('Please use Database#transaction to get a transaction scope first.')
29+
export const UnexpectedTransactionUse = () =>
30+
new ReactiveDBException('Please use Database#transaction to get a transaction scope first.')
3531

36-
export const PrimaryKeyNotProvided =
37-
() => new ReactiveDBException(`Primary key was not provided.`)
32+
export const PrimaryKeyNotProvided = () => new ReactiveDBException(`Primary key was not provided.`)
3833

39-
export const PrimaryKeyConflict =
40-
() => new ReactiveDBException(`Primary key was already provided.`)
34+
export const PrimaryKeyConflict = () => new ReactiveDBException(`Primary key was already provided.`)
4135

42-
export const DatabaseIsNotEmpty =
43-
() => new ReactiveDBException('Method: load cannnot be invoked since database is not empty.')
36+
export const DatabaseIsNotEmpty = () =>
37+
new ReactiveDBException('Method: load cannnot be invoked since database is not empty.')
4438

45-
export const NotConnected =
46-
() => new ReactiveDBException('Method: dispose cannnot be invoked before database is connected.')
39+
export const NotConnected = () =>
40+
new ReactiveDBException('Method: dispose cannnot be invoked before database is connected.')

src/exception/token.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { ReactiveDBException } from './Exception'
22

3-
export const TokenConsumed =
4-
() => new ReactiveDBException('QueryToken was already consumed.')
3+
export const TokenConsumed = () => new ReactiveDBException('QueryToken was already consumed.')
54

6-
export const TokenConcatFailed =
7-
(msg?: string) => {
8-
const errMsg = 'Token cannot be concated' + `${ msg ? ' due to: ' + msg : '' }.`
9-
return new ReactiveDBException(errMsg)
10-
}
5+
export const TokenConcatFailed = (msg?: string) => {
6+
const errMsg = 'Token cannot be concated' + `${msg ? ' due to: ' + msg : ''}.`
7+
return new ReactiveDBException(errMsg)
8+
}

src/interface/enum.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ export enum RDBType {
66
NUMBER,
77
OBJECT,
88
STRING,
9-
LITERAL_ARRAY
9+
LITERAL_ARRAY,
1010
}
1111

1212
export enum Relationship {
1313
oneToMany = 500,
1414
oneToOne = 501,
15-
manyToMany = 502
15+
manyToMany = 502,
1616
}
1717

1818
export enum DataStoreType {
1919
INDEXED_DB = 0,
2020
MEMORY = 1,
2121
LOCAL_STORAGE = 2,
2222
WEB_SQL = 3,
23-
OBSERVABLE_STORE = 4
23+
OBSERVABLE_STORE = 4,
2424
}
2525

2626
export enum StatementType {
2727
Insert = 1001,
2828
Update = 1002,
2929
Delete = 1003,
30-
Select = 1004
30+
Select = 1004,
3131
}
3232

3333
export enum JoinMode {
3434
imlicit = 2001,
35-
explicit = 2002
35+
explicit = 2002,
3636
}
3737

3838
export enum LeafType {

src/interface/index.ts

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { Observable } from 'rxjs/Observable'
2-
import { PartialObserver } from 'rxjs/Observer'
1+
import { Observable, PartialObserver } from 'rxjs'
32
import { RDBType, Relationship, LeafType, StatementType, JoinMode, DataStoreType } from './enum'
43

5-
export type DeepPartial<T> = {
6-
[K in keyof T]?: Partial<T[K]>
7-
}
4+
export type DeepPartial<T> = { [K in keyof T]?: Partial<T[K]> }
85

96
export interface SchemaMetadata<T> {
107
type: RDBType | Relationship
@@ -21,13 +18,9 @@ export interface SchemaMetadata<T> {
2118
}
2219
}
2320

24-
export type TableShape<T> = lf.schema.Table & {
25-
[P in keyof T]: lf.schema.Column
26-
}
21+
export type TableShape<T> = lf.schema.Table & { [P in keyof T]: lf.schema.Column }
2722

28-
export type SchemaDef<T> = {
29-
[P in keyof T]: SchemaMetadata<T[P]>
30-
} & {
23+
export type SchemaDef<T> = { [P in keyof T]: SchemaMetadata<T[P]> } & {
3124
dispose?: SchemaDisposeFunction<T>
3225
['@@dispose']?: SchemaDisposeFunction<T>
3326
}
@@ -71,7 +64,7 @@ export interface Query<T> extends Clause<T> {
7164
}
7265

7366
export interface JoinInfo {
74-
table: lf.schema.Table,
67+
table: lf.schema.Table
7568
predicate: lf.Predicate
7669
}
7770

@@ -101,8 +94,8 @@ export interface TraverseContext {
10194

10295
export interface UpsertContext {
10396
mapper: Function | null
104-
isNavigatorLeaf: boolean,
105-
visited: boolean,
97+
isNavigatorLeaf: boolean
98+
visited: boolean
10699
}
107100

108101
export interface SelectContext {
@@ -121,18 +114,17 @@ export interface NavigatorLeaf {
121114
assocaiation: Association
122115
}
123116

124-
export type ScopedHandler = [
125-
(where?: Predicate<any>) => Observable<any>,
126-
(ret: any[]) => void
127-
]
117+
export type ScopedHandler = [(where?: Predicate<any>) => Observable<any>, (ret: any[]) => void]
128118

129-
export type SchemaDisposeFunction<T> =
130-
(entities: Partial<T>[], scopedHandler: (name: string) => ScopedHandler) => Observable<Partial<T>>
119+
export type SchemaDisposeFunction<T> = (
120+
entities: Partial<T>[],
121+
scopedHandler: (name: string) => ScopedHandler,
122+
) => Observable<Partial<T>>
131123

132124
export interface ShapeMatcher {
133125
mainTable: lf.schema.Table
134126
pk: {
135-
name: string,
127+
name: string
136128
queried: boolean
137129
}
138130
definition: Object
@@ -164,7 +156,7 @@ export interface PredicateMeta<T> {
164156
$match: RegExp
165157
$notMatch: RegExp
166158
$has: ValueLiteral
167-
$between: [ number, number ]
159+
$between: [number, number]
168160
$in: ValueLiteral[]
169161
$isNull: boolean
170162
$isNotNull: boolean
@@ -176,9 +168,7 @@ export type Predicate<T> = {
176168

177169
export { StatementType, JoinMode, LeafType, Relationship, DataStoreType, RDBType }
178170

179-
export type TransactionDescriptor<T> = {
180-
[P in keyof T]: PropertyDescriptor
181-
}
171+
export type TransactionDescriptor<T> = { [P in keyof T]: PropertyDescriptor }
182172

183173
export type TransactionHandler = {
184174
commit: () => Observable<ExecutorResult>
@@ -187,4 +177,6 @@ export type TransactionHandler = {
187177

188178
export type Transaction<T> = [T, TransactionHandler]
189179

190-
export type TransactionEffects<T = any> = PartialObserver<T> | { next: (x: T) => void, error?: (e: any) => void, complete?: () => void }
180+
export type TransactionEffects<T = any> =
181+
| PartialObserver<T>
182+
| { next: (x: T) => void; error?: (e: any) => void; complete?: () => void }

0 commit comments

Comments
 (0)