aziosxjs 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -267
  3. package/dist/cache/memoryCache.d.ts +4 -0
  4. package/dist/cache/memoryCache.js +32 -0
  5. package/dist/cache/memoryCache.js.map +1 -0
  6. package/dist/core/Azios.d.ts +33 -3
  7. package/dist/core/Azios.js +119 -2
  8. package/dist/core/Azios.js.map +1 -1
  9. package/dist/core/createInstance.js +3 -0
  10. package/dist/core/createInstance.js.map +1 -1
  11. package/dist/core/dispatchRequest.d.ts +1 -2
  12. package/dist/core/dispatchRequest.js +68 -42
  13. package/dist/core/dispatchRequest.js.map +1 -1
  14. package/dist/core/requestStore.d.ts +3 -0
  15. package/dist/core/requestStore.js +16 -0
  16. package/dist/core/requestStore.js.map +1 -0
  17. package/dist/errors/AziosError.d.ts +2 -2
  18. package/dist/errors/AziosError.js +6 -3
  19. package/dist/errors/AziosError.js.map +1 -1
  20. package/dist/helpers/buildURL.d.ts +1 -0
  21. package/dist/helpers/buildURL.js +27 -0
  22. package/dist/helpers/buildURL.js.map +1 -1
  23. package/dist/index.d.ts +15 -0
  24. package/dist/index.js +50 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/middleware/MiddlewarePipeline.d.ts +54 -0
  27. package/dist/middleware/MiddlewarePipeline.js +122 -0
  28. package/dist/middleware/MiddlewarePipeline.js.map +1 -0
  29. package/dist/middleware/compose.d.ts +1 -0
  30. package/dist/middleware/compose.js +25 -0
  31. package/dist/middleware/compose.js.map +1 -0
  32. package/dist/middleware/middlewareManager.d.ts +4 -0
  33. package/dist/middleware/middlewareManager.js +12 -0
  34. package/dist/middleware/middlewareManager.js.map +1 -0
  35. package/dist/plugins/pluginManager.d.ts +44 -0
  36. package/dist/plugins/pluginManager.js +120 -0
  37. package/dist/plugins/pluginManager.js.map +1 -0
  38. package/dist/rateLimiter/rateLimiter.d.ts +1 -0
  39. package/dist/rateLimiter/rateLimiter.js +31 -0
  40. package/dist/rateLimiter/rateLimiter.js.map +1 -0
  41. package/dist/runtimes/AdapterFactory.d.ts +22 -0
  42. package/dist/runtimes/AdapterFactory.js +43 -0
  43. package/dist/runtimes/AdapterFactory.js.map +1 -0
  44. package/dist/runtimes/HttpAdapter.d.ts +23 -0
  45. package/dist/runtimes/HttpAdapter.js +10 -0
  46. package/dist/runtimes/HttpAdapter.js.map +1 -0
  47. package/dist/runtimes/UniversalHttpAdapter.d.ts +19 -0
  48. package/dist/runtimes/UniversalHttpAdapter.js +114 -0
  49. package/dist/runtimes/UniversalHttpAdapter.js.map +1 -0
  50. package/dist/runtimes/detectRuntime.d.ts +34 -0
  51. package/dist/runtimes/detectRuntime.js +77 -0
  52. package/dist/runtimes/detectRuntime.js.map +1 -0
  53. package/dist/types/config.d.ts +8 -1
  54. package/dist/types/index.d.ts +5 -0
  55. package/dist/types/index.js +22 -0
  56. package/dist/types/index.js.map +1 -0
  57. package/dist/types/middleware.d.ts +16 -0
  58. package/dist/types/middleware.js +3 -0
  59. package/dist/types/middleware.js.map +1 -0
  60. package/dist/types/plugin.d.ts +43 -0
  61. package/dist/types/plugin.js +3 -0
  62. package/dist/types/plugin.js.map +1 -0
  63. package/dist/types/request.d.ts +15 -0
  64. package/dist/types/response.d.ts +23 -1
  65. package/package.json +24 -5
  66. package/src/adapters/httpAdapter.ts +0 -0
  67. package/src/adapters/index.ts +0 -0
  68. package/src/adapters/xhrAdapter.ts +0 -0
  69. package/src/cache/memoryCache.ts +45 -0
  70. package/src/config/mergeConfig.ts +0 -0
  71. package/src/core/Azios.ts +184 -0
  72. package/src/core/createInstance.ts +23 -0
  73. package/src/core/dispatchRequest.ts +111 -0
  74. package/src/core/requestMethods.ts +0 -0
  75. package/src/core/requestStore.ts +13 -0
  76. package/src/errors/AziosError.ts +26 -0
  77. package/src/helpers/buildURL.ts +44 -0
  78. package/src/helpers/normalizeHeaders.ts +0 -0
  79. package/src/helpers/parseHeaders.ts +0 -0
  80. package/src/index.ts +64 -0
  81. package/src/interceptors/InterceptorManager.ts +30 -0
  82. package/src/middleware/MiddlewarePipeline.ts +155 -0
  83. package/src/middleware/compose.ts +33 -0
  84. package/src/middleware/middlewareManager.ts +9 -0
  85. package/src/plugins/pluginManager.ts +143 -0
  86. package/src/rateLimiter/rateLimiter.ts +36 -0
  87. package/src/runtimes/AdapterFactory.ts +46 -0
  88. package/src/runtimes/HttpAdapter.ts +26 -0
  89. package/src/runtimes/UniversalHttpAdapter.ts +136 -0
  90. package/src/runtimes/detectRuntime.ts +85 -0
  91. package/src/types/config.ts +30 -0
  92. package/src/types/index.ts +5 -0
  93. package/src/types/middleware.ts +21 -0
  94. package/src/types/plugin.ts +50 -0
  95. package/src/types/request.ts +39 -0
  96. package/src/types/response.ts +37 -0
@@ -0,0 +1,30 @@
1
+ export interface AziosRequestConfig {
2
+
3
+ url?: string
4
+ method?: string
5
+
6
+ baseURL?: string
7
+
8
+ headers?: Record<string, any>
9
+
10
+ params?: Record<string, any>
11
+
12
+ data?: any
13
+
14
+ timeout?: number
15
+
16
+ responseType?: string
17
+
18
+ signal?: AbortSignal
19
+
20
+ // Sprint 3
21
+ retry?: number
22
+ retryDelay?: number
23
+
24
+ // Sprint 4
25
+ cache?: boolean
26
+ cacheTTL?: number
27
+
28
+ rateLimit?: number
29
+
30
+ }
@@ -0,0 +1,5 @@
1
+ export * from './config'
2
+ export * from './request'
3
+ export * from './response'
4
+ export * from './plugin'
5
+ export * from './middleware'
@@ -0,0 +1,21 @@
1
+ import { AziosRequestConfig } from './config'
2
+ import { AziosResponse } from './response'
3
+
4
+ /**
5
+ * Middleware function type for request/response processing
6
+ * Koa-style middleware pattern that receives context and next function
7
+ */
8
+ export type AziosMiddleware = (
9
+ config: AziosRequestConfig,
10
+ next: (cfg?: AziosRequestConfig) => Promise<AziosResponse>
11
+ ) => Promise<AziosResponse>
12
+
13
+ /**
14
+ * Middleware context for tracking state across pipeline
15
+ */
16
+ export interface MiddlewareContext {
17
+ startTime?: number
18
+ endTime?: number
19
+ config: AziosRequestConfig
20
+ metadata?: Record<string, any>
21
+ }
@@ -0,0 +1,50 @@
1
+ import { AziosRequestConfig } from './config'
2
+ import { AziosResponse } from './response'
3
+ import type { AziosInstance } from './request'
4
+
5
+ /**
6
+ * Plugin lifecycle hooks
7
+ * Allows plugins to inject behavior at various stages of the request/response pipeline
8
+ */
9
+ export interface PluginHooks {
10
+ /**
11
+ * Called when plugin is installed
12
+ */
13
+ onInstall?(instance: AziosInstance): void | Promise<void>
14
+
15
+ /**
16
+ * Called before request is sent
17
+ */
18
+ beforeRequest?(config: AziosRequestConfig): AziosRequestConfig | Promise<AziosRequestConfig>
19
+
20
+ /**
21
+ * Called after response is received
22
+ */
23
+ afterResponse?(response: AziosResponse): AziosResponse | Promise<AziosResponse>
24
+
25
+ /**
26
+ * Called when an error occurs
27
+ */
28
+ onError?(error: Error): Error | Promise<Error>
29
+
30
+ /**
31
+ * Called when plugin is uninstalled
32
+ */
33
+ onUninstall?(instance: AziosInstance): void | Promise<void>
34
+ }
35
+
36
+ /**
37
+ * Plugin definition with metadata
38
+ */
39
+ export interface AziosPlugin {
40
+ name: string
41
+ version?: string
42
+ hooks: PluginHooks
43
+ }
44
+
45
+ /**
46
+ * Plugin registry to track installed plugins
47
+ */
48
+ export interface PluginRegistry {
49
+ [key: string]: AziosPlugin
50
+ }
@@ -0,0 +1,39 @@
1
+ import { AziosRequestConfig } from "./config"
2
+ import { AziosResponse } from "./response"
3
+ import InterceptorManager from "../interceptors/InterceptorManager"
4
+ import type { AziosPlugin } from "./plugin"
5
+ import type { AziosMiddleware } from "./middleware"
6
+
7
+ export interface AziosInstance {
8
+
9
+ (config: AziosRequestConfig): Promise<AziosResponse>
10
+
11
+ request(config: AziosRequestConfig): Promise<AziosResponse>
12
+
13
+ get(url: string, config?: AziosRequestConfig): Promise<AziosResponse>
14
+
15
+ post(url: string, data?: any, config?: AziosRequestConfig): Promise<AziosResponse>
16
+
17
+ put(url: string, data?: any, config?: AziosRequestConfig): Promise<AziosResponse>
18
+
19
+ patch(url: string, data?: any, config?: AziosRequestConfig): Promise<AziosResponse>
20
+
21
+ delete(url: string, config?: AziosRequestConfig): Promise<AziosResponse>
22
+
23
+ head(url: string, config?: AziosRequestConfig): Promise<AziosResponse>
24
+
25
+ options(url: string, config?: AziosRequestConfig): Promise<AziosResponse>
26
+
27
+ interceptors: {
28
+ request: InterceptorManager<AziosRequestConfig>
29
+ response: InterceptorManager<AziosResponse>
30
+ }
31
+
32
+ // Plugin system
33
+ installPlugin(plugin: AziosPlugin): Promise<void>
34
+ uninstallPlugin(name: string): Promise<void>
35
+
36
+ // Middleware system
37
+ use(middleware: AziosMiddleware): void
38
+
39
+ }
@@ -0,0 +1,37 @@
1
+ import { AziosRequestConfig } from "./config"
2
+
3
+ /**
4
+ * Azios HTTP response object
5
+ * Returned by all request methods
6
+ */
7
+ export interface AziosResponse<T = any> {
8
+ /**
9
+ * Response data (parsed if JSON)
10
+ */
11
+ data: T
12
+
13
+ /**
14
+ * HTTP status code
15
+ */
16
+ status: number
17
+
18
+ /**
19
+ * HTTP status text
20
+ */
21
+ statusText: string
22
+
23
+ /**
24
+ * Response headers
25
+ */
26
+ headers: Record<string, any>
27
+
28
+ /**
29
+ * Original request config
30
+ */
31
+ config: AziosRequestConfig
32
+
33
+ /**
34
+ * Native request object (if available)
35
+ */
36
+ request?: any
37
+ }