dolphin-server-modules 2.11.1 → 2.11.2

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 (115) hide show
  1. package/TUTORIAL_NEPALI.md +181 -0
  2. package/dist/adapters/mongoose/index.test.d.ts +1 -0
  3. package/dist/adapters/mongoose/index.test.js +145 -0
  4. package/dist/adapters/mongoose/index.test.js.map +1 -0
  5. package/dist/adapters/mongoose/integration.test.d.ts +5 -0
  6. package/dist/adapters/mongoose/integration.test.js +217 -0
  7. package/dist/adapters/mongoose/integration.test.js.map +1 -0
  8. package/dist/ai/dolphin-agent/agent.d.ts +5 -0
  9. package/dist/ai/dolphin-agent/agent.js +93 -46
  10. package/dist/ai/dolphin-agent/agent.js.map +1 -1
  11. package/dist/ai/dolphin-agent/config.js +19 -23
  12. package/dist/ai/dolphin-agent/config.js.map +1 -1
  13. package/dist/auth/auth.test.d.ts +1 -0
  14. package/dist/auth/auth.test.js +286 -0
  15. package/dist/auth/auth.test.js.map +1 -0
  16. package/dist/authController/authController.js +1 -1
  17. package/dist/authController/authController.js.map +1 -1
  18. package/dist/authController/authController.test.d.ts +1 -0
  19. package/dist/authController/authController.test.js +359 -0
  20. package/dist/authController/authController.test.js.map +1 -0
  21. package/dist/bin/cli.js +494 -131
  22. package/dist/bin/cli.js.map +1 -1
  23. package/dist/client.test.d.ts +22 -0
  24. package/dist/client.test.js +573 -0
  25. package/dist/client.test.js.map +1 -0
  26. package/dist/controller/controller.test.d.ts +1 -0
  27. package/dist/controller/controller.test.js +37 -0
  28. package/dist/controller/controller.test.js.map +1 -0
  29. package/dist/curd/crud.test.d.ts +1 -0
  30. package/dist/curd/crud.test.js +104 -0
  31. package/dist/curd/crud.test.js.map +1 -0
  32. package/dist/demo-server.d.ts +1 -0
  33. package/dist/demo-server.js +191 -0
  34. package/dist/demo-server.js.map +1 -0
  35. package/dist/djson/djson.test.d.ts +1 -0
  36. package/dist/djson/djson.test.js +200 -0
  37. package/dist/djson/djson.test.js.map +1 -0
  38. package/dist/dolphin-bench.d.ts +1 -0
  39. package/dist/dolphin-bench.js +63 -0
  40. package/dist/dolphin-bench.js.map +1 -0
  41. package/dist/hard-performance-test.d.ts +1 -0
  42. package/dist/hard-performance-test.js +97 -0
  43. package/dist/hard-performance-test.js.map +1 -0
  44. package/dist/index.d.ts +4 -4
  45. package/dist/index.js +4 -4
  46. package/dist/index.js.map +1 -1
  47. package/dist/middleware/zod.test.d.ts +1 -0
  48. package/dist/middleware/zod.test.js +74 -0
  49. package/dist/middleware/zod.test.js.map +1 -0
  50. package/dist/performance-test.d.ts +1 -0
  51. package/dist/performance-test.js +92 -0
  52. package/dist/performance-test.js.map +1 -0
  53. package/dist/real-test-mongoose.d.ts +1 -0
  54. package/dist/real-test-mongoose.js +104 -0
  55. package/dist/real-test-mongoose.js.map +1 -0
  56. package/dist/realtime/camera.d.ts +119 -0
  57. package/dist/realtime/camera.js +299 -0
  58. package/dist/realtime/camera.js.map +1 -0
  59. package/dist/realtime/camera.test.d.ts +1 -0
  60. package/dist/realtime/camera.test.js +345 -0
  61. package/dist/realtime/camera.test.js.map +1 -0
  62. package/dist/realtime/core.d.ts +5 -5
  63. package/dist/realtime/core.js +6 -6
  64. package/dist/realtime/core.js.map +1 -1
  65. package/dist/realtime/index.d.ts +6 -4
  66. package/dist/realtime/index.js +6 -4
  67. package/dist/realtime/index.js.map +1 -1
  68. package/dist/realtime/realtime.test.d.ts +1 -0
  69. package/dist/realtime/realtime.test.js +623 -0
  70. package/dist/realtime/realtime.test.js.map +1 -0
  71. package/dist/realtime/rtsp.d.ts +65 -0
  72. package/dist/realtime/rtsp.js +410 -0
  73. package/dist/realtime/rtsp.js.map +1 -0
  74. package/dist/realtime/rtsp.test.d.ts +1 -0
  75. package/dist/realtime/rtsp.test.js +361 -0
  76. package/dist/realtime/rtsp.test.js.map +1 -0
  77. package/dist/router/router.test.d.ts +1 -0
  78. package/dist/router/router.test.js +45 -0
  79. package/dist/router/router.test.js.map +1 -0
  80. package/dist/server/server.d.ts +8 -8
  81. package/dist/server/server.js +2 -11
  82. package/dist/server/server.js.map +1 -1
  83. package/dist/server/server.test.d.ts +1 -0
  84. package/dist/server/server.test.js +299 -0
  85. package/dist/server/server.test.js.map +1 -0
  86. package/dist/services/ai-service.js +22 -11
  87. package/dist/services/ai-service.js.map +1 -1
  88. package/dist/signaling/index.d.ts +1 -1
  89. package/dist/signaling/signaling.test.d.ts +1 -0
  90. package/dist/signaling/signaling.test.js +112 -0
  91. package/dist/signaling/signaling.test.js.map +1 -0
  92. package/dist/swagger/swagger.test.d.ts +1 -0
  93. package/dist/swagger/swagger.test.js +38 -0
  94. package/dist/swagger/swagger.test.js.map +1 -0
  95. package/dist/templates/index.d.ts +6 -0
  96. package/dist/templates/index.js +247 -70
  97. package/dist/templates/index.js.map +1 -1
  98. package/dist/test-2fa-real.d.ts +1 -0
  99. package/dist/test-2fa-real.js +105 -0
  100. package/dist/test-2fa-real.js.map +1 -0
  101. package/dist/test-dolphin.d.ts +1 -0
  102. package/dist/test-dolphin.js +98 -0
  103. package/dist/test-dolphin.js.map +1 -0
  104. package/dist/utils/ctx.d.ts +50 -0
  105. package/dist/utils/ctx.js +82 -0
  106. package/dist/utils/ctx.js.map +1 -0
  107. package/package.json +156 -65
  108. package/scripts/client.js +838 -703
  109. package/scripts/benchmark.js +0 -12
  110. package/scripts/benchmark.ts +0 -12
  111. package/scripts/list-models.js +0 -34
  112. package/scripts/run-real-ai-test.js +0 -79
  113. package/scripts/test-ai-logic.js +0 -44
  114. package/scripts/test-client.js +0 -105
  115. package/scripts/test-dolphin.js +0 -36
@@ -1,12 +0,0 @@
1
- const { createDolphinServer } = require('../dist/server/server');
2
-
3
- const app = createDolphinServer();
4
-
5
- app.get('/health', (ctx) => {
6
- ctx.json({ status: 'ok' });
7
- });
8
-
9
- const PORT = 5008;
10
- app.listen(PORT, () => {
11
- console.log(`Benchmark server running on port ${PORT}`);
12
- });
@@ -1,12 +0,0 @@
1
- import { createDolphinServer } from '../src/server/server';
2
-
3
- const app = createDolphinServer();
4
-
5
- app.get('/health', (ctx: any) => {
6
- ctx.json({ status: 'ok' });
7
- });
8
-
9
- const PORT = 5002;
10
- app.listen(PORT, () => {
11
- console.log(`Benchmark server running on port ${PORT}`);
12
- });
@@ -1,34 +0,0 @@
1
- /**
2
- * 🔍 Dolphin AI Diagnostic Tool
3
- * यो स्क्रिप्टले तपाइँको API Key ले कुन-कुन मोडेलहरू एक्सेस गर्न सक्छ भनेर देखाउँछ।
4
- */
5
-
6
- const https = require('https');
7
-
8
- const API_KEY = process.env.GEMINI_API_KEY || "AIzaSyA3EFr62PEEXaIRpVfW_Qd2tYMu0jftj7Y";
9
- const VERSION = "v1beta"; // सूची हेर्न प्राय: v1beta उत्तम हुन्छ
10
-
11
- console.log(`📡 Fetching available models for your API Key...`);
12
-
13
- const options = {
14
- hostname: 'generativelanguage.googleapis.com',
15
- path: `/${VERSION}/models?key=${API_KEY}`,
16
- method: 'GET'
17
- };
18
-
19
- const req = https.request(options, (res) => {
20
- let body = '';
21
- res.on('data', (d) => body += d);
22
- res.on('end', () => {
23
- const json = JSON.parse(body);
24
- if (json.models) {
25
- console.log('✅ Available Models:');
26
- json.models.forEach(m => console.log(` - ${m.name.replace('models/', '')} (${m.supportedGenerationMethods.join(', ')})`));
27
- } else {
28
- console.error('❌ Error fetching models:', json);
29
- }
30
- });
31
- });
32
-
33
- req.on('error', (e) => console.error('❌ Network Error:', e));
34
- req.end();
@@ -1,79 +0,0 @@
1
- /**
2
- * 🚀 Dolphin Real AI Integration Test
3
- * यो स्क्रिप्टले तपाइँको वास्तविक API Key प्रयोग गरेर
4
- * Google Gemini बाट कोड मगाउँछ र 'ai-demo-result.js' मा लेख्छ।
5
- */
6
-
7
- const https = require('https');
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- const API_KEY = process.env.GEMINI_API_KEY || "AIzaSyA3EFr62PEEXaIRpVfW_Qd2tYMu0jftj7Y";
12
- const MODELS = ["gemini-flash-latest", "gemini-2.0-flash", "gemini-2.5-flash", "gemini-pro-latest"];
13
- const VERSIONS = ["v1", "v1beta"];
14
-
15
- const payload = JSON.stringify({
16
- contents: [{ parts: [{ text: `Create a professional Dolphin Server app.
17
- Context: Simple health check and system info.
18
- Requirements:
19
- 1. Use ESM 'import' from 'dolphin-server-modules/server'.
20
- 2. Use 'createDolphinServer'.
21
- 3. Routes: GET '/health' (uptime) and GET '/info' (framework name).
22
- 4. Use unified context '(ctx) => ({ ... })'.
23
- 5. Include app.listen(3000).
24
- Return ONLY the pure JavaScript code, no markdown, no explanations.`
25
- }] }]
26
- });
27
-
28
- const tryAI = (mIndex, vIndex) => {
29
- if (mIndex >= MODELS.length) {
30
- console.error('❌ All models failed. Ensure your API Key from https://aistudio.google.com/ is correct and has access to these models.');
31
- return;
32
- }
33
-
34
- if (vIndex >= VERSIONS.length) {
35
- return tryAI(mIndex + 1, 0);
36
- }
37
-
38
- const MODEL = MODELS[mIndex];
39
- const VERSION = VERSIONS[vIndex];
40
- console.log(`📡 Sending request to Gemini (${MODEL} via ${VERSION})...`);
41
-
42
- const options = {
43
- hostname: 'generativelanguage.googleapis.com',
44
- path: `/${VERSION}/models/${MODEL}:generateContent?key=${API_KEY}`,
45
- method: 'POST',
46
- headers: { 'Content-Type': 'application/json' }
47
- };
48
-
49
- const req = https.request(options, (res) => {
50
- let body = '';
51
- res.on('data', (d) => body += d);
52
- res.on('end', () => {
53
- try {
54
- const json = JSON.parse(body);
55
- if (json.error) {
56
- console.warn(`⚠️ ${MODEL} (${VERSION}) failed: ${json.error.status}`);
57
- return tryAI(mIndex, vIndex + 1);
58
- }
59
- const rawCode = json.candidates?.[0]?.content?.parts?.[0]?.text || '';
60
- if (rawCode) {
61
- const codeMatch = rawCode.match(/(import|const|let|var|app|function)[\s\S]*/);
62
- const code = (codeMatch ? codeMatch[0] : rawCode).replace(/```javascript|```js|```/g, '').trim();
63
- fs.writeFileSync(path.join(process.cwd(), 'ai-demo-result.js'), code);
64
- console.log(`✅ Success! Code generated using ${MODEL} (${VERSION})`);
65
- } else {
66
- tryAI(mIndex, vIndex + 1);
67
- }
68
- } catch (e) {
69
- tryAI(mIndex, vIndex + 1);
70
- }
71
- });
72
- });
73
-
74
- req.on('error', (e) => tryAI(mIndex, vIndex + 1));
75
- req.write(payload);
76
- req.end();
77
- };
78
-
79
- tryAI(0, 0);
@@ -1,44 +0,0 @@
1
- /**
2
- * 🤖 Dolphin AI Logic Test
3
- * यो स्क्रिप्टले AI बाट आएको कच्चा (raw) रेस्पोन्सलाई
4
- * हाम्रो CLI ले कसरी सफा कोडमा बदल्छ भनेर जाँच्छ।
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- // Mock AI Response with Markdown backticks
11
- const mockAiResponse = "```javascript\nconst { createDolphinServer } = require('dolphin-server-modules/server');\nconst app = createDolphinServer();\napp.get('/', (ctx) => ({ message: 'AI Works!' }));\napp.listen(3000);\n```";
12
-
13
- function simulateParsing(rawText) {
14
- // CLI.ts मा भएको रिप्लेस लजिक
15
- return rawText.replace(/```javascript|```/g, '').trim();
16
- }
17
-
18
- function runTest() {
19
- console.log('🧪 Running AI Logic Test...');
20
-
21
- const cleanedCode = simulateParsing(mockAiResponse);
22
-
23
- console.log('\n--- Cleaned Code Output ---');
24
- console.log(cleanedCode);
25
- console.log('---------------------------\n');
26
-
27
- if (cleanedCode.includes('```') || cleanedCode.includes('javascript')) {
28
- console.error('❌ FAIL: Markdown backticks are still present!');
29
- process.exit(1);
30
- }
31
-
32
- if (!cleanedCode.includes('createDolphinServer')) {
33
- console.error('❌ FAIL: Core code logic missing!');
34
- process.exit(1);
35
- }
36
-
37
- console.log('✅ PASS: AI Response parsing logic is correct.');
38
-
39
- // Test file creation
40
- fs.writeFileSync(path.join(process.cwd(), 'ai-test-output.js'), cleanedCode);
41
- console.log('✅ PASS: Simulated file written to ai-test-output.js');
42
- }
43
-
44
- runTest();
@@ -1,105 +0,0 @@
1
- /**
2
- * Dolphin Client Logic Test
3
- * This script verifies the core logic of client.js without needing a real server.
4
- */
5
-
6
- const { DolphinClient } = require('./client');
7
-
8
- // --- Mocks ---
9
- global.fetch = async (url, options) => {
10
- console.log(`[Mock Fetch] ${options.method || 'GET'} ${url}`);
11
- return {
12
- ok: true,
13
- headers: new Map([['content-type', 'application/json']]),
14
- json: async () => ({ success: true, message: 'Mock response', data: { url, method: options.method } })
15
- };
16
- };
17
-
18
- class MockWebSocket {
19
- constructor(url) {
20
- console.log(`[Mock WS] Connecting to ${url}`);
21
- this.readyState = 1; // OPEN
22
- setTimeout(() => this.onopen && this.onopen(), 10);
23
- }
24
- send(data) { console.log(`[Mock WS] Sending: ${data}`); }
25
- close() { console.log(`[Mock WS] Closing`); }
26
- }
27
- global.WebSocket = MockWebSocket;
28
-
29
- // Storage Mock
30
- global.localStorage = {
31
- getItem: () => null,
32
- setItem: () => {},
33
- removeItem: () => {}
34
- };
35
-
36
- async function runTests() {
37
- console.log('--- Starting DolphinClient Tests ---');
38
-
39
- // 1. Constructor & Protocol Test
40
- console.log('\n[Test 1] Protocol Detection');
41
- const c1 = new DolphinClient('https://api.example.com');
42
- if (c1.httpUrl !== 'https://api.example.com') throw new Error(`Https protocol failed: ${c1.httpUrl}`);
43
-
44
- const c2 = new DolphinClient('localhost:3000');
45
- // Default should be http if not specified and not in browser
46
- if (!c2.httpUrl.startsWith('http://')) throw new Error(`Default protocol failed: ${c2.httpUrl}`);
47
- console.log('✅ Protocol detection passed');
48
-
49
- // 2. API Proxy & Method Test
50
- console.log('\n[Test 2] API Handler (Proxy & Methods)');
51
- const dolphin = new DolphinClient('localhost:3000');
52
-
53
- // Test direct get
54
- await dolphin.api.get('/products');
55
-
56
- // Test proxy path
57
- // Under the hood, this calls this._createProxy(['users']).get()
58
- await dolphin.api.users.get();
59
-
60
- // Test post with body
61
- await dolphin.api.post('/auth/login', { email: 'test@test.com' });
62
-
63
- console.log('✅ API Proxy passed');
64
-
65
- // 4. Clashing Property Test
66
- console.log('\n[Test 4] Clashing Property Names (Function built-ins)');
67
- try {
68
- const callProp = dolphin.api.call;
69
- const callType = typeof callProp;
70
- console.log(`- Type of dolphin.api.call: ${callType}`);
71
-
72
- // Since our proxy target is a function, typeof will be 'function'.
73
- // To verify it's OUR proxy and not the built-in call, check for our methods.
74
- const isOurProxy = typeof callProp.post === 'function';
75
- console.log(`- Has .post() method: ${isOurProxy}`);
76
-
77
- if (!isOurProxy) {
78
- throw new Error(`Clashing property 'call' was not shadowed by our proxy.`);
79
- }
80
- console.log('✅ Clashing properties shadowed successfully');
81
- } catch (e) {
82
- console.log(`❌ Clashing property failed: ${e.message}`);
83
- throw e;
84
- }
85
-
86
- // 3. Subscription & Memory Cleanup Test
87
- console.log('\n[Test 3] Subscriptions & Event Cleanup');
88
- let callCount = 0;
89
- const cb = () => callCount++;
90
-
91
- dolphin.subscribe('test', cb);
92
- if (!dolphin.handlers.has('test')) throw new Error('Subscribe failed');
93
-
94
- dolphin.unsubscribe('test', cb);
95
- if (dolphin.handlers.has('test')) throw new Error('Unsubscribe failed');
96
-
97
- console.log('✅ Event management passed');
98
-
99
- console.log('\n--- All Logic Tests Passed! 🐬 ---');
100
- }
101
-
102
- runTests().catch(err => {
103
- console.error('❌ Test Failed:', err);
104
- process.exit(1);
105
- });
@@ -1,36 +0,0 @@
1
- const { createDolphinServer } = require('../dist/server/server');
2
- const http = require('node:http');
3
-
4
- const app = createDolphinServer();
5
-
6
- // Mock Express Middleware
7
- app.use((req, res, next) => {
8
- req.isExpress = true;
9
- next();
10
- });
11
-
12
- app.get('/test', (ctx) => {
13
- ctx.json({
14
- success: true,
15
- isExpress: ctx.req.isExpress
16
- });
17
- });
18
-
19
- const PORT = 5005;
20
- app.listen(PORT, () => {
21
- console.log(`Test server running on port ${PORT}`);
22
-
23
- // Make a request immediately
24
- http.get(`http://127.0.0.1:${PORT}/test`, (res) => {
25
- let data = '';
26
- res.on('data', chunk => data += chunk);
27
- res.on('end', () => {
28
- console.log('STATUS:', res.statusCode);
29
- console.log('BODY:', data);
30
- process.exit(0);
31
- });
32
- }).on('error', (err) => {
33
- console.error('Request Error:', err.message);
34
- process.exit(1);
35
- });
36
- });