@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.cjs CHANGED
@@ -12867,10 +12867,17 @@ __name(createStatusCodeLimits, "createStatusCodeLimits");
12867
12867
  var cacheStrategies = {
12868
12868
  /**
12869
12869
  * No caching - always fetch fresh data
12870
- * Use for: Real-time data, sensitive information
12870
+ * Use for: Real-time data, sensitive information, mutations
12871
+ *
12872
+ * IMPORTANT: Explicit ttl/stale of 0 prevents staleTime refetch issues.
12873
+ * The skip:true alone doesn't prevent default staleTime from being applied.
12871
12874
  */
12872
12875
  none: {
12873
- skip: true
12876
+ skip: true,
12877
+ ttl: 0,
12878
+ // No caching
12879
+ stale: 0
12880
+ // No stale refetch (prevents 60s re-trigger issue)
12874
12881
  },
12875
12882
  /**
12876
12883
  * Short-lived cache for frequently changing data
@@ -17255,18 +17262,19 @@ var unifiedStrategies = {
17255
17262
  },
17256
17263
  /**
17257
17264
  * Mutation: POST/PUT/DELETE operations (uploads, creates, updates, deletes)
17258
- * - NO caching (mutations should never be cached)
17259
- * - Standard retry for actual failures
17265
+ * - NO caching (cache: 'none' sets skip:true, ttl:0, stale:0 - prevents staleTime refetch!)
17266
+ * - Conservative retry (allows retry on server errors 500/502/503/504)
17260
17267
  * - NO polling (critical! - polling causes duplicate mutations)
17261
17268
  * - Realtime performance (immediate response)
17262
17269
  *
17263
- * Use this for any data-modifying operation to prevent duplicate requests.
17270
+ * Note: The retry is safe because it only triggers on actual errors (5xx).
17271
+ * The staleTime refetch issue was fixed by setting stale:0 in cache:'none'.
17264
17272
  */
17265
17273
  mutation: {
17266
17274
  cache: "none",
17267
- // Never cache mutations
17268
- retry: "standard",
17269
- // Standard retry for actual failures (not successes)
17275
+ // Never cache mutations (ttl:0, stale:0 prevents refetch)
17276
+ retry: "conservative",
17277
+ // Retry on server errors (500/502/503/504) only
17270
17278
  // NO polling - this is critical! Polling would re-execute the mutation
17271
17279
  performance: "realtime"
17272
17280
  // Immediate response, no batching
@@ -21550,10 +21558,28 @@ function mergeHeadersCaseInsensitive(...headerSets) {
21550
21558
  return result;
21551
21559
  }
21552
21560
  __name(mergeHeadersCaseInsensitive, "mergeHeadersCaseInsensitive");
21553
- function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfig, configStrategy) {
21561
+ function createOnRequestHandler(options) {
21562
+ const {
21563
+ handlers,
21564
+ enrichedHeadersConfig,
21565
+ encryptionConfig,
21566
+ configStrategy,
21567
+ getResolvedFetchffConfig
21568
+ } = options;
21554
21569
  return async (config) => {
21555
21570
  const performanceFactory = getPerformanceEventFactory();
21556
21571
  const requestId = errors$1.generateRequestId();
21572
+ if (getResolvedFetchffConfig) {
21573
+ const resolvedConfig = getResolvedFetchffConfig();
21574
+ config = {
21575
+ ...config,
21576
+ ...resolvedConfig,
21577
+ headers: {
21578
+ ...resolvedConfig.headers,
21579
+ ...config.headers
21580
+ }
21581
+ };
21582
+ }
21557
21583
  startRequestTracking(requestId);
21558
21584
  UnifiedDebugger.getInstance().trackConfigChange(
21559
21585
  { headers: config.headers },
@@ -21722,7 +21748,8 @@ function setupUnifiedHandlers(params) {
21722
21748
  enrichedHeadersConfig,
21723
21749
  globalConfig,
21724
21750
  clientOptions,
21725
- clearTemporaryOverrides: clearTemporaryOverrides2
21751
+ clearTemporaryOverrides: clearTemporaryOverrides2,
21752
+ getResolvedFetchffConfig
21726
21753
  } = params;
21727
21754
  const mergedOnRequest = mergeHandlers(
21728
21755
  globalConfig?.onRequest,
@@ -21748,12 +21775,13 @@ function setupUnifiedHandlers(params) {
21748
21775
  const encryptionConfig = mergedConfig.encryption ?? globalConfig?.encryption ?? clientOptions?.encryption;
21749
21776
  const configStrategy = mergedConfig.configOverride?.strategy ?? clientOptions?.configOverride?.strategy ?? globalConfig?.configOverride?.strategy ?? "merge";
21750
21777
  return {
21751
- onRequest: createOnRequestHandler(
21752
- mergedOnRequest,
21778
+ onRequest: createOnRequestHandler({
21779
+ handlers: mergedOnRequest,
21753
21780
  enrichedHeadersConfig,
21754
21781
  encryptionConfig,
21755
- configStrategy
21756
- ),
21782
+ configStrategy,
21783
+ getResolvedFetchffConfig
21784
+ }),
21757
21785
  onResponse: createOnResponseHandler(
21758
21786
  mergedOnResponse,
21759
21787
  clearTemporaryOverrides2,
@@ -22108,15 +22136,21 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22108
22136
  const validation = validateConfigUpdate(updates, updateOptions);
22109
22137
  if (!validation.valid) {
22110
22138
  handleInvalidConfigUpdate(validation, updates, updateOptions);
22111
- return;
22139
+ return { fetchffConfig: {}, applied: false };
22112
22140
  }
22113
22141
  const result = applyConfigUpdate(configState, updates, updateOptions);
22114
22142
  configState = result.state;
22115
22143
  setConfigState(configState);
22116
22144
  const newConfig = getEffectiveConfig(configState);
22145
+ let resolvedUpdates = { ...updates };
22146
+ if (updates.unifiedStrategy) {
22147
+ resolvedUpdates = applyUnifiedStrategyToConfig(resolvedUpdates, updates.unifiedStrategy);
22148
+ }
22149
+ resolvedUpdates = applyIndividualStrategies(resolvedUpdates, updates);
22150
+ const fetchffConfig = toFetchffConfig(resolvedUpdates);
22117
22151
  if (client && "__config" in client) {
22118
22152
  const fetchffClient = client;
22119
- Object.assign(fetchffClient["__config"], updates);
22153
+ Object.assign(fetchffClient["__config"], fetchffConfig);
22120
22154
  }
22121
22155
  eventManager2.updateConfig(updates, updateOptions ?? {});
22122
22156
  const afterEventState = captureEventState(eventManager2);
@@ -22130,11 +22164,13 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22130
22164
  validation,
22131
22165
  startTime
22132
22166
  });
22167
+ return { fetchffConfig, applied: true };
22133
22168
  };
22134
22169
  }
22135
22170
  __name(createUpdateConfigMethod, "createUpdateConfigMethod");
22136
- function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers) {
22137
- return fetchff.createApiFetcher({
22171
+ function createFetchffClient(params) {
22172
+ const { fetchffConfig, effectiveConfig, options, unifiedHandlers, getResolvedFetchffConfig } = params;
22173
+ const rawClient = fetchff.createApiFetcher({
22138
22174
  ...fetchffConfig,
22139
22175
  baseURL: effectiveConfig.baseURL ?? options.apiUrl,
22140
22176
  endpoints,
@@ -22143,6 +22179,26 @@ function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHan
22143
22179
  onError: unifiedHandlers.onError,
22144
22180
  onRetry: unifiedHandlers.onRetry
22145
22181
  });
22182
+ const endpointMethodNames = new Set(Object.keys(endpoints));
22183
+ return new Proxy(rawClient, {
22184
+ get(target, prop, receiver) {
22185
+ const value = Reflect.get(target, prop, receiver);
22186
+ if (typeof value !== "function" || typeof prop !== "string") {
22187
+ return value;
22188
+ }
22189
+ if (!endpointMethodNames.has(prop)) {
22190
+ return value;
22191
+ }
22192
+ return /* @__PURE__ */ __name(function wrappedEndpointMethod(config) {
22193
+ const resolvedConfig = getResolvedFetchffConfig();
22194
+ const mergedConfig = {
22195
+ ...resolvedConfig,
22196
+ ...config
22197
+ };
22198
+ return value.call(this, mergedConfig);
22199
+ }, "wrappedEndpointMethod");
22200
+ }
22201
+ });
22146
22202
  }
22147
22203
  __name(createFetchffClient, "createFetchffClient");
22148
22204
  function enhanceClientWithMethods(params) {
@@ -22227,14 +22283,33 @@ async function createApiClient(options = {}) {
22227
22283
  const effectiveConfig = getEffectiveConfig(stateContainer.current);
22228
22284
  const fetchffConfig = toFetchffConfig(effectiveConfig);
22229
22285
  let clearTemporaryOverridesFn;
22286
+ const getResolvedFetchffConfig = /* @__PURE__ */ __name(() => {
22287
+ const currentConfig = getEffectiveConfig(stateContainer.current);
22288
+ let resolvedConfig2 = { ...currentConfig };
22289
+ if (currentConfig.unifiedStrategy) {
22290
+ resolvedConfig2 = applyUnifiedStrategyToConfig(
22291
+ resolvedConfig2,
22292
+ currentConfig.unifiedStrategy
22293
+ );
22294
+ }
22295
+ resolvedConfig2 = applyIndividualStrategies(resolvedConfig2, currentConfig);
22296
+ return toFetchffConfig(resolvedConfig2);
22297
+ }, "getResolvedFetchffConfig");
22230
22298
  const unifiedHandlers = setupUnifiedHandlers({
22231
22299
  mergedConfig: effectiveConfig,
22232
22300
  enrichedHeadersConfig: options.enrichedHeaders,
22233
22301
  globalConfig,
22234
22302
  clientOptions: options,
22235
- clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides")
22303
+ clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides"),
22304
+ getResolvedFetchffConfig
22305
+ });
22306
+ const client = createFetchffClient({
22307
+ fetchffConfig,
22308
+ effectiveConfig,
22309
+ options,
22310
+ unifiedHandlers,
22311
+ getResolvedFetchffConfig
22236
22312
  });
22237
- const client = createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers);
22238
22313
  const clientWithEvents = setupClientEvents(client, globalConfig, options);
22239
22314
  const { eventManager: eventManager2 } = clientWithEvents;
22240
22315
  Object.defineProperty(clientWithEvents, "then", {
@@ -25641,15 +25716,18 @@ __name(fetchCampaignParticipants, "fetchCampaignParticipants");
25641
25716
 
25642
25717
  // src/api/services/campaigns/GET/useCampaign.ts
25643
25718
  function useCampaign(queryKey, campaignId, serviceOptions, queryOptions) {
25644
- return createApiQuery(fetchCampaign, {
25645
- // Use 'background' unified strategy for stable entity data (includes longLived cache)
25646
- // Using unifiedStrategy (lowest precedence) allows easy override via:
25647
- // - serviceOptions.apiConfig.cacheStrategy (higher precedence)
25648
- // - serviceOptions.apiConfig.unifiedStrategy (same precedence, user wins)
25649
- apiConfig: {
25650
- unifiedStrategy: "background"
25719
+ return createApiQuery(
25720
+ fetchCampaign,
25721
+ {
25722
+ // Use 'background' unified strategy for stable entity data (includes longLived cache)
25723
+ // Using unifiedStrategy (lowest precedence) allows easy override via:
25724
+ // - serviceOptions.apiConfig.cacheStrategy (higher precedence)
25725
+ // - serviceOptions.apiConfig.unifiedStrategy (same precedence, user wins)
25726
+ apiConfig: {
25727
+ unifiedStrategy: "background"
25728
+ }
25651
25729
  }
25652
- })(queryKey, campaignId, serviceOptions, queryOptions);
25730
+ )(queryKey, campaignId, serviceOptions, queryOptions);
25653
25731
  }
25654
25732
  __name(useCampaign, "useCampaign");
25655
25733
 
@@ -25831,15 +25909,15 @@ __name(updateCampaign, "updateCampaign");
25831
25909
  function useUpdateCampaign(serviceOptions, mutationOptions) {
25832
25910
  const queryClient = reactQuery.useQueryClient();
25833
25911
  return createApiMutation(
25834
- (params, opts) => updateCampaign(params.campaignId, params.data, opts),
25912
+ (params, opts) => updateCampaign(params.id, params.data, opts),
25835
25913
  {
25836
25914
  onSuccess: /* @__PURE__ */ __name((campaign, variables) => {
25837
- queryClient.setQueryData(["campaign", variables.campaignId], campaign);
25915
+ queryClient.setQueryData(["campaign", variables.id], campaign);
25838
25916
  void queryClient.invalidateQueries({
25839
25917
  queryKey: ["campaigns"]
25840
25918
  });
25841
25919
  void queryClient.invalidateQueries({
25842
- queryKey: ["campaign", variables.campaignId, "stats"]
25920
+ queryKey: ["campaign", variables.id, "stats"]
25843
25921
  });
25844
25922
  }, "onSuccess"),
25845
25923
  // Merge default success handler with user-provided options
@@ -26974,8 +27052,8 @@ async function uploadFile(data, options) {
26974
27052
  const client = options?.apiClient ?? getDefaultApiClient();
26975
27053
  const serviceDefaults = {
26976
27054
  unifiedStrategy: "mutation",
26977
- timeout: 6e4
26978
- // 60 seconds for uploads
27055
+ timeout: 12e4
27056
+ // 2 minutes for large uploads
26979
27057
  };
26980
27058
  const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
26981
27059
  const updateOptions = {