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
@@ -1,14 +1,14 @@
1
- /**
2
- * Serializer
3
- */
4
- export declare class Serializer {
5
- /**
6
- * Serialize object to json string.
7
- */
8
- static serialize(data: any, type: string): any;
9
- /**
10
- * Construct object from json string
11
- */
12
- static deserialize(data: any, type: string): any;
13
- private static findCorrectType;
14
- }
1
+ /**
2
+ * Serializer
3
+ */
4
+ export declare class Serializer {
5
+ /**
6
+ * Serialize object to json string.
7
+ */
8
+ static serialize(data: any, type: string): any;
9
+ /**
10
+ * Construct object from json string
11
+ */
12
+ static deserialize(data: any, type: string): any;
13
+ private static findCorrectType;
14
+ }
@@ -1,170 +1,171 @@
1
- "use strict";
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2003-2019 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
- const model_1 = require("./model");
27
- const primitives = [
28
- "string",
29
- "boolean",
30
- "double",
31
- "integer",
32
- "long",
33
- "float",
34
- "number",
35
- "any",
36
- ];
37
- /**
38
- * Serializer
39
- */
40
- class Serializer {
41
- /**
42
- * Serialize object to json string.
43
- */
44
- static serialize(data, type) {
45
- if (data === undefined) {
46
- return data;
47
- }
48
- else if (primitives.indexOf(type.toLowerCase()) !== -1) {
49
- return data;
50
- }
51
- else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
52
- let subType = type.replace("Array<", ""); // Array<Type> => Type>
53
- subType = subType.substring(0, subType.length - 1); // Type> => Type
54
- const transformedData = [];
55
- for (const index in data) {
56
- if (data.hasOwnProperty(index)) {
57
- const date = data[index];
58
- transformedData.push(Serializer.serialize(date, subType));
59
- }
60
- }
61
- return transformedData;
62
- }
63
- else if (type === "Date") {
64
- return data.toISOString();
65
- }
66
- else {
67
- if (model_1.enumsMap[type]) {
68
- return data;
69
- }
70
- if (!model_1.typeMap[type]) { // in case we dont know the type
71
- return data;
72
- }
73
- // get the map for the correct type.
74
- const attributeTypes = model_1.typeMap[type].getAttributeTypeMap();
75
- const instance = {};
76
- for (const index in attributeTypes) {
77
- if (attributeTypes.hasOwnProperty(index)) {
78
- const attributeType = attributeTypes[index];
79
- if (data[attributeType.name] instanceof Object) {
80
- instance[attributeType.baseName] = Serializer.serialize(data[attributeType.name], data[attributeType.name].constructor.name);
81
- }
82
- else {
83
- instance[attributeType.baseName] = Serializer.serialize(data[attributeType.name], attributeType.type);
84
- }
85
- }
86
- }
87
- return instance;
88
- }
89
- }
90
- /**
91
- * Construct object from json string
92
- */
93
- static deserialize(data, type) {
94
- // polymorphism may change the actual type.
95
- type = Serializer.findCorrectType(data, type);
96
- if (data === undefined || data === null) {
97
- return data;
98
- }
99
- else if (primitives.indexOf(type.toLowerCase()) !== -1) {
100
- return data;
101
- }
102
- else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
103
- let subType = type.replace("Array<", ""); // Array<Type> => Type>
104
- subType = subType.substring(0, subType.length - 1); // Type> => Type
105
- const transformedData = [];
106
- for (const index in data) {
107
- if (data.hasOwnProperty(index)) {
108
- const date = data[index];
109
- transformedData.push(Serializer.deserialize(date, subType));
110
- }
111
- }
112
- return transformedData;
113
- }
114
- else if (type === "Date") {
115
- return new Date(Date.parse(data));
116
- }
117
- else {
118
- if (model_1.enumsMap[type]) { // is Enum
119
- return data;
120
- }
121
- if (!model_1.typeMap[type]) { // dont know the type
122
- return data;
123
- }
124
- const instance = new model_1.typeMap[type]();
125
- const attributeTypes = model_1.typeMap[type].getAttributeTypeMap();
126
- for (const index in attributeTypes) {
127
- if (attributeTypes.hasOwnProperty(index)) {
128
- const attributeType = attributeTypes[index];
129
- if (data.hasOwnProperty(attributeType.baseName)) {
130
- instance[attributeType.name] = Serializer.deserialize(data[attributeType.baseName], attributeType.type);
131
- }
132
- }
133
- }
134
- return instance;
135
- }
136
- }
137
- static findCorrectType(data, expectedType) {
138
- if (data === undefined) {
139
- return expectedType;
140
- }
141
- else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
142
- return expectedType;
143
- }
144
- else if (expectedType === "Date") {
145
- return expectedType;
146
- }
147
- else {
148
- if (model_1.enumsMap[expectedType]) {
149
- return expectedType;
150
- }
151
- if (!model_1.typeMap[expectedType]) {
152
- return expectedType; // w/e we don't know the type
153
- }
154
- // Check the discriminator
155
- const discriminatorProperty = model_1.typeMap[expectedType].discriminator;
156
- if (discriminatorProperty == null) {
157
- return expectedType; // the type does not have a discriminator. use it.
158
- }
159
- else {
160
- if (data[discriminatorProperty]) {
161
- return data[discriminatorProperty]; // use the type given in the discriminator
162
- }
163
- else {
164
- return expectedType; // discriminator was not present (or an empty string)
165
- }
166
- }
167
- }
168
- }
169
- }
170
- exports.Serializer = Serializer;
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
+ exports.Serializer = void 0;
27
+ const model_1 = require("./model");
28
+ const primitives = [
29
+ "string",
30
+ "boolean",
31
+ "double",
32
+ "integer",
33
+ "long",
34
+ "float",
35
+ "number",
36
+ "any",
37
+ ];
38
+ /**
39
+ * Serializer
40
+ */
41
+ class Serializer {
42
+ /**
43
+ * Serialize object to json string.
44
+ */
45
+ static serialize(data, type) {
46
+ if (data === undefined) {
47
+ return data;
48
+ }
49
+ else if (primitives.indexOf(type.toLowerCase()) !== -1) {
50
+ return data;
51
+ }
52
+ else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
53
+ let subType = type.replace("Array<", ""); // Array<Type> => Type>
54
+ subType = subType.substring(0, subType.length - 1); // Type> => Type
55
+ const transformedData = [];
56
+ for (const index in data) {
57
+ if (data.hasOwnProperty(index)) {
58
+ const date = data[index];
59
+ transformedData.push(Serializer.serialize(date, subType));
60
+ }
61
+ }
62
+ return transformedData;
63
+ }
64
+ else if (type === "Date") {
65
+ return data.toISOString();
66
+ }
67
+ else {
68
+ if (model_1.enumsMap[type]) {
69
+ return data;
70
+ }
71
+ if (!model_1.typeMap[type]) { // in case we dont know the type
72
+ return data;
73
+ }
74
+ // get the map for the correct type.
75
+ const attributeTypes = model_1.typeMap[type].getAttributeTypeMap();
76
+ const instance = {};
77
+ for (const index in attributeTypes) {
78
+ if (attributeTypes.hasOwnProperty(index)) {
79
+ const attributeType = attributeTypes[index];
80
+ if (data[attributeType.name] instanceof Object) {
81
+ instance[attributeType.baseName] = Serializer.serialize(data[attributeType.name], data[attributeType.name].constructor.name);
82
+ }
83
+ else {
84
+ instance[attributeType.baseName] = Serializer.serialize(data[attributeType.name], attributeType.type);
85
+ }
86
+ }
87
+ }
88
+ return instance;
89
+ }
90
+ }
91
+ /**
92
+ * Construct object from json string
93
+ */
94
+ static deserialize(data, type) {
95
+ // polymorphism may change the actual type.
96
+ type = Serializer.findCorrectType(data, type);
97
+ if (data === undefined || data === null) {
98
+ return data;
99
+ }
100
+ else if (primitives.indexOf(type.toLowerCase()) !== -1) {
101
+ return data;
102
+ }
103
+ else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
104
+ let subType = type.replace("Array<", ""); // Array<Type> => Type>
105
+ subType = subType.substring(0, subType.length - 1); // Type> => Type
106
+ const transformedData = [];
107
+ for (const index in data) {
108
+ if (data.hasOwnProperty(index)) {
109
+ const date = data[index];
110
+ transformedData.push(Serializer.deserialize(date, subType));
111
+ }
112
+ }
113
+ return transformedData;
114
+ }
115
+ else if (type === "Date") {
116
+ return new Date(Date.parse(data));
117
+ }
118
+ else {
119
+ if (model_1.enumsMap[type]) { // is Enum
120
+ return data;
121
+ }
122
+ if (!model_1.typeMap[type]) { // dont know the type
123
+ return data;
124
+ }
125
+ const instance = new model_1.typeMap[type]();
126
+ const attributeTypes = model_1.typeMap[type].getAttributeTypeMap();
127
+ for (const index in attributeTypes) {
128
+ if (attributeTypes.hasOwnProperty(index)) {
129
+ const attributeType = attributeTypes[index];
130
+ if (data.hasOwnProperty(attributeType.baseName)) {
131
+ instance[attributeType.name] = Serializer.deserialize(data[attributeType.baseName], attributeType.type);
132
+ }
133
+ }
134
+ }
135
+ return instance;
136
+ }
137
+ }
138
+ static findCorrectType(data, expectedType) {
139
+ if (data === undefined) {
140
+ return expectedType;
141
+ }
142
+ else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
143
+ return expectedType;
144
+ }
145
+ else if (expectedType === "Date") {
146
+ return expectedType;
147
+ }
148
+ else {
149
+ if (model_1.enumsMap[expectedType]) {
150
+ return expectedType;
151
+ }
152
+ if (!model_1.typeMap[expectedType]) {
153
+ return expectedType; // w/e we don't know the type
154
+ }
155
+ // Check the discriminator
156
+ const discriminatorProperty = model_1.typeMap[expectedType].discriminator;
157
+ if (discriminatorProperty == null) {
158
+ return expectedType; // the type does not have a discriminator. use it.
159
+ }
160
+ else {
161
+ if (data[discriminatorProperty]) {
162
+ return data[discriminatorProperty]; // use the type given in the discriminator
163
+ }
164
+ else {
165
+ return expectedType; // discriminator was not present (or an empty string)
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+ exports.Serializer = Serializer;
@@ -0,0 +1 @@
1
+ import "mocha";
@@ -0,0 +1,45 @@
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
+ const chai_1 = require("chai");
27
+ require("mocha");
28
+ const configuration_1 = require("../../src/configuration");
29
+ const parser_api_1 = require("../../src/parser_api");
30
+ describe("auth_api", () => {
31
+ describe("test_auth_error", () => {
32
+ it("should throw when app sid not found", () => {
33
+ const settings = require("../test_settings.json");
34
+ const appSid = "test";
35
+ const appKey = "test";
36
+ const config = new configuration_1.Configuration(appSid, appKey);
37
+ config.apiBaseUrl = settings.ApiBaseUrl;
38
+ const infoApi = parser_api_1.InfoApi.fromConfig(config);
39
+ return infoApi.getSupportedFileFormats()
40
+ .catch((error) => {
41
+ (0, chai_1.expect)(error.message).equal("invalid_client");
42
+ });
43
+ });
44
+ });
45
+ });
@@ -0,0 +1 @@
1
+ import "mocha";
@@ -0,0 +1,64 @@
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_barcode_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("TestBarcodesApi", () => {
51
+ it("TestGetBarcodes_Docx", () => {
52
+ const barcodesOptions = new model_1.BarcodesOptions();
53
+ barcodesOptions.fileInfo = test_file_1.TestFile.PasswordProtected.ToFileInfo();
54
+ const request = new model_1.BarcodesRequest(barcodesOptions);
55
+ return TestContext.getParseApi().barcodes(request)
56
+ .then((result) => {
57
+ (0, chai_1.expect)(result).not.to.be.null;
58
+ result.barcodes.forEach((barcode) => {
59
+ (0, chai_1.expect)(barcode.value).not.to.be.null;
60
+ });
61
+ });
62
+ });
63
+ });
64
+ });
@@ -0,0 +1 @@
1
+ import "mocha";
@@ -0,0 +1,95 @@
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
+ const test_file_1 = require("../test_file");
40
+ describe("file_api", () => {
41
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
42
+ process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = "0";
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("test_file_api", () => {
51
+ it("TestDeleteFile", () => __awaiter(void 0, void 0, void 0, function* () {
52
+ var testFile = test_file_1.TestFile.FourPages;
53
+ var deleteRequest = new model_1.DeleteFileRequest(testFile.GetPath());
54
+ var existsRequest = new model_1.ObjectExistsRequest(testFile.GetPath());
55
+ var uploadRequest = new model_1.UploadFileRequest(testFile.GetPath(), TestContext.getTestFileBuffer(testFile));
56
+ yield TestContext.getFileApi().deleteFile(deleteRequest);
57
+ var result = yield TestContext.getStorageApi().objectExists(existsRequest);
58
+ (0, chai_1.expect)(result.exists).equal(false);
59
+ yield TestContext.getFileApi().uploadFile(uploadRequest);
60
+ result = yield TestContext.getStorageApi().objectExists(existsRequest);
61
+ (0, chai_1.expect)(result.exists).equal(true);
62
+ }));
63
+ it("TestDownloadFile", () => __awaiter(void 0, void 0, void 0, function* () {
64
+ var testFile = test_file_1.TestFile.FourPages;
65
+ var dlRequest = new model_1.DownloadFileRequest(testFile.GetPath());
66
+ var result = yield TestContext.getFileApi().downloadFile(dlRequest);
67
+ (0, chai_1.expect)(result.length).greaterThan(0);
68
+ }));
69
+ it("TestCopyMoveFile", () => __awaiter(void 0, void 0, void 0, function* () {
70
+ var testFile = test_file_1.TestFile.FourPages;
71
+ // Create temp folder
72
+ var cRequest = new model_1.CreateFolderRequest("temp");
73
+ yield TestContext.getFolderApi().createFolder(cRequest);
74
+ // Copy file
75
+ var destPath = "temp/" + testFile.GetPath();
76
+ var request = new model_1.CopyFileRequest(testFile.GetPath(), destPath);
77
+ yield TestContext.getFileApi().copyFile(request);
78
+ // Check copied file
79
+ var eRequest = new model_1.ObjectExistsRequest(destPath);
80
+ var eResponse = yield TestContext.getStorageApi().objectExists(eRequest);
81
+ (0, chai_1.expect)(eResponse.exists).equals(true);
82
+ // Move file
83
+ var newDestPath = "temp/" + testFile.GetPath().replace("four-pages", "four-pages_1");
84
+ var mRequest = new model_1.MoveFileRequest(destPath, newDestPath);
85
+ yield TestContext.getFileApi().moveFile(mRequest);
86
+ // Check moved file
87
+ eRequest = new model_1.ObjectExistsRequest(newDestPath);
88
+ eResponse = yield TestContext.getStorageApi().objectExists(eRequest);
89
+ (0, chai_1.expect)(eResponse.exists).equals(true);
90
+ // Delete temp folder
91
+ var delRequest = new model_1.DeleteFolderRequest("temp", undefined, true);
92
+ yield TestContext.getFolderApi().deleteFolder(delRequest);
93
+ }));
94
+ });
95
+ });
@@ -0,0 +1 @@
1
+ import "mocha";