@revenium/perplexity 2.0.5 → 2.0.6

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 (45) hide show
  1. package/CHANGELOG.md +113 -97
  2. package/LICENSE +21 -21
  3. package/README.md +292 -290
  4. package/SECURITY.md +34 -34
  5. package/dist/cjs/core/client/manager.js +6 -3
  6. package/dist/cjs/core/client/manager.js.map +1 -1
  7. package/dist/cjs/core/config/validator.js +18 -16
  8. package/dist/cjs/core/config/validator.js.map +1 -1
  9. package/dist/cjs/core/middleware/interfaces.js +4 -4
  10. package/dist/cjs/core/middleware/interfaces.js.map +1 -1
  11. package/dist/cjs/core/middleware/streaming-wrapper.js +4 -4
  12. package/dist/cjs/core/middleware/streaming-wrapper.js.map +1 -1
  13. package/dist/cjs/core/tracking/api-client.js +3 -3
  14. package/dist/cjs/core/tracking/api-client.js.map +1 -1
  15. package/dist/cjs/index.js +1 -6
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/esm/core/client/manager.js +6 -3
  18. package/dist/esm/core/client/manager.js.map +1 -1
  19. package/dist/esm/core/config/validator.js +18 -16
  20. package/dist/esm/core/config/validator.js.map +1 -1
  21. package/dist/esm/core/middleware/interfaces.js +1 -1
  22. package/dist/esm/core/middleware/interfaces.js.map +1 -1
  23. package/dist/esm/core/middleware/streaming-wrapper.js +2 -2
  24. package/dist/esm/core/middleware/streaming-wrapper.js.map +1 -1
  25. package/dist/esm/core/tracking/api-client.js +1 -1
  26. package/dist/esm/core/tracking/api-client.js.map +1 -1
  27. package/dist/esm/index.js +0 -4
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/types/core/client/manager.d.ts.map +1 -1
  30. package/dist/types/core/config/validator.d.ts.map +1 -1
  31. package/dist/types/index.d.ts +0 -5
  32. package/dist/types/index.d.ts.map +1 -1
  33. package/examples/README.md +226 -226
  34. package/examples/advanced.ts +123 -123
  35. package/examples/basic.ts +45 -45
  36. package/examples/getting_started.ts +41 -41
  37. package/examples/metadata.ts +68 -68
  38. package/examples/stream.ts +53 -53
  39. package/package.json +72 -71
  40. package/dist/cjs/constants/models.js +0 -38
  41. package/dist/cjs/constants/models.js.map +0 -1
  42. package/dist/esm/constants/models.js +0 -35
  43. package/dist/esm/constants/models.js.map +0 -1
  44. package/dist/types/constants/models.d.ts +0 -39
  45. package/dist/types/constants/models.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,97 +1,113 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ## [2.0.5] - 2025-11-09
11
-
12
- ### Added
13
- - New `Initialize()` and `GetClient()` pattern for cleaner client initialization
14
- - `Configure()` function for explicit configuration without environment variables
15
- - `IsInitialized()` and `Reset()` utility functions for better state management
16
- - Automatic `.env` file loading via dotenv for simplified configuration
17
- - Modular architecture with organized `core/` directory structure
18
- - Enhanced examples: `basic.ts`, `metadata.ts`, `advanced.ts`, `stream.ts`
19
- - Export `PERPLEXITY_MODELS` constants (SONAR_PRO, SONAR, SONAR_REASONING)
20
- - Export `PerplexityModel` type for type-safe model references
21
- - Support for all 7 AI operation types (CHAT, GENERATE, EMBED, CLASSIFY, SUMMARIZE, TRANSLATE, OTHER)
22
-
23
- ### Changed
24
- - Improved API compliance with Revenium specification for provider naming and metadata
25
- - Enhanced token counting accuracy with proper handling of cache tokens
26
- - Email addresses now masked in debug logs for PII protection
27
- - Quality scores use 0.0-1.0 scale per API specification
28
- - Removed hardcoded model lists - middleware accepts any model name
29
-
30
- ### Fixed
31
- - ESM support by removing CommonJS type restriction and adding explicit `.js` extensions
32
- - API key validation now enforced in `Configure()` function
33
- - Base URL validation relaxed to accept default endpoints
34
- - npm script references corrected in documentation
35
- - Environment variable examples updated for clarity
36
-
37
- ## [2.0.4] - 2025-10-21
38
-
39
- ### Changed
40
-
41
- - Enhanced package.json with examples in files array
42
- - Added community health files (CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md)
43
- - Updated .gitignore with security report patterns
44
- - Added engines field for Node.js version requirements
45
-
46
- ## [2.0.3] - 2025-10-17
47
-
48
- ### Changed
49
-
50
- - Documentation improvements with absolute path references
51
-
52
- ## [2.0.2] - 2025-10-09
53
-
54
- ### Changed
55
-
56
- - Internal updates and improvements
57
-
58
- ## [2.0.1] - 2025-10-09
59
-
60
- ### Changed
61
-
62
- - Bug fixes and stability improvements
63
-
64
- ## [2.0.0] - 2025-10-09
65
-
66
- ### Added
67
-
68
- - Complete code restructuring with core/ directory organization
69
- - Dual package exports (ESM + CommonJS) support
70
- - TypeScript declaration maps for better debugging
71
- - Enhanced build system with separate CJS, ESM, and types builds
72
-
73
- ### Changed
74
-
75
- - Restructured src/ directory with core/config, core/tracking, core/wrapper
76
- - Enhanced README with comprehensive documentation
77
-
78
- ## [1.0.0] - 2025-09-23
79
-
80
- ### Added
81
-
82
- - Initial release of Perplexity AI middleware
83
- - Automatic token counting and usage tracking
84
- - Streaming support with automatic tracking
85
- - Custom metadata integration
86
- - TypeScript support with full type safety
87
- - Comprehensive error handling
88
- - Background processing for non-blocking tracking
89
- - Debug logging support
90
-
91
- [2.0.5]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.5
92
- [2.0.4]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.4
93
- [2.0.3]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.3
94
- [2.0.2]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.2
95
- [2.0.1]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.1
96
- [2.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.0
97
- [1.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v1.0.0
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [3.0.0] - 2025-11-08
11
+
12
+ ### Added
13
+
14
+ - Initialize()/GetClient() pattern
15
+ - Configure() function for manual configuration
16
+ - IsInitialized() function to check initialization state
17
+ - Reset() function for testing scenarios
18
+ - Automatic .env file loading via dotenv
19
+ - Complete modular architecture with core/ directory structure
20
+ - New examples: basic.ts, metadata.ts, advanced.ts, stream.ts (renamed from streaming.ts)
21
+ - COST_LIMIT and COMPLETION_LIMIT stop reasons to mapper (per API spec)
22
+ - Support for all 7 operationType enum values (CHAT, GENERATE, EMBED, CLASSIFY, SUMMARIZE, TRANSLATE, OTHER)
23
+
24
+ ### Changed
25
+
26
+ - **BREAKING:** Complete API redesign to pattern (Initialize/GetClient)
27
+ - **BREAKING:** Removed old initialization functions (initializeReveniumFromEnv, initializePerplexityFromEnv)
28
+ - **BREAKING:** Removed old wrapper functions (createChatCompletion, createStreamingChatCompletion)
29
+ - **BREAKING:** responseQualityScore now uses 0.0-1.0 scale (was 0-100) per updated API specification
30
+ - **API Compliance:** provider value changed from 'PERPLEXITY' to 'Perplexity' (proper casing per spec)
31
+ - **API Compliance:** modelSource changed to 'PERPLEXITY' for consistency
32
+ - **API Compliance:** middlewareSource changed from 'nodejs' to 'revenium-perplexity-node' per spec format
33
+ - **API Compliance:** cacheCreationTokenCount now undefined (not 0) when provider doesn't report
34
+ - **API Compliance:** cacheReadTokenCount now uses ?? operator (not ||) to preserve 0 values
35
+ - **API Compliance:** timeToFirstToken now undefined (not hardcoded) until real TTFB tracking implemented
36
+ - Restructured src/ with modular core/client, core/config, core/middleware, core/providers, core/tracking
37
+ - Email addresses now masked in debug logs for PII protection
38
+ - All examples updated to use 0.0-1.0 scale for responseQualityScore
39
+ - Removed hardcoded model lists - middleware now accepts any model name
40
+
41
+ ### Fixed
42
+
43
+ - Removed broken file references from examples documentation
44
+ - Removed non-existent config options from documentation (apiTimeout, failSilent, maxRetries)
45
+ - config.debug property now properly enables debug logging
46
+ - Updated OpenAI version requirement to match peer dependency (v5.0.0+)
47
+ - Removed taskId field from all files (field does not exist in API spec)
48
+ - Added CANCELLED stop reason to mapper for completeness
49
+ - validateMetadata now checks 0.0-1.0 scale for responseQualityScore
50
+ - Fallback provider detection now uses 'Perplexity' not 'PERPLEXITY' (proper casing)
51
+ - reasoningTokenCount now optional (undefined when not reported, per spec)
52
+
53
+ ## [2.0.4] - 2025-10-21
54
+
55
+ ### Changed
56
+
57
+ - Enhanced package.json with examples in files array
58
+ - Added community health files (CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md)
59
+ - Updated .gitignore with security report patterns
60
+ - Added engines field for Node.js version requirements
61
+
62
+ ## [2.0.3] - 2025-10-17
63
+
64
+ ### Changed
65
+
66
+ - Documentation improvements with absolute path references
67
+
68
+ ## [2.0.2] - 2025-10-09
69
+
70
+ ### Changed
71
+
72
+ - Internal updates and improvements
73
+
74
+ ## [2.0.1] - 2025-10-09
75
+
76
+ ### Changed
77
+
78
+ - Bug fixes and stability improvements
79
+
80
+ ## [2.0.0] - 2025-10-09
81
+
82
+ ### Added
83
+
84
+ - Complete code restructuring with core/ directory organization
85
+ - Dual package exports (ESM + CommonJS) support
86
+ - TypeScript declaration maps for better debugging
87
+ - Enhanced build system with separate CJS, ESM, and types builds
88
+
89
+ ### Changed
90
+
91
+ - Restructured src/ directory with core/config, core/tracking, core/wrapper
92
+ - Enhanced README with comprehensive documentation
93
+
94
+ ## [1.0.0] - 2025-09-23
95
+
96
+ ### Added
97
+
98
+ - Initial release of Perplexity AI middleware
99
+ - Automatic token counting and usage tracking
100
+ - Streaming support with automatic tracking
101
+ - Custom metadata integration
102
+ - TypeScript support with full type safety
103
+ - Comprehensive error handling
104
+ - Background processing for non-blocking tracking
105
+ - Debug logging support
106
+
107
+ [3.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v3.0.0
108
+ [2.0.4]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.4
109
+ [2.0.3]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.3
110
+ [2.0.2]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.2
111
+ [2.0.1]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.1
112
+ [2.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.0
113
+ [1.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v1.0.0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Revenium
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Revenium
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.