@memberjunction/core-entities-server 5.16.0 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/custom/MJQueryEntityServer.server.d.ts +10 -89
  2. package/dist/custom/MJQueryEntityServer.server.d.ts.map +1 -1
  3. package/dist/custom/MJQueryEntityServer.server.js +68 -1089
  4. package/dist/custom/MJQueryEntityServer.server.js.map +1 -1
  5. package/dist/custom/query-extraction/dialect.d.ts +23 -0
  6. package/dist/custom/query-extraction/dialect.d.ts.map +1 -0
  7. package/dist/custom/query-extraction/dialect.js +45 -0
  8. package/dist/custom/query-extraction/dialect.js.map +1 -0
  9. package/dist/custom/query-extraction/enrich.d.ts +51 -0
  10. package/dist/custom/query-extraction/enrich.d.ts.map +1 -0
  11. package/dist/custom/query-extraction/enrich.js +180 -0
  12. package/dist/custom/query-extraction/enrich.js.map +1 -0
  13. package/dist/custom/query-extraction/index.d.ts +9 -0
  14. package/dist/custom/query-extraction/index.d.ts.map +1 -0
  15. package/dist/custom/query-extraction/index.js +15 -0
  16. package/dist/custom/query-extraction/index.js.map +1 -0
  17. package/dist/custom/query-extraction/parse.d.ts +7 -0
  18. package/dist/custom/query-extraction/parse.d.ts.map +1 -0
  19. package/dist/custom/query-extraction/parse.js +13 -0
  20. package/dist/custom/query-extraction/parse.js.map +1 -0
  21. package/dist/custom/query-extraction/pipeline.d.ts +24 -0
  22. package/dist/custom/query-extraction/pipeline.d.ts.map +1 -0
  23. package/dist/custom/query-extraction/pipeline.js +101 -0
  24. package/dist/custom/query-extraction/pipeline.js.map +1 -0
  25. package/dist/custom/query-extraction/resolve.d.ts +110 -0
  26. package/dist/custom/query-extraction/resolve.d.ts.map +1 -0
  27. package/dist/custom/query-extraction/resolve.js +677 -0
  28. package/dist/custom/query-extraction/resolve.js.map +1 -0
  29. package/dist/custom/query-extraction/sync.d.ts +30 -0
  30. package/dist/custom/query-extraction/sync.d.ts.map +1 -0
  31. package/dist/custom/query-extraction/sync.js +456 -0
  32. package/dist/custom/query-extraction/sync.js.map +1 -0
  33. package/dist/custom/query-extraction/types.d.ts +114 -0
  34. package/dist/custom/query-extraction/types.d.ts.map +1 -0
  35. package/dist/custom/query-extraction/types.js +2 -0
  36. package/dist/custom/query-extraction/types.js.map +1 -0
  37. package/package.json +19 -19
@@ -11,8 +11,6 @@ export declare class MJQueryEntityServer extends MJQueryEntity {
11
11
  get QueryPermissions(): QueryPermissionInfo[];
12
12
  /**
13
13
  * Simple proxy to local helper method for embeddings. Needed for BaseEntity sub-classes that want to use embeddings built into BaseEntity
14
- * @param textToEmbed
15
- * @returns
16
14
  */
17
15
  protected EmbedTextLocal(textToEmbed: string): Promise<SimpleEmbeddingResult>;
18
16
  /**
@@ -28,102 +26,27 @@ export declare class MJQueryEntityServer extends MJQueryEntity {
28
26
  */
29
27
  private buildCategoryPathFromID;
30
28
  /**
31
- * Asynchronous version of extractAndSyncData that runs outside the main save operation
32
- * to prevent connection pool exhaustion
29
+ * Builds the QuerySyncContext from this entity instance for use by the extraction pipeline.
33
30
  */
34
- private extractAndSyncDataAsync;
35
- /**
36
- * Asynchronous cleanup for empty queries
37
- */
38
- private cleanupEmptyQueryAsync;
39
- private extractAndSyncData;
40
- /**
41
- * Runs the LLM enrichment prompt to get descriptions and sample values.
42
- * Returns null if the LLM is unavailable or fails (non-fatal).
43
- */
44
- private runLLMEnrichment;
45
- /**
46
- * Merges deterministic parameter extraction (SQLParser) with LLM enrichment.
47
- *
48
- * SQLParser is the authority for: name, type, isRequired, defaultValue
49
- * LLM provides: description, sampleValue (with heuristic fallbacks if LLM unavailable)
50
- */
51
- private mergeParametersWithLLM;
52
- /**
53
- * Generates a deterministic description for a parameter when LLM is unavailable.
54
- * Uses the parameter name, type, and filter information to create a meaningful description.
55
- */
56
- private generateParameterDescription;
57
- /**
58
- * Generates a deterministic sample value based on the parameter type.
59
- */
60
- private generateSampleValue;
61
- /**
62
- * Extracts entity metadata from the SQL to provide context to the LLM for parameter type inference.
63
- * Uses SQLParser for robust SQL parsing with MJ template support.
64
- */
65
- private extractEntityMetadataFromSQL;
66
- private syncQueryParameters;
67
- private removeAllQueryParameters;
68
- /**
69
- * Detects if the SQL uses SELECT * and if so, builds the complete field list deterministically
70
- * from entity metadata without relying on the AI (which can't enumerate * columns).
71
- * Returns null if the SQL doesn't use SELECT * or if entities can't be resolved.
72
- */
73
- private buildFieldsForSelectStar;
74
- /**
75
- * Finds an entity by name, checking both Name (which may have "MJ: " prefix) and DisplayName.
76
- * The AI often returns entity names without the "MJ: " prefix, so we need to match both.
77
- */
78
- private findEntityByName;
79
- /**
80
- * Expands wildcard (*) entries in the extracted fields list.
81
- * When AI returns a field with name="*" or sourceFieldName="*", we expand it into
82
- * individual field entries by looking up the source from metadata.
83
- * If the AI didn't provide a sourceEntity, we parse the SQL's FROM clause to find it.
84
- */
85
- private expandWildcardFields;
86
- private syncQueryFields;
87
- private syncQueryEntities;
88
- private removeAllQueryFields;
89
- private removeAllQueryEntities;
90
- /**
91
- * Deterministically extracts {{query:"..."}} composition references from this query's SQL
92
- * and syncs the QueryDependency records accordingly. No LLM needed — uses regex parsing.
93
- */
94
- private extractAndSyncQueryDependencies;
31
+ private buildSyncContext;
95
32
  /**
96
- * Resolves parsed composition tokens to dependency records with QueryIDs.
33
+ * Runs the extraction pipeline and saves the UsesTemplate flag.
34
+ * On error, sets UsesTemplate=false and attempts to save so the query remains usable.
97
35
  */
98
- private resolveTokensToQueryDependencies;
99
- /**
100
- * Extracts the SQL alias following a {{query:"..."}} token from this query's SQL.
101
- */
102
- private extractAliasFromSQL;
103
- /**
104
- * Detects circular dependencies by walking the dependency graph.
105
- * Returns a descriptive error string if a cycle is found, or null if clean.
106
- */
107
- private detectDependencyCycles;
108
- /**
109
- * Syncs extracted query dependencies against existing QueryDependency records.
110
- * Follows the same add/update/delete pattern as syncQueryParameters/Fields/Entities.
111
- */
112
- private syncQueryDependencies;
36
+ private extractAndSyncDataAsync;
113
37
  /**
114
- * Removes all QueryDependency records for this query.
38
+ * Cleans up all extraction data when SQL is empty, then saves the updated UsesTemplate flag.
115
39
  */
116
- private removeAllQueryDependencies;
40
+ private cleanupEmptyQueryAsync;
117
41
  /**
118
42
  * Auto-converts the query's SQL to other dialects based on the queryDialects
119
43
  * configuration stored in GlobalObjectStore. Best-effort: failures never block the save.
120
44
  */
121
45
  private autoConvertDialectsAsync;
122
46
  /**
123
- * Converts T-SQL to PostgreSQL using SQLConverter ExpressionHelper transforms.
124
- * Applies the standard transform pipeline for statement-level conversions.
47
+ * Converts and persists SQL for a single target dialect. Logs warnings on skip/failure.
125
48
  */
126
- private convertTSQLToPostgreSQL;
49
+ private convertToTargetDialect;
127
50
  /**
128
51
  * Creates or updates a QuerySQL record for the given dialect.
129
52
  */
@@ -137,9 +60,7 @@ export declare class MJQueryEntityServer extends MJQueryEntity {
137
60
  LoadFromData(data: any, _replaceOldValues?: boolean): Promise<boolean>;
138
61
  /**
139
62
  * Refreshes this record's related metadata from the provider, refreshing
140
- * all the way up from the database if refreshFromDB is true, otherwise from
141
- * cache.
142
- * @param refreshFromDB
63
+ * all the way up from the database if refreshFromDB is true, otherwise from cache.
143
64
  */
144
65
  RefreshRelatedMetadata(refreshFromDB: boolean): Promise<void>;
145
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MJQueryEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJQueryEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,iBAAiB,EAAyC,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAW,qBAAqB,EAA6C,MAAM,sBAAsB,CAAC;AAE/Q,OAAO,EAAE,aAAa,EAA8G,MAAM,+BAA+B,CAAC;AAqD1K,qBACa,mBAAoB,SAAQ,aAAa;IAClD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,gBAAgB,C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