ibm-cloud-sdk-core 4.0.8 → 4.1.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/.secrets.baseline +8 -8
- package/CHANGELOG.md +14 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.convertmodel.md +26 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.createrequestanddeserializeresponse.md +28 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.md +2 -0
- package/docs/ibm-cloud-sdk-core.api.json +166 -1
- package/es/lib/base-service.d.ts +22 -1
- package/es/lib/base-service.js +57 -1
- package/es/tsdoc-metadata.json +1 -1
- package/etc/ibm-cloud-sdk-core.api.md +2 -0
- package/ibm-cloud-sdk-core.d.ts +21 -0
- package/lib/base-service.d.ts +22 -1
- package/lib/base-service.js +59 -1
- package/package.json +1 -4
- package/temp/ibm-cloud-sdk-core.api.json +166 -1
- package/temp/ibm-cloud-sdk-core.api.md +2 -0
package/.secrets.baseline
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"files": "package-lock.json|^.secrets.baseline$",
|
|
4
4
|
"lines": null
|
|
5
5
|
},
|
|
6
|
-
"generated_at": "2023-
|
|
6
|
+
"generated_at": "2023-06-22T15:14:17Z",
|
|
7
7
|
"plugins_used": [
|
|
8
8
|
{
|
|
9
9
|
"name": "AWSKeyDetector"
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"hashed_secret": "98635b2eaa2379f28cd6d72a38299f286b81b459",
|
|
79
79
|
"is_secret": false,
|
|
80
80
|
"is_verified": false,
|
|
81
|
-
"line_number":
|
|
81
|
+
"line_number": 432,
|
|
82
82
|
"type": "Secret Keyword",
|
|
83
83
|
"verified_result": null
|
|
84
84
|
},
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"hashed_secret": "47fcf185ee7e15fe05cae31fbe9e4ebe4a06a40d",
|
|
87
87
|
"is_secret": false,
|
|
88
88
|
"is_verified": false,
|
|
89
|
-
"line_number":
|
|
89
|
+
"line_number": 470,
|
|
90
90
|
"type": "Secret Keyword",
|
|
91
91
|
"verified_result": null
|
|
92
92
|
}
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"hashed_secret": "bc2f74c22f98f7b6ffbc2f67453dbfa99bce9a32",
|
|
97
97
|
"is_secret": false,
|
|
98
98
|
"is_verified": false,
|
|
99
|
-
"line_number":
|
|
99
|
+
"line_number": 55,
|
|
100
100
|
"type": "Secret Keyword",
|
|
101
101
|
"verified_result": null
|
|
102
102
|
}
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"hashed_secret": "32e8612d8ca77c7ea8374aa7918db8e5df9252ed",
|
|
107
107
|
"is_secret": false,
|
|
108
108
|
"is_verified": false,
|
|
109
|
-
"line_number":
|
|
109
|
+
"line_number": 62,
|
|
110
110
|
"type": "Secret Keyword",
|
|
111
111
|
"verified_result": null
|
|
112
112
|
}
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"hashed_secret": "184ee1f04a018aa3b897e085516a9b657fea0f6b",
|
|
191
191
|
"is_secret": false,
|
|
192
192
|
"is_verified": false,
|
|
193
|
-
"line_number":
|
|
193
|
+
"line_number": 85,
|
|
194
194
|
"type": "Secret Keyword",
|
|
195
195
|
"verified_result": null
|
|
196
196
|
}
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
"hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
|
|
307
307
|
"is_secret": false,
|
|
308
308
|
"is_verified": false,
|
|
309
|
-
"line_number":
|
|
309
|
+
"line_number": 279,
|
|
310
310
|
"type": "Secret Keyword",
|
|
311
311
|
"verified_result": null
|
|
312
312
|
}
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
}
|
|
535
535
|
]
|
|
536
536
|
},
|
|
537
|
-
"version": "0.13.1+ibm.
|
|
537
|
+
"version": "0.13.1+ibm.60.dss",
|
|
538
538
|
"word_list": {
|
|
539
539
|
"file": null,
|
|
540
540
|
"hash": null
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [4.1.0](https://github.com/IBM/node-sdk-core/compare/v4.0.9...v4.1.0) (2023-07-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add logic for serializing/deserializing model objects ([#247](https://github.com/IBM/node-sdk-core/issues/247)) ([2397eae](https://github.com/IBM/node-sdk-core/commit/2397eaef56c247a2720396c7d1444b2331ae5a73))
|
|
7
|
+
|
|
8
|
+
## [4.0.9](https://github.com/IBM/node-sdk-core/compare/v4.0.8...v4.0.9) (2023-06-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove unused dependencies ([#246](https://github.com/IBM/node-sdk-core/issues/246)) ([3885ef0](https://github.com/IBM/node-sdk-core/commit/3885ef018ffa0ecb0def8ba6a38f1897b8f39077))
|
|
14
|
+
|
|
1
15
|
## [4.0.8](https://github.com/IBM/node-sdk-core/compare/v4.0.7...v4.0.8) (2023-05-22)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) > [BaseService](./ibm-cloud-sdk-core.baseservice.md) > [convertModel](./ibm-cloud-sdk-core.baseservice.convertmodel.md)
|
|
4
|
+
|
|
5
|
+
## BaseService.convertModel() method
|
|
6
|
+
|
|
7
|
+
Applies a given modifier function on a model object. Since the model object can be a map, or an array, or a model, these types needs different handling. Considering whether the input object is a map happens with an explicit parameter.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| input | any | the input model object |
|
|
20
|
+
| converterFn | any | the function that is applied on the input object |
|
|
21
|
+
| isMap | boolean | _(Optional)_ is <code>true</code> when the input object should be handled as a map |
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
any
|
|
26
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [ibm-cloud-sdk-core](./ibm-cloud-sdk-core.md) > [BaseService](./ibm-cloud-sdk-core.baseservice.md) > [createRequestAndDeserializeResponse](./ibm-cloud-sdk-core.baseservice.createrequestanddeserializeresponse.md)
|
|
4
|
+
|
|
5
|
+
## BaseService.createRequestAndDeserializeResponse() method
|
|
6
|
+
|
|
7
|
+
Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Description |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| parameters | any | see <code>parameters</code> in <code>createRequest</code> |
|
|
20
|
+
| deserializerFn | (any: any) => any | the deserializer function that is applied on the response object |
|
|
21
|
+
| isMap | boolean | _(Optional)_ is <code>true</code> when the response object should be handled as a map |
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
Promise<any>
|
|
26
|
+
|
|
27
|
+
a Promise
|
|
28
|
+
|
|
@@ -33,7 +33,9 @@ export declare class BaseService
|
|
|
33
33
|
| Method | Modifiers | Description |
|
|
34
34
|
| --- | --- | --- |
|
|
35
35
|
| [configureService(serviceName)](./ibm-cloud-sdk-core.baseservice.configureservice.md) | <code>protected</code> | Configure the service using external configuration |
|
|
36
|
+
| [convertModel(input, converterFn, isMap)](./ibm-cloud-sdk-core.baseservice.convertmodel.md) | <code>static</code> | Applies a given modifier function on a model object. Since the model object can be a map, or an array, or a model, these types needs different handling. Considering whether the input object is a map happens with an explicit parameter. |
|
|
36
37
|
| [createRequest(parameters)](./ibm-cloud-sdk-core.baseservice.createrequest.md) | <code>protected</code> | Wrapper around <code>sendRequest</code> that enforces the request will be authenticated. |
|
|
38
|
+
| [createRequestAndDeserializeResponse(parameters, deserializerFn, isMap)](./ibm-cloud-sdk-core.baseservice.createrequestanddeserializeresponse.md) | <code>protected</code> | Wrapper around <code>createRequest</code> that enforces arrived response to be deserialized. |
|
|
37
39
|
| [disableRetries()](./ibm-cloud-sdk-core.baseservice.disableretries.md) | | Disables retries. |
|
|
38
40
|
| [enableRetries(retryOptions)](./ibm-cloud-sdk-core.baseservice.enableretries.md) | | Enable retries for unfulfilled requests. |
|
|
39
41
|
| [getAuthenticator()](./ibm-cloud-sdk-core.baseservice.getauthenticator.md) | | Get the instance of the authenticator set on the service. |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.
|
|
4
|
+
"toolVersion": "7.36.0",
|
|
5
5
|
"schemaVersion": 1011,
|
|
6
6
|
"oldestForwardsCompatibleVersion": 1001,
|
|
7
7
|
"tsdocConfig": {
|
|
@@ -892,6 +892,86 @@
|
|
|
892
892
|
"isAbstract": false,
|
|
893
893
|
"name": "configureService"
|
|
894
894
|
},
|
|
895
|
+
{
|
|
896
|
+
"kind": "Method",
|
|
897
|
+
"canonicalReference": "ibm-cloud-sdk-core!BaseService.convertModel:member(1)",
|
|
898
|
+
"docComment": "/**\n * Applies a given modifier function on a model object. Since the model object can be a map, or an array, or a model, these types needs different handling. Considering whether the input object is a map happens with an explicit parameter.\n *\n * @param input - the input model object\n *\n * @param converterFn - the function that is applied on the input object\n *\n * @param isMap - is `true` when the input object should be handled as a map\n */\n",
|
|
899
|
+
"excerptTokens": [
|
|
900
|
+
{
|
|
901
|
+
"kind": "Content",
|
|
902
|
+
"text": "static convertModel(input: "
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"kind": "Content",
|
|
906
|
+
"text": "any"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"kind": "Content",
|
|
910
|
+
"text": ", converterFn: "
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
"kind": "Content",
|
|
914
|
+
"text": "any"
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
"kind": "Content",
|
|
918
|
+
"text": ", isMap?: "
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"kind": "Content",
|
|
922
|
+
"text": "boolean"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"kind": "Content",
|
|
926
|
+
"text": "): "
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"kind": "Content",
|
|
930
|
+
"text": "any"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"kind": "Content",
|
|
934
|
+
"text": ";"
|
|
935
|
+
}
|
|
936
|
+
],
|
|
937
|
+
"isStatic": true,
|
|
938
|
+
"returnTypeTokenRange": {
|
|
939
|
+
"startIndex": 7,
|
|
940
|
+
"endIndex": 8
|
|
941
|
+
},
|
|
942
|
+
"releaseTag": "Public",
|
|
943
|
+
"isProtected": false,
|
|
944
|
+
"overloadIndex": 1,
|
|
945
|
+
"parameters": [
|
|
946
|
+
{
|
|
947
|
+
"parameterName": "input",
|
|
948
|
+
"parameterTypeTokenRange": {
|
|
949
|
+
"startIndex": 1,
|
|
950
|
+
"endIndex": 2
|
|
951
|
+
},
|
|
952
|
+
"isOptional": false
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
"parameterName": "converterFn",
|
|
956
|
+
"parameterTypeTokenRange": {
|
|
957
|
+
"startIndex": 3,
|
|
958
|
+
"endIndex": 4
|
|
959
|
+
},
|
|
960
|
+
"isOptional": false
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"parameterName": "isMap",
|
|
964
|
+
"parameterTypeTokenRange": {
|
|
965
|
+
"startIndex": 5,
|
|
966
|
+
"endIndex": 6
|
|
967
|
+
},
|
|
968
|
+
"isOptional": true
|
|
969
|
+
}
|
|
970
|
+
],
|
|
971
|
+
"isOptional": false,
|
|
972
|
+
"isAbstract": false,
|
|
973
|
+
"name": "convertModel"
|
|
974
|
+
},
|
|
895
975
|
{
|
|
896
976
|
"kind": "Method",
|
|
897
977
|
"canonicalReference": "ibm-cloud-sdk-core!BaseService#createRequest:member(1)",
|
|
@@ -945,6 +1025,91 @@
|
|
|
945
1025
|
"isAbstract": false,
|
|
946
1026
|
"name": "createRequest"
|
|
947
1027
|
},
|
|
1028
|
+
{
|
|
1029
|
+
"kind": "Method",
|
|
1030
|
+
"canonicalReference": "ibm-cloud-sdk-core!BaseService#createRequestAndDeserializeResponse:member(1)",
|
|
1031
|
+
"docComment": "/**\n * Wrapper around `createRequest` that enforces arrived response to be deserialized.\n *\n * @param parameters - see `parameters` in `createRequest`\n *\n * @param deserializerFn - the deserializer function that is applied on the response object\n *\n * @param isMap - is `true` when the response object should be handled as a map @protected\n *\n * @returns a Promise\n */\n",
|
|
1032
|
+
"excerptTokens": [
|
|
1033
|
+
{
|
|
1034
|
+
"kind": "Content",
|
|
1035
|
+
"text": "protected createRequestAndDeserializeResponse(parameters: "
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
"kind": "Content",
|
|
1039
|
+
"text": "any"
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
"kind": "Content",
|
|
1043
|
+
"text": ", deserializerFn: "
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"kind": "Content",
|
|
1047
|
+
"text": "(any: any) => any"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"kind": "Content",
|
|
1051
|
+
"text": ", isMap?: "
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"kind": "Content",
|
|
1055
|
+
"text": "boolean"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"kind": "Content",
|
|
1059
|
+
"text": "): "
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
"kind": "Reference",
|
|
1063
|
+
"text": "Promise",
|
|
1064
|
+
"canonicalReference": "!Promise:interface"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"kind": "Content",
|
|
1068
|
+
"text": "<any>"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"kind": "Content",
|
|
1072
|
+
"text": ";"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
"isStatic": false,
|
|
1076
|
+
"returnTypeTokenRange": {
|
|
1077
|
+
"startIndex": 7,
|
|
1078
|
+
"endIndex": 9
|
|
1079
|
+
},
|
|
1080
|
+
"releaseTag": "Public",
|
|
1081
|
+
"isProtected": true,
|
|
1082
|
+
"overloadIndex": 1,
|
|
1083
|
+
"parameters": [
|
|
1084
|
+
{
|
|
1085
|
+
"parameterName": "parameters",
|
|
1086
|
+
"parameterTypeTokenRange": {
|
|
1087
|
+
"startIndex": 1,
|
|
1088
|
+
"endIndex": 2
|
|
1089
|
+
},
|
|
1090
|
+
"isOptional": false
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
"parameterName": "deserializerFn",
|
|
1094
|
+
"parameterTypeTokenRange": {
|
|
1095
|
+
"startIndex": 3,
|
|
1096
|
+
"endIndex": 4
|
|
1097
|
+
},
|
|
1098
|
+
"isOptional": false
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
"parameterName": "isMap",
|
|
1102
|
+
"parameterTypeTokenRange": {
|
|
1103
|
+
"startIndex": 5,
|
|
1104
|
+
"endIndex": 6
|
|
1105
|
+
},
|
|
1106
|
+
"isOptional": true
|
|
1107
|
+
}
|
|
1108
|
+
],
|
|
1109
|
+
"isOptional": false,
|
|
1110
|
+
"isAbstract": false,
|
|
1111
|
+
"name": "createRequestAndDeserializeResponse"
|
|
1112
|
+
},
|
|
948
1113
|
{
|
|
949
1114
|
"kind": "Property",
|
|
950
1115
|
"canonicalReference": "ibm-cloud-sdk-core!BaseService.DEFAULT_SERVICE_NAME:member",
|
package/es/lib/base-service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
2
|
+
* (C) Copyright IBM Corp. 2014, 2023.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -113,6 +113,16 @@ export declare class BaseService {
|
|
|
113
113
|
* Disables retries.
|
|
114
114
|
*/
|
|
115
115
|
disableRetries(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Applies a given modifier function on a model object.
|
|
118
|
+
* Since the model object can be a map, or an array, or a model,
|
|
119
|
+
* these types needs different handling.
|
|
120
|
+
* Considering whether the input object is a map happens with an explicit parameter.
|
|
121
|
+
* @param input - the input model object
|
|
122
|
+
* @param converterFn - the function that is applied on the input object
|
|
123
|
+
* @param isMap - is `true` when the input object should be handled as a map
|
|
124
|
+
*/
|
|
125
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
116
126
|
/**
|
|
117
127
|
* Configure the service using external configuration
|
|
118
128
|
*
|
|
@@ -142,5 +152,16 @@ export declare class BaseService {
|
|
|
142
152
|
* @returns a Promise
|
|
143
153
|
*/
|
|
144
154
|
protected createRequest(parameters: any): Promise<any>;
|
|
155
|
+
/**
|
|
156
|
+
* Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
157
|
+
* @param parameters - see `parameters` in `createRequest`
|
|
158
|
+
* @param deserializerFn - the deserializer function that is applied on the response object
|
|
159
|
+
* @param isMap - is `true` when the response object should be handled as a map
|
|
160
|
+
* @protected
|
|
161
|
+
* @returns a Promise
|
|
162
|
+
*/
|
|
163
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
145
164
|
private readOptionsFromExternalConfig;
|
|
165
|
+
private static convertArray;
|
|
166
|
+
private static convertMap;
|
|
146
167
|
}
|
package/es/lib/base-service.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
2
|
+
* (C) Copyright IBM Corp. 2014, 2023.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -132,6 +132,28 @@ export class BaseService {
|
|
|
132
132
|
disableRetries() {
|
|
133
133
|
this.requestWrapperInstance.disableRetries();
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Applies a given modifier function on a model object.
|
|
137
|
+
* Since the model object can be a map, or an array, or a model,
|
|
138
|
+
* these types needs different handling.
|
|
139
|
+
* Considering whether the input object is a map happens with an explicit parameter.
|
|
140
|
+
* @param input - the input model object
|
|
141
|
+
* @param converterFn - the function that is applied on the input object
|
|
142
|
+
* @param isMap - is `true` when the input object should be handled as a map
|
|
143
|
+
*/
|
|
144
|
+
static convertModel(input, converterFn, isMap) {
|
|
145
|
+
if (input == null || typeof input === 'string') {
|
|
146
|
+
// no need for conversation
|
|
147
|
+
return input;
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(input)) {
|
|
150
|
+
return BaseService.convertArray(input, converterFn, isMap);
|
|
151
|
+
}
|
|
152
|
+
else if (isMap === true) {
|
|
153
|
+
return BaseService.convertMap(input, converterFn);
|
|
154
|
+
}
|
|
155
|
+
return converterFn(input);
|
|
156
|
+
}
|
|
135
157
|
/**
|
|
136
158
|
* Configure the service using external configuration
|
|
137
159
|
*
|
|
@@ -179,6 +201,26 @@ export class BaseService {
|
|
|
179
201
|
// resolve() handles rejection as well, so resolving the result of sendRequest should allow for proper handling later
|
|
180
202
|
this.requestWrapperInstance.sendRequest(parameters));
|
|
181
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
206
|
+
* @param parameters - see `parameters` in `createRequest`
|
|
207
|
+
* @param deserializerFn - the deserializer function that is applied on the response object
|
|
208
|
+
* @param isMap - is `true` when the response object should be handled as a map
|
|
209
|
+
* @protected
|
|
210
|
+
* @returns a Promise
|
|
211
|
+
*/
|
|
212
|
+
createRequestAndDeserializeResponse(parameters, deserializerFn, isMap) {
|
|
213
|
+
return new Promise((resolve, reject) => {
|
|
214
|
+
this.createRequest(parameters)
|
|
215
|
+
.then((r) => {
|
|
216
|
+
if (r !== undefined && r.result !== undefined) {
|
|
217
|
+
r.result = BaseService.convertModel(r.result, deserializerFn, isMap);
|
|
218
|
+
}
|
|
219
|
+
resolve(r);
|
|
220
|
+
})
|
|
221
|
+
.catch((err) => reject(err));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
182
224
|
// eslint-disable-next-line class-methods-use-this
|
|
183
225
|
readOptionsFromExternalConfig(serviceName) {
|
|
184
226
|
const results = {};
|
|
@@ -210,4 +252,18 @@ export class BaseService {
|
|
|
210
252
|
}
|
|
211
253
|
return results;
|
|
212
254
|
}
|
|
255
|
+
static convertArray(arrayInput, converterFn, isMap) {
|
|
256
|
+
const serializedList = [];
|
|
257
|
+
arrayInput.forEach((element) => {
|
|
258
|
+
serializedList.push(this.convertModel(element, converterFn, isMap));
|
|
259
|
+
});
|
|
260
|
+
return serializedList;
|
|
261
|
+
}
|
|
262
|
+
static convertMap(mapInput, converterFn) {
|
|
263
|
+
const serializedMap = {};
|
|
264
|
+
Object.keys(mapInput).forEach((key) => {
|
|
265
|
+
serializedMap[key] = BaseService.convertModel(mapInput[key], converterFn);
|
|
266
|
+
});
|
|
267
|
+
return serializedMap;
|
|
268
|
+
}
|
|
213
269
|
}
|
package/es/tsdoc-metadata.json
CHANGED
|
@@ -55,7 +55,9 @@ export class BaseService {
|
|
|
55
55
|
// (undocumented)
|
|
56
56
|
protected baseOptions: BaseServiceOptions;
|
|
57
57
|
protected configureService(serviceName: string): void;
|
|
58
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
58
59
|
protected createRequest(parameters: any): Promise<any>;
|
|
60
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
59
61
|
// (undocumented)
|
|
60
62
|
static DEFAULT_SERVICE_NAME: string;
|
|
61
63
|
// (undocumented)
|
package/ibm-cloud-sdk-core.d.ts
CHANGED
|
@@ -178,6 +178,16 @@ export declare class BaseService {
|
|
|
178
178
|
* Disables retries.
|
|
179
179
|
*/
|
|
180
180
|
disableRetries(): void;
|
|
181
|
+
/**
|
|
182
|
+
* Applies a given modifier function on a model object.
|
|
183
|
+
* Since the model object can be a map, or an array, or a model,
|
|
184
|
+
* these types needs different handling.
|
|
185
|
+
* Considering whether the input object is a map happens with an explicit parameter.
|
|
186
|
+
* @param input - the input model object
|
|
187
|
+
* @param converterFn - the function that is applied on the input object
|
|
188
|
+
* @param isMap - is `true` when the input object should be handled as a map
|
|
189
|
+
*/
|
|
190
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
181
191
|
/**
|
|
182
192
|
* Configure the service using external configuration
|
|
183
193
|
*
|
|
@@ -207,7 +217,18 @@ export declare class BaseService {
|
|
|
207
217
|
* @returns a Promise
|
|
208
218
|
*/
|
|
209
219
|
protected createRequest(parameters: any): Promise<any>;
|
|
220
|
+
/**
|
|
221
|
+
* Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
222
|
+
* @param parameters - see `parameters` in `createRequest`
|
|
223
|
+
* @param deserializerFn - the deserializer function that is applied on the response object
|
|
224
|
+
* @param isMap - is `true` when the response object should be handled as a map
|
|
225
|
+
* @protected
|
|
226
|
+
* @returns a Promise
|
|
227
|
+
*/
|
|
228
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
210
229
|
private readOptionsFromExternalConfig;
|
|
230
|
+
private static convertArray;
|
|
231
|
+
private static convertMap;
|
|
211
232
|
}
|
|
212
233
|
|
|
213
234
|
/**
|
package/lib/base-service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
2
|
+
* (C) Copyright IBM Corp. 2014, 2023.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -113,6 +113,16 @@ export declare class BaseService {
|
|
|
113
113
|
* Disables retries.
|
|
114
114
|
*/
|
|
115
115
|
disableRetries(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Applies a given modifier function on a model object.
|
|
118
|
+
* Since the model object can be a map, or an array, or a model,
|
|
119
|
+
* these types needs different handling.
|
|
120
|
+
* Considering whether the input object is a map happens with an explicit parameter.
|
|
121
|
+
* @param input - the input model object
|
|
122
|
+
* @param converterFn - the function that is applied on the input object
|
|
123
|
+
* @param isMap - is `true` when the input object should be handled as a map
|
|
124
|
+
*/
|
|
125
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
116
126
|
/**
|
|
117
127
|
* Configure the service using external configuration
|
|
118
128
|
*
|
|
@@ -142,5 +152,16 @@ export declare class BaseService {
|
|
|
142
152
|
* @returns a Promise
|
|
143
153
|
*/
|
|
144
154
|
protected createRequest(parameters: any): Promise<any>;
|
|
155
|
+
/**
|
|
156
|
+
* Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
157
|
+
* @param parameters - see `parameters` in `createRequest`
|
|
158
|
+
* @param deserializerFn - the deserializer function that is applied on the response object
|
|
159
|
+
* @param isMap - is `true` when the response object should be handled as a map
|
|
160
|
+
* @protected
|
|
161
|
+
* @returns a Promise
|
|
162
|
+
*/
|
|
163
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
145
164
|
private readOptionsFromExternalConfig;
|
|
165
|
+
private static convertArray;
|
|
166
|
+
private static convertMap;
|
|
146
167
|
}
|
package/lib/base-service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* (C) Copyright IBM Corp. 2014,
|
|
3
|
+
* (C) Copyright IBM Corp. 2014, 2023.
|
|
4
4
|
*
|
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
* you may not use this file except in compliance with the License.
|
|
@@ -149,6 +149,28 @@ var BaseService = /** @class */ (function () {
|
|
|
149
149
|
BaseService.prototype.disableRetries = function () {
|
|
150
150
|
this.requestWrapperInstance.disableRetries();
|
|
151
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Applies a given modifier function on a model object.
|
|
154
|
+
* Since the model object can be a map, or an array, or a model,
|
|
155
|
+
* these types needs different handling.
|
|
156
|
+
* Considering whether the input object is a map happens with an explicit parameter.
|
|
157
|
+
* @param input - the input model object
|
|
158
|
+
* @param converterFn - the function that is applied on the input object
|
|
159
|
+
* @param isMap - is `true` when the input object should be handled as a map
|
|
160
|
+
*/
|
|
161
|
+
BaseService.convertModel = function (input, converterFn, isMap) {
|
|
162
|
+
if (input == null || typeof input === 'string') {
|
|
163
|
+
// no need for conversation
|
|
164
|
+
return input;
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(input)) {
|
|
167
|
+
return BaseService.convertArray(input, converterFn, isMap);
|
|
168
|
+
}
|
|
169
|
+
else if (isMap === true) {
|
|
170
|
+
return BaseService.convertMap(input, converterFn);
|
|
171
|
+
}
|
|
172
|
+
return converterFn(input);
|
|
173
|
+
};
|
|
152
174
|
/**
|
|
153
175
|
* Configure the service using external configuration
|
|
154
176
|
*
|
|
@@ -198,6 +220,27 @@ var BaseService = /** @class */ (function () {
|
|
|
198
220
|
return _this.requestWrapperInstance.sendRequest(parameters);
|
|
199
221
|
});
|
|
200
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* Wrapper around `createRequest` that enforces arrived response to be deserialized.
|
|
225
|
+
* @param parameters - see `parameters` in `createRequest`
|
|
226
|
+
* @param deserializerFn - the deserializer function that is applied on the response object
|
|
227
|
+
* @param isMap - is `true` when the response object should be handled as a map
|
|
228
|
+
* @protected
|
|
229
|
+
* @returns a Promise
|
|
230
|
+
*/
|
|
231
|
+
BaseService.prototype.createRequestAndDeserializeResponse = function (parameters, deserializerFn, isMap) {
|
|
232
|
+
var _this = this;
|
|
233
|
+
return new Promise(function (resolve, reject) {
|
|
234
|
+
_this.createRequest(parameters)
|
|
235
|
+
.then(function (r) {
|
|
236
|
+
if (r !== undefined && r.result !== undefined) {
|
|
237
|
+
r.result = BaseService.convertModel(r.result, deserializerFn, isMap);
|
|
238
|
+
}
|
|
239
|
+
resolve(r);
|
|
240
|
+
})
|
|
241
|
+
.catch(function (err) { return reject(err); });
|
|
242
|
+
});
|
|
243
|
+
};
|
|
201
244
|
// eslint-disable-next-line class-methods-use-this
|
|
202
245
|
BaseService.prototype.readOptionsFromExternalConfig = function (serviceName) {
|
|
203
246
|
var results = {};
|
|
@@ -229,6 +272,21 @@ var BaseService = /** @class */ (function () {
|
|
|
229
272
|
}
|
|
230
273
|
return results;
|
|
231
274
|
};
|
|
275
|
+
BaseService.convertArray = function (arrayInput, converterFn, isMap) {
|
|
276
|
+
var _this = this;
|
|
277
|
+
var serializedList = [];
|
|
278
|
+
arrayInput.forEach(function (element) {
|
|
279
|
+
serializedList.push(_this.convertModel(element, converterFn, isMap));
|
|
280
|
+
});
|
|
281
|
+
return serializedList;
|
|
282
|
+
};
|
|
283
|
+
BaseService.convertMap = function (mapInput, converterFn) {
|
|
284
|
+
var serializedMap = {};
|
|
285
|
+
Object.keys(mapInput).forEach(function (key) {
|
|
286
|
+
serializedMap[key] = BaseService.convertModel(mapInput[key], converterFn);
|
|
287
|
+
});
|
|
288
|
+
return serializedMap;
|
|
289
|
+
};
|
|
232
290
|
return BaseService;
|
|
233
291
|
}());
|
|
234
292
|
exports.BaseService = BaseService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ibm-cloud-sdk-core",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "./es/index.d.ts",
|
|
@@ -54,10 +54,7 @@
|
|
|
54
54
|
"jsonwebtoken": "^9.0.0",
|
|
55
55
|
"lodash.isempty": "^4.4.0",
|
|
56
56
|
"mime-types": "~2.1.18",
|
|
57
|
-
"object.omit": "~3.0.0",
|
|
58
|
-
"object.pick": "~1.3.0",
|
|
59
57
|
"retry-axios": "^2.6.0",
|
|
60
|
-
"semver": "^6.2.0",
|
|
61
58
|
"tough-cookie": "^4.0.0"
|
|
62
59
|
},
|
|
63
60
|
"browser": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.
|
|
4
|
+
"toolVersion": "7.36.0",
|
|
5
5
|
"schemaVersion": 1011,
|
|
6
6
|
"oldestForwardsCompatibleVersion": 1001,
|
|
7
7
|
"tsdocConfig": {
|
|
@@ -892,6 +892,86 @@
|
|
|
892
892
|
"isAbstract": false,
|
|
893
893
|
"name": "configureService"
|
|
894
894
|
},
|
|
895
|
+
{
|
|
896
|
+
"kind": "Method",
|
|
897
|
+
"canonicalReference": "ibm-cloud-sdk-core!BaseService.convertModel:member(1)",
|
|
898
|
+
"docComment": "/**\n * Applies a given modifier function on a model object. Since the model object can be a map, or an array, or a model, these types needs different handling. Considering whether the input object is a map happens with an explicit parameter.\n *\n * @param input - the input model object\n *\n * @param converterFn - the function that is applied on the input object\n *\n * @param isMap - is `true` when the input object should be handled as a map\n */\n",
|
|
899
|
+
"excerptTokens": [
|
|
900
|
+
{
|
|
901
|
+
"kind": "Content",
|
|
902
|
+
"text": "static convertModel(input: "
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"kind": "Content",
|
|
906
|
+
"text": "any"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"kind": "Content",
|
|
910
|
+
"text": ", converterFn: "
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
"kind": "Content",
|
|
914
|
+
"text": "any"
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
"kind": "Content",
|
|
918
|
+
"text": ", isMap?: "
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"kind": "Content",
|
|
922
|
+
"text": "boolean"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"kind": "Content",
|
|
926
|
+
"text": "): "
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"kind": "Content",
|
|
930
|
+
"text": "any"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"kind": "Content",
|
|
934
|
+
"text": ";"
|
|
935
|
+
}
|
|
936
|
+
],
|
|
937
|
+
"isStatic": true,
|
|
938
|
+
"returnTypeTokenRange": {
|
|
939
|
+
"startIndex": 7,
|
|
940
|
+
"endIndex": 8
|
|
941
|
+
},
|
|
942
|
+
"releaseTag": "Public",
|
|
943
|
+
"isProtected": false,
|
|
944
|
+
"overloadIndex": 1,
|
|
945
|
+
"parameters": [
|
|
946
|
+
{
|
|
947
|
+
"parameterName": "input",
|
|
948
|
+
"parameterTypeTokenRange": {
|
|
949
|
+
"startIndex": 1,
|
|
950
|
+
"endIndex": 2
|
|
951
|
+
},
|
|
952
|
+
"isOptional": false
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
"parameterName": "converterFn",
|
|
956
|
+
"parameterTypeTokenRange": {
|
|
957
|
+
"startIndex": 3,
|
|
958
|
+
"endIndex": 4
|
|
959
|
+
},
|
|
960
|
+
"isOptional": false
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"parameterName": "isMap",
|
|
964
|
+
"parameterTypeTokenRange": {
|
|
965
|
+
"startIndex": 5,
|
|
966
|
+
"endIndex": 6
|
|
967
|
+
},
|
|
968
|
+
"isOptional": true
|
|
969
|
+
}
|
|
970
|
+
],
|
|
971
|
+
"isOptional": false,
|
|
972
|
+
"isAbstract": false,
|
|
973
|
+
"name": "convertModel"
|
|
974
|
+
},
|
|
895
975
|
{
|
|
896
976
|
"kind": "Method",
|
|
897
977
|
"canonicalReference": "ibm-cloud-sdk-core!BaseService#createRequest:member(1)",
|
|
@@ -945,6 +1025,91 @@
|
|
|
945
1025
|
"isAbstract": false,
|
|
946
1026
|
"name": "createRequest"
|
|
947
1027
|
},
|
|
1028
|
+
{
|
|
1029
|
+
"kind": "Method",
|
|
1030
|
+
"canonicalReference": "ibm-cloud-sdk-core!BaseService#createRequestAndDeserializeResponse:member(1)",
|
|
1031
|
+
"docComment": "/**\n * Wrapper around `createRequest` that enforces arrived response to be deserialized.\n *\n * @param parameters - see `parameters` in `createRequest`\n *\n * @param deserializerFn - the deserializer function that is applied on the response object\n *\n * @param isMap - is `true` when the response object should be handled as a map @protected\n *\n * @returns a Promise\n */\n",
|
|
1032
|
+
"excerptTokens": [
|
|
1033
|
+
{
|
|
1034
|
+
"kind": "Content",
|
|
1035
|
+
"text": "protected createRequestAndDeserializeResponse(parameters: "
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
"kind": "Content",
|
|
1039
|
+
"text": "any"
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
"kind": "Content",
|
|
1043
|
+
"text": ", deserializerFn: "
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"kind": "Content",
|
|
1047
|
+
"text": "(any: any) => any"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"kind": "Content",
|
|
1051
|
+
"text": ", isMap?: "
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"kind": "Content",
|
|
1055
|
+
"text": "boolean"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"kind": "Content",
|
|
1059
|
+
"text": "): "
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
"kind": "Reference",
|
|
1063
|
+
"text": "Promise",
|
|
1064
|
+
"canonicalReference": "!Promise:interface"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"kind": "Content",
|
|
1068
|
+
"text": "<any>"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"kind": "Content",
|
|
1072
|
+
"text": ";"
|
|
1073
|
+
}
|
|
1074
|
+
],
|
|
1075
|
+
"isStatic": false,
|
|
1076
|
+
"returnTypeTokenRange": {
|
|
1077
|
+
"startIndex": 7,
|
|
1078
|
+
"endIndex": 9
|
|
1079
|
+
},
|
|
1080
|
+
"releaseTag": "Public",
|
|
1081
|
+
"isProtected": true,
|
|
1082
|
+
"overloadIndex": 1,
|
|
1083
|
+
"parameters": [
|
|
1084
|
+
{
|
|
1085
|
+
"parameterName": "parameters",
|
|
1086
|
+
"parameterTypeTokenRange": {
|
|
1087
|
+
"startIndex": 1,
|
|
1088
|
+
"endIndex": 2
|
|
1089
|
+
},
|
|
1090
|
+
"isOptional": false
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
"parameterName": "deserializerFn",
|
|
1094
|
+
"parameterTypeTokenRange": {
|
|
1095
|
+
"startIndex": 3,
|
|
1096
|
+
"endIndex": 4
|
|
1097
|
+
},
|
|
1098
|
+
"isOptional": false
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
"parameterName": "isMap",
|
|
1102
|
+
"parameterTypeTokenRange": {
|
|
1103
|
+
"startIndex": 5,
|
|
1104
|
+
"endIndex": 6
|
|
1105
|
+
},
|
|
1106
|
+
"isOptional": true
|
|
1107
|
+
}
|
|
1108
|
+
],
|
|
1109
|
+
"isOptional": false,
|
|
1110
|
+
"isAbstract": false,
|
|
1111
|
+
"name": "createRequestAndDeserializeResponse"
|
|
1112
|
+
},
|
|
948
1113
|
{
|
|
949
1114
|
"kind": "Property",
|
|
950
1115
|
"canonicalReference": "ibm-cloud-sdk-core!BaseService.DEFAULT_SERVICE_NAME:member",
|
|
@@ -55,7 +55,9 @@ export class BaseService {
|
|
|
55
55
|
// (undocumented)
|
|
56
56
|
protected baseOptions: BaseServiceOptions;
|
|
57
57
|
protected configureService(serviceName: string): void;
|
|
58
|
+
static convertModel(input: any, converterFn: any, isMap?: boolean): any;
|
|
58
59
|
protected createRequest(parameters: any): Promise<any>;
|
|
60
|
+
protected createRequestAndDeserializeResponse(parameters: any, deserializerFn: (any: any) => any, isMap?: boolean): Promise<any>;
|
|
59
61
|
// (undocumented)
|
|
60
62
|
static DEFAULT_SERVICE_NAME: string;
|
|
61
63
|
// (undocumented)
|