vtb-appit 0.0.37 → 0.0.40
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/appit-base-transformer.js +6 -1
- package/appit.js +12 -36
- package/package.json +1 -1
|
@@ -9,7 +9,12 @@ class AppitBaseTransformer {
|
|
|
9
9
|
const data = JSON.parse(fs.readFileSync(pth.join(__dirname, '../../assets/travelplan.json'), {encoding: 'utf8' }));
|
|
10
10
|
this.travelplan = JSON.parse(JSON.stringify(data));
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
try {
|
|
13
|
+
this.token = fs.readFileSync(pth.join(__dirname, '../../assets/token.jwt'), {encoding: 'utf8' });
|
|
14
|
+
} catch(e) {
|
|
15
|
+
this.token = false;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
labels()
|
package/appit.js
CHANGED
|
@@ -108,16 +108,15 @@ class Appit {
|
|
|
108
108
|
{
|
|
109
109
|
const places = this.transformer.places();
|
|
110
110
|
if(places && places.length) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let formattedPlace = this.clean(JSON.parse(JSON.stringify(formattedPlaces[i])));
|
|
111
|
+
for(let i = 0; i < places.length; i++) {
|
|
112
|
+
let place = this.clean(JSON.parse(JSON.stringify(places[i])));
|
|
114
113
|
|
|
115
|
-
let id = this.findId('places',
|
|
114
|
+
let id = this.findId('places', places[i].object_id);
|
|
116
115
|
if(!id) {
|
|
117
|
-
let model = await this.createPlace({...
|
|
118
|
-
this.history.places[
|
|
116
|
+
let model = await this.createPlace({...place, excursion_id: this.history.excursionId});
|
|
117
|
+
this.history.places[places[i].object_id] = model.data.id;
|
|
119
118
|
} else {
|
|
120
|
-
await this.updatePlace(id, {...
|
|
119
|
+
await this.updatePlace(id, {...place, excursion_id: this.history.excursionId});
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -207,12 +206,15 @@ class Appit {
|
|
|
207
206
|
let destination = this.clean(JSON.parse(JSON.stringify(destinations[i])));
|
|
208
207
|
let labels = this.getLabels(destinations[i]);
|
|
209
208
|
|
|
209
|
+
const images = (destination.images && destination.images.length) ? await this.getImages(destination.images, 'original/lg') : {};
|
|
210
|
+
delete destination.images;
|
|
211
|
+
|
|
210
212
|
let id = this.findId('destinations', destinations[i].object_id);
|
|
211
213
|
if(!id) {
|
|
212
|
-
let model = await this.createDestination({...destination, labels: labels, excursion_id: this.history.excursionId});
|
|
214
|
+
let model = await this.createDestination({...destination, ...images, labels: labels, excursion_id: this.history.excursionId});
|
|
213
215
|
this.history.destinations[destinations[i].object_id] = model.data.id;
|
|
214
216
|
} else {
|
|
215
|
-
await this.updateDestination(id, {...destination, labels: labels, excursion_id: this.history.excursionId});
|
|
217
|
+
await this.updateDestination(id, {...destination, ...images, labels: labels, excursion_id: this.history.excursionId});
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
}
|
|
@@ -246,32 +248,6 @@ class Appit {
|
|
|
246
248
|
return [];
|
|
247
249
|
}
|
|
248
250
|
|
|
249
|
-
async formatPlaces(places)
|
|
250
|
-
{
|
|
251
|
-
let result = [];
|
|
252
|
-
|
|
253
|
-
for(let i = 0; i < places.length; i++) {
|
|
254
|
-
let images = {};
|
|
255
|
-
|
|
256
|
-
if(places[i].media.length)
|
|
257
|
-
images = await this.getImages(places[i].media, 'original/lg');
|
|
258
|
-
|
|
259
|
-
result.push({
|
|
260
|
-
title : places[i].title,
|
|
261
|
-
content : places[i].additionalText,
|
|
262
|
-
category_id : places[i].category_id,
|
|
263
|
-
object_id : (places[i].TSOrderline && places[i].TSOrderline.id) ? places[i].TSOrderline.id : places[i].vtbObjectId,
|
|
264
|
-
lat: (places[i].maps && places[i].maps.latitude) ? places[i].maps.latitude : null,
|
|
265
|
-
lng: (places[i].maps && places[i].maps.longitude) ? places[i].maps.longitude : null,
|
|
266
|
-
address: (places[i].maps && places[i].maps.searchPlace) ? places[i].maps.searchPlace : null,
|
|
267
|
-
labels: this.getLabels(places[i]),
|
|
268
|
-
...images
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
return result;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
251
|
getImages(media, crop)
|
|
276
252
|
{
|
|
277
253
|
const result = {
|
|
@@ -285,7 +261,7 @@ class Appit {
|
|
|
285
261
|
|
|
286
262
|
return new Promise((resolve, reject) => {
|
|
287
263
|
media.forEach(image => {
|
|
288
|
-
const regex = (image.url.match(/amazonaws\.com/)) ? /\.com\/(.*?)\/((?:.*?)\/(?:.*?))\//g : /\.(?:nl|com|travel|io)\.?\/((?:.*?)\/(?:.*?))\//g;
|
|
264
|
+
const regex = (image.url.match(/amazonaws\.com/)) ? /\.com\/(.*?)\/((?:.*?)\/(?:.*?))\//g : /\.(?:nl|com|travel|io|be)\.?\/((?:.*?)\/(?:.*?))\//g;
|
|
289
265
|
const match = regex.exec(image.url);
|
|
290
266
|
|
|
291
267
|
if(match) {
|