gap-nodejs-sdk 1.0.199 → 1.0.201

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.
@@ -1 +1 @@
1
- {"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../src/http_client/http_client.ts"],"names":[],"mappings":"AACA,OAAc,EAAiB,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAEhB,MAAM,SAAS,CAAC;AAGjB,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,WAAW,CAAgB;gBAEhB,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,KAAK,KAAA,EAAE,OAAO,GAAE,aAAgC;IAWzE,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIzD,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7D,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAgE9D,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI9B,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;CA+DhF"}
1
+ {"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../src/http_client/http_client.ts"],"names":[],"mappings":"AACA,OAAc,EAAiB,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAEhB,MAAM,SAAS,CAAC;AAGjB,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,WAAW,CAAgB;gBAEhB,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,KAAK,KAAA,EAAE,OAAO,GAAE,aAAgC;IAWzE,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIzD,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7D,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAmE9D,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI9B,SAAS,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;CAmEhF"}
@@ -48,6 +48,9 @@ export class HttpClient {
48
48
  throw new GapErrors.HttpRequestError(`Number of tries must be >= 0, got ${maxTries}`);
49
49
  }
50
50
  let url;
51
+ console.log('params.path', params.path);
52
+ console.log('params.path', this.domain);
53
+ console.log('this.getRequestPath(params.path)', this.getRequestPath(params.path));
51
54
  if (params.path.startsWith('http') || !this.domain) {
52
55
  url = params.path;
53
56
  }
@@ -101,57 +104,59 @@ export class HttpClient {
101
104
  return __awaiter(this, void 0, void 0, function* () {
102
105
  try {
103
106
  const response = yield this.axios(options);
104
- if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.status) === 'OK' || ((_c = (_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.status) === 'OK' || (((_d = response.data) === null || _d === void 0 ? void 0 : _d.status) === 'OK' && (response === null || response === void 0 ? void 0 : response.status.toString().startsWith('2')))) {
105
- return response.data;
106
- }
107
- const errorMessage = JSON.stringify(response.data.message || response.data.result.message, null, 2);
108
- const headers = response.headers;
109
- const code = response.status;
110
- const statusText = response.statusText;
111
- switch (true) {
112
- case response.status === StatusCode.TooManyRequests: {
113
- const retryAfter = response.headers['Retry-After'];
114
- throw new GapErrors.HttpThrottlingError({
115
- message: `GAP is throttling requests ${errorMessage}`,
116
- code,
117
- statusText,
118
- body: response.data,
119
- headers,
120
- retryAfter: retryAfter ? parseFloat(retryAfter) : undefined,
121
- });
122
- }
123
- case response.status >= StatusCode.InternalServerError:
124
- throw new GapErrors.HttpInternalError({
125
- message: `GAP internal error ${errorMessage}`,
126
- code,
127
- statusText,
128
- body: response.data,
129
- headers,
130
- });
131
- default:
132
- if (((_e = response.data) === null || _e === void 0 ? void 0 : _e.status) == "FAIL") {
133
- throw new GapErrors.HttpResponseError({
134
- message: `Received an error: ${errorMessage} (${(_f = response.data) === null || _f === void 0 ? void 0 : _f.error})`,
107
+ if (((_a = response.data) === null || _a === void 0 ? void 0 : _a.status) !== 'OK' ||
108
+ ((_c = (_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.status) !== 'OK' ||
109
+ !(response === null || response === void 0 ? void 0 : response.status.toString().startsWith('2'))) {
110
+ const errorMessage = JSON.stringify(response.data.message || response.data.result.message, null, 2);
111
+ const headers = response.headers;
112
+ const code = response.status;
113
+ const statusText = response.statusText;
114
+ switch (true) {
115
+ case response.status === StatusCode.TooManyRequests: {
116
+ const retryAfter = response.headers['Retry-After'];
117
+ throw new GapErrors.HttpThrottlingError({
118
+ message: `GAP is throttling requests ${errorMessage}`,
135
119
  code,
136
120
  statusText,
137
121
  body: response.data,
138
122
  headers,
123
+ retryAfter: retryAfter ? parseFloat(retryAfter) : undefined,
139
124
  });
140
125
  }
141
- throw new GapErrors.HttpResponseError({
142
- message: `Received an error (${response.status} ${response.statusText && '' + response.statusText}): ${errorMessage}`,
143
- code,
144
- statusText,
145
- body: response.data,
146
- headers,
147
- });
126
+ case response.status >= StatusCode.InternalServerError:
127
+ throw new GapErrors.HttpInternalError({
128
+ message: `GAP internal error ${errorMessage}`,
129
+ code,
130
+ statusText,
131
+ body: response.data,
132
+ headers,
133
+ });
134
+ default:
135
+ if (((_d = response.data) === null || _d === void 0 ? void 0 : _d.status) == "FAIL") {
136
+ throw new GapErrors.HttpResponseError({
137
+ message: `Received an error: ${errorMessage} (${(_e = response.data) === null || _e === void 0 ? void 0 : _e.error})`,
138
+ code,
139
+ statusText,
140
+ body: response.data,
141
+ headers,
142
+ });
143
+ }
144
+ throw new GapErrors.HttpResponseError({
145
+ message: `Received an error (${response.status} ${response.statusText && '' + response.statusText}): ${errorMessage}`,
146
+ code,
147
+ statusText,
148
+ body: response.data,
149
+ headers,
150
+ });
151
+ }
148
152
  }
153
+ return response.data;
149
154
  }
150
155
  catch (error) {
151
156
  if (error instanceof GapErrors.GapError) {
152
157
  throw error;
153
158
  }
154
- if (error.response.status === 401) {
159
+ if (((_f = error === null || error === void 0 ? void 0 : error.response) === null || _f === void 0 ? void 0 : _f.status) === 401) {
155
160
  throw new GapErrors.HttpUnauthorizedError({
156
161
  code: error.response.status,
157
162
  statusText: error.response.statusText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gap-nodejs-sdk",
3
- "version": "1.0.199",
3
+ "version": "1.0.201",
4
4
  "description": "GCI App Platform Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",