d5-api-initializer 1.5.3 → 1.5.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d5-api-initializer",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "license": "MIT",
5
5
  "dependencies": {},
6
6
  "main": "publish/cjs/d5-api-initializer",
@@ -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
@@ -363,7 +399,6 @@ var ApiInvoker = class {
363
399
  }
364
400
  getSrcRequest() {
365
401
  throw new Error("not implemented");
366
- return this._jsWapiInvoker.getSrcRequest();
367
402
  }
368
403
  setColumns(columns) {
369
404
  this.columns = columns;
@@ -409,6 +444,14 @@ var ApiInvoker = class {
409
444
  this._jsWapiInvoker = this._jsWapiInvoker.addSorts(sorts);
410
445
  return this;
411
446
  }
447
+ addFile(fileID, fileStream) {
448
+ this._jsWapiInvoker = this._jsWapiInvoker.addFile(fileID, fileStream);
449
+ return this;
450
+ }
451
+ addRequestRow(data) {
452
+ this._jsWapiInvoker = this._jsWapiInvoker.addRequestRow(data);
453
+ return this;
454
+ }
412
455
  /* ------------------------------Other------------------------------ */
413
456
  invoke() {
414
457
  return new ApiResponse(this._jsWapiInvoker.invoke(), this._objectName);
@@ -910,6 +953,9 @@ var ApiRequest = class {
910
953
  addWatermarkToPdf(params) {
911
954
  addWatermarkToPdf(this._jsWapiRequest, params);
912
955
  }
956
+ unzip(params) {
957
+ return this._jsWapiRequest.zip().unzip(params);
958
+ }
913
959
  /**
914
960
  * Вернуть содержимое meta-Excel в виде JSON-объекта:
915
961
  * @param fileRequestId имя поля в multipart-запросе с Excel-файлом
@@ -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;
@@ -31,6 +46,8 @@ declare namespace jsWapi {
31
46
  setSingleColumn(column: string): JSWapiInvoker;
32
47
  invokeAndGetFileAsString(): string;
33
48
  invokeAndGetExcelFileAsJson(): Map<string, any>;
49
+ addRequestRow(row: Record<string, any>): JSWapiInvoker;
50
+ addFile(fileID: string, file: any): JSWapiInvoker;
34
51
  invoke(): JSWapiResponse;
35
52
  };
36
53
  type JSWapiRequest = {
@@ -61,6 +78,7 @@ declare namespace jsWapi {
61
78
  getRowsPerPage(): number;
62
79
  getLanguage(): string;
63
80
  pdf(): JSWapiPdf;
81
+ zip(): JSWapiZip;
64
82
  xls(): JSWapiXls;
65
83
  getMultiFileAsString(...arg: string[]): any;
66
84
  getMultiExcelFileAsJson(...arg: string[]): any;
@@ -95,6 +113,8 @@ declare namespace jsWapi {
95
113
  sendHttpResponse(body: string | BinaryDataStream): void;
96
114
  sendHttpResponse(headers: Record<string, any>, body: string | BinaryDataStream): void;
97
115
  getPagesPredict(): number;
116
+ sendZip({ name, contentType, callback }: SendZipJsWapiArgs): void;
117
+ sendFile({ name, contentType, file }: SendFileJsWapiArgs): void;
98
118
  setPagesPredict(pagesPredict: number): void;
99
119
  getPage(): number;
100
120
  setPage(page: number): void;
@@ -220,6 +240,30 @@ declare namespace jsWapi {
220
240
  interface JSWapiPdf {
221
241
  load(params: JSWapiPdfLoadParams): JSWapiPdf;
222
242
  }
243
+ interface JSZipEntity {
244
+ /**
245
+ * полное имя файла вместе с директориями
246
+ * @example
247
+ * zipEntry.name() === "1/2/3/tax.xlsx"
248
+ */
249
+ name(): string;
250
+ /**
251
+ * true, если это директория
252
+ */
253
+ isDirectory(): boolean;
254
+ }
255
+ interface JSWapiZip {
256
+ /**
257
+ *
258
+ * @param {Object} params
259
+ * @param params.callback Функция в callback вызывается для каждого элемента zip-файла.
260
+ *
261
+ */
262
+ unzip(params: {
263
+ fileRequestId: string;
264
+ callback: (zipEntry: JSZipEntity) => void;
265
+ }): JSWapiPdf;
266
+ }
223
267
  /**
224
268
  * Вернуть содержимое meta-Excel в виде JSON-объекта:
225
269
  {
@@ -280,6 +324,23 @@ declare class ApiHttpRequest {
280
324
  private _getWrappedCallback;
281
325
  }
282
326
 
327
+ type FileEntry = {
328
+ name: string;
329
+ objectName?: string;
330
+ operation?: string;
331
+ keyValue?: any;
332
+ field?: string;
333
+ };
334
+ type SendZipOptions = {
335
+ name: string;
336
+ contentType?: string;
337
+ files: FileEntry[];
338
+ };
339
+ type SendFileOptions = {
340
+ name: string;
341
+ contentType?: string;
342
+ file: FileEntry;
343
+ };
283
344
  declare class ApiResponse {
284
345
  private _jsWapiResponse;
285
346
  private readonly _objectName;
@@ -296,6 +357,8 @@ declare class ApiResponse {
296
357
  setPage(page: number): this;
297
358
  getPagesPredict(): number;
298
359
  setPagesPredict(pagesPredict: number): this;
360
+ sendZip({ name, contentType, files }: SendZipOptions): void;
361
+ sendFile({ name, contentType, file }: SendFileOptions): void;
299
362
  }
300
363
 
301
364
  interface IInvoker$1<T> {
@@ -348,6 +411,8 @@ declare class ApiInvoker implements IInvoker$1<ApiInvoker> {
348
411
  addAggregatedColumns(aggregatedColumns: IMappedCollection): ApiInvoker;
349
412
  addNestedColumns(nestedColumns: IMappedCollection): ApiInvoker;
350
413
  addSorts(sorts: string[]): ApiInvoker;
414
+ addFile(fileID: string, fileStream: any): ApiInvoker;
415
+ addRequestRow(data: Record<string, any>): ApiInvoker;
351
416
  invoke(): ApiResponse;
352
417
  }
353
418
 
@@ -456,6 +521,10 @@ declare class ApiRequest {
456
521
  newJSWapiInvoker(objectName: string, operName: string): jsWapi.JSWapiInvoker;
457
522
  newApiInvoker(objectName: string, operName: string): ApiInvoker;
458
523
  addWatermarkToPdf(params: AddWatermarkToPdfParams): void;
524
+ unzip(params: {
525
+ fileRequestId: string;
526
+ callback: (zipEntry: jsWapi.JSZipEntity) => void;
527
+ }): jsWapi.JSWapiPdf;
459
528
  /**
460
529
  * Вернуть содержимое meta-Excel в виде JSON-объекта:
461
530
  * @param fileRequestId имя поля в multipart-запросе с Excel-файлом
@@ -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
@@ -324,7 +360,6 @@ var ApiInvoker = class {
324
360
  }
325
361
  getSrcRequest() {
326
362
  throw new Error("not implemented");
327
- return this._jsWapiInvoker.getSrcRequest();
328
363
  }
329
364
  setColumns(columns) {
330
365
  this.columns = columns;
@@ -370,6 +405,14 @@ var ApiInvoker = class {
370
405
  this._jsWapiInvoker = this._jsWapiInvoker.addSorts(sorts);
371
406
  return this;
372
407
  }
408
+ addFile(fileID, fileStream) {
409
+ this._jsWapiInvoker = this._jsWapiInvoker.addFile(fileID, fileStream);
410
+ return this;
411
+ }
412
+ addRequestRow(data) {
413
+ this._jsWapiInvoker = this._jsWapiInvoker.addRequestRow(data);
414
+ return this;
415
+ }
373
416
  /* ------------------------------Other------------------------------ */
374
417
  invoke() {
375
418
  return new ApiResponse(this._jsWapiInvoker.invoke(), this._objectName);
@@ -871,6 +914,9 @@ var ApiRequest = class {
871
914
  addWatermarkToPdf(params) {
872
915
  addWatermarkToPdf(this._jsWapiRequest, params);
873
916
  }
917
+ unzip(params) {
918
+ return this._jsWapiRequest.zip().unzip(params);
919
+ }
874
920
  /**
875
921
  * Вернуть содержимое meta-Excel в виде JSON-объекта:
876
922
  * @param fileRequestId имя поля в multipart-запросе с Excel-файлом
@@ -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
@@ -324,7 +360,6 @@ var ApiInvoker = class {
324
360
  }
325
361
  getSrcRequest() {
326
362
  throw new Error("not implemented");
327
- return this._jsWapiInvoker.getSrcRequest();
328
363
  }
329
364
  setColumns(columns) {
330
365
  this.columns = columns;
@@ -370,6 +405,14 @@ var ApiInvoker = class {
370
405
  this._jsWapiInvoker = this._jsWapiInvoker.addSorts(sorts);
371
406
  return this;
372
407
  }
408
+ addFile(fileID, fileStream) {
409
+ this._jsWapiInvoker = this._jsWapiInvoker.addFile(fileID, fileStream);
410
+ return this;
411
+ }
412
+ addRequestRow(data) {
413
+ this._jsWapiInvoker = this._jsWapiInvoker.addRequestRow(data);
414
+ return this;
415
+ }
373
416
  /* ------------------------------Other------------------------------ */
374
417
  invoke() {
375
418
  return new ApiResponse(this._jsWapiInvoker.invoke(), this._objectName);
@@ -871,6 +914,9 @@ var ApiRequest = class {
871
914
  addWatermarkToPdf(params) {
872
915
  addWatermarkToPdf(this._jsWapiRequest, params);
873
916
  }
917
+ unzip(params) {
918
+ return this._jsWapiRequest.zip().unzip(params);
919
+ }
874
920
  /**
875
921
  * Вернуть содержимое meta-Excel в виде JSON-объекта:
876
922
  * @param fileRequestId имя поля в multipart-запросе с Excel-файлом