@ibm-cloud/cloudant 0.10.2 → 0.11.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/index.d.ts CHANGED
@@ -16,7 +16,8 @@
16
16
  /**
17
17
  * @module cloudant-node-sdk
18
18
  */
19
- export { default as CloudantV1 } from './cloudant/v1';
19
+ import { default as CloudantV1 } from './cloudant/v1';
20
+ export { CloudantV1 };
20
21
  export { BasicAuthenticator, IamAuthenticator, CouchdbSessionAuthenticator, CouchdbSessionAuthenticatorOptions, } from './auth';
21
22
  export { ChangesFollower } from './cloudant/features/changesFollower';
22
23
  export { Stream } from './cloudant/features/stream';
package/index.js CHANGED
@@ -22,8 +22,8 @@ exports.Stream = exports.ChangesFollower = exports.CouchdbSessionAuthenticator =
22
22
  /**
23
23
  * @module cloudant-node-sdk
24
24
  */
25
- var v1_1 = require("./cloudant/v1");
26
- Object.defineProperty(exports, "CloudantV1", { enumerable: true, get: function () { return __importDefault(v1_1).default; } });
25
+ const v1_1 = __importDefault(require("./cloudant/v1"));
26
+ Object.defineProperty(exports, "CloudantV1", { enumerable: true, get: function () { return v1_1.default; } });
27
27
  var auth_1 = require("./auth");
28
28
  Object.defineProperty(exports, "BasicAuthenticator", { enumerable: true, get: function () { return auth_1.BasicAuthenticator; } });
29
29
  Object.defineProperty(exports, "IamAuthenticator", { enumerable: true, get: function () { return auth_1.IamAuthenticator; } });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH;;GAEG;AAEH,oCAAsD;AAA7C,iHAAA,OAAO,OAAc;AAE9B,+BAKgB;AAJd,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAChB,mHAAA,2BAA2B,OAAA;AAI7B,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,qDAAoD;AAA3C,gGAAA,MAAM,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAEH;;GAEG;AAEH,uDAAsD;AAC7C,2FADW,YAAU,OACX;AAEnB,+BAKgB;AAJd,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAChB,mHAAA,2BAA2B,OAAA;AAI7B,uEAAsE;AAA7D,kHAAA,eAAe,OAAA;AACxB,qDAAoD;AAA3C,gGAAA,MAAM,OAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * © Copyright IBM Corporation 2020, 2022. All Rights Reserved.
2
+ * © Copyright IBM Corporation 2020, 2024. All Rights Reserved.
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.
@@ -29,6 +29,7 @@ export default abstract class CloudantBaseService extends BaseService {
29
29
  * @param {string} [userOptions.jar] A Cookie Jar. Enabled by default if there is no custom one.
30
30
  */
31
31
  constructor(userOptions: UserOptions);
32
+ private addErrorTransformers;
32
33
  getTimeout(): number;
33
34
  /**
34
35
  * Set the service URL to send requests to and
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * © Copyright IBM Corporation 2020, 2022. All Rights Reserved.
3
+ * © Copyright IBM Corporation 2020, 2024. All Rights Reserved.
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.
@@ -18,10 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  // eslint-disable-next-line max-classes-per-file
19
19
  const ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
20
20
  const tough_cookie_1 = require("tough-cookie");
21
- const auth_1 = require("../auth");
22
- const common_1 = require("./common");
23
21
  const node_https_1 = require("node:https");
24
22
  const node_http_1 = require("node:http");
23
+ const auth_1 = require("../auth");
24
+ const errorResponseInterceptor_1 = require("./errorResponseInterceptor");
25
+ const common_1 = require("./common");
25
26
  /**
26
27
  * Set default timeout to 2.5 minutes (= 150 000 ms)
27
28
  */
@@ -101,6 +102,12 @@ class CloudantBaseService extends ibm_cloud_sdk_core_1.BaseService {
101
102
  super(userOptions);
102
103
  this.timeout = userOptions.timeout;
103
104
  this.configureSessionAuthenticator();
105
+ // Add response interceptor for error transforms
106
+ this.addErrorTransformers();
107
+ }
108
+ addErrorTransformers() {
109
+ this.getHttpClient().interceptors.response.use((response) => response, errorResponseInterceptor_1.errorResponseStreamConverter);
110
+ this.getHttpClient().interceptors.response.use((response) => response, errorResponseInterceptor_1.errorResponseInterceptor);
104
111
  }
105
112
  getTimeout() {
106
113
  return this.timeout;
@@ -128,6 +135,8 @@ class CloudantBaseService extends ibm_cloud_sdk_core_1.BaseService {
128
135
  // Read external configuration and set as request defaults.
129
136
  super.configureService(serviceName);
130
137
  this.configureSessionAuthenticator();
138
+ // Add response interceptor for error transforms
139
+ this.addErrorTransformers();
131
140
  }
132
141
  /**
133
142
  * Turn request body compression on or off.
@@ -1 +1 @@
1
- {"version":3,"file":"cloudantBaseService.js","sourceRoot":"","sources":["../../lib/cloudantBaseService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,gDAAgD;AAChD,2DAA6E;AAC7E,+CAAyC;AACzC,kCAAsD;AACtD,qCAAyC;AACzC,2CAAiD;AACjD,yCAA+C;AAE/C;;GAEG;AACH,MAAM,YAAY,GAAG,OAAO,CAAC;AAE7B;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACpB,sBAAsB;IACtB,qBAAqB;IACrB,cAAc;IACd,aAAa;IACb,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,W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W,CACtD,uCAAuC,CACxC,CAAC;oBACF,GAAG,CAAC,IAAI,GAAG,uBAAuB,CAAC;oBACnC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAAC,OAAoB;QACzD,MAAM,2BAA2B,GAAG;YAClC,SAAS,EAAE,IAAI;SAChB,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,SAAS,GAAG,IAAI,iBAAS,CAAC,2BAA2B,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,OAAO,CAAC,UAAU,GAAG,IAAI,kBAAU,CAAC,2BAA2B,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AA7ID,sCA6IC"}
1
+ {"version":3,"file":"cloudantBaseService.js","sourceRoot":"","sources":["../../lib/cloudantBaseService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,gDAAgD;AAChD,2DAA6E;AAC7E,+CAAyC;AACzC,2CAAiD;AACjD,yCAA+C;AAC/C,kCAAsD;AACtD,yEAGoC;AACpC,qCAAyC;AAEzC;;GAEG;AACH,MAAM,YAAY,GAAG,OAAO,CAAC;AAE7B;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACpB,sBAAsB;IACtB,qBAAqB;IACrB,cAAc;IACd,aAAa;IACb,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,WAAW,EAAE,QAAQ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AC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;wBACpE,OAAO,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;oBAC3C,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC,CAAC;gBACH,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC7B,MAAM,GAAG,GAAG,IAAI,yBAAyB,CACvC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,kBAAkB,IACpC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CACtD,uCAAuC,CACxC,CAAC;oBACF,GAAG,CAAC,IAAI,GAAG,uBAAuB,CAAC;oBACnC,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAAC,OAAoB;QACzD,MAAM,2BAA2B,GAAG;YAClC,SAAS,EAAE,IAAI;SAChB,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,SAAS,GAAG,IAAI,iBAAS,CAAC,2BAA2B,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,OAAO,CAAC,UAAU,GAAG,IAAI,kBAAU,CAAC,2BAA2B,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AA7JD,sCA6JC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * © Copyright IBM Corporation 2024. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare function errorResponseInterceptor(axiosError: any): Promise<never>;
17
+ /**
18
+ * Axios interceptor to convert errors for streaming cases into
19
+ * JSON objects.
20
+ *
21
+ * This means users can handle rejections for AsStream cases in
22
+ * the same way as normal error rejections and we can apply the
23
+ * errorResponseInterceptor to augment the errors.
24
+ *
25
+ * @param axiosError
26
+ * @returns rejected promise with the stream body transoformed
27
+ */
28
+ export declare function errorResponseStreamConverter(axiosError: any): Promise<never>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * © Copyright IBM Corporation 2024. All Rights Reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.errorResponseInterceptor = errorResponseInterceptor;
19
+ exports.errorResponseStreamConverter = errorResponseStreamConverter;
20
+ const { pipeline } = require('node:stream/promises');
21
+ const { Writable, Readable } = require('node:stream');
22
+ function errorResponseInterceptor(axiosError) {
23
+ if (axiosError.response && // must have a response
24
+ axiosError.response.status >= 400 &&
25
+ // must have data:
26
+ axiosError.response.data &&
27
+ // must be a JSON request
28
+ // which also implies Content-Type starts with application/json:
29
+ (axiosError.config.responseType === 'json' ||
30
+ // or a stream request with application/json
31
+ // that has had the response converted to an object
32
+ (axiosError.config.responseType === 'stream' &&
33
+ axiosError.response.headers['content-type'].startsWith('application/json') &&
34
+ !(axiosError.response.data instanceof Readable))) &&
35
+ // must be a valid JSON:
36
+ // which also implies it is not a HEAD method:
37
+ axiosError.response.data instanceof Object &&
38
+ !axiosError.response.data.trace) {
39
+ // Map the error/reason if available
40
+ // and not already have errors array:
41
+ if (!axiosError.response.data.errors && axiosError.response.data.error) {
42
+ const error = {
43
+ code: axiosError.response.data.error,
44
+ message: axiosError.response.data.error,
45
+ };
46
+ if (axiosError.response.data.reason) {
47
+ error.message += `: ${axiosError.response.data.reason}`;
48
+ }
49
+ // Add the new error as part of an errors array.
50
+ axiosError.response.data.errors = [error];
51
+ }
52
+ if (axiosError.response.data.errors) {
53
+ // Map x-request-id or x-couch-request-id if available to the trace field
54
+ const trace = axiosError.response.headers['x-request-id'] ||
55
+ axiosError.response.headers['x-couch-request-id'];
56
+ if (trace) {
57
+ // Trace should be omitted if there is no value
58
+ axiosError.response.data.trace = trace;
59
+ }
60
+ }
61
+ }
62
+ return Promise.reject(axiosError);
63
+ }
64
+ /**
65
+ * Axios interceptor to convert errors for streaming cases into
66
+ * JSON objects.
67
+ *
68
+ * This means users can handle rejections for AsStream cases in
69
+ * the same way as normal error rejections and we can apply the
70
+ * errorResponseInterceptor to augment the errors.
71
+ *
72
+ * @param axiosError
73
+ * @returns rejected promise with the stream body transoformed
74
+ */
75
+ async function errorResponseStreamConverter(axiosError) {
76
+ if (axiosError.response && // must have a response
77
+ axiosError.response.status >= 400 &&
78
+ // must have data:
79
+ axiosError.response.data &&
80
+ // Must be a JSON response
81
+ axiosError.response.headers['content-type']?.startsWith('application/json') &&
82
+ // this is for streaming requests
83
+ axiosError.config.responseType === 'stream' &&
84
+ // must be a stream
85
+ axiosError.response.data instanceof Readable) {
86
+ let data = '';
87
+ await pipeline(axiosError.response.data, new Writable({
88
+ write: (c, e, cb) => {
89
+ data += c;
90
+ cb();
91
+ },
92
+ }));
93
+ try {
94
+ axiosError.response.data = JSON.parse(data);
95
+ }
96
+ catch (e) {
97
+ // JSON parse failure, just use the original
98
+ // error stream as a string, matching axios behavior
99
+ // for broken JSON
100
+ axiosError.response.data = data;
101
+ }
102
+ }
103
+ return Promise.reject(axiosError);
104
+ }
105
+ //# sourceMappingURL=errorResponseInterceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorResponseInterceptor.js","sourceRoot":"","sources":["../../lib/errorResponseInterceptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAKH,4DA+CC;AAaD,oEAoCC;AAnGD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACrD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEtD,SAAgB,wBAAwB,CAAC,UAAU;IACjD,IACE,UAAU,CAAC,QAAQ,IAAI,uBAAuB;QAC9C,UAAU,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG;QACjC,kBAAkB;QAClB,UAAU,CAAC,QAAQ,CAAC,IAAI;QACxB,yBAAyB;QACzB,gEAAgE;QAChE,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,KAAK,MAAM;YACxC,4CAA4C;YAC5C,mDAAmD;YACnD,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,KAAK,QAAQ;gBAC1C,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,UAAU,CACpD,kBAAkB,CACnB;gBACD,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,YAAY,QAAQ,CAAC,CAAC,CAAC;QACrD,wBAAwB;QACxB,8CAA8C;QAC9C,UAAU,CAAC,QAAQ,CAAC,IAAI,YAAY,MAAM;QAC1C,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAC/B,CAAC;QACD,oCAAoC;QACpC,qCAAqC;QACrC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,I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kB,CACnB;QACD,iCAAiC;QACjC,UAAU,CAAC,MAAM,CAAC,YAAY,KAAK,QAAQ;QAC3C,mBAAmB;QACnB,UAAU,CAAC,QAAQ,CAAC,IAAI,YAAY,QAAQ,EAC5C,CAAC;QACD,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,MAAM,QAAQ,CACZ,UAAU,CAAC,QAAQ,CAAC,IAAI,EACxB,IAAI,QAAQ,CAAC;YACX,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE;gBAClB,IAAI,IAAI,CAAC,CAAC;gBACV,EAAE,EAAE,CAAC;YACP,CAAC;SACF,CAAC,CACH,CAAC;QACF,IAAI,CAAC;YACH,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,4CAA4C;YAC5C,oDAAoD;YACpD,kBAAkB;YAClB,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibm-cloud/cloudant",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "IBM Cloudant Node.js SDK",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -37,16 +37,16 @@
37
37
  },
38
38
  "license": "Apache-2.0",
39
39
  "engines": {
40
- "node": "^18 || ^20"
40
+ "node": "^18 || ^20 || ^22"
41
41
  },
42
42
  "dependencies": {
43
- "@types/node": "18.19.50",
44
- "ibm-cloud-sdk-core": "5.0.2"
43
+ "@types/node": "18.19.64",
44
+ "ibm-cloud-sdk-core": "5.1.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ibm-cloud/sdk-test-utilities": "^1.0.0",
48
48
  "@types/extend": "3.0.4",
49
- "@types/jest": "29.5.13",
49
+ "@types/jest": "29.5.14",
50
50
  "@typescript-eslint/eslint-plugin": "7.18.0",
51
51
  "@typescript-eslint/parser": "7.18.0",
52
52
  "dotenv": "16.4.5",
@@ -56,18 +56,19 @@
56
56
  "eslint-config-prettier": "9.1.0",
57
57
  "eslint-import-resolver-typescript": "3.6.0",
58
58
  "eslint-plugin-header": "3.1.1",
59
- "eslint-plugin-import": "2.30.0",
60
- "eslint-plugin-jest": "28.8.0",
61
- "eslint-plugin-jsdoc": "50.2.0",
59
+ "eslint-plugin-import": "2.31.0",
60
+ "eslint-plugin-jest": "28.9.0",
61
+ "eslint-plugin-jsdoc": "50.4.1",
62
62
  "eslint-plugin-node": "11.1.0",
63
63
  "eslint-plugin-prettier": "5.2.1",
64
64
  "jest": "29.7.0",
65
65
  "jest-junit": "16.0.0",
66
+ "nock": "13.5.5",
66
67
  "prettier": "3.3.3",
67
68
  "sinon": "19.0.2",
68
69
  "ts-jest": "29.2.5",
69
- "typedoc": "0.26.7",
70
- "typescript": "5.6.2"
70
+ "typedoc": "0.26.11",
71
+ "typescript": "5.6.3"
71
72
  },
72
73
  "peerDependencies": {
73
74
  "@types/tough-cookie": "^4.0.0",