d5-api-initializer 1.3.0 → 1.4.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/package.json
CHANGED
|
@@ -128,8 +128,8 @@ var ApiHttpRequest = class {
|
|
|
128
128
|
set timeout(milliseconds) {
|
|
129
129
|
this._jsWapiHttp = this._jsWapiHttp.setTimeout(milliseconds);
|
|
130
130
|
}
|
|
131
|
-
setHeader(
|
|
132
|
-
this._jsWapiHttp = this._jsWapiHttp.setHeader(
|
|
131
|
+
setHeader(header, value) {
|
|
132
|
+
this._jsWapiHttp = this._jsWapiHttp.setHeader(header, "".concat(value));
|
|
133
133
|
return this;
|
|
134
134
|
}
|
|
135
135
|
setHeaders(headers) {
|
|
@@ -145,7 +145,7 @@ var ApiHttpRequest = class {
|
|
|
145
145
|
GET(callback) {
|
|
146
146
|
return this._jsWapiHttp.GET(this._getWrappedCallback(callback));
|
|
147
147
|
}
|
|
148
|
-
POST(request, callback) {
|
|
148
|
+
POST(request = {}, callback) {
|
|
149
149
|
return this._jsWapiHttp.POST((req) => {
|
|
150
150
|
if (request instanceof FileLink)
|
|
151
151
|
return req.setBody((body) => body.setFileLink(request.link));
|
|
@@ -154,6 +154,9 @@ var ApiHttpRequest = class {
|
|
|
154
154
|
if (request instanceof MultipartFormData) {
|
|
155
155
|
return this.setMultipartBody(req, request);
|
|
156
156
|
}
|
|
157
|
+
if (typeof request === "string") {
|
|
158
|
+
return req.setBody(request);
|
|
159
|
+
}
|
|
157
160
|
return req.setBody(JSON.stringify(request));
|
|
158
161
|
}, this._getWrappedCallback(callback));
|
|
159
162
|
}
|
|
@@ -177,11 +180,11 @@ var ApiHttpRequest = class {
|
|
|
177
180
|
return body;
|
|
178
181
|
});
|
|
179
182
|
}
|
|
180
|
-
PUT(
|
|
181
|
-
return this._jsWapiHttp.PUT(JSON.stringify(
|
|
183
|
+
PUT(body = {}, callback) {
|
|
184
|
+
return this._jsWapiHttp.PUT(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
182
185
|
}
|
|
183
|
-
PATCH(
|
|
184
|
-
return this._jsWapiHttp.PATCH(JSON.stringify(
|
|
186
|
+
PATCH(body = {}, callback) {
|
|
187
|
+
return this._jsWapiHttp.PATCH(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
185
188
|
}
|
|
186
189
|
_getWrappedCallback(callback) {
|
|
187
190
|
return (res) => {
|
|
@@ -227,12 +230,20 @@ var ApiResponse = class {
|
|
|
227
230
|
}
|
|
228
231
|
return this;
|
|
229
232
|
}
|
|
230
|
-
sendHttpResponse(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
sendHttpResponse() {
|
|
234
|
+
const args = [...arguments];
|
|
235
|
+
if (args[0] && args[1]) {
|
|
236
|
+
this._jsWapiResponse.sendHttpResponse(args[0], args[1]);
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
if (args[0] && !args[1]) {
|
|
240
|
+
this._jsWapiResponse.sendHttpResponse(args[0]);
|
|
241
|
+
return this;
|
|
242
|
+
}
|
|
243
|
+
throw new Error("Wrong parameters in function sendHttpResponse()");
|
|
233
244
|
}
|
|
234
245
|
sendHttpBody(body) {
|
|
235
|
-
this._jsWapiResponse.sendHttpResponse(
|
|
246
|
+
this._jsWapiResponse.sendHttpResponse(body);
|
|
236
247
|
return this;
|
|
237
248
|
}
|
|
238
249
|
getPage() {
|
|
@@ -72,6 +72,7 @@ declare namespace jsWapi {
|
|
|
72
72
|
setResponse(resp: {
|
|
73
73
|
[key: string]: Record<string, any>[];
|
|
74
74
|
}): void;
|
|
75
|
+
sendHttpResponse(body: string | BinaryDataStream): void;
|
|
75
76
|
sendHttpResponse(headers: Record<string, any>, body: string | BinaryDataStream): void;
|
|
76
77
|
getPagesPredict(): number;
|
|
77
78
|
setPagesPredict(pagesPredict: number): void;
|
|
@@ -173,16 +174,16 @@ declare class MultipartFormData {
|
|
|
173
174
|
declare class ApiHttpRequest {
|
|
174
175
|
private _jsWapiHttp;
|
|
175
176
|
constructor(jsWapiHttp: jsWapi.JSWapiHttp);
|
|
176
|
-
set headers(headers:
|
|
177
|
+
set headers(headers: Record<string, string>);
|
|
177
178
|
set timeout(milliseconds: number);
|
|
178
|
-
setHeader(
|
|
179
|
-
setHeaders(headers:
|
|
179
|
+
setHeader(header: string, value: string): ApiHttpRequest;
|
|
180
|
+
setHeaders(headers: Record<string, string>): ApiHttpRequest;
|
|
180
181
|
setTimeout(milliseconds: number): ApiHttpRequest;
|
|
181
182
|
GET(callback?: IHttpCallback): any;
|
|
182
|
-
POST(request
|
|
183
|
+
POST(request?: FileLink | FileRequestId | MultipartFormData | Record<string, any> | string, callback?: IHttpCallback): any;
|
|
183
184
|
private setMultipartBody;
|
|
184
|
-
PUT(
|
|
185
|
-
PATCH(
|
|
185
|
+
PUT(body?: Record<string, any> | string, callback?: IHttpCallback): any;
|
|
186
|
+
PATCH(body: Record<string, any> | string, callback: IHttpCallback): any;
|
|
186
187
|
private _getWrappedCallback;
|
|
187
188
|
}
|
|
188
189
|
|
|
@@ -195,8 +196,9 @@ declare class ApiResponse {
|
|
|
195
196
|
getResponse(responseName?: string): IMappedCollection[] | any;
|
|
196
197
|
getResponseObject(): IMappedCollection[] | any;
|
|
197
198
|
setResponse(response: IMappedCollection | any[], fieldsMap?: Record<string, any>): this;
|
|
198
|
-
sendHttpResponse(
|
|
199
|
-
|
|
199
|
+
sendHttpResponse(body: string | jsWapi.BinaryDataStream): ApiResponse;
|
|
200
|
+
sendHttpResponse(headers: Record<string, string>, body: string | jsWapi.BinaryDataStream): ApiResponse;
|
|
201
|
+
sendHttpBody(body: string | jsWapi.BinaryDataStream): this;
|
|
200
202
|
getPage(): number;
|
|
201
203
|
setPage(page: number): this;
|
|
202
204
|
getPagesPredict(): number;
|
|
@@ -89,8 +89,8 @@ var ApiHttpRequest = class {
|
|
|
89
89
|
set timeout(milliseconds) {
|
|
90
90
|
this._jsWapiHttp = this._jsWapiHttp.setTimeout(milliseconds);
|
|
91
91
|
}
|
|
92
|
-
setHeader(
|
|
93
|
-
this._jsWapiHttp = this._jsWapiHttp.setHeader(
|
|
92
|
+
setHeader(header, value) {
|
|
93
|
+
this._jsWapiHttp = this._jsWapiHttp.setHeader(header, "".concat(value));
|
|
94
94
|
return this;
|
|
95
95
|
}
|
|
96
96
|
setHeaders(headers) {
|
|
@@ -106,7 +106,7 @@ var ApiHttpRequest = class {
|
|
|
106
106
|
GET(callback) {
|
|
107
107
|
return this._jsWapiHttp.GET(this._getWrappedCallback(callback));
|
|
108
108
|
}
|
|
109
|
-
POST(request, callback) {
|
|
109
|
+
POST(request = {}, callback) {
|
|
110
110
|
return this._jsWapiHttp.POST((req) => {
|
|
111
111
|
if (request instanceof FileLink)
|
|
112
112
|
return req.setBody((body) => body.setFileLink(request.link));
|
|
@@ -115,6 +115,9 @@ var ApiHttpRequest = class {
|
|
|
115
115
|
if (request instanceof MultipartFormData) {
|
|
116
116
|
return this.setMultipartBody(req, request);
|
|
117
117
|
}
|
|
118
|
+
if (typeof request === "string") {
|
|
119
|
+
return req.setBody(request);
|
|
120
|
+
}
|
|
118
121
|
return req.setBody(JSON.stringify(request));
|
|
119
122
|
}, this._getWrappedCallback(callback));
|
|
120
123
|
}
|
|
@@ -138,11 +141,11 @@ var ApiHttpRequest = class {
|
|
|
138
141
|
return body;
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
|
-
PUT(
|
|
142
|
-
return this._jsWapiHttp.PUT(JSON.stringify(
|
|
144
|
+
PUT(body = {}, callback) {
|
|
145
|
+
return this._jsWapiHttp.PUT(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
143
146
|
}
|
|
144
|
-
PATCH(
|
|
145
|
-
return this._jsWapiHttp.PATCH(JSON.stringify(
|
|
147
|
+
PATCH(body = {}, callback) {
|
|
148
|
+
return this._jsWapiHttp.PATCH(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
146
149
|
}
|
|
147
150
|
_getWrappedCallback(callback) {
|
|
148
151
|
return (res) => {
|
|
@@ -188,12 +191,20 @@ var ApiResponse = class {
|
|
|
188
191
|
}
|
|
189
192
|
return this;
|
|
190
193
|
}
|
|
191
|
-
sendHttpResponse(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
sendHttpResponse() {
|
|
195
|
+
const args = [...arguments];
|
|
196
|
+
if (args[0] && args[1]) {
|
|
197
|
+
this._jsWapiResponse.sendHttpResponse(args[0], args[1]);
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
if (args[0] && !args[1]) {
|
|
201
|
+
this._jsWapiResponse.sendHttpResponse(args[0]);
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
204
|
+
throw new Error("Wrong parameters in function sendHttpResponse()");
|
|
194
205
|
}
|
|
195
206
|
sendHttpBody(body) {
|
|
196
|
-
this._jsWapiResponse.sendHttpResponse(
|
|
207
|
+
this._jsWapiResponse.sendHttpResponse(body);
|
|
197
208
|
return this;
|
|
198
209
|
}
|
|
199
210
|
getPage() {
|
|
@@ -89,8 +89,8 @@ var ApiHttpRequest = class {
|
|
|
89
89
|
set timeout(milliseconds) {
|
|
90
90
|
this._jsWapiHttp = this._jsWapiHttp.setTimeout(milliseconds);
|
|
91
91
|
}
|
|
92
|
-
setHeader(
|
|
93
|
-
this._jsWapiHttp = this._jsWapiHttp.setHeader(
|
|
92
|
+
setHeader(header, value) {
|
|
93
|
+
this._jsWapiHttp = this._jsWapiHttp.setHeader(header, "".concat(value));
|
|
94
94
|
return this;
|
|
95
95
|
}
|
|
96
96
|
setHeaders(headers) {
|
|
@@ -106,7 +106,7 @@ var ApiHttpRequest = class {
|
|
|
106
106
|
GET(callback) {
|
|
107
107
|
return this._jsWapiHttp.GET(this._getWrappedCallback(callback));
|
|
108
108
|
}
|
|
109
|
-
POST(request, callback) {
|
|
109
|
+
POST(request = {}, callback) {
|
|
110
110
|
return this._jsWapiHttp.POST((req) => {
|
|
111
111
|
if (request instanceof FileLink)
|
|
112
112
|
return req.setBody((body) => body.setFileLink(request.link));
|
|
@@ -115,6 +115,9 @@ var ApiHttpRequest = class {
|
|
|
115
115
|
if (request instanceof MultipartFormData) {
|
|
116
116
|
return this.setMultipartBody(req, request);
|
|
117
117
|
}
|
|
118
|
+
if (typeof request === "string") {
|
|
119
|
+
return req.setBody(request);
|
|
120
|
+
}
|
|
118
121
|
return req.setBody(JSON.stringify(request));
|
|
119
122
|
}, this._getWrappedCallback(callback));
|
|
120
123
|
}
|
|
@@ -138,11 +141,11 @@ var ApiHttpRequest = class {
|
|
|
138
141
|
return body;
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
|
-
PUT(
|
|
142
|
-
return this._jsWapiHttp.PUT(JSON.stringify(
|
|
144
|
+
PUT(body = {}, callback) {
|
|
145
|
+
return this._jsWapiHttp.PUT(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
143
146
|
}
|
|
144
|
-
PATCH(
|
|
145
|
-
return this._jsWapiHttp.PATCH(JSON.stringify(
|
|
147
|
+
PATCH(body = {}, callback) {
|
|
148
|
+
return this._jsWapiHttp.PATCH(typeof body === "string" ? body : JSON.stringify(body), this._getWrappedCallback(callback));
|
|
146
149
|
}
|
|
147
150
|
_getWrappedCallback(callback) {
|
|
148
151
|
return (res) => {
|
|
@@ -188,12 +191,20 @@ var ApiResponse = class {
|
|
|
188
191
|
}
|
|
189
192
|
return this;
|
|
190
193
|
}
|
|
191
|
-
sendHttpResponse(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
sendHttpResponse() {
|
|
195
|
+
const args = [...arguments];
|
|
196
|
+
if (args[0] && args[1]) {
|
|
197
|
+
this._jsWapiResponse.sendHttpResponse(args[0], args[1]);
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
if (args[0] && !args[1]) {
|
|
201
|
+
this._jsWapiResponse.sendHttpResponse(args[0]);
|
|
202
|
+
return this;
|
|
203
|
+
}
|
|
204
|
+
throw new Error("Wrong parameters in function sendHttpResponse()");
|
|
194
205
|
}
|
|
195
206
|
sendHttpBody(body) {
|
|
196
|
-
this._jsWapiResponse.sendHttpResponse(
|
|
207
|
+
this._jsWapiResponse.sendHttpResponse(body);
|
|
197
208
|
return this;
|
|
198
209
|
}
|
|
199
210
|
getPage() {
|