@memberjunction/core-entities-server 5.21.0 → 5.23.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 (33) hide show
  1. package/dist/custom/MJDuplicateRunEntityServer.server.d.ts +19 -0
  2. package/dist/custom/MJDuplicateRunEntityServer.server.d.ts.map +1 -1
  3. package/dist/custom/MJDuplicateRunEntityServer.server.js +122 -9
  4. package/dist/custom/MJDuplicateRunEntityServer.server.js.map +1 -1
  5. package/dist/custom/MJTemplateContentEntityServer.server.d.ts +0 -1
  6. package/dist/custom/MJTemplateContentEntityServer.server.d.ts.map +1 -1
  7. package/dist/custom/MJTemplateContentEntityServer.server.js +13 -68
  8. package/dist/custom/MJTemplateContentEntityServer.server.js.map +1 -1
  9. package/dist/custom/MJVectorIndexEntityServer.server.d.ts +40 -0
  10. package/dist/custom/MJVectorIndexEntityServer.server.d.ts.map +1 -0
  11. package/dist/custom/MJVectorIndexEntityServer.server.js +169 -0
  12. package/dist/custom/MJVectorIndexEntityServer.server.js.map +1 -0
  13. package/dist/custom/template-extraction/index.d.ts +5 -0
  14. package/dist/custom/template-extraction/index.d.ts.map +1 -0
  15. package/dist/custom/template-extraction/index.js +6 -0
  16. package/dist/custom/template-extraction/index.js.map +1 -0
  17. package/dist/custom/template-extraction/parser.d.ts +9 -0
  18. package/dist/custom/template-extraction/parser.d.ts.map +1 -0
  19. package/dist/custom/template-extraction/parser.js +685 -0
  20. package/dist/custom/template-extraction/parser.js.map +1 -0
  21. package/dist/custom/template-extraction/pipeline.d.ts +22 -0
  22. package/dist/custom/template-extraction/pipeline.d.ts.map +1 -0
  23. package/dist/custom/template-extraction/pipeline.js +181 -0
  24. package/dist/custom/template-extraction/pipeline.js.map +1 -0
  25. package/dist/custom/template-extraction/types.d.ts +101 -0
  26. package/dist/custom/template-extraction/types.d.ts.map +1 -0
  27. package/dist/custom/template-extraction/types.js +5 -0
  28. package/dist/custom/template-extraction/types.js.map +1 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -0
  32. package/dist/index.js.map +1 -1
  33. package/package.json +21 -19
@@ -1,5 +1,24 @@
1
1
  import { MJDuplicateRunEntity } from "@memberjunction/core-entities";
2
2
  export declare class MJDuplicateRunEntityServer extends MJDuplicateRunEntity {
3
3
  Save(): Promise<boolean>;
4
+ /**
5
+ * Run duplicate detection asynchronously. On failure, updates the run's
6
+ * ProcessingStatus to 'Error' so the UI can surface the problem.
7
+ */
8
+ private runDetectionAsync;
9
+ /**
10
+ * Convert a DuplicateDetectionProgress callback into a PipelineProgress notification.
11
+ */
12
+ private publishProgress;
13
+ /**
14
+ * Publish a pipeline progress notification via the global PubSubManager.
15
+ * Uses GetGlobalObjectStore to access PubSubManager without a direct dependency
16
+ * on @memberjunction/server.
17
+ */
18
+ /**
19
+ * Normalize a threshold value — treat <= 0 or >= 1.0 as "unconfigured" and use the fallback.
20
+ */
21
+ private normalizeThreshold;
22
+ private publishPipelineNotification;
4
23
  }
5
24
  //# sourceMappingURL=MJDuplicateRunEntityServer.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MJDuplicateRunEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJDuplicateRunEntityServer.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE,qBACa,0BAA2B,SAAQ,oBAAoB;IACnD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAiBxC"}
1
+ {"version":3,"file":"MJDuplicateRunEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJDuplicateRunEntityServer.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAA0B,MAAM,+BAA+B,CAAC;AAe7F,qBACa,0BAA2B,SAAQ,oBAAoB;IACnD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAarC;;;OAGG;YACW,iBAAiB;IAmE/B;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;;;OAIG;IACH;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,2BAA2B;CA8BtC"}
@@ -4,25 +4,138 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { BaseEntity, PotentialDuplicateRequest } from "@memberjunction/core";
8
- import { RegisterClass } from "@memberjunction/global";
7
+ import { BaseEntity, LogError, LogStatus, PotentialDuplicateRequest, RunView } from "@memberjunction/core";
8
+ import { RegisterClass, GetGlobalObjectStore } from "@memberjunction/global";
9
9
  import { MJDuplicateRunEntity } from "@memberjunction/core-entities";
10
10
  import { DuplicateRecordDetector } from "@memberjunction/ai-vector-dupe";
11
+ const PIPELINE_PROGRESS_TOPIC = 'PIPELINE_PROGRESS';
12
+ /** Map DuplicateDetectionProgress phases to pipeline stage names */
13
+ const PHASE_TO_STAGE = {
14
+ 'Loading': 'extract',
15
+ 'Vectorizing': 'vectorize',
16
+ 'Embedding': 'autotag',
17
+ 'Querying': 'extract',
18
+ 'Matching': 'autotag',
19
+ 'Merging': 'complete'
20
+ };
11
21
  let MJDuplicateRunEntityServer = class MJDuplicateRunEntityServer extends MJDuplicateRunEntity {
12
22
  async Save() {
13
23
  const saveResult = await super.Save();
14
24
  if (saveResult && this.EndedAt === null) {
15
- // do something
16
- const duplicateRecordDetector = new DuplicateRecordDetector();
17
- let request = new PotentialDuplicateRequest();
25
+ // Fire-and-forget: run detection asynchronously so the save returns immediately
26
+ this.runDetectionAsync().catch((error) => {
27
+ LogError(`Async duplicate detection failed for run ${this.ID}`, undefined, error);
28
+ });
29
+ }
30
+ return saveResult;
31
+ }
32
+ /**
33
+ * Run duplicate detection asynchronously. On failure, updates the run's
34
+ * ProcessingStatus to 'Error' so the UI can surface the problem.
35
+ */
36
+ async runDetectionAsync() {
37
+ const startTime = Date.now();
38
+ try {
39
+ const detector = new DuplicateRecordDetector();
40
+ const request = new PotentialDuplicateRequest();
18
41
  request.EntityID = this.EntityID;
19
- request.ListID = this.SourceListID;
20
- request.Options = {
42
+ request.ListID = this.SourceListID || undefined; // Optional — if not set, scans all entity records
43
+ // Find the first active entity document for this entity to get template/thresholds
44
+ const rv = new RunView();
45
+ const edResult = await rv.RunView({
46
+ EntityName: 'MJ: Entity Documents',
47
+ ExtraFilter: `EntityID='${this.EntityID}' AND Status='Active'`,
48
+ MaxRows: 1,
49
+ ResultType: 'entity_object'
50
+ }, this.ContextCurrentUser);
51
+ if (edResult.Success && edResult.Results.length > 0) {
52
+ request.EntityDocumentID = edResult.Results[0].ID;
53
+ }
54
+ // Build detection options with threshold normalization.
55
+ // Entity document defaults are 1.0 (100%) which means nothing ever matches.
56
+ // Normalize to sensible fallbacks when the stored value is effectively unconfigured.
57
+ const potentialThreshold = this.normalizeThreshold(edResult.Success && edResult.Results.length > 0 ? edResult.Results[0].PotentialMatchThreshold : 1.0, 0.70 // fallback: 70% for potential matches
58
+ );
59
+ const absoluteThreshold = this.normalizeThreshold(edResult.Success && edResult.Results.length > 0 ? edResult.Results[0].AbsoluteMatchThreshold : 1.0, 0.95 // fallback: 95% for absolute matches
60
+ );
61
+ const detectionOptions = {
21
62
  DuplicateRunID: this.ID,
63
+ PotentialMatchThreshold: potentialThreshold,
64
+ AbsoluteMatchThreshold: absoluteThreshold,
65
+ OnProgress: (progress) => {
66
+ this.publishProgress(progress, startTime);
67
+ }
22
68
  };
23
- const response = await duplicateRecordDetector.getDuplicateRecords(request, this.ContextCurrentUser);
69
+ request.Options = detectionOptions;
70
+ // Publish initial progress
71
+ this.publishPipelineNotification('autotag', 0, 0, 0, startTime, 'Starting duplicate detection...');
72
+ await detector.GetDuplicateRecords(request, this.ContextCurrentUser);
73
+ LogStatus(`Duplicate detection completed for run ${this.ID}`);
74
+ // Publish completion
75
+ this.publishPipelineNotification('complete', 100, 100, 100, startTime);
76
+ }
77
+ catch (error) {
78
+ LogError(`Duplicate detection error for run ${this.ID}`, undefined, error);
79
+ // Publish error
80
+ this.publishPipelineNotification('error', 0, 0, 0, startTime, String(error));
81
+ // Update the run record to reflect the error
82
+ try {
83
+ this.ProcessingStatus = 'Failed';
84
+ this.EndedAt = new Date();
85
+ await super.Save();
86
+ }
87
+ catch (updateError) {
88
+ LogError(`Failed to update run ${this.ID} after detection error`, undefined, updateError);
89
+ }
90
+ }
91
+ }
92
+ /**
93
+ * Convert a DuplicateDetectionProgress callback into a PipelineProgress notification.
94
+ */
95
+ publishProgress(progress, startTime) {
96
+ const stage = PHASE_TO_STAGE[progress.Phase] ?? 'autotag';
97
+ const pct = progress.TotalRecords > 0
98
+ ? Math.round((progress.ProcessedRecords / progress.TotalRecords) * 100)
99
+ : 0;
100
+ this.publishPipelineNotification(stage, progress.TotalRecords, progress.ProcessedRecords, pct, startTime, progress.CurrentRecordID);
101
+ }
102
+ /**
103
+ * Publish a pipeline progress notification via the global PubSubManager.
104
+ * Uses GetGlobalObjectStore to access PubSubManager without a direct dependency
105
+ * on @memberjunction/server.
106
+ */
107
+ /**
108
+ * Normalize a threshold value — treat <= 0 or >= 1.0 as "unconfigured" and use the fallback.
109
+ */
110
+ normalizeThreshold(value, fallback) {
111
+ if (value == null || value <= 0 || value >= 1.0) {
112
+ return fallback;
113
+ }
114
+ return value;
115
+ }
116
+ publishPipelineNotification(stage, totalItems, processedItems, percentComplete, startTime, currentItem) {
117
+ try {
118
+ // Access PubSubManager through the global object store
119
+ // PubSubManager is a BaseSingleton stored in the global registry
120
+ const globalStore = GetGlobalObjectStore();
121
+ const pubSubManager = globalStore['___SINGLETON__PubSubManager'];
122
+ if (pubSubManager && typeof pubSubManager.Publish === 'function') {
123
+ const elapsedMs = Date.now() - startTime;
124
+ pubSubManager.Publish(PIPELINE_PROGRESS_TOPIC, {
125
+ PipelineRunID: this.ID,
126
+ Stage: stage,
127
+ TotalItems: totalItems,
128
+ ProcessedItems: processedItems,
129
+ CurrentItem: currentItem,
130
+ ElapsedMs: elapsedMs,
131
+ PercentComplete: percentComplete
132
+ });
133
+ }
134
+ }
135
+ catch (error) {
136
+ // Don't let progress publishing errors break detection
137
+ LogError(`Failed to publish pipeline progress for run ${this.ID}`, undefined, error);
24
138
  }
25
- return saveResult;
26
139
  }
27
140
  };
28
141
  MJDuplicateRunEntityServer = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"MJDuplicateRunEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJDuplicateRunEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,oBAAoB;IACzD,KAAK,CAAC,IAAI;QACb,MAAM,UAAU,GAAY,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAC/C,IAAI,UAAU,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACtC,eAAe;YACf,MAAM,uBAAuB,GAA4B,IAAI,uBAAuB,EAAE,CAAC;YACvF,IAAI,OAAO,GAA8B,IAAI,yBAAyB,EAAE,CAAC;YACzE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YACnC,OAAO,CAAC,OAAO,GAAG;gBACd,cAAc,EAAE,IAAI,CAAC,EAAE;aAC1B,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzG,CAAC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AAlBY,0BAA0B;IADtC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC;GACnC,0BAA0B,CAkBtC"}
1
+ {"version":3,"file":"MJDuplicateRunEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJDuplicateRunEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAyD,QAAQ,EAAE,SAAS,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClK,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAA0B,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD,oEAAoE;AACpE,MAAM,cAAc,GAAwD;IACxE,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,WAAW;IAC1B,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,SAAS,EAAE,UAAU;CACxB,CAAC;AAGK,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,oBAAoB;IACzD,KAAK,CAAC,IAAI;QACb,MAAM,UAAU,GAAY,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAE/C,IAAI,UAAU,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACtC,gFAAgF;YAChF,IAAI,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrC,QAAQ,CAAC,4CAA4C,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YACtF,CAAC,CAAC,CAAC;QACP,CAAC;QA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C,6BAA6B,CAAC,CAAC;YACjE,IAAI,aAAa,IAAI,OAAO,aAAa,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC/D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;gBACzC,aAAa,CAAC,OAAO,CAAC,uBAAuB,EAAE;oBAC3C,aAAa,EAAE,IAAI,CAAC,EAAE;oBACtB,KAAK,EAAE,KAAK;oBACZ,UAAU,EAAE,UAAU;oBACtB,cAAc,EAAE,cAAc;oBAC9B,WAAW,EAAE,WAAW;oBACxB,SAAS,EAAE,SAAS;oBACpB,eAAe,EAAE,eAAe;iBACnC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,uDAAuD;YACvD,QAAQ,CAAC,+CAA+C,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACzF,CAAC;IACL,CAAC;CACJ,CAAA;AArJY,0BAA0B;IADtC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC;GACnC,0BAA0B,CAqJtC"}
@@ -3,7 +3,6 @@ import { MJTemplateContentEntity } from "@memberjunction/core-entities";
3
3
  export declare class MJTemplateContentEntityServer extends MJTemplateContentEntity {
4
4
  Save(options?: EntitySaveOptions): Promise<boolean>;
5
5
  private extractAndSyncParameters;
6
- private normalizeParameterType;
7
6
  private syncTemplateParameters;
8
7
  }
9
8
  //# sourceMappingURL=MJTemplateContentEntityServer.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MJTemplateContentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJTemplateContentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAkD,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAA2C,MAAM,+BAA+B,CAAC;AAoBjH,qBACa,6BAA8B,SAAQ,uBAAuB;IACvD,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;YAmCpD,wBAAwB;IAiDtC,OAAO,CAAC,sBAAsB;YA2BhB,sBAAsB;CAyHvC"}
1
+ {"version":3,"file":"MJTemplateContentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJTemplateContentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAkD,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAA2C,MAAM,+BAA+B,CAAC;AAMjH,qBACa,6BAA8B,SAAQ,uBAAuB;IACvD,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;YAmCpD,wBAAwB;YAuBxB,sBAAsB;CAkHvC"}
@@ -7,9 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { BaseEntity, LogError, Metadata } from "@memberjunction/core";
8
8
  import { MJTemplateContentEntity } from "@memberjunction/core-entities";
9
9
  import { RegisterClass, UUIDsEqual } from "@memberjunction/global";
10
- import { AIEngine } from "@memberjunction/aiengine";
11
- import { AIPromptRunner } from "@memberjunction/ai-prompts";
12
- import { AIPromptParams } from "@memberjunction/ai-core-plus";
10
+ import { RunTemplateExtractionPipeline } from "./template-extraction/index.js";
13
11
  let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends MJTemplateContentEntity {
14
12
  async Save(options) {
15
13
  const provider = Metadata.Provider;
@@ -42,36 +40,14 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
42
40
  }
43
41
  async extractAndSyncParameters() {
44
42
  try {
45
- if (this.Template === "Template Parameter Extraction") {
46
- return; // Skip extraction for this special case - this is ourselves!
43
+ // Run the hybrid extraction pipeline: deterministic parse + AI enrichment
44
+ const result = await RunTemplateExtractionPipeline(this.TemplateText, this.Template, this.ContextCurrentUser);
45
+ if (result.warnings.length > 0) {
46
+ console.warn('Template parameter extraction warnings:', result.warnings);
47
47
  }
48
- // Ensure AIEngine is configured
49
- await AIEngine.Instance.Config(false, this.ContextCurrentUser);
50
- // Find the Template Parameter Extraction prompt
51
- const aiPrompt = AIEngine.Instance.Prompts.find(p => p.Name === 'Template Parameter Extraction' &&
52
- p.Category === 'MJ: System');
53
- if (!aiPrompt) {
54
- // prompt not configured, non-fatl, just warn and return
55
- console.warn('AI prompt for Template Parameter Extraction not found. Skipping parameter extraction.');
56
- return;
48
+ if (result.parameters.length > 0) {
49
+ await this.syncTemplateParameters(result.parameters);
57
50
  }
58
- // Prepare prompt data
59
- const promptData = {
60
- templateText: this.TemplateText
61
- };
62
- // Execute the prompt using AIPromptRunner
63
- const promptRunner = new AIPromptRunner();
64
- const params = new AIPromptParams();
65
- params.prompt = aiPrompt;
66
- params.data = promptData;
67
- params.contextUser = this.ContextCurrentUser;
68
- const result = await promptRunner.ExecutePrompt(params);
69
- if (!result.success || !result.result) {
70
- LogError('Failed to extract template parameters:', result.errorMessage);
71
- return;
72
- }
73
- // Process the extracted parameters
74
- await this.syncTemplateParameters(result.result.parameters);
75
51
  }
76
52
  catch (e) {
77
53
  LogError('Error extracting template parameters:', e);
@@ -79,32 +55,6 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
79
55
  // The user can still manually manage parameters if needed
80
56
  }
81
57
  }
82
- normalizeParameterType(type) {
83
- // Normalize LLM output to match database constraint values
84
- const normalized = type.toLowerCase();
85
- switch (normalized) {
86
- case 'scalar':
87
- case 'string':
88
- case 'number':
89
- case 'boolean':
90
- case 'date':
91
- return 'Scalar';
92
- case 'array':
93
- case 'list':
94
- return 'Array';
95
- case 'object':
96
- case 'dict':
97
- case 'dictionary':
98
- return 'Object';
99
- case 'record':
100
- return 'Record';
101
- case 'entity':
102
- return 'Entity';
103
- default:
104
- console.warn(`Unknown parameter type '${type}', defaulting to 'Scalar'`);
105
- return 'Scalar';
106
- }
107
- }
108
58
  async syncTemplateParameters(extractedParams) {
109
59
  // Use the entity's provider instead of creating new Metadata instance
110
60
  const md = this.ProviderToUse;
@@ -119,7 +69,7 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
119
69
  if (!existingParamsResult.Success) {
120
70
  throw new Error(`Failed to load existing template parameters: ${existingParamsResult.ErrorMessage}`);
121
71
  }
122
- const existingParams = existingParamsResult.Results || [];
72
+ const existingParams = existingParamsResult.Results ?? [];
123
73
  // Determine if we're in single or multiple template content scenario
124
74
  const templateContentsResult = await rv.RunView({
125
75
  EntityName: 'MJ: Template Contents',
@@ -148,8 +98,8 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
148
98
  newParam.TemplateID = this.TemplateID;
149
99
  newParam.TemplateContentID = templateContentID;
150
100
  newParam.Name = param.name;
151
- newParam.Type = this.normalizeParameterType(param.type);
152
- newParam.IsRequired = false; // LLM has been unreliable here, make them ALL optional so we don't break template rendering in case it picks up stuff that is NOT really a param... param.isRequired;
101
+ newParam.Type = param.type;
102
+ newParam.IsRequired = param.isRequired;
153
103
  newParam.DefaultValue = param.defaultValue;
154
104
  newParam.Description = param.description;
155
105
  promises.push(newParam.Save());
@@ -159,14 +109,12 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
159
109
  const extractedParam = extractedParams.find(p => p.name.toLowerCase() === existingParam.Name.toLowerCase());
160
110
  if (extractedParam) {
161
111
  let hasChanges = false;
162
- // Check each property for changes
163
- const normalizedType = this.normalizeParameterType(extractedParam.type);
164
- if (existingParam.Type !== normalizedType) {
165
- existingParam.Type = normalizedType;
112
+ if (existingParam.Type !== extractedParam.type) {
113
+ existingParam.Type = extractedParam.type;
166
114
  hasChanges = true;
167
115
  }
168
116
  if (existingParam.IsRequired !== extractedParam.isRequired) {
169
- existingParam.IsRequired = false; // SEE ABOVE - make not required in all cases.... extractedParam.isRequired;
117
+ existingParam.IsRequired = extractedParam.isRequired;
170
118
  hasChanges = true;
171
119
  }
172
120
  if (existingParam.DefaultValue !== extractedParam.defaultValue) {
@@ -190,9 +138,6 @@ let MJTemplateContentEntityServer = class MJTemplateContentEntityServer extends
190
138
  if (promises.length > 0) {
191
139
  await Promise.all(promises); // saving these is non-critical
192
140
  }
193
- // If this is multiple contents scenario, we might need to handle global params
194
- // This is a more complex scenario that would require analyzing all template contents
195
- // For now, we're handling content-specific params only
196
141
  }
197
142
  catch (e) {
198
143
  LogError('Failed to sync template parameters:', e);
@@ -1 +1 @@
1
- {"version":3,"file":"MJTemplateContentEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJTemplateContentEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAqB,QAAQ,EAAE,QAAQ,EAA8B,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAA2C,MAAM,+BAA+B,CAAC;AACjH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAgBvD,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,uBAAuB;IAC7D,KAAK,CAAC,IAAI,CAAC,OAA2B;QAC3C,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAiC,CAAC;QAE5D,+BAA+B;QAC/B,MAAM,QAAQ,CAAC,gBAAgB,EAAE,CAAC;QAElC,IAAI,CAAC;YACD,+DAA+D;YAC/D,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;YAC9D,MAAM,mBAAmB,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC;YAErE,kCAAkC;YAClC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,MAAM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C,YAAY,EAAE,CAAC;wBAC7D,aAAa,CAAC,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC;wBACzD,UAAU,GAAG,IAAI,CAAC;oBACtB,CAAC;oBACD,IAAI,aAAa,CAAC,WAAW,KAAK,cAAc,CAAC,WAAW,EAAE,CAAC;wBAC3D,aAAa,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC;wBACvD,UAAU,GAAG,IAAI,CAAC;oBACtB,CAAC;oBAED,IAAI,UAAU,EAAE,CAAC;wBACb,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;oBACxC,CAAC;gBACL,CAAC;YACL,CAAC;YAED,uDAAuD;YACvD,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;gBACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1C,CAAC;YAED,qCAAqC;YACrC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,+BAA+B;YAChE,CAAC;YAED,+EAA+E;YAC/E,qFAAqF;YACrF,uDAAuD;QAE3D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,QAAQ,CAAC,qCAAqC,EAAE,CAAC,CAAC,CAAC;YACnD,MAAM,CAAC,CAAC,CAAC,wCAAwC;QACrD,CAAC;IACL,CAAC;CACJ,CAAA;AAzOY,6BAA6B;IADzC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,6BAA6B,CAyOzC"}
1
+ {"version":3,"file":"MJTemplateContentEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJTemplateContentEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAqB,QAAQ,EAAE,QAAQ,EAA8B,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAA2C,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C,wCAAwC;QACrD,CAAC;IACL,CAAC;CACJ,CAAA;AA7KY,6BAA6B;IADzC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,6BAA6B,CA6KzC"}
@@ -0,0 +1,40 @@
1
+ import { MJVectorIndexEntity } from "@memberjunction/core-entities";
2
+ /**
3
+ * Server-side VectorIndex entity that syncs with the vector database provider.
4
+ * On create: calls vectorDB.CreateIndex() to provision the index in the provider (e.g., Pinecone).
5
+ * On delete: calls vectorDB.DeleteIndex() to remove the index from the provider.
6
+ */
7
+ export declare class MJVectorIndexEntityServer extends MJVectorIndexEntity {
8
+ /**
9
+ * After saving, if this is a new record, create the index in the provider.
10
+ */
11
+ Save(): Promise<boolean>;
12
+ /**
13
+ * Before deleting, remove the index from the provider.
14
+ */
15
+ Delete(): Promise<boolean>;
16
+ /**
17
+ * Create the index in the vector database provider.
18
+ */
19
+ private createIndexInProvider;
20
+ /**
21
+ * Delete the index from the vector database provider.
22
+ */
23
+ private deleteIndexFromProvider;
24
+ /**
25
+ * Instantiate the VectorDB provider class using ClassFactory.
26
+ * Looks up the VectorDatabase record to get the ClassKey for provider instantiation.
27
+ */
28
+ private getVectorDBInstance;
29
+ /**
30
+ * Resolve embedding dimensions from the associated AI model.
31
+ * Default to 1536 (OpenAI text-embedding-3-small) if not determinable.
32
+ */
33
+ private resolveDimensions;
34
+ /**
35
+ * After provider creates the index, save the returned metadata back to our record.
36
+ * Stores ExternalID, Dimensions, Metric, and full provider config as JSON.
37
+ */
38
+ private saveProviderMetadata;
39
+ }
40
+ //# sourceMappingURL=MJVectorIndexEntityServer.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJVectorIndexEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJVectorIndexEntityServer.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAI5F;;;;GAIG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;IACmB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAa9C;;OAEG;IACmB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAShD;;OAEG;YACW,qBAAqB;IA6BnC;;OAEG;YACW,uBAAuB;IAgBrC;;;OAGG;YACW,mBAAmB;IAmCjC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;;OAGG;YACW,oBAAoB;CAgCrC"}
@@ -0,0 +1,169 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseEntity, LogError, LogStatus, RunView } from "@memberjunction/core";
8
+ import { RegisterClass, MJGlobal } from "@memberjunction/global";
9
+ import { MJVectorIndexEntity } from "@memberjunction/core-entities";
10
+ import { VectorDBBase } from "@memberjunction/ai-vectordb";
11
+ import { GetAIAPIKey } from "@memberjunction/ai";
12
+ /**
13
+ * Server-side VectorIndex entity that syncs with the vector database provider.
14
+ * On create: calls vectorDB.CreateIndex() to provision the index in the provider (e.g., Pinecone).
15
+ * On delete: calls vectorDB.DeleteIndex() to remove the index from the provider.
16
+ */
17
+ let MJVectorIndexEntityServer = class MJVectorIndexEntityServer extends MJVectorIndexEntity {
18
+ /**
19
+ * After saving, if this is a new record, create the index in the provider.
20
+ */
21
+ async Save() {
22
+ const isNew = this.IsSaved === false;
23
+ const saveResult = await super.Save();
24
+ if (saveResult && isNew) {
25
+ this.createIndexInProvider().catch((error) => {
26
+ LogError(`Failed to create index "${this.Name}" in vector DB provider`, undefined, error);
27
+ });
28
+ }
29
+ return saveResult;
30
+ }
31
+ /**
32
+ * Before deleting, remove the index from the provider.
33
+ */
34
+ async Delete() {
35
+ // Try to delete from provider first — if it fails, still delete the metadata record
36
+ await this.deleteIndexFromProvider().catch((error) => {
37
+ LogError(`Failed to delete index "${this.Name}" from vector DB provider (proceeding with metadata delete)`, undefined, error);
38
+ });
39
+ return super.Delete();
40
+ }
41
+ /**
42
+ * Create the index in the vector database provider.
43
+ */
44
+ async createIndexInProvider() {
45
+ const vectorDB = await this.getVectorDBInstance();
46
+ if (!vectorDB) {
47
+ LogError(`Cannot create index: no VectorDB instance for database ${this.VectorDatabaseID}`);
48
+ return;
49
+ }
50
+ const params = {
51
+ id: this.Name,
52
+ dimension: this.resolveDimensions(),
53
+ metric: 'cosine',
54
+ additionalParams: {
55
+ serverless: {
56
+ cloud: 'aws',
57
+ region: 'us-east-1'
58
+ }
59
+ }
60
+ };
61
+ LogStatus(`Creating index "${this.Name}" in vector DB provider...`);
62
+ const result = await vectorDB.CreateIndex(params);
63
+ if (result.success) {
64
+ LogStatus(`Index "${this.Name}" created successfully in provider`);
65
+ await this.saveProviderMetadata(result.data, params);
66
+ }
67
+ else {
68
+ LogError(`Provider returned error creating index "${this.Name}": ${result.message}`);
69
+ }
70
+ }
71
+ /**
72
+ * Delete the index from the vector database provider.
73
+ */
74
+ async deleteIndexFromProvider() {
75
+ const vectorDB = await this.getVectorDBInstance();
76
+ if (!vectorDB) {
77
+ LogError(`Cannot delete index: no VectorDB instance for database ${this.VectorDatabaseID}`);
78
+ return;
79
+ }
80
+ LogStatus(`Deleting index "${this.Name}" from vector DB provider...`);
81
+ const result = await vectorDB.DeleteIndex({ id: this.Name });
82
+ if (result.success) {
83
+ LogStatus(`Index "${this.Name}" deleted from provider`);
84
+ }
85
+ else {
86
+ LogError(`Provider returned error deleting index "${this.Name}": ${result.message}`);
87
+ }
88
+ }
89
+ /**
90
+ * Instantiate the VectorDB provider class using ClassFactory.
91
+ * Looks up the VectorDatabase record to get the ClassKey for provider instantiation.
92
+ */
93
+ async getVectorDBInstance() {
94
+ if (!this.VectorDatabaseID) {
95
+ return null;
96
+ }
97
+ const rv = new RunView();
98
+ const result = await rv.RunView({
99
+ EntityName: 'MJ: Vector Databases',
100
+ ExtraFilter: `ID='${this.VectorDatabaseID}'`,
101
+ ResultType: 'entity_object'
102
+ }, this.ContextCurrentUser);
103
+ if (!result.Success || result.Results.length === 0) {
104
+ LogError(`VectorDatabase with ID ${this.VectorDatabaseID} not found`);
105
+ return null;
106
+ }
107
+ const vectorDB = result.Results[0];
108
+ const classKey = vectorDB.ClassKey;
109
+ if (!classKey) {
110
+ LogError(`VectorDatabase "${vectorDB.Name}" has no ClassKey configured`);
111
+ return null;
112
+ }
113
+ const apiKey = GetAIAPIKey(classKey);
114
+ if (!apiKey) {
115
+ LogError(`No API key found for vector DB provider "${classKey}"`);
116
+ return null;
117
+ }
118
+ return MJGlobal.Instance.ClassFactory.CreateInstance(VectorDBBase, classKey, apiKey);
119
+ }
120
+ /**
121
+ * Resolve embedding dimensions from the associated AI model.
122
+ * Default to 1536 (OpenAI text-embedding-3-small) if not determinable.
123
+ */
124
+ resolveDimensions() {
125
+ // TODO: Look up the embedding model's dimension count from metadata
126
+ // For now, default to 1536 which covers most common embedding models
127
+ return 1536;
128
+ }
129
+ /**
130
+ * After provider creates the index, save the returned metadata back to our record.
131
+ * Stores ExternalID, Dimensions, Metric, and full provider config as JSON.
132
+ */
133
+ async saveProviderMetadata(providerResult, params) {
134
+ try {
135
+ // Save what we know from our params + whatever the provider returned
136
+ this.ExternalID = this.Name; // For Pinecone, name IS the external ID
137
+ this.Dimensions = params.dimension;
138
+ this.Metric = params.metric;
139
+ // Store full provider response + our spec as JSON config
140
+ const config = {};
141
+ if (params.additionalParams) {
142
+ config['spec'] = params.additionalParams;
143
+ }
144
+ if (providerResult && typeof providerResult === 'object') {
145
+ // Extract useful provider metadata (host, status, etc.)
146
+ if ('host' in providerResult)
147
+ config['host'] = providerResult['host'];
148
+ if ('status' in providerResult)
149
+ config['status'] = providerResult['status'];
150
+ }
151
+ this.ProviderConfig = JSON.stringify(config);
152
+ const saved = await super.Save();
153
+ if (saved) {
154
+ LogStatus(`Saved provider metadata for index "${this.Name}"`);
155
+ }
156
+ else {
157
+ LogError(`Failed to save provider metadata for index "${this.Name}": ${this.LatestResult?.CompleteMessage}`);
158
+ }
159
+ }
160
+ catch (error) {
161
+ LogError(`Error saving provider metadata for index "${this.Name}"`, undefined, error);
162
+ }
163
+ }
164
+ };
165
+ MJVectorIndexEntityServer = __decorate([
166
+ RegisterClass(BaseEntity, 'MJ: Vector Indexes')
167
+ ], MJVectorIndexEntityServer);
168
+ export { MJVectorIndexEntityServer };
169
+ //# sourceMappingURL=MJVectorIndexEntityServer.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MJVectorIndexEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJVectorIndexEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAY,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;GAIG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;IACa,KAAK,CAAC,IAAI;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEtC,IAAI,UAAU,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,qBAAqB,EAAE,CAAC,KA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,GAAG,MAAM,CAAC,gBAAgB,CAAC;YAC7C,CAAC;YACD,IAAI,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;gBACvD,wDAAwD;gBACxD,IAAI,MAAM,IAAI,cAAc;oBAAE,MAAM,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACtE,IAAI,QAAQ,IAAI,cAAc;oBAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE7C,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,KAAK,EAAE,CAAC;gBACR,SAAS,CAAC,sCAAsC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;YAClE,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,+CAA+C,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,CAAC,CAAC;YACjH,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,QAAQ,CAAC,6CAA6C,IAAI,CAAC,IAAI,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC1F,CAAC;IACL,CAAC;CACJ,CAAA;AArKY,yBAAyB;IADrC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC;GACnC,yBAAyB,CAqKrC"}
@@ -0,0 +1,5 @@
1
+ export { RunTemplateExtractionPipeline } from "./pipeline.js";
2
+ export type { TemplateExtractionResult } from "./pipeline.js";
3
+ export { ParseTemplateParameters } from "./parser.js";
4
+ export type { TemplateParamType, PropertyAccess, DeterministicParameter, ParameterUsage, ParseResult, EnrichmentResult, EnrichedParameterInfo, MergedTemplateParameter, } from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/template-extraction/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGnD,YAAY,EACR,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,GAC1B,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Template Extraction Pipeline — barrel exports
2
+ // Pipeline orchestrator
3
+ export { RunTemplateExtractionPipeline } from "./pipeline.js";
4
+ // Parser (deterministic AST extraction)
5
+ export { ParseTemplateParameters } from "./parser.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/template-extraction/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,wBAAwB;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAG3D,wCAAwC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ParseResult } from './types.js';
2
+ /**
3
+ * Parse a Nunjucks template and deterministically extract all template parameters.
4
+ *
5
+ * @param templateText The raw Nunjucks template string
6
+ * @returns ParseResult with extracted parameters and any warnings
7
+ */
8
+ export declare function ParseTemplateParameters(templateText: string): ParseResult;
9
+ //# sourceMappingURL=parser.d.ts.map