@bytebrand/export-cars 1.26.2 → 1.26.4

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.2",
3
+ "version": "1.26.4",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -13,7 +13,7 @@ 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 { ImageSize, ImageType } from '../enums';
16
+ import { ExportType, ImageSize, ImageType } from '../enums';
17
17
 
18
18
  @Injectable()
19
19
  export class ImagesService {
@@ -85,6 +85,8 @@ export class ImagesService {
85
85
  'https://images.auto.de/carimage/noimage/pFyfBsqBHEso/large-cached.jpeg',
86
86
  ];
87
87
 
88
+ private hasLoggedMarketingImageDebug = false;
89
+
88
90
  constructor(private readonly configService: ConfigService, private readonly userService: UserService) { }
89
91
 
90
92
  async getImages(car: DataSchemes.Car, images: ImboImageResponseInterface[], imageType: ImageType, ignoreDefImages: boolean): Promise<Array<string>> {
@@ -179,9 +181,31 @@ export class ImagesService {
179
181
  const imageUrl = this.configService.config.marketingImageUrl;
180
182
 
181
183
  const transformedImages = this.transformImagesArrayIntoObject(images);
182
- const config = await this.userService.getMarketingImageConfig(this.configService.config.marketingImageConfigId);
184
+ // fbMarketingImageId is a hardcoded per-environment id in config.ts and has drifted from
185
+ // the real meta_aia config at least once (dev's id pointed at a stale, never-populated "fb"
186
+ // channel) — the FB feed resolves its config by channelCode instead of trusting that id.
187
+ const config = this.configService.config.exportType === ExportType.FB
188
+ ? await this.userService.getMarketingImageConfigByChannelCode('meta_aia')
189
+ : await this.userService.getMarketingImageConfig(this.configService.config.marketingImageConfigId);
190
+
191
+ if (!config) {
192
+ console.log('getMarketingImages: no marketing image config found (channelCode meta_aia missing?)');
193
+ return ignoreDefImages ? [] : [...this.DEFAULT_IMAGES];
194
+ }
195
+
183
196
  const marketingImageConfigs = config.marketingImages.map(i => ({ marketingImageCodes: i.imageCodes }));
184
197
 
198
+ if (this.configService.config.exportType === ExportType.FB && !this.hasLoggedMarketingImageDebug) {
199
+ this.hasLoggedMarketingImageDebug = true;
200
+ console.log(
201
+ 'getMarketingImages debug —',
202
+ 'config.id:', config.id,
203
+ 'config.channelCode:', config.channelCode,
204
+ 'requested imageCodes per slot:', JSON.stringify(marketingImageConfigs.map(c => c.marketingImageCodes)),
205
+ 'photo codes available on this car:', JSON.stringify(Object.keys(transformedImages)),
206
+ );
207
+ }
208
+
185
209
  const imageWithUrls: Partial<ImboImageResponseInterface & { url: string }>[] = [];
186
210
  for (let i = 0; i < marketingImageConfigs.length; i++) {
187
211
  const marketingImage = marketingImageConfigs[i];
@@ -67,4 +67,17 @@ 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
+ }
70
83
  }