@bytebrand/export-cars 1.26.13 → 1.26.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/export-cars",
3
- "version": "1.26.13",
3
+ "version": "1.26.15",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -8,12 +8,12 @@ import { MarketingImageConfigsInterface } from '@bytebrand/autode-request';
8
8
  import { ImboImageResponseInterface } from '@bytebrand/chunkable';
9
9
  import { DataSchemes } from '@bytebrand/car-schema';
10
10
 
11
- import { FB_MAX_IMAGE_COUNT_FOR_DEAFULT, META_AIA_CHANNEL_CODE, META_AIA_MODE_FINANCING } from '../constants/fb.constants';
11
+ import { FB_MAX_IMAGE_COUNT_FOR_DEAFULT, META_AIA_CHANNEL_CODE } from '../constants/fb.constants';
12
12
  import { ConfigService } from './config.service';
13
13
  import { UserService } from './user.service';
14
14
  import { isNotEmptyArray } from '../utils';
15
15
  import { Config } from '../configs/config';
16
- import { ExportType, ImageSize, ImageType } from '../enums';
16
+ import { ImageSize, ImageType } from '../enums';
17
17
 
18
18
  @Injectable()
19
19
  export class ImagesService {
@@ -176,28 +176,10 @@ export class ImagesService {
176
176
  }
177
177
 
178
178
  async getMarketingImages(carId: string, images: ImboImageResponseInterface[], ignoreDefImages: boolean): Promise<string[]> {
179
- const transformedImages = this.transformImagesArrayIntoObject(images);
180
- // fbMarketingImageId is a hardcoded per-environment id in config.ts and has drifted from
181
- // the real meta_aia config at least once (dev's id pointed at a stale, never-populated "fb"
182
- // channel) — the FB feed resolves its config by channelCode instead of trusting that id.
183
- const config = this.configService.config.exportType === ExportType.FB
184
- ? await this.userService.getMarketingImageConfigByChannelCode(META_AIA_CHANNEL_CODE)
185
- : await this.userService.getMarketingImageConfig(this.configService.config.marketingImageConfigId);
186
-
187
- if (!config) {
188
- console.log('getMarketingImages: no marketing image config found (channelCode meta_aia missing?)');
189
- return ignoreDefImages ? [] : [...this.DEFAULT_IMAGES];
190
- }
191
-
192
- // marketingImageUrl AND config.imageUrl (FbConfig overrides the latter to the same
193
- // per-env value right after super()) both point at the old "fb" channel's base path
194
- // (/cache_test on dev, already /generated_images on prod) — not where image-generator
195
- // publishes meta_aia composites. metaAiaImageUrl is derived from the un-suffixed
196
- // baseImageUrl, so it's the one safe /generated_images base.
197
- const imageUrl = config.channelCode === META_AIA_CHANNEL_CODE
198
- ? this.configService.config.metaAiaImageUrl
199
- : this.configService.config.marketingImageUrl;
179
+ const imageUrl = this.configService.config.marketingImageUrl;
200
180
 
181
+ const transformedImages = this.transformImagesArrayIntoObject(images);
182
+ const config = await this.userService.getMarketingImageConfig(this.configService.config.marketingImageConfigId);
201
183
  const marketingImageConfigs = config.marketingImages.map(i => ({ marketingImageCodes: i.imageCodes }));
202
184
 
203
185
  const imageWithUrls: Partial<ImboImageResponseInterface & { url: string }>[] = [];
@@ -292,13 +274,7 @@ export class ImagesService {
292
274
 
293
275
  protected getImagePathWithExtension(imageUrl: string, carId: string, imageId: string, config: MarketingImageConfigsInterface): string {
294
276
  const { channelCode, imageExtension } = config;
295
- // image-generator's MetaAiaImagesService writes files as `meta-aia-financing-{imageId}` /
296
- // `meta-aia-leasing-{imageId}` (hyphenated, mode baked into the name) — not derived from
297
- // channelCode the way other channels are. FB only wants the financing variant.
298
- const filenamePrefix = channelCode === META_AIA_CHANNEL_CODE
299
- ? `meta-aia-${META_AIA_MODE_FINANCING}`
300
- : channelCode.replace(/ /g, '-');
301
- return `${this.getChannelPath(imageUrl, carId)}/${filenamePrefix}-${imageId}.${imageExtension}`;
277
+ return `${this.getChannelPath(imageUrl, carId)}/${channelCode.replace(/ /g, '-')}-${imageId}.${imageExtension}`;
302
278
  }
303
279
 
304
280
  sortImages(images: ImboImageResponseInterface[]): ImboImageResponseInterface[] {
@@ -67,17 +67,4 @@ export class UserService {
67
67
 
68
68
  return result;
69
69
  }
70
-
71
- // The per-environment fbMarketingImageId config.ts hardcodes doesn't reliably point at the
72
- // meta_aia channel (dev's id 8 turned out to be a stale, never-populated "fb" channel) —
73
- // resolve by channelCode instead of trusting a fixed id.
74
- async getMarketingImageConfigByChannelCode(channelCode: string): Promise<MarketingImageConfigInterface | null> {
75
- const configs = await this.getMarketingImageConfigs();
76
- const match = configs.find(config => config.channelCode === channelCode);
77
- if (!match) {
78
- return null;
79
- }
80
-
81
- return this.getMarketingImageConfig(match.id);
82
- }
83
70
  }
@@ -68,7 +68,8 @@ export class FacebookShopTransformer {
68
68
  return [];
69
69
  }
70
70
 
71
- const vehicleId = toString(get(car, 'metaData.vehicleId', car._id));
71
+ // ADV-200: AIA/AMA now wants the long auto.de ID (VDP URL id), not the short metaData.vehicleId code
72
+ const vehicleId = toString(car._id);
72
73
  const make = toString(get(car, 'mainData.make', ''));
73
74
  const model = toString(get(car, 'mainData.model', ''));
74
75
  const price = this.getPriceValue(car);
@@ -30,13 +30,13 @@ import { ConfigService, ImagesService, MappingService } from '../services';
30
30
  import { FbEquipment } from './fb-equipment.transformer';
31
31
  import { isValidVin, normalizeFeedText } from '../utils';
32
32
  import { UserService } from 'src/services';
33
- import { ImageType } from '../enums';
34
33
  import {
35
34
  DEFAULT_ADDR1,
36
35
  DEFAULT_CITY,
37
36
  DEFAULT_ZIP,
38
37
  FB_MAX_TRIM_LENGTH,
39
38
  FB_MIN_MILEAGES,
39
+ META_AIA_MODE_FINANCING,
40
40
  META_PUSH_PRIORITY_ALLOWED_VALUES,
41
41
  META_PUSH_PRIORITY_STANDARD,
42
42
  TIMESTAMP_FIRST_YEAR,
@@ -72,10 +72,12 @@ export class FbTransformer {
72
72
  images: ImboImageResponseInterface[];
73
73
  owner: unknown;
74
74
  }): Promise<unknown> {
75
- // ignoreDefImages=true: cars with no real photos must be excluded, not padded with
76
- // placeholders (matches facebook-shop.transformer.ts's AMA feed policy).
77
- const image_links = await this.imagesService.getImages(car, images, ImageType.marketing, true);
78
- if (!image_links.length) {
75
+ // Meta AIA financing overlay is the ONLY image this feed ships — same HEAD-checked path as
76
+ // the AMA facebook-shop feed. getMetaAiaImage returns null when the car has no eligible photo
77
+ // OR the composite hasn't actually been rendered/landed on the CDN yet, so every exported item
78
+ // is guaranteed a real, existing image (no placeholders, no 404s, no zero-image cars).
79
+ const metaAiaImage = await this.imagesService.getMetaAiaImage(car._id, images, META_AIA_MODE_FINANCING);
80
+ if (!metaAiaImage) {
79
81
  return null;
80
82
  }
81
83
 
@@ -93,7 +95,8 @@ export class FbTransformer {
93
95
  ...dealerInfo,
94
96
  user_id: ownerId,
95
97
  custom_label_4: await this.getMetaPushPriority(ownerId),
96
- vehicle_id: get(car, 'metaData.vehicleId', autodeId),
98
+ // ADV-200: AIA/AMA now wants the long auto.de ID (VDP URL id), not the short metaData.vehicleId code
99
+ vehicle_id: autodeId,
97
100
  stock_number: autodeId,
98
101
  availability: this.mapAvailability(car),
99
102
  title: this.getTitle(car),
@@ -105,7 +108,7 @@ export class FbTransformer {
105
108
  make: toString(get(car, 'mainData.make', '')),
106
109
  model: toString(get(car, 'mainData.model', '')),
107
110
  trim: this.getTrim(car),
108
- image: image_links.slice(0, 20), // Meta caps the whole image array at 20 items
111
+ image: [metaAiaImage], // single Meta AIA financing overlay, per feed spec
109
112
  year: toString(year),
110
113
  mileage: {
111
114
  value: this.getMileage(car),