@plyaz/api 1.0.1 → 1.1.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.
- package/README.md +632 -542
- package/dist/api/cache/index.d.ts +183 -0
- package/dist/api/cache/index.d.ts.map +1 -0
- package/dist/api/cache/patterns.d.ts +174 -0
- package/dist/api/cache/patterns.d.ts.map +1 -0
- package/dist/api/cache/strategies.d.ts +47 -0
- package/dist/api/cache/strategies.d.ts.map +1 -0
- package/dist/api/client/clientEventManager.d.ts +238 -0
- package/dist/api/client/clientEventManager.d.ts.map +1 -0
- package/dist/api/client/createApiClient.d.ts +5 -0
- package/dist/api/client/createApiClient.d.ts.map +1 -0
- package/dist/api/client/helpers/headers.d.ts +11 -0
- package/dist/api/client/helpers/headers.d.ts.map +1 -0
- package/dist/api/client/helpers/index.d.ts +9 -0
- package/dist/api/client/helpers/index.d.ts.map +1 -0
- package/dist/api/client/helpers/interceptors.d.ts +29 -0
- package/dist/api/client/helpers/interceptors.d.ts.map +1 -0
- package/dist/api/client/helpers/network.d.ts +21 -0
- package/dist/api/client/helpers/network.d.ts.map +1 -0
- package/dist/api/client/helpers/strategies.d.ts +30 -0
- package/dist/api/client/helpers/strategies.d.ts.map +1 -0
- package/dist/api/client/helpers/tracking.d.ts +15 -0
- package/dist/api/client/helpers/tracking.d.ts.map +1 -0
- package/dist/api/client/index.d.ts +7 -0
- package/dist/api/client/index.d.ts.map +1 -0
- package/dist/api/config/adapter.d.ts +25 -0
- package/dist/api/config/adapter.d.ts.map +1 -0
- package/dist/api/config/configBuilder.d.ts +62 -0
- package/dist/api/config/configBuilder.d.ts.map +1 -0
- package/dist/api/config/configManager.d.ts +67 -0
- package/dist/api/config/configManager.d.ts.map +1 -0
- package/dist/api/config/global.d.ts +106 -0
- package/dist/api/config/global.d.ts.map +1 -0
- package/dist/api/config/index.d.ts +11 -0
- package/dist/api/config/index.d.ts.map +1 -0
- package/dist/api/debugger/DebugReport.d.ts +71 -0
- package/dist/api/debugger/DebugReport.d.ts.map +1 -0
- package/dist/api/debugger/UnifiedDebugger.d.ts +444 -0
- package/dist/api/debugger/UnifiedDebugger.d.ts.map +1 -0
- package/dist/api/debugger/factories/conflict.d.ts +58 -0
- package/dist/api/debugger/factories/conflict.d.ts.map +1 -0
- package/dist/api/debugger/factories/eventTracking.d.ts +126 -0
- package/dist/api/debugger/factories/eventTracking.d.ts.map +1 -0
- package/dist/api/debugger/factories/history.d.ts +97 -0
- package/dist/api/debugger/factories/history.d.ts.map +1 -0
- package/dist/api/debugger/factories/index.d.ts +15 -0
- package/dist/api/debugger/factories/index.d.ts.map +1 -0
- package/dist/api/debugger/factories/issueAnalysis.d.ts +52 -0
- package/dist/api/debugger/factories/issueAnalysis.d.ts.map +1 -0
- package/dist/api/debugger/factories/performance.d.ts +53 -0
- package/dist/api/debugger/factories/performance.d.ts.map +1 -0
- package/dist/api/debugger/factories/report.d.ts +43 -0
- package/dist/api/debugger/factories/report.d.ts.map +1 -0
- package/dist/api/debugger/index.d.ts +99 -0
- package/dist/api/debugger/index.d.ts.map +1 -0
- package/dist/api/debugger/queue/DebuggerQueueManager.d.ts +61 -0
- package/dist/api/debugger/queue/DebuggerQueueManager.d.ts.map +1 -0
- package/dist/api/debugger/queue/OperationTracker.d.ts +86 -0
- package/dist/api/debugger/queue/OperationTracker.d.ts.map +1 -0
- package/dist/api/debugger/queue/index.d.ts +9 -0
- package/dist/api/debugger/queue/index.d.ts.map +1 -0
- package/dist/api/endpoints/builders.d.ts +109 -0
- package/dist/api/endpoints/builders.d.ts.map +1 -0
- package/dist/api/endpoints/campaigns.d.ts +43 -0
- package/dist/api/endpoints/campaigns.d.ts.map +1 -0
- package/dist/api/endpoints/index.d.ts +100 -0
- package/dist/api/endpoints/index.d.ts.map +1 -0
- package/dist/api/endpoints/polling.d.ts +83 -0
- package/dist/api/endpoints/polling.d.ts.map +1 -0
- package/dist/api/endpoints/utils.d.ts +128 -0
- package/dist/api/endpoints/utils.d.ts.map +1 -0
- package/dist/api/errors/ApiPackageError.d.ts +101 -0
- package/dist/api/errors/ApiPackageError.d.ts.map +1 -0
- package/dist/api/errors/definitions.d.ts +24 -0
- package/dist/api/errors/definitions.d.ts.map +1 -0
- package/dist/api/errors/error-codes.d.ts +116 -0
- package/dist/api/errors/error-codes.d.ts.map +1 -0
- package/dist/api/errors/error-events.d.ts +63 -0
- package/dist/api/errors/error-events.d.ts.map +1 -0
- package/dist/api/errors/index.d.ts +18 -0
- package/dist/api/errors/index.d.ts.map +1 -0
- package/dist/api/errors/types-constants.d.ts +64 -0
- package/dist/api/errors/types-constants.d.ts.map +1 -0
- package/dist/api/events/EventManager.d.ts +230 -0
- package/dist/api/events/EventManager.d.ts.map +1 -0
- package/dist/api/events/factories/base.d.ts +269 -0
- package/dist/api/events/factories/base.d.ts.map +1 -0
- package/dist/api/events/factories/cache.d.ts +31 -0
- package/dist/api/events/factories/cache.d.ts.map +1 -0
- package/dist/api/events/factories/client.d.ts +43 -0
- package/dist/api/events/factories/client.d.ts.map +1 -0
- package/dist/api/events/factories/config.d.ts +34 -0
- package/dist/api/events/factories/config.d.ts.map +1 -0
- package/dist/api/events/factories/debug.d.ts +74 -0
- package/dist/api/events/factories/debug.d.ts.map +1 -0
- package/dist/api/events/factories/errors.d.ts +91 -0
- package/dist/api/events/factories/errors.d.ts.map +1 -0
- package/dist/api/events/factories/headers.d.ts +54 -0
- package/dist/api/events/factories/headers.d.ts.map +1 -0
- package/dist/api/events/factories/index.d.ts +46 -0
- package/dist/api/events/factories/index.d.ts.map +1 -0
- package/dist/api/events/factories/network.d.ts +54 -0
- package/dist/api/events/factories/network.d.ts.map +1 -0
- package/dist/api/events/factories/performance.d.ts +43 -0
- package/dist/api/events/factories/performance.d.ts.map +1 -0
- package/dist/api/events/index.d.ts +34 -0
- package/dist/api/events/index.d.ts.map +1 -0
- package/dist/api/events/namespaces.d.ts +464 -0
- package/dist/api/events/namespaces.d.ts.map +1 -0
- package/dist/api/events/queue/ConfigUpdateQueueManager.d.ts +53 -0
- package/dist/api/events/queue/ConfigUpdateQueueManager.d.ts.map +1 -0
- package/dist/api/events/queue/EventQueueManager.d.ts +69 -0
- package/dist/api/events/queue/EventQueueManager.d.ts.map +1 -0
- package/dist/api/events/queue/index.d.ts +12 -0
- package/dist/api/events/queue/index.d.ts.map +1 -0
- package/dist/api/events/shared-emitter.d.ts +14 -0
- package/dist/api/events/shared-emitter.d.ts.map +1 -0
- package/dist/api/headers/cache.d.ts +17 -0
- package/dist/api/headers/cache.d.ts.map +1 -0
- package/dist/api/headers/enriched.d.ts +18 -0
- package/dist/api/headers/enriched.d.ts.map +1 -0
- package/dist/api/headers/events.d.ts +17 -0
- package/dist/api/headers/events.d.ts.map +1 -0
- package/dist/api/headers/extract.d.ts +73 -0
- package/dist/api/headers/extract.d.ts.map +1 -0
- package/dist/api/headers/headerBuilder.d.ts +308 -0
- package/dist/api/headers/headerBuilder.d.ts.map +1 -0
- package/dist/api/headers/index.d.ts +37 -0
- package/dist/api/headers/index.d.ts.map +1 -0
- package/dist/api/headers/merge.d.ts +32 -0
- package/dist/api/headers/merge.d.ts.map +1 -0
- package/dist/api/headers/presets.d.ts +24 -0
- package/dist/api/headers/presets.d.ts.map +1 -0
- package/dist/api/headers/utils.d.ts +38 -0
- package/dist/api/headers/utils.d.ts.map +1 -0
- package/dist/api/hooks/factories/createApiMutation.d.ts +57 -0
- package/dist/api/hooks/factories/createApiMutation.d.ts.map +1 -0
- package/dist/api/hooks/factories/createApiQuery.d.ts +55 -0
- package/dist/api/hooks/factories/createApiQuery.d.ts.map +1 -0
- package/dist/api/hooks/factories/defaults.d.ts +15 -0
- package/dist/api/hooks/factories/defaults.d.ts.map +1 -0
- package/dist/api/hooks/factories/index.d.ts +8 -0
- package/dist/api/hooks/factories/index.d.ts.map +1 -0
- package/dist/api/hooks/index.d.ts +11 -0
- package/dist/api/hooks/index.d.ts.map +1 -0
- package/dist/api/hooks/types.d.ts +82 -0
- package/dist/api/hooks/types.d.ts.map +1 -0
- package/dist/api/hooks/useApiConfigConflicts.d.ts +24 -0
- package/dist/api/hooks/useApiConfigConflicts.d.ts.map +1 -0
- package/dist/api/hooks/useApiDebugInfo.d.ts +24 -0
- package/dist/api/hooks/useApiDebugInfo.d.ts.map +1 -0
- package/dist/api/hooks/useApiMonitor.d.ts +25 -0
- package/dist/api/hooks/useApiMonitor.d.ts.map +1 -0
- package/dist/api/hooks/useApiNetworkQuality.d.ts +21 -0
- package/dist/api/hooks/useApiNetworkQuality.d.ts.map +1 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/network/adaptive.d.ts +56 -0
- package/dist/api/network/adaptive.d.ts.map +1 -0
- package/dist/api/network/client-hints.d.ts +25 -0
- package/dist/api/network/client-hints.d.ts.map +1 -0
- package/dist/api/network/connection.d.ts +60 -0
- package/dist/api/network/connection.d.ts.map +1 -0
- package/dist/api/network/core.d.ts +26 -0
- package/dist/api/network/core.d.ts.map +1 -0
- package/dist/api/network/events.d.ts +18 -0
- package/dist/api/network/events.d.ts.map +1 -0
- package/dist/api/network/frameworks/express.d.ts +110 -0
- package/dist/api/network/frameworks/express.d.ts.map +1 -0
- package/dist/api/network/frameworks/index.d.ts +13 -0
- package/dist/api/network/frameworks/index.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/clientHintsInterceptor.d.ts +29 -0
- package/dist/api/network/frameworks/nestjs/clientHintsInterceptor.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/decorators.d.ts +48 -0
- package/dist/api/network/frameworks/nestjs/decorators.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/enrichedHeadersGuard.d.ts +80 -0
- package/dist/api/network/frameworks/nestjs/enrichedHeadersGuard.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/enrichedHeadersInterceptor.d.ts +83 -0
- package/dist/api/network/frameworks/nestjs/enrichedHeadersInterceptor.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/index.d.ts +13 -0
- package/dist/api/network/frameworks/nestjs/index.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/minimumConnectionGuard.d.ts +27 -0
- package/dist/api/network/frameworks/nestjs/minimumConnectionGuard.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/networkDetectionMiddleware.d.ts +31 -0
- package/dist/api/network/frameworks/nestjs/networkDetectionMiddleware.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/networkGuard.d.ts +33 -0
- package/dist/api/network/frameworks/nestjs/networkGuard.d.ts.map +1 -0
- package/dist/api/network/frameworks/nestjs/noDataSaverGuard.d.ts +25 -0
- package/dist/api/network/frameworks/nestjs/noDataSaverGuard.d.ts.map +1 -0
- package/dist/api/network/frameworks/nextjs.d.ts +86 -0
- package/dist/api/network/frameworks/nextjs.d.ts.map +1 -0
- package/dist/api/network/frameworks/shared.d.ts +45 -0
- package/dist/api/network/frameworks/shared.d.ts.map +1 -0
- package/dist/api/network/headers.d.ts +112 -0
- package/dist/api/network/headers.d.ts.map +1 -0
- package/dist/api/network/index.d.ts +17 -0
- package/dist/api/network/index.d.ts.map +1 -0
- package/dist/api/network/networkConfigurationManager.d.ts +225 -0
- package/dist/api/network/networkConfigurationManager.d.ts.map +1 -0
- package/dist/api/network/platform.d.ts +171 -0
- package/dist/api/network/platform.d.ts.map +1 -0
- package/dist/api/network/presets.d.ts +55 -0
- package/dist/api/network/presets.d.ts.map +1 -0
- package/dist/api/network/quality.d.ts +28 -0
- package/dist/api/network/quality.d.ts.map +1 -0
- package/dist/api/network/status.d.ts +74 -0
- package/dist/api/network/status.d.ts.map +1 -0
- package/dist/api/performance/adaptive.d.ts +35 -0
- package/dist/api/performance/adaptive.d.ts.map +1 -0
- package/dist/api/performance/index.d.ts +133 -0
- package/dist/api/performance/index.d.ts.map +1 -0
- package/dist/api/performance/patterns.d.ts +20 -0
- package/dist/api/performance/patterns.d.ts.map +1 -0
- package/dist/api/performance/performanceMonitor.d.ts +85 -0
- package/dist/api/performance/performanceMonitor.d.ts.map +1 -0
- package/dist/api/performance/presets.d.ts +18 -0
- package/dist/api/performance/presets.d.ts.map +1 -0
- package/dist/api/performance/utils.d.ts +98 -0
- package/dist/api/performance/utils.d.ts.map +1 -0
- package/dist/api/polling/index.d.ts +10 -0
- package/dist/api/polling/index.d.ts.map +1 -0
- package/dist/api/polling/strategies.d.ts +128 -0
- package/dist/api/polling/strategies.d.ts.map +1 -0
- package/dist/api/polling/utils.d.ts +133 -0
- package/dist/api/polling/utils.d.ts.map +1 -0
- package/dist/api/pubsub/index.d.ts +147 -0
- package/dist/api/pubsub/index.d.ts.map +1 -0
- package/dist/api/pubsub/react.d.ts +214 -0
- package/dist/api/pubsub/react.d.ts.map +1 -0
- package/dist/api/queue/BaseOperationTracker.d.ts +86 -0
- package/dist/api/queue/BaseOperationTracker.d.ts.map +1 -0
- package/dist/api/queue/BaseQueueManager.d.ts +54 -0
- package/dist/api/queue/BaseQueueManager.d.ts.map +1 -0
- package/dist/api/queue/BatchProcessor.d.ts +42 -0
- package/dist/api/queue/BatchProcessor.d.ts.map +1 -0
- package/dist/api/queue/EventQueueManager.d.ts +128 -0
- package/dist/api/queue/EventQueueManager.d.ts.map +1 -0
- package/dist/api/queue/PriorityQueue.d.ts +58 -0
- package/dist/api/queue/PriorityQueue.d.ts.map +1 -0
- package/dist/api/queue/QueueFactory.d.ts +57 -0
- package/dist/api/queue/QueueFactory.d.ts.map +1 -0
- package/dist/api/queue/QueueOrchestrator.d.ts +90 -0
- package/dist/api/queue/QueueOrchestrator.d.ts.map +1 -0
- package/dist/api/queue/QueueSystem.d.ts +102 -0
- package/dist/api/queue/QueueSystem.d.ts.map +1 -0
- package/dist/api/queue/index.d.ts +22 -0
- package/dist/api/queue/index.d.ts.map +1 -0
- package/dist/api/regional/constants.d.ts +76 -0
- package/dist/api/regional/constants.d.ts.map +1 -0
- package/dist/api/regional/core.d.ts +56 -0
- package/dist/api/regional/core.d.ts.map +1 -0
- package/dist/api/regional/helpers.d.ts +49 -0
- package/dist/api/regional/helpers.d.ts.map +1 -0
- package/dist/api/regional/index.d.ts +10 -0
- package/dist/api/regional/index.d.ts.map +1 -0
- package/dist/api/regional/presets.d.ts +16 -0
- package/dist/api/regional/presets.d.ts.map +1 -0
- package/dist/api/request/index.d.ts +18 -0
- package/dist/api/request/index.d.ts.map +1 -0
- package/dist/api/request/management.d.ts +46 -0
- package/dist/api/request/management.d.ts.map +1 -0
- package/dist/api/request/prepare.d.ts +34 -0
- package/dist/api/request/prepare.d.ts.map +1 -0
- package/dist/api/request/react.d.ts +98 -0
- package/dist/api/request/react.d.ts.map +1 -0
- package/dist/api/request/routing.d.ts +74 -0
- package/dist/api/request/routing.d.ts.map +1 -0
- package/dist/api/request/tracker.d.ts +76 -0
- package/dist/api/request/tracker.d.ts.map +1 -0
- package/dist/api/request/utils.d.ts +129 -0
- package/dist/api/request/utils.d.ts.map +1 -0
- package/dist/api/retry/conditions.d.ts +140 -0
- package/dist/api/retry/conditions.d.ts.map +1 -0
- package/dist/api/retry/index.d.ts +10 -0
- package/dist/api/retry/index.d.ts.map +1 -0
- package/dist/api/retry/strategies.d.ts +56 -0
- package/dist/api/retry/strategies.d.ts.map +1 -0
- package/dist/api/revalidation/index.d.ts +29 -0
- package/dist/api/revalidation/index.d.ts.map +1 -0
- package/dist/api/revalidation/presets.d.ts +71 -0
- package/dist/api/revalidation/presets.d.ts.map +1 -0
- package/dist/api/revalidation/strategies.d.ts +116 -0
- package/dist/api/revalidation/strategies.d.ts.map +1 -0
- package/dist/api/revalidation/utils.d.ts +78 -0
- package/dist/api/revalidation/utils.d.ts.map +1 -0
- package/dist/api/services/campaigns/DELETE/deleteCampaign.d.ts +30 -0
- package/dist/api/services/campaigns/DELETE/deleteCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/DELETE/index.d.ts +7 -0
- package/dist/api/services/campaigns/DELETE/index.d.ts.map +1 -0
- package/dist/api/services/campaigns/DELETE/useDeleteCampaign.d.ts +24 -0
- package/dist/api/services/campaigns/DELETE/useDeleteCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/fetchCampaign.d.ts +36 -0
- package/dist/api/services/campaigns/GET/fetchCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/fetchCampaignParticipants.d.ts +40 -0
- package/dist/api/services/campaigns/GET/fetchCampaignParticipants.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/fetchCampaignStats.d.ts +31 -0
- package/dist/api/services/campaigns/GET/fetchCampaignStats.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts +39 -0
- package/dist/api/services/campaigns/GET/fetchCampaigns.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/index.d.ts +13 -0
- package/dist/api/services/campaigns/GET/index.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/useCampaign.d.ts +47 -0
- package/dist/api/services/campaigns/GET/useCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts +43 -0
- package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/useCampaignStats.d.ts +33 -0
- package/dist/api/services/campaigns/GET/useCampaignStats.d.ts.map +1 -0
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts +43 -0
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/createCampaign.d.ts +37 -0
- package/dist/api/services/campaigns/POST/createCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/index.d.ts +11 -0
- package/dist/api/services/campaigns/POST/index.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/joinCampaign.d.ts +31 -0
- package/dist/api/services/campaigns/POST/joinCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/leaveCampaign.d.ts +31 -0
- package/dist/api/services/campaigns/POST/leaveCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts +36 -0
- package/dist/api/services/campaigns/POST/useCreateCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/useJoinCampaign.d.ts +23 -0
- package/dist/api/services/campaigns/POST/useJoinCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/POST/useLeaveCampaign.d.ts +23 -0
- package/dist/api/services/campaigns/POST/useLeaveCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/PUT/index.d.ts +7 -0
- package/dist/api/services/campaigns/PUT/index.d.ts.map +1 -0
- package/dist/api/services/campaigns/PUT/updateCampaign.d.ts +37 -0
- package/dist/api/services/campaigns/PUT/updateCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts +38 -0
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts.map +1 -0
- package/dist/api/services/campaigns/index.d.ts +9 -0
- package/dist/api/services/campaigns/index.d.ts.map +1 -0
- package/dist/api/services/clients.d.ts +58 -0
- package/dist/api/services/clients.d.ts.map +1 -0
- package/dist/api/services/index.d.ts +8 -0
- package/dist/api/services/index.d.ts.map +1 -0
- package/dist/api/services/types.d.ts +65 -0
- package/dist/api/services/types.d.ts.map +1 -0
- package/dist/api/strategies/index.d.ts +8 -0
- package/dist/api/strategies/index.d.ts.map +1 -0
- package/dist/api/strategies/tracked.d.ts +15 -0
- package/dist/api/strategies/tracked.d.ts.map +1 -0
- package/dist/api/strategies/unified.d.ts +87 -0
- package/dist/api/strategies/unified.d.ts.map +1 -0
- package/dist/api/utils/async-control.d.ts +96 -0
- package/dist/api/utils/async-control.d.ts.map +1 -0
- package/dist/api/utils/colors.d.ts +88 -0
- package/dist/api/utils/colors.d.ts.map +1 -0
- package/dist/api/utils/environment.d.ts +595 -0
- package/dist/api/utils/environment.d.ts.map +1 -0
- package/dist/api/utils/generation/correlation-id.d.ts +206 -0
- package/dist/api/utils/generation/correlation-id.d.ts.map +1 -0
- package/dist/api/utils/generation/id-generator.d.ts +133 -0
- package/dist/api/utils/generation/id-generator.d.ts.map +1 -0
- package/dist/api/utils/generation/request-id.d.ts +106 -0
- package/dist/api/utils/generation/request-id.d.ts.map +1 -0
- package/dist/api/utils/index.d.ts +19 -0
- package/dist/api/utils/index.d.ts.map +1 -0
- package/dist/api/utils/interval-manager.d.ts +94 -0
- package/dist/api/utils/interval-manager.d.ts.map +1 -0
- package/dist/api/utils/json.d.ts +98 -0
- package/dist/api/utils/json.d.ts.map +1 -0
- package/dist/api/utils/math.d.ts +168 -0
- package/dist/api/utils/math.d.ts.map +1 -0
- package/dist/api/utils/object-merge.d.ts +34 -0
- package/dist/api/utils/object-merge.d.ts.map +1 -0
- package/dist/api/utils/object.d.ts +101 -0
- package/dist/api/utils/object.d.ts.map +1 -0
- package/dist/api/utils/string.d.ts +41 -0
- package/dist/api/utils/string.d.ts.map +1 -0
- package/dist/api/utils/time.d.ts +233 -0
- package/dist/api/utils/time.d.ts.map +1 -0
- package/dist/api/utils/type-guards.d.ts +59 -0
- package/dist/api/utils/type-guards.d.ts.map +1 -0
- package/dist/api/utils/validation.d.ts +21 -0
- package/dist/api/utils/validation.d.ts.map +1 -0
- package/dist/index.cjs +25594 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +25068 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -7
package/README.md
CHANGED
|
@@ -1,693 +1,783 @@
|
|
|
1
1
|
# @plyaz/api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> ⚡ Smart, type-safe API client for the Plyaz ecosystem with zero-configuration intelligence
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://github.com/Plyaz-Official/api)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](LICENSE)
|
|
6
8
|
|
|
7
|
-
|
|
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
|
-
|
|
11
|
+
---
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## ✨ Why @plyaz/api?
|
|
12
14
|
|
|
13
|
-
|
|
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
|
-
|
|
17
|
+
The API client works intelligently out of the box:
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 📦 Installation
|
|
30
43
|
|
|
31
|
-
|
|
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
|
-
|
|
52
|
+
---
|
|
37
53
|
|
|
38
|
-
|
|
39
|
-
# Clone the repository
|
|
40
|
-
git clone https://github.com/Plyaz-Official/api.git
|
|
41
|
-
cd api
|
|
54
|
+
## 🚀 Quick Start
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
pnpm install
|
|
56
|
+
### Simple REST API (2 lines)
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
const api = await createApiClient({ baseURL: 'https://api.example.com' });
|
|
60
|
+
const { data } = await api.getUsers();
|
|
48
61
|
```
|
|
49
62
|
|
|
50
|
-
###
|
|
63
|
+
### Authenticated API
|
|
51
64
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
122
|
-
|
|
123
|
-
#### Initialize API Client
|
|
84
|
+
### Real-Time Dashboard
|
|
124
85
|
|
|
125
86
|
```typescript
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
365
|
+
### Common Configuration Patterns
|
|
163
366
|
|
|
164
367
|
```typescript
|
|
165
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
174
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
409
|
+
---
|
|
186
410
|
|
|
187
|
-
|
|
188
|
-
import { useUpdateUserProfile } from '@plyaz/api/hooks';
|
|
411
|
+
## 📖 Usage Examples
|
|
189
412
|
|
|
190
|
-
|
|
191
|
-
const { mutate, isLoading } = useUpdateUserProfile();
|
|
413
|
+
### React Hooks
|
|
192
414
|
|
|
193
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
511
|
+
#### Hook Configuration Priority
|
|
256
512
|
|
|
257
513
|
```typescript
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
{
|
|
269
|
-
{
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
### GET Requests
|
|
529
|
+
#### Monitoring Hooks
|
|
276
530
|
|
|
277
531
|
```typescript
|
|
278
|
-
|
|
279
|
-
const { data } = await api.getUserProfile({
|
|
280
|
-
urlPathParams: { walletAddress: '0x123...' }
|
|
281
|
-
});
|
|
532
|
+
import { useApiMonitor, useApiNetworkQuality } from '@plyaz/api';
|
|
282
533
|
|
|
283
|
-
|
|
284
|
-
const {
|
|
285
|
-
|
|
286
|
-
});
|
|
534
|
+
function Dashboard() {
|
|
535
|
+
const { stats, isHealthy } = useApiMonitor(api);
|
|
536
|
+
const { quality, isOnline } = useApiNetworkQuality();
|
|
287
537
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
urlPathParams: { walletAddress: '0x123...', chainId: 'ethereum' },
|
|
291
|
-
params: { tokenType: 'ERC721' }
|
|
292
|
-
});
|
|
538
|
+
return <DashboardUI stats={stats} quality={quality} />;
|
|
539
|
+
}
|
|
293
540
|
```
|
|
294
541
|
|
|
295
|
-
###
|
|
542
|
+
### Service Functions
|
|
296
543
|
|
|
297
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
551
|
+
// Simple fetch with smart defaults (interactive caching for lists)
|
|
552
|
+
const response = await fetchCampaigns({ status: 'active' });
|
|
327
553
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
336
|
-
|
|
337
|
-
### Full Configuration Options
|
|
561
|
+
#### With ServiceOptions Configuration
|
|
338
562
|
|
|
339
563
|
```typescript
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
575
|
+
const campaigns = await fetchCampaigns(
|
|
576
|
+
{ status: 'active', limit: 50 },
|
|
577
|
+
serviceOptions
|
|
578
|
+
);
|
|
379
579
|
|
|
380
|
-
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
603
|
+
#### Error Handling Patterns
|
|
392
604
|
|
|
393
605
|
```typescript
|
|
394
|
-
|
|
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
|
-
|
|
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
|
-
|
|
404
|
-
// Reject strategy (throws errors)
|
|
618
|
+
// Pattern 2: Try-catch with throw
|
|
405
619
|
try {
|
|
406
|
-
const { data } = await
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
-
|
|
415
|
-
const { data, error } = await api.getUserProfile({
|
|
416
|
-
urlPathParams: { walletAddress: '0x123...' },
|
|
417
|
-
strategy: 'softFail'
|
|
418
|
-
});
|
|
630
|
+
#### Using Multiple Services
|
|
419
631
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
|
437
|
-
onRequest:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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
|
-
|
|
667
|
+
redirectToLogin();
|
|
456
668
|
}
|
|
457
669
|
return error;
|
|
458
670
|
}
|
|
459
671
|
});
|
|
460
672
|
```
|
|
461
673
|
|
|
462
|
-
|
|
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
|
|
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
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
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
|
-
|
|
690
|
+
---
|
|
514
691
|
|
|
515
|
-
|
|
692
|
+
## 🏗️ Architecture
|
|
516
693
|
|
|
517
|
-
|
|
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
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
712
|
+
## 📚 Documentation
|
|
554
713
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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
|
-
|
|
719
|
+
---
|
|
567
720
|
|
|
568
|
-
|
|
721
|
+
## 🛠️ Development
|
|
569
722
|
|
|
570
|
-
|
|
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
|
-
|
|
725
|
+
```bash
|
|
726
|
+
# Install dependencies
|
|
727
|
+
pnpm install
|
|
586
728
|
|
|
587
|
-
|
|
588
|
-
|
|
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
|
-
|
|
733
|
+
### Common Commands
|
|
600
734
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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
|
-
|
|
745
|
+
---
|
|
617
746
|
|
|
618
|
-
|
|
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
|
-
|
|
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
|
-
|
|
631
|
-
import { ErrorBoundary } from '@plyaz/ui';
|
|
632
|
-
import { handleApiError } from '@plyaz/api/utils';
|
|
755
|
+
---
|
|
633
756
|
|
|
634
|
-
|
|
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
|
-
|
|
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
|
-
|
|
764
|
+
---
|
|
652
765
|
|
|
653
|
-
|
|
654
|
-
// Before (Axios)
|
|
655
|
-
const response = await axios.get('/api/users/123');
|
|
656
|
-
const user = response.data;
|
|
766
|
+
## 🤝 Contributing
|
|
657
767
|
|
|
658
|
-
|
|
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
|
-
|
|
770
|
+
---
|
|
665
771
|
|
|
666
|
-
|
|
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
|
-
|
|
676
|
-
const { data: user } = await api.createUser({
|
|
677
|
-
body: userData
|
|
678
|
-
});
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
## Contributing
|
|
774
|
+
ISC © Plyaz
|
|
682
775
|
|
|
683
|
-
|
|
776
|
+
---
|
|
684
777
|
|
|
685
|
-
##
|
|
778
|
+
## 🔗 Links
|
|
686
779
|
|
|
687
|
-
- [Plyaz
|
|
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/)
|