@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.
- package/dist/api/cache/strategies.d.ts.map +1 -1
- package/dist/api/client/createApiClient.d.ts.map +1 -1
- package/dist/api/client/helpers/interceptors.d.ts +2 -2
- package/dist/api/client/helpers/interceptors.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts +2 -2
- package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaign.d.ts +2 -2
- package/dist/api/services/campaigns/GET/useCampaign.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts +2 -2
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts.map +1 -1
- package/dist/api/services/campaigns/POST/createCampaign.d.ts +2 -2
- package/dist/api/services/campaigns/POST/createCampaign.d.ts.map +1 -1
- package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts +2 -2
- package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts.map +1 -1
- package/dist/api/services/campaigns/PUT/updateCampaign.d.ts +2 -2
- package/dist/api/services/campaigns/PUT/updateCampaign.d.ts.map +1 -1
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts +2 -2
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts.map +1 -1
- package/dist/api/strategies/unified.d.ts.map +1 -1
- package/dist/entry-frontend.cjs +111 -33
- package/dist/entry-frontend.cjs.map +1 -1
- package/dist/entry-frontend.mjs +111 -33
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/index.cjs +111 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +111 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/entry-frontend.mjs
CHANGED
|
@@ -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 (
|
|
17232
|
-
* -
|
|
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
|
-
*
|
|
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: "
|
|
17242
|
-
//
|
|
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(
|
|
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"],
|
|
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(
|
|
22110
|
-
|
|
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", {
|
|
@@ -22424,15 +22499,18 @@ __name(createApiMutation, "createApiMutation");
|
|
|
22424
22499
|
|
|
22425
22500
|
// src/api/services/campaigns/GET/useCampaign.ts
|
|
22426
22501
|
function useCampaign(queryKey, campaignId, serviceOptions, queryOptions) {
|
|
22427
|
-
return createApiQuery(
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
unifiedStrategy
|
|
22502
|
+
return createApiQuery(
|
|
22503
|
+
fetchCampaign,
|
|
22504
|
+
{
|
|
22505
|
+
// Use 'background' unified strategy for stable entity data (includes longLived cache)
|
|
22506
|
+
// Using unifiedStrategy (lowest precedence) allows easy override via:
|
|
22507
|
+
// - serviceOptions.apiConfig.cacheStrategy (higher precedence)
|
|
22508
|
+
// - serviceOptions.apiConfig.unifiedStrategy (same precedence, user wins)
|
|
22509
|
+
apiConfig: {
|
|
22510
|
+
unifiedStrategy: "background"
|
|
22511
|
+
}
|
|
22434
22512
|
}
|
|
22435
|
-
|
|
22513
|
+
)(queryKey, campaignId, serviceOptions, queryOptions);
|
|
22436
22514
|
}
|
|
22437
22515
|
__name(useCampaign, "useCampaign");
|
|
22438
22516
|
|
|
@@ -22614,15 +22692,15 @@ __name(updateCampaign, "updateCampaign");
|
|
|
22614
22692
|
function useUpdateCampaign(serviceOptions, mutationOptions) {
|
|
22615
22693
|
const queryClient = useQueryClient();
|
|
22616
22694
|
return createApiMutation(
|
|
22617
|
-
(params, opts) => updateCampaign(params.
|
|
22695
|
+
(params, opts) => updateCampaign(params.id, params.data, opts),
|
|
22618
22696
|
{
|
|
22619
22697
|
onSuccess: /* @__PURE__ */ __name((campaign, variables) => {
|
|
22620
|
-
queryClient.setQueryData(["campaign", variables.
|
|
22698
|
+
queryClient.setQueryData(["campaign", variables.id], campaign);
|
|
22621
22699
|
void queryClient.invalidateQueries({
|
|
22622
22700
|
queryKey: ["campaigns"]
|
|
22623
22701
|
});
|
|
22624
22702
|
void queryClient.invalidateQueries({
|
|
22625
|
-
queryKey: ["campaign", variables.
|
|
22703
|
+
queryKey: ["campaign", variables.id, "stats"]
|
|
22626
22704
|
});
|
|
22627
22705
|
}, "onSuccess"),
|
|
22628
22706
|
// Merge default success handler with user-provided options
|
|
@@ -23757,8 +23835,8 @@ async function uploadFile(data, options) {
|
|
|
23757
23835
|
const client = options?.apiClient ?? getDefaultApiClient();
|
|
23758
23836
|
const serviceDefaults = {
|
|
23759
23837
|
unifiedStrategy: "mutation",
|
|
23760
|
-
timeout:
|
|
23761
|
-
//
|
|
23838
|
+
timeout: 12e4
|
|
23839
|
+
// 2 minutes for large uploads
|
|
23762
23840
|
};
|
|
23763
23841
|
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
23764
23842
|
const updateOptions = {
|