@vertikalx/vtx-backend-client 1.0.0-dev-daniel.109 → 1.0.0-dev-daniel.111
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/package.json +1 -1
- package/src/api/backend-response.d.ts +7 -1
- package/src/api/response-builder.js +62 -11
- package/src/api/response-builder.js.map +1 -1
- package/src/api/vtx-base-api.js +80 -316
- package/src/api/vtx-base-api.js.map +1 -1
- package/src/client/schema.d.ts +10 -0
- package/src/client/schema.graphql +6 -0
- package/src/client/schema.js.map +1 -1
- package/src/client/types.d.ts +8 -0
- package/src/client/types.js +35 -15
- package/src/client/types.js.map +1 -1
- package/tsconfig.lib.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildResponse = buildResponse;
|
|
4
4
|
exports.buildErrorResponse = buildErrorResponse;
|
|
5
|
+
const vtx_core_common_1 = require("@vertikalx/vtx-core-common");
|
|
5
6
|
function buildResponse(response, rootProperty, checker) {
|
|
6
7
|
const retValue = {};
|
|
7
8
|
console.log("=========== BEGIN buildResponse =============");
|
|
@@ -14,25 +15,35 @@ function buildResponse(response, rootProperty, checker) {
|
|
|
14
15
|
}
|
|
15
16
|
catch (casterr) {
|
|
16
17
|
console.log('Error trying to cast to return type');
|
|
17
|
-
retValue.
|
|
18
|
+
retValue.error = {
|
|
19
|
+
httpStatus: 500,
|
|
20
|
+
code: vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.code,
|
|
21
|
+
message: "Error: Obtained incorrect data from Backend"
|
|
22
|
+
};
|
|
23
|
+
retValue.rawErrors = [
|
|
24
|
+
{
|
|
25
|
+
data: response,
|
|
26
|
+
error: casterr
|
|
27
|
+
}
|
|
28
|
+
];
|
|
18
29
|
}
|
|
19
30
|
}
|
|
20
31
|
else if (response?.errors) {
|
|
21
32
|
console.log('checker 2');
|
|
22
33
|
if (Array.isArray(response.errors)) {
|
|
23
|
-
retValue.
|
|
34
|
+
retValue.rawErrors = response.errors;
|
|
24
35
|
}
|
|
25
36
|
else {
|
|
26
|
-
retValue.
|
|
37
|
+
retValue.rawErrors = [response.errors];
|
|
27
38
|
}
|
|
28
39
|
}
|
|
29
40
|
else if (response?.error) {
|
|
30
41
|
console.log('checker 3');
|
|
31
42
|
if (Array.isArray(response.error)) {
|
|
32
|
-
retValue.
|
|
43
|
+
retValue.rawErrors = response.error;
|
|
33
44
|
}
|
|
34
45
|
else {
|
|
35
|
-
retValue.
|
|
46
|
+
retValue.rawErrors = [response.error];
|
|
36
47
|
}
|
|
37
48
|
}
|
|
38
49
|
else if (checker(response?.data)) {
|
|
@@ -42,12 +53,27 @@ function buildResponse(response, rootProperty, checker) {
|
|
|
42
53
|
}
|
|
43
54
|
catch (casterr) {
|
|
44
55
|
console.log('Error trying to cast to return type');
|
|
45
|
-
retValue.
|
|
56
|
+
retValue.error = {
|
|
57
|
+
httpStatus: 500,
|
|
58
|
+
code: vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.code,
|
|
59
|
+
message: "Error: Obtained incorrect data from Backend"
|
|
60
|
+
};
|
|
61
|
+
retValue.rawErrors = [
|
|
62
|
+
{
|
|
63
|
+
data: response.data,
|
|
64
|
+
error: casterr
|
|
65
|
+
}
|
|
66
|
+
];
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
69
|
else {
|
|
49
70
|
console.log('checker 5');
|
|
50
|
-
retValue.
|
|
71
|
+
retValue.error = {
|
|
72
|
+
httpStatus: 500,
|
|
73
|
+
code: vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.code,
|
|
74
|
+
message: "Error: Obtained incorrect data from Backend"
|
|
75
|
+
};
|
|
76
|
+
retValue.rawErrors = ['Error: Obtained incorrect data from Backend'];
|
|
51
77
|
}
|
|
52
78
|
console.log('buildResponse retValue:');
|
|
53
79
|
console.log(JSON.stringify(retValue, null, 2));
|
|
@@ -60,23 +86,48 @@ function buildErrorResponse(error) {
|
|
|
60
86
|
const retValue = {};
|
|
61
87
|
if (error.errors) {
|
|
62
88
|
if (Array.isArray(error.errors)) {
|
|
63
|
-
retValue.
|
|
89
|
+
retValue.rawErrors = error.errors;
|
|
64
90
|
}
|
|
65
91
|
else {
|
|
66
|
-
retValue.
|
|
92
|
+
retValue.rawErrors = [error.errors];
|
|
67
93
|
}
|
|
68
94
|
}
|
|
69
95
|
else {
|
|
70
96
|
if (Array.isArray(error)) {
|
|
71
|
-
retValue.
|
|
97
|
+
retValue.rawErrors = error;
|
|
72
98
|
}
|
|
73
99
|
else {
|
|
74
|
-
retValue.
|
|
100
|
+
retValue.rawErrors = [error];
|
|
75
101
|
}
|
|
76
102
|
}
|
|
103
|
+
retValue.error = extractError(retValue.rawErrors);
|
|
77
104
|
console.log("=========== BEGIN buildErrorResponse returned =============");
|
|
78
105
|
console.log(JSON.stringify(retValue, null, 2));
|
|
79
106
|
console.log("=========== END buildErrorResponse returned =============");
|
|
80
107
|
return retValue;
|
|
81
108
|
}
|
|
109
|
+
function extractError(rawErrors) {
|
|
110
|
+
let retValue = {
|
|
111
|
+
httpStatus: 500,
|
|
112
|
+
code: vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.code,
|
|
113
|
+
message: vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.description
|
|
114
|
+
};
|
|
115
|
+
if (!rawErrors || rawErrors.length <= 0) {
|
|
116
|
+
return retValue;
|
|
117
|
+
}
|
|
118
|
+
let theError = rawErrors.find(e => {
|
|
119
|
+
if (e.extensions && e.extensions.type === "VtxError") {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
});
|
|
124
|
+
if (theError) {
|
|
125
|
+
retValue = {
|
|
126
|
+
httpStatus: theError?.extensions?.httpStatus ?? 500,
|
|
127
|
+
code: theError?.extensions?.vtxError?.code ?? vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.code,
|
|
128
|
+
message: theError?.extensions?.vtxError?.description ?? vtx_core_common_1.VTX_ERRORS.VTX_SERVER_ERROR.description
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return retValue;
|
|
132
|
+
}
|
|
82
133
|
//# sourceMappingURL=response-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../../../libs/vtx-backend-client/src/api/response-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../../../libs/vtx-backend-client/src/api/response-builder.ts"],"names":[],"mappings":";;AAOA,sCAkFC;AACD,gDAmCC;AA3HD,gEAAwD;AAKxD,SAAgB,aAAa,CAAI,QAAY,EAAE,YAAmB,EAAE,OAAkB;IAClF,MAAM,QAAQ,GAA4B,EAAE,CAAA;IAE5C,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE/C,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAEzD,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzB,IAAI,CAAC;YACH,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,YAAY,CAAM,CAAC;QAC9C,CAAC;QAAC,OAAO,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,QAAQ,CAAC,KAAK,GAAG;gBACf,UAAU,EAAC,GAAG;gBACd,IAAI,EAAC,4BAAU,CAAC,gBAAgB,CAAC,IAAI;gBACrC,OAAO,EAAC,6CAA6C;aACtD,CAAC;YACF,QAAQ,CAAC,SAAS,GAAG;gBACnB;oBACE,IAAI,EAAC,QAAQ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U,EAAE,QAAQ,EAAE,WAAW,IAAK,4BAAU,CAAC,gBAAgB,CAAC,WAAW;SACjG,CAAA;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAGlB,CAAC"}
|
package/src/api/vtx-base-api.js
CHANGED
|
@@ -6,6 +6,7 @@ const client_1 = require("../client");
|
|
|
6
6
|
const api_call_headers_1 = require("./api-call-headers");
|
|
7
7
|
const response_builder_1 = require("./response-builder");
|
|
8
8
|
const domains_1 = require("./domains");
|
|
9
|
+
const vtx_core_common_1 = require("@vertikalx/vtx-core-common");
|
|
9
10
|
class VTXBaseAPI {
|
|
10
11
|
constructor(headers, backendUrl) {
|
|
11
12
|
this.headers = headers ?? api_call_headers_1.DEFAULT_HEADERS;
|
|
@@ -74,48 +75,17 @@ class VTXBaseAPI {
|
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
77
|
});
|
|
78
|
+
console.log('findUserByEmail Response:');
|
|
77
79
|
console.log(JSON.stringify(response, null, 2));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
catch (casterr) {
|
|
83
|
-
console.log('Error trying to cast to User');
|
|
84
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else if (response?.errors) {
|
|
88
|
-
if (Array.isArray(response.errors)) {
|
|
89
|
-
retValue.errors = response.errors;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
retValue.errors = [response.errors];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else if (response?.error) {
|
|
96
|
-
if (Array.isArray(response.error)) {
|
|
97
|
-
retValue.errors = response.error;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
retValue.errors = [response.error];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
105
|
-
}
|
|
80
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'findUserByEmail', (r) => {
|
|
81
|
+
const isResponseOk = true && response?.findUserByEmail?._id;
|
|
82
|
+
return isResponseOk;
|
|
83
|
+
});
|
|
106
84
|
}
|
|
107
85
|
catch (err1) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
catch (ex) { }
|
|
113
|
-
if (Array.isArray(err1)) {
|
|
114
|
-
retValue.errors = err1;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
retValue.errors = [err1];
|
|
118
|
-
}
|
|
86
|
+
console.log('findUserByEmail err1:');
|
|
87
|
+
console.log(err1);
|
|
88
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
119
89
|
}
|
|
120
90
|
return retValue;
|
|
121
91
|
}
|
|
@@ -136,45 +106,17 @@ class VTXBaseAPI {
|
|
|
136
106
|
refreshToken: true,
|
|
137
107
|
},
|
|
138
108
|
});
|
|
109
|
+
console.log('loginUserFromEmail Response:');
|
|
139
110
|
console.log(JSON.stringify(response, null, 2));
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
catch (casterr) {
|
|
146
|
-
console.log('Error trying to cast to UserToken:');
|
|
147
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else if (response?.errors) {
|
|
151
|
-
if (Array.isArray(response.errors)) {
|
|
152
|
-
retValue.errors = response.errors;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
retValue.errors = [response.errors];
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else if (response?.error) {
|
|
159
|
-
if (Array.isArray(response.error)) {
|
|
160
|
-
retValue.errors = response.error;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
retValue.errors = [response.error];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
168
|
-
}
|
|
111
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'loginUserFromEmail', (r) => {
|
|
112
|
+
const isResponseOk = true && response?.loginUserFromEmail?.actualToken;
|
|
113
|
+
return isResponseOk;
|
|
114
|
+
});
|
|
169
115
|
}
|
|
170
116
|
catch (err1) {
|
|
171
|
-
console.log(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
retValue.errors = [err1];
|
|
177
|
-
}
|
|
117
|
+
console.log('loginUserFromEmail err1:');
|
|
118
|
+
console.log(err1);
|
|
119
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
178
120
|
}
|
|
179
121
|
return retValue;
|
|
180
122
|
}
|
|
@@ -203,53 +145,17 @@ class VTXBaseAPI {
|
|
|
203
145
|
}
|
|
204
146
|
}
|
|
205
147
|
});
|
|
148
|
+
console.log('createUserAndLogin Response:');
|
|
206
149
|
console.log(JSON.stringify(response, null, 2));
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
catch (casterr) {
|
|
212
|
-
console.log('Error trying to cast to UserToken:');
|
|
213
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else if (response?.errors) {
|
|
217
|
-
if (Array.isArray(response.errors)) {
|
|
218
|
-
retValue.errors = response.errors;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
retValue.errors = [response.errors];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else if (response?.error) {
|
|
225
|
-
if (Array.isArray(response.error)) {
|
|
226
|
-
retValue.errors = response.error;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
retValue.errors = [response.error];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else if (response?.data?._id) {
|
|
233
|
-
try {
|
|
234
|
-
retValue.data = response?.data;
|
|
235
|
-
}
|
|
236
|
-
catch (casterr) {
|
|
237
|
-
console.log('Error trying to cast to UserWithToken:');
|
|
238
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
243
|
-
}
|
|
150
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'createUserAndLogin', (r) => {
|
|
151
|
+
const isResponseOk = true && response?.createUserAndLogin?._id;
|
|
152
|
+
return isResponseOk;
|
|
153
|
+
});
|
|
244
154
|
}
|
|
245
155
|
catch (err1) {
|
|
246
|
-
console.log(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
retValue.errors = [err1];
|
|
252
|
-
}
|
|
156
|
+
console.log('createUserAndLogin err1:');
|
|
157
|
+
console.log(err1);
|
|
158
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
253
159
|
}
|
|
254
160
|
return retValue;
|
|
255
161
|
}
|
|
@@ -273,53 +179,17 @@ class VTXBaseAPI {
|
|
|
273
179
|
countryName: true
|
|
274
180
|
}
|
|
275
181
|
});
|
|
182
|
+
console.log('registerAthlete Response:');
|
|
276
183
|
console.log(JSON.stringify(response, null, 2));
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
catch (casterr) {
|
|
282
|
-
console.log('Error trying to cast to Athlete:');
|
|
283
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
else if (response?.errors) {
|
|
287
|
-
if (Array.isArray(response.errors)) {
|
|
288
|
-
retValue.errors = response.errors;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
retValue.errors = [response.errors];
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
else if (response?.error) {
|
|
295
|
-
if (Array.isArray(response.error)) {
|
|
296
|
-
retValue.errors = response.error;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
retValue.errors = [response.error];
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
else if (response?.data?._id) {
|
|
303
|
-
try {
|
|
304
|
-
retValue.data = response?.data;
|
|
305
|
-
}
|
|
306
|
-
catch (casterr) {
|
|
307
|
-
console.log('Error trying to cast to Athlete:');
|
|
308
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
313
|
-
}
|
|
184
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'registerAthlete', (r) => {
|
|
185
|
+
const isResponseOk = true && response?.registerAthlete?._id;
|
|
186
|
+
return isResponseOk;
|
|
187
|
+
});
|
|
314
188
|
}
|
|
315
189
|
catch (err1) {
|
|
316
|
-
console.log(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
retValue.errors = [err1];
|
|
322
|
-
}
|
|
190
|
+
console.log('registerAthlete err1:');
|
|
191
|
+
console.log(err1);
|
|
192
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
323
193
|
}
|
|
324
194
|
return retValue;
|
|
325
195
|
}
|
|
@@ -399,49 +269,17 @@ class VTXBaseAPI {
|
|
|
399
269
|
}
|
|
400
270
|
});
|
|
401
271
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
else if (response?.errors) {
|
|
411
|
-
if (Array.isArray(response.errors)) {
|
|
412
|
-
retValue.errors = response.errors;
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
retValue.errors = [response.errors];
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
else if (response?.error) {
|
|
419
|
-
if (Array.isArray(response.error)) {
|
|
420
|
-
retValue.errors = response.error;
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
retValue.errors = [response.error];
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else if (response?.data?._id) {
|
|
427
|
-
try {
|
|
428
|
-
retValue.data = response?.data;
|
|
429
|
-
}
|
|
430
|
-
catch (casterr) {
|
|
431
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
436
|
-
}
|
|
272
|
+
console.log('getBrandByName Response:');
|
|
273
|
+
console.log(JSON.stringify(response, null, 2));
|
|
274
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'getBrandByName', (r) => {
|
|
275
|
+
const isResponseOk = true && response?.getBrandByName?._id;
|
|
276
|
+
return isResponseOk;
|
|
277
|
+
});
|
|
437
278
|
}
|
|
438
279
|
catch (err1) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
else {
|
|
443
|
-
retValue.errors = [err1];
|
|
444
|
-
}
|
|
280
|
+
console.log('getBrandByName err1:');
|
|
281
|
+
console.log(err1);
|
|
282
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
445
283
|
}
|
|
446
284
|
return retValue;
|
|
447
285
|
}
|
|
@@ -461,54 +299,17 @@ class VTXBaseAPI {
|
|
|
461
299
|
...fields
|
|
462
300
|
}
|
|
463
301
|
});
|
|
464
|
-
console.log('
|
|
302
|
+
console.log('createBrand Response:');
|
|
465
303
|
console.log(JSON.stringify(response, null, 2));
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
catch (casterr) {
|
|
471
|
-
console.log('Error trying to cast to Brand:');
|
|
472
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
else if (response?.errors) {
|
|
476
|
-
if (Array.isArray(response.errors)) {
|
|
477
|
-
retValue.errors = response.errors;
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
retValue.errors = [response.errors];
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else if (response?.error) {
|
|
484
|
-
if (Array.isArray(response.error)) {
|
|
485
|
-
retValue.errors = response.error;
|
|
486
|
-
}
|
|
487
|
-
else {
|
|
488
|
-
retValue.errors = [response.error];
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
else if (response?.data?._id) {
|
|
492
|
-
try {
|
|
493
|
-
retValue.data = response?.data;
|
|
494
|
-
}
|
|
495
|
-
catch (casterr) {
|
|
496
|
-
console.log('Error trying to cast to Brand:');
|
|
497
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
else {
|
|
501
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
502
|
-
}
|
|
304
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'createBrand', (r) => {
|
|
305
|
+
const isResponseOk = true && response?.createBrand?._id;
|
|
306
|
+
return isResponseOk;
|
|
307
|
+
});
|
|
503
308
|
}
|
|
504
309
|
catch (err1) {
|
|
505
|
-
console.log(
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
retValue.errors = [err1];
|
|
511
|
-
}
|
|
310
|
+
console.log('createBrand err1:');
|
|
311
|
+
console.log(err1);
|
|
312
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
512
313
|
}
|
|
513
314
|
return retValue;
|
|
514
315
|
}
|
|
@@ -528,54 +329,17 @@ class VTXBaseAPI {
|
|
|
528
329
|
...fields
|
|
529
330
|
}
|
|
530
331
|
});
|
|
531
|
-
console.log('
|
|
332
|
+
console.log('createSponsorship Response:');
|
|
532
333
|
console.log(JSON.stringify(response, null, 2));
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
catch (casterr) {
|
|
538
|
-
console.log('Error trying to cast to Sponsorship:');
|
|
539
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
else if (response?.errors) {
|
|
543
|
-
if (Array.isArray(response.errors)) {
|
|
544
|
-
retValue.errors = response.errors;
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
retValue.errors = [response.errors];
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
else if (response?.error) {
|
|
551
|
-
if (Array.isArray(response.error)) {
|
|
552
|
-
retValue.errors = response.error;
|
|
553
|
-
}
|
|
554
|
-
else {
|
|
555
|
-
retValue.errors = [response.error];
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
else if (response?.data?._id) {
|
|
559
|
-
try {
|
|
560
|
-
retValue.data = response?.data;
|
|
561
|
-
}
|
|
562
|
-
catch (casterr) {
|
|
563
|
-
console.log('Error trying to cast to Sponsorship:');
|
|
564
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
569
|
-
}
|
|
334
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'createSponsorship', (r) => {
|
|
335
|
+
const isResponseOk = true && response?.createSponsorship?._id;
|
|
336
|
+
return isResponseOk;
|
|
337
|
+
});
|
|
570
338
|
}
|
|
571
339
|
catch (err1) {
|
|
572
|
-
console.log(
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
retValue.errors = [err1];
|
|
578
|
-
}
|
|
340
|
+
console.log('createSponsorship err1:');
|
|
341
|
+
console.log(err1);
|
|
342
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
579
343
|
}
|
|
580
344
|
return retValue;
|
|
581
345
|
}
|
|
@@ -606,27 +370,15 @@ class VTXBaseAPI {
|
|
|
606
370
|
});
|
|
607
371
|
console.log('getUploadUrl Response:');
|
|
608
372
|
console.log(JSON.stringify(response, null, 2));
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
catch (casterr) {
|
|
614
|
-
console.log('Error trying to cast to AWSS3UploadUrl:');
|
|
615
|
-
retValue.errors = ['Error: Obtained incorrect data from Backend'];
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
retValue.errors = ["Unable to generate correct upload URL"];
|
|
620
|
-
}
|
|
373
|
+
retValue = (0, response_builder_1.buildResponse)(response, 'getUploadUrl', (r) => {
|
|
374
|
+
const isResponseOk = true && ((response?.getUploadUrl?.uploadUrl !== undefined) && (response?.getUploadUrl?.uploadUrl !== null));
|
|
375
|
+
return isResponseOk;
|
|
376
|
+
});
|
|
621
377
|
}
|
|
622
378
|
catch (err1) {
|
|
623
|
-
console.log(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
627
|
-
else {
|
|
628
|
-
retValue.errors = [err1];
|
|
629
|
-
}
|
|
379
|
+
console.log('createSponsorship err1:');
|
|
380
|
+
console.log(err1);
|
|
381
|
+
retValue = (0, response_builder_1.buildErrorResponse)(err1);
|
|
630
382
|
}
|
|
631
383
|
return retValue;
|
|
632
384
|
}
|
|
@@ -877,7 +629,11 @@ class VTXBaseAPI {
|
|
|
877
629
|
async getTenantSponsorshipsFromUri(tenantUri, token) {
|
|
878
630
|
if ((!tenantUri) || (tenantUri.trim() === "")) {
|
|
879
631
|
return {
|
|
880
|
-
|
|
632
|
+
error: {
|
|
633
|
+
httpStatus: 400,
|
|
634
|
+
code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.code,
|
|
635
|
+
message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI.description
|
|
636
|
+
}
|
|
881
637
|
};
|
|
882
638
|
}
|
|
883
639
|
const credential = token.domains.find(c => {
|
|
@@ -890,13 +646,21 @@ class VTXBaseAPI {
|
|
|
890
646
|
});
|
|
891
647
|
if (!credential) {
|
|
892
648
|
return {
|
|
893
|
-
|
|
649
|
+
error: {
|
|
650
|
+
httpStatus: 400,
|
|
651
|
+
code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_URI_FOR_SPONSOR.code,
|
|
652
|
+
message: "Tenant in domain SPONSOR not found in domains with URI " + tenantUri
|
|
653
|
+
}
|
|
894
654
|
};
|
|
895
655
|
}
|
|
896
656
|
const tenantId = credential.tenant?._id ?? null;
|
|
897
657
|
if ((!tenantId) || (tenantId == "ALL")) {
|
|
898
658
|
return {
|
|
899
|
-
|
|
659
|
+
error: {
|
|
660
|
+
httpStatus: 400,
|
|
661
|
+
code: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.code,
|
|
662
|
+
message: vtx_core_common_1.VTX_ERRORS.INVALID_TENANT_ID.description
|
|
663
|
+
}
|
|
900
664
|
};
|
|
901
665
|
}
|
|
902
666
|
return this.getTenantSponsorships(tenantId);
|