@gsp-svc/formdoc-upload 0.1.38 → 0.2.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.
Files changed (48) hide show
  1. package/bundles/gsp-svc-formdoc-upload.umd.js +434 -341
  2. package/bundles/gsp-svc-formdoc-upload.umd.js.map +1 -1
  3. package/bundles/gsp-svc-formdoc-upload.umd.min.js +1 -1
  4. package/bundles/gsp-svc-formdoc-upload.umd.min.js.map +1 -1
  5. package/esm2015/lib/i18n/language.resource.js +9 -5
  6. package/esm2015/lib/upload/download.service.js +9 -1
  7. package/esm2015/lib/upload/entity/completemultiuploadrequest.js +21 -0
  8. package/esm2015/lib/upload/entity/{gspdocsecuritynaseinfo.js → gspdocsecuritybaseinfo.js} +1 -1
  9. package/esm2015/lib/upload/entity/gspformstreamentity.js +25 -0
  10. package/esm2015/lib/upload/entity/gspformuploadentity.js +1 -1
  11. package/esm2015/lib/upload/entity/initmultiuploadrequest.js +19 -0
  12. package/esm2015/lib/upload/entity/multiuploadrequest.js +21 -0
  13. package/esm2015/lib/upload/entity/multiuploadresult.js +13 -0
  14. package/esm2015/lib/upload/entity/uploadlimit.js +1 -1
  15. package/esm2015/lib/upload/file-upload/file-upload.component.js +354 -284
  16. package/esm2015/lib/upload/upload.service.js +5 -30
  17. package/esm2015/public-api.js +2 -2
  18. package/esm5/lib/i18n/language.resource.js +9 -5
  19. package/esm5/lib/upload/download.service.js +14 -1
  20. package/esm5/lib/upload/entity/completemultiuploadrequest.js +25 -0
  21. package/esm5/lib/upload/entity/{gspdocsecuritynaseinfo.js → gspdocsecuritybaseinfo.js} +1 -1
  22. package/esm5/lib/upload/entity/gspformstreamentity.js +29 -0
  23. package/esm5/lib/upload/entity/gspformuploadentity.js +1 -1
  24. package/esm5/lib/upload/entity/initmultiuploadrequest.js +23 -0
  25. package/esm5/lib/upload/entity/multiuploadrequest.js +25 -0
  26. package/esm5/lib/upload/entity/multiuploadresult.js +17 -0
  27. package/esm5/lib/upload/entity/uploadlimit.js +1 -1
  28. package/esm5/lib/upload/file-upload/file-upload.component.js +368 -296
  29. package/esm5/lib/upload/upload.service.js +5 -34
  30. package/esm5/public-api.js +2 -2
  31. package/fesm2015/gsp-svc-formdoc-upload.js +410 -329
  32. package/fesm2015/gsp-svc-formdoc-upload.js.map +1 -1
  33. package/fesm5/gsp-svc-formdoc-upload.js +447 -351
  34. package/fesm5/gsp-svc-formdoc-upload.js.map +1 -1
  35. package/gsp-svc-formdoc-upload.metadata.json +1 -1
  36. package/lib/i18n/language.resource.d.ts +4 -0
  37. package/lib/upload/download.service.d.ts +1 -0
  38. package/lib/upload/entity/completemultiuploadrequest.d.ts +9 -0
  39. package/lib/upload/entity/gspformstreamentity.d.ts +12 -0
  40. package/lib/upload/entity/initmultiuploadrequest.d.ts +7 -0
  41. package/lib/upload/entity/multiuploadrequest.d.ts +8 -0
  42. package/lib/upload/entity/multiuploadresult.d.ts +4 -0
  43. package/lib/upload/entity/uploadlimit.d.ts +1 -1
  44. package/lib/upload/file-upload/file-upload.component.d.ts +10 -6
  45. package/lib/upload/upload.service.d.ts +2 -3
  46. package/package.json +1 -1
  47. package/public-api.d.ts +1 -1
  48. /package/lib/upload/entity/{gspdocsecuritynaseinfo.d.ts → gspdocsecuritybaseinfo.d.ts} +0 -0
@@ -92,16 +92,6 @@
92
92
  DocType[DocType.Image] = 'Image';
93
93
  DocType[DocType.Other] = 'Other';
94
94
 
95
- /**
96
- * @fileoverview added by tsickle
97
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
98
- */
99
- var GspFormDocInfo = /** @class */ (function () {
100
- function GspFormDocInfo() {
101
- }
102
- return GspFormDocInfo;
103
- }());
104
-
105
95
  /**
106
96
  * @fileoverview added by tsickle
107
97
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -414,15 +404,10 @@
414
404
  request.metadataId = metadataId;
415
405
  request.rootId = rootId;
416
406
  request.path = path;
417
- return this.http.post(url, request).pipe(operators.tap(( /**
407
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(operators.tap(( /**
418
408
  * @param {?} res
419
409
  * @return {?}
420
- */function (res) { })), operators.catchError(( /**
421
- * @param {?} error
422
- * @return {?}
423
- */function (error) {
424
- return of.of(error);
425
- })));
410
+ */function (res) { })));
426
411
  };
427
412
  /**
428
413
  * @param {?} uploadFileInfoList
@@ -485,34 +470,13 @@
485
470
  * @param {?} rootId
486
471
  * @return {?}
487
472
  */
488
- UploadService.prototype.getRootSetting = /**
473
+ UploadService.prototype.getUploadInfo = /**
489
474
  * @param {?} rootId
490
475
  * @return {?}
491
476
  */
492
477
  function (rootId) {
493
478
  /** @type {?} */
494
- var url = "/api/runtime/dfs/v1.0/rootsetting/" + rootId;
495
- return this.http.get(url).pipe(operators.tap(( /**
496
- * @param {?} res
497
- * @return {?}
498
- */function (res) { })), operators.catchError(( /**
499
- * @param {?} error
500
- * @return {?}
501
- */function (error) {
502
- return of.of(error);
503
- })));
504
- };
505
- /**
506
- * @param {?} id
507
- * @return {?}
508
- */
509
- UploadService.prototype.getValidation = /**
510
- * @param {?} id
511
- * @return {?}
512
- */
513
- function (id) {
514
- /** @type {?} */
515
- var url = "/api/runtime/dfs/v1.0/validation/" + id;
479
+ var url = "/api/runtime/dfs/v1.0/rootsetting/info?id=" + rootId;
516
480
  return this.http.get(url).pipe(operators.tap(( /**
517
481
  * @param {?} res
518
482
  * @return {?}
@@ -546,16 +510,6 @@
546
510
  return UploadFileInfo;
547
511
  }());
548
512
 
549
- /**
550
- * @fileoverview added by tsickle
551
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
552
- */
553
- var GspFormUploadEntity = /** @class */ (function () {
554
- function GspFormUploadEntity() {
555
- }
556
- return GspFormUploadEntity;
557
- }());
558
-
559
513
  /**
560
514
  * @fileoverview added by tsickle
561
515
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -610,7 +564,8 @@
610
564
  'operation': '操作',
611
565
  'size': '大小',
612
566
  'close': '关闭',
613
- 'loading': '拼命加载中'
567
+ 'loading': '拼命加载中',
568
+ 'mismatchChunkSize': '文档分片上传部分丢失,请重新上传,如果多次上传失败,请联系管理员。'
614
569
  },
615
570
  'en-US': {
616
571
  'uploadFile': 'Upload File',
@@ -638,7 +593,8 @@
638
593
  'operation': 'Operation',
639
594
  'size': 'Size',
640
595
  'close': 'Close',
641
- 'loading': 'Loading'
596
+ 'loading': 'Loading',
597
+ 'mismatchChunkSize': 'The partial upload of document shards is missing. Please upload again. If multiple uploads fail, please contact the administrator.'
642
598
  },
643
599
  'en': {
644
600
  'uploadFile': 'Upload File',
@@ -666,7 +622,8 @@
666
622
  'operation': 'Operation',
667
623
  'size': 'Size',
668
624
  'close': 'Close',
669
- 'loading': 'Loading'
625
+ 'loading': 'Loading',
626
+ 'mismatchChunkSize': 'The partial upload of document shards is missing. Please upload again. If multiple uploads fail, please contact the administrator.'
670
627
  },
671
628
  'zh-CHT': {
672
629
  'uploadFile': '上傳文件',
@@ -694,7 +651,8 @@
694
651
  'operation': '操作',
695
652
  'size': '大小',
696
653
  'close': '關閉',
697
- 'loading': '拼命加載中'
654
+ 'loading': '拼命加載中',
655
+ 'mismatchChunkSize': '文檔分片上傳部分遺失,請重新上傳,如果多次上傳失敗,請聯系管理員。'
698
656
  },
699
657
  };
700
658
 
@@ -731,6 +689,46 @@
731
689
  return LocalLangPipe;
732
690
  }());
733
691
 
692
+ /**
693
+ * @fileoverview added by tsickle
694
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
695
+ */
696
+ var InitMultiUploadRequest = /** @class */ (function () {
697
+ function InitMultiUploadRequest() {
698
+ }
699
+ return InitMultiUploadRequest;
700
+ }());
701
+
702
+ /**
703
+ * @fileoverview added by tsickle
704
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
705
+ */
706
+ var CompleteMultiUploadRequest = /** @class */ (function () {
707
+ function CompleteMultiUploadRequest() {
708
+ }
709
+ return CompleteMultiUploadRequest;
710
+ }());
711
+
712
+ /**
713
+ * @fileoverview added by tsickle
714
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
715
+ */
716
+ var GspFormStreamEntity = /** @class */ (function () {
717
+ function GspFormStreamEntity() {
718
+ }
719
+ return GspFormStreamEntity;
720
+ }());
721
+
722
+ /**
723
+ * @fileoverview added by tsickle
724
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
725
+ */
726
+ var MultiUploadRequest = /** @class */ (function () {
727
+ function MultiUploadRequest() {
728
+ }
729
+ return MultiUploadRequest;
730
+ }());
731
+
734
732
  /**
735
733
  * @fileoverview added by tsickle
736
734
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -750,7 +748,7 @@
750
748
  this.beyondFileList = [];
751
749
  this.showType = 0;
752
750
  this.mouseOn = false;
753
- this.bufferSize = 10 * 1024 * 1024;
751
+ this.bufferSize = 5 * 1024 * 1024;
754
752
  this.selectedFileCount = 0;
755
753
  this.uploadIconAddress = '/platform/runtime/dfs/images/upload.svg';
756
754
  this.uploadLittleIconAddress = '/platform/runtime/dfs/images/uploadIcon.svg';
@@ -758,8 +756,6 @@
758
756
  this.fileAllSelected = false;
759
757
  this.uploadProcess = { width: '0%' };
760
758
  this.fileTotalChunk = {};
761
- //fileUploadState: { [key: string]: boolean } = {};
762
- //flag: number = 0;
763
759
  this.requestArray = new Array;
764
760
  this.requestBodyArray = new Array;
765
761
  this.uploadedChunk = {};
@@ -839,13 +835,14 @@
839
835
  _this.haveExtensionProperty = true;
840
836
  }
841
837
  }));
842
- this.uploadService.getRootSetting(this.rootId).subscribe(( /**
838
+ this.uploadService.getUploadInfo(this.rootId).subscribe(( /**
843
839
  * @param {?} res
844
840
  * @return {?}
845
841
  */function (res) {
846
842
  if (res != null && res.error == null) {
847
843
  _this.sameNameAllowed = res.sameNameAllowed;
848
- _this.validationId = res.validationId;
844
+ _this.maxFileSize = parseInt(JSON.parse(res.validateConfiguration).maxFileSize);
845
+ _this.allowedMultiUpload = res.allowedMultiUpload;
849
846
  if (!_this.sameNameAllowed) {
850
847
  _this.uploadService.getUploadedFileInfoList(_this.formId, _this.rootId).subscribe(( /**
851
848
  * @param {?} res
@@ -857,17 +854,9 @@
857
854
  }
858
855
  }));
859
856
  }
860
- _this.uploadService.getValidation(_this.validationId).subscribe(( /**
861
- * @param {?} res
862
- * @return {?}
863
- */function (res) {
864
- _this.maxFileSize = parseInt(JSON.parse(res.configuration).maxFileSize);
865
- }));
866
857
  }
867
858
  }));
868
- if (this.oldIdList != null && this.oldIdList.length > 0) {
869
- this.uploadService.cancel(this.oldIdList, this.rootId).subscribe();
870
- }
859
+ if (this.oldIdList != null && this.oldIdList.length > 0) ;
871
860
  };
872
861
  /**
873
862
  * @return {?}
@@ -891,12 +880,7 @@
891
880
  * @return {?}
892
881
  */
893
882
  function ($event) {
894
- // const loading = this.loadService.show({
895
- // message: this.localepipe.transform('uploading')
896
- // });
897
883
  var _this = this;
898
- // this.totalLoad.close();
899
- // this.totalLoad = null;
900
884
  this.hasSelectedFile = true;
901
885
  this.selectedFiles = document.querySelector('#file');
902
886
  if (this.fileCount > 0) {
@@ -928,11 +912,6 @@
928
912
  * @param {?} x
929
913
  * @return {?}
930
914
  */function (x) { return x.fileName == selectedFile.name; })) != null) {
931
- // this.uploadedNameList.push(selectedFile.name);
932
- // this.msgService.question('之前已上传过同名文件: ' + selectedFile.name + ',需要替换么?', () => {
933
- // uuid = this.uploadedFileInfoList.find(x => x.fileName == selectedFile.name).metadataId;
934
- // this.uploadFile(uuid, selectedFile);
935
- // })
936
915
  /** @type {?} */
937
916
  var msg_1 = this_1.msgService.show('warning', this_1.localepipe.transform('haveSameName') + selectedFile.name, {
938
917
  initialState: {
@@ -1013,11 +992,6 @@
1013
992
  for (var i = 0; i < this.selectedFiles.files.length; i++) {
1014
993
  _loop_1(i);
1015
994
  }
1016
- // if (this.uploadedNameList.length > 0) {
1017
- // let name: string = this.listToString(this.uploadedNameList);
1018
- // this.msgService.warning('之前已上传过同名文件: ' + name + '请重新选择上传文件。');
1019
- // this.uploadedNameList = [];
1020
- // }
1021
995
  if (this.errFileList.length > 0) {
1022
996
  /** @type {?} */
1023
997
  var name_1 = this.listToString(this.errFileList);
@@ -1038,11 +1012,6 @@
1038
1012
  this.msgService.warning(name_3 + this.localepipe.transform('sizeMax') + this.maxFileSize + "KB" + this.localepipe.transform('rechooseFile'));
1039
1013
  this.beyondFileList = [];
1040
1014
  }
1041
- // if (this.errTypeList.length > 0) {
1042
- // let type: string = this.listToString(this.errTypeList);
1043
- // this.msgService.warning('不支持上传类型为 ' + type + '的文件请重新选择上传文件。');
1044
- // this.errTypeList = [];
1045
- // }
1046
1015
  this.files = this.files.slice();
1047
1016
  this.fileAllSelected = false;
1048
1017
  $event.target.value = '';
@@ -1072,68 +1041,62 @@
1072
1041
  * @return {?}
1073
1042
  */
1074
1043
  function (uuid, selectedFile, fileName) {
1075
- var _this = this;
1076
- return new Promise(( /**
1077
- * @param {?} resolve
1078
- * @return {?}
1079
- */function (resolve) {
1080
- /** @type {?} */
1081
- var fileInfo;
1082
- fileInfo = {
1083
- id: uuid,
1084
- name: fileName,
1085
- type: selectedFile.type,
1086
- source: "",
1087
- size: _this.getFileSize(selectedFile.size),
1088
- fileSize: selectedFile.size,
1089
- picListDisplayName: _this.getPicListDisplayName(fileName),
1090
- queueListDisplayName: _this.getQueueDisplayName(fileName),
1091
- //content: reader.result.toString(),
1092
- hasUploaded: false,
1093
- mouseOn: false,
1094
- selectd: false,
1095
- isUploading: true,
1096
- uploadResult: false,
1097
- uploadProcess: 0,
1098
- errorMessage: "",
1099
- extensionDropListId: 0,
1100
- extensionName: "",
1101
- securityDropListId: 0,
1102
- securityInfo: _this.securityInfoList[0]
1103
- };
1104
- if (_this.storageExtension != null)
1105
- fileInfo.extensionName = _this.defaultPropertyName;
1106
- /** @type {?} */
1107
- var type = selectedFile.type;
1108
- if (type.includes("tiff")) {
1109
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1110
- }
1111
- else if (type.includes("image")) {
1112
- _this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1113
- }
1114
- else if (type.includes("word")) {
1115
- _this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1116
- }
1117
- else if (type.includes("pdf")) {
1118
- _this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1119
- }
1120
- else if (type.includes("plain")) {
1121
- _this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1122
- }
1123
- else if (type.includes("sheet") || type.includes("excel")) {
1124
- _this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1125
- }
1126
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1127
- _this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1128
- }
1129
- else {
1130
- _this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1131
- // let name: string = selectedFile.name;
1132
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1133
- // this.errTypeList.push(errType);
1134
- }
1135
- resolve(fileInfo);
1136
- }));
1044
+ /** @type {?} */
1045
+ var fileInfo;
1046
+ fileInfo = {
1047
+ id: uuid,
1048
+ name: fileName,
1049
+ type: selectedFile.type,
1050
+ source: "",
1051
+ size: this.getFileSize(selectedFile.size),
1052
+ fileSize: selectedFile.size,
1053
+ picListDisplayName: this.getPicListDisplayName(fileName),
1054
+ queueListDisplayName: this.getQueueDisplayName(fileName),
1055
+ //content: reader.result.toString(),
1056
+ hasUploaded: false,
1057
+ mouseOn: false,
1058
+ selectd: false,
1059
+ isUploading: true,
1060
+ uploadResult: false,
1061
+ uploadProcess: 0,
1062
+ errorMessage: "",
1063
+ extensionDropListId: 0,
1064
+ extensionName: "",
1065
+ securityDropListId: 0,
1066
+ securityInfo: this.securityInfoList[0]
1067
+ };
1068
+ if (this.storageExtension != null)
1069
+ fileInfo.extensionName = this.defaultPropertyName;
1070
+ /** @type {?} */
1071
+ var type = selectedFile.type;
1072
+ if (type.includes("tiff")) {
1073
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1074
+ }
1075
+ else if (type.includes("image")) {
1076
+ this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1077
+ }
1078
+ else if (type.includes("word")) {
1079
+ this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1080
+ }
1081
+ else if (type.includes("pdf")) {
1082
+ this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1083
+ }
1084
+ else if (type.includes("plain")) {
1085
+ this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1086
+ }
1087
+ else if (type.includes("sheet") || type.includes("excel")) {
1088
+ this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1089
+ }
1090
+ else if (type.includes("powerpoint") || type.includes("presentation")) {
1091
+ this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1092
+ }
1093
+ else {
1094
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1095
+ // let name: string = selectedFile.name;
1096
+ // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1097
+ // this.errTypeList.push(errType);
1098
+ }
1099
+ return fileInfo;
1137
1100
  };
1138
1101
  /**
1139
1102
  * @param {?} uuid
@@ -1154,123 +1117,183 @@
1154
1117
  if (state === void 0) {
1155
1118
  state = FileState.New;
1156
1119
  }
1157
- this.handleFileInfo(uuid, selectedFile, fileName).then(( /**
1158
- * @param {?} res
1159
- * @return {?}
1160
- */function (res) {
1161
- /** @type {?} */
1162
- var fileInfo = res;
1163
- /** @type {?} */
1164
- var chunkTotal = Math.ceil(selectedFile.size / _this.bufferSize);
1120
+ /** @type {?} */
1121
+ var fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1122
+ /** @type {?} */
1123
+ var uploadFileInfo = new UploadFileInfo();
1124
+ uploadFileInfo.metadataId = uuid;
1125
+ uploadFileInfo.fileName = fileInfo.name;
1126
+ uploadFileInfo.fileSize = fileInfo.fileSize;
1127
+ uploadFileInfo.state = state;
1128
+ uploadFileInfo.securityInfo = this.securityInfoList[0];
1129
+ //判断是否支持分片上传
1130
+ if (this.allowedMultiUpload) {
1131
+ //支持分片上传
1165
1132
  /** @type {?} */
1166
- var chunkIndex = 0;
1167
- _this.fileTotalChunk[uuid] = chunkTotal;
1133
+ var initRequest = new InitMultiUploadRequest;
1134
+ initRequest.path = this.formId;
1135
+ initRequest.metadataId = uuid;
1136
+ initRequest.rootId = this.rootId;
1137
+ initRequest.size = fileInfo.fileSize;
1138
+ initRequest.fileName = fileName;
1139
+ //初始化分片
1140
+ this.initMultiUpload(initRequest).subscribe(( /**
1141
+ * @param {?} res
1142
+ * @return {?}
1143
+ */function (res) {
1144
+ if (res.error != null) {
1145
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1146
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1147
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1148
+ }
1149
+ else {
1150
+ /** @type {?} */
1151
+ var uploadId_1 = res.uploadId;
1152
+ /** @type {?} */
1153
+ var chunkTotal = Math.ceil(selectedFile.size / _this.bufferSize);
1154
+ /** @type {?} */
1155
+ var chunkIndex = 0;
1156
+ /** @type {?} */
1157
+ var multiResultList_1 = [];
1158
+ _this.fileTotalChunk[uuid] = chunkTotal;
1159
+ _this.uploadedChunk[uuid] = 0;
1160
+ while (chunkIndex < chunkTotal) {
1161
+ /** @type {?} */
1162
+ var nextSize = Math.min((chunkIndex + 1) * _this.bufferSize, selectedFile.size);
1163
+ /** @type {?} */
1164
+ var fileData = selectedFile.slice(chunkIndex * _this.bufferSize, nextSize);
1165
+ /** @type {?} */
1166
+ var multiRequest = new MultiUploadRequest;
1167
+ multiRequest.metadataId = uuid;
1168
+ multiRequest.rootId = _this.rootId;
1169
+ multiRequest.uploadId = uploadId_1;
1170
+ multiRequest.index = chunkIndex;
1171
+ multiRequest.total = chunkTotal;
1172
+ multiRequest.size = fileData.size;
1173
+ /** @type {?} */
1174
+ var formData = new FormData();
1175
+ formData.append('multiRequest', JSON.stringify(multiRequest));
1176
+ formData.append('file', fileData);
1177
+ _this.multiUpload(formData).subscribe(( /**
1178
+ * @param {?} res
1179
+ * @return {?}
1180
+ */function (res) {
1181
+ if (res.error != null) {
1182
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1183
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1184
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1185
+ }
1186
+ else {
1187
+ multiResultList_1.push(res.result);
1188
+ _this.uploadedChunk[uuid]++;
1189
+ _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[uuid] / _this.fileTotalChunk[uuid] * 100).toFixed(0));
1190
+ if (_this.uploadedChunk[uuid] == _this.fileTotalChunk[uuid]) {
1191
+ if (multiResultList_1.length == _this.fileTotalChunk[uuid]) {
1192
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1193
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1194
+ _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1195
+ _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1196
+ _this.uploadedFileTotal++;
1197
+ /** @type {?} */
1198
+ var completeMultiUploadRequest = new CompleteMultiUploadRequest;
1199
+ completeMultiUploadRequest.metadataId = uuid;
1200
+ completeMultiUploadRequest.partList = multiResultList_1;
1201
+ completeMultiUploadRequest.rootId = _this.rootId;
1202
+ completeMultiUploadRequest.uploadId = uploadId_1;
1203
+ completeMultiUploadRequest.size = fileInfo.fileSize;
1204
+ if (_this.haveExtensionProperty)
1205
+ completeMultiUploadRequest.exPropertyName = _this.defaultPropertyName;
1206
+ _this.completeMultiUpload(completeMultiUploadRequest).subscribe(( /**
1207
+ * @param {?} res
1208
+ * @return {?}
1209
+ */function (res) {
1210
+ }));
1211
+ //后台异步拼接文档
1212
+ }
1213
+ else {
1214
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1215
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1216
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = _this.localepipe.transform('mismatchChunkSize');
1217
+ }
1218
+ }
1219
+ }
1220
+ }));
1221
+ chunkIndex = chunkIndex + 1;
1222
+ }
1223
+ }
1224
+ }));
1225
+ }
1226
+ else {
1168
1227
  /** @type {?} */
1169
- var uploadFileInfo = new UploadFileInfo();
1170
- uploadFileInfo.metadataId = uuid;
1171
- uploadFileInfo.fileName = fileInfo.name;
1172
- uploadFileInfo.fileSize = fileInfo.size;
1173
- uploadFileInfo.state = state;
1174
- uploadFileInfo.securityInfo = _this.securityInfoList[0];
1175
- while (chunkIndex < chunkTotal) {
1176
- /** @type {?} */
1177
- var uploadInfo = new GspFormUploadEntity;
1178
- uploadInfo.formId = _this.formId;
1179
- uploadInfo.mode = OperatingModes.Temp;
1180
- uploadInfo.rootId = _this.rootId;
1181
- /** @type {?} */
1182
- var docInfo = new GspFormDocInfo;
1183
- docInfo.fileName = fileName;
1184
- docInfo.metadataId = uuid;
1185
- docInfo.total = chunkTotal;
1186
- _this.uploadedChunk[docInfo.metadataId] = 0;
1187
- /** @type {?} */
1188
- var nextSize = Math.min((chunkIndex + 1) * _this.bufferSize, selectedFile.size);
1189
- /** @type {?} */
1190
- var fileData = selectedFile.slice(chunkIndex * _this.bufferSize, nextSize);
1191
- // let reader = new FileReader();
1192
- // reader.readAsBinaryString(fileData);
1193
- /** @type {?} */
1194
- var innerIndex = chunkIndex;
1195
- // reader.onload = () => {
1196
- // docInfo.fileContent = btoa(reader.result.toString());
1197
- docInfo.size = selectedFile.size;
1198
- docInfo.index = innerIndex;
1199
- docInfo.fileContent = "";
1200
- //chunkIndex++;
1201
- if (_this.haveExtensionProperty)
1202
- docInfo.exPropertyName = _this.defaultPropertyName;
1203
- //docInfo.isLast = true;
1204
- uploadInfo.docInfo = docInfo;
1205
- // let info = uploadInfo;
1206
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1207
- // this.requestBodyArray.push(info);
1208
- //封装请求formdata
1209
- /** @type {?} */
1210
- var formData = new FormData();
1211
- formData.append('uploadInfo', JSON.stringify(uploadInfo));
1212
- formData.append('docInfo', JSON.stringify(docInfo));
1213
- formData.append('file', fileData);
1214
- // }
1215
- //console.log(chunkIndex + 1);
1216
- chunkIndex = chunkIndex + 1;
1217
- }
1228
+ var entity = new GspFormStreamEntity;
1229
+ entity.formId = this.formId;
1230
+ entity.metadataId = uuid;
1231
+ entity.mode = OperatingModes.Temp;
1232
+ entity.rootId = this.rootId;
1233
+ entity.size = selectedFile.size;
1234
+ entity.fileName = fileName;
1235
+ if (this.haveExtensionProperty)
1236
+ entity.exPropertyName = this.defaultPropertyName;
1218
1237
  /** @type {?} */
1219
- var index = -1;
1220
- _this.files.forEach(( /**
1221
- * @param {?} x
1238
+ var formData = new FormData();
1239
+ formData.append('uploadEntity', JSON.stringify(entity));
1240
+ formData.append('file', selectedFile);
1241
+ this.uploadSingleFile(formData).subscribe(( /**
1242
+ * @param {?} res
1222
1243
  * @return {?}
1223
- */function (x) {
1224
- if (x.name == fileInfo.name) {
1225
- if (index == -1)
1226
- index = _this.files.indexOf(x);
1244
+ */function (res) {
1245
+ if (res != null) {
1246
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1247
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1248
+ _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1249
+ }
1250
+ else {
1251
+ _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1252
+ _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1253
+ _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1254
+ _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1255
+ _this.uploadedFileTotal++;
1227
1256
  }
1228
1257
  }));
1229
- if (index != -1 && index != _this.files.length - 1) {
1230
- _this.files.splice(index, 1);
1231
- _this.uploadFileInfoList.splice(index, 1);
1232
- _this.uploadedFileInfoList.splice(index, 1);
1233
- _this.uploadedFileTotal--;
1258
+ }
1259
+ /** @type {?} */
1260
+ var index = -1;
1261
+ this.files.forEach(( /**
1262
+ * @param {?} x
1263
+ * @return {?}
1264
+ */function (x) {
1265
+ if (x.name == fileInfo.name) {
1266
+ if (index == -1)
1267
+ index = _this.files.indexOf(x);
1234
1268
  }
1235
1269
  }));
1270
+ if (index != -1 && index != this.files.length - 1) {
1271
+ this.files.splice(index, 1);
1272
+ this.uploadFileInfoList.splice(index, 1);
1273
+ this.uploadedFileInfoList.splice(index, 1);
1274
+ //this.uploadedFileTotal--;
1275
+ }
1236
1276
  };
1237
1277
  /**
1238
- * @param {?} formData
1239
- * @param {?} fileInfo
1240
- * @param {?} docInfo
1241
- * @param {?} uploadFileInfo
1278
+ * @param {?} formdata
1242
1279
  * @return {?}
1243
1280
  */
1244
- FileUploadComponent.prototype.sendUploadRequest = /**
1245
- * @param {?} formData
1246
- * @param {?} fileInfo
1247
- * @param {?} docInfo
1248
- * @param {?} uploadFileInfo
1281
+ FileUploadComponent.prototype.uploadSingleFile = /**
1282
+ * @param {?} formdata
1249
1283
  * @return {?}
1250
1284
  */
1251
- function (formData, fileInfo, docInfo, uploadFileInfo) {
1252
- var _this = this;
1253
- this.uploadSliceFile(formData).subscribe(( /**
1285
+ function (formdata) {
1286
+ /** @type {?} */
1287
+ var url = "/api/runtime/dfs/v1.0/formdoc/single";
1288
+ return this.httpclient.post(url, formdata).pipe(operators.tap(( /**
1254
1289
  * @param {?} res
1255
1290
  * @return {?}
1256
- */function (res) {
1257
- if (res != null) {
1258
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = false;
1259
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1260
- _this.files[_this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1261
- }
1262
- else {
1263
- _this.uploadedChunk[docInfo.metadataId]++;
1264
- _this.files[_this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((_this.uploadedChunk[docInfo.metadataId] / _this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1265
- if (_this.uploadedChunk[docInfo.metadataId] == _this.fileTotalChunk[docInfo.metadataId]) {
1266
- _this.files[_this.files.indexOf(fileInfo)].uploadResult = true;
1267
- _this.files[_this.files.indexOf(fileInfo)].isUploading = false;
1268
- _this.uploadFileInfoList = _this.uploadFileInfoList.concat(uploadFileInfo);
1269
- _this.uploadedFileInfoList = _this.uploadedFileInfoList.concat(uploadFileInfo);
1270
- _this.uploadedFileTotal++;
1271
- }
1272
- }
1273
- }));
1291
+ */function (res) { })), operators.catchError(( /**
1292
+ * @param {?} error
1293
+ * @return {?}
1294
+ */function (error) {
1295
+ return rxjs.of(error);
1296
+ })));
1274
1297
  };
1275
1298
  /**
1276
1299
  * @param {?} formdata
@@ -1283,7 +1306,6 @@
1283
1306
  function (formdata) {
1284
1307
  /** @type {?} */
1285
1308
  var url = "/api/runtime/dfs/v1.0/formdoc/slice";
1286
- //url = "/api/runtime/dfs/v1.0/formdoc/list";
1287
1309
  return this.httpclient.post(url, formdata).pipe(operators.tap(( /**
1288
1310
  * @param {?} res
1289
1311
  * @return {?}
@@ -1294,6 +1316,69 @@
1294
1316
  return rxjs.of(error);
1295
1317
  })));
1296
1318
  };
1319
+ /**
1320
+ * @param {?} request
1321
+ * @return {?}
1322
+ */
1323
+ FileUploadComponent.prototype.initMultiUpload = /**
1324
+ * @param {?} request
1325
+ * @return {?}
1326
+ */
1327
+ function (request) {
1328
+ /** @type {?} */
1329
+ var url = "/api/runtime/dfs/v1.0/formdoc/multi/init";
1330
+ return this.httpclient.post(url, request).pipe(operators.tap(( /**
1331
+ * @param {?} res
1332
+ * @return {?}
1333
+ */function (res) { })), operators.catchError(( /**
1334
+ * @param {?} error
1335
+ * @return {?}
1336
+ */function (error) {
1337
+ return rxjs.of(error);
1338
+ })));
1339
+ };
1340
+ /**
1341
+ * @param {?} formdata
1342
+ * @return {?}
1343
+ */
1344
+ FileUploadComponent.prototype.multiUpload = /**
1345
+ * @param {?} formdata
1346
+ * @return {?}
1347
+ */
1348
+ function (formdata) {
1349
+ /** @type {?} */
1350
+ var url = "/api/runtime/dfs/v1.0/formdoc/multi/upload";
1351
+ return this.httpclient.post(url, formdata).pipe(operators.tap(( /**
1352
+ * @param {?} res
1353
+ * @return {?}
1354
+ */function (res) { })), operators.catchError(( /**
1355
+ * @param {?} error
1356
+ * @return {?}
1357
+ */function (error) {
1358
+ return rxjs.of(error);
1359
+ })));
1360
+ };
1361
+ /**
1362
+ * @param {?} request
1363
+ * @return {?}
1364
+ */
1365
+ FileUploadComponent.prototype.completeMultiUpload = /**
1366
+ * @param {?} request
1367
+ * @return {?}
1368
+ */
1369
+ function (request) {
1370
+ /** @type {?} */
1371
+ var url = "/api/runtime/dfs/v1.0/formdoc/multi/complete";
1372
+ return this.httpclient.post(url, request).pipe(operators.tap(( /**
1373
+ * @param {?} res
1374
+ * @return {?}
1375
+ */function (res) { })), operators.catchError(( /**
1376
+ * @param {?} error
1377
+ * @return {?}
1378
+ */function (error) {
1379
+ return rxjs.of(error);
1380
+ })));
1381
+ };
1297
1382
  /**
1298
1383
  * @return {?}
1299
1384
  */
@@ -1306,8 +1391,6 @@
1306
1391
  * @param {?} element
1307
1392
  * @return {?}
1308
1393
  */function (element) {
1309
- // let obj: any = document.getElementById(element.name);
1310
- // obj.checked = true;
1311
1394
  element.selectd = true;
1312
1395
  }));
1313
1396
  this.fileAllSelected = true;
@@ -1318,8 +1401,6 @@
1318
1401
  * @param {?} element
1319
1402
  * @return {?}
1320
1403
  */function (element) {
1321
- // let obj: any = document.getElementById(element.name);
1322
- // obj.checked = false;
1323
1404
  element.selectd = false;
1324
1405
  }));
1325
1406
  this.fileAllSelected = false;
@@ -1409,9 +1490,6 @@
1409
1490
  metadataList.push(element.id);
1410
1491
  _this.files.splice(_this.files.indexOf(element), 1);
1411
1492
  if (element.uploadResult) {
1412
- // let idList: string[] = [];
1413
- // idList.push(fileInfo.id);
1414
- // this.uploadService.cancel(idList, this.rootId).subscribe();
1415
1493
  _this.uploadFileInfoList.splice(_this.uploadFileInfoList.indexOf(_this.uploadFileInfoList.filter(( /**
1416
1494
  * @param {?} x
1417
1495
  * @return {?}
@@ -1475,86 +1553,74 @@
1475
1553
  */
1476
1554
  function (selectdFile, fileInfo, docType) {
1477
1555
  var _this = this;
1478
- return new Promise(( /**
1479
- * @param {?} resolve
1480
- * @return {?}
1481
- */function (resolve) {
1482
- switch (docType) {
1483
- case DocType.Word: {
1484
- fileInfo.source = "/platform/runtime/dfs/images/word.png";
1485
- _this.files.push(fileInfo);
1486
- break;
1487
- }
1488
- case DocType.Pdf: {
1489
- fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1490
- _this.files.push(fileInfo);
1491
- break;
1492
- }
1493
- case DocType.Excel: {
1494
- fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1495
- _this.files.push(fileInfo);
1496
- break;
1497
- }
1498
- case DocType.Txt: {
1499
- fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1500
- _this.files.push(fileInfo);
1501
- break;
1502
- }
1503
- case DocType.Powerpoint: {
1504
- fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1505
- _this.files.push(fileInfo);
1506
- break;
1507
- }
1508
- case DocType.Other: {
1509
- fileInfo.source = "/platform/runtime/dfs/images/file.png";
1556
+ switch (docType) {
1557
+ case DocType.Word: {
1558
+ fileInfo.source = "/platform/runtime/dfs/images/word.png";
1559
+ this.files.push(fileInfo);
1560
+ break;
1561
+ }
1562
+ case DocType.Pdf: {
1563
+ fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1564
+ this.files.push(fileInfo);
1565
+ break;
1566
+ }
1567
+ case DocType.Excel: {
1568
+ fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1569
+ this.files.push(fileInfo);
1570
+ break;
1571
+ }
1572
+ case DocType.Txt: {
1573
+ fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1574
+ this.files.push(fileInfo);
1575
+ break;
1576
+ }
1577
+ case DocType.Powerpoint: {
1578
+ fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1579
+ this.files.push(fileInfo);
1580
+ break;
1581
+ }
1582
+ case DocType.Other: {
1583
+ fileInfo.source = "/platform/runtime/dfs/images/file.png";
1584
+ this.files.push(fileInfo);
1585
+ break;
1586
+ }
1587
+ case DocType.Image: {
1588
+ /** @type {?} */
1589
+ var reader_1 = new FileReader();
1590
+ reader_1.readAsDataURL(selectdFile);
1591
+ reader_1.onload = ( /**
1592
+ * @param {?} _event
1593
+ * @return {?}
1594
+ */function (_event) {
1595
+ /** @type {?} */
1596
+ var imgUrl = reader_1.result;
1597
+ if (_this.injector != null) {
1598
+ /** @type {?} */
1599
+ var sanitizer = _this.injector.get(platformBrowser.DomSanitizer);
1600
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1601
+ }
1602
+ fileInfo.source = imgUrl;
1510
1603
  _this.files.push(fileInfo);
1511
- break;
1512
- }
1513
- case DocType.Image: {
1514
- _this.getImageUrl(selectdFile).then(( /**
1515
- * @param {?} res
1604
+ //因为异步处理的差异,补偿一次删除
1605
+ /** @type {?} */
1606
+ var index = -1;
1607
+ _this.files.forEach(( /**
1608
+ * @param {?} x
1516
1609
  * @return {?}
1517
- */function (res) {
1518
- fileInfo.source = res;
1519
- _this.files.push(fileInfo);
1520
- resolve(fileInfo);
1610
+ */function (x) {
1611
+ if (x.name == fileInfo.name) {
1612
+ if (index == -1)
1613
+ index = _this.files.indexOf(x);
1614
+ }
1521
1615
  }));
1522
- }
1616
+ if (index != -1 && index != _this.files.length - 1) {
1617
+ _this.files.splice(index, 1);
1618
+ _this.uploadFileInfoList.splice(index, 1);
1619
+ _this.uploadedFileInfoList.splice(index, 1);
1620
+ }
1621
+ });
1523
1622
  }
1524
- resolve(fileInfo);
1525
- }));
1526
- };
1527
- /**
1528
- * @param {?} selectdFile
1529
- * @return {?}
1530
- */
1531
- FileUploadComponent.prototype.getImageUrl = /**
1532
- * @param {?} selectdFile
1533
- * @return {?}
1534
- */
1535
- function (selectdFile) {
1536
- var _this = this;
1537
- return new Promise(( /**
1538
- * @param {?} resolve
1539
- * @return {?}
1540
- */function (resolve) {
1541
- /** @type {?} */
1542
- var reader = new FileReader();
1543
- reader.readAsDataURL(selectdFile);
1544
- reader.onload = ( /**
1545
- * @param {?} _event
1546
- * @return {?}
1547
- */function (_event) {
1548
- /** @type {?} */
1549
- var imgUrl = reader.result;
1550
- if (_this.injector != null) {
1551
- /** @type {?} */
1552
- var sanitizer = _this.injector.get(platformBrowser.DomSanitizer);
1553
- imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1554
- }
1555
- resolve(imgUrl);
1556
- });
1557
- }));
1623
+ }
1558
1624
  };
1559
1625
  /**
1560
1626
  * @param {?} strList
@@ -1645,9 +1711,6 @@
1645
1711
  * @param {?} x
1646
1712
  * @return {?}
1647
1713
  */function (x) { return x.isUploading || x.uploadResult; })).length) {
1648
- // this.notifyService.success(<NotifyOptions>{
1649
- // msg: '保存成功!', timeout: 3000
1650
- // });
1651
1714
  this.msgService.warning(this.localepipe.transform('wait'));
1652
1715
  return rxjs.of(false);
1653
1716
  }
@@ -1724,9 +1787,6 @@
1724
1787
  * @return {?}
1725
1788
  */function (x) { return x.metadataId == file.id; })), 1);
1726
1789
  }
1727
- // var obj:any = document.querySelector('#file');
1728
- // obj.files.remove();
1729
- //obj.value='';
1730
1790
  };
1731
1791
  /**
1732
1792
  * @param {?} size
@@ -1841,6 +1901,19 @@
1841
1901
  function (metadataId, rootId) {
1842
1902
  return "/api/runtime/dfs/v1.0/doc/filecontent?metadataid=" + metadataId + "&rootid=" + rootId + "&token=" + this.getToken(this.mergeString(metadataId, rootId));
1843
1903
  };
1904
+ /**
1905
+ * @param {?} metadataId
1906
+ * @param {?} rootId
1907
+ * @return {?}
1908
+ */
1909
+ DownloadService.prototype.getStreamDownloadUrl = /**
1910
+ * @param {?} metadataId
1911
+ * @param {?} rootId
1912
+ * @return {?}
1913
+ */
1914
+ function (metadataId, rootId) {
1915
+ return "/api/runtime/dfs/v1.0/formdoc/stream?metadataid=" + metadataId + "&rootid=" + rootId + "&token=" + this.getToken(this.mergeString(metadataId, rootId));
1916
+ };
1844
1917
  /**
1845
1918
  * @param {?} metadataIdList
1846
1919
  * @param {?} rootId
@@ -2330,6 +2403,16 @@
2330
2403
  return GspFormUploadListEntity;
2331
2404
  }());
2332
2405
 
2406
+ /**
2407
+ * @fileoverview added by tsickle
2408
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2409
+ */
2410
+ var GspFormDocInfo = /** @class */ (function () {
2411
+ function GspFormDocInfo() {
2412
+ }
2413
+ return GspFormDocInfo;
2414
+ }());
2415
+
2333
2416
  /**
2334
2417
  * @fileoverview added by tsickle
2335
2418
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2340,6 +2423,16 @@
2340
2423
  return GspDocMetaProperty;
2341
2424
  }());
2342
2425
 
2426
+ /**
2427
+ * @fileoverview added by tsickle
2428
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2429
+ */
2430
+ var GspFormUploadEntity = /** @class */ (function () {
2431
+ function GspFormUploadEntity() {
2432
+ }
2433
+ return GspFormUploadEntity;
2434
+ }());
2435
+
2343
2436
  /**
2344
2437
  * @fileoverview added by tsickle
2345
2438
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc