rest-client-sdk
Advanced tools
Comparing version 4.1.2 to 5.0.0-rc.1
# Changelog | ||
## Unreleased | ||
### Changed | ||
- [BREAKING] TokenGenerator's `refreshToken` method signature changed from `refreshToken(accessToken, parameters)` to `refreshToken(accessToken)`. | ||
If you did extend the `AbstractToken` generator, you shouldn't relly on the second parameter. | ||
As a matter of fact, the auto-refreshed token in `AbstractClient` did not send any parameters either, so it should not have been working before ! | ||
- [BREAKING] Accordingly The `refreshToken` method of `TokenStorage` signature changed from `refreshToken(parameters)` to `refreshToken()` | ||
- Migrate codebase to TypeScript. It should not change anything to users, exept a more robust code for TypeScript users. Some small undocumented cases might break: | ||
- [Might Break] `ClassMetadata`, `Attribute` and `Relation` attributes are now `readonly`. You can not change them after initialization. | ||
- [Might Break] `AbstractTokenGenerator` is now abstract. It should not have been used directly anyway. It implies that the method that previously did thrown errors are not callable (`generateToken`, `refreshToken` and `checkTokenGeneratorConfig`). They should not have been called. | ||
- `canAutogenerateToken` has been removed from the token storages and replaced by a `autogenerateToken()` method (it's not real POO, but I did not manage to deal with instance of for now) | ||
- [Might Break] AbstractClient.\_refreshTokenAndRefetch does not take the response as a first argument (it wan unused). The method was supposed to be private be the way. | ||
## 4.1.2 | ||
@@ -4,0 +18,0 @@ |
{ | ||
"name": "rest-client-sdk", | ||
"version": "4.1.2", | ||
"version": "5.0.0-rc.1", | ||
"description": "Rest Client SDK for API", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"types": "dist/types/index.d.ts", | ||
"files": [ | ||
@@ -13,6 +14,12 @@ "dist", | ||
"clean": "rimraf dist", | ||
"test": "jest", | ||
"build": "rollup -c", | ||
"test": "yarn lint --quiet && jest", | ||
"build": "yarn clean && yarn build:types && yarn build:js", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build:js": "rollup -c", | ||
"check:src": "npm run test", | ||
"prepublishOnly": "npm run clean && npm run check:src && npm run build" | ||
"prepublishOnly": "npm run clean && npm run check:src && npm run build", | ||
"lint": "yarn lint:types && yarn lint:eslint", | ||
"lint:eslint": "eslint --ext js,jsx,jsx,ts,tsx src/", | ||
"lint:types": "tsc --noEmit", | ||
"version": "sed -i \"s/current_version = .*/current_version = $npm_package_version/\" .bumpversion.cfg && git add .bumpversion.cfg" | ||
}, | ||
@@ -24,32 +31,41 @@ "dependencies": { | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.24.1", | ||
"babel-jest": "^23.6.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.7.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-typescript": "^7.9.0", | ||
"@types/deep-diff": "^1.0.0", | ||
"@types/urijs": "^1.19.8", | ||
"@typescript-eslint/eslint-plugin": "^2.26.0", | ||
"@typescript-eslint/parser": "^2.26.0", | ||
"babel-jest": "^25.2.6", | ||
"bundlesize": "^0.18.0", | ||
"eslint": "^5.9.0", | ||
"eslint-config-airbnb": "^17.1.0", | ||
"eslint-config-prettier": "^3.0.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.2", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"eslint-plugin-react": "^7.11.1", | ||
"fetch-mock": "^5.13.1", | ||
"form-data": "^2.3.3", | ||
"husky": "^1.1.4", | ||
"core-js": "^3.6.4", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb": "^18.1.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"eslint-plugin-react": "^7.19.0", | ||
"eslint-plugin-react-hooks": "^2.5.0 || ^1.7.0", | ||
"fetch-mock": "^9", | ||
"form-data": "^3.0.0", | ||
"husky": "^4.2.3", | ||
"immutable": "^4.0.0-rc.12", | ||
"jest": "^23.6.0", | ||
"jest-fetch-mock": "^1.7.4", | ||
"lint-staged": "^8.0.4", | ||
"pluralize": "^7.0.0", | ||
"prettier": "^1.10.2", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.67.1", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-commonjs": "^9.1.0", | ||
"rollup-plugin-node-resolve": "^4.0.0" | ||
"jest": "^25.2.7", | ||
"jest-fetch-mock": "^3.0.0", | ||
"lint-staged": "^10.1.2", | ||
"pluralize": "^8.0.0", | ||
"prettier": "^2.0.2", | ||
"regenerator-runtime": "^0.13.5", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^2.3.3", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"typescript": "^3.9.6" | ||
}, | ||
"optionalDependencies": { | ||
"pluralize": "^7.0.0" | ||
"pluralize": "^8.0.0" | ||
}, | ||
@@ -82,4 +98,3 @@ "repository": { | ||
"*.{js,jsx,json,md}": [ | ||
"yarn run prettier --write", | ||
"git add" | ||
"yarn run prettier --write" | ||
] | ||
@@ -89,3 +104,5 @@ }, | ||
"automock": false, | ||
"setupTestFrameworkScriptFile": "./setupJest.js" | ||
"setupFilesAfterEnv": [ | ||
"./setupJest.js" | ||
] | ||
}, | ||
@@ -92,0 +109,0 @@ "husky": { |
@@ -1,2 +0,2 @@ | ||
# Mapado Rest Client JS SDK [![Build Status](https://travis-ci.org/mapado/rest-client-js-sdk.svg?branch=master)](https://travis-ci.org/mapado/rest-client-js-sdk) [![Greenkeeper badge](https://badges.greenkeeper.io/mapado/rest-client-js-sdk.svg)](https://greenkeeper.io/) | ||
# Mapado Rest Client JS SDK [![Build Status](https://travis-ci.org/mapado/rest-client-js-sdk.svg?branch=master)](https://travis-ci.org/mapado/rest-client-js-sdk) | ||
@@ -23,21 +23,21 @@ Rest client SDK for API for Javascript usage. | ||
const productMetadata = new ClassMetadata( | ||
'products', // key: mandatory, will be passed in your serializer | ||
'my_products', // pathRoot: optional, the endpoint of your API: will be added to the mapping prefix ('/v1' here) | ||
SomeRepositoryClass, // repositoryClass: optional, See "Overriding repository" for more detail | ||
'products', // key: mandatory, will be passed in your serializer | ||
'my_products', // pathRoot: optional, the endpoint of your API: will be added to the mapping prefix ('/v1' here) | ||
SomeRepositoryClass // repositoryClass: optional, See "Overriding repository" for more detail | ||
); | ||
const idAttr = new Attribute( | ||
'@id', // serializedKey: mandatory, the key returned from your API | ||
'id', // attributeName: optional, the name in your entity, default to the `serializedKey` attribute | ||
'string', // type: optional, default to `string` | ||
true // isIdentifier: optional, default to `false` | ||
'@id', // serializedKey: mandatory, the key returned from your API | ||
'id', // attributeName: optional, the name in your entity, default to the `serializedKey` attribute | ||
'string', // type: optional, default to `string` | ||
true // isIdentifier: optional, default to `false` | ||
); | ||
const name = new Attribute('name'); | ||
productMetadata.setAttributeList([ idAttr, name ]); | ||
productMetadata.setAttributeList([idAttr, name]); | ||
productMetadata.setRelationList([ | ||
new Relation( | ||
Relation.ONE_TO_MANY, // type: Relation.ONE_TO_MANY or Relation.MANY_TO_ONE | ||
'categories', // targetMetadataKey: must match the first argument of `ClassMetadata` constructor of the target entity | ||
'category_list', // serializedKey: the key returned from your API | ||
'categoryList', // attributeName: optional, the name in your entity, default to the `serializedKey` attribute | ||
Relation.ONE_TO_MANY, // type: Relation.ONE_TO_MANY or Relation.MANY_TO_ONE | ||
'categories', // targetMetadataKey: must match the first argument of `ClassMetadata` constructor of the target entity | ||
'category_list', // serializedKey: the key returned from your API | ||
'categoryList' // attributeName: optional, the name in your entity, default to the `serializedKey` attribute | ||
), | ||
@@ -48,4 +48,4 @@ ]); | ||
categoryMetadata.setAttributeList([ | ||
new Attribute('id', 'id', 'string', true), | ||
new Attribute('name'), | ||
new Attribute('id', 'id', 'string', true), | ||
new Attribute('name'), | ||
]); | ||
@@ -56,6 +56,3 @@ categoryMetadata.setRelationList([ | ||
mapping.setMapping([ | ||
productMetadata, | ||
categoryMetadata, | ||
]); | ||
mapping.setMapping([productMetadata, categoryMetadata]); | ||
``` | ||
@@ -153,5 +150,5 @@ | ||
* `deserializeItem(rawData, type)` (type is the key of the mapping) | ||
* `deserializeList(rawListData, type)` (type is the key of the mapping) | ||
* `serializeItem(item, type)` (type is the key of the mapping) | ||
- `deserializeItem(rawData, classMetadata)` (`classMetadata` is the instance of ClassMetadata you configured) | ||
- `deserializeList(rawListData, classMetadata)` (`classMetadata` is the instance of ClassMetadata you configured) | ||
- `serializeItem(item, classMetadata)` (`classMetadata` is the instance of ClassMetadata you configured) | ||
@@ -171,3 +168,3 @@ All text response from GET / PUT / POST request will be send to | ||
class JsSerializer extends Serializer { | ||
deserializeItem(rawData, type) { | ||
deserializeItem(rawData, classMetadata) { | ||
// do stuff with your item input | ||
@@ -177,3 +174,3 @@ return JSON.parse(rawData); | ||
deserializeList(rawListData, type) { | ||
deserializeList(rawListData, classMetadata) { | ||
// do stuff with your list input | ||
@@ -183,3 +180,3 @@ return JSON.parse(rawListData); | ||
serializeItem(entity, type) { | ||
serializeItem(entity, classMetadata) { | ||
// prepare item for being sent in a request | ||
@@ -186,0 +183,0 @@ return JSON.stringify(entity); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
491948
54
6557
6
36
1
184