dff-util 1.2.8 → 1.2.9

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/README.md CHANGED
@@ -264,17 +264,6 @@ export type SessionUser = {
264
264
  };
265
265
  ```
266
266
 
267
- ## ResponseType
268
-
269
- ```
270
- ResponseType = {
271
- status?: string | number;
272
- data?: any;
273
- error?: any;
274
- total?: number;
275
- };
276
-
277
- ```
278
267
 
279
268
  ## SearchByLimitType
280
269
  ```
@@ -354,6 +343,9 @@ export type ResponseType = {
354
343
  status?: string | number;
355
344
  data?: any;
356
345
  error?: any;
346
+ total?: number;
347
+ skip?: number;
348
+ limit?: number;
357
349
  };
358
350
 
359
351
  export type SearchByType = {
@@ -363,14 +355,6 @@ export type SearchByType = {
363
355
  searchTerm?: string;
364
356
  };
365
357
 
366
- export type PaginationResponseType = {
367
- status?: string | number;
368
- data?: any;
369
- error?: any;
370
- total?: number;
371
- skip?: number;
372
- limit?: number;
373
- };
374
358
 
375
359
  export type SearchByLimitType = {
376
360
  limit: number;
@@ -23,6 +23,9 @@ export type ResponseType = {
23
23
  status?: string | number;
24
24
  data?: any;
25
25
  error?: any;
26
+ total?: number;
27
+ skip?: number;
28
+ limit?: number;
26
29
  };
27
30
  export type SearchByType = {
28
31
  query?: Record<string, any>;
@@ -30,14 +33,6 @@ export type SearchByType = {
30
33
  order?: "ASC" | "DESC";
31
34
  searchTerm?: string;
32
35
  };
33
- export type PaginationResponseType = {
34
- status?: string | number;
35
- data?: any;
36
- error?: any;
37
- total?: number;
38
- skip?: number;
39
- limit?: number;
40
- };
41
36
  export type SearchByLimitType = {
42
37
  limit: number;
43
38
  skip: number;
@@ -8,11 +8,11 @@ export declare enum RespType {
8
8
  export declare const HttpHeaders: {
9
9
  'Content-Type': string;
10
10
  authorization: null;
11
- 'x-request-id': null;
11
+ 'request-id': null;
12
12
  };
13
13
  export declare const BaseHeaders: {
14
14
  authorization: null;
15
- 'x-request-id': null;
15
+ 'request-id': null;
16
16
  };
17
17
  export declare const HttpMethods: {
18
18
  GET: string;
package/dist/main/http.js CHANGED
@@ -22,11 +22,11 @@ var RespType;
22
22
  exports.HttpHeaders = {
23
23
  'Content-Type': 'application/json',
24
24
  authorization: null,
25
- 'x-request-id': null,
25
+ 'request-id': null,
26
26
  };
27
27
  exports.BaseHeaders = {
28
28
  authorization: null,
29
- 'x-request-id': null,
29
+ 'request-id': null,
30
30
  };
31
31
  exports.HttpMethods = {
32
32
  GET: "GET",
@@ -69,14 +69,14 @@ class Http {
69
69
  url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
70
70
  const fullUrl = params ? `${url}?${new URLSearchParams(params).toString()}` : url;
71
71
  headers = headers || exports.HttpHeaders;
72
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
72
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
73
73
  try {
74
74
  const requestOptions = { method: 'GET', headers: headers };
75
75
  const response = yield fetch(fullUrl, requestOptions);
76
76
  return yield Http.RespData(response, type);
77
77
  }
78
78
  catch (error) {
79
- throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
79
+ throw { url: fullUrl, requestId: headers['request-id'], error: error };
80
80
  }
81
81
  });
82
82
  }
@@ -84,14 +84,14 @@ class Http {
84
84
  return __awaiter(this, arguments, void 0, function* (url, data, headers, type = RespType.JSON) {
85
85
  url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
86
86
  headers = headers || exports.HttpHeaders;
87
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
87
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
88
88
  try {
89
89
  const requestOptions = { method: 'POST', body: JSON.stringify(data), headers: headers };
90
90
  const response = yield fetch(url, requestOptions);
91
91
  return yield Http.RespData(response, type);
92
92
  }
93
93
  catch (error) {
94
- throw { url: url, requestId: headers['x-request-id'], body: data, error: error };
94
+ throw { url: url, requestId: headers['request-id'], body: data, error: error };
95
95
  }
96
96
  });
97
97
  }
@@ -99,14 +99,14 @@ class Http {
99
99
  return __awaiter(this, arguments, void 0, function* (url, data, headers, type = RespType.JSON) {
100
100
  url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
101
101
  headers = headers || exports.HttpHeaders;
102
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
102
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
103
103
  try {
104
104
  const requestOptions = { method: 'PUT', body: JSON.stringify(data), headers: headers };
105
105
  const response = yield fetch(url, requestOptions);
106
106
  return yield Http.RespData(response, type);
107
107
  }
108
108
  catch (error) {
109
- throw { url: url, requestId: headers['x-request-id'], body: data, error: error };
109
+ throw { url: url, requestId: headers['request-id'], body: data, error: error };
110
110
  }
111
111
  });
112
112
  }
@@ -115,14 +115,14 @@ class Http {
115
115
  url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
116
116
  const fullUrl = params ? `${url}?${new URLSearchParams(params).toString()}` : url;
117
117
  headers = headers || exports.HttpHeaders;
118
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
118
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
119
119
  try {
120
120
  const requestOptions = { method: 'DELETE', headers: headers };
121
121
  const response = yield fetch(fullUrl, requestOptions);
122
122
  return yield Http.RespData(response, type);
123
123
  }
124
124
  catch (error) {
125
- throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
125
+ throw { url: fullUrl, requestId: headers['request-id'], error: error };
126
126
  }
127
127
  });
128
128
  }
@@ -132,14 +132,14 @@ class Http {
132
132
  const params = { key: appKey, payload: JSON.stringify(sessionInfo) };
133
133
  const fullUrl = `${url}?${new URLSearchParams(params).toString()}`;
134
134
  const headers = Object.assign(Object.assign({}, Headers), { 'X-API-KEY': apiKey || '' });
135
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
135
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
136
136
  try {
137
137
  const requestOptions = { method: 'GET', headers: headers };
138
138
  const response = yield fetch(fullUrl, requestOptions);
139
139
  return yield Http.RespData(response, type);
140
140
  }
141
141
  catch (error) {
142
- throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
142
+ throw { url: fullUrl, requestId: headers['request-id'], error: error };
143
143
  }
144
144
  });
145
145
  }
@@ -156,7 +156,7 @@ class Http {
156
156
  if (isHeadersAddMultiForm) {
157
157
  headers = Object.assign(Object.assign({}, headers), { 'Content-Type': headers['Content-Type'] || 'multipart/form-data' });
158
158
  }
159
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
159
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
160
160
  try {
161
161
  const requestOptions = {
162
162
  method: method,
@@ -167,7 +167,7 @@ class Http {
167
167
  return yield Http.RespData(response, type);
168
168
  }
169
169
  catch (error) {
170
- throw { url: url, requestId: headers['x-request-id'], error: error };
170
+ throw { url: url, requestId: headers['request-id'], error: error };
171
171
  }
172
172
  });
173
173
  }
@@ -176,7 +176,7 @@ class Http {
176
176
  headers = headers || {
177
177
  'Content-Type': file.type,
178
178
  };
179
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
179
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
180
180
  try {
181
181
  const requestOptions = {
182
182
  method: method,
@@ -187,7 +187,7 @@ class Http {
187
187
  return response;
188
188
  }
189
189
  catch (error) {
190
- throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
190
+ throw { url: fullUrl, requestId: headers['request-id'], error: error };
191
191
  }
192
192
  });
193
193
  }
@@ -195,7 +195,7 @@ class Http {
195
195
  return __awaiter(this, arguments, void 0, function* (fullUrl, params, headers = exports.HttpHeaders, method = 'GET') {
196
196
  fullUrl = params ? `${fullUrl}?${new URLSearchParams(params).toString()}` : fullUrl;
197
197
  headers = headers || exports.HttpHeaders;
198
- headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
198
+ headers['request-id'] = headers['request-id'] || (0, util_1.AppUUID4)();
199
199
  try {
200
200
  const requestOptions = { method: method, headers: headers };
201
201
  const response = yield fetch(fullUrl, requestOptions);
@@ -204,7 +204,7 @@ class Http {
204
204
  return buffer;
205
205
  }
206
206
  catch (error) {
207
- throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
207
+ throw { url: fullUrl, requestId: headers['request-id'], error: error };
208
208
  }
209
209
  });
210
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dff-util",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {