@plyaz/api 1.7.3 → 1.7.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.
@@ -12840,10 +12840,17 @@ __name(createStatusCodeLimits, "createStatusCodeLimits");
12840
12840
  var cacheStrategies = {
12841
12841
  /**
12842
12842
  * No caching - always fetch fresh data
12843
- * Use for: Real-time data, sensitive information
12843
+ * Use for: Real-time data, sensitive information, mutations
12844
+ *
12845
+ * IMPORTANT: Explicit ttl/stale of 0 prevents staleTime refetch issues.
12846
+ * The skip:true alone doesn't prevent default staleTime from being applied.
12844
12847
  */
12845
12848
  none: {
12846
- skip: true
12849
+ skip: true,
12850
+ ttl: 0,
12851
+ // No caching
12852
+ stale: 0
12853
+ // No stale refetch (prevents 60s re-trigger issue)
12847
12854
  },
12848
12855
  /**
12849
12856
  * Short-lived cache for frequently changing data
@@ -17228,18 +17235,19 @@ var unifiedStrategies = {
17228
17235
  },
17229
17236
  /**
17230
17237
  * Mutation: POST/PUT/DELETE operations (uploads, creates, updates, deletes)
17231
- * - NO caching (mutations should never be cached)
17232
- * - Standard retry for actual failures
17238
+ * - NO caching (cache: 'none' sets skip:true, ttl:0, stale:0 - prevents staleTime refetch!)
17239
+ * - Conservative retry (allows retry on server errors 500/502/503/504)
17233
17240
  * - NO polling (critical! - polling causes duplicate mutations)
17234
17241
  * - Realtime performance (immediate response)
17235
17242
  *
17236
- * Use this for any data-modifying operation to prevent duplicate requests.
17243
+ * Note: The retry is safe because it only triggers on actual errors (5xx).
17244
+ * The staleTime refetch issue was fixed by setting stale:0 in cache:'none'.
17237
17245
  */
17238
17246
  mutation: {
17239
17247
  cache: "none",
17240
- // Never cache mutations
17241
- retry: "none",
17242
- // No retry - mutations should not auto-retry to prevent duplicates
17248
+ // Never cache mutations (ttl:0, stale:0 prevents refetch)
17249
+ retry: "conservative",
17250
+ // Retry on server errors (500/502/503/504) only
17243
17251
  // NO polling - this is critical! Polling would re-execute the mutation
17244
17252
  performance: "realtime"
17245
17253
  // Immediate response, no batching
@@ -21523,10 +21531,28 @@ function mergeHeadersCaseInsensitive(...headerSets) {
21523
21531
  return result;
21524
21532
  }
21525
21533
  __name(mergeHeadersCaseInsensitive, "mergeHeadersCaseInsensitive");
21526
- function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfig, configStrategy) {
21534
+ function createOnRequestHandler(options) {
21535
+ const {
21536
+ handlers,
21537
+ enrichedHeadersConfig,
21538
+ encryptionConfig,
21539
+ configStrategy,
21540
+ getResolvedFetchffConfig
21541
+ } = options;
21527
21542
  return async (config) => {
21528
21543
  const performanceFactory = getPerformanceEventFactory();
21529
21544
  const requestId = generateRequestId();
21545
+ if (getResolvedFetchffConfig) {
21546
+ const resolvedConfig = getResolvedFetchffConfig();
21547
+ config = {
21548
+ ...config,
21549
+ ...resolvedConfig,
21550
+ headers: {
21551
+ ...resolvedConfig.headers,
21552
+ ...config.headers
21553
+ }
21554
+ };
21555
+ }
21530
21556
  startRequestTracking(requestId);
21531
21557
  UnifiedDebugger.getInstance().trackConfigChange(
21532
21558
  { headers: config.headers },
@@ -21695,7 +21721,8 @@ function setupUnifiedHandlers(params) {
21695
21721
  enrichedHeadersConfig,
21696
21722
  globalConfig,
21697
21723
  clientOptions,
21698
- clearTemporaryOverrides: clearTemporaryOverrides2
21724
+ clearTemporaryOverrides: clearTemporaryOverrides2,
21725
+ getResolvedFetchffConfig
21699
21726
  } = params;
21700
21727
  const mergedOnRequest = mergeHandlers(
21701
21728
  globalConfig?.onRequest,
@@ -21721,12 +21748,13 @@ function setupUnifiedHandlers(params) {
21721
21748
  const encryptionConfig = mergedConfig.encryption ?? globalConfig?.encryption ?? clientOptions?.encryption;
21722
21749
  const configStrategy = mergedConfig.configOverride?.strategy ?? clientOptions?.configOverride?.strategy ?? globalConfig?.configOverride?.strategy ?? "merge";
21723
21750
  return {
21724
- onRequest: createOnRequestHandler(
21725
- mergedOnRequest,
21751
+ onRequest: createOnRequestHandler({
21752
+ handlers: mergedOnRequest,
21726
21753
  enrichedHeadersConfig,
21727
21754
  encryptionConfig,
21728
- configStrategy
21729
- ),
21755
+ configStrategy,
21756
+ getResolvedFetchffConfig
21757
+ }),
21730
21758
  onResponse: createOnResponseHandler(
21731
21759
  mergedOnResponse,
21732
21760
  clearTemporaryOverrides2,
@@ -22081,15 +22109,21 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22081
22109
  const validation = validateConfigUpdate(updates, updateOptions);
22082
22110
  if (!validation.valid) {
22083
22111
  handleInvalidConfigUpdate(validation, updates, updateOptions);
22084
- return;
22112
+ return { fetchffConfig: {}, applied: false };
22085
22113
  }
22086
22114
  const result = applyConfigUpdate(configState, updates, updateOptions);
22087
22115
  configState = result.state;
22088
22116
  setConfigState(configState);
22089
22117
  const newConfig = getEffectiveConfig(configState);
22118
+ let resolvedUpdates = { ...updates };
22119
+ if (updates.unifiedStrategy) {
22120
+ resolvedUpdates = applyUnifiedStrategyToConfig(resolvedUpdates, updates.unifiedStrategy);
22121
+ }
22122
+ resolvedUpdates = applyIndividualStrategies(resolvedUpdates, updates);
22123
+ const fetchffConfig = toFetchffConfig(resolvedUpdates);
22090
22124
  if (client && "__config" in client) {
22091
22125
  const fetchffClient = client;
22092
- Object.assign(fetchffClient["__config"], updates);
22126
+ Object.assign(fetchffClient["__config"], fetchffConfig);
22093
22127
  }
22094
22128
  eventManager2.updateConfig(updates, updateOptions ?? {});
22095
22129
  const afterEventState = captureEventState(eventManager2);
@@ -22103,11 +22137,13 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22103
22137
  validation,
22104
22138
  startTime
22105
22139
  });
22140
+ return { fetchffConfig, applied: true };
22106
22141
  };
22107
22142
  }
22108
22143
  __name(createUpdateConfigMethod, "createUpdateConfigMethod");
22109
- function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers) {
22110
- return createApiFetcher({
22144
+ function createFetchffClient(params) {
22145
+ const { fetchffConfig, effectiveConfig, options, unifiedHandlers, getResolvedFetchffConfig } = params;
22146
+ const rawClient = createApiFetcher({
22111
22147
  ...fetchffConfig,
22112
22148
  baseURL: effectiveConfig.baseURL ?? options.apiUrl,
22113
22149
  endpoints,
@@ -22116,6 +22152,26 @@ function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHan
22116
22152
  onError: unifiedHandlers.onError,
22117
22153
  onRetry: unifiedHandlers.onRetry
22118
22154
  });
22155
+ const endpointMethodNames = new Set(Object.keys(endpoints));
22156
+ return new Proxy(rawClient, {
22157
+ get(target, prop, receiver) {
22158
+ const value = Reflect.get(target, prop, receiver);
22159
+ if (typeof value !== "function" || typeof prop !== "string") {
22160
+ return value;
22161
+ }
22162
+ if (!endpointMethodNames.has(prop)) {
22163
+ return value;
22164
+ }
22165
+ return /* @__PURE__ */ __name(function wrappedEndpointMethod(config) {
22166
+ const resolvedConfig = getResolvedFetchffConfig();
22167
+ const mergedConfig = {
22168
+ ...resolvedConfig,
22169
+ ...config
22170
+ };
22171
+ return value.call(this, mergedConfig);
22172
+ }, "wrappedEndpointMethod");
22173
+ }
22174
+ });
22119
22175
  }
22120
22176
  __name(createFetchffClient, "createFetchffClient");
22121
22177
  function enhanceClientWithMethods(params) {
@@ -22200,14 +22256,33 @@ async function createApiClient(options = {}) {
22200
22256
  const effectiveConfig = getEffectiveConfig(stateContainer.current);
22201
22257
  const fetchffConfig = toFetchffConfig(effectiveConfig);
22202
22258
  let clearTemporaryOverridesFn;
22259
+ const getResolvedFetchffConfig = /* @__PURE__ */ __name(() => {
22260
+ const currentConfig = getEffectiveConfig(stateContainer.current);
22261
+ let resolvedConfig2 = { ...currentConfig };
22262
+ if (currentConfig.unifiedStrategy) {
22263
+ resolvedConfig2 = applyUnifiedStrategyToConfig(
22264
+ resolvedConfig2,
22265
+ currentConfig.unifiedStrategy
22266
+ );
22267
+ }
22268
+ resolvedConfig2 = applyIndividualStrategies(resolvedConfig2, currentConfig);
22269
+ return toFetchffConfig(resolvedConfig2);
22270
+ }, "getResolvedFetchffConfig");
22203
22271
  const unifiedHandlers = setupUnifiedHandlers({
22204
22272
  mergedConfig: effectiveConfig,
22205
22273
  enrichedHeadersConfig: options.enrichedHeaders,
22206
22274
  globalConfig,
22207
22275
  clientOptions: options,
22208
- clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides")
22276
+ clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides"),
22277
+ getResolvedFetchffConfig
22278
+ });
22279
+ const client = createFetchffClient({
22280
+ fetchffConfig,
22281
+ effectiveConfig,
22282
+ options,
22283
+ unifiedHandlers,
22284
+ getResolvedFetchffConfig
22209
22285
  });
22210
- const client = createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers);
22211
22286
  const clientWithEvents = setupClientEvents(client, globalConfig, options);
22212
22287
  const { eventManager: eventManager2 } = clientWithEvents;
22213
22288
  Object.defineProperty(clientWithEvents, "then", {
@@ -23760,8 +23835,8 @@ async function uploadFile(data, options) {
23760
23835
  const client = options?.apiClient ?? getDefaultApiClient();
23761
23836
  const serviceDefaults = {
23762
23837
  unifiedStrategy: "mutation",
23763
- timeout: 6e4
23764
- // 60 seconds for uploads
23838
+ timeout: 12e4
23839
+ // 2 minutes for large uploads
23765
23840
  };
23766
23841
  const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
23767
23842
  const updateOptions = {