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.
Files changed (49) hide show
  1. package/LICENSE +1 -1
  2. package/lib/{api_client.d.ts → src/api_client.d.ts} +17 -17
  3. package/lib/{api_client.js → src/api_client.js} +135 -125
  4. package/lib/{api_error.d.ts → src/api_error.d.ts} +56 -56
  5. package/lib/{api_error.js → src/api_error.js} +81 -80
  6. package/lib/{auth.d.ts → src/auth.d.ts} +23 -22
  7. package/lib/{auth.js → src/auth.js} +96 -71
  8. package/lib/{configuration.d.ts → src/configuration.d.ts} +39 -39
  9. package/lib/{configuration.js → src/configuration.js} +56 -55
  10. package/lib/{model.d.ts → src/model.d.ts} +2248 -2206
  11. package/lib/{model.js → src/model.js} +2216 -2169
  12. package/lib/{package_version.d.ts → src/package_version.d.ts} +4 -4
  13. package/lib/{package_version.js → src/package_version.js} +30 -29
  14. package/lib/{parser_api.d.ts → src/parser_api.d.ts} +274 -270
  15. package/lib/{parser_api.js → src/parser_api.js} +930 -893
  16. package/lib/{serializer.d.ts → src/serializer.d.ts} +14 -14
  17. package/lib/{serializer.js → src/serializer.js} +171 -170
  18. package/lib/test/api/test_auth_api.d.ts +1 -0
  19. package/lib/test/api/test_auth_api.js +45 -0
  20. package/lib/test/api/test_barcode_api.d.ts +1 -0
  21. package/lib/test/api/test_barcode_api.js +64 -0
  22. package/lib/test/api/test_file_api.d.ts +1 -0
  23. package/lib/test/api/test_file_api.js +95 -0
  24. package/lib/test/api/test_folder_api.d.ts +1 -0
  25. package/lib/test/api/test_folder_api.js +84 -0
  26. package/lib/test/api/test_formats_api.d.ts +1 -0
  27. package/lib/test/api/test_formats_api.js +60 -0
  28. package/lib/test/api/test_parser_container_api.d.ts +1 -0
  29. package/lib/test/api/test_parser_container_api.js +134 -0
  30. package/lib/test/api/test_parser_image_api.d.ts +1 -0
  31. package/lib/test/api/test_parser_image_api.js +179 -0
  32. package/lib/test/api/test_parser_info_api.d.ts +1 -0
  33. package/lib/test/api/test_parser_info_api.js +112 -0
  34. package/lib/test/api/test_parser_parse_api.d.ts +1 -0
  35. package/lib/test/api/test_parser_parse_api.js +184 -0
  36. package/lib/test/api/test_parser_template_api.d.ts +1 -0
  37. package/lib/test/api/test_parser_template_api.js +168 -0
  38. package/lib/test/api/test_parser_text_api.d.ts +1 -0
  39. package/lib/test/api/test_parser_text_api.js +180 -0
  40. package/lib/test/api/test_storage_api.d.ts +1 -0
  41. package/lib/test/api/test_storage_api.js +76 -0
  42. package/lib/test/test_context.d.ts +30 -0
  43. package/lib/test/test_context.js +156 -0
  44. package/lib/test/test_coverage.d.ts +1 -0
  45. package/lib/test/test_coverage.js +77 -0
  46. package/lib/test/test_file.d.ts +50 -0
  47. package/lib/test/test_file.js +92 -0
  48. package/lib/tsconfig.tsbuildinfo +1 -0
  49. package/package.json +16 -14
@@ -0,0 +1,156 @@
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
+ exports.getParseApi = getParseApi;
36
+ exports.getInfoApi = getInfoApi;
37
+ exports.getTemplateApi = getTemplateApi;
38
+ exports.getStorageApi = getStorageApi;
39
+ exports.getFileApi = getFileApi;
40
+ exports.getFolderApi = getFolderApi;
41
+ exports.uploadTestFiles = uploadTestFiles;
42
+ exports.cleanupTempFiles = cleanupTempFiles;
43
+ exports.getTestFileBuffer = getTestFileBuffer;
44
+ exports.serializeIntoBuffer = serializeIntoBuffer;
45
+ const fs = require("fs");
46
+ const configuration_1 = require("../src/configuration");
47
+ const serializer_1 = require("../src/serializer");
48
+ const parser_api_1 = require("../src/parser_api");
49
+ const parser_api_2 = require("../src/parser_api");
50
+ const parser_api_3 = require("../src/parser_api");
51
+ const parser_api_4 = require("../src/parser_api");
52
+ const test_file_1 = require("./test_file");
53
+ let parseApi;
54
+ let infoApi;
55
+ let templateApi;
56
+ let storageApi;
57
+ let fileApi;
58
+ let folderApi;
59
+ var uploaded = false;
60
+ let config;
61
+ /**
62
+ * Initializes ParserApi
63
+ */
64
+ function getParseApi() {
65
+ if (!parseApi) {
66
+ parseApi = parser_api_1.ParseApi.fromConfig(getConfig());
67
+ }
68
+ return parseApi;
69
+ }
70
+ function getInfoApi() {
71
+ if (!infoApi) {
72
+ infoApi = parser_api_1.InfoApi.fromConfig(getConfig());
73
+ }
74
+ return infoApi;
75
+ }
76
+ function getTemplateApi() {
77
+ if (!templateApi) {
78
+ templateApi = parser_api_1.TemplateApi.fromConfig(getConfig());
79
+ }
80
+ return templateApi;
81
+ }
82
+ function getStorageApi() {
83
+ if (!storageApi) {
84
+ storageApi = parser_api_2.StorageApi.fromConfig(getConfig());
85
+ }
86
+ return storageApi;
87
+ }
88
+ function getFileApi() {
89
+ if (!fileApi) {
90
+ fileApi = parser_api_3.FileApi.fromConfig(getConfig());
91
+ }
92
+ return fileApi;
93
+ }
94
+ function getFolderApi() {
95
+ if (!folderApi) {
96
+ folderApi = parser_api_4.FolderApi.fromConfig(getConfig());
97
+ }
98
+ return folderApi;
99
+ }
100
+ /**
101
+ * Uploads test files
102
+ */
103
+ function uploadTestFiles() {
104
+ if (uploaded)
105
+ return;
106
+ getStorageApi();
107
+ const testFiles = test_file_1.TestFile.GetTestFiles();
108
+ testFiles.forEach(function (file) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const response = yield storageApi.objectExists(new parser_api_1.ObjectExistsRequest(file.GetPath()));
111
+ if (!response.exists) {
112
+ console.log("Uploading: " + file.GetPath());
113
+ let filebuf = getTestFileBuffer(file);
114
+ yield fileApi.uploadFile(new parser_api_1.UploadFileRequest(file.GetPath(), filebuf));
115
+ }
116
+ });
117
+ });
118
+ uploaded = true;
119
+ }
120
+ function getConfig() {
121
+ if (!config) {
122
+ const settings = require("./test_settings.json");
123
+ config = new configuration_1.Configuration(settings.AppSid, settings.AppKey);
124
+ config.apiBaseUrl = settings.ApiBaseUrl;
125
+ }
126
+ return config;
127
+ }
128
+ /**
129
+ * Cleanups temp files
130
+ */
131
+ function cleanupTempFiles() {
132
+ const api = getFolderApi();
133
+ const tempDirs = ["parser"];
134
+ return Promise.all(tempDirs.map((dir) => {
135
+ return deleteTempDir(api, dir);
136
+ }));
137
+ }
138
+ /**
139
+ * Retrieves test file
140
+ */
141
+ function getTestFileBuffer(file) {
142
+ const testFilesDir = __dirname + "/test_files";
143
+ const testFilePath = testFilesDir + "/" + file.GetPath();
144
+ return fs.readFileSync(testFilePath);
145
+ }
146
+ /**
147
+ * Retrieves test file
148
+ */
149
+ function serializeIntoBuffer(obj) {
150
+ const serialized = serializer_1.Serializer.serialize(obj, obj.constructor.name);
151
+ const json = JSON.stringify(serialized, undefined, 2);
152
+ return new Buffer(json, "utf-8");
153
+ }
154
+ const deleteTempDir = (api, dir) => {
155
+ return api.deleteFolder(new parser_api_4.DeleteFolderRequest(dir, undefined, true));
156
+ };
@@ -0,0 +1 @@
1
+ import "mocha";
@@ -0,0 +1,77 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ require("mocha");
27
+ const assert_1 = require("assert");
28
+ const fs = require("fs");
29
+ const TestContext = require("./test_context");
30
+ const testFolder = "./test/";
31
+ describe("API method coverage", () => {
32
+ it("each api method should be covered with at least 1 test'", () => {
33
+ const methods = getAllMethods(TestContext.getParseApi()).concat(getAllMethods(TestContext.getInfoApi())).concat(getAllMethods(TestContext.getTemplateApi()));
34
+ const filesWithTests = getFileList(testFolder, null).filter((p) => p.endsWith(".ts"));
35
+ methods.forEach((method) => {
36
+ let usageOfMethodFound = false;
37
+ filesWithTests.forEach((file) => {
38
+ const fileContent = fs.readFileSync(file, "utf8");
39
+ if (fileContent.indexOf("." + method) > 0) {
40
+ usageOfMethodFound = true;
41
+ }
42
+ });
43
+ if (!usageOfMethodFound) {
44
+ (0, assert_1.fail)("usage of api method '" + method + "' not found");
45
+ }
46
+ });
47
+ });
48
+ });
49
+ const getAllMethods = (obj) => {
50
+ let props = [];
51
+ do {
52
+ const l = Object.getOwnPropertyNames(obj)
53
+ .concat(Object.getOwnPropertySymbols(obj).map((s) => s.toString()))
54
+ .sort()
55
+ .filter((p, i, arr) => typeof obj[p] === "function" && // only the methods
56
+ p !== "constructor" && // not the constructor
57
+ (i === 0 || p !== arr[i - 1]) && // not overriding in this prototype
58
+ props.indexOf(p) === -1); // not overridden in a child
59
+ props = props.concat(l);
60
+ obj = Object.getPrototypeOf(obj); // walk-up the prototype chain
61
+ } while (Object.getPrototypeOf(obj) // not the the Object prototype methods (hasOwnProperty, etc...)
62
+ );
63
+ return props;
64
+ };
65
+ const getFileList = (dir, fileList) => {
66
+ const files = fs.readdirSync(dir);
67
+ fileList = fileList || [];
68
+ files.forEach((file) => {
69
+ if (fs.statSync(dir + "/" + file).isDirectory()) {
70
+ fileList = fileList.concat(getFileList(dir + "/" + file, []));
71
+ }
72
+ else {
73
+ fileList.push(dir + "/" + file);
74
+ }
75
+ });
76
+ return fileList;
77
+ };
@@ -0,0 +1,50 @@
1
+ import { FileInfo } from "../src/model";
2
+ /**
3
+ * Describes test file
4
+ */
5
+ export declare class TestFile {
6
+ static PasswordProtected: TestFile;
7
+ static FourPages: TestFile;
8
+ static OnePage: TestFile;
9
+ static TemplateDocumentDocx: TestFile;
10
+ static FormattedDocument: TestFile;
11
+ static EncodingDetection: TestFile;
12
+ static Zip: TestFile;
13
+ static ZipWithEmailImagePdf: TestFile;
14
+ static JpegFile: TestFile;
15
+ static ImageAndAttachment: TestFile;
16
+ static Pdf: TestFile;
17
+ static PdfContainer: TestFile;
18
+ static Rar: TestFile;
19
+ static Tar: TestFile;
20
+ static Md: TestFile;
21
+ static Video: TestFile;
22
+ static NotExist: TestFile;
23
+ static Invoice: TestFile;
24
+ /**
25
+ * File name
26
+ */
27
+ fileName: string;
28
+ /**
29
+ * Folder where file is located
30
+ */
31
+ folder: string;
32
+ /**
33
+ * File password
34
+ */
35
+ password?: string;
36
+ /**
37
+ * Returns test file path
38
+ */
39
+ GetPath(): string;
40
+ /**
41
+ * Returns FileInfo
42
+ */
43
+ ToFileInfo(): FileInfo;
44
+ /**
45
+ * Attachment password
46
+ */
47
+ attachmentPassword: string | undefined;
48
+ private constructor();
49
+ static GetTestFiles(): TestFile[];
50
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestFile = void 0;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) Aspose Pty Ltd
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+ const model_1 = require("../src/model");
28
+ /**
29
+ * Describes test file
30
+ */
31
+ class TestFile {
32
+ /**
33
+ * Returns test file path
34
+ */
35
+ GetPath() {
36
+ return this.folder + this.fileName;
37
+ }
38
+ /**
39
+ * Returns FileInfo
40
+ */
41
+ ToFileInfo() {
42
+ let fileInfo = new model_1.FileInfo();
43
+ fileInfo.filePath = this.GetPath();
44
+ if (this.password)
45
+ fileInfo.password = this.password;
46
+ return fileInfo;
47
+ }
48
+ constructor(fileName, folder, password) {
49
+ this.fileName = fileName;
50
+ this.folder = folder;
51
+ this.password = password;
52
+ }
53
+ static GetTestFiles() {
54
+ return [
55
+ TestFile.PasswordProtected,
56
+ TestFile.FourPages,
57
+ TestFile.OnePage,
58
+ TestFile.TemplateDocumentDocx,
59
+ TestFile.FormattedDocument,
60
+ TestFile.EncodingDetection,
61
+ TestFile.Zip,
62
+ TestFile.ZipWithEmailImagePdf,
63
+ TestFile.JpegFile,
64
+ TestFile.ImageAndAttachment,
65
+ TestFile.Pdf,
66
+ TestFile.PdfContainer,
67
+ TestFile.Rar,
68
+ TestFile.Tar,
69
+ TestFile.Md,
70
+ TestFile.Invoice
71
+ ];
72
+ }
73
+ }
74
+ exports.TestFile = TestFile;
75
+ TestFile.PasswordProtected = new TestFile("password-protected.docx", "words/docx/", "password");
76
+ TestFile.FourPages = new TestFile("four-pages.docx", "words/docx/");
77
+ TestFile.OnePage = new TestFile("one-page.docx", "words/docx/");
78
+ TestFile.TemplateDocumentDocx = new TestFile("template-document.docx", "words/docx/");
79
+ TestFile.FormattedDocument = new TestFile("formatted-document.docx", "words/docx/");
80
+ TestFile.EncodingDetection = new TestFile("encoding-detection.txt", "words/txt/");
81
+ TestFile.Zip = new TestFile("docx.zip", "containers/archive/");
82
+ TestFile.ZipWithEmailImagePdf = new TestFile("zip-eml-jpg-pdf.zip", "containers/archive/");
83
+ TestFile.JpegFile = new TestFile("document.jpeg", "image/jpeg/");
84
+ TestFile.ImageAndAttachment = new TestFile("embedded-image-and-attachment.eml", "email/eml/");
85
+ TestFile.Pdf = new TestFile("template-document.pdf", "pdf/");
86
+ TestFile.PdfContainer = new TestFile("PDF with attachements.pdf", "pdf/", "password");
87
+ TestFile.Rar = new TestFile("sample.rar", "containers/archive/");
88
+ TestFile.Tar = new TestFile("sample.tar", "containers/archive/");
89
+ TestFile.Md = new TestFile("sample.md", "words/docx/");
90
+ TestFile.Video = new TestFile("sample.avi", "video/avi/");
91
+ TestFile.NotExist = new TestFile("file-not-exist.pdf", "folder/");
92
+ TestFile.Invoice = new TestFile("Invoice.xlsx", "cells/");
@@ -0,0 +1 @@
1
+ {"root":["../src/api_client.ts","../src/api_error.ts","../src/auth.ts","../src/configuration.ts","../src/model.ts","../src/package_version.ts","../src/parser_api.ts","../src/serializer.ts","../test/test_context.ts","../test/test_coverage.ts","../test/test_file.ts","../test/api/test_auth_api.ts","../test/api/test_barcode_api.ts","../test/api/test_file_api.ts","../test/api/test_folder_api.ts","../test/api/test_formats_api.ts","../test/api/test_parser_container_api.ts","../test/api/test_parser_image_api.ts","../test/api/test_parser_info_api.ts","../test/api/test_parser_parse_api.ts","../test/api/test_parser_template_api.ts","../test/api/test_parser_text_api.ts","../test/api/test_storage_api.ts"],"version":"5.9.2"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groupdocs-parser-cloud",
3
- "version": "23.10.0",
3
+ "version": "26.2.0",
4
4
  "description": "GroupDocs.Parser Cloud SDK for Node.js",
5
5
  "homepage": "https://products.groupdocs.cloud/parser",
6
6
  "author": {
@@ -31,19 +31,21 @@
31
31
  "build:package": "npm pack"
32
32
  },
33
33
  "dependencies": {
34
- "request": "^2.81.0",
35
- "request-debug": "^0.2.0",
36
- "@types/request": "*"
34
+ "axios": "1.13.5",
35
+ "form-data": "*",
36
+ "jsonwebtoken": "9.0.1",
37
+ "qs": "6.14.1"
37
38
  },
38
39
  "devDependencies": {
39
- "@types/chai": "^4.0.10",
40
- "@types/mocha": "^2.2.44",
41
- "@types/node": "^10.10.1",
42
- "asposestoragecloud": "^1.0.5",
43
- "mocha": "^4.0.1",
44
- "chai": "^4.1.2",
45
- "ts-node": "^7.0.1",
46
- "tslint": "^5.8.0",
47
- "typescript": "^3.0.3"
40
+ "@types/chai": "^4.2.14",
41
+ "@types/jsonwebtoken": "9.0.1",
42
+ "@types/mocha": "^5.2.7",
43
+ "@types/node": "^12.19.15",
44
+ "@types/qs": "^6.9.7",
45
+ "chai": "^4.2.0",
46
+ "mocha": "^10.2.0",
47
+ "ts-node": "^8.6.2",
48
+ "tslint": "^5.17.0",
49
+ "typescript": "^5.1.6"
48
50
  }
49
- }
51
+ }