groupdocs-parser-cloud 23.10.0 → 25.9.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.
@@ -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
+ }
package/lib/serializer.js CHANGED
@@ -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
+ {"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"],"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": "25.9.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.6.2",
35
+ "form-data": "*",
36
+ "jsonwebtoken": "9.0.1",
37
+ "qs": "6.11.2"
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
+ }