@odata2ts/http-client-api 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +52 -46
- package/lib/ODataClientError.js +1 -2
- package/lib/ODataClientError.js.map +1 -1
- package/lib/ODataHttpClient.d.ts +38 -19
- package/lib/ODataHttpClient.js +1 -2
- package/lib/ODataHttpClient.js.map +1 -1
- package/lib/ODataResponseModel.js +1 -2
- package/lib/ODataResponseModel.js.map +1 -1
- package/lib/index.js +3 -6
- package/lib/index.js.map +1 -1
- package/package.json +21 -25
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.6.0](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.5.1...@odata2ts/http-client-api@0.6.0) (2024-08-13)
|
|
7
|
+
|
|
8
|
+
### Code Refactoring
|
|
9
|
+
|
|
10
|
+
* switch to vitest & ESM ([#18](https://github.com/odata2ts/http-client/issues/18)) ([748558f](https://github.com/odata2ts/http-client/commit/748558f1e3f699085ade1058b1459c843f60994f))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* blob and stream support ([#12](https://github.com/odata2ts/http-client/issues/12)) ([ae6f062](https://github.com/odata2ts/http-client/commit/ae6f062371a0ad11707fa3f9edff9571998edb5b))
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* switch to ESM tends to break stuff
|
|
19
|
+
|
|
20
|
+
## [0.5.1](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.5.0...@odata2ts/http-client-api@0.5.1) (2023-09-13)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package @odata2ts/http-client-api
|
|
23
|
+
|
|
6
24
|
# [0.5.0](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.4.0...@odata2ts/http-client-api@0.5.0) (2023-09-13)
|
|
7
25
|
|
|
8
26
|
### Code Refactoring
|
package/README.md
CHANGED
|
@@ -1,46 +1,52 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/@odata2ts/http-client-api)
|
|
2
|
-
|
|
3
|
-
# HTTP Client API
|
|
4
|
-
|
|
5
|
-
Defines the contract between [odata2ts](https://github.com/odata2ts/odata2ts) and any HTTP client implementation.
|
|
6
|
-
|
|
7
|
-
The responsibilities of the HTTP Client are:
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
[](https://www.npmjs.com/package/@odata2ts/http-client-api)
|
|
2
|
+
|
|
3
|
+
# HTTP Client API
|
|
4
|
+
|
|
5
|
+
Defines the contract between [odata2ts](https://github.com/odata2ts/odata2ts) and any HTTP client implementation.
|
|
6
|
+
|
|
7
|
+
The responsibilities of the HTTP Client are:
|
|
8
|
+
|
|
9
|
+
- HTTP request execution
|
|
10
|
+
- mapping responses to conventionalized structures
|
|
11
|
+
- custom request configuration (optional)
|
|
12
|
+
- automatic CSRF Token Handling (optional)
|
|
13
|
+
|
|
14
|
+
Features like **optimistic locking** (via `ETag`) or **batch requests** are currently not in scope
|
|
15
|
+
of the HTTP client and may never be.
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
[HTTP Client Documentation](https://odata2ts.github.io/docs/odata-client/http-client)
|
|
20
|
+
|
|
21
|
+
Main documentation for the odata2ts eco system:
|
|
22
|
+
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
23
|
+
|
|
24
|
+
## Tests
|
|
25
|
+
|
|
26
|
+
As this library provides the API as TypeScript types, there are no runtime
|
|
27
|
+
artefacts to test.
|
|
28
|
+
|
|
29
|
+
## Support, Feedback, Contributing
|
|
30
|
+
|
|
31
|
+
This project is open to feature requests, suggestions, bug reports, usage questions etc.
|
|
32
|
+
via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
|
|
33
|
+
|
|
34
|
+
Contributions and feedback are encouraged and always welcome.
|
|
35
|
+
|
|
36
|
+
See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
|
|
37
|
+
|
|
38
|
+
## Spirit
|
|
39
|
+
|
|
40
|
+
This project and this module have been created and are maintained in the following spirit:
|
|
41
|
+
|
|
42
|
+
- adhere to the **OData specification** as much as possible
|
|
43
|
+
- support any OData service implementation which conforms to the spec
|
|
44
|
+
- allow to work around faulty implementations if possible
|
|
45
|
+
- stability matters
|
|
46
|
+
- exercise Test Driven Development
|
|
47
|
+
- bomb the place with unit tests (code coverage > 95%)
|
|
48
|
+
- ensure that assumptions & understanding are correct by creating integration tests
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT - see [License](./LICENSE).
|
package/lib/ODataClientError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataClientError.js","sourceRoot":"","sources":["../src/ODataClientError.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataClientError {\
|
|
1
|
+
{"version":3,"file":"ODataClientError.js","sourceRoot":"","sources":["../src/ODataClientError.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataClientError {\n readonly name: string;\n readonly status?: number;\n readonly headers?: Record<string, string>;\n readonly cause?: Error;\n}\n"]}
|
package/lib/ODataHttpClient.d.ts
CHANGED
|
@@ -3,16 +3,6 @@ import { ODataResponse } from "./ODataResponseModel";
|
|
|
3
3
|
* Retrieves the configuration type for the given HTTP client.
|
|
4
4
|
*/
|
|
5
5
|
export type ODataHttpClientConfig<ClientType extends ODataHttpClient> = ClientType extends ODataHttpClient<infer Config> ? Config : never;
|
|
6
|
-
export interface InternalHttpClientConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Additional headers set internally by services or HttpClient implementation.
|
|
9
|
-
*/
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
|
-
/**
|
|
12
|
-
* Very special option needed for FetchClient to not evaluate the response body in certain situations.
|
|
13
|
-
*/
|
|
14
|
-
noBodyEvaluation?: boolean;
|
|
15
|
-
}
|
|
16
6
|
export interface ODataHttpClient<RequestConfig = any> {
|
|
17
7
|
/**
|
|
18
8
|
* Create a model or collection entry.
|
|
@@ -20,34 +10,63 @@ export interface ODataHttpClient<RequestConfig = any> {
|
|
|
20
10
|
* @param url
|
|
21
11
|
* @param data
|
|
22
12
|
* @param requestConfig
|
|
23
|
-
* @param
|
|
13
|
+
* @param additionalHeaders
|
|
24
14
|
*/
|
|
25
|
-
post<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig,
|
|
26
|
-
get<ResponseModel>(url: string, requestConfig?: RequestConfig,
|
|
15
|
+
post<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<ResponseModel>;
|
|
16
|
+
get<ResponseModel>(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<ResponseModel>;
|
|
27
17
|
/**
|
|
28
18
|
* Replace a model.
|
|
29
19
|
*
|
|
30
20
|
* @param url
|
|
31
21
|
* @param data
|
|
32
22
|
* @param requestConfig
|
|
33
|
-
* @param
|
|
23
|
+
* @param additionalHeaders
|
|
34
24
|
*/
|
|
35
|
-
put<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig,
|
|
25
|
+
put<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<ResponseModel>;
|
|
36
26
|
/**
|
|
37
27
|
* Partially update a model.
|
|
38
28
|
*
|
|
39
29
|
* @param url
|
|
40
30
|
* @param data
|
|
41
31
|
* @param requestConfig
|
|
42
|
-
* @param
|
|
32
|
+
* @param additionalHeaders
|
|
43
33
|
*/
|
|
44
|
-
patch<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig,
|
|
34
|
+
patch<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<ResponseModel>;
|
|
45
35
|
/**
|
|
46
36
|
* Delete a model or collection.
|
|
47
37
|
*
|
|
48
38
|
* @param url
|
|
49
39
|
* @param requestConfig
|
|
50
|
-
* @param
|
|
40
|
+
* @param additionalHeaders
|
|
41
|
+
*/
|
|
42
|
+
delete(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Get binary data (Edm.Stream) as Blob.
|
|
45
|
+
*
|
|
46
|
+
* @param url
|
|
47
|
+
* @param requestConfig
|
|
48
|
+
* @param additionalHeaders
|
|
49
|
+
*/
|
|
50
|
+
getBlob(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<Blob>;
|
|
51
|
+
/**
|
|
52
|
+
* Get binary data (Edm.Stream) as ReadableStream.
|
|
53
|
+
*
|
|
54
|
+
* Cannot be supported by HTTP clients based on XmlHttpRequest, e.g. axios.
|
|
55
|
+
* Should throw an error in this case.
|
|
56
|
+
*
|
|
57
|
+
* @param url
|
|
58
|
+
* @param requestConfig
|
|
59
|
+
* @param additionalHeaders
|
|
60
|
+
*/
|
|
61
|
+
getStream(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<ReadableStream>;
|
|
62
|
+
/**
|
|
63
|
+
* Updates binary data (Edm.Stream).
|
|
64
|
+
*
|
|
65
|
+
* @param url
|
|
66
|
+
* @param data
|
|
67
|
+
* @param mimeType
|
|
68
|
+
* @param requestConfig
|
|
69
|
+
* @param additionalHeaders
|
|
51
70
|
*/
|
|
52
|
-
|
|
71
|
+
updateBlob(url: string, data: Blob, mimeType: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void | Blob>;
|
|
53
72
|
}
|
package/lib/ODataHttpClient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataHttpClient.js","sourceRoot":"","sources":["../src/ODataHttpClient.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataResponse } from \"./ODataResponseModel\";\
|
|
1
|
+
{"version":3,"file":"ODataHttpClient.js","sourceRoot":"","sources":["../src/ODataHttpClient.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataResponse } from \"./ODataResponseModel\";\n\n/**\n * Retrieves the configuration type for the given HTTP client.\n */\nexport type ODataHttpClientConfig<ClientType extends ODataHttpClient> =\n ClientType extends ODataHttpClient<infer Config> ? Config : never;\n\nexport interface ODataHttpClient<RequestConfig = any> {\n /**\n * Create a model or collection entry.\n *\n * @param url\n * @param data\n * @param requestConfig\n * @param additionalHeaders\n */\n post<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<ResponseModel>;\n\n get<ResponseModel>(\n url: string,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<ResponseModel>;\n\n /**\n * Replace a model.\n *\n * @param url\n * @param data\n * @param requestConfig\n * @param additionalHeaders\n */\n put<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<ResponseModel>;\n\n /**\n * Partially update a model.\n *\n * @param url\n * @param data\n * @param requestConfig\n * @param additionalHeaders\n */\n patch<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<ResponseModel>;\n\n /**\n * Delete a model or collection.\n *\n * @param url\n * @param requestConfig\n * @param additionalHeaders\n */\n delete(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void>;\n\n /**\n * Get binary data (Edm.Stream) as Blob.\n *\n * @param url\n * @param requestConfig\n * @param additionalHeaders\n */\n getBlob(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<Blob>;\n\n /**\n * Get binary data (Edm.Stream) as ReadableStream.\n *\n * Cannot be supported by HTTP clients based on XmlHttpRequest, e.g. axios.\n * Should throw an error in this case.\n *\n * @param url\n * @param requestConfig\n * @param additionalHeaders\n */\n getStream(\n url: string,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<ReadableStream>;\n\n /**\n * Updates binary data (Edm.Stream).\n *\n * @param url\n * @param data\n * @param mimeType\n * @param requestConfig\n * @param additionalHeaders\n */\n updateBlob(\n url: string,\n data: Blob,\n mimeType: string,\n requestConfig?: RequestConfig,\n additionalHeaders?: Record<string, string>,\n ): ODataResponse<void | Blob>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ODataResponseModel.js","sourceRoot":"","sources":["../src/ODataResponseModel.ts"],"names":[],"mappings":"","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"ODataResponseModel.js","sourceRoot":"","sources":["../src/ODataResponseModel.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This model represents the response for any completed HTTP request.\n */\nexport interface HttpResponseModel<T> {\n /** status code, e.g. 200 or 404 */\n status: number;\n /** status text, e.g. 200 = \"OK\" or 404 = \"Not Found\" */\n statusText: string;\n /** response headers as key value pairs */\n headers: { [key: string]: string };\n // config?: any;\n /** response data */\n data: T;\n}\n\n/**\n * Wrapping response instance, containing status code info, headers\n * and the response body.\n */\nexport type ODataResponse<T> = Promise<HttpResponseModel<T>>;\n"]}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./ODataResponseModel"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ODataHttpClient"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./ODataClientError"), exports);
|
|
1
|
+
export * from "./ODataResponseModel";
|
|
2
|
+
export * from "./ODataHttpClient";
|
|
3
|
+
export * from "./ODataClientError";
|
|
7
4
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./ODataResponseModel\";\nexport * from \"./ODataHttpClient\";\nexport * from \"./ODataClientError\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/http-client-api",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
3
|
+
"version": "0.6.0",
|
|
7
4
|
"description": "Specifies the contract between HTTP clients and odata2ts",
|
|
8
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"http client",
|
|
7
|
+
"api",
|
|
8
|
+
"odata2ts",
|
|
9
|
+
"ts",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
9
12
|
"repository": "git@github.com:odata2ts/http-client.git",
|
|
13
|
+
"license": "MIT",
|
|
10
14
|
"author": "texttechne",
|
|
15
|
+
"type": "module",
|
|
11
16
|
"main": "./lib/index.js",
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"*.md",
|
|
20
|
+
"lib",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
12
23
|
"scripts": {
|
|
13
24
|
"build": "yarn clean && yarn compile",
|
|
14
25
|
"check-circular-deps": "madge ./src --extensions ts --circular",
|
|
15
26
|
"clean": "rimraf lib coverage",
|
|
16
27
|
"compile": "tsc",
|
|
17
|
-
"prepublish": "yarn build"
|
|
18
|
-
"test": "jest --passWithNoTests"
|
|
28
|
+
"prepublish": "yarn build"
|
|
19
29
|
},
|
|
20
|
-
"files": [
|
|
21
|
-
"*.md",
|
|
22
|
-
"lib",
|
|
23
|
-
"LICENSE"
|
|
24
|
-
],
|
|
25
|
-
"keywords": [
|
|
26
|
-
"http client",
|
|
27
|
-
"api",
|
|
28
|
-
"odata2ts",
|
|
29
|
-
"ts",
|
|
30
|
-
"typescript"
|
|
31
|
-
],
|
|
32
30
|
"devDependencies": {
|
|
33
|
-
"@types/jest": "^27.4.1",
|
|
34
31
|
"@types/node": "^20.2.5",
|
|
35
|
-
"jest": "29.5.0",
|
|
36
32
|
"rimraf": "^5.0.1",
|
|
37
|
-
"ts-jest": "^29.1.0",
|
|
38
|
-
"ts-node": "10.9.1",
|
|
39
33
|
"typescript": "5.0.4"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "6a0905bd7f201a5c91d83a9319c2a0325a017651"
|
|
43
39
|
}
|