@odata2ts/http-client-api 0.3.0 → 0.5.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 CHANGED
@@ -3,6 +3,36 @@
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.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
+
8
+ ### Code Refactoring
9
+
10
+ * expand additionalHeaders param to internalConfig ([#15](https://github.com/odata2ts/http-client/issues/15)) ([7fe1d73](https://github.com/odata2ts/http-client/commit/7fe1d73a7436f64b84a060bd1dbf9e121ef901ce))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * additional headers are now part of the config parameter
15
+
16
+ * fix: don't lose configuration when CSRF token is active
17
+
18
+ * add new option which prevents FetchClient from evaluating response body (not needed for fetching csrf tokens & makes trouble with SAP's mockServer)
19
+
20
+ * fix: add headers for content-type and accept for main methods
21
+
22
+ # [0.4.0](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.3.0...@odata2ts/http-client-api@0.4.0) (2023-08-03)
23
+
24
+ ### Code Refactoring
25
+
26
+ * **api:** remove merge & retrieveBigNumbersAsString methods ([a99f89e](https://github.com/odata2ts/http-client/commit/a99f89ee7782733ba75543b3abd03a3060e5e7dc))
27
+
28
+ ### Features
29
+
30
+ * **api:** additional headers for all operations ([#9](https://github.com/odata2ts/http-client/issues/9)) ([6379511](https://github.com/odata2ts/http-client/commit/637951126118aeb020d68ce16e48ea80e98987e1))
31
+
32
+ ### BREAKING CHANGES
33
+
34
+ * **api:** removed remove merge & retrieveBigNumbersAsString methods; use the additionalHeaders option on the appropriate operations
35
+
6
36
  # [0.3.0](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-api@0.2.0...@odata2ts/http-client-api@0.3.0) (2023-07-26)
7
37
 
8
38
  ### Features
@@ -3,6 +3,16 @@ 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
+ }
6
16
  export interface ODataHttpClient<RequestConfig = any> {
7
17
  /**
8
18
  * Create a model or collection entry.
@@ -10,54 +20,34 @@ export interface ODataHttpClient<RequestConfig = any> {
10
20
  * @param url
11
21
  * @param data
12
22
  * @param requestConfig
23
+ * @param config
13
24
  */
14
- post<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;
15
- get<ResponseModel>(url: string, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;
25
+ post<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<ResponseModel>;
26
+ get<ResponseModel>(url: string, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<ResponseModel>;
16
27
  /**
17
28
  * Replace a model.
18
29
  *
19
30
  * @param url
20
31
  * @param data
21
32
  * @param requestConfig
33
+ * @param config
22
34
  */
23
- put<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;
35
+ put<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<ResponseModel>;
24
36
  /**
25
37
  * Partially update a model.
26
38
  *
27
39
  * @param url
28
40
  * @param data
29
41
  * @param requestConfig
42
+ * @param config
30
43
  */
31
- patch<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;
32
- /**
33
- * OData V2 only feature.
34
- * Historically, PATCH method was not part of the official HTTP spec, when V1 & V2 were specified;
35
- * but use of PATCH was already envisioned {@link https://www.odata.org/documentation/odata-version-2-0/operations/}.
36
- * V3 and all following versions, specify use of PATCH method.
37
- *
38
- * If implemented, this method wil be used instead of patch to partially update models.
39
- * Use case: You want to reuse this client and one server can only handle MERGE,
40
- * but not PATCH http requests.
41
- *
42
- * @param url
43
- * @param data
44
- * @param requestConfig
45
- */
46
- merge?<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;
44
+ patch<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<ResponseModel>;
47
45
  /**
48
46
  * Delete a model or collection.
49
47
  *
50
48
  * @param url
51
49
  * @param requestConfig
50
+ * @param config
52
51
  */
53
- delete(url: string, requestConfig?: RequestConfig): ODataResponse<void>;
54
- /**
55
- * Get `Edm.Int64` and `Edm.Decimal` types as string instead of number to prevent precision loss.
56
- * Only applies to V4 services.
57
- *
58
- * Set by odata2ts.
59
- *
60
- * @param enabled
61
- */
62
- retrieveBigNumbersAsString(enabled: boolean): void;
52
+ delete(url: string, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<void>;
63
53
  }
@@ -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 */\r\n post<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;\r\n\r\n get<ResponseModel>(url: string, requestConfig?: RequestConfig): 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 */\r\n put<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): 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 */\r\n patch<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): ODataResponse<ResponseModel>;\r\n\r\n /**\r\n * OData V2 only feature.\r\n * Historically, PATCH method was not part of the official HTTP spec, when V1 & V2 were specified;\r\n * but use of PATCH was already envisioned {@link https://www.odata.org/documentation/odata-version-2-0/operations/}.\r\n * V3 and all following versions, specify use of PATCH method.\r\n *\r\n * If implemented, this method wil be used instead of patch to partially update models.\r\n * Use case: You want to reuse this client and one server can only handle MERGE,\r\n * but not PATCH http requests.\r\n *\r\n * @param url\r\n * @param data\r\n * @param requestConfig\r\n */\r\n merge?<ResponseModel>(url: string, data: any, requestConfig?: RequestConfig): 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 */\r\n delete(url: string, requestConfig?: RequestConfig): ODataResponse<void>;\r\n\r\n /**\r\n * Get `Edm.Int64` and `Edm.Decimal` types as string instead of number to prevent precision loss.\r\n * Only applies to V4 services.\r\n *\r\n * Set by odata2ts.\r\n *\r\n * @param enabled\r\n */\r\n retrieveBigNumbersAsString(enabled: boolean): 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> = ClientType extends ODataHttpClient<infer Config>\r\n ? Config\r\n : never;\r\n\r\nexport interface InternalHttpClientConfig {\r\n /**\r\n * Additional headers set internally by services or HttpClient implementation.\r\n */\r\n headers?: Record<string, string>;\r\n /**\r\n * Very special option needed for FetchClient to not evaluate the response body in certain situations.\r\n */\r\n noBodyEvaluation?: boolean;\r\n}\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 config\r\n */\r\n post<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n config?: InternalHttpClientConfig\r\n ): ODataResponse<ResponseModel>;\r\n\r\n get<ResponseModel>(\r\n url: string,\r\n requestConfig?: RequestConfig,\r\n config?: InternalHttpClientConfig\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 config\r\n */\r\n put<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n config?: InternalHttpClientConfig\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 config\r\n */\r\n patch<ResponseModel>(\r\n url: string,\r\n data: any,\r\n requestConfig?: RequestConfig,\r\n config?: InternalHttpClientConfig\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 config\r\n */\r\n delete(url: string, requestConfig?: RequestConfig, config?: InternalHttpClientConfig): ODataResponse<void>;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/http-client-api",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,5 +39,5 @@
39
39
  "typescript": "5.0.4"
40
40
  },
41
41
  "types": "./lib/index.d.ts",
42
- "gitHead": "9babd2df3010673249e7e3fa26705a8ba84f2cef"
42
+ "gitHead": "67c7fc10f25461c33baf4e35694a457a03b81b78"
43
43
  }