intelica-library-project 20.0.23 → 20.0.24

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.
@@ -2408,6 +2408,10 @@ class Shared {
2408
2408
  globalTermService = inject(GlobalTermService);
2409
2409
  path = `${this.configService.environment?.sharedPath}`;
2410
2410
  sessionTimer;
2411
+ // ventana segura bajo el límite de validez (~5 min) de la embed URL de QuickSight
2412
+ static EMBED_URL_TTL_MS = 4 * 60_000;
2413
+ // caché de embed URLs por dashboardId (independientes de los parámetros del dataset)
2414
+ embedUrlCache = new Map();
2411
2415
  scheduleSessionExpiry(expiresInMinutes) {
2412
2416
  this.clearSessionTimer();
2413
2417
  this.sessionTimer = setTimeout(() => this.handleSessionExpired(), Math.max((expiresInMinutes - 1) * 60_000, 30_000));
@@ -2423,6 +2427,31 @@ class Shared {
2423
2427
  getEmbedUrl(command) {
2424
2428
  return this.http.post(`${this.path}/quicksight-embed-url`, command);
2425
2429
  }
2430
+ /**
2431
+ * Devuelve la embed URL del dashboard desde caché (por dashboardId) o la solicita.
2432
+ * La URL es independiente de los parámetros del dataset (se pide con parameters: undefined),
2433
+ * por eso puede prefetchearse y cachearse. TTL corto por la validez ~5 min de la URL de QuickSight.
2434
+ * De-duplica solicitudes en vuelo: warm + primer embed comparten la misma promesa.
2435
+ */
2436
+ getEmbedUrlCached(dashboardId) {
2437
+ const cached = this.embedUrlCache.get(dashboardId);
2438
+ if (cached && cached.expiresAt > Date.now())
2439
+ return cached.promise;
2440
+ const promise = firstValueFrom(this.getEmbedUrl({ dashboardId, parameters: undefined })).catch(error => {
2441
+ this.embedUrlCache.delete(dashboardId);
2442
+ throw error;
2443
+ });
2444
+ this.embedUrlCache.set(dashboardId, { promise, expiresAt: Date.now() + Shared.EMBED_URL_TTL_MS });
2445
+ return promise;
2446
+ }
2447
+ /** Prefetch (fire-and-forget) de las embed URLs para que el primer embed de cada dashboard no espere el round-trip. */
2448
+ warmEmbedUrls(dashboardIds) {
2449
+ for (const dashboardId of dashboardIds) {
2450
+ if (!dashboardId)
2451
+ continue;
2452
+ void this.getEmbedUrlCached(dashboardId).catch(() => undefined);
2453
+ }
2454
+ }
2426
2455
  getEmbedVisualUrl(command) {
2427
2456
  return this.http.post(`${this.path}/quicksight-embed-visual-url`, command);
2428
2457
  }
@@ -2445,7 +2474,9 @@ class Shared {
2445
2474
  }
2446
2475
  async embedDashboardInteractive(command, container, options) {
2447
2476
  container.replaceChildren();
2448
- const dashResponse = await firstValueFrom(this.getEmbedUrl({ ...command, parameters: undefined }));
2477
+ const dashResponse = await this.getEmbedUrlCached(command.dashboardId);
2478
+ // las embed URLs de QuickSight son de un solo uso al inicializar el iframe: se invalida tras consumirla
2479
+ this.embedUrlCache.delete(command.dashboardId);
2449
2480
  this.scheduleSessionExpiry(dashResponse.expiresInMinutes);
2450
2481
  const embeddingContext = await createEmbeddingContext();
2451
2482
  const sdkParameters = command.parameters ? Object.entries(command.parameters).map(([Name, Values]) => ({ Name, Values })) : undefined;