@futdevpro/nts-dynamo 1.15.2 → 1.15.5

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 (192) hide show
  1. package/.cursor/rules/__assistant_guide.mdc +30 -0
  2. package/.cursor/rules/__main.mdc +64 -0
  3. package/.cursor/rules/_ag_backend-structure.mdc +86 -0
  4. package/.cursor/rules/_ag_backend.mdc +16 -0
  5. package/.cursor/rules/_ag_debug.mdc +8 -0
  6. package/.cursor/rules/_ag_documentation_writing_rules.mdc +372 -0
  7. package/.cursor/rules/_ag_file-refactoring.mdc +113 -0
  8. package/.cursor/rules/_ag_fixes_rules.mdc +6 -0
  9. package/.cursor/rules/_ag_frontend-structure.mdc +87 -0
  10. package/.cursor/rules/_ag_frontend.mdc +40 -0
  11. package/.cursor/rules/_ag_import-rules.mdc +45 -0
  12. package/.cursor/rules/_ag_naming.mdc +116 -0
  13. package/.cursor/rules/_ag_running_commands.mdc +5 -0
  14. package/.cursor/rules/_ag_server-controller.mdc +6 -0
  15. package/.cursor/rules/_ag_should-be.mdc +7 -0
  16. package/.cursor/rules/_ag_swearing.mdc +47 -0
  17. package/.cursor/rules/ai_development_guide.md +61 -0
  18. package/.cursor/rules/ai_directives.md +114 -0
  19. package/.cursor/rules/cursor-rules.md +160 -0
  20. package/.cursor/rules/default-command.mdc +465 -0
  21. package/.cursor/rules/error_code_pattern.md +40 -0
  22. package/.cursor/rules/saved rule mcp server use.md +16 -0
  23. package/_specifications/BACKLOG.md +15 -0
  24. package/_specifications/TODO.md +15 -0
  25. package/build/_modules/ai/_models/ai-test-generation-result.interface.d.ts +17 -0
  26. package/build/_modules/ai/_models/ai-test-generation-result.interface.d.ts.map +1 -0
  27. package/build/_modules/ai/_models/ai-test-generation-result.interface.js +3 -0
  28. package/build/_modules/ai/_models/ai-test-generation-result.interface.js.map +1 -0
  29. package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.d.ts +36 -0
  30. package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.d.ts.map +1 -0
  31. package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.js +118 -0
  32. package/build/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.js.map +1 -0
  33. package/build/_modules/ai/_modules/anthropic/index.d.ts +3 -0
  34. package/build/_modules/ai/_modules/anthropic/index.d.ts.map +1 -0
  35. package/build/_modules/ai/_modules/anthropic/index.js +8 -0
  36. package/build/_modules/ai/_modules/anthropic/index.js.map +1 -0
  37. package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.d.ts +35 -0
  38. package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.d.ts.map +1 -0
  39. package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.js +129 -0
  40. package/build/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.js.map +1 -0
  41. package/build/_modules/ai/_modules/fdp-ai/index.d.ts +3 -0
  42. package/build/_modules/ai/_modules/fdp-ai/index.d.ts.map +1 -0
  43. package/build/_modules/ai/_modules/fdp-ai/index.js +8 -0
  44. package/build/_modules/ai/_modules/fdp-ai/index.js.map +1 -0
  45. package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.d.ts +40 -0
  46. package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.d.ts.map +1 -0
  47. package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.js +111 -0
  48. package/build/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.js.map +1 -0
  49. package/build/_modules/ai/_modules/open-ai/index.d.ts +1 -0
  50. package/build/_modules/ai/_modules/open-ai/index.d.ts.map +1 -1
  51. package/build/_modules/ai/_modules/open-ai/index.js +1 -0
  52. package/build/_modules/ai/_modules/open-ai/index.js.map +1 -1
  53. package/build/_modules/ai/_services/ai-user-key.service-base.d.ts +45 -0
  54. package/build/_modules/ai/_services/ai-user-key.service-base.d.ts.map +1 -0
  55. package/build/_modules/ai/_services/ai-user-key.service-base.js +15 -0
  56. package/build/_modules/ai/_services/ai-user-key.service-base.js.map +1 -0
  57. package/build/_modules/ai/index.d.ts +2 -0
  58. package/build/_modules/ai/index.d.ts.map +1 -1
  59. package/build/_modules/ai/index.js +2 -0
  60. package/build/_modules/ai/index.js.map +1 -1
  61. package/build/_modules/custom-data/custom-data.controller.d.ts.map +1 -1
  62. package/build/_modules/custom-data/custom-data.controller.js +1 -2
  63. package/build/_modules/custom-data/custom-data.controller.js.map +1 -1
  64. package/build/_modules/socket/app-extended.server.js +1 -1
  65. package/build/_modules/socket/app-extended.server.js.map +1 -1
  66. package/build/_services/base/data.service.d.ts +1 -1
  67. package/build/_services/base/data.service.js +1 -1
  68. package/build/_services/base/db.service.d.ts +1 -1
  69. package/build/_services/base/db.service.js +1 -1
  70. package/build/_services/core/api.service.d.ts.map +1 -1
  71. package/build/_services/core/api.service.js +1 -0
  72. package/build/_services/core/api.service.js.map +1 -1
  73. package/build/_services/core/auth.service.d.ts +2 -2
  74. package/build/_services/core/auth.service.js +1 -1
  75. package/build/_services/core/email.service.js +1 -1
  76. package/build/_services/core/email.service.js.map +1 -1
  77. package/build/_services/core/global.service.d.ts +1 -1
  78. package/build/_services/core/global.service.js +2 -2
  79. package/build/_services/core/global.service.js.map +1 -1
  80. package/build/_services/server/app.server.d.ts.map +1 -1
  81. package/build/_services/server/app.server.js +11 -1
  82. package/build/_services/server/app.server.js.map +1 -1
  83. package/package.json +18 -4
  84. package/scripts/run-coverage-tests.js +5 -1
  85. package/spec/support/helpers/spec-reporter-loader.js +359 -0
  86. package/spec/support/helpers/ts-node-helper.js +84 -0
  87. package/spec/support/jasmine.coverage.json +2 -1
  88. package/spec/support/jasmine.json +3 -3
  89. package/src/_collections/archive.util.spec.ts +36 -0
  90. package/src/_collections/get-environment-settings.util.spec.ts +210 -0
  91. package/src/_collections/star.controller.spec.ts +224 -0
  92. package/src/_models/control-models/api-call-params.control-model.spec.ts +62 -3
  93. package/src/_models/control-models/app-ext-system-controls.control-model.spec.ts +52 -0
  94. package/src/_models/control-models/app-params.control-model.spec.ts +158 -2
  95. package/src/_models/control-models/endpoint-params.control-model.spec.ts +578 -0
  96. package/src/_modules/ai/_models/ai-test-generation-result.interface.ts +16 -0
  97. package/src/_modules/ai/_modules/anthropic/_services/aai-user-key.control-service.ts +138 -0
  98. package/src/_modules/ai/_modules/anthropic/index.ts +5 -0
  99. package/src/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.spec.ts +242 -0
  100. package/src/_modules/ai/_modules/document-ai/_collections/dai-document.util.spec.ts +209 -0
  101. package/src/_modules/ai/_modules/fdp-ai/_services/fdpai-user-key.control-service.ts +189 -0
  102. package/src/_modules/ai/_modules/fdp-ai/index.ts +5 -0
  103. package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.spec.ts +342 -0
  104. package/src/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.spec.ts +550 -0
  105. package/src/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.spec.ts +240 -0
  106. package/src/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.spec.ts +462 -0
  107. package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.spec.ts +437 -0
  108. package/src/_modules/ai/_modules/open-ai/_services/oai-user-key.control-service.ts +157 -0
  109. package/src/_modules/ai/_modules/open-ai/index.ts +1 -0
  110. package/src/_modules/ai/_services/ai-embedding.service-base.spec.ts +98 -0
  111. package/src/_modules/ai/_services/ai-llm-chat.service-base.spec.ts +229 -0
  112. package/src/_modules/ai/_services/ai-llm.service-base.spec.ts +250 -0
  113. package/src/_modules/ai/_services/ai-provider.service-base.spec.ts +79 -0
  114. package/src/_modules/ai/_services/ai-user-key.service-base.ts +59 -0
  115. package/src/_modules/ai/index.ts +2 -0
  116. package/src/_modules/assistant/_collections/ass.util.spec.ts +176 -0
  117. package/src/_modules/assistant/_services/ass-io.control-service.spec.ts +140 -0
  118. package/src/_modules/assistant/_services/ass-main.control-service.spec.ts +192 -0
  119. package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.spec.ts +431 -0
  120. package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.spec.ts +160 -0
  121. package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.spec.ts +374 -0
  122. package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.spec.ts +344 -0
  123. package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.spec.ts +345 -0
  124. package/src/_modules/bot/_services/bot-commands.control-service.spec.ts +116 -0
  125. package/src/_modules/bot/_services/bot-io.control-service.spec.ts +285 -0
  126. package/src/_modules/bot/_services/bot-main.control-service.spec.ts +208 -0
  127. package/src/_modules/bot/_services/bot-messaging-provider.service-base.spec.ts +349 -0
  128. package/src/_modules/bot/_services/bot-routines.control-service.spec.ts +111 -0
  129. package/src/_modules/custom-data/custom-data.controller.spec.ts +49 -0
  130. package/src/_modules/custom-data/custom-data.controller.ts +1 -3
  131. package/src/_modules/custom-data/custom-data.data-service.spec.ts +54 -0
  132. package/src/_modules/custom-data/get-custom-data-routing-module.util.spec.ts +28 -0
  133. package/src/_modules/defaults/_services/default-auth.service.spec.ts +269 -0
  134. package/src/_modules/defaults/_services/default-socket-events.service.spec.ts +42 -0
  135. package/src/_modules/defaults/_services/default-user.data-service.spec.ts +187 -0
  136. package/src/_modules/discord-assistant/_collections/dias.util.spec.ts +366 -0
  137. package/src/_modules/discord-assistant/_services/dias-io.control-service.spec.ts +108 -0
  138. package/src/_modules/discord-assistant/_services/dias-main.control-service.spec.ts +22 -0
  139. package/src/_modules/discord-assistant/_services/dias.service-base.spec.ts +195 -0
  140. package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.spec.ts +34 -0
  141. package/src/_modules/discord-bot/_collections/dibo-operations.util.spec.ts +214 -0
  142. package/src/_modules/discord-bot/_services/dibo-commands.control-service.spec.ts +154 -0
  143. package/src/_modules/discord-bot/_services/dibo-io.control-service.spec.ts +264 -0
  144. package/src/_modules/discord-bot/_services/dibo-main.control-service.spec.ts +408 -0
  145. package/src/_modules/discord-bot/_services/dibo-routines.control-service.spec.ts +105 -0
  146. package/src/_modules/local-vector-search/_services/lvs-doc-chunk-data.service.spec.ts +418 -0
  147. package/src/_modules/local-vector-search/_services/lvs-local-vector-search.data-service.spec.ts +345 -0
  148. package/src/_modules/messaging/_collections/msg.util.spec.ts +226 -0
  149. package/src/_modules/messaging/_services/msg-events.service.spec.ts +219 -0
  150. package/src/_modules/messaging/_services/msg-main.control-service.spec.ts +147 -0
  151. package/src/_modules/messaging/_services/msg.controller.spec.ts +201 -0
  152. package/src/_modules/mock/data-model.mock.spec.ts +27 -24
  153. package/src/_modules/oauth2/_routes/oauth2.controller.spec.ts +107 -0
  154. package/src/_modules/oauth2/_services/oauth2.auth-service.spec.ts +254 -0
  155. package/src/_modules/oauth2/_services/oauth2.control-service.spec.ts +585 -0
  156. package/src/_modules/server/errors/errors.control-service.spec.ts +230 -0
  157. package/src/_modules/server/errors/errors.controller.spec.ts +165 -0
  158. package/src/_modules/server/errors/errors.data-service.spec.ts +355 -0
  159. package/src/_modules/server/server-status/server-status-snapshot.control-service.spec.ts +70 -0
  160. package/src/_modules/server/server-status/server-status-snapshot.data-service.spec.ts +77 -0
  161. package/src/_modules/server/server-status/server-status.control-service.spec.ts +516 -0
  162. package/src/_modules/server/server-status/server-status.controller.spec.ts +156 -0
  163. package/src/_modules/socket/_models/socket-client-service-params.control-model.spec.ts +6 -3
  164. package/src/_modules/socket/_models/socket-presence.control-model.spec.ts +164 -0
  165. package/src/_modules/socket/_services/socket-client.service.spec.ts +15 -0
  166. package/src/_modules/socket/app-extended.server.ts +1 -1
  167. package/src/_modules/test/get-test-routing-module.util.spec.ts +28 -0
  168. package/src/_modules/test/test.controller.spec.ts +72 -0
  169. package/src/_modules/usage/usage.controller.spec.ts +81 -0
  170. package/src/_modules/usage/usage.data-service.spec.ts +332 -0
  171. package/src/_services/base/api.service-base.spec.ts +125 -0
  172. package/src/_services/base/archive-data.service.spec.ts +196 -0
  173. package/src/_services/base/data.service.spec.ts +493 -0
  174. package/src/_services/base/data.service.ts +1 -1
  175. package/src/_services/base/db.service.spec.ts +59 -18
  176. package/src/_services/base/db.service.ts +1 -1
  177. package/src/_services/base/singleton.service-base.spec.ts +28 -0
  178. package/src/_services/base/singleton.service.spec.ts +114 -0
  179. package/src/_services/core/api.service.ts +1 -0
  180. package/src/_services/core/auth.service.spec.ts +159 -0
  181. package/src/_services/core/auth.service.ts +2 -2
  182. package/src/_services/core/email.service.spec.ts +14 -22
  183. package/src/_services/core/email.service.ts +1 -1
  184. package/src/_services/core/global.service.spec.ts +275 -0
  185. package/src/_services/core/global.service.ts +2 -2
  186. package/src/_services/core/service-collection.service.spec.ts +46 -0
  187. package/src/_services/route/controller.service.ts +1 -1
  188. package/src/_services/route/routing-module.service.spec.ts +8 -6
  189. package/src/_services/server/app.server.ts +17 -1
  190. package/src/_services/shared.static-service.spec.ts +89 -0
  191. package/src/_modules/socket/app-extended.server.spec.ts +0 -227
  192. package/src/_services/server/app.server.spec.ts +0 -138
@@ -0,0 +1,229 @@
1
+
2
+ import { DyNTS_AI_LLMChat_ServiceBase } from './ai-llm-chat.service-base';
3
+ import { DyNTS_AI_LLM_ServiceBase } from './ai-llm.service-base';
4
+ import { DyFM_AI_CallSettings, DyFM_AI_MessageRole, DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
5
+ import { DyFM_AI_ConversationBase_Input, DyFM_AI_ConversationGenericSelect_Input, DyFM_AI_ConversationGenericMultiSelect_Input, DyFM_AI_ConversationJSONKeysDescription_Input, DyFM_AI_ConversationJSONExactKeys_Input } from '../_models/ai-input-interfaces';
6
+
7
+ class TestLLMChatService extends DyNTS_AI_LLMChat_ServiceBase<DyFM_AI_CallSettings> {
8
+ readonly aiProvider: any = {} as any;
9
+ readonly capabilities: any = {} as any;
10
+ setup = (config: any): void => {};
11
+ testConnection = async (issuer: string): Promise<boolean> => true;
12
+ readonly defaultSettings: DyFM_AI_CallSettings = {
13
+ systemPrompt: 'Test system prompt',
14
+ useModel: 'test-model',
15
+ debugLog: false,
16
+ };
17
+
18
+ readonly predefinedRequests = {
19
+ yesNo: {
20
+ upperCaseYes: 'YES',
21
+ },
22
+ };
23
+
24
+ requestSimpleMessage = async (set: any): Promise<string> => { return ''; };
25
+ requestYesNo = async (set: any): Promise<boolean> => { return false; };
26
+ requestPercentage = async (set: any): Promise<number> => { return 0; };
27
+ requestSelect = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
28
+ requestMultiselect = async <T>(set: any): Promise<T[] | { unparsableResult: string }> => { return []; };
29
+ requestJSON = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
30
+ requestJSONQuestionWithKeysDescription = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
31
+ requestJSONWithExactKeys = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
32
+ requestList = async <T>(set: any): Promise<T[] | { unparsableResult: string }> => { return []; };
33
+
34
+ async requestSimpleMessageInConversation(set: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings>): Promise<string> {
35
+ return 'Test response';
36
+ }
37
+
38
+ async requestYesNoInConversation(set: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings>): Promise<boolean> {
39
+ return true;
40
+ }
41
+
42
+ async requestPercentageInConversation(set: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings>): Promise<number> {
43
+ return 50;
44
+ }
45
+
46
+ async requestSelectInConversation<T>(set: DyFM_AI_ConversationGenericSelect_Input<T, DyFM_AI_CallSettings>): Promise<T | { unparsableResult: string }> {
47
+ return null as any;
48
+ }
49
+
50
+ async requestMultiselectInConversation<T>(set: DyFM_AI_ConversationGenericMultiSelect_Input<T, DyFM_AI_CallSettings>): Promise<T[] | { unparsableResult: string }> {
51
+ return [];
52
+ }
53
+
54
+ async requestJSONInConversation<T = any>(set: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings>): Promise<T | { unparsableResult: string }> {
55
+ return null as any;
56
+ }
57
+
58
+ async requestJSONInConversationWithKeysDescription<T>(set: DyFM_AI_ConversationJSONKeysDescription_Input<DyFM_AI_CallSettings>): Promise<T | { unparsableResult: string }> {
59
+ return null as any;
60
+ }
61
+
62
+ async requestJSONInConversationWithExactKeys<T>(set: DyFM_AI_ConversationJSONExactKeys_Input<DyFM_AI_CallSettings>): Promise<T | { unparsableResult: string }> {
63
+ return null as any;
64
+ }
65
+
66
+ async requestListInConversation(set: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings>): Promise<string[] | { unparsableResult: string }> {
67
+ return [];
68
+ }
69
+
70
+ static getInstance(): TestLLMChatService {
71
+ return TestLLMChatService.getSingletonInstance();
72
+ }
73
+ }
74
+
75
+ describe('| DyNTS_AI_LLMChat_ServiceBase', () => {
76
+ let service: TestLLMChatService;
77
+
78
+ beforeEach(() => {
79
+ service = new (TestLLMChatService as any)();
80
+ });
81
+
82
+ describe('| constructor', () => {
83
+ it('| should extend LLM service base', () => {
84
+ expect(service).toBeInstanceOf(DyNTS_AI_LLM_ServiceBase);
85
+ });
86
+ });
87
+
88
+ describe('| requestSimpleMessageInConversation', () => {
89
+ it('| should request simple message in conversation', async () => {
90
+ const input: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings> = {
91
+ conversation: [
92
+ { role: DyFM_AI_MessageRole.user, content: 'Hello' },
93
+ ],
94
+ issuer: 'test-issuer',
95
+ };
96
+
97
+ const result = await service.requestSimpleMessageInConversation(input);
98
+
99
+ expect(result).toBe('Test response');
100
+ });
101
+ });
102
+
103
+ describe('| requestYesNoInConversation', () => {
104
+ it('| should request yes/no in conversation', async () => {
105
+ const input: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings> = {
106
+ conversation: [
107
+ { role: DyFM_AI_MessageRole.user, content: 'Is this true?' },
108
+ ],
109
+ issuer: 'test-issuer',
110
+ };
111
+
112
+ const result = await service.requestYesNoInConversation(input);
113
+
114
+ expect(result).toBe(true);
115
+ });
116
+ });
117
+
118
+ describe('| requestPercentageInConversation', () => {
119
+ it('| should request percentage in conversation', async () => {
120
+ const input: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings> = {
121
+ conversation: [
122
+ { role: DyFM_AI_MessageRole.user, content: 'What percentage?' },
123
+ ],
124
+ issuer: 'test-issuer',
125
+ };
126
+
127
+ const result = await service.requestPercentageInConversation(input);
128
+
129
+ expect(result).toBe(50);
130
+ });
131
+ });
132
+
133
+ describe('| requestSelectInConversation', () => {
134
+ it('| should request select in conversation', async () => {
135
+ const input: DyFM_AI_ConversationGenericSelect_Input<string, DyFM_AI_CallSettings> = {
136
+ conversation: [
137
+ { role: DyFM_AI_MessageRole.user, content: 'Choose one' },
138
+ ],
139
+ selectFrom: ['option1', 'option2'],
140
+ issuer: 'test-issuer',
141
+ };
142
+
143
+ const result = await service.requestSelectInConversation(input);
144
+
145
+ expect(result).toBeDefined();
146
+ });
147
+ });
148
+
149
+ describe('| requestMultiselectInConversation', () => {
150
+ it('| should request multiselect in conversation', async () => {
151
+ const input: DyFM_AI_ConversationGenericMultiSelect_Input<string, DyFM_AI_CallSettings> = {
152
+ conversation: [
153
+ { role: DyFM_AI_MessageRole.user, content: 'Choose multiple' },
154
+ ],
155
+ options: ['option1', 'option2'],
156
+ issuer: 'test-issuer',
157
+ };
158
+
159
+ const result = await service.requestMultiselectInConversation(input);
160
+
161
+ expect(result).toBeDefined();
162
+ expect(Array.isArray(result)).toBe(true);
163
+ });
164
+ });
165
+
166
+ describe('| requestJSONInConversation', () => {
167
+ it('| should request JSON in conversation', async () => {
168
+ const input: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings> = {
169
+ conversation: [
170
+ { role: DyFM_AI_MessageRole.user, content: 'Return JSON' },
171
+ ],
172
+ issuer: 'test-issuer',
173
+ };
174
+
175
+ const result = await service.requestJSONInConversation(input);
176
+
177
+ expect(result).toBeDefined();
178
+ });
179
+ });
180
+
181
+ describe('| requestJSONInConversationWithKeysDescription', () => {
182
+ it('| should request JSON with keys description in conversation', async () => {
183
+ const input: DyFM_AI_ConversationJSONKeysDescription_Input<DyFM_AI_CallSettings> = {
184
+ conversation: [
185
+ { role: DyFM_AI_MessageRole.user, content: 'Return JSON with keys' },
186
+ ],
187
+ keysDescription: 'key1: Description 1',
188
+ issuer: 'test-issuer',
189
+ };
190
+
191
+ const result = await service.requestJSONInConversationWithKeysDescription(input);
192
+
193
+ expect(result).toBeDefined();
194
+ });
195
+ });
196
+
197
+ describe('| requestJSONInConversationWithExactKeys', () => {
198
+ it('| should request JSON with exact keys in conversation', async () => {
199
+ const input: DyFM_AI_ConversationJSONExactKeys_Input<DyFM_AI_CallSettings> = {
200
+ conversation: [
201
+ { role: DyFM_AI_MessageRole.user, content: 'Return JSON with exact keys' },
202
+ ],
203
+ keys: ['key1', 'key2'],
204
+ issuer: 'test-issuer',
205
+ };
206
+
207
+ const result = await service.requestJSONInConversationWithExactKeys(input);
208
+
209
+ expect(result).toBeDefined();
210
+ });
211
+ });
212
+
213
+ describe('| requestListInConversation', () => {
214
+ it('| should request list in conversation', async () => {
215
+ const input: DyFM_AI_ConversationBase_Input<DyFM_AI_CallSettings> = {
216
+ conversation: [
217
+ { role: DyFM_AI_MessageRole.user, content: 'Return list' },
218
+ ],
219
+ issuer: 'test-issuer',
220
+ };
221
+
222
+ const result = await service.requestListInConversation(input);
223
+
224
+ expect(result).toBeDefined();
225
+ expect(Array.isArray(result)).toBe(true);
226
+ });
227
+ });
228
+ });
229
+
@@ -0,0 +1,250 @@
1
+
2
+ import { DyNTS_AI_LLM_ServiceBase } from './ai-llm.service-base';
3
+ import { DyFM_AI_CallSettings, DyFM_AI_MessageRole } from '@futdevpro/fsm-dynamo/ai';
4
+ import { DyFM_Log, DyFM_Object } from '@futdevpro/fsm-dynamo';
5
+
6
+ class TestLLMService extends DyNTS_AI_LLM_ServiceBase<DyFM_AI_CallSettings> {
7
+ readonly aiProvider: any = {} as any;
8
+ readonly capabilities: any = {} as any;
9
+ setup = (config: any): void => {};
10
+ testConnection = async (issuer: string): Promise<boolean> => true;
11
+ readonly defaultSettings: DyFM_AI_CallSettings = {
12
+ systemPrompt: 'Test system prompt',
13
+ useModel: 'test-model',
14
+ debugLog: false,
15
+ };
16
+
17
+ readonly predefinedRequests = {
18
+ yesNo: {
19
+ upperCaseYes: 'YES',
20
+ },
21
+ };
22
+
23
+ requestSimpleMessage = async (set: any): Promise<string> => { return ''; };
24
+ requestYesNo = async (set: any): Promise<boolean> => { return false; };
25
+ requestPercentage = async (set: any): Promise<number> => { return 0; };
26
+ requestSelect = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
27
+ requestMultiselect = async <T>(set: any): Promise<T[] | { unparsableResult: string }> => { return []; };
28
+ requestJSON = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
29
+ requestJSONQuestionWithKeysDescription = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
30
+ requestJSONWithExactKeys = async <T>(set: any): Promise<T | { unparsableResult: string }> => { return null as any; };
31
+ requestList = async <T>(set: any): Promise<T[] | { unparsableResult: string }> => { return []; };
32
+
33
+ static getInstance(): TestLLMService {
34
+ return TestLLMService.getSingletonInstance();
35
+ }
36
+ }
37
+
38
+ describe('| DyNTS_AI_LLM_ServiceBase', () => {
39
+ let service: TestLLMService;
40
+
41
+ beforeEach(() => {
42
+ service = TestLLMService.getInstance();
43
+ });
44
+
45
+ it('| should be a singleton instance', () => {
46
+ const instance1 = TestLLMService.getInstance();
47
+ const instance2 = TestLLMService.getInstance();
48
+
49
+ expect(instance1).toBe(instance2);
50
+ expect(instance1).toBeInstanceOf(TestLLMService);
51
+ });
52
+
53
+ describe('| defaultSystemPrompt', () => {
54
+ it('| should return system prompt from default settings', () => {
55
+ expect(service.defaultSystemPrompt).toBe('Test system prompt');
56
+ });
57
+ });
58
+
59
+ describe('| defaultModel', () => {
60
+ it('| should return model from default settings', () => {
61
+ expect(service.defaultModel).toBe('test-model');
62
+ });
63
+ });
64
+
65
+ describe('| debugLog', () => {
66
+ it('| should return debugLog from default settings', () => {
67
+ expect(service.debugLog).toBe(false);
68
+ });
69
+
70
+ it('| should return _debugLog when defaultSettings debugLog is not set', () => {
71
+ const serviceWithoutDebugLog = new (class extends TestLLMService {
72
+ override readonly defaultSettings: DyFM_AI_CallSettings = {
73
+ systemPrompt: 'Test',
74
+ useModel: 'test',
75
+ };
76
+ override readonly aiProvider: any = {} as any;
77
+ override readonly capabilities: any = {} as any;
78
+ override setup = (config: any): void => {};
79
+ override testConnection = async (issuer: string): Promise<boolean> => true;
80
+ } as any)();
81
+
82
+ // Set _debugLog on the new instance
83
+ serviceWithoutDebugLog._debugLog = true;
84
+ expect(serviceWithoutDebugLog.debugLog).toBe(true);
85
+ });
86
+ });
87
+
88
+ describe('| convertAnswerToBoolean', () => {
89
+ it('| should return true when answer contains YES', () => {
90
+ const result = (service as any).convertAnswerToBoolean('YES');
91
+
92
+ expect(result).toBe(true);
93
+ });
94
+
95
+ it('| should return true when answer contains yes in uppercase', () => {
96
+ const result = (service as any).convertAnswerToBoolean('The answer is YES');
97
+
98
+ expect(result).toBe(true);
99
+ });
100
+
101
+ it('| should return false when answer does not contain YES', () => {
102
+ const result = (service as any).convertAnswerToBoolean('NO');
103
+
104
+ expect(result).toBe(false);
105
+ });
106
+
107
+ it('| should be case insensitive', () => {
108
+ const result = (service as any).convertAnswerToBoolean('yes');
109
+
110
+ expect(result).toBe(true);
111
+ });
112
+ });
113
+
114
+ describe('| convertAnswerToNumber', () => {
115
+ it('| should return number when answer is valid', () => {
116
+ const result = (service as any).convertAnswerToNumber('42', 'What is the answer?');
117
+
118
+ expect(result).toBe(42);
119
+ });
120
+
121
+ it('| should return null when answer is invalid (contains skip flag)', () => {
122
+ spyOn(service as any, 'isAnswerValid').and.returnValue(true);
123
+
124
+ const result = (service as any).convertAnswerToNumber('42', 'What is the answer?');
125
+
126
+ expect(result).toBeNull();
127
+ });
128
+
129
+ it('| should return null when answer is NaN', () => {
130
+ const logSpy = spyOn(DyFM_Log, 'T_error');
131
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
132
+
133
+ const result = (service as any).convertAnswerToNumber('not-a-number', 'What is the answer?');
134
+
135
+ expect(result).toBeNull();
136
+ expect(logSpy).toHaveBeenCalled();
137
+ });
138
+
139
+ it('| should handle decimal numbers', () => {
140
+ const result = (service as any).convertAnswerToNumber('42.5', 'What is the answer?');
141
+
142
+ expect(result).toBe(42.5);
143
+ });
144
+ });
145
+
146
+ describe('| convertAnswerToSelectOption', () => {
147
+ it('| should return selected option when found', () => {
148
+ const options = ['option1', 'option2', 'option3'];
149
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
150
+ spyOn(service as any, 'stringifySelectOptions').and.returnValue(['option1', 'option2', 'option3']);
151
+
152
+ const result = (service as any).convertAnswerToSelectOption('option1', 'Select an option', options);
153
+
154
+ expect(result).toBe('option1');
155
+ });
156
+
157
+ it('| should return null when answer is invalid', () => {
158
+ spyOn(service as any, 'isAnswerValid').and.returnValue(true);
159
+
160
+ const result = (service as any).convertAnswerToSelectOption('option1', 'Select an option', ['option1']);
161
+
162
+ expect(result).toBeNull();
163
+ });
164
+
165
+ it('| should return null when option not found', () => {
166
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
167
+ spyOn(service as any, 'stringifySelectOptions').and.returnValue(['option1', 'option2']);
168
+
169
+ const result = (service as any).convertAnswerToSelectOption('option3', 'Select an option', ['option1', 'option2']);
170
+
171
+ expect(result).toBeNull();
172
+ });
173
+
174
+ it('| should handle JSON options', () => {
175
+ const options = [{ id: 1, name: 'test' }];
176
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
177
+ spyOn(service as any, 'stringifySelectOptions').and.returnValue([JSON.stringify({ id: 1, name: 'test' })]);
178
+ spyOn(DyFM_Object, 'safeParseJSON').and.returnValue({ id: 1, name: 'test' });
179
+
180
+ const result = (service as any).convertAnswerToSelectOption(
181
+ JSON.stringify({ id: 1, name: 'test' }),
182
+ 'Select an option',
183
+ options
184
+ );
185
+
186
+ expect(result).toEqual({ id: 1, name: 'test' });
187
+ });
188
+ });
189
+
190
+ describe('| convertAnswerToSelectOptions', () => {
191
+ it('| should return multiple selected options', () => {
192
+ const options = ['option1', 'option2', 'option3'];
193
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
194
+ spyOn(service as any, 'stringifySelectOption').and.callFake((opt: string) => opt);
195
+
196
+ const result = (service as any).convertAnswerToSelectOptions('option1 and option2', 'Select options', options);
197
+
198
+ expect(result).toEqual(['option1', 'option2']);
199
+ });
200
+
201
+ it('| should return null when answer is invalid', () => {
202
+ spyOn(service as any, 'isAnswerValid').and.returnValue(true);
203
+
204
+ const result = (service as any).convertAnswerToSelectOptions('option1', 'Select options', ['option1']);
205
+
206
+ expect(result).toBeNull();
207
+ });
208
+
209
+ it('| should return empty array when no options match', () => {
210
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
211
+ spyOn(service as any, 'stringifySelectOption').and.callFake((opt: string) => opt);
212
+
213
+ const result = (service as any).convertAnswerToSelectOptions('option4', 'Select options', ['option1', 'option2']);
214
+
215
+ expect(result).toEqual([]);
216
+ });
217
+ });
218
+
219
+ describe('| convertAnswerToJSON', () => {
220
+ it('| should return parsed JSON when valid', () => {
221
+ const jsonString = '{"key": "value"}';
222
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
223
+ spyOn(DyFM_Object, 'safeParseJSON').and.returnValue({ key: 'value' });
224
+
225
+ const result = (service as any).convertAnswerToJSON(jsonString, 'Enter JSON') as { key: string };
226
+
227
+ expect(result).toEqual({ key: 'value' });
228
+ });
229
+
230
+ it('| should return unparsableResult when answer is invalid', () => {
231
+ spyOn(service as any, 'isAnswerValid').and.returnValue(true);
232
+
233
+ const result = (service as any).convertAnswerToJSON('{"key": "value"}', 'Enter JSON');
234
+
235
+ expect(result).toEqual({ unparsableResult: '{"key": "value"}' });
236
+ });
237
+
238
+ it('| should return unparsableResult when JSON is invalid', () => {
239
+ const logSpy = spyOn(DyFM_Log, 'T_error');
240
+ spyOn(service as any, 'isAnswerValid').and.returnValue(false);
241
+ spyOn(DyFM_Object, 'safeParseJSON').and.returnValue({ unparsableResult: 'invalid json' });
242
+
243
+ const result = (service as any).convertAnswerToJSON('invalid json', 'Enter JSON');
244
+
245
+ expect(result).toEqual({ unparsableResult: 'invalid json' });
246
+ expect(logSpy).toHaveBeenCalled();
247
+ });
248
+ });
249
+ });
250
+
@@ -0,0 +1,79 @@
1
+
2
+ import { DyNTS_AI_Provider_ServiceBase } from './ai-provider.service-base';
3
+ import { DyFM_AI_Provider, DyFM_AI_ProviderCapabilities, DyFM_AI_Config } from '@futdevpro/fsm-dynamo/ai';
4
+
5
+ class TestProviderService extends DyNTS_AI_Provider_ServiceBase {
6
+ readonly aiProvider: DyFM_AI_Provider = DyFM_AI_Provider.OpenAI;
7
+ readonly capabilities: DyFM_AI_ProviderCapabilities = {
8
+ chat: true,
9
+ embeddings: true,
10
+ imageGeneration: false,
11
+ vision: false,
12
+ audioGeneration: false,
13
+ audioAnalysis: false,
14
+ functionCalling: false,
15
+ streaming: false,
16
+ batchOperations: false,
17
+ supportedModelTypes: [],
18
+ };
19
+
20
+ setup = (config: DyFM_AI_Config): void => {
21
+ // Mock implementation
22
+ };
23
+
24
+ testConnection = async (issuer: string): Promise<boolean> => {
25
+ return true;
26
+ };
27
+
28
+ static getInstance(): TestProviderService {
29
+ return TestProviderService.getSingletonInstance();
30
+ }
31
+ }
32
+
33
+ describe('| DyNTS_AI_Provider_ServiceBase', () => {
34
+ let service: TestProviderService;
35
+
36
+ beforeEach(() => {
37
+ service = TestProviderService.getInstance();
38
+ });
39
+
40
+ it('| should be a singleton instance', () => {
41
+ const instance1 = TestProviderService.getInstance();
42
+ const instance2 = TestProviderService.getInstance();
43
+
44
+ expect(instance1).toBe(instance2);
45
+ expect(instance1).toBeInstanceOf(TestProviderService);
46
+ });
47
+
48
+ it('| should have aiProvider property', () => {
49
+ expect(service.aiProvider).toBe(DyFM_AI_Provider.OpenAI);
50
+ });
51
+
52
+ it('| should have capabilities property', () => {
53
+ expect(service.capabilities).toBeDefined();
54
+ expect(service.capabilities.chat).toBe(true);
55
+ expect(service.capabilities.embeddings).toBe(true);
56
+ expect(service.capabilities.chat).toBe(true);
57
+ });
58
+
59
+ describe('| setup', () => {
60
+ it('| should accept config parameter', () => {
61
+ const config: DyFM_AI_Config = {
62
+ apiKey: 'test-key',
63
+ };
64
+
65
+ expect(() => {
66
+ service.setup(config);
67
+ }).not.toThrow();
68
+ });
69
+ });
70
+
71
+ describe('| testConnection', () => {
72
+ it('| should return true when connection is successful', async () => {
73
+ const result = await service.testConnection('issuer-123');
74
+
75
+ expect(result).toBe(true);
76
+ });
77
+ });
78
+ });
79
+
@@ -0,0 +1,59 @@
1
+ import { DyFM_AI_Provider, DyFM_AI_Config } from '@futdevpro/fsm-dynamo/ai';
2
+ import { DyFM_AI_UserProviderConfig } from '@futdevpro/fsm-dynamo/ai';
3
+
4
+ import { DyNTS_SingletonService } from '../../../_services/base/singleton.service';
5
+ import { DyNTS_AI_TestGeneration_Result } from '../_models/ai-test-generation-result.interface';
6
+
7
+ /**
8
+ * Absztrakt bazis osztaly a user AI provider kulcs kezeleshez
9
+ *
10
+ * A titkositas/visszafejtes NEM itt tortenik -- azt az fdp-auth-service Auth_ControlService-e vegzi.
11
+ * Ezek a service-ek a mar visszafejtett config-ot es API kulcsot kapjak,
12
+ * es abbol allitjak ossze a provider-specifikus konfigot.
13
+ */
14
+ export abstract class DyNTS_AI_UserKey_ServiceBase extends DyNTS_SingletonService {
15
+ /** melyik provider-hez tartozik ez a service */
16
+ abstract readonly aiProvider: DyFM_AI_Provider;
17
+
18
+ /**
19
+ * Visszafejtett user config + kulcs -> provider-specifikus AI config osszeallitas
20
+ * @param userProviderConfig - a user provider konfiguracioja
21
+ * @param decryptedApiKey - a mar visszafejtett API kulcs
22
+ */
23
+ abstract resolveConfig(
24
+ userProviderConfig: DyFM_AI_UserProviderConfig,
25
+ decryptedApiKey: string
26
+ ): DyFM_AI_Config;
27
+
28
+ /**
29
+ * Kapcsolat tesztelese a provider-rel a visszafejtett kulccsal
30
+ * @param userProviderConfig - a user provider konfiguracioja
31
+ * @param decryptedApiKey - a mar visszafejtett API kulcs
32
+ */
33
+ abstract testConnection(
34
+ userProviderConfig: DyFM_AI_UserProviderConfig,
35
+ decryptedApiKey: string
36
+ ): Promise<boolean>;
37
+
38
+ /**
39
+ * Elerheto modellek lekerdezese a provider API-rol
40
+ * @param userProviderConfig - a user provider konfiguracioja
41
+ * @param decryptedApiKey - a mar visszafejtett API kulcs
42
+ */
43
+ abstract listAvailableModels(
44
+ userProviderConfig: DyFM_AI_UserProviderConfig,
45
+ decryptedApiKey: string
46
+ ): Promise<string[]>;
47
+
48
+ /**
49
+ * Teszt generalas a provider-rel
50
+ * @param set.userProviderConfig - a user provider konfiguracioja
51
+ * @param set.decryptedApiKey - a mar visszafejtett API kulcs
52
+ * @param set.model - a hasznalando modell
53
+ */
54
+ abstract testGeneration(set: {
55
+ userProviderConfig: DyFM_AI_UserProviderConfig;
56
+ decryptedApiKey: string;
57
+ model: string;
58
+ }): Promise<DyNTS_AI_TestGeneration_Result>;
59
+ }
@@ -3,9 +3,11 @@ export * from '@futdevpro/fsm-dynamo/ai';
3
3
 
4
4
  // AI Input Interfaces (moved from FSM)
5
5
  export * from './_models/ai-input-interfaces';
6
+ export * from './_models/ai-test-generation-result.interface';
6
7
 
7
8
  // Abstract Services
8
9
  export * from './_services/ai-provider.service-base';
9
10
  export * from './_services/ai-llm.service-base';
10
11
  export * from './_services/ai-llm-chat.service-base';
11
12
  export * from './_services/ai-embedding.service-base';
13
+ export * from './_services/ai-user-key.service-base';