@plyaz/api 1.7.2 → 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.
Files changed (28) hide show
  1. package/dist/api/cache/strategies.d.ts.map +1 -1
  2. package/dist/api/client/createApiClient.d.ts.map +1 -1
  3. package/dist/api/client/helpers/interceptors.d.ts +2 -2
  4. package/dist/api/client/helpers/interceptors.d.ts.map +1 -1
  5. package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts +2 -2
  6. package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts.map +1 -1
  7. package/dist/api/services/campaigns/GET/useCampaign.d.ts +2 -2
  8. package/dist/api/services/campaigns/GET/useCampaign.d.ts.map +1 -1
  9. package/dist/api/services/campaigns/GET/useCampaigns.d.ts +2 -2
  10. package/dist/api/services/campaigns/GET/useCampaigns.d.ts.map +1 -1
  11. package/dist/api/services/campaigns/POST/createCampaign.d.ts +2 -2
  12. package/dist/api/services/campaigns/POST/createCampaign.d.ts.map +1 -1
  13. package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts +2 -2
  14. package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts.map +1 -1
  15. package/dist/api/services/campaigns/PUT/updateCampaign.d.ts +2 -2
  16. package/dist/api/services/campaigns/PUT/updateCampaign.d.ts.map +1 -1
  17. package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts +2 -2
  18. package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts.map +1 -1
  19. package/dist/api/strategies/unified.d.ts.map +1 -1
  20. package/dist/entry-frontend.cjs +111 -33
  21. package/dist/entry-frontend.cjs.map +1 -1
  22. package/dist/entry-frontend.mjs +111 -33
  23. package/dist/entry-frontend.mjs.map +1 -1
  24. package/dist/index.cjs +111 -33
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.mjs +111 -33
  27. package/dist/index.mjs.map +1 -1
  28. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -12851,10 +12851,17 @@ __name(createStatusCodeLimits, "createStatusCodeLimits");
12851
12851
  var cacheStrategies = {
12852
12852
  /**
12853
12853
  * No caching - always fetch fresh data
12854
- * Use for: Real-time data, sensitive information
12854
+ * Use for: Real-time data, sensitive information, mutations
12855
+ *
12856
+ * IMPORTANT: Explicit ttl/stale of 0 prevents staleTime refetch issues.
12857
+ * The skip:true alone doesn't prevent default staleTime from being applied.
12855
12858
  */
12856
12859
  none: {
12857
- skip: true
12860
+ skip: true,
12861
+ ttl: 0,
12862
+ // No caching
12863
+ stale: 0
12864
+ // No stale refetch (prevents 60s re-trigger issue)
12858
12865
  },
12859
12866
  /**
12860
12867
  * Short-lived cache for frequently changing data
@@ -17239,18 +17246,19 @@ var unifiedStrategies = {
17239
17246
  },
17240
17247
  /**
17241
17248
  * Mutation: POST/PUT/DELETE operations (uploads, creates, updates, deletes)
17242
- * - NO caching (mutations should never be cached)
17243
- * - Standard retry for actual failures
17249
+ * - NO caching (cache: 'none' sets skip:true, ttl:0, stale:0 - prevents staleTime refetch!)
17250
+ * - Conservative retry (allows retry on server errors 500/502/503/504)
17244
17251
  * - NO polling (critical! - polling causes duplicate mutations)
17245
17252
  * - Realtime performance (immediate response)
17246
17253
  *
17247
- * Use this for any data-modifying operation to prevent duplicate requests.
17254
+ * Note: The retry is safe because it only triggers on actual errors (5xx).
17255
+ * The staleTime refetch issue was fixed by setting stale:0 in cache:'none'.
17248
17256
  */
17249
17257
  mutation: {
17250
17258
  cache: "none",
17251
- // Never cache mutations
17252
- retry: "standard",
17253
- // Standard retry for actual failures (not successes)
17259
+ // Never cache mutations (ttl:0, stale:0 prevents refetch)
17260
+ retry: "conservative",
17261
+ // Retry on server errors (500/502/503/504) only
17254
17262
  // NO polling - this is critical! Polling would re-execute the mutation
17255
17263
  performance: "realtime"
17256
17264
  // Immediate response, no batching
@@ -21534,10 +21542,28 @@ function mergeHeadersCaseInsensitive(...headerSets) {
21534
21542
  return result;
21535
21543
  }
21536
21544
  __name(mergeHeadersCaseInsensitive, "mergeHeadersCaseInsensitive");
21537
- function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfig, configStrategy) {
21545
+ function createOnRequestHandler(options) {
21546
+ const {
21547
+ handlers,
21548
+ enrichedHeadersConfig,
21549
+ encryptionConfig,
21550
+ configStrategy,
21551
+ getResolvedFetchffConfig
21552
+ } = options;
21538
21553
  return async (config) => {
21539
21554
  const performanceFactory = getPerformanceEventFactory();
21540
21555
  const requestId = generateRequestId();
21556
+ if (getResolvedFetchffConfig) {
21557
+ const resolvedConfig = getResolvedFetchffConfig();
21558
+ config = {
21559
+ ...config,
21560
+ ...resolvedConfig,
21561
+ headers: {
21562
+ ...resolvedConfig.headers,
21563
+ ...config.headers
21564
+ }
21565
+ };
21566
+ }
21541
21567
  startRequestTracking(requestId);
21542
21568
  UnifiedDebugger.getInstance().trackConfigChange(
21543
21569
  { headers: config.headers },
@@ -21706,7 +21732,8 @@ function setupUnifiedHandlers(params) {
21706
21732
  enrichedHeadersConfig,
21707
21733
  globalConfig,
21708
21734
  clientOptions,
21709
- clearTemporaryOverrides: clearTemporaryOverrides2
21735
+ clearTemporaryOverrides: clearTemporaryOverrides2,
21736
+ getResolvedFetchffConfig
21710
21737
  } = params;
21711
21738
  const mergedOnRequest = mergeHandlers(
21712
21739
  globalConfig?.onRequest,
@@ -21732,12 +21759,13 @@ function setupUnifiedHandlers(params) {
21732
21759
  const encryptionConfig = mergedConfig.encryption ?? globalConfig?.encryption ?? clientOptions?.encryption;
21733
21760
  const configStrategy = mergedConfig.configOverride?.strategy ?? clientOptions?.configOverride?.strategy ?? globalConfig?.configOverride?.strategy ?? "merge";
21734
21761
  return {
21735
- onRequest: createOnRequestHandler(
21736
- mergedOnRequest,
21762
+ onRequest: createOnRequestHandler({
21763
+ handlers: mergedOnRequest,
21737
21764
  enrichedHeadersConfig,
21738
21765
  encryptionConfig,
21739
- configStrategy
21740
- ),
21766
+ configStrategy,
21767
+ getResolvedFetchffConfig
21768
+ }),
21741
21769
  onResponse: createOnResponseHandler(
21742
21770
  mergedOnResponse,
21743
21771
  clearTemporaryOverrides2,
@@ -22092,15 +22120,21 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22092
22120
  const validation = validateConfigUpdate(updates, updateOptions);
22093
22121
  if (!validation.valid) {
22094
22122
  handleInvalidConfigUpdate(validation, updates, updateOptions);
22095
- return;
22123
+ return { fetchffConfig: {}, applied: false };
22096
22124
  }
22097
22125
  const result = applyConfigUpdate(configState, updates, updateOptions);
22098
22126
  configState = result.state;
22099
22127
  setConfigState(configState);
22100
22128
  const newConfig = getEffectiveConfig(configState);
22129
+ let resolvedUpdates = { ...updates };
22130
+ if (updates.unifiedStrategy) {
22131
+ resolvedUpdates = applyUnifiedStrategyToConfig(resolvedUpdates, updates.unifiedStrategy);
22132
+ }
22133
+ resolvedUpdates = applyIndividualStrategies(resolvedUpdates, updates);
22134
+ const fetchffConfig = toFetchffConfig(resolvedUpdates);
22101
22135
  if (client && "__config" in client) {
22102
22136
  const fetchffClient = client;
22103
- Object.assign(fetchffClient["__config"], updates);
22137
+ Object.assign(fetchffClient["__config"], fetchffConfig);
22104
22138
  }
22105
22139
  eventManager2.updateConfig(updates, updateOptions ?? {});
22106
22140
  const afterEventState = captureEventState(eventManager2);
@@ -22114,11 +22148,13 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22114
22148
  validation,
22115
22149
  startTime
22116
22150
  });
22151
+ return { fetchffConfig, applied: true };
22117
22152
  };
22118
22153
  }
22119
22154
  __name(createUpdateConfigMethod, "createUpdateConfigMethod");
22120
- function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers) {
22121
- return createApiFetcher({
22155
+ function createFetchffClient(params) {
22156
+ const { fetchffConfig, effectiveConfig, options, unifiedHandlers, getResolvedFetchffConfig } = params;
22157
+ const rawClient = createApiFetcher({
22122
22158
  ...fetchffConfig,
22123
22159
  baseURL: effectiveConfig.baseURL ?? options.apiUrl,
22124
22160
  endpoints,
@@ -22127,6 +22163,26 @@ function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHan
22127
22163
  onError: unifiedHandlers.onError,
22128
22164
  onRetry: unifiedHandlers.onRetry
22129
22165
  });
22166
+ const endpointMethodNames = new Set(Object.keys(endpoints));
22167
+ return new Proxy(rawClient, {
22168
+ get(target, prop, receiver) {
22169
+ const value = Reflect.get(target, prop, receiver);
22170
+ if (typeof value !== "function" || typeof prop !== "string") {
22171
+ return value;
22172
+ }
22173
+ if (!endpointMethodNames.has(prop)) {
22174
+ return value;
22175
+ }
22176
+ return /* @__PURE__ */ __name(function wrappedEndpointMethod(config) {
22177
+ const resolvedConfig = getResolvedFetchffConfig();
22178
+ const mergedConfig = {
22179
+ ...resolvedConfig,
22180
+ ...config
22181
+ };
22182
+ return value.call(this, mergedConfig);
22183
+ }, "wrappedEndpointMethod");
22184
+ }
22185
+ });
22130
22186
  }
22131
22187
  __name(createFetchffClient, "createFetchffClient");
22132
22188
  function enhanceClientWithMethods(params) {
@@ -22211,14 +22267,33 @@ async function createApiClient(options = {}) {
22211
22267
  const effectiveConfig = getEffectiveConfig(stateContainer.current);
22212
22268
  const fetchffConfig = toFetchffConfig(effectiveConfig);
22213
22269
  let clearTemporaryOverridesFn;
22270
+ const getResolvedFetchffConfig = /* @__PURE__ */ __name(() => {
22271
+ const currentConfig = getEffectiveConfig(stateContainer.current);
22272
+ let resolvedConfig2 = { ...currentConfig };
22273
+ if (currentConfig.unifiedStrategy) {
22274
+ resolvedConfig2 = applyUnifiedStrategyToConfig(
22275
+ resolvedConfig2,
22276
+ currentConfig.unifiedStrategy
22277
+ );
22278
+ }
22279
+ resolvedConfig2 = applyIndividualStrategies(resolvedConfig2, currentConfig);
22280
+ return toFetchffConfig(resolvedConfig2);
22281
+ }, "getResolvedFetchffConfig");
22214
22282
  const unifiedHandlers = setupUnifiedHandlers({
22215
22283
  mergedConfig: effectiveConfig,
22216
22284
  enrichedHeadersConfig: options.enrichedHeaders,
22217
22285
  globalConfig,
22218
22286
  clientOptions: options,
22219
- clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides")
22287
+ clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides"),
22288
+ getResolvedFetchffConfig
22289
+ });
22290
+ const client = createFetchffClient({
22291
+ fetchffConfig,
22292
+ effectiveConfig,
22293
+ options,
22294
+ unifiedHandlers,
22295
+ getResolvedFetchffConfig
22220
22296
  });
22221
- const client = createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers);
22222
22297
  const clientWithEvents = setupClientEvents(client, globalConfig, options);
22223
22298
  const { eventManager: eventManager2 } = clientWithEvents;
22224
22299
  Object.defineProperty(clientWithEvents, "then", {
@@ -25625,15 +25700,18 @@ __name(fetchCampaignParticipants, "fetchCampaignParticipants");
25625
25700
 
25626
25701
  // src/api/services/campaigns/GET/useCampaign.ts
25627
25702
  function useCampaign(queryKey, campaignId, serviceOptions, queryOptions) {
25628
- return createApiQuery(fetchCampaign, {
25629
- // Use 'background' unified strategy for stable entity data (includes longLived cache)
25630
- // Using unifiedStrategy (lowest precedence) allows easy override via:
25631
- // - serviceOptions.apiConfig.cacheStrategy (higher precedence)
25632
- // - serviceOptions.apiConfig.unifiedStrategy (same precedence, user wins)
25633
- apiConfig: {
25634
- unifiedStrategy: "background"
25703
+ return createApiQuery(
25704
+ fetchCampaign,
25705
+ {
25706
+ // Use 'background' unified strategy for stable entity data (includes longLived cache)
25707
+ // Using unifiedStrategy (lowest precedence) allows easy override via:
25708
+ // - serviceOptions.apiConfig.cacheStrategy (higher precedence)
25709
+ // - serviceOptions.apiConfig.unifiedStrategy (same precedence, user wins)
25710
+ apiConfig: {
25711
+ unifiedStrategy: "background"
25712
+ }
25635
25713
  }
25636
- })(queryKey, campaignId, serviceOptions, queryOptions);
25714
+ )(queryKey, campaignId, serviceOptions, queryOptions);
25637
25715
  }
25638
25716
  __name(useCampaign, "useCampaign");
25639
25717
 
@@ -25815,15 +25893,15 @@ __name(updateCampaign, "updateCampaign");
25815
25893
  function useUpdateCampaign(serviceOptions, mutationOptions) {
25816
25894
  const queryClient = useQueryClient();
25817
25895
  return createApiMutation(
25818
- (params, opts) => updateCampaign(params.campaignId, params.data, opts),
25896
+ (params, opts) => updateCampaign(params.id, params.data, opts),
25819
25897
  {
25820
25898
  onSuccess: /* @__PURE__ */ __name((campaign, variables) => {
25821
- queryClient.setQueryData(["campaign", variables.campaignId], campaign);
25899
+ queryClient.setQueryData(["campaign", variables.id], campaign);
25822
25900
  void queryClient.invalidateQueries({
25823
25901
  queryKey: ["campaigns"]
25824
25902
  });
25825
25903
  void queryClient.invalidateQueries({
25826
- queryKey: ["campaign", variables.campaignId, "stats"]
25904
+ queryKey: ["campaign", variables.id, "stats"]
25827
25905
  });
25828
25906
  }, "onSuccess"),
25829
25907
  // Merge default success handler with user-provided options
@@ -26958,8 +27036,8 @@ async function uploadFile(data, options) {
26958
27036
  const client = options?.apiClient ?? getDefaultApiClient();
26959
27037
  const serviceDefaults = {
26960
27038
  unifiedStrategy: "mutation",
26961
- timeout: 6e4
26962
- // 60 seconds for uploads
27039
+ timeout: 12e4
27040
+ // 2 minutes for large uploads
26963
27041
  };
26964
27042
  const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
26965
27043
  const updateOptions = {