@odata2ts/http-client-api 0.5.1 → 0.6.1

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 CHANGED
@@ -3,6 +3,26 @@
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.1](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.6.0...@odata2ts/http-client-api@0.6.1) (2024-08-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ * add ".js" suffix for all relative imports ([#20](https://github.com/odata2ts/http-client/issues/20)) ([961c910](https://github.com/odata2ts/http-client/commit/961c91002c8b1e9a7a6256cccd6b6d0ec9c142cd))
11
+
12
+ # [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)
13
+
14
+ ### Code Refactoring
15
+
16
+ * switch to vitest & ESM ([#18](https://github.com/odata2ts/http-client/issues/18)) ([748558f](https://github.com/odata2ts/http-client/commit/748558f1e3f699085ade1058b1459c843f60994f))
17
+
18
+ ### Features
19
+
20
+ * blob and stream support ([#12](https://github.com/odata2ts/http-client/issues/12)) ([ae6f062](https://github.com/odata2ts/http-client/commit/ae6f062371a0ad11707fa3f9edff9571998edb5b))
21
+
22
+ ### BREAKING CHANGES
23
+
24
+ * switch to ESM tends to break stuff
25
+
6
26
  ## [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)
7
27
 
8
28
  **Note:** Version bump only for package @odata2ts/http-client-api
package/README.md CHANGED
@@ -1,46 +1,52 @@
1
- [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/http-client-api?style=for-the-badge)](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
- - HTTP request execution
9
- - mapping responses to conventionalized structures
10
- - custom request configuration (optional)
11
- - automatic CSRF Token Handling (optional)
12
-
13
- Features like **optimistic locking** (via `ETag`) or **batch requests** are currently not in scope
14
- of the HTTP client and may never be.
15
-
16
- ## Documentation
17
- [HTTP Client Documentation](https://odata2ts.github.io/docs/odata-client/http-client)
18
-
19
- Main documentation for the odata2ts eco system:
20
- [https://odata2ts.github.io](https://odata2ts.github.io/)
21
-
22
- ## Tests
23
- As this library provides the API as TypeScript types, there are no runtime
24
- artefacts to test.
25
-
26
- ## Support, Feedback, Contributing
27
- This project is open to feature requests, suggestions, bug reports, usage questions etc.
28
- via [GitHub issues](https://github.com/odata2ts/odata2ts/issues).
29
-
30
- Contributions and feedback are encouraged and always welcome.
31
-
32
- See the [contribution guidelines](https://github.com/odata2ts/odata2ts/blob/main/CONTRIBUTING.md) for further information.
33
-
34
- ## Spirit
35
- This project and this module have been created and are maintained in the following spirit:
36
-
37
- * adhere to the **OData specification** as much as possible
38
- * support any OData service implementation which conforms to the spec
39
- * allow to work around faulty implementations if possible
40
- * stability matters
41
- * exercise Test Driven Development
42
- * bomb the place with unit tests (code coverage > 95%)
43
- * ensure that assumptions & understanding are correct by creating integration tests
44
-
45
- ## License
46
- MIT - see [License](./LICENSE).
1
+ [![npm (scoped)](https://img.shields.io/npm/v/@odata2ts/http-client-api?style=for-the-badge)](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).
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=ODataClientError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ODataClientError.js","sourceRoot":"","sources":["../src/ODataClientError.ts"],"names":[],"mappings":"","sourcesContent":["export interface ODataClientError {\r\n readonly name: string;\r\n readonly status?: number;\r\n readonly headers?: Record<string, string>;\r\n readonly cause?: Error;\r\n}\r\n"]}
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"]}
@@ -40,4 +40,33 @@ export interface ODataHttpClient<RequestConfig = any> {
40
40
  * @param additionalHeaders
41
41
  */
42
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
70
+ */
71
+ updateBlob(url: string, data: Blob, mimeType: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void | Blob>;
43
72
  }
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=ODataHttpClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ODataHttpClient.js","sourceRoot":"","sources":["../src/ODataHttpClient.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataResponse } from \"./ODataResponseModel\";\r\n\r\n/**\r\n * Retrieves the configuration type for the given HTTP client.\r\n */\r\nexport type ODataHttpClientConfig<ClientType extends ODataHttpClient> = ClientType extends ODataHttpClient<infer Config>\r\n ? Config\r\n : never;\r\n\r\nexport interface ODataHttpClient<RequestConfig = any> {\r\n /**\r\n * Create a model or collection entry.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n post<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>\r\n ): ODataResponse<ResponseModel>;\r\n\r\n get<ResponseModel>(\r\n url: string,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Replace a model.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n put<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Partially update a model.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n patch<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Delete a model or collection.\r\n *\r\n * @param url\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n delete(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void>;\r\n}\r\n"]}
1
+ {"version":3,"file":"ODataHttpClient.js","sourceRoot":"","sources":["../src/ODataHttpClient.ts"],"names":[],"mappings":"","sourcesContent":["import { ODataResponse } from \"./ODataResponseModel\";\r\n\r\n/**\r\n * Retrieves the configuration type for the given HTTP client.\r\n */\r\nexport type ODataHttpClientConfig<ClientType extends ODataHttpClient> =\r\n ClientType extends ODataHttpClient<infer Config> ? Config : never;\r\n\r\nexport interface ODataHttpClient<RequestConfig = any> {\r\n /**\r\n * Create a model or collection entry.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n post<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<ResponseModel>;\r\n\r\n get<ResponseModel>(\r\n url: string,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Replace a model.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n put<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Partially update a model.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n patch<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * Delete a model or collection.\r\n *\r\n * @param url\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n delete(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<void>;\r\n\r\n /**\r\n * Get binary data (Edm.Stream) as Blob.\r\n *\r\n * @param url\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n getBlob(url: string, requestConfig?: RequestConfig, additionalHeaders?: Record<string, string>): ODataResponse<Blob>;\r\n\r\n /**\r\n * Get binary data (Edm.Stream) as ReadableStream.\r\n *\r\n * Cannot be supported by HTTP clients based on XmlHttpRequest, e.g. axios.\r\n * Should throw an error in this case.\r\n *\r\n * @param url\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n getStream(\r\n url: string,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<ReadableStream>;\r\n\r\n /**\r\n * Updates binary data (Edm.Stream).\r\n *\r\n * @param url\r\n * @param data\r\n * @param mimeType\r\n * @param requestConfig\r\n * @param additionalHeaders\r\n */\r\n updateBlob(\r\n url: string,\r\n data: Blob,\r\n mimeType: string,\r\n requestConfig?: RequestConfig,\r\n additionalHeaders?: Record<string, string>,\r\n ): ODataResponse<void | Blob>;\r\n}\r\n"]}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=ODataResponseModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ODataResponseModel.js","sourceRoot":"","sources":["../src/ODataResponseModel.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * This model represents the response for any completed HTTP request.\r\n */\r\nexport interface HttpResponseModel<T> {\r\n /** status code, e.g. 200 or 404 */\r\n status: number;\r\n /** status text, e.g. 200 = \"OK\" or 404 = \"Not Found\" */\r\n statusText: string;\r\n /** response headers as key value pairs */\r\n headers: { [key: string]: string };\r\n // config?: any;\r\n /** response data */\r\n data: T;\r\n}\r\n\r\n/**\r\n * Wrapping response instance, containing status code info, headers\r\n * and the response body.\r\n */\r\nexport type ODataResponse<T> = Promise<HttpResponseModel<T>>;\r\n"]}
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.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./ODataResponseModel";
2
- export * from "./ODataHttpClient";
3
- export * from "./ODataClientError";
1
+ export * from "./ODataResponseModel.js";
2
+ export * from "./ODataHttpClient.js";
3
+ export * from "./ODataClientError.js";
package/lib/index.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
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.js";
2
+ export * from "./ODataHttpClient.js";
3
+ export * from "./ODataClientError.js";
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":";;;AAAA,+DAAqC;AACrC,4DAAkC;AAClC,6DAAmC","sourcesContent":["export * from \"./ODataResponseModel\";\r\nexport * from \"./ODataHttpClient\";\r\nexport * from \"./ODataClientError\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./ODataResponseModel.js\";\r\nexport * from \"./ODataHttpClient.js\";\r\nexport * from \"./ODataClientError.js\";\r\n"]}
package/package.json CHANGED
@@ -1,43 +1,39 @@
1
1
  {
2
2
  "name": "@odata2ts/http-client-api",
3
- "version": "0.5.1",
4
- "publishConfig": {
5
- "access": "public"
6
- },
3
+ "version": "0.6.1",
7
4
  "description": "Specifies the contract between HTTP clients and odata2ts",
8
- "license": "MIT",
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
- "types": "./lib/index.d.ts",
42
- "gitHead": "0886c9e292a84560001d4c4e4503babf3809e1d7"
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "232521cbfae692d00900237845bd317b11e442d2"
43
39
  }