-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e01777
commit 85d01b9
Showing
13 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/**/*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# @qiwi/substrate-abstract | ||
Abstract classes collection | ||
|
||
### Install | ||
```bash | ||
yarn add @qiwi/substrate-abstract -D | ||
npm add @qiwi/substrate-abstract -D | ||
``` | ||
|
||
### Usage | ||
```typescript | ||
import { AbstractError } from '@qiwi/substrate-abstract' | ||
|
||
class CustomError extends AbstractError { | ||
foo: string | ||
constructor(args) { | ||
super(...args) | ||
|
||
this.foo = 'bar' | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"testEnvironment": "node", | ||
"collectCoverage": true, | ||
"rootDir": "../../", | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"<rootDir>/packages/abstract/src/main/**/*.ts" | ||
], | ||
"testMatch": [ | ||
"<rootDir>/packages/abstract/src/test/**/*.ts" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/packages/abstract/src/test/ts/index.ts", | ||
"<rootDir>/packages/abstract/src/test/ts/index.d.ts" | ||
], | ||
"transformIgnorePatterns": [ | ||
"/!node_modules\\/lodash-es/", | ||
"<roodDir>/node_modules/(?!lodash-es)" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"json", | ||
"node" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "@qiwi/substrate-abstract", | ||
"description": "Abstract classes", | ||
"version": "1.16.0", | ||
"main": "target/es5/index.js", | ||
"types": "typings/index.d.ts", | ||
"typesVersions": { | ||
">=3.1": { | ||
"*": [ | ||
"typings/index.d.ts", | ||
"src/test/ts/*" | ||
] | ||
} | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"clean": "rm -rf target", | ||
"build": "yarn build:es5 && yarn build:es6 && yarn build:ts && yarn libdef", | ||
"build:es5": "mkdir -p target/es5 && tsc -p tsconfig.json --target ES5 --outDir target/es5", | ||
"build:es6": "mkdir -p target/es6 && tsc -p tsconfig.json --target ES6 --outDir target/es6", | ||
"build:ts": "cp -r src/main/ts/ target/ts/", | ||
"libdef": "yarn dtsgen && yarn libdeffix && yarn flowgen", | ||
"libdeffix": "node -r esm ../../scripts/libdef-fix.js --flow=./typings/index.flow.js --dts=./typings/index.d.ts", | ||
"dtsgen": "dts-generator --project ./ --out typings/index.d.ts --prefix @qiwi/substrate-abstract/target/es5 --name @qiwi/substrate-abstract --main @qiwi/substrate-abstract/target/es5/index --moduleResolution node", | ||
"flowgen": "flowgen typings/index.d.ts --output-file typings/index.flow.js", | ||
"test": "yarn test:libdefs && yarn jest", | ||
"test:libdefs": "cp typings/index.d.ts src/test/ts/index.d.ts && yarn dtslint", | ||
"jest": "jest --config=jest.config.json", | ||
"dtslint": "dtslint src/test/ts --onlyTestTsNext" | ||
}, | ||
"files": [ | ||
"README.md", | ||
"CHANGELOG.md", | ||
"typings", | ||
"target" | ||
], | ||
"devDependencies": { | ||
"@qiwi/uniconfig": "^3.0.1", | ||
"@types/bluebird": "^3.5.27", | ||
"@types/config": "^0.0.34", | ||
"@types/jest": "^24.0.18", | ||
"@types/lodash": "^4.14.137", | ||
"@types/node": "^12.7.2", | ||
"@types/parsimmon": "^1.10.0", | ||
"@types/underscore": "^1.9.2", | ||
"bluebird": "^3.5.5", | ||
"conf": "^4.1.0", | ||
"config": "^3.1.0", | ||
"dts-generator": "^3.0.0", | ||
"dtslint": "^0.9.1", | ||
"flowgen": "^1.10.0", | ||
"lodash": "^4.17.15", | ||
"replace-in-file": "^4.1.3", | ||
"ts-loader": "^6.0.4", | ||
"ts-node": "^8.3.0", | ||
"ts-to-flow": "^0.0.3", | ||
"typescript": "3.5.3", | ||
"underscore": "^1.9.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export type IError = { | ||
message: string | ||
code?: string | number | ||
[key: string]: any | ||
} | ||
|
||
export type IErrorOpts = { | ||
message: string | ||
} | ||
|
||
export class AbstractError extends Error implements IError { | ||
message: string | ||
code?: string | number | ||
constructor(message: string | IErrorOpts) { | ||
const opts = typeof message === 'string' | ||
? { message } | ||
: message | ||
|
||
super(opts.message) | ||
this.message = opts.message | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './AError' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AbstractError } from './index'; | ||
|
||
describe('AbstractError', () => { | ||
describe('constructor', () => { | ||
it('constructs by message', () => { | ||
const message = 'foo'; | ||
const instance = new AbstractError(message); | ||
|
||
expect(instance.message).toBe(message); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
declare module '@qiwi/substrate-abstract/target/es5/AError' { | ||
type IError = { | ||
message: string; | ||
code?: string | number; | ||
[key: string]: any; | ||
}; | ||
type IErrorOpts = { | ||
message: string; | ||
}; | ||
class AbstractError extends Error implements IError { | ||
message: string; | ||
code?: string | number; | ||
constructor(message: string | IErrorOpts); | ||
} | ||
} | ||
declare module '@qiwi/substrate-abstract/target/es5/index' { | ||
export * from '@qiwi/substrate-abstract/target/es5/AError'; | ||
} | ||
declare module '@qiwi/substrate-abstract' { | ||
export * from '@qiwi/substrate-abstract/target/es5/index'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@qiwi/substrate-abstract'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
/* Additional Checks */ | ||
/* next line commented out because we need unused vars for type tests */ | ||
// "noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"lib": ["es6", "dom"], | ||
"skipLibCheck": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@qiwi/substrate-abstract": [ | ||
"../../main/ts" | ||
] | ||
}, | ||
"typeRoots": [ | ||
".", | ||
"../../../../../node_modules/@types" | ||
] | ||
}, | ||
"include": [ | ||
"./*" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"strict-type-predicates": true, | ||
"interface-over-type-literal": false, | ||
"interface-name": [true, "always-prefix"], | ||
"max-line-length": [true, 1000] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src/main/ts", | ||
"outDir": "target/es5", | ||
"baseUrl": "src/main/ts" | ||
}, | ||
"include": [ | ||
"src/main/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters