@memberjunction/query-gen 6.2.0-edge.0 → 6.2.0-edge.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 (111) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +130 -0
  3. package/dist/cli/commands/export.d.ts +2 -0
  4. package/dist/cli/commands/export.d.ts.map +1 -1
  5. package/dist/cli/commands/export.js +10 -6
  6. package/dist/cli/commands/export.js.map +1 -1
  7. package/dist/cli/commands/generate.d.ts +2 -0
  8. package/dist/cli/commands/generate.d.ts.map +1 -1
  9. package/dist/cli/commands/generate.js +19 -15
  10. package/dist/cli/commands/generate.js.map +1 -1
  11. package/dist/cli/commands/validate.d.ts +2 -0
  12. package/dist/cli/commands/validate.d.ts.map +1 -1
  13. package/dist/cli/commands/validate.js +12 -8
  14. package/dist/cli/commands/validate.js.map +1 -1
  15. package/dist/cli/config.d.ts +2 -0
  16. package/dist/cli/config.d.ts.map +1 -1
  17. package/dist/cli/config.js +5 -1
  18. package/dist/cli/config.js.map +1 -1
  19. package/dist/cli/index.js +6 -6
  20. package/dist/core/EntityGrouper.d.ts +2 -0
  21. package/dist/core/EntityGrouper.d.ts.map +1 -1
  22. package/dist/core/EntityGrouper.js +13 -9
  23. package/dist/core/EntityGrouper.js.map +1 -1
  24. package/dist/core/MetadataExporter.d.ts +2 -0
  25. package/dist/core/MetadataExporter.d.ts.map +1 -1
  26. package/dist/core/MetadataExporter.js +5 -1
  27. package/dist/core/MetadataExporter.js.map +1 -1
  28. package/dist/core/QueryDatabaseWriter.d.ts +2 -0
  29. package/dist/core/QueryDatabaseWriter.d.ts.map +1 -1
  30. package/dist/core/QueryDatabaseWriter.js +7 -3
  31. package/dist/core/QueryDatabaseWriter.js.map +1 -1
  32. package/dist/core/QueryFixer.d.ts +2 -0
  33. package/dist/core/QueryFixer.d.ts.map +1 -1
  34. package/dist/core/QueryFixer.js +9 -5
  35. package/dist/core/QueryFixer.js.map +1 -1
  36. package/dist/core/QueryRefiner.d.ts +2 -0
  37. package/dist/core/QueryRefiner.d.ts.map +1 -1
  38. package/dist/core/QueryRefiner.js +12 -8
  39. package/dist/core/QueryRefiner.js.map +1 -1
  40. package/dist/core/QueryTester.d.ts +2 -0
  41. package/dist/core/QueryTester.d.ts.map +1 -1
  42. package/dist/core/QueryTester.js +9 -5
  43. package/dist/core/QueryTester.js.map +1 -1
  44. package/dist/core/QueryWriter.d.ts +2 -0
  45. package/dist/core/QueryWriter.d.ts.map +1 -1
  46. package/dist/core/QueryWriter.js +9 -5
  47. package/dist/core/QueryWriter.js.map +1 -1
  48. package/dist/core/QuestionGenerator.d.ts +2 -0
  49. package/dist/core/QuestionGenerator.d.ts.map +1 -1
  50. package/dist/core/QuestionGenerator.js +11 -7
  51. package/dist/core/QuestionGenerator.js.map +1 -1
  52. package/dist/index.d.ts +6 -6
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +6 -6
  55. package/dist/index.js.map +1 -1
  56. package/dist/utils/category-builder.d.ts +4 -0
  57. package/dist/utils/category-builder.d.ts.map +1 -1
  58. package/dist/utils/category-builder.js +10 -2
  59. package/dist/utils/category-builder.js.map +1 -1
  60. package/dist/utils/entity-helpers.d.ts +14 -0
  61. package/dist/utils/entity-helpers.d.ts.map +1 -1
  62. package/dist/utils/entity-helpers.js +36 -8
  63. package/dist/utils/entity-helpers.js.map +1 -1
  64. package/dist/utils/error-handlers.d.ts +6 -0
  65. package/dist/utils/error-handlers.d.ts.map +1 -1
  66. package/dist/utils/error-handlers.js +15 -3
  67. package/dist/utils/error-handlers.js.map +1 -1
  68. package/dist/utils/graph-helpers.d.ts +6 -0
  69. package/dist/utils/graph-helpers.d.ts.map +1 -1
  70. package/dist/utils/graph-helpers.js +15 -3
  71. package/dist/utils/graph-helpers.js.map +1 -1
  72. package/dist/utils/prompt-helpers.d.ts +6 -0
  73. package/dist/utils/prompt-helpers.d.ts.map +1 -1
  74. package/dist/utils/prompt-helpers.js +5 -1
  75. package/dist/utils/prompt-helpers.js.map +1 -1
  76. package/dist/utils/user-helpers.d.ts +2 -0
  77. package/dist/utils/user-helpers.d.ts.map +1 -1
  78. package/dist/utils/user-helpers.js +5 -1
  79. package/dist/utils/user-helpers.js.map +1 -1
  80. package/dist/vectors/EmbeddingService.d.ts +14 -0
  81. package/dist/vectors/EmbeddingService.d.ts.map +1 -1
  82. package/dist/vectors/EmbeddingService.js +17 -5
  83. package/dist/vectors/EmbeddingService.js.map +1 -1
  84. package/dist/vectors/SimilaritySearch.d.ts +2 -0
  85. package/dist/vectors/SimilaritySearch.d.ts.map +1 -1
  86. package/dist/vectors/SimilaritySearch.js +5 -1
  87. package/dist/vectors/SimilaritySearch.js.map +1 -1
  88. package/package.json +11 -11
  89. package/src/__tests__/QueryGen.test.ts +22 -22
  90. package/src/cli/commands/export.ts +11 -6
  91. package/src/cli/commands/generate.ts +20 -15
  92. package/src/cli/commands/validate.ts +13 -8
  93. package/src/cli/config.ts +6 -1
  94. package/src/cli/index.ts +6 -6
  95. package/src/core/EntityGrouper.ts +17 -9
  96. package/src/core/MetadataExporter.ts +10 -1
  97. package/src/core/QueryDatabaseWriter.ts +11 -3
  98. package/src/core/QueryFixer.ts +15 -5
  99. package/src/core/QueryRefiner.ts +18 -8
  100. package/src/core/QueryTester.ts +13 -5
  101. package/src/core/QueryWriter.ts +14 -5
  102. package/src/core/QuestionGenerator.ts +12 -7
  103. package/src/index.ts +12 -12
  104. package/src/utils/category-builder.ts +15 -2
  105. package/src/utils/entity-helpers.ts +44 -9
  106. package/src/utils/error-handlers.ts +22 -3
  107. package/src/utils/graph-helpers.ts +18 -3
  108. package/src/utils/prompt-helpers.ts +11 -1
  109. package/src/utils/user-helpers.ts +6 -1
  110. package/src/vectors/EmbeddingService.ts +30 -5
  111. package/src/vectors/SimilaritySearch.ts +10 -1
@@ -9,9 +9,9 @@ import { AIEngine } from '@memberjunction/aiengine';
9
9
  import { MJAIPromptEntityExtended } from '@memberjunction/ai-core-plus';
10
10
  import { UserInfo, LogStatus } from '@memberjunction/core';
11
11
  import { QueryGenConfig } from '../cli/config';
12
- import { extractErrorMessage } from '../utils/error-handlers';
13
- import { formatEntityGroupForPrompt } from '../utils/entity-helpers';
14
- import { executePromptWithOverrides } from '../utils/prompt-helpers';
12
+ import { ExtractErrorMessage } from '../utils/error-handlers';
13
+ import { FormatEntityGroupForPrompt } from '../utils/entity-helpers';
14
+ import { ExecutePromptWithOverrides } from '../utils/prompt-helpers';
15
15
  import { EntityGroup, BusinessQuestion } from '../data/schema';
16
16
  import { PROMPT_BUSINESS_QUESTION_GENERATOR } from '../prompts/PromptNames';
17
17
 
@@ -39,7 +39,7 @@ export class QuestionGenerator {
39
39
  * @param entityGroup - Entity group to generate questions for
40
40
  * @returns Array of validated business questions
41
41
  */
42
- async generateQuestions(entityGroup: EntityGroup): Promise<BusinessQuestion[]> {
42
+ async GenerateQuestions(entityGroup: EntityGroup): Promise<BusinessQuestion[]> {
43
43
  try {
44
44
  // Ensure AIEngine is configured
45
45
  const aiEngine = AIEngine.Instance;
@@ -49,7 +49,7 @@ export class QuestionGenerator {
49
49
  const prompt = this.findPromptByName(aiEngine, PROMPT_BUSINESS_QUESTION_GENERATOR);
50
50
 
51
51
  // Format entity group for prompt
52
- const entityMetadata = formatEntityGroupForPrompt(entityGroup);
52
+ const entityMetadata = FormatEntityGroupForPrompt(entityGroup);
53
53
 
54
54
  // Execute AI prompt
55
55
  const result = await this.executePrompt(prompt, entityMetadata);
@@ -75,11 +75,16 @@ export class QuestionGenerator {
75
75
  return validQuestions;
76
76
  } catch (error: unknown) {
77
77
  throw new Error(
78
- extractErrorMessage(error, 'QuestionGenerator.generateQuestions')
78
+ ExtractErrorMessage(error, 'QuestionGenerator.generateQuestions')
79
79
  );
80
80
  }
81
81
  }
82
82
 
83
+ /** @deprecated Use {@link GenerateQuestions}. */
84
+ async generateQuestions(entityGroup: EntityGroup): Promise<BusinessQuestion[]> {
85
+ return this.GenerateQuestions(entityGroup);
86
+ }
87
+
83
88
  /**
84
89
  * Find prompt by name in AIEngine cache
85
90
  * Throws if prompt not found
@@ -103,7 +108,7 @@ export class QuestionGenerator {
103
108
  prompt: MJAIPromptEntityExtended,
104
109
  entityMetadata: unknown
105
110
  ): Promise<QuestionGeneratorResult> {
106
- const result = await executePromptWithOverrides<QuestionGeneratorResult>(
111
+ const result = await ExecutePromptWithOverrides<QuestionGeneratorResult>(
107
112
  prompt,
108
113
  { entityGroupMetadata: entityMetadata },
109
114
  this.contextUser,
package/src/index.ts CHANGED
@@ -28,21 +28,21 @@ export * from './data/schema';
28
28
  export * from './prompts/PromptNames';
29
29
 
30
30
  // Export configuration
31
- export { QueryGenConfig, loadConfig } from './cli/config';
31
+ export { QueryGenConfig, LoadConfig, loadConfig } from './cli/config';
32
32
 
33
33
  // Export CLI commands
34
- export { generateCommand } from './cli/commands/generate';
35
- export { validateCommand } from './cli/commands/validate';
36
- export { exportCommand } from './cli/commands/export';
34
+ export { GenerateCommand, generateCommand } from './cli/commands/generate';
35
+ export { ValidateCommand, validateCommand } from './cli/commands/validate';
36
+ export { ExportCommand, exportCommand } from './cli/commands/export';
37
37
 
38
38
  // Export utilities
39
- export { extractErrorMessage, requireValue, getPropertyOrDefault } from './utils/error-handlers';
39
+ export { ExtractErrorMessage, extractErrorMessage, RequireValue, requireValue, GetPropertyOrDefault, getPropertyOrDefault } from './utils/error-handlers';
40
40
  export {
41
- formatEntityMetadataForPrompt,
42
- formatEntityGroupForPrompt,
43
- findEntityById,
44
- getPrimaryKeyFields,
45
- getForeignKeyFields,
46
- hasRelationships,
47
- getRelationshipCount
41
+ FormatEntityMetadataForPrompt, formatEntityMetadataForPrompt,
42
+ FormatEntityGroupForPrompt, formatEntityGroupForPrompt,
43
+ FindEntityById, findEntityById,
44
+ GetPrimaryKeyFields, getPrimaryKeyFields,
45
+ GetForeignKeyFields, getForeignKeyFields,
46
+ HasRelationships, hasRelationships,
47
+ GetRelationshipCount, getRelationshipCount
48
48
  } from './utils/entity-helpers';
@@ -15,7 +15,7 @@ import { QueryGenConfig } from '../cli/config';
15
15
  * @param entityGroup - Entity group for the query
16
16
  * @returns QueryCategoryInfo with full category details
17
17
  */
18
- export function buildQueryCategory(
18
+ export function BuildQueryCategory(
19
19
  config: QueryGenConfig,
20
20
  entityGroup: EntityGroup
21
21
  ): QueryCategoryInfo {
@@ -52,6 +52,14 @@ export function buildQueryCategory(
52
52
  }
53
53
  }
54
54
 
55
+ /** @deprecated Use {@link BuildQueryCategory}. */
56
+ export function buildQueryCategory(
57
+ config: QueryGenConfig,
58
+ entityGroup: EntityGroup
59
+ ): QueryCategoryInfo {
60
+ return BuildQueryCategory(config, entityGroup);
61
+ }
62
+
55
63
  /**
56
64
  * Extract all unique categories from validated queries
57
65
  * Returns categories in hierarchical order (root first, then children)
@@ -62,7 +70,7 @@ export function buildQueryCategory(
62
70
  * @param categories - Array of QueryCategoryInfo from validated queries
63
71
  * @returns Unique categories sorted hierarchically (includes auto-generated parents)
64
72
  */
65
- export function extractUniqueCategories(categories: QueryCategoryInfo[]): QueryCategoryInfo[] {
73
+ export function ExtractUniqueCategories(categories: QueryCategoryInfo[]): QueryCategoryInfo[] {
66
74
  const uniqueMap = new Map<string, QueryCategoryInfo>();
67
75
 
68
76
  // Collect all unique categories (by path)
@@ -95,3 +103,8 @@ export function extractUniqueCategories(categories: QueryCategoryInfo[]): QueryC
95
103
 
96
104
  return result;
97
105
  }
106
+
107
+ /** @deprecated Use {@link ExtractUniqueCategories}. */
108
+ export function extractUniqueCategories(categories: QueryCategoryInfo[]): QueryCategoryInfo[] {
109
+ return ExtractUniqueCategories(categories);
110
+ }
@@ -23,7 +23,7 @@ import {
23
23
  * @param allEntities - All available entities for relationship lookups
24
24
  * @returns Formatted entity metadata ready for AI prompts
25
25
  */
26
- export function formatEntityMetadataForPrompt(entity: EntityInfo, allEntities: EntityInfo[]): EntityMetadataForPrompt {
26
+ export function FormatEntityMetadataForPrompt(entity: EntityInfo, allEntities: EntityInfo[]): EntityMetadataForPrompt {
27
27
  return {
28
28
  entityName: entity.Name,
29
29
  description: entity.Description || '',
@@ -35,6 +35,11 @@ export function formatEntityMetadataForPrompt(entity: EntityInfo, allEntities: E
35
35
  };
36
36
  }
37
37
 
38
+ /** @deprecated Use {@link FormatEntityMetadataForPrompt}. */
39
+ export function formatEntityMetadataForPrompt(entity: EntityInfo, allEntities: EntityInfo[]): EntityMetadataForPrompt {
40
+ return FormatEntityMetadataForPrompt(entity, allEntities);
41
+ }
42
+
38
43
  /**
39
44
  * Format entity fields for AI prompt
40
45
  * Includes field metadata with types, descriptions, and relationship info
@@ -91,7 +96,7 @@ function formatEntityRelationships(entity: EntityInfo, allEntities: EntityInfo[]
91
96
  return entity.RelatedEntities
92
97
  .filter(rel => entityNamesInGroup.has(rel.RelatedEntity)) // Only include relationships within the group
93
98
  .map(rel => {
94
- const relatedEntity = findEntityById(rel.RelatedEntityID, allEntities);
99
+ const relatedEntity = FindEntityById(rel.RelatedEntityID, allEntities);
95
100
 
96
101
  // Determine the foreign key field based on relationship type and available fields
97
102
  let foreignKeyField: string;
@@ -156,40 +161,65 @@ function findEntityByName(name: string, entities: EntityInfo[]): EntityInfo | un
156
161
  /**
157
162
  * Find entity by ID in array
158
163
  */
159
- export function findEntityById(id: string, entities: EntityInfo[]): EntityInfo | undefined {
164
+ export function FindEntityById(id: string, entities: EntityInfo[]): EntityInfo | undefined {
160
165
  return entities.find((e) => UUIDsEqual(e.ID, id));
161
166
  }
162
167
 
168
+ /** @deprecated Use {@link FindEntityById}. */
169
+ export function findEntityById(id: string, entities: EntityInfo[]): EntityInfo | undefined {
170
+ return FindEntityById(id, entities);
171
+ }
172
+
163
173
  /**
164
174
  * Get primary key field(s) for an entity
165
175
  */
166
- export function getPrimaryKeyFields(entity: EntityInfo): EntityFieldInfo[] {
176
+ export function GetPrimaryKeyFields(entity: EntityInfo): EntityFieldInfo[] {
167
177
  return entity.Fields.filter((f) => f.IsPrimaryKey);
168
178
  }
169
179
 
180
+ /** @deprecated Use {@link GetPrimaryKeyFields}. */
181
+ export function getPrimaryKeyFields(entity: EntityInfo): EntityFieldInfo[] {
182
+ return GetPrimaryKeyFields(entity);
183
+ }
184
+
170
185
  /**
171
186
  * Get foreign key fields for an entity
172
187
  */
173
- export function getForeignKeyFields(entity: EntityInfo): EntityFieldInfo[] {
188
+ export function GetForeignKeyFields(entity: EntityInfo): EntityFieldInfo[] {
174
189
  return entity.Fields.filter((f) => isForeignKeyField(f));
175
190
  }
176
191
 
192
+ /** @deprecated Use {@link GetForeignKeyFields}. */
193
+ export function getForeignKeyFields(entity: EntityInfo): EntityFieldInfo[] {
194
+ return GetForeignKeyFields(entity);
195
+ }
196
+
177
197
  /**
178
198
  * Check if an entity has any relationships
179
199
  * Uses EntityInfo.RelatedEntities getter
180
200
  */
181
- export function hasRelationships(entity: EntityInfo, allEntities: EntityInfo[]): boolean {
201
+ export function HasRelationships(entity: EntityInfo, allEntities: EntityInfo[]): boolean {
182
202
  return entity.RelatedEntities.length > 0;
183
203
  }
184
204
 
205
+ /** @deprecated Use {@link HasRelationships}. */
206
+ export function hasRelationships(entity: EntityInfo, allEntities: EntityInfo[]): boolean {
207
+ return HasRelationships(entity, allEntities);
208
+ }
209
+
185
210
  /**
186
211
  * Get count of relationships for an entity
187
212
  * Uses EntityInfo.RelatedEntities getter
188
213
  */
189
- export function getRelationshipCount(entity: EntityInfo, allEntities: EntityInfo[]): number {
214
+ export function GetRelationshipCount(entity: EntityInfo, allEntities: EntityInfo[]): number {
190
215
  return entity.RelatedEntities.length;
191
216
  }
192
217
 
218
+ /** @deprecated Use {@link GetRelationshipCount}. */
219
+ export function getRelationshipCount(entity: EntityInfo, allEntities: EntityInfo[]): number {
220
+ return GetRelationshipCount(entity, allEntities);
221
+ }
222
+
193
223
  /**
194
224
  * Format an entire entity group for AI prompt consumption
195
225
  * Converts all entities in the group to structured metadata
@@ -197,8 +227,13 @@ export function getRelationshipCount(entity: EntityInfo, allEntities: EntityInfo
197
227
  * @param entityGroup - Entity group to format
198
228
  * @returns Array of formatted entity metadata for Nunjucks template
199
229
  */
200
- export function formatEntityGroupForPrompt(entityGroup: EntityGroup): EntityMetadataForPrompt[] {
230
+ export function FormatEntityGroupForPrompt(entityGroup: EntityGroup): EntityMetadataForPrompt[] {
201
231
  return entityGroup.entities.map((entity) =>
202
- formatEntityMetadataForPrompt(entity, entityGroup.entities)
232
+ FormatEntityMetadataForPrompt(entity, entityGroup.entities)
203
233
  );
204
234
  }
235
+
236
+ /** @deprecated Use {@link FormatEntityGroupForPrompt}. */
237
+ export function formatEntityGroupForPrompt(entityGroup: EntityGroup): EntityMetadataForPrompt[] {
238
+ return FormatEntityGroupForPrompt(entityGroup);
239
+ }
@@ -8,7 +8,7 @@
8
8
  * Extract error message from unknown error type
9
9
  * Uses MJ's extractErrorMessage pattern
10
10
  */
11
- export function extractErrorMessage(error: unknown, context: string): string {
11
+ export function ExtractErrorMessage(error: unknown, context: string): string {
12
12
  if (error instanceof Error) {
13
13
  return `${context}: ${error.message}`;
14
14
  }
@@ -18,20 +18,30 @@ export function extractErrorMessage(error: unknown, context: string): string {
18
18
  return `${context}: Unknown error occurred`;
19
19
  }
20
20
 
21
+ /** @deprecated Use {@link ExtractErrorMessage}. */
22
+ export function extractErrorMessage(error: unknown, context: string): string {
23
+ return ExtractErrorMessage(error, context);
24
+ }
25
+
21
26
  /**
22
27
  * Validate required value is not null/undefined
23
28
  */
24
- export function requireValue<T>(value: T | null | undefined, fieldName: string): T {
29
+ export function RequireValue<T>(value: T | null | undefined, fieldName: string): T {
25
30
  if (value === null || value === undefined) {
26
31
  throw new Error(`Required value '${fieldName}' is missing`);
27
32
  }
28
33
  return value;
29
34
  }
30
35
 
36
+ /** @deprecated Use {@link RequireValue}. */
37
+ export function requireValue<T>(value: T | null | undefined, fieldName: string): T {
38
+ return RequireValue(value, fieldName);
39
+ }
40
+
31
41
  /**
32
42
  * Get property with fallback value
33
43
  */
34
- export function getPropertyOrDefault<T>(
44
+ export function GetPropertyOrDefault<T>(
35
45
  obj: Record<string, unknown>,
36
46
  key: string,
37
47
  defaultValue: T
@@ -39,3 +49,12 @@ export function getPropertyOrDefault<T>(
39
49
  const value = obj[key];
40
50
  return value !== undefined ? (value as T) : defaultValue;
41
51
  }
52
+
53
+ /** @deprecated Use {@link GetPropertyOrDefault}. */
54
+ export function getPropertyOrDefault<T>(
55
+ obj: Record<string, unknown>,
56
+ key: string,
57
+ defaultValue: T
58
+ ): T {
59
+ return GetPropertyOrDefault(obj, key, defaultValue);
60
+ }
@@ -25,7 +25,7 @@ export interface EntityMetadataForPrompt {
25
25
  * Products: → OrderDetails, → Categories
26
26
  * ```
27
27
  */
28
- export function generateRelationshipGraph(entities: EntityInfo[]): string {
28
+ export function GenerateRelationshipGraph(entities: EntityInfo[]): string {
29
29
  const lines: string[] = [];
30
30
 
31
31
  for (const entity of entities) {
@@ -44,6 +44,11 @@ export function generateRelationshipGraph(entities: EntityInfo[]): string {
44
44
  return lines.join('\n');
45
45
  }
46
46
 
47
+ /** @deprecated Use {@link GenerateRelationshipGraph}. */
48
+ export function generateRelationshipGraph(entities: EntityInfo[]): string {
49
+ return GenerateRelationshipGraph(entities);
50
+ }
51
+
47
52
  /**
48
53
  * Generates a Mermaid diagram for richer visualization
49
54
  *
@@ -55,7 +60,7 @@ export function generateRelationshipGraph(entities: EntityInfo[]): string {
55
60
  * Orders[Orders] --> OrderDetails[OrderDetails]
56
61
  * ```
57
62
  */
58
- export function generateMermaidDiagram(entities: EntityInfo[]): string {
63
+ export function GenerateMermaidDiagram(entities: EntityInfo[]): string {
59
64
  const lines = ['graph LR'];
60
65
  const processedPairs = new Set<string>();
61
66
 
@@ -76,6 +81,11 @@ export function generateMermaidDiagram(entities: EntityInfo[]): string {
76
81
  return lines.join('\n');
77
82
  }
78
83
 
84
+ /** @deprecated Use {@link GenerateMermaidDiagram}. */
85
+ export function generateMermaidDiagram(entities: EntityInfo[]): string {
86
+ return GenerateMermaidDiagram(entities);
87
+ }
88
+
79
89
  /**
80
90
  * Formats entity metadata for LLM prompt (concise version with key info)
81
91
  *
@@ -85,7 +95,7 @@ export function generateMermaidDiagram(entities: EntityInfo[]): string {
85
95
  * - Field count (as a proxy for data richness)
86
96
  * - Related entities with relationship types
87
97
  */
88
- export function formatEntitiesForPrompt(entities: EntityInfo[]): EntityMetadataForPrompt[] {
98
+ export function FormatEntitiesForPrompt(entities: EntityInfo[]): EntityMetadataForPrompt[] {
89
99
  return entities.map(entity => ({
90
100
  Name: entity.Name,
91
101
  Description: entity.Description || 'No description available',
@@ -97,3 +107,8 @@ export function formatEntitiesForPrompt(entities: EntityInfo[]): EntityMetadataF
97
107
  }))
98
108
  }));
99
109
  }
110
+
111
+ /** @deprecated Use {@link FormatEntitiesForPrompt}. */
112
+ export function formatEntitiesForPrompt(entities: EntityInfo[]): EntityMetadataForPrompt[] {
113
+ return FormatEntitiesForPrompt(entities);
114
+ }
@@ -22,7 +22,7 @@ import { QueryGenConfig } from '../cli/config';
22
22
  * @param config - QueryGen configuration (for model/vendor overrides)
23
23
  * @returns Promise resolving to the prompt result
24
24
  */
25
- export async function executePromptWithOverrides<T>(
25
+ export async function ExecutePromptWithOverrides<T>(
26
26
  prompt: MJAIPromptEntityExtended,
27
27
  data: Record<string, unknown>,
28
28
  contextUser: UserInfo,
@@ -46,6 +46,16 @@ export async function executePromptWithOverrides<T>(
46
46
  return await runner.ExecutePrompt<T>(promptParams);
47
47
  }
48
48
 
49
+ /** @deprecated Use {@link ExecutePromptWithOverrides}. */
50
+ export async function executePromptWithOverrides<T>(
51
+ prompt: MJAIPromptEntityExtended,
52
+ data: Record<string, unknown>,
53
+ contextUser: UserInfo,
54
+ config: QueryGenConfig
55
+ ): Promise<{ success: boolean; result?: T; errorMessage?: string }> {
56
+ return ExecutePromptWithOverrides(prompt, data, contextUser, config);
57
+ }
58
+
49
59
  /**
50
60
  * Resolve model/vendor names to IDs for AIPromptParams.override
51
61
  *
@@ -14,7 +14,7 @@ import { UserCache } from '@memberjunction/generic-database-provider';
14
14
  * @returns The System UserInfo object from the cache
15
15
  * @throws Error if System user is not found in cache or doesn't have Developer role
16
16
  */
17
- export function getSystemUser(): UserInfo {
17
+ export function GetSystemUser(): UserInfo {
18
18
  const sysUser = UserCache.Instance.UserByName("System", false);
19
19
  if (!sysUser) {
20
20
  throw new Error(
@@ -37,3 +37,8 @@ export function getSystemUser(): UserInfo {
37
37
 
38
38
  return sysUser;
39
39
  }
40
+
41
+ /** @deprecated Use {@link GetSystemUser}. */
42
+ export function getSystemUser(): UserInfo {
43
+ return GetSystemUser();
44
+ }
@@ -34,7 +34,7 @@ export class EmbeddingService {
34
34
  * @param query - Query to embed (partial structure with text fields)
35
35
  * @returns Embeddings for all fields
36
36
  */
37
- async embedQuery(query: {
37
+ async EmbedQuery(query: {
38
38
  userQuestion: string;
39
39
  description: string;
40
40
  technicalDescription: string;
@@ -55,6 +55,15 @@ export class EmbeddingService {
55
55
  };
56
56
  }
57
57
 
58
+ /** @deprecated Use {@link EmbedQuery}. */
59
+ async embedQuery(query: {
60
+ userQuestion: string;
61
+ description: string;
62
+ technicalDescription: string;
63
+ }): Promise<QueryEmbeddings> {
64
+ return this.EmbedQuery(query);
65
+ }
66
+
58
67
  /**
59
68
  * Embed all golden queries for few-shot learning
60
69
  *
@@ -65,11 +74,11 @@ export class EmbeddingService {
65
74
  * @param goldenQueries - Array of golden queries to embed
66
75
  * @returns Array of golden queries with their embeddings
67
76
  */
68
- async embedGoldenQueries(goldenQueries: GoldenQuery[]): Promise<EmbeddedGoldenQuery[]> {
77
+ async EmbedGoldenQueries(goldenQueries: GoldenQuery[]): Promise<EmbeddedGoldenQuery[]> {
69
78
  const embedded: EmbeddedGoldenQuery[] = [];
70
79
 
71
80
  for (const query of goldenQueries) {
72
- const embeddings = await this.embedQuery({
81
+ const embeddings = await this.EmbedQuery({
73
82
  userQuestion: query.userQuestion,
74
83
  description: query.description,
75
84
  technicalDescription: query.technicalDescription,
@@ -84,13 +93,18 @@ export class EmbeddingService {
84
93
  return embedded;
85
94
  }
86
95
 
96
+ /** @deprecated Use {@link EmbedGoldenQueries}. */
97
+ async embedGoldenQueries(goldenQueries: GoldenQuery[]): Promise<EmbeddedGoldenQuery[]> {
98
+ return this.EmbedGoldenQueries(goldenQueries);
99
+ }
100
+
87
101
  /**
88
102
  * Embed multiple queries in batch
89
103
  *
90
104
  * @param queries - Array of queries to embed
91
105
  * @returns Array of embeddings corresponding to input queries
92
106
  */
93
- async embedQueries(
107
+ async EmbedQueries(
94
108
  queries: Array<{
95
109
  userQuestion: string;
96
110
  description: string;
@@ -100,10 +114,21 @@ export class EmbeddingService {
100
114
  const embeddings: QueryEmbeddings[] = [];
101
115
 
102
116
  for (const query of queries) {
103
- const embedding = await this.embedQuery(query);
117
+ const embedding = await this.EmbedQuery(query);
104
118
  embeddings.push(embedding);
105
119
  }
106
120
 
107
121
  return embeddings;
108
122
  }
123
+
124
+ /** @deprecated Use {@link EmbedQueries}. */
125
+ async embedQueries(
126
+ queries: Array<{
127
+ userQuestion: string;
128
+ description: string;
129
+ technicalDescription: string;
130
+ }>
131
+ ): Promise<QueryEmbeddings[]> {
132
+ return this.EmbedQueries(queries);
133
+ }
109
134
  }
@@ -49,7 +49,7 @@ export class SimilaritySearch extends SimpleVectorService {
49
49
  * @param topK - Number of most similar queries to return (default: 5)
50
50
  * @returns Array of top-K most similar golden queries with scores
51
51
  */
52
- async findSimilarQueries(
52
+ async FindSimilarQueries(
53
53
  queryEmbeddings: QueryEmbeddings,
54
54
  goldenEmbeddings: EmbeddedGoldenQuery[],
55
55
  topK: number = 5
@@ -70,6 +70,15 @@ export class SimilaritySearch extends SimpleVectorService {
70
70
  return this.selectTopK(similarities, topK);
71
71
  }
72
72
 
73
+ /** @deprecated Use {@link FindSimilarQueries}. */
74
+ async findSimilarQueries(
75
+ queryEmbeddings: QueryEmbeddings,
76
+ goldenEmbeddings: EmbeddedGoldenQuery[],
77
+ topK: number = 5
78
+ ): Promise<SimilarQuery[]> {
79
+ return this.FindSimilarQueries(queryEmbeddings, goldenEmbeddings, topK);
80
+ }
81
+
73
82
  /**
74
83
  * Calculate cosine similarity for each field separately
75
84
  * Note: name field excluded as queries don't have names during generation