@revenium/perplexity 2.0.6 → 2.0.8

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 (49) hide show
  1. package/.env.example +10 -0
  2. package/CHANGELOG.md +82 -113
  3. package/LICENSE +21 -21
  4. package/README.md +408 -292
  5. package/SECURITY.md +34 -34
  6. package/dist/cjs/core/config/index.js +0 -1
  7. package/dist/cjs/core/config/index.js.map +1 -1
  8. package/dist/cjs/core/config/manager.js +0 -1
  9. package/dist/cjs/core/config/manager.js.map +1 -1
  10. package/dist/cjs/core/providers/detector.js +0 -2
  11. package/dist/cjs/core/providers/detector.js.map +1 -1
  12. package/dist/cjs/core/providers/index.js +0 -1
  13. package/dist/cjs/core/providers/index.js.map +1 -1
  14. package/dist/cjs/index.js +1 -34
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/cjs/utils/stop-reason-mapper.js +18 -20
  17. package/dist/cjs/utils/stop-reason-mapper.js.map +1 -1
  18. package/dist/esm/core/config/index.js +3 -4
  19. package/dist/esm/core/config/index.js.map +1 -1
  20. package/dist/esm/core/config/manager.js +0 -1
  21. package/dist/esm/core/config/manager.js.map +1 -1
  22. package/dist/esm/core/providers/detector.js +0 -2
  23. package/dist/esm/core/providers/detector.js.map +1 -1
  24. package/dist/esm/core/providers/index.js +0 -1
  25. package/dist/esm/core/providers/index.js.map +1 -1
  26. package/dist/esm/index.js +1 -34
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/utils/stop-reason-mapper.js +18 -20
  29. package/dist/esm/utils/stop-reason-mapper.js.map +1 -1
  30. package/dist/types/core/config/index.d.ts +3 -4
  31. package/dist/types/core/config/index.d.ts.map +1 -1
  32. package/dist/types/core/config/manager.d.ts +0 -1
  33. package/dist/types/core/config/manager.d.ts.map +1 -1
  34. package/dist/types/core/providers/detector.d.ts +0 -2
  35. package/dist/types/core/providers/detector.d.ts.map +1 -1
  36. package/dist/types/core/providers/index.d.ts +0 -1
  37. package/dist/types/core/providers/index.d.ts.map +1 -1
  38. package/dist/types/index.d.ts +2 -32
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/types/index.d.ts +1 -1
  41. package/dist/types/utils/stop-reason-mapper.d.ts +1 -3
  42. package/dist/types/utils/stop-reason-mapper.d.ts.map +1 -1
  43. package/examples/README.md +274 -226
  44. package/examples/advanced.ts +123 -123
  45. package/examples/basic.ts +45 -45
  46. package/examples/getting_started.ts +41 -41
  47. package/examples/metadata.ts +68 -68
  48. package/examples/stream.ts +53 -53
  49. package/package.json +80 -72
package/.env.example ADDED
@@ -0,0 +1,10 @@
1
+ # Revenium Configuration (Required)
2
+ REVENIUM_METERING_API_KEY=hak_your_revenium_api_key_here
3
+ REVENIUM_METERING_BASE_URL=https://api.revenium.ai
4
+
5
+ # Perplexity Configuration (Required)
6
+ PERPLEXITY_API_KEY=pplx_your_perplexity_api_key_here
7
+ PERPLEXITY_API_BASE_URL=https://api.perplexity.ai
8
+
9
+ # Debug Configuration (Optional)
10
+ REVENIUM_DEBUG=false # Set to true to enable debug logging
package/CHANGELOG.md CHANGED
@@ -1,113 +1,82 @@
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
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
+ ## [2.0.8] - 2025-11-14
9
+
10
+ ### Changed
11
+
12
+ - Updated documentation with semver range examples
13
+ - Enhanced package structure for better npm distribution
14
+ - Improved installation instructions and clarity
15
+ - Improved metadata table clarity and accuracy with better field descriptions
16
+
17
+ ### Fixed
18
+
19
+ - Updated dashboard URL references to app.revenium.ai
20
+ - Documentation improvements for better user experience
21
+
22
+ ## [2.0.4] - 2025-10-21
23
+
24
+ ### Changed
25
+
26
+ - Enhanced package.json with examples in files array
27
+ - Added community health files (CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md)
28
+ - Updated .gitignore with security report patterns
29
+ - Added engines field for Node.js version requirements
30
+
31
+ ## [2.0.3] - 2025-10-17
32
+
33
+ ### Changed
34
+
35
+ - Documentation improvements with absolute path references
36
+
37
+ ## [2.0.2] - 2025-10-09
38
+
39
+ ### Changed
40
+
41
+ - Internal updates and improvements
42
+
43
+ ## [2.0.1] - 2025-10-09
44
+
45
+ ### Changed
46
+
47
+ - Bug fixes and stability improvements
48
+
49
+ ## [2.0.0] - 2025-10-09
50
+
51
+ ### Added
52
+
53
+ - Complete code restructuring with core/ directory organization
54
+ - Dual package exports (ESM + CommonJS) support
55
+ - TypeScript declaration maps for better debugging
56
+ - Enhanced build system with separate CJS, ESM, and types builds
57
+
58
+ ### Changed
59
+
60
+ - Restructured src/ directory with core/config, core/tracking, core/wrapper
61
+ - Enhanced README with comprehensive documentation
62
+
63
+ ## [1.0.0] - 2025-09-23
64
+
65
+ ### Added
66
+
67
+ - Initial release of Perplexity AI middleware
68
+ - Automatic token counting and usage tracking
69
+ - Streaming support with automatic tracking
70
+ - Custom metadata integration
71
+ - TypeScript support with full type safety
72
+ - Comprehensive error handling
73
+ - Background processing for non-blocking tracking
74
+ - Debug logging support
75
+
76
+ [2.0.8]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.8
77
+ [2.0.4]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.4
78
+ [2.0.3]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.3
79
+ [2.0.2]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.2
80
+ [2.0.1]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.1
81
+ [2.0.0]: https://github.com/revenium/revenium-middleware-perplexity-node/releases/tag/v2.0.0
82
+ [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.