@devilsdev/rag-pipeline-utils 2.2.0 → 2.3.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 (46) hide show
  1. package/README.md +323 -722
  2. package/contracts/contract-schema.json +189 -0
  3. package/contracts/reranker-contract.json +69 -0
  4. package/dist/index.cjs +19 -0
  5. package/dist/index.mjs +15 -1
  6. package/package.json +4 -2
  7. package/src/cli/commands/wizard.js +627 -0
  8. package/src/cli/input-sanitization-middleware.js +356 -0
  9. package/src/cli/templates/development.template.json +64 -0
  10. package/src/cli/templates/minimal.template.json +33 -0
  11. package/src/cli/templates/production.template.json +104 -0
  12. package/src/cli/templates/testing.template.json +45 -0
  13. package/src/config/connection-pool-config.json +259 -0
  14. package/src/config/memory-optimization.js +414 -0
  15. package/src/config/redaction-patterns.json +150 -0
  16. package/src/config/sanitization-rules.json +323 -0
  17. package/src/core/performance/streaming-safeguards.js +10 -1
  18. package/src/core/plugin-registry.js +275 -0
  19. package/src/dag/core/error-context.js +391 -0
  20. package/src/dag/core/execution-scheduler.js +350 -0
  21. package/src/dag/core/topology-validation.js +415 -0
  22. package/src/dag/dag-engine.js +26 -424
  23. package/src/dev/README.md +126 -0
  24. package/src/dev/dev-server.js +356 -0
  25. package/src/dev/examples/hot-reload-usage.js +355 -0
  26. package/src/dev/hot-reload.js +807 -0
  27. package/src/enterprise/sso-integration.js +184 -15
  28. package/src/index.js +19 -0
  29. package/src/observability/event-logger.js +62 -2
  30. package/src/plugins/optimized-openai-embedder.js +169 -0
  31. package/src/reranker/llm-reranker.js +30 -4
  32. package/src/security/jwt-config.js +431 -0
  33. package/src/security/jwt-validator.js +701 -0
  34. package/src/utils/api-client-pool-integration.js +436 -0
  35. package/src/utils/batch-processor.js +710 -0
  36. package/src/utils/connection-pool.js +605 -0
  37. package/src/utils/contract-validator.js +460 -0
  38. package/src/utils/error-formatter.js +603 -0
  39. package/src/utils/examples/error-formatter-usage.js +351 -0
  40. package/src/utils/input-sanitizer.js +967 -0
  41. package/src/utils/memory-monitor.js +800 -0
  42. package/src/utils/rate-limiter.js +244 -0
  43. package/src/utils/secure-logger-config.js +352 -0
  44. package/src/utils/secure-logger.js +576 -0
  45. package/src/utils/secure-logging.js +338 -0
  46. package/src/utils/structured-logger.js +32 -5
@@ -0,0 +1,189 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://github.com/devilsdev/rag-pipeline-utils/schemas/contract.json",
4
+ "title": "Plugin Contract Schema",
5
+ "description": "Schema for validating plugin contract specifications in the RAG pipeline utilities",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "version",
10
+ "title",
11
+ "description",
12
+ "methods",
13
+ "properties",
14
+ "required"
15
+ ],
16
+ "properties": {
17
+ "$schema": {
18
+ "type": "string",
19
+ "description": "JSON Schema specification URI"
20
+ },
21
+ "type": {
22
+ "type": "string",
23
+ "description": "Plugin type identifier",
24
+ "enum": [
25
+ "loader",
26
+ "embedder",
27
+ "retriever",
28
+ "llm",
29
+ "reranker",
30
+ "evaluator"
31
+ ]
32
+ },
33
+ "version": {
34
+ "type": "string",
35
+ "description": "Contract version (semantic versioning)",
36
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
37
+ },
38
+ "title": {
39
+ "type": "string",
40
+ "description": "Human-readable contract title",
41
+ "minLength": 1
42
+ },
43
+ "description": {
44
+ "type": "string",
45
+ "description": "Contract description",
46
+ "minLength": 1
47
+ },
48
+ "methods": {
49
+ "type": "array",
50
+ "description": "Array of method specifications",
51
+ "minItems": 1,
52
+ "items": {
53
+ "type": "object",
54
+ "required": ["name", "parameters", "returns"],
55
+ "properties": {
56
+ "name": {
57
+ "type": "string",
58
+ "description": "Method name",
59
+ "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
60
+ },
61
+ "parameters": {
62
+ "type": "array",
63
+ "description": "Method parameter names",
64
+ "items": {
65
+ "type": "string",
66
+ "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
67
+ }
68
+ },
69
+ "returns": {
70
+ "type": "string",
71
+ "description": "Return type description",
72
+ "minLength": 1
73
+ }
74
+ },
75
+ "additionalProperties": false
76
+ }
77
+ },
78
+ "properties": {
79
+ "type": "object",
80
+ "description": "Detailed method property specifications",
81
+ "minProperties": 1,
82
+ "patternProperties": {
83
+ "^[a-zA-Z_][a-zA-Z0-9_]*$": {
84
+ "type": "object",
85
+ "required": ["type", "description"],
86
+ "properties": {
87
+ "type": {
88
+ "type": "string",
89
+ "description": "Property type",
90
+ "enum": [
91
+ "function",
92
+ "string",
93
+ "number",
94
+ "boolean",
95
+ "object",
96
+ "array"
97
+ ]
98
+ },
99
+ "description": {
100
+ "type": "string",
101
+ "description": "Property description",
102
+ "minLength": 1
103
+ },
104
+ "parameters": {
105
+ "type": "object",
106
+ "description": "Parameter schema (for function properties)",
107
+ "properties": {
108
+ "type": {
109
+ "const": "object"
110
+ },
111
+ "properties": {
112
+ "type": "object"
113
+ },
114
+ "required": {
115
+ "type": "array",
116
+ "items": {
117
+ "type": "string"
118
+ }
119
+ }
120
+ }
121
+ },
122
+ "returns": {
123
+ "type": "object",
124
+ "description": "Return value schema (for function properties)"
125
+ }
126
+ },
127
+ "additionalProperties": true
128
+ }
129
+ },
130
+ "additionalProperties": false
131
+ },
132
+ "required": {
133
+ "type": "array",
134
+ "description": "List of required methods",
135
+ "minItems": 1,
136
+ "items": {
137
+ "type": "string",
138
+ "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
139
+ },
140
+ "uniqueItems": true
141
+ }
142
+ },
143
+ "additionalProperties": false,
144
+ "examples": [
145
+ {
146
+ "$schema": "http://json-schema.org/draft-07/schema#",
147
+ "type": "loader",
148
+ "version": "1.0.0",
149
+ "title": "Loader Contract",
150
+ "description": "Contract for loader plugins",
151
+ "methods": [
152
+ {
153
+ "name": "load",
154
+ "parameters": ["source"],
155
+ "returns": "documents"
156
+ }
157
+ ],
158
+ "properties": {
159
+ "load": {
160
+ "type": "function",
161
+ "description": "Load documents from source",
162
+ "parameters": {
163
+ "type": "object",
164
+ "properties": {
165
+ "source": {
166
+ "type": "string",
167
+ "description": "Source path or identifier"
168
+ }
169
+ },
170
+ "required": ["source"]
171
+ },
172
+ "returns": {
173
+ "type": "array",
174
+ "items": {
175
+ "type": "object",
176
+ "properties": {
177
+ "id": { "type": "string" },
178
+ "content": { "type": "string" },
179
+ "metadata": { "type": "object" }
180
+ },
181
+ "required": ["id", "content"]
182
+ }
183
+ }
184
+ }
185
+ },
186
+ "required": ["load"]
187
+ }
188
+ ]
189
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "reranker",
4
+ "version": "1.0.0",
5
+ "title": "Reranker Contract",
6
+ "description": "Contract for reranker plugins",
7
+ "methods": [
8
+ {
9
+ "name": "rerank",
10
+ "parameters": ["results", "query", "options"],
11
+ "returns": "rankedResults"
12
+ }
13
+ ],
14
+ "properties": {
15
+ "rerank": {
16
+ "type": "function",
17
+ "description": "Rerank search results based on relevance to query",
18
+ "parameters": {
19
+ "type": "object",
20
+ "properties": {
21
+ "results": {
22
+ "type": "array",
23
+ "items": {
24
+ "type": "object",
25
+ "properties": {
26
+ "id": { "type": "string" },
27
+ "content": { "type": "string" },
28
+ "score": { "type": "number" }
29
+ },
30
+ "required": ["id", "content"]
31
+ }
32
+ },
33
+ "query": {
34
+ "type": "string",
35
+ "description": "The original search query"
36
+ },
37
+ "options": {
38
+ "type": "object",
39
+ "properties": {
40
+ "topK": {
41
+ "type": "number",
42
+ "description": "Number of top results to return"
43
+ },
44
+ "threshold": {
45
+ "type": "number",
46
+ "description": "Minimum relevance score threshold"
47
+ }
48
+ }
49
+ }
50
+ },
51
+ "required": ["results", "query"]
52
+ },
53
+ "returns": {
54
+ "type": "array",
55
+ "items": {
56
+ "type": "object",
57
+ "properties": {
58
+ "id": { "type": "string" },
59
+ "content": { "type": "string" },
60
+ "score": { "type": "number" },
61
+ "relevanceScore": { "type": "number" }
62
+ },
63
+ "required": ["id", "content", "relevanceScore"]
64
+ }
65
+ }
66
+ }
67
+ },
68
+ "required": ["rerank"]
69
+ }
package/dist/index.cjs CHANGED
@@ -16,6 +16,7 @@ const pluginRegistry = require('../src/core/plugin-registry');
16
16
 
17
17
  // Utilities
18
18
  const logger = require('../src/utils/logger');
19
+ const errorFormatter = require('../src/utils/error-formatter');
19
20
 
20
21
  // AI/ML capabilities
21
22
  const MultiModalProcessor = require('../src/ai/multimodal');
@@ -33,6 +34,13 @@ const metrics = require('../src/core/observability/metrics');
33
34
  const { AuditLogger } = require('../src/enterprise/audit-logging');
34
35
  const { DataGovernance } = require('../src/enterprise/data-governance');
35
36
 
37
+ // Development tools
38
+ const {
39
+ HotReloadManager,
40
+ createHotReloadManager,
41
+ } = require('../src/dev/hot-reload');
42
+ const { DevServer, createDevServer } = require('../src/dev/dev-server');
43
+
36
44
  module.exports = {
37
45
  // Core API
38
46
  createRagPipeline,
@@ -48,6 +56,11 @@ module.exports = {
48
56
 
49
57
  // Utilities
50
58
  logger,
59
+ errorFormatter,
60
+ // Error handling utilities
61
+ createError: errorFormatter.createError,
62
+ wrapError: errorFormatter.wrapError,
63
+ ERROR_CODES: errorFormatter.ERROR_CODES,
51
64
 
52
65
  // AI/ML
53
66
  MultiModalProcessor,
@@ -64,4 +77,10 @@ module.exports = {
64
77
  // Enterprise
65
78
  AuditLogger,
66
79
  DataGovernance,
80
+
81
+ // Development tools
82
+ HotReloadManager,
83
+ createHotReloadManager,
84
+ DevServer,
85
+ createDevServer,
67
86
  };
package/dist/index.mjs CHANGED
@@ -25,6 +25,7 @@ import pluginRegistry from '../src/core/plugin-registry.js';
25
25
 
26
26
  // Utilities
27
27
  import logger from '../src/utils/logger.js';
28
+ import errorFormatter from '../src/utils/error-formatter.js';
28
29
 
29
30
  // AI/ML capabilities
30
31
  import MultiModalProcessor from '../src/ai/multimodal.js';
@@ -45,6 +46,14 @@ const { AuditLogger } = auditloggingModule;
45
46
  import datagovernanceModule from '../src/enterprise/data-governance.js';
46
47
  const { DataGovernance } = datagovernanceModule;
47
48
 
49
+ // Development tools
50
+ import hotreloadModule from '../src/dev/hot-reload.js';
51
+ const { HotReloadManager,
52
+ createHotReloadManager,
53
+ } = hotreloadModule;
54
+ import devserverModule from '../src/dev/dev-server.js';
55
+ const { DevServer, createDevServer } = devserverModule;
56
+
48
57
  export {
49
58
  createRagPipeline,
50
59
  loadConfig,
@@ -52,6 +61,7 @@ export {
52
61
  normalizeConfig,
53
62
  pluginRegistry,
54
63
  logger,
64
+ errorFormatter,
55
65
  MultiModalProcessor,
56
66
  AdaptiveRetrievalEngine,
57
67
  DAGEngine,
@@ -59,7 +69,11 @@ export {
59
69
  eventLogger,
60
70
  metrics,
61
71
  AuditLogger,
62
- DataGovernance
72
+ DataGovernance,
73
+ HotReloadManager,
74
+ createHotReloadManager,
75
+ DevServer,
76
+ createDevServer
63
77
  };
64
78
 
65
79
  // Backward compatibility aliases
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devilsdev/rag-pipeline-utils",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "A comprehensive enterprise-grade toolkit for building RAG (Retrieval-Augmented Generation) pipelines with advanced AI/ML capabilities",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "commonjs",
@@ -167,7 +167,7 @@
167
167
  "eslint-plugin-storybook": "^0.12.0",
168
168
  "framer-motion": "^12.7.4",
169
169
  "husky": "^8.0.3",
170
- "isolated-vm": "6.0.1",
170
+ "isolated-vm": "5.0.4",
171
171
  "jest": "^29.7.0",
172
172
  "jest-junit": "^16.0.0",
173
173
  "jest-transform-stub": "^2.0.0",
@@ -186,12 +186,14 @@
186
186
  "ajv": "^8.17.1",
187
187
  "axios": "^1.8.4",
188
188
  "chalk": "^5.4.1",
189
+ "chokidar": "^4.0.3",
189
190
  "commander": "^13.1.0",
190
191
  "csv-parse": "^5.6.0",
191
192
  "dotenv": "^16.5.0",
192
193
  "fast-glob": "^3.3.3",
193
194
  "inquirer": "^8.2.5",
194
195
  "jsdom": "^26.1.0",
196
+ "jsonwebtoken": "9.0.2",
195
197
  "openai": "^4.93.0",
196
198
  "pino": "^9.6.0"
197
199
  }