@plyaz/api 1.0.2 → 1.1.1

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 (380) hide show
  1. package/README.md +632 -542
  2. package/dist/api/cache/index.d.ts +183 -0
  3. package/dist/api/cache/index.d.ts.map +1 -0
  4. package/dist/api/cache/patterns.d.ts +174 -0
  5. package/dist/api/cache/patterns.d.ts.map +1 -0
  6. package/dist/api/cache/strategies.d.ts +47 -0
  7. package/dist/api/cache/strategies.d.ts.map +1 -0
  8. package/dist/api/client/clientEventManager.d.ts +238 -0
  9. package/dist/api/client/clientEventManager.d.ts.map +1 -0
  10. package/dist/api/client/createApiClient.d.ts +5 -0
  11. package/dist/api/client/createApiClient.d.ts.map +1 -0
  12. package/dist/api/client/helpers/headers.d.ts +11 -0
  13. package/dist/api/client/helpers/headers.d.ts.map +1 -0
  14. package/dist/api/client/helpers/index.d.ts +9 -0
  15. package/dist/api/client/helpers/index.d.ts.map +1 -0
  16. package/dist/api/client/helpers/interceptors.d.ts +29 -0
  17. package/dist/api/client/helpers/interceptors.d.ts.map +1 -0
  18. package/dist/api/client/helpers/network.d.ts +21 -0
  19. package/dist/api/client/helpers/network.d.ts.map +1 -0
  20. package/dist/api/client/helpers/strategies.d.ts +30 -0
  21. package/dist/api/client/helpers/strategies.d.ts.map +1 -0
  22. package/dist/api/client/helpers/tracking.d.ts +15 -0
  23. package/dist/api/client/helpers/tracking.d.ts.map +1 -0
  24. package/dist/api/client/index.d.ts +7 -0
  25. package/dist/api/client/index.d.ts.map +1 -0
  26. package/dist/api/config/adapter.d.ts +25 -0
  27. package/dist/api/config/adapter.d.ts.map +1 -0
  28. package/dist/api/config/configBuilder.d.ts +62 -0
  29. package/dist/api/config/configBuilder.d.ts.map +1 -0
  30. package/dist/api/config/configManager.d.ts +67 -0
  31. package/dist/api/config/configManager.d.ts.map +1 -0
  32. package/dist/api/config/global.d.ts +106 -0
  33. package/dist/api/config/global.d.ts.map +1 -0
  34. package/dist/api/config/index.d.ts +11 -0
  35. package/dist/api/config/index.d.ts.map +1 -0
  36. package/dist/api/debugger/DebugReport.d.ts +71 -0
  37. package/dist/api/debugger/DebugReport.d.ts.map +1 -0
  38. package/dist/api/debugger/UnifiedDebugger.d.ts +444 -0
  39. package/dist/api/debugger/UnifiedDebugger.d.ts.map +1 -0
  40. package/dist/api/debugger/factories/conflict.d.ts +58 -0
  41. package/dist/api/debugger/factories/conflict.d.ts.map +1 -0
  42. package/dist/api/debugger/factories/eventTracking.d.ts +126 -0
  43. package/dist/api/debugger/factories/eventTracking.d.ts.map +1 -0
  44. package/dist/api/debugger/factories/history.d.ts +97 -0
  45. package/dist/api/debugger/factories/history.d.ts.map +1 -0
  46. package/dist/api/debugger/factories/index.d.ts +15 -0
  47. package/dist/api/debugger/factories/index.d.ts.map +1 -0
  48. package/dist/api/debugger/factories/issueAnalysis.d.ts +52 -0
  49. package/dist/api/debugger/factories/issueAnalysis.d.ts.map +1 -0
  50. package/dist/api/debugger/factories/performance.d.ts +53 -0
  51. package/dist/api/debugger/factories/performance.d.ts.map +1 -0
  52. package/dist/api/debugger/factories/report.d.ts +43 -0
  53. package/dist/api/debugger/factories/report.d.ts.map +1 -0
  54. package/dist/api/debugger/index.d.ts +99 -0
  55. package/dist/api/debugger/index.d.ts.map +1 -0
  56. package/dist/api/debugger/queue/DebuggerQueueManager.d.ts +61 -0
  57. package/dist/api/debugger/queue/DebuggerQueueManager.d.ts.map +1 -0
  58. package/dist/api/debugger/queue/OperationTracker.d.ts +86 -0
  59. package/dist/api/debugger/queue/OperationTracker.d.ts.map +1 -0
  60. package/dist/api/debugger/queue/index.d.ts +9 -0
  61. package/dist/api/debugger/queue/index.d.ts.map +1 -0
  62. package/dist/api/endpoints/builders.d.ts +109 -0
  63. package/dist/api/endpoints/builders.d.ts.map +1 -0
  64. package/dist/api/endpoints/campaigns.d.ts +43 -0
  65. package/dist/api/endpoints/campaigns.d.ts.map +1 -0
  66. package/dist/api/endpoints/index.d.ts +100 -0
  67. package/dist/api/endpoints/index.d.ts.map +1 -0
  68. package/dist/api/endpoints/polling.d.ts +83 -0
  69. package/dist/api/endpoints/polling.d.ts.map +1 -0
  70. package/dist/api/endpoints/utils.d.ts +128 -0
  71. package/dist/api/endpoints/utils.d.ts.map +1 -0
  72. package/dist/api/errors/ApiPackageError.d.ts +101 -0
  73. package/dist/api/errors/ApiPackageError.d.ts.map +1 -0
  74. package/dist/api/errors/definitions.d.ts +24 -0
  75. package/dist/api/errors/definitions.d.ts.map +1 -0
  76. package/dist/api/errors/error-codes.d.ts +116 -0
  77. package/dist/api/errors/error-codes.d.ts.map +1 -0
  78. package/dist/api/errors/error-events.d.ts +63 -0
  79. package/dist/api/errors/error-events.d.ts.map +1 -0
  80. package/dist/api/errors/index.d.ts +18 -0
  81. package/dist/api/errors/index.d.ts.map +1 -0
  82. package/dist/api/errors/types-constants.d.ts +64 -0
  83. package/dist/api/errors/types-constants.d.ts.map +1 -0
  84. package/dist/api/events/EventManager.d.ts +230 -0
  85. package/dist/api/events/EventManager.d.ts.map +1 -0
  86. package/dist/api/events/factories/base.d.ts +269 -0
  87. package/dist/api/events/factories/base.d.ts.map +1 -0
  88. package/dist/api/events/factories/cache.d.ts +31 -0
  89. package/dist/api/events/factories/cache.d.ts.map +1 -0
  90. package/dist/api/events/factories/client.d.ts +43 -0
  91. package/dist/api/events/factories/client.d.ts.map +1 -0
  92. package/dist/api/events/factories/config.d.ts +34 -0
  93. package/dist/api/events/factories/config.d.ts.map +1 -0
  94. package/dist/api/events/factories/debug.d.ts +74 -0
  95. package/dist/api/events/factories/debug.d.ts.map +1 -0
  96. package/dist/api/events/factories/errors.d.ts +91 -0
  97. package/dist/api/events/factories/errors.d.ts.map +1 -0
  98. package/dist/api/events/factories/headers.d.ts +54 -0
  99. package/dist/api/events/factories/headers.d.ts.map +1 -0
  100. package/dist/api/events/factories/index.d.ts +46 -0
  101. package/dist/api/events/factories/index.d.ts.map +1 -0
  102. package/dist/api/events/factories/network.d.ts +54 -0
  103. package/dist/api/events/factories/network.d.ts.map +1 -0
  104. package/dist/api/events/factories/performance.d.ts +43 -0
  105. package/dist/api/events/factories/performance.d.ts.map +1 -0
  106. package/dist/api/events/index.d.ts +34 -0
  107. package/dist/api/events/index.d.ts.map +1 -0
  108. package/dist/api/events/namespaces.d.ts +464 -0
  109. package/dist/api/events/namespaces.d.ts.map +1 -0
  110. package/dist/api/events/queue/ConfigUpdateQueueManager.d.ts +53 -0
  111. package/dist/api/events/queue/ConfigUpdateQueueManager.d.ts.map +1 -0
  112. package/dist/api/events/queue/EventQueueManager.d.ts +69 -0
  113. package/dist/api/events/queue/EventQueueManager.d.ts.map +1 -0
  114. package/dist/api/events/queue/index.d.ts +12 -0
  115. package/dist/api/events/queue/index.d.ts.map +1 -0
  116. package/dist/api/events/shared-emitter.d.ts +14 -0
  117. package/dist/api/events/shared-emitter.d.ts.map +1 -0
  118. package/dist/api/headers/cache.d.ts +17 -0
  119. package/dist/api/headers/cache.d.ts.map +1 -0
  120. package/dist/api/headers/enriched.d.ts +18 -0
  121. package/dist/api/headers/enriched.d.ts.map +1 -0
  122. package/dist/api/headers/events.d.ts +17 -0
  123. package/dist/api/headers/events.d.ts.map +1 -0
  124. package/dist/api/headers/extract.d.ts +73 -0
  125. package/dist/api/headers/extract.d.ts.map +1 -0
  126. package/dist/api/headers/headerBuilder.d.ts +308 -0
  127. package/dist/api/headers/headerBuilder.d.ts.map +1 -0
  128. package/dist/api/headers/index.d.ts +37 -0
  129. package/dist/api/headers/index.d.ts.map +1 -0
  130. package/dist/api/headers/merge.d.ts +32 -0
  131. package/dist/api/headers/merge.d.ts.map +1 -0
  132. package/dist/api/headers/presets.d.ts +24 -0
  133. package/dist/api/headers/presets.d.ts.map +1 -0
  134. package/dist/api/headers/utils.d.ts +38 -0
  135. package/dist/api/headers/utils.d.ts.map +1 -0
  136. package/dist/api/hooks/factories/createApiMutation.d.ts +57 -0
  137. package/dist/api/hooks/factories/createApiMutation.d.ts.map +1 -0
  138. package/dist/api/hooks/factories/createApiQuery.d.ts +55 -0
  139. package/dist/api/hooks/factories/createApiQuery.d.ts.map +1 -0
  140. package/dist/api/hooks/factories/defaults.d.ts +15 -0
  141. package/dist/api/hooks/factories/defaults.d.ts.map +1 -0
  142. package/dist/api/hooks/factories/index.d.ts +8 -0
  143. package/dist/api/hooks/factories/index.d.ts.map +1 -0
  144. package/dist/api/hooks/index.d.ts +11 -0
  145. package/dist/api/hooks/index.d.ts.map +1 -0
  146. package/dist/api/hooks/types.d.ts +82 -0
  147. package/dist/api/hooks/types.d.ts.map +1 -0
  148. package/dist/api/hooks/useApiConfigConflicts.d.ts +24 -0
  149. package/dist/api/hooks/useApiConfigConflicts.d.ts.map +1 -0
  150. package/dist/api/hooks/useApiDebugInfo.d.ts +24 -0
  151. package/dist/api/hooks/useApiDebugInfo.d.ts.map +1 -0
  152. package/dist/api/hooks/useApiMonitor.d.ts +25 -0
  153. package/dist/api/hooks/useApiMonitor.d.ts.map +1 -0
  154. package/dist/api/hooks/useApiNetworkQuality.d.ts +21 -0
  155. package/dist/api/hooks/useApiNetworkQuality.d.ts.map +1 -0
  156. package/dist/api/index.d.ts +26 -0
  157. package/dist/api/index.d.ts.map +1 -0
  158. package/dist/api/network/adaptive.d.ts +56 -0
  159. package/dist/api/network/adaptive.d.ts.map +1 -0
  160. package/dist/api/network/client-hints.d.ts +25 -0
  161. package/dist/api/network/client-hints.d.ts.map +1 -0
  162. package/dist/api/network/connection.d.ts +60 -0
  163. package/dist/api/network/connection.d.ts.map +1 -0
  164. package/dist/api/network/core.d.ts +26 -0
  165. package/dist/api/network/core.d.ts.map +1 -0
  166. package/dist/api/network/events.d.ts +18 -0
  167. package/dist/api/network/events.d.ts.map +1 -0
  168. package/dist/api/network/frameworks/express.d.ts +110 -0
  169. package/dist/api/network/frameworks/express.d.ts.map +1 -0
  170. package/dist/api/network/frameworks/index.d.ts +13 -0
  171. package/dist/api/network/frameworks/index.d.ts.map +1 -0
  172. package/dist/api/network/frameworks/nestjs/clientHintsInterceptor.d.ts +29 -0
  173. package/dist/api/network/frameworks/nestjs/clientHintsInterceptor.d.ts.map +1 -0
  174. package/dist/api/network/frameworks/nestjs/decorators.d.ts +48 -0
  175. package/dist/api/network/frameworks/nestjs/decorators.d.ts.map +1 -0
  176. package/dist/api/network/frameworks/nestjs/enrichedHeadersGuard.d.ts +80 -0
  177. package/dist/api/network/frameworks/nestjs/enrichedHeadersGuard.d.ts.map +1 -0
  178. package/dist/api/network/frameworks/nestjs/enrichedHeadersInterceptor.d.ts +83 -0
  179. package/dist/api/network/frameworks/nestjs/enrichedHeadersInterceptor.d.ts.map +1 -0
  180. package/dist/api/network/frameworks/nestjs/index.d.ts +13 -0
  181. package/dist/api/network/frameworks/nestjs/index.d.ts.map +1 -0
  182. package/dist/api/network/frameworks/nestjs/minimumConnectionGuard.d.ts +27 -0
  183. package/dist/api/network/frameworks/nestjs/minimumConnectionGuard.d.ts.map +1 -0
  184. package/dist/api/network/frameworks/nestjs/networkDetectionMiddleware.d.ts +31 -0
  185. package/dist/api/network/frameworks/nestjs/networkDetectionMiddleware.d.ts.map +1 -0
  186. package/dist/api/network/frameworks/nestjs/networkGuard.d.ts +33 -0
  187. package/dist/api/network/frameworks/nestjs/networkGuard.d.ts.map +1 -0
  188. package/dist/api/network/frameworks/nestjs/noDataSaverGuard.d.ts +25 -0
  189. package/dist/api/network/frameworks/nestjs/noDataSaverGuard.d.ts.map +1 -0
  190. package/dist/api/network/frameworks/nextjs.d.ts +86 -0
  191. package/dist/api/network/frameworks/nextjs.d.ts.map +1 -0
  192. package/dist/api/network/frameworks/shared.d.ts +45 -0
  193. package/dist/api/network/frameworks/shared.d.ts.map +1 -0
  194. package/dist/api/network/headers.d.ts +112 -0
  195. package/dist/api/network/headers.d.ts.map +1 -0
  196. package/dist/api/network/index.d.ts +17 -0
  197. package/dist/api/network/index.d.ts.map +1 -0
  198. package/dist/api/network/networkConfigurationManager.d.ts +225 -0
  199. package/dist/api/network/networkConfigurationManager.d.ts.map +1 -0
  200. package/dist/api/network/platform.d.ts +171 -0
  201. package/dist/api/network/platform.d.ts.map +1 -0
  202. package/dist/api/network/presets.d.ts +55 -0
  203. package/dist/api/network/presets.d.ts.map +1 -0
  204. package/dist/api/network/quality.d.ts +28 -0
  205. package/dist/api/network/quality.d.ts.map +1 -0
  206. package/dist/api/network/status.d.ts +74 -0
  207. package/dist/api/network/status.d.ts.map +1 -0
  208. package/dist/api/performance/adaptive.d.ts +35 -0
  209. package/dist/api/performance/adaptive.d.ts.map +1 -0
  210. package/dist/api/performance/index.d.ts +133 -0
  211. package/dist/api/performance/index.d.ts.map +1 -0
  212. package/dist/api/performance/patterns.d.ts +20 -0
  213. package/dist/api/performance/patterns.d.ts.map +1 -0
  214. package/dist/api/performance/performanceMonitor.d.ts +85 -0
  215. package/dist/api/performance/performanceMonitor.d.ts.map +1 -0
  216. package/dist/api/performance/presets.d.ts +18 -0
  217. package/dist/api/performance/presets.d.ts.map +1 -0
  218. package/dist/api/performance/utils.d.ts +98 -0
  219. package/dist/api/performance/utils.d.ts.map +1 -0
  220. package/dist/api/polling/index.d.ts +10 -0
  221. package/dist/api/polling/index.d.ts.map +1 -0
  222. package/dist/api/polling/strategies.d.ts +128 -0
  223. package/dist/api/polling/strategies.d.ts.map +1 -0
  224. package/dist/api/polling/utils.d.ts +133 -0
  225. package/dist/api/polling/utils.d.ts.map +1 -0
  226. package/dist/api/pubsub/index.d.ts +147 -0
  227. package/dist/api/pubsub/index.d.ts.map +1 -0
  228. package/dist/api/pubsub/react.d.ts +214 -0
  229. package/dist/api/pubsub/react.d.ts.map +1 -0
  230. package/dist/api/queue/BaseOperationTracker.d.ts +86 -0
  231. package/dist/api/queue/BaseOperationTracker.d.ts.map +1 -0
  232. package/dist/api/queue/BaseQueueManager.d.ts +54 -0
  233. package/dist/api/queue/BaseQueueManager.d.ts.map +1 -0
  234. package/dist/api/queue/BatchProcessor.d.ts +42 -0
  235. package/dist/api/queue/BatchProcessor.d.ts.map +1 -0
  236. package/dist/api/queue/EventQueueManager.d.ts +128 -0
  237. package/dist/api/queue/EventQueueManager.d.ts.map +1 -0
  238. package/dist/api/queue/PriorityQueue.d.ts +58 -0
  239. package/dist/api/queue/PriorityQueue.d.ts.map +1 -0
  240. package/dist/api/queue/QueueFactory.d.ts +57 -0
  241. package/dist/api/queue/QueueFactory.d.ts.map +1 -0
  242. package/dist/api/queue/QueueOrchestrator.d.ts +90 -0
  243. package/dist/api/queue/QueueOrchestrator.d.ts.map +1 -0
  244. package/dist/api/queue/QueueSystem.d.ts +102 -0
  245. package/dist/api/queue/QueueSystem.d.ts.map +1 -0
  246. package/dist/api/queue/index.d.ts +22 -0
  247. package/dist/api/queue/index.d.ts.map +1 -0
  248. package/dist/api/regional/constants.d.ts +76 -0
  249. package/dist/api/regional/constants.d.ts.map +1 -0
  250. package/dist/api/regional/core.d.ts +56 -0
  251. package/dist/api/regional/core.d.ts.map +1 -0
  252. package/dist/api/regional/helpers.d.ts +49 -0
  253. package/dist/api/regional/helpers.d.ts.map +1 -0
  254. package/dist/api/regional/index.d.ts +10 -0
  255. package/dist/api/regional/index.d.ts.map +1 -0
  256. package/dist/api/regional/presets.d.ts +16 -0
  257. package/dist/api/regional/presets.d.ts.map +1 -0
  258. package/dist/api/request/index.d.ts +18 -0
  259. package/dist/api/request/index.d.ts.map +1 -0
  260. package/dist/api/request/management.d.ts +46 -0
  261. package/dist/api/request/management.d.ts.map +1 -0
  262. package/dist/api/request/prepare.d.ts +34 -0
  263. package/dist/api/request/prepare.d.ts.map +1 -0
  264. package/dist/api/request/react.d.ts +98 -0
  265. package/dist/api/request/react.d.ts.map +1 -0
  266. package/dist/api/request/routing.d.ts +74 -0
  267. package/dist/api/request/routing.d.ts.map +1 -0
  268. package/dist/api/request/tracker.d.ts +76 -0
  269. package/dist/api/request/tracker.d.ts.map +1 -0
  270. package/dist/api/request/utils.d.ts +129 -0
  271. package/dist/api/request/utils.d.ts.map +1 -0
  272. package/dist/api/retry/conditions.d.ts +140 -0
  273. package/dist/api/retry/conditions.d.ts.map +1 -0
  274. package/dist/api/retry/index.d.ts +10 -0
  275. package/dist/api/retry/index.d.ts.map +1 -0
  276. package/dist/api/retry/strategies.d.ts +56 -0
  277. package/dist/api/retry/strategies.d.ts.map +1 -0
  278. package/dist/api/revalidation/index.d.ts +29 -0
  279. package/dist/api/revalidation/index.d.ts.map +1 -0
  280. package/dist/api/revalidation/presets.d.ts +71 -0
  281. package/dist/api/revalidation/presets.d.ts.map +1 -0
  282. package/dist/api/revalidation/strategies.d.ts +116 -0
  283. package/dist/api/revalidation/strategies.d.ts.map +1 -0
  284. package/dist/api/revalidation/utils.d.ts +78 -0
  285. package/dist/api/revalidation/utils.d.ts.map +1 -0
  286. package/dist/api/services/campaigns/DELETE/deleteCampaign.d.ts +30 -0
  287. package/dist/api/services/campaigns/DELETE/deleteCampaign.d.ts.map +1 -0
  288. package/dist/api/services/campaigns/DELETE/index.d.ts +7 -0
  289. package/dist/api/services/campaigns/DELETE/index.d.ts.map +1 -0
  290. package/dist/api/services/campaigns/DELETE/useDeleteCampaign.d.ts +24 -0
  291. package/dist/api/services/campaigns/DELETE/useDeleteCampaign.d.ts.map +1 -0
  292. package/dist/api/services/campaigns/GET/fetchCampaign.d.ts +36 -0
  293. package/dist/api/services/campaigns/GET/fetchCampaign.d.ts.map +1 -0
  294. package/dist/api/services/campaigns/GET/fetchCampaignParticipants.d.ts +40 -0
  295. package/dist/api/services/campaigns/GET/fetchCampaignParticipants.d.ts.map +1 -0
  296. package/dist/api/services/campaigns/GET/fetchCampaignStats.d.ts +31 -0
  297. package/dist/api/services/campaigns/GET/fetchCampaignStats.d.ts.map +1 -0
  298. package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts +39 -0
  299. package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts.map +1 -0
  300. package/dist/api/services/campaigns/GET/index.d.ts +13 -0
  301. package/dist/api/services/campaigns/GET/index.d.ts.map +1 -0
  302. package/dist/api/services/campaigns/GET/useCampaign.d.ts +47 -0
  303. package/dist/api/services/campaigns/GET/useCampaign.d.ts.map +1 -0
  304. package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts +43 -0
  305. package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts.map +1 -0
  306. package/dist/api/services/campaigns/GET/useCampaignStats.d.ts +33 -0
  307. package/dist/api/services/campaigns/GET/useCampaignStats.d.ts.map +1 -0
  308. package/dist/api/services/campaigns/GET/useCampaigns.d.ts +43 -0
  309. package/dist/api/services/campaigns/GET/useCampaigns.d.ts.map +1 -0
  310. package/dist/api/services/campaigns/POST/createCampaign.d.ts +37 -0
  311. package/dist/api/services/campaigns/POST/createCampaign.d.ts.map +1 -0
  312. package/dist/api/services/campaigns/POST/index.d.ts +11 -0
  313. package/dist/api/services/campaigns/POST/index.d.ts.map +1 -0
  314. package/dist/api/services/campaigns/POST/joinCampaign.d.ts +31 -0
  315. package/dist/api/services/campaigns/POST/joinCampaign.d.ts.map +1 -0
  316. package/dist/api/services/campaigns/POST/leaveCampaign.d.ts +31 -0
  317. package/dist/api/services/campaigns/POST/leaveCampaign.d.ts.map +1 -0
  318. package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts +36 -0
  319. package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts.map +1 -0
  320. package/dist/api/services/campaigns/POST/useJoinCampaign.d.ts +23 -0
  321. package/dist/api/services/campaigns/POST/useJoinCampaign.d.ts.map +1 -0
  322. package/dist/api/services/campaigns/POST/useLeaveCampaign.d.ts +23 -0
  323. package/dist/api/services/campaigns/POST/useLeaveCampaign.d.ts.map +1 -0
  324. package/dist/api/services/campaigns/PUT/index.d.ts +7 -0
  325. package/dist/api/services/campaigns/PUT/index.d.ts.map +1 -0
  326. package/dist/api/services/campaigns/PUT/updateCampaign.d.ts +37 -0
  327. package/dist/api/services/campaigns/PUT/updateCampaign.d.ts.map +1 -0
  328. package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts +38 -0
  329. package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts.map +1 -0
  330. package/dist/api/services/campaigns/index.d.ts +9 -0
  331. package/dist/api/services/campaigns/index.d.ts.map +1 -0
  332. package/dist/api/services/clients.d.ts +58 -0
  333. package/dist/api/services/clients.d.ts.map +1 -0
  334. package/dist/api/services/index.d.ts +7 -0
  335. package/dist/api/services/index.d.ts.map +1 -0
  336. package/dist/api/strategies/index.d.ts +8 -0
  337. package/dist/api/strategies/index.d.ts.map +1 -0
  338. package/dist/api/strategies/tracked.d.ts +15 -0
  339. package/dist/api/strategies/tracked.d.ts.map +1 -0
  340. package/dist/api/strategies/unified.d.ts +87 -0
  341. package/dist/api/strategies/unified.d.ts.map +1 -0
  342. package/dist/api/utils/async-control.d.ts +96 -0
  343. package/dist/api/utils/async-control.d.ts.map +1 -0
  344. package/dist/api/utils/colors.d.ts +88 -0
  345. package/dist/api/utils/colors.d.ts.map +1 -0
  346. package/dist/api/utils/environment.d.ts +595 -0
  347. package/dist/api/utils/environment.d.ts.map +1 -0
  348. package/dist/api/utils/generation/correlation-id.d.ts +206 -0
  349. package/dist/api/utils/generation/correlation-id.d.ts.map +1 -0
  350. package/dist/api/utils/generation/id-generator.d.ts +133 -0
  351. package/dist/api/utils/generation/id-generator.d.ts.map +1 -0
  352. package/dist/api/utils/generation/request-id.d.ts +106 -0
  353. package/dist/api/utils/generation/request-id.d.ts.map +1 -0
  354. package/dist/api/utils/index.d.ts +19 -0
  355. package/dist/api/utils/index.d.ts.map +1 -0
  356. package/dist/api/utils/interval-manager.d.ts +94 -0
  357. package/dist/api/utils/interval-manager.d.ts.map +1 -0
  358. package/dist/api/utils/json.d.ts +98 -0
  359. package/dist/api/utils/json.d.ts.map +1 -0
  360. package/dist/api/utils/math.d.ts +168 -0
  361. package/dist/api/utils/math.d.ts.map +1 -0
  362. package/dist/api/utils/object-merge.d.ts +34 -0
  363. package/dist/api/utils/object-merge.d.ts.map +1 -0
  364. package/dist/api/utils/object.d.ts +101 -0
  365. package/dist/api/utils/object.d.ts.map +1 -0
  366. package/dist/api/utils/string.d.ts +41 -0
  367. package/dist/api/utils/string.d.ts.map +1 -0
  368. package/dist/api/utils/time.d.ts +233 -0
  369. package/dist/api/utils/time.d.ts.map +1 -0
  370. package/dist/api/utils/type-guards.d.ts +59 -0
  371. package/dist/api/utils/type-guards.d.ts.map +1 -0
  372. package/dist/api/utils/validation.d.ts +21 -0
  373. package/dist/api/utils/validation.d.ts.map +1 -0
  374. package/dist/index.cjs +25594 -3
  375. package/dist/index.cjs.map +1 -1
  376. package/dist/index.d.ts +5 -1
  377. package/dist/index.d.ts.map +1 -1
  378. package/dist/index.mjs +25068 -3
  379. package/dist/index.mjs.map +1 -1
  380. package/package.json +15 -6
package/README.md CHANGED
@@ -1,693 +1,783 @@
1
1
  # @plyaz/api
2
2
 
3
- Unified API client for seamless backend communication across the Plyaz platform. Provides type-safe endpoints, React Query integration, consistent error handling, and intelligent request management - supporting Web3, authentication, and tokenized experiences.
3
+ > Smart, type-safe API client for the Plyaz ecosystem with zero-configuration intelligence
4
4
 
5
- ## Overview
5
+ [![Version](https://img.shields.io/badge/version-1.0.2-blue.svg)](https://github.com/Plyaz-Official/api)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
7
+ [![License](https://img.shields.io/badge/license-ISC-green.svg)](LICENSE)
6
8
 
7
- The @plyaz/api package provides a unified API client for communicating with backend services across the Plyaz platform. It offers type-safe API endpoints, consistent error handling, and integration with React Query for efficient data fetching. This package serves as the core communication layer between frontend applications and backend services.
9
+ **@plyaz/api** is the unified API client for seamless backend communication across the Plyaz platform. Built on [fetchff](https://www.npmjs.com/package/fetchff), it provides intelligent defaults, automatic optimizations, and full TypeScript support for Web3, authentication, and tokenized experiences.
8
10
 
9
- > **Note**: This package is designed as a shared package that works across frontend and backend contexts, with platform-specific implementations where necessary. It integrates seamlessly with the @plyaz/* ecosystem of shared packages.
11
+ ---
10
12
 
11
- ## Features
13
+ ## ✨ Why @plyaz/api?
12
14
 
13
- - **Type-Safe API Client**: Built on `fetchff` with full TypeScript support
14
- - **React Query Integration**: Ready-to-use hooks for data fetching and mutations
15
- - **Consistent Error Handling**: Integrated with `@plyaz/errors` for standardized errors
16
- - **Request Management**: Deduplication, cancellation, and retry mechanisms
17
- - **Authentication Support**: Built-in auth token handling and interceptors
18
- - **Pagination Support**: Cursor and offset-based pagination utilities
19
- - **Performance Optimized**: Request batching, caching, and queue management
20
- - **Event Integration**: Lifecycle events via `@plyaz/events`
21
- - **Third-Party APIs**: Support for Alchemy, The Graph, and other integrations
15
+ ### Zero-Configuration Smart Features
22
16
 
23
- ## Installation
17
+ The API client works intelligently out of the box:
24
18
 
25
- ```bash
26
- pnpm add @plyaz/api
19
+ | Feature | What It Does | Default Behavior | When to Override |
20
+ |---------|--------------|------------------|------------------|
21
+ | **Request Deduplication** | Prevents duplicate requests | 2-second window | Real-time data needs |
22
+ | **Automatic Retry** | Retries failed requests | 3 retries with exponential backoff | Critical operations |
23
+ | **Response Caching** | Caches successful responses | 10min cache, 2min stale | Static vs real-time data |
24
+ | **Network Adaptation** | Adjusts to connection quality | Automatic detection | Custom performance needs |
25
+ | **Smart Headers** | Sets appropriate headers | JSON content-type | File uploads, GraphQL |
26
+ | **Timeout Handling** | Prevents hanging requests | 30 seconds | Long-running operations |
27
+
28
+ ### Pre-Configured Endpoints
29
+
30
+ All endpoints are pre-defined and fully typed. No configuration needed:
31
+
32
+ ```typescript
33
+ const api = await createApiClient({ baseURL: 'https://api.example.com' });
34
+
35
+ // Pre-configured, fully typed methods ready to use!
36
+ const { data } = await api.getUsers();
37
+ const { data: campaign } = await api.getCampaign({ id: '123' });
27
38
  ```
28
39
 
29
- ## Development
40
+ ---
41
+
42
+ ## 📦 Installation
30
43
 
31
- ### Prerequisites
44
+ ```bash
45
+ pnpm add @plyaz/api
46
+ ```
32
47
 
48
+ **Requirements:**
33
49
  - Node.js >= 22.4.0
34
50
  - pnpm >= 8.0.0
35
51
 
36
- ### Setup
52
+ ---
37
53
 
38
- ```bash
39
- # Clone the repository
40
- git clone https://github.com/Plyaz-Official/api.git
41
- cd api
54
+ ## 🚀 Quick Start
42
55
 
43
- # Install dependencies
44
- pnpm install
56
+ ### Simple REST API (2 lines)
45
57
 
46
- # Start development (watch mode)
47
- pnpm dev
58
+ ```typescript
59
+ const api = await createApiClient({ baseURL: 'https://api.example.com' });
60
+ const { data } = await api.getUsers();
48
61
  ```
49
62
 
50
- ### Available Scripts
63
+ ### Authenticated API
51
64
 
52
- ```bash
53
- # Development
54
- pnpm dev # Start development with watch mode (alias: pnpm build:watch)
55
- pnpm build:watch # Watch files and rebuild on changes
56
-
57
- # Building
58
- pnpm build # Full build (clean + JS + TypeScript declarations)
59
- pnpm build:js # Build JavaScript bundles with tsup
60
- pnpm build:types # Generate TypeScript declaration files
61
- pnpm clean # Remove dist directory
62
-
63
- # Testing
64
- pnpm test # Run all tests once
65
- pnpm test:watch # Run tests in watch mode
66
- pnpm test:coverage # Run tests with coverage report
67
- pnpm test:ui # Open Vitest UI for interactive testing
68
- pnpm test:ci # Run tests in CI environment
69
-
70
- # Code Quality
71
- pnpm lint # Check code with ESLint
72
- pnpm lint:fix # Auto-fix ESLint issues
73
- pnpm format # Format code with Prettier
74
- pnpm format:check # Check if code is formatted correctly
75
- pnpm type:check # Type check with TypeScript (no emit)
76
-
77
- # Security & Auditing
78
- pnpm audit # Basic security audit
79
- pnpm audit:moderate # Check for moderate+ vulnerabilities
80
- pnpm audit:high # Check for high+ vulnerabilities
81
- pnpm audit:critical # Check only critical vulnerabilities
82
- pnpm audit:fix # Auto-fix vulnerabilities where possible
83
- pnpm audit:enhanced # Enhanced audit with audit-ci
84
- pnpm security:check # Full security check (moderate + audit-ci)
85
-
86
- # Publishing
87
- pnpm prepublishOnly # Runs build, test, and lint before publishing
65
+ ```typescript
66
+ const api = await createApiClient({
67
+ baseURL: 'https://api.example.com',
68
+ headers: async () => ({
69
+ Authorization: `Bearer ${await getToken()}`
70
+ })
71
+ });
88
72
  ```
89
73
 
90
- ## Package Structure
74
+ ### Mobile App (Network-aware)
91
75
 
76
+ ```typescript
77
+ const api = await createApiClient({
78
+ baseURL: 'https://api.example.com',
79
+ performanceStrategy: 'mobile',
80
+ networkAware: { enabled: true }
81
+ });
92
82
  ```
93
- @plyaz/api/
94
- ├── src/
95
- │ ├── client/ # API client implementation
96
- │ │ ├── createApiClient.ts # Factory function for API client
97
- │ │ ├── defaultConfig.ts # Default configuration
98
- │ │ └── types.ts # Client-specific types
99
- │ ├── endpoints/ # API endpoint definitions
100
- │ │ ├── auth.ts # Authentication endpoints
101
- │ │ ├── user.ts # User endpoints
102
- │ │ ├── nft.ts # NFT endpoints
103
- │ │ └── transaction.ts # Transaction endpoints
104
- │ ├── services/ # API service functions
105
- │ │ ├── auth.ts # Auth service functions
106
- │ │ ├── user.ts # User service functions
107
- │ │ └── nft.ts # NFT service functions
108
- │ ├── integrations/ # Third-party API integrations
109
- │ │ └── alchemy/ # Alchemy API integration
110
- │ ├── hooks/ # React Query hooks
111
- │ │ ├── auth/ # Auth-related hooks
112
- │ │ └── user/ # User-related hooks
113
- │ ├── utils/ # Utility functions
114
- │ │ ├── error-handler.ts # Error handling utilities
115
- │ │ └── pagination.ts # Pagination utilities
116
- │ └── index.ts # Main exports
117
- ```
118
-
119
- ## Quick Start
120
83
 
121
- ### Basic Setup
122
-
123
- #### Initialize API Client
84
+ ### Real-Time Dashboard
124
85
 
125
86
  ```typescript
126
- import { createApiClient } from '@plyaz/api';
127
-
128
- // Create API client with custom configuration
129
- const api = createApiClient({
130
- baseURL: process.env.NEXT_PUBLIC_API_URL,
131
- timeout: 30000,
132
- headers: {
133
- 'Content-Type': 'application/json'
134
- }
87
+ const api = await createApiClient({
88
+ baseURL: 'https://api.example.com',
89
+ unifiedStrategy: 'realtime',
90
+ revalidationStrategy: 'aggressive'
135
91
  });
136
-
137
- // Or use the default pre-configured client
138
- import { api } from '@plyaz/api';
139
92
  ```
140
93
 
141
- #### With Authentication
94
+ ---
95
+
96
+ ## 🎯 Complete Feature Set
97
+
98
+ ### Core Request Features
99
+
100
+ | Feature | Type | Description | Default | Configuration |
101
+ |---------|------|-------------|---------|---------------|
102
+ | **🔒 Type Safety** | Auto | Full TypeScript support with intelligent type inference | Enabled | N/A - Always active |
103
+ | **⚡ Smart Defaults** | Auto | Zero-config setup, works perfectly out of the box | Enabled | Override via config |
104
+ | **📋 Pre-Configured Endpoints** | Auto | Typed endpoint methods ready to use | All endpoints | Override with `endpoints` |
105
+ | **🔁 Request Deduplication** | Auto | Prevents duplicate requests within time window | 2-second window | `dedupeTime: number` |
106
+ | **⏱️ Timeout Handling** | Auto | Prevents hanging requests | 30 seconds | `timeout: number` |
107
+ | **🚦 Request Cancellation** | Manual | AbortController support | Available | `cancellable: true` |
108
+ | **🔗 Request Chaining** | Manual | Chain multiple requests efficiently | Available | Standard usage |
109
+ | **🔌 Interceptors** | Manual | Request/response/error interceptors | None | `onRequest`, `onResponse`, `onError` |
110
+
111
+ ### Retry & Resilience
112
+
113
+ | Feature | Type | Description | Default | Configuration |
114
+ |---------|------|-------------|---------|---------------|
115
+ | **🔄 Retry Logic** | Auto | Exponential backoff for failed requests | 3 retries, 1s delay, 1.5x backoff | `retry: { retries, delay, backoff }` |
116
+ | **🎯 Retry Strategies** | Manual | Customizable retry strategies (none, minimal, standard, etc.) | `standard` | `retryStrategy: string` |
117
+ | **🔍 Retry Conditions** | Manual | Conditional retry based on status codes, errors | Standard HTTP errors | `retryOn: number[]` |
118
+ | **⚠️ Status Code Limits** | Manual | Define retry behavior per status code | 408, 429, 500, 502, 503, 504 | Custom limits |
119
+
120
+ ### Caching & Revalidation
121
+
122
+ | Feature | Type | Description | Default | Configuration |
123
+ |---------|------|-------------|---------|---------------|
124
+ | **💾 Response Caching** | Auto | Multi-level caching (memory, session, persistent) | 10min cache, 2min stale | `cacheTime`, `staleTime` |
125
+ | **📦 Cache Strategies** | Manual | 6 strategies (none, minimal, standard, moderate, aggressive, offline) | `standard` | `cacheStrategy: string` |
126
+ | **🔑 Cache Key Patterns** | Manual | Custom cache key generation patterns | Standard pattern | `buildCacheKey()` |
127
+ | **🗑️ Cache Invalidation** | Manual | Invalidation scenarios and utilities | Available | `mutate()`, `deleteCache()` |
128
+ | **♻️ Revalidation** | Auto | 9 strategies (focus, reconnect, interval, etc.) | On focus/reconnect | `revalidationStrategy: string` |
129
+ | **🔄 Manual Revalidation** | Manual | Programmatic cache revalidation | Available | `revalidate()`, `revalidateAll()` |
130
+
131
+ ### Network & Performance
132
+
133
+ | Feature | Type | Description | Default | Configuration |
134
+ |---------|------|-------------|---------|---------------|
135
+ | **🌐 Network Detection** | Auto | Detects connection quality and adapts | Enabled | `networkAware: { enabled }` |
136
+ | **📊 Network Quality** | Auto | Monitors network quality (excellent, good, slow, offline) | Automatic | Auto-detection |
137
+ | **🎯 Performance Strategies** | Manual | Optimized presets (mobile, realtime, static, etc.) | `standard` | `performanceStrategy: string` |
138
+ | **⚙️ Network Config Manager** | Auto | Manages network-optimized configurations | Enabled | Automatic management |
139
+ | **💻 Platform Detection** | Auto | Detects platform (browser, Node.js, Electron, etc.) | Automatic | Auto-detection |
140
+ | **📱 Device Detection** | Auto | Detects device type and capabilities | Automatic | Auto-detection |
141
+ | **🔍 Client Hints** | Auto | Enhanced client hints for network optimization | Enabled | Automatic detection |
142
+ | **⚡ Adaptive Performance** | Auto | Adapts behavior based on device/network | Enabled | Automatic adaptation |
143
+ | **📈 Performance Monitoring** | Auto | Tracks request timing and performance metrics | Enabled | Automatic tracking |
144
+ | **💤 Data Saver Mode** | Auto | Detects and respects data saver preferences | Enabled | Automatic detection |
145
+
146
+ ### Headers & Regional
147
+
148
+ | Feature | Type | Description | Default | Configuration |
149
+ |---------|------|-------------|---------|---------------|
150
+ | **📝 Header Management** | Auto | Smart header enrichment and presets | JSON content-type | `headers: {}` or `headers: () => {}` |
151
+ | **✨ Enriched Headers** | Auto | Automatic header enrichment with platform/network data | Enabled | `enrichedHeaders: boolean` |
152
+ | **🎨 Header Presets** | Manual | Pre-configured header sets (json, multipart, etc.) | Available | `headerPresets` |
153
+ | **🔐 Authentication** | Manual | Token management and auth interceptors | None | `onRequest` interceptor |
154
+ | **🌍 Regional Compliance** | Auto | GDPR, CCPA, APAC support | Enabled | `regionalConfig` |
155
+ | **🗺️ Regional Detection** | Auto | Auto-detect user region for compliance | Enabled | Automatic detection |
156
+ | **🎯 Regional Presets** | Manual | Region-specific configuration presets | Available | Regional presets |
157
+
158
+ ### Configuration Management
159
+
160
+ | Feature | Type | Description | Default | Configuration |
161
+ |---------|------|-------------|---------|---------------|
162
+ | **📊 Config Levels** | Auto | 4-level hierarchy (global → client → request → temporary) | All levels active | Config hierarchy |
163
+ | **🔄 Config Merging** | Auto | Smart deep merging of configuration objects | Enabled | Automatic merging |
164
+ | **⚙️ Merge Strategies** | Manual | Custom merge strategies for config properties | Deep merge | Custom strategies |
165
+ | **🔀 Temporary Overrides** | Manual | Temporary config overrides with auto-reset | Available | `applyTemporaryOverride()` |
166
+ | **📋 Override Tracking** | Auto | Tracks all configuration overrides | Enabled | Automatic tracking |
167
+ | **🎯 Config Update Strategy** | Manual | 3 strategies (merge, replace, temporary) | Merge | `configOverride.strategy` |
168
+ | **🎨 Handler Strategy** | Manual | 4 strategies (merge, replace, prepend, append) | Merge | `configOverride.handlerStrategy` |
169
+ | **📍 Event Scopes Control** | Manual | Control which scopes receive events | All scopes | `configOverride.eventScopes` |
170
+ | **🧹 Auto-Clear Overrides** | Manual | Auto-clear temporary overrides after request | Disabled | `configOverride.clearOnComplete` |
171
+ | **⚡ Priority Mode** | Manual | Only highest priority handler runs | Disabled | `configOverride.priority` |
172
+ | **💾 Preserved Config** | Auto | Preserves original config for restoration | Enabled | Automatic preservation |
173
+ | **🔍 Config Debugger** | Manual | Detect configuration conflicts | Available | `useApiConfigConflicts()` |
174
+ | **⚠️ Conflict Detection** | Manual | Detects conflicting configurations | Available | `checkConflicts()` |
175
+ | **🌐 Global Config API** | Manual | Set/get/update global configuration | Available | Global config methods |
176
+ | **📝 Config Validation** | Auto | Validates configuration at runtime | Enabled | Automatic validation |
177
+
178
+ ### Tracking & Telemetry
179
+
180
+ | Feature | Type | Description | Default | Configuration |
181
+ |---------|------|-------------|---------|---------------|
182
+ | **🎛️ Master Tracking Switch** | Manual | Enable/disable all tracking features | Enabled | `tracking.enabled` |
183
+ | **📊 Operation Tracking** | Manual | Track operations for debugging (debugger queue) | Enabled | `tracking.operations` |
184
+ | **📡 Event Emission Control** | Manual | Control whether events are emitted/processed | Enabled | `tracking.events` |
185
+ | **⚙️ Queue Strategy** | Manual | 4 strategies (immediate, batch, throttle, debounce) | Batch | `tracking.queueStrategy` |
186
+ | **📤 Event Strategy** | Manual | Event processing (immediate, queued) | Immediate | `tracking.eventStrategy` |
187
+ | **⚡ Performance Mode** | Manual | 3 modes (full, minimal, off) | Full | `tracking.performanceMode` |
188
+ | **📜 History Size Limit** | Manual | Max operations to keep in history | 1000 | `tracking.historySize` |
189
+ | **⚠️ Max Conflicts Tracking** | Manual | Max conflicts to track | 100 | `tracking.maxConflicts` |
190
+ | **🚫 Skip History** | Manual | Skip adding entries to history for this request | Disabled | `tracking.skipHistory` |
191
+ | **📈 Telemetry Collection** | Manual | Analytics/monitoring data collection | Disabled | `tracking.telemetry` |
192
+ | **🎯 Context-Aware Tracking** | Auto | Different defaults for test vs production | Auto-detected | Environment-based |
193
+
194
+ ### Events & Monitoring
195
+
196
+ | Feature | Type | Description | Default | Configuration |
197
+ |---------|------|-------------|---------|---------------|
198
+ | **📊 Event System** | Auto | 80+ events across 8 namespaces | Enabled | `on()`, `off()`, `emit()` |
199
+ | **🎯 Event Namespaces** | Auto | 8 namespaces (headers, network, errors, debug, config, perf, client, cache) | All active | Namespace filtering |
200
+ | **📍 Event Scopes** | Auto | 4 scopes (GLOBAL → CONFIG → CLIENT → REQUEST) | All scopes | Scope-based handlers |
201
+ | **🔄 Handler Strategies** | Manual | 4 strategies (merge, replace, prepend, append) | Merge | `handlerStrategy` config |
202
+ | **⚡ Event Priorities** | Auto | Priority-based event execution | By scope priority | Automatic prioritization |
203
+ | **⚙️ Queue System** | Auto | Priority-based async operation processing | Enabled | Automatic batching |
204
+ | **📦 Batch Processing** | Auto | Batches events for efficient processing | 10ms window | Batch config |
205
+ | **🔔 Network Events** | Auto | Network state change events | Enabled | Event subscriptions |
206
+ | **📦 PubSub System** | Manual | Real-time subscriptions and updates | Available | Event subscriptions |
207
+ | **🎣 React Hooks** | Manual | 4 monitoring hooks (monitor, debug, config, network) | Available | `useApiMonitor()`, etc. |
208
+ | **📈 Event Statistics** | Manual | Get stats on event emissions and handlers | Available | `getEventStats()` |
209
+ | **🎯 Scoped Handlers** | Manual | Register handlers at specific scopes | Available | Scope parameter |
210
+ | **⏱️ Once Handlers** | Manual | Handlers that execute only once | Available | `once()` method |
211
+ | **🚫 Handler Removal** | Manual | Unregister event handlers | Available | `off()` method |
212
+
213
+ ### Debugging & Diagnostics
214
+
215
+ | Feature | Type | Description | Default | Configuration |
216
+ |---------|------|-------------|---------|---------------|
217
+ | **🐛 Debug Tools** | Manual | Built-in debugging and analysis tools | Available | `getDebugInfo()` |
218
+ | **📋 Debug Reporting** | Manual | Generate comprehensive debug reports | Available | `generateReport()` |
219
+ | **📊 Operation Tracking** | Auto | Tracks all API operations for debugging | Enabled | Automatic tracking |
220
+ | **📜 History Tracking** | Auto | Maintains request/response history (LRU) | Enabled | Automatic tracking |
221
+ | **🔍 Issue Analysis** | Manual | Analyzes issues and provides recommendations | Available | Debug factories |
222
+ | **📊 Performance Analysis** | Manual | Analyzes performance bottlenecks | Available | Performance factory |
223
+
224
+ ### Strategies & Patterns
225
+
226
+ | Feature | Type | Description | Default | Configuration |
227
+ |---------|------|-------------|---------|---------------|
228
+ | **🎯 Unified Strategies** | Manual | Combined strategy presets (realtime, mobile, etc.) | Available | `unifiedStrategy: string` |
229
+ | **🔄 Polling Strategies** | Manual | Progressive, conditional, visibility-aware polling | Available | Polling config |
230
+ | **♻️ Revalidation Strategies** | Manual | 9 revalidation patterns | On focus/reconnect | Strategy config |
231
+ | **⏰ Visibility-Aware** | Auto | Pauses operations when tab inactive | Enabled | Automatic behavior |
232
+ | **📈 Progressive Polling** | Manual | Gradually increasing poll intervals | Available | Progressive config |
233
+ | **🎯 Conditional Polling** | Manual | Poll based on conditions | Available | Conditional config |
234
+
235
+ ### Error Handling
236
+
237
+ | Feature | Type | Description | Default | Configuration |
238
+ |---------|------|-------------|---------|---------------|
239
+ | **❌ Error Handling** | Auto | Standardized error handling with @plyaz/errors | 18 error types | `strategy: 'softFail' \| 'reject'` |
240
+ | **🎯 Error Strategies** | Manual | softFail, reject, silent, defaultResponse | `softFail` | `strategy` config |
241
+ | **🔔 Error Events** | Auto | Error event handlers (global, instance, once) | Enabled | Error event handlers |
242
+ | **📊 Error Categories** | Auto | Categorized errors (network, validation, auth, etc.) | Automatic | Built-in categories |
243
+
244
+ ### Framework Integration
245
+
246
+ | Feature | Type | Description | Default | Configuration |
247
+ |---------|------|-------------|---------|---------------|
248
+ | **🚀 Next.js Middleware** | Manual | Next.js-specific integrations | Available | Framework middleware |
249
+ | **⚡ Express Middleware** | Manual | Express server-side integration | Available | Framework middleware |
250
+ | **🎯 NestJS Integration** | Manual | NestJS decorators and providers | Available | Framework middleware |
251
+ | **💻 SSR Support** | Auto | Server-side rendering safe operations | Enabled | SSR-safe configs |
252
+
253
+ ### Utilities
254
+
255
+ | Feature | Type | Description | Default | Configuration |
256
+ |---------|------|-------------|---------|---------------|
257
+ | **🆔 ID Generation** | Auto | Request ID, Correlation ID generation | Enabled | Automatic generation |
258
+ | **⏱️ Time Utilities** | Manual | Time formatting, duration, delays | Available | Utility functions |
259
+ | **🔢 Math Utilities** | Manual | Percentage, clamping, averaging | Available | Utility functions |
260
+ | **📝 String Utilities** | Manual | String manipulation helpers | Available | Utility functions |
261
+ | **📦 Object Utilities** | Manual | Deep merge, clone, access | Available | Utility functions |
262
+ | **🔍 Type Guards** | Manual | Runtime type checking | Available | Utility functions |
263
+ | **✅ Validation** | Manual | Data validation utilities | Available | Utility functions |
264
+ | **⏰ Interval Manager** | Manual | Manage polling intervals | Available | Utility functions |
265
+ | **🎨 JSON Utilities** | Manual | Safe JSON parsing/stringifying | Available | Utility functions |
266
+
267
+ ### Endpoints & Services
268
+
269
+ | Feature | Type | Description | Default | Configuration |
270
+ |---------|------|-------------|---------|---------------|
271
+ | **📋 Endpoint Builders** | Manual | Fluent API for building endpoint configurations | Available | Endpoint builder pattern |
272
+ | **🏗️ Endpoint Utilities** | Manual | Helper utilities for endpoint management | Available | Utility functions |
273
+ | **🎯 Services Layer** | Manual | Service functions with smart defaults per HTTP method | Available | `ServiceOptions` |
274
+ | **🔧 Campaign Services** | Manual | Complete CRUD operations for campaigns | Available | Service layer |
275
+ | **🎣 React Query Hooks** | Manual | Pre-built hooks (useCampaigns, useCreateCampaign, etc.) | Available | Hook factories |
276
+ | **📦 Endpoint Registry** | Auto | Maintains registry of all configured endpoints | Enabled | Automatic registration |
277
+ | **🔍 Endpoint Validation** | Auto | Validates endpoint configurations | Enabled | Automatic validation |
278
+
279
+ ### Request Management
280
+
281
+ | Feature | Type | Description | Default | Configuration |
282
+ |---------|------|-------------|---------|---------------|
283
+ | **📝 Request Preparation** | Auto | Prepares requests with proper formatting | Enabled | Automatic preparation |
284
+ | **🚫 Abort Management** | Manual | Manage request cancellation via AbortController | Available | Abort utilities |
285
+ | **🔍 Request Routing** | Auto | Routes requests through proper pipeline | Enabled | Automatic routing |
286
+ | **📊 Request Utils** | Manual | Request preparation and management utilities | Available | Utility functions |
287
+ | **🆔 Request ID Tracking** | Auto | Automatic request ID generation and tracking | Enabled | Automatic generation |
288
+ | **🔗 Correlation ID** | Auto | Correlation ID for distributed tracing | Enabled | Automatic generation |
289
+
290
+ ### Advanced Features
291
+
292
+ | Feature | Type | Description | Default | Configuration |
293
+ |---------|------|-------------|---------|---------------|
294
+ | **🔍 Request Fingerprinting** | Auto | Generates unique fingerprints for requests | Enabled | Automatic generation |
295
+ | **🔐 Header Sanitization** | Auto | Removes sensitive headers from logs | Enabled | Automatic sanitization |
296
+ | **🔍 Authentication Detection** | Auto | Detects auth type from headers | Enabled | Automatic detection |
297
+ | **📦 Multiple Clients** | Manual | Create and manage multiple client instances | Available | Standard usage |
298
+ | **🎯 Extended API Client** | Manual | ApiClientWithEvents with enhanced features | Available | Create extended client |
299
+ | **🔄 Client Factory Pattern** | Manual | Factory pattern for creating specialized clients | Available | Factory functions |
300
+ | **🎨 Color Utilities** | Manual | Console color utilities for logging | Available | Color helpers |
301
+ | **🌐 Environment Detection** | Auto | Detects runtime environment (browser/Node/Deno/Bun) | Enabled | Automatic detection |
302
+ | **📱 Push Notification Support** | Auto | Detects push notification capabilities | Enabled | Automatic detection |
303
+
304
+ ### Legend
305
+ - **Auto**: Enabled by default, works automatically
306
+ - **Manual**: Available when needed, requires explicit usage
307
+ - **Total Features**: **110+** comprehensive features
308
+
309
+ ---
310
+
311
+ ## ⚙️ Service Configuration Reference
312
+
313
+ ### ServiceOptions Interface
142
314
 
143
315
  ```typescript
144
- import { createApiClient } from '@plyaz/api';
316
+ interface ServiceOptions {
317
+ /**
318
+ * Optional API client instance override
319
+ * Use this when you need a different client configuration
320
+ * The client should have all endpoints from EndpointsList
321
+ */
322
+ apiClient?: ApiClientWithEvents<ClientEventManager, TEndpoints>;
323
+
324
+ /**
325
+ * Optional API configuration updates
326
+ * By default applied with { strategy: 'temporary' } mode (affects only this request)
327
+ * Can be overridden via updateConfigOptions
328
+ */
329
+ apiConfig?: Partial<ApiConfig>;
330
+
331
+ /**
332
+ * Optional update config options
333
+ * Controls how apiConfig is applied to the client
334
+ *
335
+ * Defaults to: { strategy: 'temporary' }
336
+ * - 'temporary': Only affects this request (highest priority)
337
+ * - 'merge': Merges with client config (persists)
338
+ * - 'replace': Replaces client config (persists)
339
+ */
340
+ updateConfigOptions?: UpdateConfigOptions;
341
+ }
145
342
 
146
- const api = createApiClient({
147
- onRequest: (config) => {
148
- const token = localStorage.getItem('auth_token');
149
- if (token) {
150
- config.headers = {
151
- ...config.headers,
152
- Authorization: `Bearer ${token}`
153
- };
154
- }
155
- return config;
156
- }
157
- });
343
+ /**
344
+ * Config update options
345
+ */
346
+ interface UpdateConfigOptions {
347
+ strategy?: ConfigUpdateStrategy;
348
+ priority?: number;
349
+ namespace?: string;
350
+ scope?: string;
351
+ preserveFields?: (keyof ApiConfig)[];
352
+ }
158
353
  ```
159
354
 
160
- ### React/Next.js Integration
355
+ ### Available Unified Strategies
356
+
357
+ | Strategy | Cache | Retry | Use Case | Default For |
358
+ |----------|-------|-------|----------|-------------|
359
+ | **realtime** | None | Low | Live data, mutations | POST/PUT/DELETE |
360
+ | **interactive** | 2min stale, 10min cache | Medium | User-facing lists | GET (lists) |
361
+ | **background** | 10min stale, 30min cache | Medium | Background refreshes | GET (single items) |
362
+ | **mobile** | 5min stale, 15min cache | High | Mobile networks | - |
363
+ | **static** | 1hr stale, 24hr cache | Low | Rarely-changing data | - |
161
364
 
162
- #### Query Hook Usage
365
+ ### Common Configuration Patterns
163
366
 
164
367
  ```typescript
165
- import { useGetUserProfile } from '@plyaz/api/hooks';
368
+ // Pattern 1: Mobile-optimized
369
+ const serviceOptions: ServiceOptions = {
370
+ apiConfig: {
371
+ unifiedStrategy: 'mobile',
372
+ networkAware: { enabled: true, adaptConfig: true },
373
+ retry: { retries: 5, backoff: 2 }
374
+ }
375
+ };
166
376
 
167
- export function UserProfile({ walletAddress }: { walletAddress: string }) {
168
- const { data, error, isLoading } = useGetUserProfile(
169
- { walletAddress },
170
- { includeDetails: true }
171
- );
377
+ // Pattern 2: Real-time dashboard
378
+ const serviceOptions: ServiceOptions = {
379
+ apiConfig: {
380
+ unifiedStrategy: 'realtime',
381
+ revalidationStrategy: 'aggressive',
382
+ cacheStrategy: 'none'
383
+ }
384
+ };
172
385
 
173
- if (isLoading) return <div>Loading...</div>;
174
- if (error) return <div>Error: {error.message}</div>;
386
+ // Pattern 3: Static content
387
+ const serviceOptions: ServiceOptions = {
388
+ apiConfig: {
389
+ unifiedStrategy: 'static',
390
+ cacheStrategy: 'aggressive',
391
+ timeout: 10000
392
+ }
393
+ };
175
394
 
176
- return (
177
- <div>
178
- <h1>{data.username}</h1>
179
- <p>{data.email}</p>
180
- </div>
181
- );
182
- }
395
+ // Pattern 4: Custom fine-tuned
396
+ const serviceOptions: ServiceOptions = {
397
+ apiConfig: {
398
+ timeout: 15000,
399
+ retry: { retries: 3, delay: 2000, backoff: 2 },
400
+ cacheStrategy: 'moderate',
401
+ headers: {
402
+ 'X-Client-Version': '1.0.0',
403
+ 'X-Request-Priority': 'high'
404
+ }
405
+ }
406
+ };
183
407
  ```
184
408
 
185
- #### Mutation Hook Usage
409
+ ---
186
410
 
187
- ```typescript
188
- import { useUpdateUserProfile } from '@plyaz/api/hooks';
411
+ ## 📖 Usage Examples
189
412
 
190
- export function ProfileEditForm({ userId }: { userId: string }) {
191
- const { mutate, isLoading } = useUpdateUserProfile();
413
+ ### React Hooks
192
414
 
193
- const handleSubmit = (formData: UpdateUserRequest) => {
194
- mutate(
195
- {
196
- pathParams: { userId },
197
- body: formData
198
- },
199
- {
200
- onSuccess: (data) => {
201
- console.log('Profile updated:', data);
202
- },
203
- onError: (error) => {
204
- console.error('Update failed:', error);
205
- }
206
- }
207
- );
208
- };
415
+ #### Data Fetching with Services
209
416
 
210
- return (
211
- <form onSubmit={handleSubmit}>
212
- {/* Form fields */}
213
- <button type="submit" disabled={isLoading}>
214
- {isLoading ? 'Updating...' : 'Update Profile'}
215
- </button>
216
- </form>
417
+ ```typescript
418
+ import {
419
+ useCampaigns,
420
+ useCampaign,
421
+ useCreateCampaign,
422
+ useJoinCampaign,
423
+ } from '@plyaz/api/services/campaigns';
424
+ import { useQueryClient } from '@tanstack/react-query';
425
+ import type { ServiceOptions } from '@plyaz/api/services';
426
+
427
+ function CampaignList() {
428
+ const queryClient = useQueryClient();
429
+
430
+ // Basic query with smart defaults
431
+ const { data, isLoading, error } = useCampaigns(
432
+ ['campaigns', 'active'],
433
+ { status: 'active' }
217
434
  );
218
- }
219
- ```
220
435
 
221
- #### Infinite Query for Pagination
436
+ // Query with custom configuration
437
+ const { data: searchResults } = useCampaigns(
438
+ ['campaigns', 'search', searchTerm],
439
+ { search: searchTerm },
440
+ // ServiceOptions - API client config
441
+ {
442
+ apiConfig: {
443
+ timeout: 5000,
444
+ retry: { retries: 2 },
445
+ }
446
+ },
447
+ // UseQueryOptions - React Query config
448
+ {
449
+ enabled: searchTerm.length > 2,
450
+ staleTime: 30000,
451
+ refetchOnWindowFocus: false,
452
+ }
453
+ );
222
454
 
223
- ```typescript
224
- import { useInfiniteTransactions } from '@plyaz/api/hooks';
225
-
226
- export function TransactionList({ walletAddress, chainId }: Props) {
227
- const {
228
- data,
229
- fetchNextPage,
230
- hasNextPage,
231
- isFetchingNextPage
232
- } = useInfiniteTransactions(
233
- { walletAddress, chainId },
234
- { limit: 10 }
455
+ // Single item query with background caching
456
+ const { data: campaign } = useCampaign(
457
+ ['campaign', campaignId],
458
+ { id: campaignId }
459
+ );
460
+
461
+ // Mutation with comprehensive handlers
462
+ const { mutate: createCampaign, isPending } = useCreateCampaign(
463
+ // ServiceOptions for API config
464
+ {
465
+ apiConfig: {
466
+ timeout: 15000,
467
+ headers: { 'X-Campaign-Source': 'web-app' },
468
+ }
469
+ },
470
+ // Mutation options
471
+ {
472
+ onSuccess: (data) => {
473
+ queryClient.invalidateQueries({ queryKey: ['campaigns'] });
474
+ toast.success(`Campaign "${data.name}" created!`);
475
+ },
476
+ onError: (error) => {
477
+ toast.error(`Failed to create: ${error.message}`);
478
+ },
479
+ onMutate: (variables) => {
480
+ // Optimistic update
481
+ const previousCampaigns = queryClient.getQueryData(['campaigns']);
482
+ queryClient.setQueryData(['campaigns'], (old) => [...old, variables]);
483
+ return { previousCampaigns };
484
+ },
485
+ }
235
486
  );
236
487
 
488
+ // Multiple mutations with shared options
489
+ const { mutate: joinCampaign } = useJoinCampaign(undefined, {
490
+ onSuccess: () => {
491
+ queryClient.invalidateQueries({ queryKey: ['campaigns', campaignId] });
492
+ }
493
+ });
494
+
495
+ if (isLoading) return <Spinner />;
496
+ if (error) return <ErrorMessage error={error} />;
497
+
237
498
  return (
238
499
  <div>
239
- {data?.pages.flatMap(page =>
240
- page.transactions.map(tx => (
241
- <div key={tx.id}>{tx.hash}</div>
242
- ))
243
- )}
244
-
245
- {hasNextPage && (
246
- <button onClick={() => fetchNextPage()}>
247
- {isFetchingNextPage ? 'Loading...' : 'Load More'}
248
- </button>
249
- )}
500
+ <CampaignGrid
501
+ campaigns={data}
502
+ onCreate={createCampaign}
503
+ onJoin={joinCampaign}
504
+ isPending={isPending}
505
+ />
250
506
  </div>
251
507
  );
252
508
  }
253
509
  ```
254
510
 
255
- ### Service Functions
511
+ #### Hook Configuration Priority
256
512
 
257
513
  ```typescript
258
- import { getUserProfile, updateUserProfile } from '@plyaz/api/services';
259
-
260
- // Fetch user profile
261
- const profile = await getUserProfile(
262
- { walletAddress: '0x123...' },
263
- { includeDetails: true }
264
- );
265
-
266
- // Update user profile
267
- const updated = await updateUserProfile(
268
- { userId: 'usr-123' },
269
- { username: 'newusername', email: 'new@email.com' }
514
+ // The priority chain (lowest to highest):
515
+ // 1. Factory defaults (from createApiQuery/createApiMutation)
516
+ // 2. Hook-level defaults (when hook was created)
517
+ // 3. ServiceOptions parameter (API config)
518
+ // 4. UseQueryOptions parameter (React Query config)
519
+
520
+ // Example showing all levels:
521
+ const { data } = useCampaigns(
522
+ ['campaigns'],
523
+ { status: 'active' }, // Query parameters
524
+ { apiConfig: { timeout: 10000 } }, // Level 3: Service options
525
+ { staleTime: 60000 } // Level 4: React Query options (highest)
270
526
  );
271
527
  ```
272
528
 
273
- ## API Methods
274
-
275
- ### GET Requests
529
+ #### Monitoring Hooks
276
530
 
277
531
  ```typescript
278
- // Path parameters
279
- const { data } = await api.getUserProfile({
280
- urlPathParams: { walletAddress: '0x123...' }
281
- });
532
+ import { useApiMonitor, useApiNetworkQuality } from '@plyaz/api';
282
533
 
283
- // Query parameters
284
- const { data } = await api.getUsers({
285
- params: { page: 1, limit: 10 }
286
- });
534
+ function Dashboard() {
535
+ const { stats, isHealthy } = useApiMonitor(api);
536
+ const { quality, isOnline } = useApiNetworkQuality();
287
537
 
288
- // Both path and query parameters
289
- const { data } = await api.getNFTs({
290
- urlPathParams: { walletAddress: '0x123...', chainId: 'ethereum' },
291
- params: { tokenType: 'ERC721' }
292
- });
538
+ return <DashboardUI stats={stats} quality={quality} />;
539
+ }
293
540
  ```
294
541
 
295
- ### POST Requests
542
+ ### Service Functions
296
543
 
297
- ```typescript
298
- // Simple POST
299
- const { data } = await api.createUser({
300
- body: { username: 'johndoe', email: 'john@example.com' }
301
- });
544
+ Service functions provide smart defaults based on HTTP method (GET/POST/PUT/DELETE) and allow granular configuration overrides.
302
545
 
303
- // POST with path parameters
304
- const { data } = await api.transferNFT({
305
- urlPathParams: { walletAddress: '0x456...' },
306
- body: { nftId: '123', toAddress: '0x789...' }
307
- });
308
- ```
309
-
310
- ### PUT/PATCH Requests
546
+ #### Basic Usage
311
547
 
312
548
  ```typescript
313
- // PUT request
314
- const { data } = await api.updateUserProfile({
315
- urlPathParams: { userId: '123' },
316
- body: { username: 'newusername' }
317
- });
318
-
319
- // PATCH request
320
- const { data } = await api.patchUserSettings({
321
- urlPathParams: { userId: '123' },
322
- body: { theme: 'dark' }
323
- });
324
- ```
549
+ import { fetchCampaigns, createCampaign } from '@plyaz/api/services/campaigns';
325
550
 
326
- ### DELETE Requests
551
+ // Simple fetch with smart defaults (interactive caching for lists)
552
+ const response = await fetchCampaigns({ status: 'active' });
327
553
 
328
- ```typescript
329
- // DELETE with path parameters
330
- const { data } = await api.deleteUser({
331
- urlPathParams: { userId: '123' }
554
+ // Create with realtime strategy (no cache for mutations)
555
+ const created = await createCampaign({
556
+ name: 'Summer Campaign',
557
+ description: 'Q3 promotional campaign'
332
558
  });
333
559
  ```
334
560
 
335
- ## Configuration
336
-
337
- ### Full Configuration Options
561
+ #### With ServiceOptions Configuration
338
562
 
339
563
  ```typescript
340
- {
341
- // Base configuration
342
- baseURL: process.env.NEXT_PUBLIC_API_URL,
343
- timeout: 30000,
344
- headers: {
345
- 'Content-Type': 'application/json'
346
- },
347
-
348
- // Request management
349
- withCredentials: true,
350
- cancellable: true,
351
- dedupeTime: 1000,
352
-
353
- // Retry configuration
354
- retry: {
355
- retries: 3,
356
- delay: 1000,
357
- backoff: 1.5,
358
- maxDelay: 10000,
359
- retryOn: [408, 429, 500, 502, 503, 504]
360
- },
361
-
362
- // Error handling strategy
363
- strategy: 'softFail', // 'reject' | 'softFail' | 'defaultResponse' | 'silent'
364
-
365
- // Caching
366
- cache: {
367
- cacheTime: 60,
368
- skipCache: (response, config) => config.method !== 'GET'
369
- },
370
-
371
- // Interceptors
372
- onRequest: (config) => config,
373
- onResponse: (response) => response,
374
- onError: (error) => error
375
- }
376
- ```
564
+ import type { ServiceOptions } from '@plyaz/api/services';
565
+
566
+ // Override API client configuration
567
+ const serviceOptions: ServiceOptions = {
568
+ apiConfig: {
569
+ timeout: 15000, // Custom timeout
570
+ retry: { retries: 5, delay: 2000 }, // Aggressive retry
571
+ headers: { 'X-Custom': 'value' }, // Additional headers
572
+ }
573
+ };
377
574
 
378
- ## Advanced Features
575
+ const campaigns = await fetchCampaigns(
576
+ { status: 'active', limit: 50 },
577
+ serviceOptions
578
+ );
379
579
 
380
- ### Request Cancellation
580
+ // Use different strategies
581
+ const realtimeData = await fetchCampaigns(
582
+ { status: 'active' },
583
+ {
584
+ apiConfig: {
585
+ unifiedStrategy: 'realtime', // No cache, always fresh
586
+ revalidationStrategy: 'none',
587
+ }
588
+ }
589
+ );
381
590
 
382
- ```typescript
383
- // Enable automatic cancellation
384
- const { data } = await api.searchUsers({
385
- params: { query: searchTerm },
386
- cancellable: true,
387
- rejectCancelled: true
388
- });
591
+ // Mobile-optimized configuration
592
+ const mobileData = await fetchCampaigns(
593
+ { status: 'active' },
594
+ {
595
+ apiConfig: {
596
+ unifiedStrategy: 'mobile', // Mobile-friendly caching
597
+ networkAware: { enabled: true }, // Adapt to connection
598
+ }
599
+ }
600
+ );
389
601
  ```
390
602
 
391
- ### Request Deduplication
603
+ #### Error Handling Patterns
392
604
 
393
605
  ```typescript
394
- // Deduplicate identical requests within time window
395
- const { data } = await api.getUserProfile({
396
- urlPathParams: { walletAddress: '0x123...' },
397
- dedupeTime: 5000 // 5 seconds
398
- });
399
- ```
606
+ import { isNotFoundError, isValidationError } from '@plyaz/errors';
400
607
 
401
- ### Error Handling Strategies
608
+ // Pattern 1: Check response.error
609
+ const response = await fetchCampaigns({ status: 'active' });
610
+ if (response.error) {
611
+ if (isNotFoundError(response.error)) {
612
+ console.log('No campaigns found');
613
+ }
614
+ return;
615
+ }
616
+ console.log('Campaigns:', response.data);
402
617
 
403
- ```typescript
404
- // Reject strategy (throws errors)
618
+ // Pattern 2: Try-catch with throw
405
619
  try {
406
- const { data } = await api.getUserProfile({
407
- urlPathParams: { walletAddress: '0x123...' },
408
- strategy: 'reject'
409
- });
410
- } catch (error) {
411
- console.error(error);
620
+ const { data, error } = await createCampaign(newCampaign);
621
+ if (error) throw error;
622
+ console.log('Created:', data);
623
+ } catch (err) {
624
+ if (isValidationError(err)) {
625
+ console.error('Invalid data:', err.message);
626
+ }
412
627
  }
628
+ ```
413
629
 
414
- // SoftFail strategy (returns error property)
415
- const { data, error } = await api.getUserProfile({
416
- urlPathParams: { walletAddress: '0x123...' },
417
- strategy: 'softFail'
418
- });
630
+ #### Using Multiple Services
419
631
 
420
- if (error) {
421
- console.error(error);
422
- } else {
423
- console.log(data);
424
- }
632
+ ```typescript
633
+ import {
634
+ fetchCampaign,
635
+ fetchCampaignStats,
636
+ fetchCampaignParticipants,
637
+ } from '@plyaz/api/services/campaigns';
638
+
639
+ // Fetch related data with consistent configuration
640
+ const serviceOpts: ServiceOptions = {
641
+ apiConfig: { timeout: 10000 }
642
+ };
425
643
 
426
- // Silent strategy (fire-and-forget)
427
- api.trackUserActivity({
428
- body: { action: 'page_view' },
429
- strategy: 'silent'
430
- });
644
+ const [campaign, stats, participants] = await Promise.all([
645
+ fetchCampaign({ id: '123' }, serviceOpts),
646
+ fetchCampaignStats({ id: '123' }, serviceOpts),
647
+ fetchCampaignParticipants({ id: '123' }, serviceOpts),
648
+ ]);
431
649
  ```
432
650
 
433
651
  ### Custom Interceptors
434
652
 
435
653
  ```typescript
436
- const apiWithAuth = createApiClient({
437
- onRequest: [
438
- // Add authentication
439
- (config) => {
440
- const token = getAuthToken();
441
- if (token) {
442
- config.headers.Authorization = `Bearer ${token}`;
443
- }
444
- return config;
445
- },
446
- // Add tenant ID
447
- (config) => {
448
- config.headers['X-Tenant-ID'] = getTenantId();
449
- return config;
450
- }
451
- ],
452
-
654
+ const api = await createApiClient({
655
+ onRequest: (config) => {
656
+ config.headers['X-Request-ID'] = generateRequestId();
657
+ return config;
658
+ },
659
+
660
+ onResponse: (response) => {
661
+ console.log(`Request completed in ${response.duration}ms`);
662
+ return response;
663
+ },
664
+
453
665
  onError: (error) => {
454
666
  if (error.status === 401) {
455
- router.push('/login');
667
+ redirectToLogin();
456
668
  }
457
669
  return error;
458
670
  }
459
671
  });
460
672
  ```
461
673
 
462
- ## Error Handling
463
-
464
- ### With @plyaz/errors Integration
674
+ ### Error Handling
465
675
 
466
676
  ```typescript
467
677
  import { isNotFoundError, isValidationError } from '@plyaz/errors';
468
- import { handleApiError } from '@plyaz/api/utils';
469
678
 
470
- const fetchUser = async (walletAddress: string) => {
471
- const { data, error } = await api.getUserProfile({
472
- urlPathParams: { walletAddress },
473
- strategy: 'softFail'
474
- });
475
-
476
- if (error) {
477
- if (isNotFoundError(error)) {
478
- console.log('User not found');
479
- } else if (isValidationError(error)) {
480
- console.log('Invalid parameters');
481
- } else {
482
- const handled = handleApiError(error);
483
- console.error(handled.message);
484
- }
485
- return null;
486
- }
487
-
488
- return data;
489
- };
490
- ```
491
-
492
- ## Pagination Utilities
679
+ const { data, error } = await api.getUser({ id: '123' });
493
680
 
494
- ```typescript
495
- import {
496
- getCursorPaginationParams,
497
- getOffsetPaginationParams,
498
- getPaginationInfo
499
- } from '@plyaz/api/utils';
500
-
501
- // Cursor-based pagination
502
- const cursorParams = getCursorPaginationParams('next_cursor_123', 10);
503
-
504
- // Offset-based pagination
505
- const offsetParams = getOffsetPaginationParams(2, 10); // Page 2, 10 items
506
-
507
- // Extract pagination info
508
- const { data } = await api.getUsers({ params: offsetParams });
509
- const info = getPaginationInfo(data);
510
- console.log(`Page ${info.currentPage} of ${info.totalPages}`);
681
+ if (error) {
682
+ if (isNotFoundError(error)) {
683
+ console.log('User not found');
684
+ } else if (isValidationError(error)) {
685
+ console.log('Invalid parameters');
686
+ }
687
+ }
511
688
  ```
512
689
 
513
- ## Third-Party Integrations
690
+ ---
514
691
 
515
- ### Alchemy API Integration
692
+ ## 🏗️ Architecture
516
693
 
517
- ```typescript
518
- import { AlchemyService } from '@plyaz/api/integrations/alchemy';
519
-
520
- const alchemy = new AlchemyService({
521
- apiKey: process.env.ALCHEMY_API_KEY,
522
- network: 'eth-mainnet'
523
- });
694
+ The @plyaz/api package orchestrates 21 internal modules to provide a seamless API experience:
524
695
 
525
- // Get NFTs for wallet
526
- const nfts = await alchemy.getNFTs({
527
- owner: '0x123...',
528
- withMetadata: true
529
- });
530
-
531
- // Get token balances
532
- const balances = await alchemy.getTokenBalances({
533
- address: '0x123...'
534
- });
696
+ ```
697
+ Your App createApiClient() → Smart Features → fetchff → Your API
698
+
699
+ [Automatic]
700
+ • Retry Logic
701
+ • Caching
702
+ Deduplication
703
+ Network Adaptation
704
+ Event System
705
+ • Performance Tracking
535
706
  ```
536
707
 
537
- ## Platform Architecture Context
538
-
539
- The API client is a critical component of the Plyaz platform's shared package ecosystem:
540
-
541
- ### Frontend Architecture
542
- - **Multiple Apps**: Supports web app, admin panel, and micro apps
543
- - **React Query**: Deep integration for efficient data fetching
544
- - **State Management**: Works with Zustand stores for state synchronization
545
- - **Next.js**: Optimized for server-side rendering and API routes
708
+ **Want to understand how it works?** See the [Architecture Overview](./docs/USAGE.md#architecture-overview) and [Internal Architecture](./docs/INTERNAL.md).
546
709
 
547
- ### Backend Architecture
548
- - **Microservices**: Communicates with distributed NestJS services
549
- - **API Gateway**: Routes through centralized gateway with auth
550
- - **Event-Driven**: Supports async communication patterns
551
- - **GraphQL/REST**: Flexible endpoint configuration
710
+ ---
552
711
 
553
- ## Integration with Other Plyaz Packages
712
+ ## 📚 Documentation
554
713
 
555
- | Package | Integration | Purpose |
556
- |---------|------------|---------|
557
- | **@plyaz/types** | Type definitions | Provides API interfaces and types |
558
- | **@plyaz/errors** | Error handling | Standardized error types and handlers |
559
- | **@plyaz/config** | Configuration | API URLs and environment settings |
560
- | **@plyaz/auth** | Authentication | Token management and auth headers |
561
- | **@plyaz/events** | Event bus | API lifecycle events |
562
- | **@plyaz/logger** | Logging | Request/response logging |
563
- | **@plyaz/web3** | Blockchain | Web3 transaction APIs |
564
- | **@plyaz/monitoring** | Metrics | API performance tracking |
714
+ - **[Usage Guide](./docs/USAGE.md)** - Complete usage documentation with examples
715
+ - **[API Reference](./docs/API-REFERENCE.md)** - Detailed API reference
716
+ - **[Internal Architecture](./docs/INTERNAL.md)** - Deep dive into internal systems
717
+ - **[Confluence Docs](https://plyaz.atlassian.net/wiki/spaces/SD/pages/950316/API+Package)** - Official documentation
565
718
 
566
- ## Type Safety
719
+ ---
567
720
 
568
- ### Endpoint Type Definitions
721
+ ## 🛠️ Development
569
722
 
570
- ```typescript
571
- // Types are imported from @plyaz/types
572
- import type {
573
- UserMethods,
574
- TransactionMethods,
575
- NFTMethods
576
- } from '@plyaz/types/api';
577
-
578
- // Combined interface for all endpoints
579
- export interface EndpointsMethods extends
580
- UserMethods,
581
- TransactionMethods,
582
- NFTMethods {}
583
- ```
723
+ ### Setup
584
724
 
585
- ### Request/Response Types
725
+ ```bash
726
+ # Install dependencies
727
+ pnpm install
586
728
 
587
- ```typescript
588
- import type {
589
- ApiResponse,
590
- PaginatedResponse,
591
- ApiError
592
- } from '@plyaz/types/api';
593
-
594
- // Type-safe responses
595
- type UserResponse = ApiResponse<User>;
596
- type UsersListResponse = PaginatedResponse<User>;
729
+ # Start development mode
730
+ pnpm dev
597
731
  ```
598
732
 
599
- ## Best Practices
733
+ ### Common Commands
600
734
 
601
- ### Service Layer Pattern
602
-
603
- ```typescript
604
- // services/user.ts
605
- export async function getUserProfile(
606
- urlPathParams: GetUserProfilePathParams,
607
- queryParams?: GetUserProfileQueryParams
608
- ): Promise<UserProfile> {
609
- return api.getUserProfile({
610
- urlPathParams,
611
- params: queryParams
612
- });
613
- }
735
+ ```bash
736
+ pnpm dev # Watch mode development
737
+ pnpm build # Build the package
738
+ pnpm test # Run tests
739
+ pnpm test:watch # Watch mode testing
740
+ pnpm test:coverage # Coverage report
741
+ pnpm lint # Lint code
742
+ pnpm type:check # Type checking
614
743
  ```
615
744
 
616
- ### Query Key Management
745
+ ---
617
746
 
618
- ```typescript
619
- // hooks/user/keys.ts
620
- export const userKeys = {
621
- all: ['user'] as const,
622
- lists: () => [...userKeys.all, 'list'] as const,
623
- list: (params: any) => [...userKeys.lists(), params] as const,
624
- profile: (id: string) => [...userKeys.all, 'profile', id] as const
625
- };
626
- ```
747
+ ## 🔗 Integration with Plyaz Packages
627
748
 
628
- ### Error Boundary Integration
749
+ | Package | Purpose | Usage |
750
+ |---------|---------|-------|
751
+ | **@plyaz/types** | Type definitions | API interfaces and types |
752
+ | **@plyaz/errors** | Error handling | Standardized error types |
753
+ | **@plyaz/config** | Configuration | API URLs and constants |
629
754
 
630
- ```typescript
631
- import { ErrorBoundary } from '@plyaz/ui';
632
- import { handleApiError } from '@plyaz/api/utils';
755
+ ---
633
756
 
634
- function MyApp() {
635
- return (
636
- <ErrorBoundary
637
- fallback={<ErrorFallback />}
638
- onError={(error) => {
639
- const handled = handleApiError(error);
640
- logError(handled);
641
- }}
642
- >
643
- <App />
644
- </ErrorBoundary>
645
- );
646
- }
647
- ```
757
+ ## 🎓 Learning Path
648
758
 
649
- ## Migration Guide
759
+ 1. **Beginner**: Start with [Quick Start](#-quick-start) → Try the examples
760
+ 2. **Intermediate**: Read [Usage Guide](./docs/USAGE.md) → Learn patterns
761
+ 3. **Advanced**: Explore [API Reference](./docs/API-REFERENCE.md) → Master configuration
762
+ 4. **Expert**: Study [Internal Architecture](./docs/INTERNAL.md) → Understand internals
650
763
 
651
- ### From Axios
764
+ ---
652
765
 
653
- ```typescript
654
- // Before (Axios)
655
- const response = await axios.get('/api/users/123');
656
- const user = response.data;
766
+ ## 🤝 Contributing
657
767
 
658
- // After (@plyaz/api)
659
- const { data: user } = await api.getUserProfile({
660
- urlPathParams: { userId: '123' }
661
- });
662
- ```
768
+ This package is part of the Plyaz platform. Please follow the [contribution guidelines](https://plyaz.atlassian.net/wiki/spaces/SD/pages/22544393) in the main repository.
663
769
 
664
- ### From Fetch
770
+ ---
665
771
 
666
- ```typescript
667
- // Before (Fetch)
668
- const response = await fetch('/api/users', {
669
- method: 'POST',
670
- headers: { 'Content-Type': 'application/json' },
671
- body: JSON.stringify(userData)
672
- });
673
- const user = await response.json();
772
+ ## 📄 License
674
773
 
675
- // After (@plyaz/api)
676
- const { data: user } = await api.createUser({
677
- body: userData
678
- });
679
- ```
680
-
681
- ## Contributing
774
+ ISC © Plyaz
682
775
 
683
- This package is part of the Plyaz platform. Please follow the contribution guidelines in the main repository.
776
+ ---
684
777
 
685
- ## Resources
778
+ ## 🔗 Links
686
779
 
687
- - [Plyaz Confluence Documentation](https://plyaz.atlassian.net/wiki/spaces/SD/pages/950316/API+Package)
780
+ - [Plyaz Platform Documentation](https://plyaz.atlassian.net/wiki/spaces/SD)
688
781
  - [fetchff Documentation](https://www.npmjs.com/package/fetchff)
689
782
  - [React Query Documentation](https://tanstack.com/query)
690
-
691
- ## License
692
-
693
- ISC © Plyaz
783
+ - [TypeScript Documentation](https://www.typescriptlang.org/)