d5-api-initializer 1.5.2 → 1.5.4
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
|
@@ -260,6 +260,42 @@ var ApiResponse = class {
|
|
|
260
260
|
this._jsWapiResponse.setPagesPredict(pagesPredict);
|
|
261
261
|
return this;
|
|
262
262
|
}
|
|
263
|
+
sendZip({ name, contentType = "application/zip", files }) {
|
|
264
|
+
return this._jsWapiResponse.sendZip({
|
|
265
|
+
name,
|
|
266
|
+
contentType,
|
|
267
|
+
callback: (zip) => {
|
|
268
|
+
files.forEach((file) => {
|
|
269
|
+
const isEmptyDirectory = !file.objectName && !file.operation && !file.keyValue && !file.field;
|
|
270
|
+
if (isEmptyDirectory) {
|
|
271
|
+
zip.add({ name: file.name });
|
|
272
|
+
} else {
|
|
273
|
+
zip.add({
|
|
274
|
+
name: file.name,
|
|
275
|
+
file: {
|
|
276
|
+
object: file.objectName,
|
|
277
|
+
oper: file.operation || "List",
|
|
278
|
+
keyValue: file.keyValue,
|
|
279
|
+
field: file.field
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
sendFile({ name, contentType, file }) {
|
|
288
|
+
return this._jsWapiResponse.sendFile({
|
|
289
|
+
name,
|
|
290
|
+
contentType,
|
|
291
|
+
file: {
|
|
292
|
+
object: file.objectName,
|
|
293
|
+
oper: file.operation || "List",
|
|
294
|
+
keyValue: file.keyValue,
|
|
295
|
+
field: file.field
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
263
299
|
};
|
|
264
300
|
|
|
265
301
|
// src/classes/ApiInvoker.ts
|
|
@@ -588,10 +624,10 @@ var ApiCore = class {
|
|
|
588
624
|
* Валидирует xml по переданому xsd.
|
|
589
625
|
* Если валидация происходит с ошибками, то бросается исключение.
|
|
590
626
|
*/
|
|
591
|
-
validateXml(xml, xsd) {
|
|
627
|
+
validateXml(xml, xsd, options) {
|
|
592
628
|
if (!this.httpSender.validateXml)
|
|
593
629
|
throw this.newApiException("validateXml() is not allowed");
|
|
594
|
-
return this.httpSender.validateXml(xsd, xml);
|
|
630
|
+
return this.httpSender.validateXml(xsd, xml, options);
|
|
595
631
|
}
|
|
596
632
|
/*
|
|
597
633
|
* Will be implemented later
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
type SendZipJsWapiArgs = {
|
|
2
|
+
name: string;
|
|
3
|
+
contentType?: string;
|
|
4
|
+
callback: (zip: any) => void;
|
|
5
|
+
};
|
|
6
|
+
type SendFileJsWapiArgs = {
|
|
7
|
+
name: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
file: {
|
|
10
|
+
object: string;
|
|
11
|
+
oper: string;
|
|
12
|
+
keyValue: any;
|
|
13
|
+
field: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
1
16
|
declare namespace jsWapi {
|
|
2
17
|
interface JSRequestModesSetter {
|
|
3
18
|
setAutocompleteLinkedObjectFields(isAutocompleteLinkedObjectFields: boolean): void;
|
|
@@ -95,6 +110,8 @@ declare namespace jsWapi {
|
|
|
95
110
|
sendHttpResponse(body: string | BinaryDataStream): void;
|
|
96
111
|
sendHttpResponse(headers: Record<string, any>, body: string | BinaryDataStream): void;
|
|
97
112
|
getPagesPredict(): number;
|
|
113
|
+
sendZip({ name, contentType, callback }: SendZipJsWapiArgs): void;
|
|
114
|
+
sendFile({ name, contentType, file }: SendFileJsWapiArgs): void;
|
|
98
115
|
setPagesPredict(pagesPredict: number): void;
|
|
99
116
|
getPage(): number;
|
|
100
117
|
setPage(page: number): void;
|
|
@@ -280,6 +297,23 @@ declare class ApiHttpRequest {
|
|
|
280
297
|
private _getWrappedCallback;
|
|
281
298
|
}
|
|
282
299
|
|
|
300
|
+
type FileEntry = {
|
|
301
|
+
name: string;
|
|
302
|
+
objectName?: string;
|
|
303
|
+
operation?: string;
|
|
304
|
+
keyValue?: any;
|
|
305
|
+
field?: string;
|
|
306
|
+
};
|
|
307
|
+
type SendZipOptions = {
|
|
308
|
+
name: string;
|
|
309
|
+
contentType?: string;
|
|
310
|
+
files: FileEntry[];
|
|
311
|
+
};
|
|
312
|
+
type SendFileOptions = {
|
|
313
|
+
name: string;
|
|
314
|
+
contentType?: string;
|
|
315
|
+
file: FileEntry;
|
|
316
|
+
};
|
|
283
317
|
declare class ApiResponse {
|
|
284
318
|
private _jsWapiResponse;
|
|
285
319
|
private readonly _objectName;
|
|
@@ -296,6 +330,8 @@ declare class ApiResponse {
|
|
|
296
330
|
setPage(page: number): this;
|
|
297
331
|
getPagesPredict(): number;
|
|
298
332
|
setPagesPredict(pagesPredict: number): this;
|
|
333
|
+
sendZip({ name, contentType, files }: SendZipOptions): void;
|
|
334
|
+
sendFile({ name, contentType, file }: SendFileOptions): void;
|
|
299
335
|
}
|
|
300
336
|
|
|
301
337
|
interface IInvoker$1<T> {
|
|
@@ -517,7 +553,9 @@ declare class ApiFileInvoker implements IInvoker {
|
|
|
517
553
|
type HTTPSender = {
|
|
518
554
|
newJSWapiHttp(url: string): jsWapi.JSWapiHttp;
|
|
519
555
|
/** Если не валидируется, то будет exception. */
|
|
520
|
-
validateXml?(xsd: string, xml: string
|
|
556
|
+
validateXml?(xsd: string, xml: string, options?: {
|
|
557
|
+
macroses: Record<string, any>;
|
|
558
|
+
}): boolean;
|
|
521
559
|
};
|
|
522
560
|
declare class ApiCore {
|
|
523
561
|
private readonly httpSender;
|
|
@@ -549,7 +587,9 @@ declare class ApiCore {
|
|
|
549
587
|
* Валидирует xml по переданому xsd.
|
|
550
588
|
* Если валидация происходит с ошибками, то бросается исключение.
|
|
551
589
|
*/
|
|
552
|
-
validateXml(xml: string, xsd: string
|
|
590
|
+
validateXml(xml: string, xsd: string, options?: {
|
|
591
|
+
macroses: Record<string, any>;
|
|
592
|
+
}): boolean;
|
|
553
593
|
}
|
|
554
594
|
|
|
555
595
|
declare class ApiHttpResponse {
|
|
@@ -221,6 +221,42 @@ var ApiResponse = class {
|
|
|
221
221
|
this._jsWapiResponse.setPagesPredict(pagesPredict);
|
|
222
222
|
return this;
|
|
223
223
|
}
|
|
224
|
+
sendZip({ name, contentType = "application/zip", files }) {
|
|
225
|
+
return this._jsWapiResponse.sendZip({
|
|
226
|
+
name,
|
|
227
|
+
contentType,
|
|
228
|
+
callback: (zip) => {
|
|
229
|
+
files.forEach((file) => {
|
|
230
|
+
const isEmptyDirectory = !file.objectName && !file.operation && !file.keyValue && !file.field;
|
|
231
|
+
if (isEmptyDirectory) {
|
|
232
|
+
zip.add({ name: file.name });
|
|
233
|
+
} else {
|
|
234
|
+
zip.add({
|
|
235
|
+
name: file.name,
|
|
236
|
+
file: {
|
|
237
|
+
object: file.objectName,
|
|
238
|
+
oper: file.operation || "List",
|
|
239
|
+
keyValue: file.keyValue,
|
|
240
|
+
field: file.field
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
sendFile({ name, contentType, file }) {
|
|
249
|
+
return this._jsWapiResponse.sendFile({
|
|
250
|
+
name,
|
|
251
|
+
contentType,
|
|
252
|
+
file: {
|
|
253
|
+
object: file.objectName,
|
|
254
|
+
oper: file.operation || "List",
|
|
255
|
+
keyValue: file.keyValue,
|
|
256
|
+
field: file.field
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
224
260
|
};
|
|
225
261
|
|
|
226
262
|
// src/classes/ApiInvoker.ts
|
|
@@ -549,10 +585,10 @@ var ApiCore = class {
|
|
|
549
585
|
* Валидирует xml по переданому xsd.
|
|
550
586
|
* Если валидация происходит с ошибками, то бросается исключение.
|
|
551
587
|
*/
|
|
552
|
-
validateXml(xml, xsd) {
|
|
588
|
+
validateXml(xml, xsd, options) {
|
|
553
589
|
if (!this.httpSender.validateXml)
|
|
554
590
|
throw this.newApiException("validateXml() is not allowed");
|
|
555
|
-
return this.httpSender.validateXml(xsd, xml);
|
|
591
|
+
return this.httpSender.validateXml(xsd, xml, options);
|
|
556
592
|
}
|
|
557
593
|
/*
|
|
558
594
|
* Will be implemented later
|
|
@@ -221,6 +221,42 @@ var ApiResponse = class {
|
|
|
221
221
|
this._jsWapiResponse.setPagesPredict(pagesPredict);
|
|
222
222
|
return this;
|
|
223
223
|
}
|
|
224
|
+
sendZip({ name, contentType = "application/zip", files }) {
|
|
225
|
+
return this._jsWapiResponse.sendZip({
|
|
226
|
+
name,
|
|
227
|
+
contentType,
|
|
228
|
+
callback: (zip) => {
|
|
229
|
+
files.forEach((file) => {
|
|
230
|
+
const isEmptyDirectory = !file.objectName && !file.operation && !file.keyValue && !file.field;
|
|
231
|
+
if (isEmptyDirectory) {
|
|
232
|
+
zip.add({ name: file.name });
|
|
233
|
+
} else {
|
|
234
|
+
zip.add({
|
|
235
|
+
name: file.name,
|
|
236
|
+
file: {
|
|
237
|
+
object: file.objectName,
|
|
238
|
+
oper: file.operation || "List",
|
|
239
|
+
keyValue: file.keyValue,
|
|
240
|
+
field: file.field
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
sendFile({ name, contentType, file }) {
|
|
249
|
+
return this._jsWapiResponse.sendFile({
|
|
250
|
+
name,
|
|
251
|
+
contentType,
|
|
252
|
+
file: {
|
|
253
|
+
object: file.objectName,
|
|
254
|
+
oper: file.operation || "List",
|
|
255
|
+
keyValue: file.keyValue,
|
|
256
|
+
field: file.field
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
224
260
|
};
|
|
225
261
|
|
|
226
262
|
// src/classes/ApiInvoker.ts
|
|
@@ -549,10 +585,10 @@ var ApiCore = class {
|
|
|
549
585
|
* Валидирует xml по переданому xsd.
|
|
550
586
|
* Если валидация происходит с ошибками, то бросается исключение.
|
|
551
587
|
*/
|
|
552
|
-
validateXml(xml, xsd) {
|
|
588
|
+
validateXml(xml, xsd, options) {
|
|
553
589
|
if (!this.httpSender.validateXml)
|
|
554
590
|
throw this.newApiException("validateXml() is not allowed");
|
|
555
|
-
return this.httpSender.validateXml(xsd, xml);
|
|
591
|
+
return this.httpSender.validateXml(xsd, xml, options);
|
|
556
592
|
}
|
|
557
593
|
/*
|
|
558
594
|
* Will be implemented later
|