@plyaz/api 1.6.7 → 1.7.0

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.
@@ -1,6 +1,6 @@
1
1
  import { abortRequest as abortRequest$1, isSlowConnection as isSlowConnection$1, deleteCache as deleteCache$1, getCache as getCache$1, mutate, setCache as setCache$1, subscribe as subscribe$1, revalidateAll as revalidateAll$1, revalidate, setDefaultConfig, createApiFetcher } from 'fetchff';
2
2
  export { removeRevalidators, revalidate, revalidateAll } from 'fetchff';
3
- import { ApiPackageError as ApiPackageError$1, emitScopedErrorEvent, generateCorrelationId, generateRequestId, generateTraceCorrelationId, registerEventFactory, registerErrorHandler as registerErrorHandler$1, registerScopedHandlers, setErrorHandlers as setErrorHandlers$1, getErrorHandlers as getErrorHandlers$1, unregisterScopedHandlers, clearErrorHandlers as clearErrorHandlers$1, registerOnceErrorHandler, isErrorSystemInitialized, setErrorLocale, addMessageCatalog, initializeErrorSystem } from '@plyaz/errors';
3
+ import { ApiPackageError as ApiPackageError$1, emitScopedErrorEvent, generateCorrelationId, generateRequestId, generateTraceCorrelationId, registerEventFactory, registerErrorHandler as registerErrorHandler$1, registerScopedHandlers, setErrorHandlers as setErrorHandlers$1, getErrorHandlers as getErrorHandlers$1, unregisterScopedHandlers, clearErrorHandlers as clearErrorHandlers$1, registerOnceErrorHandler, isErrorSystemInitialized, setErrorLocale, addMessageCatalog, initializeErrorSystem, getErrorCodeByStatus } from '@plyaz/errors';
4
4
  export { getErrorCategory, getErrorCodeByStatus, getErrorDefinition } from '@plyaz/errors';
5
5
  import { PRIORITY_LEVEL, EVENT_SCOPES_WITH_TEMPORARY, EVENT_NAMESPACES, HEADER_EVENTS, NETWORK_EVENTS, ERROR_EVENTS, DEBUG_EVENTS, CONFIG_EVENTS, PERFORMANCE_EVENTS, CACHE_EVENTS, CLIENT_EVENTS, NETWORK_QUALITY, EVENT_PRIORITY_MAP, PACKAGE_STATUS_CODES, API_ERROR_CODES, OPERATIONS, HISTORY_TYPES, EVENT_SCOPES as EVENT_SCOPES$1, HANDLER_SCOPES as HANDLER_SCOPES$1, DEFAULT_THRESHOLDS, NETWORK_CONFIDENCE_LEVELS, UPDATE_STRATEGIES, DEBUGGER_CONFIG_SOURCES, RTT_THRESHOLDS, SPEED_THRESHOLDS, REGIONAL_CONFIDENCE_LEVELS as REGIONAL_CONFIDENCE_LEVELS$1, COORDINATES, STORAGE_TYPES, ERROR_FIELDS, EVENT_OPERATIONS } from '@plyaz/types/api';
6
6
  export { NETWORK_QUALITY, PUB_SUB_EVENT } from '@plyaz/types/api';
@@ -9121,6 +9121,9 @@ var UnifiedDebugger = class _UnifiedDebugger {
9121
9121
  performanceMode = "minimal";
9122
9122
  trackAllProperties = true;
9123
9123
  // If false, uses TRACKED_PROPERTIES filter
9124
+ // Debug report control - disabled by default, enable via config:
9125
+ // createApiClient({ debugEvents: { comprehensiveReport: true } })
9126
+ comprehensiveReportEnabled = false;
9124
9127
  // Tracking configuration from API config
9125
9128
  trackingConfig = {};
9126
9129
  // Configurable limits
@@ -9549,8 +9552,14 @@ var UnifiedDebugger = class _UnifiedDebugger {
9549
9552
  }
9550
9553
  /**
9551
9554
  * Log comprehensive report to console
9555
+ *
9556
+ * Controlled via API config: debugEvents.comprehensiveReport = true
9557
+ * Or programmatically via setComprehensiveReportEnabled(true)
9552
9558
  */
9553
9559
  async logComprehensiveReport() {
9560
+ if (!this.comprehensiveReportEnabled) {
9561
+ return;
9562
+ }
9554
9563
  try {
9555
9564
  const presetReport = this.getPresetChangeReport();
9556
9565
  if (presetReport) {
@@ -9572,6 +9581,20 @@ var UnifiedDebugger = class _UnifiedDebugger {
9572
9581
  throw error;
9573
9582
  }
9574
9583
  }
9584
+ /**
9585
+ * Enable or disable comprehensive debug report logging
9586
+ *
9587
+ * Typically configured via API config: debugEvents.comprehensiveReport
9588
+ */
9589
+ setComprehensiveReportEnabled(enabled) {
9590
+ this.comprehensiveReportEnabled = enabled;
9591
+ }
9592
+ /**
9593
+ * Get current comprehensive report enabled state
9594
+ */
9595
+ getComprehensiveReportEnabled() {
9596
+ return this.comprehensiveReportEnabled;
9597
+ }
9575
9598
  /**
9576
9599
  * Get debug report (alias for generateDebugReport for API consistency)
9577
9600
  */
@@ -16147,6 +16170,11 @@ var ClientEventManager = class _ClientEventManager {
16147
16170
  this.config.configOverride.eventScopes ??= [...EVENT_SCOPES$1];
16148
16171
  }
16149
16172
  eventManager.setEventScopes(this.config.configOverride.eventScopes);
16173
+ if (this.config.debugEvents?.comprehensiveReport !== void 0) {
16174
+ getUnifiedDebugger().setComprehensiveReportEnabled(
16175
+ this.config.debugEvents.comprehensiveReport
16176
+ );
16177
+ }
16150
16178
  this.setupEventHandlers();
16151
16179
  }
16152
16180
  static {
@@ -16804,6 +16832,9 @@ var ClientEventManager = class _ClientEventManager {
16804
16832
  const id = setInterval(() => this.getDebugInfo(), interval);
16805
16833
  this.monitoringState.intervals.push(id);
16806
16834
  }
16835
+ if (debugConfig?.comprehensiveReport !== void 0) {
16836
+ getUnifiedDebugger().setComprehensiveReportEnabled(debugConfig.comprehensiveReport);
16837
+ }
16807
16838
  }
16808
16839
  /**
16809
16840
  * Stop monitoring
@@ -21596,7 +21627,7 @@ function createOnErrorHandler(handlers, clearTemporaryOverrides2, clearOnComplet
21596
21627
  const apiError = new ApiPackageError(
21597
21628
  "request.failed",
21598
21629
  PACKAGE_STATUS_CODES.REQUEST_FAILED,
21599
- error.status ? `HTTP_${error.status}` : API_ERROR_CODES.NETWORK_ERROR,
21630
+ error.status ? getErrorCodeByStatus(error.status) ?? API_ERROR_CODES.CLIENT_ERROR : API_ERROR_CODES.NETWORK_ERROR,
21600
21631
  {
21601
21632
  cause: error,
21602
21633
  context: {