@plyaz/api 1.7.3 → 1.8.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.
Files changed (34) 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/endpoints/index.d.ts +9 -0
  6. package/dist/api/endpoints/index.d.ts.map +1 -1
  7. package/dist/api/endpoints/notification.d.ts +72 -0
  8. package/dist/api/endpoints/notification.d.ts.map +1 -0
  9. package/dist/api/services/index.d.ts +1 -0
  10. package/dist/api/services/index.d.ts.map +1 -1
  11. package/dist/api/services/notification/DELETE/deleteNotification.d.ts +25 -0
  12. package/dist/api/services/notification/DELETE/deleteNotification.d.ts.map +1 -0
  13. package/dist/api/services/notification/DELETE/index.d.ts +12 -0
  14. package/dist/api/services/notification/DELETE/index.d.ts.map +1 -0
  15. package/dist/api/services/notification/DELETE/useDeleteNotification.d.ts +34 -0
  16. package/dist/api/services/notification/DELETE/useDeleteNotification.d.ts.map +1 -0
  17. package/dist/api/services/notification/GET/fetchNotifications.d.ts +26 -0
  18. package/dist/api/services/notification/GET/fetchNotifications.d.ts.map +1 -0
  19. package/dist/api/services/notification/GET/index.d.ts +12 -0
  20. package/dist/api/services/notification/GET/index.d.ts.map +1 -0
  21. package/dist/api/services/notification/GET/useNotifications.d.ts +32 -0
  22. package/dist/api/services/notification/GET/useNotifications.d.ts.map +1 -0
  23. package/dist/api/services/notification/index.d.ts +14 -0
  24. package/dist/api/services/notification/index.d.ts.map +1 -0
  25. package/dist/api/strategies/unified.d.ts.map +1 -1
  26. package/dist/entry-frontend.cjs +196 -23
  27. package/dist/entry-frontend.cjs.map +1 -1
  28. package/dist/entry-frontend.mjs +192 -24
  29. package/dist/entry-frontend.mjs.map +1 -1
  30. package/dist/index.cjs +196 -23
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.mjs +192 -24
  33. package/dist/index.mjs.map +1 -1
  34. 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
@@ -14251,6 +14258,32 @@ var cdnEndpoints = {
14251
14258
  ...fastlyEndpoints
14252
14259
  };
14253
14260
 
14261
+ // src/api/endpoints/notification.ts
14262
+ var notificationEndpoints = {
14263
+ // ==========================================================================
14264
+ // GET ENDPOINTS
14265
+ // ==========================================================================
14266
+ /**
14267
+ * GET /notifications
14268
+ * List all notifications with optional filters
14269
+ */
14270
+ listNotifications: {
14271
+ url: "/notifications",
14272
+ method: "GET"
14273
+ },
14274
+ // ==========================================================================
14275
+ // DELETE ENDPOINTS
14276
+ // ==========================================================================
14277
+ /**
14278
+ * DELETE /notifications/:id
14279
+ * Delete a notification
14280
+ */
14281
+ deleteNotification: {
14282
+ url: "/notifications/:id",
14283
+ method: "DELETE"
14284
+ }
14285
+ };
14286
+
14254
14287
  // src/api/endpoints/utils.ts
14255
14288
  function getEndpointUrl(name) {
14256
14289
  return endpoints[name].url;
@@ -14435,7 +14468,8 @@ var endpoints = {
14435
14468
  // CDN provider endpoints (Cloudflare, CloudFront, Fastly)
14436
14469
  ...cloudflareEndpoints,
14437
14470
  ...cloudFrontEndpoints,
14438
- ...fastlyEndpoints
14471
+ ...fastlyEndpoints,
14472
+ ...notificationEndpoints
14439
14473
  };
14440
14474
  var isSlowConnection = fetchff.isSlowConnection;
14441
14475
  function isNetworkAPISupported() {
@@ -17255,18 +17289,19 @@ var unifiedStrategies = {
17255
17289
  },
17256
17290
  /**
17257
17291
  * Mutation: POST/PUT/DELETE operations (uploads, creates, updates, deletes)
17258
- * - NO caching (mutations should never be cached)
17259
- * - Standard retry for actual failures
17292
+ * - NO caching (cache: 'none' sets skip:true, ttl:0, stale:0 - prevents staleTime refetch!)
17293
+ * - Conservative retry (allows retry on server errors 500/502/503/504)
17260
17294
  * - NO polling (critical! - polling causes duplicate mutations)
17261
17295
  * - Realtime performance (immediate response)
17262
17296
  *
17263
- * Use this for any data-modifying operation to prevent duplicate requests.
17297
+ * Note: The retry is safe because it only triggers on actual errors (5xx).
17298
+ * The staleTime refetch issue was fixed by setting stale:0 in cache:'none'.
17264
17299
  */
17265
17300
  mutation: {
17266
17301
  cache: "none",
17267
- // Never cache mutations
17268
- retry: "none",
17269
- // No retry - mutations should not auto-retry to prevent duplicates
17302
+ // Never cache mutations (ttl:0, stale:0 prevents refetch)
17303
+ retry: "conservative",
17304
+ // Retry on server errors (500/502/503/504) only
17270
17305
  // NO polling - this is critical! Polling would re-execute the mutation
17271
17306
  performance: "realtime"
17272
17307
  // Immediate response, no batching
@@ -21550,10 +21585,28 @@ function mergeHeadersCaseInsensitive(...headerSets) {
21550
21585
  return result;
21551
21586
  }
21552
21587
  __name(mergeHeadersCaseInsensitive, "mergeHeadersCaseInsensitive");
21553
- function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfig, configStrategy) {
21588
+ function createOnRequestHandler(options) {
21589
+ const {
21590
+ handlers,
21591
+ enrichedHeadersConfig,
21592
+ encryptionConfig,
21593
+ configStrategy,
21594
+ getResolvedFetchffConfig
21595
+ } = options;
21554
21596
  return async (config) => {
21555
21597
  const performanceFactory = getPerformanceEventFactory();
21556
21598
  const requestId = errors$1.generateRequestId();
21599
+ if (getResolvedFetchffConfig) {
21600
+ const resolvedConfig = getResolvedFetchffConfig();
21601
+ config = {
21602
+ ...config,
21603
+ ...resolvedConfig,
21604
+ headers: {
21605
+ ...resolvedConfig.headers,
21606
+ ...config.headers
21607
+ }
21608
+ };
21609
+ }
21557
21610
  startRequestTracking(requestId);
21558
21611
  UnifiedDebugger.getInstance().trackConfigChange(
21559
21612
  { headers: config.headers },
@@ -21722,7 +21775,8 @@ function setupUnifiedHandlers(params) {
21722
21775
  enrichedHeadersConfig,
21723
21776
  globalConfig,
21724
21777
  clientOptions,
21725
- clearTemporaryOverrides: clearTemporaryOverrides2
21778
+ clearTemporaryOverrides: clearTemporaryOverrides2,
21779
+ getResolvedFetchffConfig
21726
21780
  } = params;
21727
21781
  const mergedOnRequest = mergeHandlers(
21728
21782
  globalConfig?.onRequest,
@@ -21748,12 +21802,13 @@ function setupUnifiedHandlers(params) {
21748
21802
  const encryptionConfig = mergedConfig.encryption ?? globalConfig?.encryption ?? clientOptions?.encryption;
21749
21803
  const configStrategy = mergedConfig.configOverride?.strategy ?? clientOptions?.configOverride?.strategy ?? globalConfig?.configOverride?.strategy ?? "merge";
21750
21804
  return {
21751
- onRequest: createOnRequestHandler(
21752
- mergedOnRequest,
21805
+ onRequest: createOnRequestHandler({
21806
+ handlers: mergedOnRequest,
21753
21807
  enrichedHeadersConfig,
21754
21808
  encryptionConfig,
21755
- configStrategy
21756
- ),
21809
+ configStrategy,
21810
+ getResolvedFetchffConfig
21811
+ }),
21757
21812
  onResponse: createOnResponseHandler(
21758
21813
  mergedOnResponse,
21759
21814
  clearTemporaryOverrides2,
@@ -22108,15 +22163,21 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22108
22163
  const validation = validateConfigUpdate(updates, updateOptions);
22109
22164
  if (!validation.valid) {
22110
22165
  handleInvalidConfigUpdate(validation, updates, updateOptions);
22111
- return;
22166
+ return { fetchffConfig: {}, applied: false };
22112
22167
  }
22113
22168
  const result = applyConfigUpdate(configState, updates, updateOptions);
22114
22169
  configState = result.state;
22115
22170
  setConfigState(configState);
22116
22171
  const newConfig = getEffectiveConfig(configState);
22172
+ let resolvedUpdates = { ...updates };
22173
+ if (updates.unifiedStrategy) {
22174
+ resolvedUpdates = applyUnifiedStrategyToConfig(resolvedUpdates, updates.unifiedStrategy);
22175
+ }
22176
+ resolvedUpdates = applyIndividualStrategies(resolvedUpdates, updates);
22177
+ const fetchffConfig = toFetchffConfig(resolvedUpdates);
22117
22178
  if (client && "__config" in client) {
22118
22179
  const fetchffClient = client;
22119
- Object.assign(fetchffClient["__config"], updates);
22180
+ Object.assign(fetchffClient["__config"], fetchffConfig);
22120
22181
  }
22121
22182
  eventManager2.updateConfig(updates, updateOptions ?? {});
22122
22183
  const afterEventState = captureEventState(eventManager2);
@@ -22130,11 +22191,13 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
22130
22191
  validation,
22131
22192
  startTime
22132
22193
  });
22194
+ return { fetchffConfig, applied: true };
22133
22195
  };
22134
22196
  }
22135
22197
  __name(createUpdateConfigMethod, "createUpdateConfigMethod");
22136
- function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers) {
22137
- return fetchff.createApiFetcher({
22198
+ function createFetchffClient(params) {
22199
+ const { fetchffConfig, effectiveConfig, options, unifiedHandlers, getResolvedFetchffConfig } = params;
22200
+ const rawClient = fetchff.createApiFetcher({
22138
22201
  ...fetchffConfig,
22139
22202
  baseURL: effectiveConfig.baseURL ?? options.apiUrl,
22140
22203
  endpoints,
@@ -22143,6 +22206,26 @@ function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHan
22143
22206
  onError: unifiedHandlers.onError,
22144
22207
  onRetry: unifiedHandlers.onRetry
22145
22208
  });
22209
+ const endpointMethodNames = new Set(Object.keys(endpoints));
22210
+ return new Proxy(rawClient, {
22211
+ get(target, prop, receiver) {
22212
+ const value = Reflect.get(target, prop, receiver);
22213
+ if (typeof value !== "function" || typeof prop !== "string") {
22214
+ return value;
22215
+ }
22216
+ if (!endpointMethodNames.has(prop)) {
22217
+ return value;
22218
+ }
22219
+ return /* @__PURE__ */ __name(function wrappedEndpointMethod(config) {
22220
+ const resolvedConfig = getResolvedFetchffConfig();
22221
+ const mergedConfig = {
22222
+ ...resolvedConfig,
22223
+ ...config
22224
+ };
22225
+ return value.call(this, mergedConfig);
22226
+ }, "wrappedEndpointMethod");
22227
+ }
22228
+ });
22146
22229
  }
22147
22230
  __name(createFetchffClient, "createFetchffClient");
22148
22231
  function enhanceClientWithMethods(params) {
@@ -22227,14 +22310,33 @@ async function createApiClient(options = {}) {
22227
22310
  const effectiveConfig = getEffectiveConfig(stateContainer.current);
22228
22311
  const fetchffConfig = toFetchffConfig(effectiveConfig);
22229
22312
  let clearTemporaryOverridesFn;
22313
+ const getResolvedFetchffConfig = /* @__PURE__ */ __name(() => {
22314
+ const currentConfig = getEffectiveConfig(stateContainer.current);
22315
+ let resolvedConfig2 = { ...currentConfig };
22316
+ if (currentConfig.unifiedStrategy) {
22317
+ resolvedConfig2 = applyUnifiedStrategyToConfig(
22318
+ resolvedConfig2,
22319
+ currentConfig.unifiedStrategy
22320
+ );
22321
+ }
22322
+ resolvedConfig2 = applyIndividualStrategies(resolvedConfig2, currentConfig);
22323
+ return toFetchffConfig(resolvedConfig2);
22324
+ }, "getResolvedFetchffConfig");
22230
22325
  const unifiedHandlers = setupUnifiedHandlers({
22231
22326
  mergedConfig: effectiveConfig,
22232
22327
  enrichedHeadersConfig: options.enrichedHeaders,
22233
22328
  globalConfig,
22234
22329
  clientOptions: options,
22235
- clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides")
22330
+ clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides"),
22331
+ getResolvedFetchffConfig
22332
+ });
22333
+ const client = createFetchffClient({
22334
+ fetchffConfig,
22335
+ effectiveConfig,
22336
+ options,
22337
+ unifiedHandlers,
22338
+ getResolvedFetchffConfig
22236
22339
  });
22237
- const client = createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers);
22238
22340
  const clientWithEvents = setupClientEvents(client, globalConfig, options);
22239
22341
  const { eventManager: eventManager2 } = clientWithEvents;
22240
22342
  Object.defineProperty(clientWithEvents, "then", {
@@ -26977,8 +27079,8 @@ async function uploadFile(data, options) {
26977
27079
  const client = options?.apiClient ?? getDefaultApiClient();
26978
27080
  const serviceDefaults = {
26979
27081
  unifiedStrategy: "mutation",
26980
- timeout: 6e4
26981
- // 60 seconds for uploads
27082
+ timeout: 12e4
27083
+ // 2 minutes for large uploads
26982
27084
  };
26983
27085
  const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
26984
27086
  const updateOptions = {
@@ -27112,6 +27214,72 @@ function useDeleteFile(serviceOptions, mutationOptions) {
27112
27214
  })(serviceOptions, mutationOptions);
27113
27215
  }
27114
27216
  __name(useDeleteFile, "useDeleteFile");
27217
+
27218
+ // src/api/services/notification/GET/fetchNotifications.ts
27219
+ async function fetchNotifications(filters, options) {
27220
+ const client = options?.apiClient ?? getDefaultApiClient();
27221
+ const serviceDefaults = { unifiedStrategy: "interactive" };
27222
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
27223
+ const updateOptions = {
27224
+ strategy: "temporary",
27225
+ ...options?.updateConfigOptions
27226
+ };
27227
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
27228
+ client.updateConfig(mergedConfig, updateOptions);
27229
+ }
27230
+ return client.listNotifications({
27231
+ params: filters
27232
+ });
27233
+ }
27234
+ __name(fetchNotifications, "fetchNotifications");
27235
+ function useNotifications(queryKey, filters, serviceOptions, queryOptions) {
27236
+ return createApiQuery(fetchNotifications, {
27237
+ apiConfig: {
27238
+ unifiedStrategy: "interactive"
27239
+ },
27240
+ staleTime: config.TIME_CONSTANTS.TEN_MINUTES
27241
+ })(queryKey, filters, serviceOptions, queryOptions);
27242
+ }
27243
+ __name(useNotifications, "useNotifications");
27244
+
27245
+ // src/api/services/notification/DELETE/deleteNotification.ts
27246
+ async function deleteNotification(id, options) {
27247
+ const client = options?.apiClient ?? getDefaultApiClient();
27248
+ const serviceDefaults = {
27249
+ unifiedStrategy: "mutation"
27250
+ };
27251
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
27252
+ const updateOptions = {
27253
+ strategy: "temporary",
27254
+ ...options?.updateConfigOptions
27255
+ };
27256
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
27257
+ client.updateConfig(mergedConfig, updateOptions);
27258
+ }
27259
+ const pathParams = { id };
27260
+ return client.deleteNotification({
27261
+ urlPathParams: pathParams
27262
+ });
27263
+ }
27264
+ __name(deleteNotification, "deleteNotification");
27265
+ function useDeleteNotification(serviceOptions, mutationOptions) {
27266
+ const queryClient = reactQuery.useQueryClient();
27267
+ return createApiMutation(
27268
+ deleteNotification,
27269
+ {
27270
+ onSuccess: /* @__PURE__ */ __name((_data, id) => {
27271
+ void queryClient.invalidateQueries({
27272
+ queryKey: ["notifications"]
27273
+ });
27274
+ queryClient.removeQueries({
27275
+ queryKey: ["notification", id]
27276
+ });
27277
+ }, "onSuccess"),
27278
+ ...mutationOptions
27279
+ }
27280
+ )(serviceOptions, mutationOptions);
27281
+ }
27282
+ __name(useDeleteNotification, "useDeleteNotification");
27115
27283
  function getSSRSafeConfig(config) {
27116
27284
  if (!isBrowser()) {
27117
27285
  return {
@@ -27681,6 +27849,7 @@ exports.deleteCache = deleteCache;
27681
27849
  exports.deleteCampaign = deleteCampaign;
27682
27850
  exports.deleteFeatureFlag = deleteFeatureFlag;
27683
27851
  exports.deleteFile = deleteFile;
27852
+ exports.deleteNotification = deleteNotification;
27684
27853
  exports.detectConfigConflicts = detectConfigConflicts;
27685
27854
  exports.detectConflicts = detectConflicts;
27686
27855
  exports.detectPlatform = detectPlatform;
@@ -27715,6 +27884,7 @@ exports.fetchInfobipEmailReports = fetchInfobipEmailReports;
27715
27884
  exports.fetchInfobipScheduledEmailStatuses = fetchInfobipScheduledEmailStatuses;
27716
27885
  exports.fetchInfobipScheduledEmails = fetchInfobipScheduledEmails;
27717
27886
  exports.fetchInfobipValidations = fetchInfobipValidations;
27887
+ exports.fetchNotifications = fetchNotifications;
27718
27888
  exports.filesEndpoints = filesEndpoints;
27719
27889
  exports.filterHistory = filterHistory;
27720
27890
  exports.filterObject = filterObject;
@@ -27971,6 +28141,7 @@ exports.networkDetectionMiddleware = networkDetectionMiddleware;
27971
28141
  exports.networkPresets = networkPresets;
27972
28142
  exports.networkStatus = networkStatus;
27973
28143
  exports.normalizeHeaders = normalizeHeaders2;
28144
+ exports.notificationEndpoints = notificationEndpoints;
27974
28145
  exports.now = now;
27975
28146
  exports.nowInSeconds = nowInSeconds;
27976
28147
  exports.omit = omit;
@@ -28097,6 +28268,7 @@ exports.useDebouncedSubscription = useDebouncedSubscription;
28097
28268
  exports.useDeleteCampaign = useDeleteCampaign;
28098
28269
  exports.useDeleteFeatureFlag = useDeleteFeatureFlag;
28099
28270
  exports.useDeleteFile = useDeleteFile;
28271
+ exports.useDeleteNotification = useDeleteNotification;
28100
28272
  exports.useDownloadFile = useDownloadFile;
28101
28273
  exports.useEvaluateAllFeatureFlags = useEvaluateAllFeatureFlags;
28102
28274
  exports.useGenerateDocument = useGenerateDocument;
@@ -28105,6 +28277,7 @@ exports.useGetSignedUrl = useGetSignedUrl;
28105
28277
  exports.useJoinCampaign = useJoinCampaign;
28106
28278
  exports.useLeaveCampaign = useLeaveCampaign;
28107
28279
  exports.useMultipleSubscriptions = useMultipleSubscriptions;
28280
+ exports.useNotifications = useNotifications;
28108
28281
  exports.useOptimisticUpdate = useOptimisticUpdate;
28109
28282
  exports.useRealTimeData = useRealTimeData;
28110
28283
  exports.useRemoveFeatureFlagOverride = useRemoveFeatureFlagOverride;