groupdocs-parser-cloud 23.10.0 → 26.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.
- package/LICENSE +1 -1
- package/lib/{api_client.d.ts → src/api_client.d.ts} +17 -17
- package/lib/{api_client.js → src/api_client.js} +135 -125
- package/lib/{api_error.d.ts → src/api_error.d.ts} +56 -56
- package/lib/{api_error.js → src/api_error.js} +81 -80
- package/lib/{auth.d.ts → src/auth.d.ts} +23 -22
- package/lib/{auth.js → src/auth.js} +96 -71
- package/lib/{configuration.d.ts → src/configuration.d.ts} +39 -39
- package/lib/{configuration.js → src/configuration.js} +56 -55
- package/lib/{model.d.ts → src/model.d.ts} +2248 -2206
- package/lib/{model.js → src/model.js} +2216 -2169
- package/lib/{package_version.d.ts → src/package_version.d.ts} +4 -4
- package/lib/{package_version.js → src/package_version.js} +30 -29
- package/lib/{parser_api.d.ts → src/parser_api.d.ts} +274 -270
- package/lib/{parser_api.js → src/parser_api.js} +930 -893
- package/lib/{serializer.d.ts → src/serializer.d.ts} +14 -14
- package/lib/{serializer.js → src/serializer.js} +171 -170
- package/lib/test/api/test_auth_api.d.ts +1 -0
- package/lib/test/api/test_auth_api.js +45 -0
- package/lib/test/api/test_barcode_api.d.ts +1 -0
- package/lib/test/api/test_barcode_api.js +64 -0
- package/lib/test/api/test_file_api.d.ts +1 -0
- package/lib/test/api/test_file_api.js +95 -0
- package/lib/test/api/test_folder_api.d.ts +1 -0
- package/lib/test/api/test_folder_api.js +84 -0
- package/lib/test/api/test_formats_api.d.ts +1 -0
- package/lib/test/api/test_formats_api.js +60 -0
- package/lib/test/api/test_parser_container_api.d.ts +1 -0
- package/lib/test/api/test_parser_container_api.js +134 -0
- package/lib/test/api/test_parser_image_api.d.ts +1 -0
- package/lib/test/api/test_parser_image_api.js +179 -0
- package/lib/test/api/test_parser_info_api.d.ts +1 -0
- package/lib/test/api/test_parser_info_api.js +112 -0
- package/lib/test/api/test_parser_parse_api.d.ts +1 -0
- package/lib/test/api/test_parser_parse_api.js +184 -0
- package/lib/test/api/test_parser_template_api.d.ts +1 -0
- package/lib/test/api/test_parser_template_api.js +168 -0
- package/lib/test/api/test_parser_text_api.d.ts +1 -0
- package/lib/test/api/test_parser_text_api.js +180 -0
- package/lib/test/api/test_storage_api.d.ts +1 -0
- package/lib/test/api/test_storage_api.js +76 -0
- package/lib/test/test_context.d.ts +30 -0
- package/lib/test/test_context.js +156 -0
- package/lib/test/test_coverage.d.ts +1 -0
- package/lib/test/test_coverage.js +77 -0
- package/lib/test/test_file.d.ts +50 -0
- package/lib/test/test_file.js +92 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +16 -14
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Aspose Pty Ltd
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const chai_1 = require("chai");
|
|
36
|
+
require("mocha");
|
|
37
|
+
const model_1 = require("../../src/model");
|
|
38
|
+
const TestContext = require("../test_context");
|
|
39
|
+
describe("folder_api", () => {
|
|
40
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = "0";
|
|
42
|
+
yield TestContext.uploadTestFiles();
|
|
43
|
+
}));
|
|
44
|
+
afterEach(function () {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
yield TestContext.cleanupTempFiles();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe("test_folder_api", () => {
|
|
50
|
+
it("TestGetFilesList", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
var request = new model_1.GetFilesListRequest("words");
|
|
52
|
+
var response = yield TestContext.getFolderApi().getFilesList(request);
|
|
53
|
+
(0, chai_1.expect)(response.value.length).greaterThan(0);
|
|
54
|
+
}));
|
|
55
|
+
it("TestCopyMoveFolder", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
// Create temp folder
|
|
57
|
+
var cRequest = new model_1.CreateFolderRequest("temp");
|
|
58
|
+
yield TestContext.getFolderApi().createFolder(cRequest);
|
|
59
|
+
// Copy folder
|
|
60
|
+
var copyRequest = new model_1.CopyFolderRequest("temp", "temp1");
|
|
61
|
+
yield TestContext.getFolderApi().copyFolder(copyRequest);
|
|
62
|
+
// Check copied folder
|
|
63
|
+
var eRequest = new model_1.ObjectExistsRequest("temp1");
|
|
64
|
+
var eResponse = yield TestContext.getStorageApi().objectExists(eRequest);
|
|
65
|
+
(0, chai_1.expect)(eResponse.exists).equals(true);
|
|
66
|
+
(0, chai_1.expect)(eResponse.isFolder).equals(true);
|
|
67
|
+
// Copy folder
|
|
68
|
+
var moveRequest = new model_1.MoveFolderRequest("temp1", "temp2");
|
|
69
|
+
yield TestContext.getFolderApi().moveFolder(moveRequest);
|
|
70
|
+
// Check moved folder
|
|
71
|
+
eRequest = new model_1.ObjectExistsRequest("temp1");
|
|
72
|
+
eResponse = yield TestContext.getStorageApi().objectExists(eRequest);
|
|
73
|
+
(0, chai_1.expect)(eResponse.exists).equals(false);
|
|
74
|
+
eRequest = new model_1.ObjectExistsRequest("temp2");
|
|
75
|
+
eResponse = yield TestContext.getStorageApi().objectExists(eRequest);
|
|
76
|
+
(0, chai_1.expect)(eResponse.exists).equals(true);
|
|
77
|
+
// Delete temp and temp2 folders
|
|
78
|
+
var delRequest = new model_1.DeleteFolderRequest("temp", undefined, true);
|
|
79
|
+
yield TestContext.getFolderApi().deleteFolder(delRequest);
|
|
80
|
+
delRequest = new model_1.DeleteFolderRequest("temp2", undefined, true);
|
|
81
|
+
yield TestContext.getFolderApi().deleteFolder(delRequest);
|
|
82
|
+
}));
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Aspose Pty Ltd
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const chai_1 = require("chai");
|
|
36
|
+
require("mocha");
|
|
37
|
+
const TestContext = require("../test_context");
|
|
38
|
+
describe("formats_api", () => {
|
|
39
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = "0";
|
|
41
|
+
yield TestContext.uploadTestFiles();
|
|
42
|
+
}));
|
|
43
|
+
afterEach(function () {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
yield TestContext.cleanupTempFiles();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("test_get_supported_file_formats", () => {
|
|
49
|
+
it("should return list of supported formats", () => {
|
|
50
|
+
const infoApi = TestContext.getInfoApi();
|
|
51
|
+
return infoApi.getSupportedFileFormats()
|
|
52
|
+
.then((result) => {
|
|
53
|
+
for (const format of result.formats) {
|
|
54
|
+
(0, chai_1.expect)(format.fileFormat).to.not.equal("");
|
|
55
|
+
(0, chai_1.expect)(format.extension).to.not.equal("");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
3
|
+
// <copyright company="Aspose Pty Ltd">
|
|
4
|
+
// Copyright (c) Aspose Pty Ltd
|
|
5
|
+
// </copyright>
|
|
6
|
+
// <summary>
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
// in the Software without restriction, including without limitation the rights
|
|
10
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
// furnished to do so, subject to the following conditions:
|
|
13
|
+
//
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
// copies or substantial portions of the Software.
|
|
16
|
+
//
|
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
// SOFTWARE.
|
|
24
|
+
// </summary>
|
|
25
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const chai_1 = require("chai");
|
|
37
|
+
require("mocha");
|
|
38
|
+
const model_1 = require("../../src/model");
|
|
39
|
+
const TestContext = require("../test_context");
|
|
40
|
+
const test_file_1 = require("../test_file");
|
|
41
|
+
describe("test_parser_container_api", () => {
|
|
42
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
yield TestContext.uploadTestFiles();
|
|
44
|
+
}));
|
|
45
|
+
afterEach(function () {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield TestContext.cleanupTempFiles();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("TestInfoApi", () => {
|
|
51
|
+
it("TestGetContainerItemInfo", () => {
|
|
52
|
+
const containerOptions = new model_1.ContainerOptions();
|
|
53
|
+
containerOptions.fileInfo = test_file_1.TestFile.Zip.ToFileInfo();
|
|
54
|
+
const request = new model_1.ContainerRequest(containerOptions);
|
|
55
|
+
return TestContext.getInfoApi().container(request)
|
|
56
|
+
.then((result) => {
|
|
57
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
58
|
+
(0, chai_1.expect)(result.containerItems).not.to.be.empty;
|
|
59
|
+
(0, chai_1.expect)(result.containerItems.length).equal(2);
|
|
60
|
+
var names = [
|
|
61
|
+
"one-page.docx", "four-pages.docx"
|
|
62
|
+
];
|
|
63
|
+
result.containerItems.forEach((item) => {
|
|
64
|
+
(0, chai_1.expect)(names.some(x => item.name.includes(x))).to.be.true;
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it("TestGetContainerItemInfo_rar", () => {
|
|
69
|
+
const containerOptions = new model_1.ContainerOptions();
|
|
70
|
+
containerOptions.fileInfo = test_file_1.TestFile.Rar.ToFileInfo();
|
|
71
|
+
const request = new model_1.ContainerRequest(containerOptions);
|
|
72
|
+
return TestContext.getInfoApi().container(request)
|
|
73
|
+
.then((result) => {
|
|
74
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
75
|
+
(0, chai_1.expect)(result.containerItems).not.to.be.empty;
|
|
76
|
+
(0, chai_1.expect)(result.containerItems.length).equal(2);
|
|
77
|
+
var names = [
|
|
78
|
+
"sample.docx", "sample.pdf"
|
|
79
|
+
];
|
|
80
|
+
result.containerItems.forEach((item) => {
|
|
81
|
+
(0, chai_1.expect)(names.some(x => item.name.includes(x))).to.be.true;
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
it("TestGetContainerItemInfo_tar", () => {
|
|
86
|
+
const containerOptions = new model_1.ContainerOptions();
|
|
87
|
+
containerOptions.fileInfo = test_file_1.TestFile.Tar.ToFileInfo();
|
|
88
|
+
const request = new model_1.ContainerRequest(containerOptions);
|
|
89
|
+
return TestContext.getInfoApi().container(request)
|
|
90
|
+
.then((result) => {
|
|
91
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
92
|
+
(0, chai_1.expect)(result.containerItems).not.to.be.empty;
|
|
93
|
+
(0, chai_1.expect)(result.containerItems.length).equal(5);
|
|
94
|
+
var names = [
|
|
95
|
+
"sample.docx", "sample.pdf", "1200px-RedPandaFullBody.JPG", "images.pdf", "th.jpg"
|
|
96
|
+
];
|
|
97
|
+
result.containerItems.forEach((item) => {
|
|
98
|
+
(0, chai_1.expect)(names.some(x => item.name.includes(x))).to.be.true;
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it("TestGetContainerItemInfo_FileNotFoundResult", () => {
|
|
103
|
+
const containerOptions = new model_1.ContainerOptions();
|
|
104
|
+
containerOptions.fileInfo = test_file_1.TestFile.NotExist.ToFileInfo();
|
|
105
|
+
const request = new model_1.ContainerRequest(containerOptions);
|
|
106
|
+
try {
|
|
107
|
+
TestContext.getInfoApi().container(request);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
(0, chai_1.expect)(e.message).equal("Can\'t find file located at \'folder/file-not-exist.pdf\'.");
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
it("GetContainerItemsInfo_UnsupportedFileType", () => {
|
|
114
|
+
const containerOptions = new model_1.ContainerOptions();
|
|
115
|
+
containerOptions.fileInfo = test_file_1.TestFile.Video.ToFileInfo();
|
|
116
|
+
const request = new model_1.ContainerRequest(containerOptions);
|
|
117
|
+
try {
|
|
118
|
+
TestContext.getInfoApi().container(request);
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
(0, chai_1.expect)(e.message).equal("Password provided for file \'video/avi/sample.avi\' is incorrect.");
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
it("GetContainerItemsInfo_WithoutOptions", () => {
|
|
125
|
+
const request = new model_1.ContainerRequest(null);
|
|
126
|
+
try {
|
|
127
|
+
TestContext.getInfoApi().container(request);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
(0, chai_1.expect)(e.message).equal('Required parameter "requestObj" was null or undefined when calling container.');
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
3
|
+
// <copyright company="Aspose Pty Ltd">
|
|
4
|
+
// Copyright (c) Aspose Pty Ltd
|
|
5
|
+
// </copyright>
|
|
6
|
+
// <summary>
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
// in the Software without restriction, including without limitation the rights
|
|
10
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
// furnished to do so, subject to the following conditions:
|
|
13
|
+
//
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
// copies or substantial portions of the Software.
|
|
16
|
+
//
|
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
// SOFTWARE.
|
|
24
|
+
// </summary>
|
|
25
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const chai_1 = require("chai");
|
|
37
|
+
require("mocha");
|
|
38
|
+
const model_1 = require("../../src/model");
|
|
39
|
+
const TestContext = require("../test_context");
|
|
40
|
+
const test_file_1 = require("../test_file");
|
|
41
|
+
describe("test_parser_image_api", () => {
|
|
42
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
yield TestContext.uploadTestFiles();
|
|
44
|
+
}));
|
|
45
|
+
afterEach(function () {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield TestContext.cleanupTempFiles();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("TestImageApi", () => {
|
|
51
|
+
it("TestGetImage_Docx", () => {
|
|
52
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
53
|
+
imageOptions.fileInfo = test_file_1.TestFile.PasswordProtected.ToFileInfo();
|
|
54
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
55
|
+
return TestContext.getParseApi().images(request)
|
|
56
|
+
.then((result) => {
|
|
57
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
58
|
+
result.images.forEach((image) => {
|
|
59
|
+
(0, chai_1.expect)(image.path).to.have.string("parser/images/words/docx/four-pages_docx/image_{i}.jpeg");
|
|
60
|
+
(0, chai_1.expect)(image.downloadUrl).not.to.be.null;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
it("TestGetImage_Container", () => {
|
|
65
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
66
|
+
imageOptions.fileInfo = test_file_1.TestFile.ZipWithEmailImagePdf.ToFileInfo();
|
|
67
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
68
|
+
return TestContext.getParseApi().images(request)
|
|
69
|
+
.then((result) => {
|
|
70
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
71
|
+
var paths = [
|
|
72
|
+
"containers/archive/zip-eml-jpg-pdf_zip/",
|
|
73
|
+
"containers/archive/zip-eml-jpg-pdf_zip/embedded-image-and-attachment_eml/",
|
|
74
|
+
"containers/archive/zip-eml-jpg-pdf_zip/template-document_pdf/"
|
|
75
|
+
];
|
|
76
|
+
result.images.forEach((image) => {
|
|
77
|
+
(0, chai_1.expect)(paths.some(x => image.path.includes(x))).to.be.true;
|
|
78
|
+
(0, chai_1.expect)(image.downloadUrl).not.to.be.null;
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
it("TestGetImage_Email", () => {
|
|
83
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
84
|
+
imageOptions.fileInfo = test_file_1.TestFile.ImageAndAttachment.ToFileInfo();
|
|
85
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
86
|
+
return TestContext.getParseApi().images(request)
|
|
87
|
+
.then((result) => {
|
|
88
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
89
|
+
var paths = [
|
|
90
|
+
"parser/images/email/eml/embedded-image-and-attachment_eml/"
|
|
91
|
+
];
|
|
92
|
+
result.images.forEach((image) => {
|
|
93
|
+
(0, chai_1.expect)(paths.some(x => image.path.includes(x))).to.be.true;
|
|
94
|
+
(0, chai_1.expect)(image.downloadUrl).not.to.be.null;
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it("TestGetImage_Pdf_FromPages", () => {
|
|
99
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
100
|
+
imageOptions.fileInfo = test_file_1.TestFile.Pdf.ToFileInfo();
|
|
101
|
+
imageOptions.startPageNumber = 1;
|
|
102
|
+
imageOptions.countPagesToExtract = 2;
|
|
103
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
104
|
+
return TestContext.getParseApi().images(request)
|
|
105
|
+
.then((result) => {
|
|
106
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
107
|
+
(0, chai_1.expect)(result.pages).not.to.be.empty;
|
|
108
|
+
(0, chai_1.expect)(result.pages.length).equal(2);
|
|
109
|
+
(0, chai_1.expect)(result.pages[0].images[0].path).equal("parser/images/pdf/template-document_pdf/page_1/image_0.jpeg");
|
|
110
|
+
(0, chai_1.expect)(result.pages[1].images[0].path).equal("parser/images/pdf/template-document_pdf/page_2/image_0.jpeg");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
it("ImageExtractTest_Pdf_ContainerItem_FromPages", () => {
|
|
114
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
115
|
+
imageOptions.fileInfo = test_file_1.TestFile.PdfContainer.ToFileInfo();
|
|
116
|
+
imageOptions.startPageNumber = 1;
|
|
117
|
+
imageOptions.countPagesToExtract = 2;
|
|
118
|
+
imageOptions.containerItemInfo = new model_1.ContainerItemInfo({ relativePath: "template-document.pdf" });
|
|
119
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
120
|
+
return TestContext.getParseApi().images(request)
|
|
121
|
+
.then((result) => {
|
|
122
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
123
|
+
(0, chai_1.expect)(result.pages).not.to.be.empty;
|
|
124
|
+
(0, chai_1.expect)(result.pages.length).equal(2);
|
|
125
|
+
(0, chai_1.expect)(result.pages[0].images[0].path).equal("parser/images/template-document_pdf/page_1/image_0.jpeg");
|
|
126
|
+
(0, chai_1.expect)(result.pages[1].images[0].path).equal("parser/images/template-document_pdf/page_2/image_0.jpeg");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it("ImageExtractTest_Pdf_FromPages_OutOfThePageRange", () => {
|
|
130
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
131
|
+
imageOptions.fileInfo = test_file_1.TestFile.Pdf.ToFileInfo();
|
|
132
|
+
imageOptions.startPageNumber = 3;
|
|
133
|
+
imageOptions.countPagesToExtract = 5;
|
|
134
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
135
|
+
try {
|
|
136
|
+
TestContext.getParseApi().images(request);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
(0, chai_1.expect)(error.message).equal("Request parameters missing or have incorrect format");
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
it("ImageExtractTest_Pdf_Container_FromPages_Error", () => {
|
|
143
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
144
|
+
imageOptions.fileInfo = test_file_1.TestFile.Zip.ToFileInfo();
|
|
145
|
+
imageOptions.startPageNumber = 3;
|
|
146
|
+
imageOptions.countPagesToExtract = 5;
|
|
147
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
148
|
+
try {
|
|
149
|
+
TestContext.getParseApi().images(request);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
(0, chai_1.expect)(error.message).equal("The specified file \'containers/archive/docx.zip\' has type which is not currently supported.");
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
it("TestGetImage_FileNotFoundResult", () => {
|
|
156
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
157
|
+
imageOptions.fileInfo = test_file_1.TestFile.NotExist.ToFileInfo();
|
|
158
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
159
|
+
try {
|
|
160
|
+
TestContext.getParseApi().images(request);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
(0, chai_1.expect)(error.message).equal("Can\'t find file located at \'folder/file-not-exist.pdf\'.");
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
it("TestGetImage_IncorrectPassword", () => {
|
|
167
|
+
const imageOptions = new model_1.ImagesOptions();
|
|
168
|
+
imageOptions.fileInfo = test_file_1.TestFile.PasswordProtected.ToFileInfo();
|
|
169
|
+
imageOptions.fileInfo.password = "123";
|
|
170
|
+
const request = new model_1.ImagesRequest(imageOptions);
|
|
171
|
+
try {
|
|
172
|
+
TestContext.getParseApi().images(request);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
(0, chai_1.expect)(error.message).equal("Password provided for file \'words/docx/password-protected.docx\' is incorrect.");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
3
|
+
// <copyright company="Aspose Pty Ltd">
|
|
4
|
+
// Copyright (c) Aspose Pty Ltd
|
|
5
|
+
// </copyright>
|
|
6
|
+
// <summary>
|
|
7
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
// in the Software without restriction, including without limitation the rights
|
|
10
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
// furnished to do so, subject to the following conditions:
|
|
13
|
+
//
|
|
14
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
// copies or substantial portions of the Software.
|
|
16
|
+
//
|
|
17
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
// SOFTWARE.
|
|
24
|
+
// </summary>
|
|
25
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const chai_1 = require("chai");
|
|
37
|
+
require("mocha");
|
|
38
|
+
const model_1 = require("../../src/model");
|
|
39
|
+
const TestContext = require("../test_context");
|
|
40
|
+
const test_file_1 = require("../test_file");
|
|
41
|
+
describe("test_parser_info_api", () => {
|
|
42
|
+
before(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
yield TestContext.uploadTestFiles();
|
|
44
|
+
}));
|
|
45
|
+
afterEach(function () {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield TestContext.cleanupTempFiles();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("TestInfoApi", () => {
|
|
51
|
+
it("TestGetInfo_Txt", () => {
|
|
52
|
+
const infoOptions = new model_1.InfoOptions();
|
|
53
|
+
infoOptions.fileInfo = test_file_1.TestFile.EncodingDetection.ToFileInfo();
|
|
54
|
+
const request = new model_1.GetInfoRequest(infoOptions);
|
|
55
|
+
return TestContext.getInfoApi().getInfo(request)
|
|
56
|
+
.then((result) => {
|
|
57
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
58
|
+
(0, chai_1.expect)(result.fileType.fileFormat.toUpperCase()).to.have.string("PLAIN TEXT FILE");
|
|
59
|
+
(0, chai_1.expect)(result.pageCount).equal(1);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it("TestGetInfo_Docx", () => {
|
|
63
|
+
const infoOptions = new model_1.InfoOptions();
|
|
64
|
+
infoOptions.fileInfo = test_file_1.TestFile.FourPages.ToFileInfo();
|
|
65
|
+
const request = new model_1.GetInfoRequest(infoOptions);
|
|
66
|
+
return TestContext.getInfoApi().getInfo(request)
|
|
67
|
+
.then((result) => {
|
|
68
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
69
|
+
(0, chai_1.expect)(result.fileType.fileFormat.toUpperCase()).to.have.string("MICROSOFT WORD OPEN XML DOCUMENT"
|
|
70
|
+
.toUpperCase());
|
|
71
|
+
(0, chai_1.expect)(result.pageCount).equal(4);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
it("TestGetInfo_ContainerItem", () => {
|
|
75
|
+
const infoOptions = new model_1.InfoOptions();
|
|
76
|
+
infoOptions.fileInfo = test_file_1.TestFile.Zip.ToFileInfo();
|
|
77
|
+
let containerItemInfo = new model_1.ContainerItemInfo();
|
|
78
|
+
containerItemInfo.relativePath = "one-page.docx";
|
|
79
|
+
infoOptions.containerItemInfo = containerItemInfo;
|
|
80
|
+
const request = new model_1.GetInfoRequest(infoOptions);
|
|
81
|
+
return TestContext.getInfoApi().getInfo(request)
|
|
82
|
+
.then((result) => {
|
|
83
|
+
(0, chai_1.expect)(result).not.to.be.null;
|
|
84
|
+
(0, chai_1.expect)(result.fileType.fileFormat.toUpperCase()).to.have.string("MICROSOFT WORD OPEN XML DOCUMENT");
|
|
85
|
+
(0, chai_1.expect)(result.pageCount).equal(1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it("TestGetInfo_FileNotFoundResult", () => {
|
|
89
|
+
const infoOptions = new model_1.InfoOptions();
|
|
90
|
+
infoOptions.fileInfo = test_file_1.TestFile.NotExist.ToFileInfo();
|
|
91
|
+
const request = new model_1.GetInfoRequest(infoOptions);
|
|
92
|
+
try {
|
|
93
|
+
TestContext.getInfoApi().getInfo(request);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
(0, chai_1.expect)(error.message).equal("Can\'t find file located at \'folder/file-not-exist.pdf\'.");
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
it("TestGetInfo_IncorrectPassword", () => {
|
|
100
|
+
const infoOptions = new model_1.InfoOptions();
|
|
101
|
+
infoOptions.fileInfo = test_file_1.TestFile.PasswordProtected.ToFileInfo();
|
|
102
|
+
infoOptions.fileInfo.password = "123";
|
|
103
|
+
const request = new model_1.GetInfoRequest(infoOptions);
|
|
104
|
+
try {
|
|
105
|
+
TestContext.getInfoApi().getInfo(request);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
(0, chai_1.expect)(error.message).equal("Password provided for file \'words/docx/password-protected.docx\' is incorrect.");
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "mocha";
|