librechat-data-provider 0.7.5 → 0.7.7

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/check_updates.sh +1 -0
  2. package/dist/index.es.js +1 -1
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/react-query/index.es.js +1 -1
  7. package/dist/react-query/index.es.js.map +1 -1
  8. package/package.json +4 -4
  9. package/server-rollup.config.js +3 -3
  10. package/specs/actions.spec.ts +424 -35
  11. package/specs/azure.spec.ts +8 -5
  12. package/specs/filetypes.spec.ts +1 -7
  13. package/specs/mcp.spec.ts +52 -0
  14. package/specs/utils.spec.ts +129 -0
  15. package/src/actions.ts +209 -82
  16. package/src/api-endpoints.ts +39 -16
  17. package/src/azure.ts +40 -33
  18. package/src/bedrock.ts +84 -4
  19. package/src/config.ts +199 -95
  20. package/src/createPayload.ts +3 -1
  21. package/src/data-service.ts +114 -20
  22. package/src/file-config.ts +10 -2
  23. package/src/generate.ts +1 -1
  24. package/src/index.ts +7 -4
  25. package/src/keys.ts +6 -0
  26. package/src/mcp.ts +87 -0
  27. package/src/models.ts +1 -1
  28. package/src/parsers.ts +43 -43
  29. package/src/react-query/react-query-service.ts +40 -126
  30. package/src/request.ts +28 -7
  31. package/src/roles.ts +33 -1
  32. package/src/schemas.ts +250 -198
  33. package/src/types/agents.ts +57 -1
  34. package/src/types/assistants.ts +33 -2
  35. package/src/types/files.ts +1 -0
  36. package/src/types/mutations.ts +96 -8
  37. package/src/types/queries.ts +39 -21
  38. package/src/types/runs.ts +1 -0
  39. package/src/types.ts +90 -81
  40. package/src/utils.ts +44 -0
  41. package/src/zod.spec.ts +526 -0
  42. package/src/zod.ts +86 -0
  43. package/tsconfig.json +1 -2
  44. package/specs/parsers.spec.ts +0 -48
  45. package/src/sse.js +0 -242
@@ -94,8 +94,8 @@ describe('validateAzureGroups', () => {
94
94
  expect(isValid).toBe(true);
95
95
  const modelGroup = modelGroupMap['gpt-5-turbo'];
96
96
  expect(modelGroup).toBeDefined();
97
- expect(modelGroup.group).toBe('japan-east');
98
- expect(groupMap[modelGroup.group]).toBeDefined();
97
+ expect(modelGroup?.group).toBe('japan-east');
98
+ expect(groupMap[modelGroup?.group ?? '']).toBeDefined();
99
99
  expect(modelNames).toContain('gpt-5-turbo');
100
100
  const { azureOptions } = mapModelToAzureConfig({
101
101
  modelName: 'gpt-5-turbo',
@@ -323,6 +323,7 @@ describe('validateAzureGroups for Serverless Configurations', () => {
323
323
 
324
324
  expect(azureOptions).toEqual({
325
325
  azureOpenAIApiKey: 'def456',
326
+ azureOpenAIApiVersion: '',
326
327
  });
327
328
  expect(baseURL).toEqual('https://new-serverless.example.com/v1/completions');
328
329
  expect(serverless).toBe(true);
@@ -381,10 +382,10 @@ describe('validateAzureGroups with modelGroupMap and groupMap', () => {
381
382
  const { isValid, modelGroupMap, groupMap } = validateAzureGroups(validConfigs);
382
383
  expect(isValid).toBe(true);
383
384
  expect(modelGroupMap['gpt-4-turbo']).toBeDefined();
384
- expect(modelGroupMap['gpt-4-turbo'].group).toBe('us-east');
385
+ expect(modelGroupMap['gpt-4-turbo']?.group).toBe('us-east');
385
386
  expect(groupMap['us-east']).toBeDefined();
386
- expect(groupMap['us-east'].apiKey).toBe('prod-1234');
387
- expect(groupMap['us-east'].models['gpt-4-turbo']).toBeDefined();
387
+ expect(groupMap['us-east']?.apiKey).toBe('prod-1234');
388
+ expect(groupMap['us-east']?.models['gpt-4-turbo']).toBeDefined();
388
389
  const { azureOptions, baseURL, headers } = mapModelToAzureConfig({
389
390
  modelName: 'gpt-4-turbo',
390
391
  modelGroupMap,
@@ -765,6 +766,7 @@ describe('validateAzureGroups with modelGroupMap and groupMap', () => {
765
766
  );
766
767
  expect(azureOptions7).toEqual({
767
768
  azureOpenAIApiKey: 'mistral-key',
769
+ azureOpenAIApiVersion: '',
768
770
  });
769
771
 
770
772
  const {
@@ -782,6 +784,7 @@ describe('validateAzureGroups with modelGroupMap and groupMap', () => {
782
784
  );
783
785
  expect(azureOptions8).toEqual({
784
786
  azureOpenAIApiKey: 'llama-key',
787
+ azureOpenAIApiVersion: '',
785
788
  });
786
789
  });
787
790
  });
@@ -14,13 +14,7 @@ import {
14
14
  } from '../src/file-config';
15
15
 
16
16
  describe('MIME Type Regex Patterns', () => {
17
- const unsupportedMimeTypes = [
18
- 'text/x-unknown',
19
- 'application/unknown',
20
- 'image/bmp',
21
- 'image/svg',
22
- 'audio/mp3',
23
- ];
17
+ const unsupportedMimeTypes = ['text/x-unknown', 'application/unknown', 'image/bmp', 'audio/mp3'];
24
18
 
25
19
  // Testing general supported MIME types
26
20
  fullMimeTypesList.forEach((mimeType) => {
@@ -0,0 +1,52 @@
1
+ import { StdioOptionsSchema } from '../src/mcp';
2
+
3
+ describe('Environment Variable Extraction (MCP)', () => {
4
+ const originalEnv = process.env;
5
+
6
+ beforeEach(() => {
7
+ process.env = {
8
+ ...originalEnv,
9
+ TEST_API_KEY: 'test-api-key-value',
10
+ ANOTHER_SECRET: 'another-secret-value',
11
+ };
12
+ });
13
+
14
+ afterEach(() => {
15
+ process.env = originalEnv;
16
+ });
17
+
18
+ describe('StdioOptionsSchema', () => {
19
+ it('should transform environment variables in the env field', () => {
20
+ const options = {
21
+ command: 'node',
22
+ args: ['server.js'],
23
+ env: {
24
+ API_KEY: '${TEST_API_KEY}',
25
+ ANOTHER_KEY: '${ANOTHER_SECRET}',
26
+ PLAIN_VALUE: 'plain-value',
27
+ NON_EXISTENT: '${NON_EXISTENT_VAR}',
28
+ },
29
+ };
30
+
31
+ const result = StdioOptionsSchema.parse(options);
32
+
33
+ expect(result.env).toEqual({
34
+ API_KEY: 'test-api-key-value',
35
+ ANOTHER_KEY: 'another-secret-value',
36
+ PLAIN_VALUE: 'plain-value',
37
+ NON_EXISTENT: '${NON_EXISTENT_VAR}',
38
+ });
39
+ });
40
+
41
+ it('should handle undefined env field', () => {
42
+ const options = {
43
+ command: 'node',
44
+ args: ['server.js'],
45
+ };
46
+
47
+ const result = StdioOptionsSchema.parse(options);
48
+
49
+ expect(result.env).toBeUndefined();
50
+ });
51
+ });
52
+ });
@@ -0,0 +1,129 @@
1
+ import { extractEnvVariable } from '../src/utils';
2
+
3
+ describe('Environment Variable Extraction', () => {
4
+ const originalEnv = process.env;
5
+
6
+ beforeEach(() => {
7
+ process.env = {
8
+ ...originalEnv,
9
+ TEST_API_KEY: 'test-api-key-value',
10
+ ANOTHER_SECRET: 'another-secret-value',
11
+ };
12
+ });
13
+
14
+ afterEach(() => {
15
+ process.env = originalEnv;
16
+ });
17
+
18
+ describe('extractEnvVariable (original tests)', () => {
19
+ test('should return the value of the environment variable', () => {
20
+ process.env.TEST_VAR = 'test_value';
21
+ expect(extractEnvVariable('${TEST_VAR}')).toBe('test_value');
22
+ });
23
+
24
+ test('should return the original string if the envrionment variable is not defined correctly', () => {
25
+ process.env.TEST_VAR = 'test_value';
26
+ expect(extractEnvVariable('${ TEST_VAR }')).toBe('${ TEST_VAR }');
27
+ });
28
+
29
+ test('should return the original string if environment variable is not set', () => {
30
+ expect(extractEnvVariable('${NON_EXISTENT_VAR}')).toBe('${NON_EXISTENT_VAR}');
31
+ });
32
+
33
+ test('should return the original string if it does not contain an environment variable', () => {
34
+ expect(extractEnvVariable('some_string')).toBe('some_string');
35
+ });
36
+
37
+ test('should handle empty strings', () => {
38
+ expect(extractEnvVariable('')).toBe('');
39
+ });
40
+
41
+ test('should handle strings without variable format', () => {
42
+ expect(extractEnvVariable('no_var_here')).toBe('no_var_here');
43
+ });
44
+
45
+ /** No longer the expected behavior; keeping for reference */
46
+ test.skip('should not process multiple variable formats', () => {
47
+ process.env.FIRST_VAR = 'first';
48
+ process.env.SECOND_VAR = 'second';
49
+ expect(extractEnvVariable('${FIRST_VAR} and ${SECOND_VAR}')).toBe(
50
+ '${FIRST_VAR} and ${SECOND_VAR}',
51
+ );
52
+ });
53
+ });
54
+
55
+ describe('extractEnvVariable function', () => {
56
+ it('should extract environment variables from exact matches', () => {
57
+ expect(extractEnvVariable('${TEST_API_KEY}')).toBe('test-api-key-value');
58
+ expect(extractEnvVariable('${ANOTHER_SECRET}')).toBe('another-secret-value');
59
+ });
60
+
61
+ it('should extract environment variables from strings with prefixes', () => {
62
+ expect(extractEnvVariable('prefix-${TEST_API_KEY}')).toBe('prefix-test-api-key-value');
63
+ });
64
+
65
+ it('should extract environment variables from strings with suffixes', () => {
66
+ expect(extractEnvVariable('${TEST_API_KEY}-suffix')).toBe('test-api-key-value-suffix');
67
+ });
68
+
69
+ it('should extract environment variables from strings with both prefixes and suffixes', () => {
70
+ expect(extractEnvVariable('prefix-${TEST_API_KEY}-suffix')).toBe(
71
+ 'prefix-test-api-key-value-suffix',
72
+ );
73
+ });
74
+
75
+ it('should not match invalid patterns', () => {
76
+ expect(extractEnvVariable('$TEST_API_KEY')).toBe('$TEST_API_KEY');
77
+ expect(extractEnvVariable('{TEST_API_KEY}')).toBe('{TEST_API_KEY}');
78
+ expect(extractEnvVariable('TEST_API_KEY')).toBe('TEST_API_KEY');
79
+ });
80
+ });
81
+
82
+ describe('extractEnvVariable', () => {
83
+ it('should extract environment variable values', () => {
84
+ expect(extractEnvVariable('${TEST_API_KEY}')).toBe('test-api-key-value');
85
+ expect(extractEnvVariable('${ANOTHER_SECRET}')).toBe('another-secret-value');
86
+ });
87
+
88
+ it('should return the original string if environment variable is not found', () => {
89
+ expect(extractEnvVariable('${NON_EXISTENT_VAR}')).toBe('${NON_EXISTENT_VAR}');
90
+ });
91
+
92
+ it('should return the original string if no environment variable pattern is found', () => {
93
+ expect(extractEnvVariable('plain-string')).toBe('plain-string');
94
+ });
95
+ });
96
+
97
+ describe('extractEnvVariable space trimming', () => {
98
+ beforeEach(() => {
99
+ process.env.HELLO = 'world';
100
+ process.env.USER = 'testuser';
101
+ });
102
+
103
+ it('should extract the value when string contains only an environment variable with surrounding whitespace', () => {
104
+ expect(extractEnvVariable(' ${HELLO} ')).toBe('world');
105
+ expect(extractEnvVariable(' ${HELLO} ')).toBe('world');
106
+ expect(extractEnvVariable('\t${HELLO}\n')).toBe('world');
107
+ });
108
+
109
+ it('should preserve content when variable is part of a larger string', () => {
110
+ expect(extractEnvVariable('Hello ${USER}!')).toBe('Hello testuser!');
111
+ expect(extractEnvVariable(' Hello ${USER}! ')).toBe('Hello testuser!');
112
+ });
113
+
114
+ it('should not handle multiple variables', () => {
115
+ expect(extractEnvVariable('${HELLO} ${USER}')).toBe('${HELLO} ${USER}');
116
+ expect(extractEnvVariable(' ${HELLO} ${USER} ')).toBe('${HELLO} ${USER}');
117
+ });
118
+
119
+ it('should handle undefined variables', () => {
120
+ expect(extractEnvVariable(' ${UNDEFINED_VAR} ')).toBe('${UNDEFINED_VAR}');
121
+ });
122
+
123
+ it('should handle mixed content correctly', () => {
124
+ expect(extractEnvVariable('Welcome, ${USER}!\nYour message: ${HELLO}')).toBe(
125
+ 'Welcome, testuser!\nYour message: world',
126
+ );
127
+ });
128
+ });
129
+ });