@jfront/core-rest
Advanced tools
Comparing version 0.1.0-rc.0 to 0.1.0
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
# [0.1.0](https://github.com/Jepria/jfront-core/compare/@jfront/core-rest@0.1.0-rc.0...@jfront/core-rest@0.1.0) (2021-01-18) | ||
### Features | ||
* generic primary key for rest connectors ([da9d27d](https://github.com/Jepria/jfront-core/commit/da9d27daa4be402a1cda9c58b4ec27b1ffe656a0)) | ||
# Change Log | ||
All notable changes to this project will be documented in this file. See | ||
@@ -4,0 +20,0 @@ [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -43,3 +43,3 @@ "use strict"; | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -54,3 +54,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -87,3 +87,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -96,3 +96,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -125,3 +125,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -141,3 +141,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -144,0 +144,0 @@ } |
@@ -17,5 +17,5 @@ "use strict"; | ||
/** | ||
* Standard jepria-rest CRUD RESTful API connector. | ||
* Standard jepria-rest Search RESTful API connector. | ||
* @example | ||
* let connector: ConnectorCrud<Dto, CreateDto, UpdateDto, Template> = new ConnectorCrud("http://localhost:8080/feature/api/feature"); | ||
* let connector: ConnectorSearch<Dto, SearchTemplate> = new ConnectorSearch("http://localhost:8080/feature/api/feature"); | ||
*/ | ||
@@ -44,3 +44,3 @@ var ConnectorSearch = /*#__PURE__*/function (_ConnectorBase) { | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -70,3 +70,3 @@ "Cache-Control": cacheControl | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -97,3 +97,3 @@ "Cache-Control": cacheControl | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -100,0 +100,0 @@ "Cache-Control": cacheControl |
"use strict"; | ||
exports.__esModule = true; | ||
exports.handleAxiosError = exports.buildError = void 0; | ||
exports.buildError = exports.handleAxiosError = void 0; | ||
@@ -9,9 +9,44 @@ var _types = require("./types"); | ||
/** | ||
* Обработка ошибки Axios. | ||
* | ||
* Axios error handling. | ||
* @param {AxiosError} error | ||
* @returns {NetworkError} | ||
*/ | ||
var handleAxiosError = function handleAxiosError(error) { | ||
if (error != null && error.response) { | ||
/* | ||
* The request was made and the server responded with a | ||
* status code that falls out of the range of 2xx | ||
*/ | ||
return buildError(error.response); | ||
} else if (error != null && error.request) { | ||
/* | ||
* The request was made but no response was received, `error.request` | ||
* is an instance of XMLHttpRequest in the browser and an instance | ||
* of http.ClientRequest in Node.js | ||
*/ | ||
return { | ||
type: _types.SERVER_ERROR, | ||
errorMessage: error == null ? void 0 : error.message | ||
}; | ||
} else { | ||
// Something happened in setting up the request and triggered an Error | ||
throw new Error(error == null ? void 0 : error.message); | ||
} | ||
}; | ||
/** | ||
* Получение ошибки из ответа. | ||
* | ||
* Building error object from response. | ||
* @param AxiosResponse response | ||
* @param AxiosResponse response | ||
*/ | ||
exports.handleAxiosError = handleAxiosError; | ||
var buildError = function buildError(response) { | ||
var error; | ||
switch (response.status) { | ||
switch (response == null ? void 0 : response.status) { | ||
case 400: | ||
@@ -70,35 +105,4 @@ { | ||
}; | ||
/** | ||
* Axios error handling. | ||
* @param {AxiosError} error | ||
* @returns {NetworkError} | ||
*/ | ||
exports.buildError = buildError; | ||
var handleAxiosError = function handleAxiosError(error) { | ||
if (error.response) { | ||
/* | ||
* The request was made and the server responded with a | ||
* status code that falls out of the range of 2xx | ||
*/ | ||
return buildError(error.response); | ||
} else if (error.request) { | ||
/* | ||
* The request was made but no response was received, `error.request` | ||
* is an instance of XMLHttpRequest in the browser and an instance | ||
* of http.ClientRequest in Node.js | ||
*/ | ||
return { | ||
type: _types.SERVER_ERROR, | ||
errorMessage: error == null ? void 0 : error.message | ||
}; | ||
} else { | ||
// Something happened in setting up the request and triggered an Error | ||
throw new Error(error.message); | ||
} | ||
}; | ||
exports.handleAxiosError = handleAxiosError; | ||
//# sourceMappingURL=Errors.js.map |
@@ -0,0 +0,0 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } |
@@ -28,3 +28,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -39,3 +39,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -68,3 +68,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -77,3 +77,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -102,3 +102,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -116,3 +116,3 @@ } | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8" | ||
@@ -119,0 +119,0 @@ } |
@@ -7,5 +7,5 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
* Standard jepria-rest CRUD RESTful API connector. | ||
* Standard jepria-rest Search RESTful API connector. | ||
* @example | ||
* let connector: ConnectorCrud<Dto, CreateDto, UpdateDto, Template> = new ConnectorCrud("http://localhost:8080/feature/api/feature"); | ||
* let connector: ConnectorSearch<Dto, SearchTemplate> = new ConnectorSearch("http://localhost:8080/feature/api/feature"); | ||
*/ | ||
@@ -29,3 +29,3 @@ export class ConnectorSearch extends ConnectorBase { | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -53,3 +53,3 @@ "Cache-Control": cacheControl | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -78,3 +78,3 @@ "Cache-Control": cacheControl | ||
headers: { | ||
"Accept": "application/json;charset=utf-8", | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
@@ -81,0 +81,0 @@ "Cache-Control": cacheControl |
import { ACCESS_DENIED, AUTHORIZATION_FAILED, BAD_REQUEST, NOT_FOUND, SERVER_ERROR } from "./types"; | ||
/** | ||
* Обработка ошибки Axios. | ||
* | ||
* Axios error handling. | ||
* @param {AxiosError} error | ||
* @returns {NetworkError} | ||
*/ | ||
export var handleAxiosError = error => { | ||
if (error != null && error.response) { | ||
/* | ||
* The request was made and the server responded with a | ||
* status code that falls out of the range of 2xx | ||
*/ | ||
return buildError(error.response); | ||
} else if (error != null && error.request) { | ||
/* | ||
* The request was made but no response was received, `error.request` | ||
* is an instance of XMLHttpRequest in the browser and an instance | ||
* of http.ClientRequest in Node.js | ||
*/ | ||
return { | ||
type: SERVER_ERROR, | ||
errorMessage: error == null ? void 0 : error.message | ||
}; | ||
} else { | ||
// Something happened in setting up the request and triggered an Error | ||
throw new Error(error == null ? void 0 : error.message); | ||
} | ||
}; | ||
/** | ||
* Получение ошибки из ответа. | ||
* | ||
* Building error object from response. | ||
* @param AxiosResponse response | ||
* @param AxiosResponse response | ||
*/ | ||
@@ -10,3 +42,3 @@ | ||
switch (response.status) { | ||
switch (response == null ? void 0 : response.status) { | ||
case 400: | ||
@@ -65,30 +97,2 @@ { | ||
}; | ||
/** | ||
* Axios error handling. | ||
* @param {AxiosError} error | ||
* @returns {NetworkError} | ||
*/ | ||
export var handleAxiosError = error => { | ||
if (error.response) { | ||
/* | ||
* The request was made and the server responded with a | ||
* status code that falls out of the range of 2xx | ||
*/ | ||
return buildError(error.response); | ||
} else if (error.request) { | ||
/* | ||
* The request was made but no response was received, `error.request` | ||
* is an instance of XMLHttpRequest in the browser and an instance | ||
* of http.ClientRequest in Node.js | ||
*/ | ||
return { | ||
type: SERVER_ERROR, | ||
errorMessage: error == null ? void 0 : error.message | ||
}; | ||
} else { | ||
// Something happened in setting up the request and triggered an Error | ||
throw new Error(error.message); | ||
} | ||
}; | ||
//# sourceMappingURL=Errors.js.map |
@@ -0,0 +0,0 @@ import { AxiosInstance } from 'axios'; |
@@ -7,3 +7,3 @@ import { ConnectorBase } from "./ConnectorBase"; | ||
*/ | ||
export declare class ConnectorCrud<Dto, CreateDto, UpdateDto> extends ConnectorBase { | ||
export declare class ConnectorCrud<Dto, PrimaryKey = string, CreateDto = Dto, UpdateDto = Dto> extends ConnectorBase { | ||
private axios; | ||
@@ -19,3 +19,3 @@ /** | ||
* Record updating. | ||
* @param {string} id record primary id | ||
* @param {PrimaryKey} id record primary id | ||
* @param {UpdateDto} updateDto record update DTO | ||
@@ -25,3 +25,3 @@ * @param {boolean} getRecordById optional flag, if true getRecordById will be called after create (default true). | ||
*/ | ||
update: (id: string, updateDto: UpdateDto, getRecordById?: boolean) => Promise<Dto | void>; | ||
update: (id: PrimaryKey, updateDto: UpdateDto, getRecordById?: boolean) => Promise<Dto | void>; | ||
/** | ||
@@ -31,3 +31,3 @@ * Record deletion. | ||
*/ | ||
delete: (id: string) => Promise<void>; | ||
delete: (id: PrimaryKey) => Promise<void>; | ||
/** | ||
@@ -37,3 +37,3 @@ * Get record by id. | ||
*/ | ||
getRecordById: (id: string) => Promise<Dto>; | ||
getRecordById: (id: PrimaryKey) => Promise<Dto>; | ||
} |
import { ConnectorBase } from "./ConnectorBase"; | ||
import { SearchRequest } from "./types"; | ||
/** | ||
* Standard jepria-rest CRUD RESTful API connector. | ||
* Standard jepria-rest Search RESTful API connector. | ||
* @example | ||
* let connector: ConnectorCrud<Dto, CreateDto, UpdateDto, Template> = new ConnectorCrud("http://localhost:8080/feature/api/feature"); | ||
* let connector: ConnectorSearch<Dto, SearchTemplate> = new ConnectorSearch("http://localhost:8080/feature/api/feature"); | ||
*/ | ||
@@ -8,0 +8,0 @@ export declare class ConnectorSearch<Dto, SearchTemplate> extends ConnectorBase { |
import { AxiosError, AxiosResponse } from "axios"; | ||
import { NetworkError } from "./types"; | ||
/** | ||
* Building error object from response. | ||
* @param AxiosResponse response | ||
*/ | ||
export declare const buildError: (response: AxiosResponse) => NetworkError; | ||
/** | ||
* Обработка ошибки Axios. | ||
* | ||
* Axios error handling. | ||
@@ -14,1 +11,8 @@ * @param {AxiosError} error | ||
export declare const handleAxiosError: (error: AxiosError) => NetworkError; | ||
/** | ||
* Получение ошибки из ответа. | ||
* | ||
* Building error object from response. | ||
* @param AxiosResponse response | ||
*/ | ||
export declare const buildError: (response: AxiosResponse) => NetworkError; |
@@ -0,0 +0,0 @@ export declare const BAD_REQUEST = 400; |
@@ -0,0 +0,0 @@ export * from "./api/Errors"; |
{ | ||
"name": "@jfront/core-rest", | ||
"version": "0.1.0-rc.0", | ||
"version": "0.1.0", | ||
"license": "Apache-2.0", | ||
@@ -37,3 +37,3 @@ "main": "dist/cjs/index.js", | ||
}, | ||
"gitHead": "d8c24e44b268ccd7ddc48a091be722a751894022" | ||
"gitHead": "487771e31f8825ceffaafd8cc3b62717398c7fe8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
907
96362