-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: ts setup, fix ts-sdk issues (#1395)
- Loading branch information
Showing
167 changed files
with
13,802 additions
and
15,514 deletions.
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
package-lock.json | ||
credentials.js | ||
package.json | ||
**/dist/ | ||
**/lib/ |
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
"eslint.validate": [ | ||
"javascript", | ||
"typescript" | ||
], | ||
"flow.useNPMPackagedFlow": true, | ||
"javascript.validate.enable": false | ||
"javascript.validate.enable": false, | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
hooks: { | ||
'commit-msg': 'commitlint -e $HUSKY_GIT_PARAMS', | ||
'pre-commit': 'lint-staged', | ||
'pre-commit': 'yarn typecheck:ts && lint-staged', | ||
}, | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
runner: 'jest-runner-eslint', | ||
displayName: 'eslint', | ||
testMatch: ['<rootDir>/packages/**/*.js'], | ||
testMatch: ['<rootDir>/packages/**/*.js', '<rootDir>/packages/**/*.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
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
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
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,46 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/typescript', | ||
'plugin:jest/recommended', | ||
'prettier', | ||
'prettier/@typescript-eslint', | ||
], | ||
plugins: ['import', 'jest', 'prettier', '@typescript-eslint/eslint-plugin'], | ||
env: { | ||
es6: true, | ||
browser: true, | ||
jest: true, | ||
node: true, | ||
}, | ||
rules: { | ||
'@typescript-eslint/camelcase': 0, | ||
'@typescript-eslint/consistent-type-definitions': 0, | ||
'@typescript-eslint/explicit-function-return-type': 0, | ||
'@typescript-eslint/no-explicit-any': 2, | ||
'@typescript-eslint/no-use-before-define': ['error', { functions: false }], | ||
'@typescript-eslint/no-var-requires': 0, | ||
'@typescript-eslint/unbound-method': 0, | ||
'import/no-extraneous-dependencies': 0, | ||
'import/no-named-as-default': 0, | ||
'import/no-unresolved': 2, | ||
|
||
// Specific for the generated SDK | ||
'import/no-duplicates': 0, | ||
'import/no-cycle': 0, | ||
'spaced-comment': 0 | ||
}, | ||
settings: { | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts'], | ||
}, | ||
'import/resolver': { | ||
'eslint-import-resolver-typescript': true, | ||
typescript: {}, | ||
node: { | ||
extensions: ['.js', '.ts'], | ||
}, | ||
}, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -15,28 +15,28 @@ | |
"bugs": "https://github.com/commercetools/nodejs/issues", | ||
"license": "MIT", | ||
"author": "Beniasaad Achraf <[email protected]> (https://github.com/acbeni)", | ||
"main": "lib/typescript-sdk.cjs.js", | ||
"module": "lib/typescript-sdk.es.js", | ||
"browser": "lib/typescript-sdk.umd.js", | ||
"types": "lib/types/index.d.ts", | ||
"main": "dist/typescript-sdk.cjs.js", | ||
"module": "dist/typescript-sdk.es.js", | ||
"browser": "dist/typescript-sdk.umd.js", | ||
"typings": "./dist/typings/index.d.ts", | ||
"types": "./dist/typings/index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/commercetools/nodejs.git" | ||
}, | ||
"files": [ | ||
"lib" | ||
"dist" | ||
], | ||
"scripts": { | ||
"type-check": "tsc --noEmit", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"prebuild": "rimraf -rf lib && npm run build:types", | ||
"build": "cross-env npm run build:umd && npm run build:umd:min && npm run build:es && npm run build:cjs", | ||
"build:umd": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f umd -n TypescriptSdk -i ./src/index.ts -o lib/typescript-sdk.umd.js", | ||
"build:umd:min": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -f umd -n TypescriptSdk -i ./src/index.ts -o lib/typescript-sdk.umd.min.js", | ||
"build:es": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f es -n TypescriptSdk -i ./src/index.ts -o lib/typescript-sdk.es.js", | ||
"build:cjs": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f cjs -n TypescriptSdk -i ./src/index.ts -o lib/typescript-sdk.cjs.js" | ||
"prebuild": "rimraf dist/**", | ||
"build": "cross-env yarn build:umd && yarn build:umd:min && yarn build:es && yarn build:cjs", | ||
"build:umd": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f umd -n TypescriptSdk -i ./src/index.ts -o dist/typescript-sdk.umd.js", | ||
"build:umd:min": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -f umd -n TypescriptSdk -i ./src/index.ts -o dist/typescript-sdk.umd.min.js", | ||
"build:es": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f es -n TypescriptSdk -i ./src/index.ts -o dist/typescript-sdk.es.js", | ||
"build:cjs": "cross-env NODE_ENV=rollup rollup -c ../../rollup.config.js -f cjs -n TypescriptSdk -i ./src/index.ts -o dist/typescript-sdk.cjs.js", | ||
"build:typings": "tsc -p tsconfig.declarations.json --emitDeclarationOnly --declarationDir dist/typings" | ||
}, | ||
"dependencies": { | ||
"regenerator-runtime": "^0.13.2" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
export type MethodType = | ||
| "GET" | ||
| "HEAD" | ||
| "POST" | ||
| "PUT" | ||
| "DELETE" | ||
| "CONNECT" | ||
| "OPTIONS" | ||
| "TRACE"; | ||
| 'GET' | ||
| 'HEAD' | ||
| 'POST' | ||
| 'PUT' | ||
| 'DELETE' | ||
| 'CONNECT' | ||
| 'OPTIONS' | ||
| 'TRACE' | ||
|
||
export type VariableMap = { [key: string]: string | number | boolean | undefined } | ||
export type VariableMap = { | ||
[key: string]: string | number | boolean | undefined | ||
} | ||
|
||
export type MiddlewareArg = { | ||
request: ClientRequest; | ||
response?: ClientResponse<any>; | ||
error?: Error; | ||
next: Middleware; | ||
}; | ||
request: ClientRequest | ||
response?: ClientResponse<any> | ||
error?: Error | ||
next: Middleware | ||
} | ||
|
||
export type ClientRequest = { | ||
uri: string, | ||
method: MethodType, | ||
body?: any, | ||
headers?: VariableMap, | ||
uri: string | ||
method: MethodType | ||
body?: any | ||
headers?: VariableMap | ||
} | ||
|
||
export type ClientResponse<T> = { | ||
body: T, | ||
statusCode?: number, | ||
body: T | ||
statusCode?: number | ||
headers?: Object | ||
} | ||
|
||
export type Middleware = (arg: MiddlewareArg) => Promise<MiddlewareArg>; | ||
export type Middleware = (arg: MiddlewareArg) => Promise<MiddlewareArg> |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { MethodType, VariableMap } from "./common-types"; | ||
import { MethodType, VariableMap } from './common-types' | ||
|
||
export interface CommonRequest<T> { | ||
baseURL: string; | ||
url?: string, | ||
headers?: VariableMap; | ||
method: MethodType; | ||
uriTemplate: string; | ||
pathVariables?: VariableMap; | ||
queryParams?: VariableMap; | ||
baseURL: string | ||
url?: string | ||
headers?: VariableMap | ||
method: MethodType | ||
uriTemplate: string | ||
pathVariables?: VariableMap | ||
queryParams?: VariableMap | ||
body?: T | ||
} | ||
} |
Oops, something went wrong.