@memberjunction/ng-dashboards 6.1.0-edge.3 → 6.1.0-edge.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-transcripts-data.d.ts","sourceRoot":"","sources":["../../../../../src/AI/components/analytics/realtime/realtime-transcripts-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAW,MAAM,sBAAsB,CAAC;AAQlE,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,sGAAsG;IACtG,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;CACtB;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,mGAAmG;IACnG,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAClC,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,IAAI,CAAC;CACZ;AAKD;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,SAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuBhH;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,EAAE,CAAC,CAyB3B;AAqDD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EACjE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,cAAc,CAqBhB"}
1
+ {"version":3,"file":"realtime-transcripts-data.d.ts","sourceRoot":"","sources":["../../../../../src/AI/components/analytics/realtime/realtime-transcripts-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAW,MAAM,sBAAsB,CAAC;AASlE,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,sGAAsG;IACtG,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;CACtB;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,mGAAmG;IACnG,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAClC,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,IAAI,CAAC;CACZ;AAID;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,SAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuBhH;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,EAAE,CAAC,CAyB3B;AAqDD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EACjE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,cAAc,CAqBhB"}
@@ -8,12 +8,12 @@
8
8
  * @module @memberjunction/ng-dashboards
9
9
  */
10
10
  import { RunView } from '@memberjunction/core';
11
+ import { EscapeSQLString } from '@memberjunction/global';
11
12
  import { AIEngineBase } from '@memberjunction/ai-engine-base';
12
13
  const CONVERSATION_ENTITY = 'MJ: Conversations';
13
14
  const CONVERSATION_DETAIL_ENTITY = 'MJ: Conversation Details';
14
15
  const BRIDGE_ENTITY = 'MJ: AI Agent Session Bridges';
15
16
  const PARTICIPANT_ENTITY = 'MJ: AI Agent Session Bridge Participants';
16
- const escapeSql = (v) => v.replace(/'/g, "''");
17
17
  const toDate = (v) => (v instanceof Date ? v : new Date(String(v ?? '')));
18
18
  /**
19
19
  * Loads the meeting-room transcript LIST (light — no per-room detail load). Newest activity first.
@@ -56,7 +56,7 @@ export async function LoadRoomTranscript(provider, conversationID, roomKey) {
56
56
  const [detailResult, bridgeResult] = await rv.RunViews([
57
57
  {
58
58
  EntityName: CONVERSATION_DETAIL_ENTITY,
59
- ExtraFilter: `ConversationID='${escapeSql(conversationID)}'`,
59
+ ExtraFilter: `ConversationID='${EscapeSQLString(conversationID)}'`,
60
60
  Fields: ['ID', 'Role', 'Message', 'AgentID', 'ExternalID', 'Error', '__mj_CreatedAt'],
61
61
  OrderBy: '__mj_CreatedAt ASC',
62
62
  MaxRows: 5000,
@@ -64,7 +64,7 @@ export async function LoadRoomTranscript(provider, conversationID, roomKey) {
64
64
  },
65
65
  {
66
66
  EntityName: BRIDGE_ENTITY,
67
- ExtraFilter: roomKey ? `ExternalConnectionID='${escapeSql(roomKey)}'` : `1=0`,
67
+ ExtraFilter: roomKey ? `ExternalConnectionID='${EscapeSQLString(roomKey)}'` : `1=0`,
68
68
  Fields: ['ID'],
69
69
  MaxRows: 100,
70
70
  ResultType: 'simple',
@@ -81,7 +81,7 @@ async function loadParticipantNames(provider, rv, bridgeIds) {
81
81
  if (bridgeIds.length === 0) {
82
82
  return map;
83
83
  }
84
- const inClause = bridgeIds.map((id) => `'${escapeSql(id)}'`).join(',');
84
+ const inClause = bridgeIds.map((id) => `'${EscapeSQLString(id)}'`).join(',');
85
85
  const result = await rv.RunView({
86
86
  EntityName: PARTICIPANT_ENTITY,
87
87
  ExtraFilter: `SessionBridgeID IN (${inClause})`,
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-transcripts-data.js","sourceRoot":"","sources":["../../../../../src/AI/components/analytics/realtime/realtime-transcripts-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAqB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAC9D,MAAM,aAAa,GAAG,8BAA8B,CAAC;AACrD,MAAM,kBAAkB,GAAG,0CAA0C,CAAC;AAuBtE,MAAM,SAAS,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/D,MAAM,MAAM,GAAG,CAAC,CAAU,EAAQ,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAA2B,EAAE,OAAO,GAAG,GAAG;IAC7E,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAC3B;QACI,UAAU,EAAE,mB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AAS,CAAC;IAC9E,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;IACjG,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * @fileoverview Pure data layer for the Realtime \"Voice Transcripts\" view. Loads the unified per-room\n * meeting transcripts the bridge writes (one `MJ: Conversations` of `Type='Meeting Room'` per room +\n * `MJ: Conversation Details` per utterance), and resolves each line's speaker — agent lines via `AgentID`,\n * heard ('User') lines via the diarized `ExternalID` → the room's `AIAgentSessionBridgeParticipant` roster\n * (DisplayName + IsAgent). No Angular imports — RunView(s) + client-side aggregation only.\n *\n * @module @memberjunction/ng-dashboards\n */\nimport { IMetadataProvider, RunView } from '@memberjunction/core';\nimport { AIEngineBase } from '@memberjunction/ai-engine-base';\n\nconst CONVERSATION_ENTITY = 'MJ: Conversations';\nconst CONVERSATION_DETAIL_ENTITY = 'MJ: Conversation Details';\nconst BRIDGE_ENTITY = 'MJ: AI Agent Session Bridges';\nconst PARTICIPANT_ENTITY = 'MJ: AI Agent Session Bridge Participants';\n\n/** One meeting-room transcript in the list view. */\nexport interface MeetingRoomSummary {\n ConversationID: string;\n Name: string;\n /** The room's external connection id (`ExternalID`) — the join key to the bridge/participant rows. */\n RoomKey: string;\n CreatedAt: Date;\n LastActivity: Date;\n}\n\n/** A speaker-attributed transcript line for the drill-in view. */\nexport interface TranscriptLine {\n ID: string;\n /** `'agent'` = an agent spoke; `'human'` = a human/participant spoke; `'error'` = an error row. */\n Kind: 'agent' | 'human' | 'error';\n /** Resolved display name of the speaker (agent name, participant name, or a sensible fallback). */\n Speaker: string;\n Message: string;\n At: Date;\n}\n\nconst escapeSql = (v: string): string => v.replace(/'/g, \"''\");\nconst toDate = (v: unknown): Date => (v instanceof Date ? v : new Date(String(v ?? '')));\n\n/**\n * Loads the meeting-room transcript LIST (light — no per-room detail load). Newest activity first.\n *\n * @param provider The request-scoped metadata provider.\n * @param maxRows Cap on rooms returned (default 500).\n */\nexport async function LoadMeetingRooms(provider: IMetadataProvider, maxRows = 500): Promise<MeetingRoomSummary[]> {\n const rv = RunView.FromMetadataProvider(provider);\n const result = await rv.RunView<Record<string, unknown>>(\n {\n EntityName: CONVERSATION_ENTITY,\n ExtraFilter: `Type='Meeting Room'`,\n Fields: ['ID', 'Name', 'ExternalID', '__mj_CreatedAt', '__mj_UpdatedAt'],\n OrderBy: '__mj_UpdatedAt DESC',\n MaxRows: maxRows,\n ResultType: 'simple',\n },\n provider.CurrentUser,\n );\n if (!result.Success) {\n return [];\n }\n return result.Results.map((r) => ({\n ConversationID: String(r['ID']),\n Name: String(r['Name'] ?? 'Meeting Room'),\n RoomKey: String(r['ExternalID'] ?? ''),\n CreatedAt: toDate(r['__mj_CreatedAt']),\n LastActivity: toDate(r['__mj_UpdatedAt']),\n }));\n}\n\n/**\n * Loads + speaker-attributes one room's transcript. Resolves agent lines via `AgentID` (AIEngine cache) and\n * heard lines via the diarized `ExternalID` against the room's participant roster (so a `User` line reads as\n * the actual person, and another agent heard in the room reads as that agent — not a generic \"User\").\n *\n * @param provider The request-scoped metadata provider.\n * @param conversationID The room conversation id.\n * @param roomKey The room's external id (to load its bridge participants for attribution).\n */\nexport async function LoadRoomTranscript(\n provider: IMetadataProvider,\n conversationID: string,\n roomKey: string,\n): Promise<TranscriptLine[]> {\n const rv = RunView.FromMetadataProvider(provider);\n const [detailResult, bridgeResult] = await rv.RunViews([\n {\n EntityName: CONVERSATION_DETAIL_ENTITY,\n ExtraFilter: `ConversationID='${escapeSql(conversationID)}'`,\n Fields: ['ID', 'Role', 'Message', 'AgentID', 'ExternalID', 'Error', '__mj_CreatedAt'],\n OrderBy: '__mj_CreatedAt ASC',\n MaxRows: 5000,\n ResultType: 'simple',\n },\n {\n EntityName: BRIDGE_ENTITY,\n ExtraFilter: roomKey ? `ExternalConnectionID='${escapeSql(roomKey)}'` : `1=0`,\n Fields: ['ID'],\n MaxRows: 100,\n ResultType: 'simple',\n },\n ], provider.CurrentUser);\n\n const participantNames = await loadParticipantNames(provider, rv, (bridgeResult?.Results ?? []).map((b) => String(b['ID'])));\n const agentName = buildAgentNameLookup();\n\n const details = detailResult?.Success ? detailResult.Results : [];\n return details.map((d) => attributeLine(d, participantNames, agentName));\n}\n\n/** roomBridges → a map of `ExternalParticipantID → { name, isAgent }` for diarized-line attribution. */\nasync function loadParticipantNames(\n provider: IMetadataProvider,\n rv: RunView,\n bridgeIds: string[],\n): Promise<Map<string, { name: string; isAgent: boolean }>> {\n const map = new Map<string, { name: string; isAgent: boolean }>();\n if (bridgeIds.length === 0) {\n return map;\n }\n const inClause = bridgeIds.map((id) => `'${escapeSql(id)}'`).join(',');\n const result = await rv.RunView<Record<string, unknown>>(\n {\n EntityName: PARTICIPANT_ENTITY,\n ExtraFilter: `SessionBridgeID IN (${inClause})`,\n Fields: ['ExternalParticipantID', 'DisplayName', 'IsAgent'],\n MaxRows: 1000,\n ResultType: 'simple',\n },\n provider.CurrentUser,\n );\n if (result.Success) {\n for (const p of result.Results) {\n const id = String(p['ExternalParticipantID'] ?? '').toLowerCase();\n if (!id) {\n continue;\n }\n // Each agent appears on multiple bridges' rosters — `IsAgent=1` only on its OWN bridge (where it's\n // the bot), `IsAgent=0` where another agent merely heard it. OR-reduce so it resolves to an agent,\n // and keep the most specific (non-fallback) DisplayName we've seen for the identity.\n const isAgent = p['IsAgent'] === true;\n const name = String(p['DisplayName'] ?? '');\n const prev = map.get(id);\n map.set(id, {\n name: name || prev?.name || 'Participant',\n isAgent: (prev?.isAgent ?? false) || isAgent,\n });\n }\n }\n return map;\n}\n\n/** AgentID → agent name, from the AIEngine cache (agents are always loaded for the analytics shell). */\nfunction buildAgentNameLookup(): Map<string, string> {\n const map = new Map<string, string>();\n for (const a of AIEngineBase.Instance.Agents ?? []) {\n map.set(a.ID.toLowerCase(), a.Name ?? 'Agent');\n }\n return map;\n}\n\n/**\n * Resolves one raw detail row into a display-ready, speaker-attributed line — the diarization-attribution\n * core. Exported for unit testing (the maps are easy to construct directly, no RunView mocking needed).\n *\n * @param d The raw `MJ: Conversation Details` row.\n * @param participantNames `ExternalParticipantID(lower) → { name, isAgent }` from the room roster.\n * @param agentName `AgentID(lower) → agent name`.\n */\nexport function attributeLine(\n d: Record<string, unknown>,\n participantNames: Map<string, { name: string; isAgent: boolean }>,\n agentName: Map<string, string>,\n): TranscriptLine {\n const role = String(d['Role'] ?? 'User');\n const externalId = String(d['ExternalID'] ?? '').toLowerCase();\n const base = {\n ID: String(d['ID']),\n Message: String(d['Message'] ?? d['Error'] ?? ''),\n At: toDate(d['__mj_CreatedAt']),\n };\n if (role === 'Error') {\n return { ...base, Kind: 'error', Speaker: 'Error' };\n }\n if (role === 'AI') {\n const agentId = String(d['AgentID'] ?? '').toLowerCase();\n return { ...base, Kind: 'agent', Speaker: agentName.get(agentId) ?? 'Agent' };\n }\n // 'User' — diarized to a participant when we have the speaker label; another agent heard reads as agent.\n const participant = externalId ? participantNames.get(externalId) : undefined;\n if (participant) {\n return { ...base, Kind: participant.isAgent ? 'agent' : 'human', Speaker: participant.name };\n }\n return { ...base, Kind: 'human', Speaker: 'Participant' };\n}\n"]}
1
+ {"version":3,"file":"realtime-transcripts-data.js","sourceRoot":"","sources":["../../../../../src/AI/components/analytics/realtime/realtime-transcripts-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAqB,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,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AI,IAAI,KAAK,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACzD,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC;IAClF,CAAC;IACD,yGAAyG;IACzG,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;IACjG,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * @fileoverview Pure data layer for the Realtime \"Voice Transcripts\" view. Loads the unified per-room\n * meeting transcripts the bridge writes (one `MJ: Conversations` of `Type='Meeting Room'` per room +\n * `MJ: Conversation Details` per utterance), and resolves each line's speaker — agent lines via `AgentID`,\n * heard ('User') lines via the diarized `ExternalID` → the room's `AIAgentSessionBridgeParticipant` roster\n * (DisplayName + IsAgent). No Angular imports — RunView(s) + client-side aggregation only.\n *\n * @module @memberjunction/ng-dashboards\n */\nimport { IMetadataProvider, RunView } from '@memberjunction/core';\nimport { EscapeSQLString } from '@memberjunction/global';\nimport { AIEngineBase } from '@memberjunction/ai-engine-base';\n\nconst CONVERSATION_ENTITY = 'MJ: Conversations';\nconst CONVERSATION_DETAIL_ENTITY = 'MJ: Conversation Details';\nconst BRIDGE_ENTITY = 'MJ: AI Agent Session Bridges';\nconst PARTICIPANT_ENTITY = 'MJ: AI Agent Session Bridge Participants';\n\n/** One meeting-room transcript in the list view. */\nexport interface MeetingRoomSummary {\n ConversationID: string;\n Name: string;\n /** The room's external connection id (`ExternalID`) — the join key to the bridge/participant rows. */\n RoomKey: string;\n CreatedAt: Date;\n LastActivity: Date;\n}\n\n/** A speaker-attributed transcript line for the drill-in view. */\nexport interface TranscriptLine {\n ID: string;\n /** `'agent'` = an agent spoke; `'human'` = a human/participant spoke; `'error'` = an error row. */\n Kind: 'agent' | 'human' | 'error';\n /** Resolved display name of the speaker (agent name, participant name, or a sensible fallback). */\n Speaker: string;\n Message: string;\n At: Date;\n}\n\nconst toDate = (v: unknown): Date => (v instanceof Date ? v : new Date(String(v ?? '')));\n\n/**\n * Loads the meeting-room transcript LIST (light — no per-room detail load). Newest activity first.\n *\n * @param provider The request-scoped metadata provider.\n * @param maxRows Cap on rooms returned (default 500).\n */\nexport async function LoadMeetingRooms(provider: IMetadataProvider, maxRows = 500): Promise<MeetingRoomSummary[]> {\n const rv = RunView.FromMetadataProvider(provider);\n const result = await rv.RunView<Record<string, unknown>>(\n {\n EntityName: CONVERSATION_ENTITY,\n ExtraFilter: `Type='Meeting Room'`,\n Fields: ['ID', 'Name', 'ExternalID', '__mj_CreatedAt', '__mj_UpdatedAt'],\n OrderBy: '__mj_UpdatedAt DESC',\n MaxRows: maxRows,\n ResultType: 'simple',\n },\n provider.CurrentUser,\n );\n if (!result.Success) {\n return [];\n }\n return result.Results.map((r) => ({\n ConversationID: String(r['ID']),\n Name: String(r['Name'] ?? 'Meeting Room'),\n RoomKey: String(r['ExternalID'] ?? ''),\n CreatedAt: toDate(r['__mj_CreatedAt']),\n LastActivity: toDate(r['__mj_UpdatedAt']),\n }));\n}\n\n/**\n * Loads + speaker-attributes one room's transcript. Resolves agent lines via `AgentID` (AIEngine cache) and\n * heard lines via the diarized `ExternalID` against the room's participant roster (so a `User` line reads as\n * the actual person, and another agent heard in the room reads as that agent — not a generic \"User\").\n *\n * @param provider The request-scoped metadata provider.\n * @param conversationID The room conversation id.\n * @param roomKey The room's external id (to load its bridge participants for attribution).\n */\nexport async function LoadRoomTranscript(\n provider: IMetadataProvider,\n conversationID: string,\n roomKey: string,\n): Promise<TranscriptLine[]> {\n const rv = RunView.FromMetadataProvider(provider);\n const [detailResult, bridgeResult] = await rv.RunViews([\n {\n EntityName: CONVERSATION_DETAIL_ENTITY,\n ExtraFilter: `ConversationID='${EscapeSQLString(conversationID)}'`,\n Fields: ['ID', 'Role', 'Message', 'AgentID', 'ExternalID', 'Error', '__mj_CreatedAt'],\n OrderBy: '__mj_CreatedAt ASC',\n MaxRows: 5000,\n ResultType: 'simple',\n },\n {\n EntityName: BRIDGE_ENTITY,\n ExtraFilter: roomKey ? `ExternalConnectionID='${EscapeSQLString(roomKey)}'` : `1=0`,\n Fields: ['ID'],\n MaxRows: 100,\n ResultType: 'simple',\n },\n ], provider.CurrentUser);\n\n const participantNames = await loadParticipantNames(provider, rv, (bridgeResult?.Results ?? []).map((b) => String(b['ID'])));\n const agentName = buildAgentNameLookup();\n\n const details = detailResult?.Success ? detailResult.Results : [];\n return details.map((d) => attributeLine(d, participantNames, agentName));\n}\n\n/** roomBridges → a map of `ExternalParticipantID → { name, isAgent }` for diarized-line attribution. */\nasync function loadParticipantNames(\n provider: IMetadataProvider,\n rv: RunView,\n bridgeIds: string[],\n): Promise<Map<string, { name: string; isAgent: boolean }>> {\n const map = new Map<string, { name: string; isAgent: boolean }>();\n if (bridgeIds.length === 0) {\n return map;\n }\n const inClause = bridgeIds.map((id) => `'${EscapeSQLString(id)}'`).join(',');\n const result = await rv.RunView<Record<string, unknown>>(\n {\n EntityName: PARTICIPANT_ENTITY,\n ExtraFilter: `SessionBridgeID IN (${inClause})`,\n Fields: ['ExternalParticipantID', 'DisplayName', 'IsAgent'],\n MaxRows: 1000,\n ResultType: 'simple',\n },\n provider.CurrentUser,\n );\n if (result.Success) {\n for (const p of result.Results) {\n const id = String(p['ExternalParticipantID'] ?? '').toLowerCase();\n if (!id) {\n continue;\n }\n // Each agent appears on multiple bridges' rosters — `IsAgent=1` only on its OWN bridge (where it's\n // the bot), `IsAgent=0` where another agent merely heard it. OR-reduce so it resolves to an agent,\n // and keep the most specific (non-fallback) DisplayName we've seen for the identity.\n const isAgent = p['IsAgent'] === true;\n const name = String(p['DisplayName'] ?? '');\n const prev = map.get(id);\n map.set(id, {\n name: name || prev?.name || 'Participant',\n isAgent: (prev?.isAgent ?? false) || isAgent,\n });\n }\n }\n return map;\n}\n\n/** AgentID → agent name, from the AIEngine cache (agents are always loaded for the analytics shell). */\nfunction buildAgentNameLookup(): Map<string, string> {\n const map = new Map<string, string>();\n for (const a of AIEngineBase.Instance.Agents ?? []) {\n map.set(a.ID.toLowerCase(), a.Name ?? 'Agent');\n }\n return map;\n}\n\n/**\n * Resolves one raw detail row into a display-ready, speaker-attributed line — the diarization-attribution\n * core. Exported for unit testing (the maps are easy to construct directly, no RunView mocking needed).\n *\n * @param d The raw `MJ: Conversation Details` row.\n * @param participantNames `ExternalParticipantID(lower) → { name, isAgent }` from the room roster.\n * @param agentName `AgentID(lower) → agent name`.\n */\nexport function attributeLine(\n d: Record<string, unknown>,\n participantNames: Map<string, { name: string; isAgent: boolean }>,\n agentName: Map<string, string>,\n): TranscriptLine {\n const role = String(d['Role'] ?? 'User');\n const externalId = String(d['ExternalID'] ?? '').toLowerCase();\n const base = {\n ID: String(d['ID']),\n Message: String(d['Message'] ?? d['Error'] ?? ''),\n At: toDate(d['__mj_CreatedAt']),\n };\n if (role === 'Error') {\n return { ...base, Kind: 'error', Speaker: 'Error' };\n }\n if (role === 'AI') {\n const agentId = String(d['AgentID'] ?? '').toLowerCase();\n return { ...base, Kind: 'agent', Speaker: agentName.get(agentId) ?? 'Agent' };\n }\n // 'User' — diarized to a participant when we have the speaker label; another agent heard reads as agent.\n const participant = externalId ? participantNames.get(externalId) : undefined;\n if (participant) {\n return { ...base, Kind: participant.isAgent ? 'agent' : 'human', Speaker: participant.name };\n }\n return { ...base, Kind: 'human', Speaker: 'Participant' };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"database-designer.engine.d.ts","sourceRoot":"","sources":["../../../src/DatabaseDesigner/services/database-designer.engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,aAAa,EAAc,MAAM,wBAAwB,CAAC;AAEnE,OAAO,KAAK,EACR,gBAAgB,EAChB,sBAAsB,EAGtB,YAAY,EACf,MAAM,+BAA+B,CAAC;AAwEvC;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IAE7E,WAAkB,QAAQ,IAAI,sBAAsB,CAEnD;IAED,SAAS;IAIT,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAElE,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;IAEpE,sFAAsF;IAC/E,eAAe,IAAI,IAAI;IAU9B;;;;;;;;OAQG;IACU,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAmBlE;;;OAGG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAqDvF;;;;;;;;;;;;;;OAcG;IACU,oBAAoB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAc5D,iFAAiF;YACnE,qBAAqB;IA+CnC,0FAA0F;YAC5E,iBAAiB;IAe/B;;;;;OAKG;IACU,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBzG,uFAAuF;YACzE,eAAe;IAsD7B,oEAAoE;YACtD,iBAAiB;IAkC/B,kFAAkF;YACpE,kBAAkB;IAmBhC,oFAAoF;IACpF,OAAO,CAAC,uBAAuB;IAQ/B,2EAA2E;IAC3E,OAAO,CAAC,oBAAoB;CAe/B"}
1
+ {"version":3,"file":"database-designer.engine.d.ts","sourceRoot":"","sources":["../../../src/DatabaseDesigner/services/database-designer.engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,aAAa,EAA+B,MAAM,wBAAwB,CAAC;AAEpF,OAAO,KAAK,EACR,gBAAgB,EAChB,sBAAsB,EAGtB,YAAY,EACf,MAAM,+BAA+B,CAAC;AAwEvC;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,aAAa,CAAC,sBAAsB,CAAC;IAE7E,WAAkB,QAAQ,IAAI,sBAAsB,CAEnD;IAED,SAAS;IAIT,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAElE,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;IAEpE,sFAAsF;IAC/E,eAAe,IAAI,IAAI;IAU9B;;;;;;;;OAQG;IACU,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAmBlE;;;OAGG;IACU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAqDvF;;;;;;;;;;;;;;OAcG;IACU,oBAAoB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAc5D,iFAAiF;YACnE,qBAAqB;IA+CnC,0FAA0F;YAC5E,iBAAiB;IAe/B;;;;;OAKG;IACU,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBzG,uFAAuF;YACzE,eAAe;IAsD7B,oEAAoE;YACtD,iBAAiB;IAkC/B,kFAAkF;YACpE,kBAAkB;IAmBhC,oFAAoF;IACpF,OAAO,CAAC,uBAAuB;IAQ/B,2EAA2E;IAC3E,OAAO,CAAC,oBAAoB;CAe/B"}
@@ -24,7 +24,7 @@
24
24
  * @see DatabaseDesignerService — for action invocation (create, modify, validate)
25
25
  */
26
26
  import { Metadata, RunView, AuthorizationEvaluator } from '@memberjunction/core';
27
- import { BaseSingleton, UUIDsEqual } from '@memberjunction/global';
27
+ import { BaseSingleton, UUIDsEqual, EscapeSQLString } from '@memberjunction/global';
28
28
  // ─── Constants (mirror database-designer-core/src/interfaces.ts) ───────────────
29
29
  // These string values MUST stay in sync with the server-side constants.
30
30
  // If the server-side values change, update here in parallel.
@@ -247,8 +247,8 @@ export class DatabaseDesignerEngine extends BaseSingleton {
247
247
  const rv = new RunView();
248
248
  const result = await rv.RunView({
249
249
  EntityName: 'MJ: Entities',
250
- ExtraFilter: `(Name = '${escapeSqlLiteral(entityName)}' OR BaseTable = '${escapeSqlLiteral(tableName)}') ` +
251
- `AND SchemaName = '${escapeSqlLiteral(schemaName)}'`,
250
+ ExtraFilter: `(Name = '${EscapeSQLString(entityName)}' OR BaseTable = '${EscapeSQLString(tableName)}') ` +
251
+ `AND SchemaName = '${EscapeSQLString(schemaName)}'`,
252
252
  Fields: ['ID'],
253
253
  ResultType: 'simple',
254
254
  });
@@ -308,7 +308,7 @@ export class DatabaseDesignerEngine extends BaseSingleton {
308
308
  // Find entities owned by this user
309
309
  const ownerResult = await rv.RunView({
310
310
  EntityName: 'MJ: Entity Settings',
311
- ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}' AND Value = '${escapeSqlLiteral(userId)}'`,
311
+ ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}' AND Value = '${EscapeSQLString(userId)}'`,
312
312
  Fields: ['EntityID', 'Value'],
313
313
  ResultType: 'simple',
314
314
  });
@@ -343,7 +343,7 @@ export class DatabaseDesignerEngine extends BaseSingleton {
343
343
  EntityName: 'MJ: Entity Settings',
344
344
  ExtraFilter: (`EntityID = '${escapeSqlId(entityId)}' ` +
345
345
  `AND Name = '${UDT_SETTINGS.OWNER_KEY}' ` +
346
- `AND Value = '${escapeSqlLiteral(userId)}'`),
346
+ `AND Value = '${EscapeSQLString(userId)}'`),
347
347
  Fields: ['EntityID', 'Value'],
348
348
  ResultType: 'simple',
349
349
  });
@@ -385,8 +385,4 @@ function buildInFilter(column, ids) {
385
385
  function escapeSqlId(id) {
386
386
  return id.replace(/[^a-zA-Z0-9-]/g, '');
387
387
  }
388
- /** Escape a string value for safe embedding in a SQL single-quoted literal. */
389
- function escapeSqlLiteral(value) {
390
- return value.replace(/'/g, "''");
391
- }
392
388
  //# sourceMappingURL=database-designer.engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"database-designer.engine.js","sourceRoot":"","sources":["../../../src/DatabaseDesigner/services/database-designer.engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAUnE,kFAAkF;AAClF,wEAAwE;AACxE,6DAA6D;AAE7D,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC,MAAM,YAAY,GAAG;IACjB,SAAS,EAAE,cAAc;IACzB,UAAU,EAAE,eAAe;IAC3B,wBAAwB,EAAE,kBAAkB;IAC5C,oBAAoB,EAAE,cAAc;CAC9B,CAAC;AAEX,MAAM,oBAAoB,GAAG;IACzB,oBAAoB,EAAE,sBAAsB;IAC5C,uBAAuB,EAAE,yBAAyB;IAClD,mBAAmB,EAAE,qBAAqB;IAC1C,uBAAuB,EAAE,yBAAyB;CAC5C,CAAC;AAEX,6CAA6C;AAC7C,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,C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K,CAAC;QACxB,MAAM,SAAS,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC,kCAAkC,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,2EAA2E;IACnE,oBAAoB,CAAC,KAAe;QACxC,OAAO;YACH,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,QAAQ,EAAG,4DAA4D;YAC7E,UAAU,EAAE,KAAK,CAAC,IAAI;YACtB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,6EAA6E;YAC7E,0EAA0E;YAC1E,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;YACvC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;YACvC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS;YAC/B,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,SAAS;YAC7C,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,SAAS;SAC9C,CAAC;IACN,CAAC;CACJ;AAED,gFAAgF;AAEhF,0EAA0E;AAC1E,SAAS,aAAa,CAAC,MAAc,EAAE,GAAa;IAChD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,OAAO,GAAG,MAAM,QAAQ,MAAM,GAAG,CAAC;AACtC,CAAC;AAED,2GAA2G;AAC3G,SAAS,WAAW,CAAC,EAAU;IAC3B,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E,SAAS,gBAAgB,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC","sourcesContent":["/**\n * @module database-designer.engine\n * @description Read-only data access engine for the Database Designer Angular UI.\n *\n * `DatabaseDesignerEngine` is a `BaseSingleton` (NOT an Angular service) that:\n * - Loads the list of entities accessible to the current user\n * - Loads full entity detail for the modify wizard\n * - Loads available schemas from `MJ: Schema Info` (async, cached per-user)\n * - Checks whether a proposed entity name / table name is available\n *\n * ### Why BaseSingleton, not @Injectable?\n * Engine classes hold a cross-request cache that must survive Angular's DI\n * lifecycle boundaries (the same instance is reused across multiple wizard\n * openings in the same session). `BaseSingleton` uses the MJ Global Object\n * Store which guarantees exactly one instance per process, even across ESBuild\n * code-split chunks.\n *\n * ### Usage\n * ```typescript\n * const engine = DatabaseDesignerEngine.Instance;\n * const entities = await engine.loadAccessibleEntities();\n * ```\n *\n * @see DatabaseDesignerService — for action invocation (create, modify, validate)\n */\n\nimport { Metadata, RunView, AuthorizationEvaluator } from '@memberjunction/core';\nimport { BaseSingleton, UUIDsEqual } from '@memberjunction/global';\n\nimport type {\n AccessibleEntity,\n AccessibleEntityDetail,\n ColumnSpec,\n ForeignKeySpec,\n SchemaOption,\n} from '../database-designer.types.js';\n\n// ─── Constants (mirror database-designer-core/src/interfaces.ts) ───────────────\n// These string values MUST stay in sync with the server-side constants.\n// If the server-side values change, update here in parallel.\n\nconst UDT_SCHEMA_NAME = '__mj_UDT';\n\nconst UDT_SETTINGS = {\n OWNER_KEY: 'MJ:UDT:Owner',\n SOURCE_KEY: 'MJ:UDT:Source',\n SOURCE_DATABASE_DESIGNER: 'DatabaseDesigner',\n SOURCE_AGENT_MANAGER: 'AgentManager',\n} as const;\n\nconst ENTITY_DESIGNER_AUTH = {\n CREATE_IN_UDT_SCHEMA: 'Create in UDT Schema',\n CREATE_IN_CUSTOM_SCHEMA: 'Create in Custom Schema',\n MODIFY_OWN_ENTITIES: 'Modify Own Entities',\n MODIFY_ANY_UDT_ENTITIES: 'Modify Any UDT Entities',\n} as const;\n\n/** Cache TTL in milliseconds (5 minutes). */\nconst CACHE_TTL_MS = 5 * 60 * 1_000;\n\n// ─── Columns managed automatically by CodeGen (never shown as user-editable) ─\n\n/**\n * Normalised lower-case set of column names that CodeGen injects on every entity.\n * These are filtered out of the modify wizard so users cannot inadvertently remove or\n * rename them. The set is compared after calling `.toLowerCase()` on each column name\n * so it is case-insensitive regardless of DB platform.\n */\nconst AUTO_MANAGED_COLUMNS = new Set(['id', '__mj_createdat', '__mj_updatedat']);\n\n// ─── Internal row types for RunView results ───────────────────────────────────\n\ninterface SettingsRow { EntityID: string; Value: string }\ninterface EntityRow { ID: string; Name: string; BaseTable: string; SchemaName: string; __mj_CreatedAt: string }\ninterface FieldRow {\n ID: string;\n EntityID: string;\n Name: string;\n Type: string;\n AllowsNull: boolean;\n Description: string;\n DefaultValue: string | null;\n MaxLength: number | null;\n Precision: number | null;\n Scale: number | null;\n}\n\n// ─── Cache entry ─────────────────────────────────────────────────────────────\n\ninterface EntityListCacheEntry {\n entities: AccessibleEntity[];\n timestamp: number;\n}\n\ninterface SchemaCacheEntry {\n schemas: SchemaOption[];\n timestamp: number;\n}\n\n// ─── Frontend-only schema blocklist ──────────────────────────────────────────\n// `MJ: Schema Info` only surfaces MJ-registered schemas, so system schemas\n// (sys, dbo, information_schema) never appear. Only __mj must be blocked here.\n// Server-side RSM.GetAllProtectedSchemas() remains the authoritative gate.\nconst FRONTEND_BLOCKED_SCHEMAS = new Set(['__mj']);\n\n// ─── Engine ──────────────────────────────────────────────────────────────────\n\n/**\n * Singleton data access engine for Database Designer.\n * All methods read data; none modifies state (mutations go through `DatabaseDesignerService`).\n */\nexport class DatabaseDesignerEngine extends BaseSingleton<DatabaseDesignerEngine> {\n\n public static get Instance(): DatabaseDesignerEngine {\n return super.getInstance<DatabaseDesignerEngine>();\n }\n\n protected constructor() { super(); }\n\n // ─── Cache ────────────────────────────────────────────────────────────\n\n /** Per-user entity list cache. Key = userID. */\n private readonly _cache = new Map<string, EntityListCacheEntry>();\n\n /** Per-user schema list cache. Key = userID. Invalidated alongside entity cache. */\n private readonly _schemaCache = new Map<string, SchemaCacheEntry>();\n\n /** Invalidate all per-user caches for the current user (call after create/modify). */\n public invalidateCache(): void {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (userId) {\n this._cache.delete(userId);\n this._schemaCache.delete(userId);\n }\n }\n\n // ─── Entity list ──────────────────────────────────────────────────────\n\n /**\n * Load all entities accessible to the current user.\n *\n * - **Admin** (holds `Modify Any UDT Entities`): sees all entities created by\n * Database Designer or Agent Manager, with ownership annotations.\n * - **Regular user**: sees only entities they own (`MJ:UDT:Owner = userId`).\n *\n * Results are cached per-user with a 5-minute TTL.\n */\n public async loadAccessibleEntities(): Promise<AccessibleEntity[]> {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const userId = md.CurrentUser?.ID;\n if (!userId) return [];\n\n const cached = this._cache.get(userId);\n if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {\n return cached.entities;\n }\n\n const isAdmin = this.currentUserCanModifyAny();\n const entities = isAdmin\n ? await this.loadAllEntities(userId)\n : await this.loadOwnedEntities(userId);\n\n this._cache.set(userId, { entities, timestamp: Date.now() });\n return entities;\n }\n\n /**\n * Load full entity detail (columns, foreign keys, description) for the modify wizard.\n * Not cached — always fetches fresh data so the wizard reflects current DB state.\n */\n public async loadEntityDetail(entityId: string): Promise<AccessibleEntityDetail | null> {\n const rv = new RunView();\n // BypassCache: true on both queries because CodeGen writes Entity Fields via direct\n // SQL (outside BaseEntity.Save()), so the server-side RunView cache never receives\n // an invalidation event after a pipeline run. Without this, the detail view would\n // show stale field data (e.g. old AllowsNull value) until MJAPI restarts.\n const [entityResult, fieldsResult] = await rv.RunViews([\n {\n EntityName: 'MJ: Entities',\n ExtraFilter: `ID = '${escapeSqlId(entityId)}'`,\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', 'Description', '__mj_CreatedAt'],\n ResultType: 'simple',\n BypassCache: true,\n },\n {\n EntityName: 'MJ: Entity Fields',\n ExtraFilter: `EntityID = '${escapeSqlId(entityId)}' AND IsVirtual = 0`,\n Fields: ['ID', 'EntityID', 'Name', 'Type', 'AllowsNull', 'Description', 'DefaultValue', 'MaxLength', 'Precision', 'Scale'],\n OrderBy: 'Sequence ASC, Name ASC',\n ResultType: 'simple',\n BypassCache: true,\n },\n ]);\n\n if (!entityResult.Success || entityResult.Results.length === 0) return null;\n\n const entity = entityResult.Results[0] as EntityRow & { Description: string };\n const fieldRows = (fieldsResult.Results ?? []) as FieldRow[];\n\n const isOwner = await this.isCurrentUserOwner(entityId);\n\n // Exclude auto-managed columns (ID, __mj_CreatedAt, __mj_UpdatedAt) from the editable\n // column list. CodeGen injects these automatically — they must not be user-modified.\n const editableFields = fieldRows.filter(\n f => !AUTO_MANAGED_COLUMNS.has(f.Name.toLowerCase())\n );\n\n return {\n entityId: entity.ID,\n entityName: entity.Name,\n tableName: entity.BaseTable,\n schemaName: entity.SchemaName,\n description: entity.Description ?? '',\n fieldCount: editableFields.length,\n createdAt: new Date(entity.__mj_CreatedAt),\n isOwner,\n columns: editableFields.map(f => this.mapFieldToColumnSpec(f)),\n foreignKeys: [], // FK detail loaded on demand — Phase 5e\n };\n }\n\n // ─── Schema options ───────────────────────────────────────────────────\n\n /**\n * Return the list of schemas the current user is authorized to create tables in.\n *\n * Async — queries `MJ: Schema Info` to surface real DB schemas for users\n * with `Create in Custom Schema` authorization. Results are cached per-user\n * with the same 5-minute TTL as the entity list.\n *\n * Order:\n * 1. `__mj_UDT` (if user holds `Create in UDT Schema`)\n * 2. Real DB schemas from `MJ: Schema Info`, excluding blocked schemas\n * and `__mj_UDT` (already listed first)\n * 3. \"Other (enter schema name)\" free-text option, at the end\n *\n * All items beyond #1 require `Create in Custom Schema` authorization.\n */\n public async loadAvailableSchemas(): Promise<SchemaOption[]> {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (!userId) return [];\n\n const cached = this._schemaCache.get(userId);\n if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {\n return cached.schemas;\n }\n\n const schemas = await this.fetchAvailableSchemas();\n this._schemaCache.set(userId, { schemas, timestamp: Date.now() });\n return schemas;\n }\n\n /** Build the schema option list: UDT first, then real DB schemas, then Other. */\n private async fetchAvailableSchemas(): Promise<SchemaOption[]> {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const evaluator = new AuthorizationEvaluator();\n\n const udtAuth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.CREATE_IN_UDT_SCHEMA);\n const customAuth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.CREATE_IN_CUSTOM_SCHEMA);\n\n const canUseUdt = !!(udtAuth && evaluator.CurrentUserCanExecuteWithAncestors(udtAuth));\n const canUseCustom = !!(customAuth && evaluator.CurrentUserCanExecuteWithAncestors(customAuth));\n\n const schemas: SchemaOption[] = [];\n\n if (canUseUdt) {\n schemas.push({\n value: UDT_SCHEMA_NAME,\n label: `${UDT_SCHEMA_NAME} — User-Defined Tables (default)`,\n isDefault: true,\n requiresElevatedAuth: false,\n });\n }\n\n if (canUseCustom) {\n const dbSchemas = await this.loadDbSchemaNames();\n for (const schemaName of dbSchemas) {\n // Skip the UDT schema (already first) and any server-blocked schemas\n if (schemaName === UDT_SCHEMA_NAME) continue;\n if (FRONTEND_BLOCKED_SCHEMAS.has(schemaName)) continue;\n schemas.push({\n value: schemaName,\n label: schemaName,\n isDefault: false,\n requiresElevatedAuth: true,\n });\n }\n\n // Free-text escape hatch for schemas not yet registered with MJ\n schemas.push({\n value: '',\n label: 'Other (enter schema name)',\n isDefault: false,\n requiresElevatedAuth: true,\n });\n }\n\n return schemas;\n }\n\n /** Query `MJ: Schema Info` for distinct schema names registered with this MJ instance. */\n private async loadDbSchemaNames(): Promise<string[]> {\n const rv = new RunView();\n const result = await rv.RunView<{ SchemaName: string }>({\n EntityName: 'MJ: Schema Info',\n Fields: ['SchemaName'],\n OrderBy: 'SchemaName ASC',\n ResultType: 'simple',\n });\n\n if (!result.Success) return [];\n return result.Results.map(r => r.SchemaName).filter(Boolean);\n }\n\n // ─── Name availability ────────────────────────────────────────────────\n\n /**\n * Check whether the proposed entity name and table name are available\n * (no existing MJ entity in the same schema shares either).\n *\n * Returns true when the proposed names are safe to use.\n */\n public async isNameAvailable(entityName: string, tableName: string, schemaName: string): Promise<boolean> {\n const rv = new RunView();\n const result = await rv.RunView<{ ID: string }>({\n EntityName: 'MJ: Entities',\n ExtraFilter:\n `(Name = '${escapeSqlLiteral(entityName)}' OR BaseTable = '${escapeSqlLiteral(tableName)}') ` +\n `AND SchemaName = '${escapeSqlLiteral(schemaName)}'`,\n Fields: ['ID'],\n ResultType: 'simple',\n });\n\n return result.Success && result.Results.length === 0;\n }\n\n // ─── Private helpers ──────────────────────────────────────────────────\n\n /** Admin path: load all database-Designer-managed entities + ownership annotations. */\n private async loadAllEntities(currentUserId: string): Promise<AccessibleEntity[]> {\n const rv = new RunView();\n\n // Round 1: get entity IDs from provenance settings and owner map\n const [sourceResult, ownerResult] = await rv.RunViews([\n {\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: (\n `Name = '${UDT_SETTINGS.SOURCE_KEY}' ` +\n `AND Value IN ('${UDT_SETTINGS.SOURCE_DATABASE_DESIGNER}', '${UDT_SETTINGS.SOURCE_AGENT_MANAGER}')`\n ),\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n },\n {\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}'`,\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n },\n ]);\n\n const sourceRows = (sourceResult.Results ?? []) as SettingsRow[];\n const ownerRows = (ownerResult.Results ?? []) as SettingsRow[];\n\n const entityIds = Array.from(new Set(sourceRows.map(r => r.EntityID)));\n if (entityIds.length === 0) return [];\n\n const ownerMap = new Map(ownerRows.map(r => [r.EntityID, r.Value]));\n\n // Round 2: entity details\n const entityResult = await rv.RunView<EntityRow>({\n EntityName: 'MJ: Entities',\n ExtraFilter: buildInFilter('ID', entityIds),\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', '__mj_CreatedAt'],\n OrderBy: 'Name ASC',\n ResultType: 'simple',\n });\n\n return (entityResult.Results ?? []).map(row => {\n const ownerUserId = ownerMap.get(row.ID);\n return {\n entityId: row.ID,\n entityName: row.Name,\n tableName: row.BaseTable,\n schemaName: row.SchemaName,\n fieldCount: 0, // loaded on demand in detail view\n createdAt: new Date(row.__mj_CreatedAt),\n // UUIDsEqual handles SQL Server uppercase vs PostgreSQL lowercase UUIDs\n isOwner: ownerUserId != null && UUIDsEqual(ownerUserId, currentUserId),\n } satisfies AccessibleEntity;\n });\n }\n\n /** Non-admin path: load only entities owned by the current user. */\n private async loadOwnedEntities(userId: string): Promise<AccessibleEntity[]> {\n const rv = new RunView();\n\n // Find entities owned by this user\n const ownerResult = await rv.RunView<SettingsRow>({\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}' AND Value = '${escapeSqlLiteral(userId)}'`,\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n });\n\n const entityIds = (ownerResult.Results ?? []).map(r => r.EntityID);\n if (entityIds.length === 0) return [];\n\n // Fetch entity details\n const entityResult = await rv.RunView<EntityRow>({\n EntityName: 'MJ: Entities',\n ExtraFilter: buildInFilter('ID', entityIds),\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', '__mj_CreatedAt'],\n OrderBy: 'Name ASC',\n ResultType: 'simple',\n });\n\n return (entityResult.Results ?? []).map(row => ({\n entityId: row.ID,\n entityName: row.Name,\n tableName: row.BaseTable,\n schemaName: row.SchemaName,\n fieldCount: 0,\n createdAt: new Date(row.__mj_CreatedAt),\n isOwner: true, // user can only see their own entities in this path\n } satisfies AccessibleEntity));\n }\n\n /** Check if the current user owns the given entity (via MJ:UDT:Owner setting). */\n private async isCurrentUserOwner(entityId: string): Promise<boolean> {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (!userId) return false;\n\n const rv = new RunView();\n const result = await rv.RunView<SettingsRow>({\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: (\n `EntityID = '${escapeSqlId(entityId)}' ` +\n `AND Name = '${UDT_SETTINGS.OWNER_KEY}' ` +\n `AND Value = '${escapeSqlLiteral(userId)}'`\n ),\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n });\n\n return result.Success && result.Results.length > 0;\n }\n\n /** True when the current user holds the `Modify Any UDT Entities` authorization. */\n private currentUserCanModifyAny(): boolean {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const auth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.MODIFY_ANY_UDT_ENTITIES);\n if (!auth) return false;\n const evaluator = new AuthorizationEvaluator();\n return evaluator.CurrentUserCanExecuteWithAncestors(auth);\n }\n\n /** Map a `MJ: Entity Fields` row to a `ColumnSpec` for the detail view. */\n private mapFieldToColumnSpec(field: FieldRow): ColumnSpec {\n return {\n Name: field.Name,\n Type: 'string', // detail view uses RawSqlType for display; Type is semantic\n RawSqlType: field.Type,\n IsNullable: field.AllowsNull,\n // Preserve precision/scale metadata so the modify wizard renders the correct\n // field type controls (e.g. DECIMAL(18,2) vs DECIMAL with no constraints)\n MaxLength: field.MaxLength ?? undefined,\n Precision: field.Precision ?? undefined,\n Scale: field.Scale ?? undefined,\n DefaultValue: field.DefaultValue ?? undefined,\n Description: field.Description ?? undefined,\n };\n }\n}\n\n// ─── Private module-level utilities ──────────────────────────────────────────\n\n/** Build a SQL `column IN ('id1', 'id2', ...)` filter for a UUID list. */\nfunction buildInFilter(column: string, ids: string[]): string {\n const quoted = ids.map(id => `'${escapeSqlId(id)}'`).join(', ');\n return `${column} IN (${quoted})`;\n}\n\n/** Escape a UUID for safe embedding in a SQL filter (UUIDs are alphanumeric + dashes, but be explicit). */\nfunction escapeSqlId(id: string): string {\n return id.replace(/[^a-zA-Z0-9-]/g, '');\n}\n\n/** Escape a string value for safe embedding in a SQL single-quoted literal. */\nfunction escapeSqlLiteral(value: string): string {\n return value.replace(/'/g, \"''\");\n}\n"]}
1
+ {"version":3,"file":"database-designer.engine.js","sourceRoot":"","sources":["../../../src/DatabaseDesigner/services/database-designer.engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUpF,kFAAkF;AAClF,wEAAwE;AACxE,6DAA6D;AAE7D,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC,MAAM,YAAY,GAAG;IACjB,SAAS,EAAE,cAAc;IACzB,UAAU,EAAE,eAAe;IAC3B,wBAAwB,EAAE,kBAAkB;IAC5C,oBAAoB,EAAE,cAAc;CAC9B,CAAC;AAEX,MAAM,oBAAoB,GAAG;IACzB,oBAAoB,EAAE,sBAAsB;IAC5C,uBAAuB,EAAE,yBAAyB;IAClD,mBAAmB,EAAE,qBAAqB;IAC1C,uBAAuB,EAAE,yBAAyB;CAC5C,CAAC;AAEX,6CAA6C;AAC7C,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AAEpC,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AA+BjF,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,2EAA2E;AAC3E,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEnD,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,aAAqC;IAEtE,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,EAA0B,CAAC;IACvD,CAAC;I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S,IAAI,SAAS;YACvC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS;YAC/B,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,SAAS;YAC7C,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,SAAS;SAC9C,CAAC;IACN,CAAC;CACJ;AAED,gFAAgF;AAEhF,0EAA0E;AAC1E,SAAS,aAAa,CAAC,MAAc,EAAE,GAAa;IAChD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,OAAO,GAAG,MAAM,QAAQ,MAAM,GAAG,CAAC;AACtC,CAAC;AAED,2GAA2G;AAC3G,SAAS,WAAW,CAAC,EAAU;IAC3B,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * @module database-designer.engine\n * @description Read-only data access engine for the Database Designer Angular UI.\n *\n * `DatabaseDesignerEngine` is a `BaseSingleton` (NOT an Angular service) that:\n * - Loads the list of entities accessible to the current user\n * - Loads full entity detail for the modify wizard\n * - Loads available schemas from `MJ: Schema Info` (async, cached per-user)\n * - Checks whether a proposed entity name / table name is available\n *\n * ### Why BaseSingleton, not @Injectable?\n * Engine classes hold a cross-request cache that must survive Angular's DI\n * lifecycle boundaries (the same instance is reused across multiple wizard\n * openings in the same session). `BaseSingleton` uses the MJ Global Object\n * Store which guarantees exactly one instance per process, even across ESBuild\n * code-split chunks.\n *\n * ### Usage\n * ```typescript\n * const engine = DatabaseDesignerEngine.Instance;\n * const entities = await engine.loadAccessibleEntities();\n * ```\n *\n * @see DatabaseDesignerService — for action invocation (create, modify, validate)\n */\n\nimport { Metadata, RunView, AuthorizationEvaluator } from '@memberjunction/core';\nimport { BaseSingleton, UUIDsEqual, EscapeSQLString } from '@memberjunction/global';\n\nimport type {\n AccessibleEntity,\n AccessibleEntityDetail,\n ColumnSpec,\n ForeignKeySpec,\n SchemaOption,\n} from '../database-designer.types.js';\n\n// ─── Constants (mirror database-designer-core/src/interfaces.ts) ───────────────\n// These string values MUST stay in sync with the server-side constants.\n// If the server-side values change, update here in parallel.\n\nconst UDT_SCHEMA_NAME = '__mj_UDT';\n\nconst UDT_SETTINGS = {\n OWNER_KEY: 'MJ:UDT:Owner',\n SOURCE_KEY: 'MJ:UDT:Source',\n SOURCE_DATABASE_DESIGNER: 'DatabaseDesigner',\n SOURCE_AGENT_MANAGER: 'AgentManager',\n} as const;\n\nconst ENTITY_DESIGNER_AUTH = {\n CREATE_IN_UDT_SCHEMA: 'Create in UDT Schema',\n CREATE_IN_CUSTOM_SCHEMA: 'Create in Custom Schema',\n MODIFY_OWN_ENTITIES: 'Modify Own Entities',\n MODIFY_ANY_UDT_ENTITIES: 'Modify Any UDT Entities',\n} as const;\n\n/** Cache TTL in milliseconds (5 minutes). */\nconst CACHE_TTL_MS = 5 * 60 * 1_000;\n\n// ─── Columns managed automatically by CodeGen (never shown as user-editable) ─\n\n/**\n * Normalised lower-case set of column names that CodeGen injects on every entity.\n * These are filtered out of the modify wizard so users cannot inadvertently remove or\n * rename them. The set is compared after calling `.toLowerCase()` on each column name\n * so it is case-insensitive regardless of DB platform.\n */\nconst AUTO_MANAGED_COLUMNS = new Set(['id', '__mj_createdat', '__mj_updatedat']);\n\n// ─── Internal row types for RunView results ───────────────────────────────────\n\ninterface SettingsRow { EntityID: string; Value: string }\ninterface EntityRow { ID: string; Name: string; BaseTable: string; SchemaName: string; __mj_CreatedAt: string }\ninterface FieldRow {\n ID: string;\n EntityID: string;\n Name: string;\n Type: string;\n AllowsNull: boolean;\n Description: string;\n DefaultValue: string | null;\n MaxLength: number | null;\n Precision: number | null;\n Scale: number | null;\n}\n\n// ─── Cache entry ─────────────────────────────────────────────────────────────\n\ninterface EntityListCacheEntry {\n entities: AccessibleEntity[];\n timestamp: number;\n}\n\ninterface SchemaCacheEntry {\n schemas: SchemaOption[];\n timestamp: number;\n}\n\n// ─── Frontend-only schema blocklist ──────────────────────────────────────────\n// `MJ: Schema Info` only surfaces MJ-registered schemas, so system schemas\n// (sys, dbo, information_schema) never appear. Only __mj must be blocked here.\n// Server-side RSM.GetAllProtectedSchemas() remains the authoritative gate.\nconst FRONTEND_BLOCKED_SCHEMAS = new Set(['__mj']);\n\n// ─── Engine ──────────────────────────────────────────────────────────────────\n\n/**\n * Singleton data access engine for Database Designer.\n * All methods read data; none modifies state (mutations go through `DatabaseDesignerService`).\n */\nexport class DatabaseDesignerEngine extends BaseSingleton<DatabaseDesignerEngine> {\n\n public static get Instance(): DatabaseDesignerEngine {\n return super.getInstance<DatabaseDesignerEngine>();\n }\n\n protected constructor() { super(); }\n\n // ─── Cache ────────────────────────────────────────────────────────────\n\n /** Per-user entity list cache. Key = userID. */\n private readonly _cache = new Map<string, EntityListCacheEntry>();\n\n /** Per-user schema list cache. Key = userID. Invalidated alongside entity cache. */\n private readonly _schemaCache = new Map<string, SchemaCacheEntry>();\n\n /** Invalidate all per-user caches for the current user (call after create/modify). */\n public invalidateCache(): void {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (userId) {\n this._cache.delete(userId);\n this._schemaCache.delete(userId);\n }\n }\n\n // ─── Entity list ──────────────────────────────────────────────────────\n\n /**\n * Load all entities accessible to the current user.\n *\n * - **Admin** (holds `Modify Any UDT Entities`): sees all entities created by\n * Database Designer or Agent Manager, with ownership annotations.\n * - **Regular user**: sees only entities they own (`MJ:UDT:Owner = userId`).\n *\n * Results are cached per-user with a 5-minute TTL.\n */\n public async loadAccessibleEntities(): Promise<AccessibleEntity[]> {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const userId = md.CurrentUser?.ID;\n if (!userId) return [];\n\n const cached = this._cache.get(userId);\n if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {\n return cached.entities;\n }\n\n const isAdmin = this.currentUserCanModifyAny();\n const entities = isAdmin\n ? await this.loadAllEntities(userId)\n : await this.loadOwnedEntities(userId);\n\n this._cache.set(userId, { entities, timestamp: Date.now() });\n return entities;\n }\n\n /**\n * Load full entity detail (columns, foreign keys, description) for the modify wizard.\n * Not cached — always fetches fresh data so the wizard reflects current DB state.\n */\n public async loadEntityDetail(entityId: string): Promise<AccessibleEntityDetail | null> {\n const rv = new RunView();\n // BypassCache: true on both queries because CodeGen writes Entity Fields via direct\n // SQL (outside BaseEntity.Save()), so the server-side RunView cache never receives\n // an invalidation event after a pipeline run. Without this, the detail view would\n // show stale field data (e.g. old AllowsNull value) until MJAPI restarts.\n const [entityResult, fieldsResult] = await rv.RunViews([\n {\n EntityName: 'MJ: Entities',\n ExtraFilter: `ID = '${escapeSqlId(entityId)}'`,\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', 'Description', '__mj_CreatedAt'],\n ResultType: 'simple',\n BypassCache: true,\n },\n {\n EntityName: 'MJ: Entity Fields',\n ExtraFilter: `EntityID = '${escapeSqlId(entityId)}' AND IsVirtual = 0`,\n Fields: ['ID', 'EntityID', 'Name', 'Type', 'AllowsNull', 'Description', 'DefaultValue', 'MaxLength', 'Precision', 'Scale'],\n OrderBy: 'Sequence ASC, Name ASC',\n ResultType: 'simple',\n BypassCache: true,\n },\n ]);\n\n if (!entityResult.Success || entityResult.Results.length === 0) return null;\n\n const entity = entityResult.Results[0] as EntityRow & { Description: string };\n const fieldRows = (fieldsResult.Results ?? []) as FieldRow[];\n\n const isOwner = await this.isCurrentUserOwner(entityId);\n\n // Exclude auto-managed columns (ID, __mj_CreatedAt, __mj_UpdatedAt) from the editable\n // column list. CodeGen injects these automatically — they must not be user-modified.\n const editableFields = fieldRows.filter(\n f => !AUTO_MANAGED_COLUMNS.has(f.Name.toLowerCase())\n );\n\n return {\n entityId: entity.ID,\n entityName: entity.Name,\n tableName: entity.BaseTable,\n schemaName: entity.SchemaName,\n description: entity.Description ?? '',\n fieldCount: editableFields.length,\n createdAt: new Date(entity.__mj_CreatedAt),\n isOwner,\n columns: editableFields.map(f => this.mapFieldToColumnSpec(f)),\n foreignKeys: [], // FK detail loaded on demand — Phase 5e\n };\n }\n\n // ─── Schema options ───────────────────────────────────────────────────\n\n /**\n * Return the list of schemas the current user is authorized to create tables in.\n *\n * Async — queries `MJ: Schema Info` to surface real DB schemas for users\n * with `Create in Custom Schema` authorization. Results are cached per-user\n * with the same 5-minute TTL as the entity list.\n *\n * Order:\n * 1. `__mj_UDT` (if user holds `Create in UDT Schema`)\n * 2. Real DB schemas from `MJ: Schema Info`, excluding blocked schemas\n * and `__mj_UDT` (already listed first)\n * 3. \"Other (enter schema name)\" free-text option, at the end\n *\n * All items beyond #1 require `Create in Custom Schema` authorization.\n */\n public async loadAvailableSchemas(): Promise<SchemaOption[]> {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (!userId) return [];\n\n const cached = this._schemaCache.get(userId);\n if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {\n return cached.schemas;\n }\n\n const schemas = await this.fetchAvailableSchemas();\n this._schemaCache.set(userId, { schemas, timestamp: Date.now() });\n return schemas;\n }\n\n /** Build the schema option list: UDT first, then real DB schemas, then Other. */\n private async fetchAvailableSchemas(): Promise<SchemaOption[]> {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const evaluator = new AuthorizationEvaluator();\n\n const udtAuth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.CREATE_IN_UDT_SCHEMA);\n const customAuth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.CREATE_IN_CUSTOM_SCHEMA);\n\n const canUseUdt = !!(udtAuth && evaluator.CurrentUserCanExecuteWithAncestors(udtAuth));\n const canUseCustom = !!(customAuth && evaluator.CurrentUserCanExecuteWithAncestors(customAuth));\n\n const schemas: SchemaOption[] = [];\n\n if (canUseUdt) {\n schemas.push({\n value: UDT_SCHEMA_NAME,\n label: `${UDT_SCHEMA_NAME} — User-Defined Tables (default)`,\n isDefault: true,\n requiresElevatedAuth: false,\n });\n }\n\n if (canUseCustom) {\n const dbSchemas = await this.loadDbSchemaNames();\n for (const schemaName of dbSchemas) {\n // Skip the UDT schema (already first) and any server-blocked schemas\n if (schemaName === UDT_SCHEMA_NAME) continue;\n if (FRONTEND_BLOCKED_SCHEMAS.has(schemaName)) continue;\n schemas.push({\n value: schemaName,\n label: schemaName,\n isDefault: false,\n requiresElevatedAuth: true,\n });\n }\n\n // Free-text escape hatch for schemas not yet registered with MJ\n schemas.push({\n value: '',\n label: 'Other (enter schema name)',\n isDefault: false,\n requiresElevatedAuth: true,\n });\n }\n\n return schemas;\n }\n\n /** Query `MJ: Schema Info` for distinct schema names registered with this MJ instance. */\n private async loadDbSchemaNames(): Promise<string[]> {\n const rv = new RunView();\n const result = await rv.RunView<{ SchemaName: string }>({\n EntityName: 'MJ: Schema Info',\n Fields: ['SchemaName'],\n OrderBy: 'SchemaName ASC',\n ResultType: 'simple',\n });\n\n if (!result.Success) return [];\n return result.Results.map(r => r.SchemaName).filter(Boolean);\n }\n\n // ─── Name availability ────────────────────────────────────────────────\n\n /**\n * Check whether the proposed entity name and table name are available\n * (no existing MJ entity in the same schema shares either).\n *\n * Returns true when the proposed names are safe to use.\n */\n public async isNameAvailable(entityName: string, tableName: string, schemaName: string): Promise<boolean> {\n const rv = new RunView();\n const result = await rv.RunView<{ ID: string }>({\n EntityName: 'MJ: Entities',\n ExtraFilter:\n `(Name = '${EscapeSQLString(entityName)}' OR BaseTable = '${EscapeSQLString(tableName)}') ` +\n `AND SchemaName = '${EscapeSQLString(schemaName)}'`,\n Fields: ['ID'],\n ResultType: 'simple',\n });\n\n return result.Success && result.Results.length === 0;\n }\n\n // ─── Private helpers ──────────────────────────────────────────────────\n\n /** Admin path: load all database-Designer-managed entities + ownership annotations. */\n private async loadAllEntities(currentUserId: string): Promise<AccessibleEntity[]> {\n const rv = new RunView();\n\n // Round 1: get entity IDs from provenance settings and owner map\n const [sourceResult, ownerResult] = await rv.RunViews([\n {\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: (\n `Name = '${UDT_SETTINGS.SOURCE_KEY}' ` +\n `AND Value IN ('${UDT_SETTINGS.SOURCE_DATABASE_DESIGNER}', '${UDT_SETTINGS.SOURCE_AGENT_MANAGER}')`\n ),\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n },\n {\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}'`,\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n },\n ]);\n\n const sourceRows = (sourceResult.Results ?? []) as SettingsRow[];\n const ownerRows = (ownerResult.Results ?? []) as SettingsRow[];\n\n const entityIds = Array.from(new Set(sourceRows.map(r => r.EntityID)));\n if (entityIds.length === 0) return [];\n\n const ownerMap = new Map(ownerRows.map(r => [r.EntityID, r.Value]));\n\n // Round 2: entity details\n const entityResult = await rv.RunView<EntityRow>({\n EntityName: 'MJ: Entities',\n ExtraFilter: buildInFilter('ID', entityIds),\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', '__mj_CreatedAt'],\n OrderBy: 'Name ASC',\n ResultType: 'simple',\n });\n\n return (entityResult.Results ?? []).map(row => {\n const ownerUserId = ownerMap.get(row.ID);\n return {\n entityId: row.ID,\n entityName: row.Name,\n tableName: row.BaseTable,\n schemaName: row.SchemaName,\n fieldCount: 0, // loaded on demand in detail view\n createdAt: new Date(row.__mj_CreatedAt),\n // UUIDsEqual handles SQL Server uppercase vs PostgreSQL lowercase UUIDs\n isOwner: ownerUserId != null && UUIDsEqual(ownerUserId, currentUserId),\n } satisfies AccessibleEntity;\n });\n }\n\n /** Non-admin path: load only entities owned by the current user. */\n private async loadOwnedEntities(userId: string): Promise<AccessibleEntity[]> {\n const rv = new RunView();\n\n // Find entities owned by this user\n const ownerResult = await rv.RunView<SettingsRow>({\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: `Name = '${UDT_SETTINGS.OWNER_KEY}' AND Value = '${EscapeSQLString(userId)}'`,\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n });\n\n const entityIds = (ownerResult.Results ?? []).map(r => r.EntityID);\n if (entityIds.length === 0) return [];\n\n // Fetch entity details\n const entityResult = await rv.RunView<EntityRow>({\n EntityName: 'MJ: Entities',\n ExtraFilter: buildInFilter('ID', entityIds),\n Fields: ['ID', 'Name', 'BaseTable', 'SchemaName', '__mj_CreatedAt'],\n OrderBy: 'Name ASC',\n ResultType: 'simple',\n });\n\n return (entityResult.Results ?? []).map(row => ({\n entityId: row.ID,\n entityName: row.Name,\n tableName: row.BaseTable,\n schemaName: row.SchemaName,\n fieldCount: 0,\n createdAt: new Date(row.__mj_CreatedAt),\n isOwner: true, // user can only see their own entities in this path\n } satisfies AccessibleEntity));\n }\n\n /** Check if the current user owns the given entity (via MJ:UDT:Owner setting). */\n private async isCurrentUserOwner(entityId: string): Promise<boolean> {\n const userId = new Metadata().CurrentUser?.ID; // global-provider-ok: client-side Angular engine, single provider\n if (!userId) return false;\n\n const rv = new RunView();\n const result = await rv.RunView<SettingsRow>({\n EntityName: 'MJ: Entity Settings',\n ExtraFilter: (\n `EntityID = '${escapeSqlId(entityId)}' ` +\n `AND Name = '${UDT_SETTINGS.OWNER_KEY}' ` +\n `AND Value = '${EscapeSQLString(userId)}'`\n ),\n Fields: ['EntityID', 'Value'],\n ResultType: 'simple',\n });\n\n return result.Success && result.Results.length > 0;\n }\n\n /** True when the current user holds the `Modify Any UDT Entities` authorization. */\n private currentUserCanModifyAny(): boolean {\n const md = new Metadata(); // global-provider-ok: client-side Angular engine, single provider\n const auth = md.Authorizations.find(a => a.Name === ENTITY_DESIGNER_AUTH.MODIFY_ANY_UDT_ENTITIES);\n if (!auth) return false;\n const evaluator = new AuthorizationEvaluator();\n return evaluator.CurrentUserCanExecuteWithAncestors(auth);\n }\n\n /** Map a `MJ: Entity Fields` row to a `ColumnSpec` for the detail view. */\n private mapFieldToColumnSpec(field: FieldRow): ColumnSpec {\n return {\n Name: field.Name,\n Type: 'string', // detail view uses RawSqlType for display; Type is semantic\n RawSqlType: field.Type,\n IsNullable: field.AllowsNull,\n // Preserve precision/scale metadata so the modify wizard renders the correct\n // field type controls (e.g. DECIMAL(18,2) vs DECIMAL with no constraints)\n MaxLength: field.MaxLength ?? undefined,\n Precision: field.Precision ?? undefined,\n Scale: field.Scale ?? undefined,\n DefaultValue: field.DefaultValue ?? undefined,\n Description: field.Description ?? undefined,\n };\n }\n}\n\n// ─── Private module-level utilities ──────────────────────────────────────────\n\n/** Build a SQL `column IN ('id1', 'id2', ...)` filter for a UUID list. */\nfunction buildInFilter(column: string, ids: string[]): string {\n const quoted = ids.map(id => `'${escapeSqlId(id)}'`).join(', ');\n return `${column} IN (${quoted})`;\n}\n\n/** Escape a UUID for safe embedding in a SQL filter (UUIDs are alphanumeric + dashes, but be explicit). */\nfunction escapeSqlId(id: string): string {\n return id.replace(/[^a-zA-Z0-9-]/g, '');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-dashboards",
3
- "version": "6.1.0-edge.3",
3
+ "version": "6.1.0-edge.4",
4
4
  "description": "MemberJunction Dashboards",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -85,7 +85,7 @@
85
85
  "@angular/compiler-cli": "21.1.3",
86
86
  "@types/d3": "^7.4.0",
87
87
  "sass": "^1.97.3",
88
- "@memberjunction/ng-test-utils": "6.1.0-edge.3"
88
+ "@memberjunction/ng-test-utils": "6.1.0-edge.4"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@angular/common": "^21.1.3",
@@ -102,67 +102,67 @@
102
102
  "@codemirror/merge": "^6.11.2",
103
103
  "@codemirror/state": "^6.5.4",
104
104
  "@codemirror/view": "^6.39.12",
105
- "@memberjunction/actions-base": "6.1.0-edge.3",
106
- "@memberjunction/ai-core-plus": "6.1.0-edge.3",
107
- "@memberjunction/ai-engine-base": "6.1.0-edge.3",
108
- "@memberjunction/api-keys-base": "6.1.0-edge.3",
109
- "@memberjunction/core": "6.1.0-edge.3",
110
- "@memberjunction/core-entities": "6.1.0-edge.3",
111
- "@memberjunction/credentials": "6.1.0-edge.3",
112
- "@memberjunction/export-engine": "6.1.0-edge.3",
113
- "@memberjunction/global": "6.1.0-edge.3",
114
- "@memberjunction/graphql-dataprovider": "6.1.0-edge.3",
115
- "@memberjunction/integration-engine-base": "6.1.0-edge.3",
116
- "@memberjunction/interactive-component-types": "6.1.0-edge.3",
117
- "@memberjunction/lists-base": "6.1.0-edge.3",
118
- "@memberjunction/ng-action-gallery": "6.1.0-edge.3",
119
- "@memberjunction/ng-actions": "6.1.0-edge.3",
120
- "@memberjunction/ng-agent-requests": "6.1.0-edge.3",
121
- "@memberjunction/ng-agents": "6.1.0-edge.3",
122
- "@memberjunction/ng-ai-test-harness": "6.1.0-edge.3",
123
- "@memberjunction/ng-archive-manager": "6.1.0-edge.3",
124
- "@memberjunction/ng-base-application": "6.1.0-edge.3",
125
- "@memberjunction/ng-base-forms": "6.1.0-edge.3",
126
- "@memberjunction/ng-base-types": "6.1.0-edge.3",
127
- "@memberjunction/ng-clustering": "6.1.0-edge.3",
128
- "@memberjunction/ng-code-editor": "6.1.0-edge.3",
129
- "@memberjunction/ng-composer": "6.1.0-edge.3",
130
- "@memberjunction/ng-container-directives": "6.1.0-edge.3",
131
- "@memberjunction/ng-conversations": "6.1.0-edge.3",
132
- "@memberjunction/ng-core-entity-forms": "6.1.0-edge.3",
133
- "@memberjunction/ng-credentials": "6.1.0-edge.3",
134
- "@memberjunction/ng-dashboard-viewer": "6.1.0-edge.3",
135
- "@memberjunction/ng-entity-relationship-diagram": "6.1.0-edge.3",
136
- "@memberjunction/ng-entity-viewer": "6.1.0-edge.3",
137
- "@memberjunction/ng-explorer-settings": "6.1.0-edge.3",
138
- "@memberjunction/ng-export-service": "6.1.0-edge.3",
139
- "@memberjunction/ng-filter-builder": "6.1.0-edge.3",
140
- "@memberjunction/ng-list-management": "6.1.0-edge.3",
141
- "@memberjunction/ng-map-view": "6.1.0-edge.3",
142
- "@memberjunction/ng-markdown": "6.1.0-edge.3",
143
- "@memberjunction/ng-media-player": "6.1.0-edge.3",
144
- "@memberjunction/ng-notifications": "6.1.0-edge.3",
145
- "@memberjunction/ng-query-viewer": "6.1.0-edge.3",
146
- "@memberjunction/ng-react": "6.1.0-edge.3",
147
- "@memberjunction/ng-record-process-studio": "6.1.0-edge.3",
148
- "@memberjunction/ng-resource-permissions": "6.1.0-edge.3",
149
- "@memberjunction/ng-scheduling": "6.1.0-edge.3",
150
- "@memberjunction/ng-search": "6.1.0-edge.3",
151
- "@memberjunction/ng-shared": "6.1.0-edge.3",
152
- "@memberjunction/ng-shared-generic": "6.1.0-edge.3",
153
- "@memberjunction/ng-task-graph-editor": "6.1.0-edge.3",
154
- "@memberjunction/ng-tabstrip": "6.1.0-edge.3",
155
- "@memberjunction/ng-testing": "6.1.0-edge.3",
156
- "@memberjunction/ng-trees": "6.1.0-edge.3",
157
- "@memberjunction/ng-ui-components": "6.1.0-edge.3",
158
- "@memberjunction/ng-user-routines": "6.1.0-edge.3",
159
- "@memberjunction/ng-versions": "6.1.0-edge.3",
160
- "@memberjunction/ng-word-cloud": "6.1.0-edge.3",
161
- "@memberjunction/predictive-studio-core": "6.1.0-edge.3",
162
- "@memberjunction/tag-engine-base": "6.1.0-edge.3",
163
- "@memberjunction/templates-base-types": "6.1.0-edge.3",
164
- "@memberjunction/testing-engine-base": "6.1.0-edge.3",
165
- "@memberjunction/theme-engine": "6.1.0-edge.3",
105
+ "@memberjunction/actions-base": "6.1.0-edge.4",
106
+ "@memberjunction/ai-core-plus": "6.1.0-edge.4",
107
+ "@memberjunction/ai-engine-base": "6.1.0-edge.4",
108
+ "@memberjunction/api-keys-base": "6.1.0-edge.4",
109
+ "@memberjunction/core": "6.1.0-edge.4",
110
+ "@memberjunction/core-entities": "6.1.0-edge.4",
111
+ "@memberjunction/credentials": "6.1.0-edge.4",
112
+ "@memberjunction/export-engine": "6.1.0-edge.4",
113
+ "@memberjunction/global": "6.1.0-edge.4",
114
+ "@memberjunction/graphql-dataprovider": "6.1.0-edge.4",
115
+ "@memberjunction/integration-engine-base": "6.1.0-edge.4",
116
+ "@memberjunction/interactive-component-types": "6.1.0-edge.4",
117
+ "@memberjunction/lists-base": "6.1.0-edge.4",
118
+ "@memberjunction/ng-action-gallery": "6.1.0-edge.4",
119
+ "@memberjunction/ng-actions": "6.1.0-edge.4",
120
+ "@memberjunction/ng-agent-requests": "6.1.0-edge.4",
121
+ "@memberjunction/ng-agents": "6.1.0-edge.4",
122
+ "@memberjunction/ng-ai-test-harness": "6.1.0-edge.4",
123
+ "@memberjunction/ng-archive-manager": "6.1.0-edge.4",
124
+ "@memberjunction/ng-base-application": "6.1.0-edge.4",
125
+ "@memberjunction/ng-base-forms": "6.1.0-edge.4",
126
+ "@memberjunction/ng-base-types": "6.1.0-edge.4",
127
+ "@memberjunction/ng-clustering": "6.1.0-edge.4",
128
+ "@memberjunction/ng-code-editor": "6.1.0-edge.4",
129
+ "@memberjunction/ng-composer": "6.1.0-edge.4",
130
+ "@memberjunction/ng-container-directives": "6.1.0-edge.4",
131
+ "@memberjunction/ng-conversations": "6.1.0-edge.4",
132
+ "@memberjunction/ng-core-entity-forms": "6.1.0-edge.4",
133
+ "@memberjunction/ng-credentials": "6.1.0-edge.4",
134
+ "@memberjunction/ng-dashboard-viewer": "6.1.0-edge.4",
135
+ "@memberjunction/ng-entity-relationship-diagram": "6.1.0-edge.4",
136
+ "@memberjunction/ng-entity-viewer": "6.1.0-edge.4",
137
+ "@memberjunction/ng-explorer-settings": "6.1.0-edge.4",
138
+ "@memberjunction/ng-export-service": "6.1.0-edge.4",
139
+ "@memberjunction/ng-filter-builder": "6.1.0-edge.4",
140
+ "@memberjunction/ng-list-management": "6.1.0-edge.4",
141
+ "@memberjunction/ng-map-view": "6.1.0-edge.4",
142
+ "@memberjunction/ng-markdown": "6.1.0-edge.4",
143
+ "@memberjunction/ng-media-player": "6.1.0-edge.4",
144
+ "@memberjunction/ng-notifications": "6.1.0-edge.4",
145
+ "@memberjunction/ng-query-viewer": "6.1.0-edge.4",
146
+ "@memberjunction/ng-react": "6.1.0-edge.4",
147
+ "@memberjunction/ng-record-process-studio": "6.1.0-edge.4",
148
+ "@memberjunction/ng-resource-permissions": "6.1.0-edge.4",
149
+ "@memberjunction/ng-scheduling": "6.1.0-edge.4",
150
+ "@memberjunction/ng-search": "6.1.0-edge.4",
151
+ "@memberjunction/ng-shared": "6.1.0-edge.4",
152
+ "@memberjunction/ng-shared-generic": "6.1.0-edge.4",
153
+ "@memberjunction/ng-task-graph-editor": "6.1.0-edge.4",
154
+ "@memberjunction/ng-tabstrip": "6.1.0-edge.4",
155
+ "@memberjunction/ng-testing": "6.1.0-edge.4",
156
+ "@memberjunction/ng-trees": "6.1.0-edge.4",
157
+ "@memberjunction/ng-ui-components": "6.1.0-edge.4",
158
+ "@memberjunction/ng-user-routines": "6.1.0-edge.4",
159
+ "@memberjunction/ng-versions": "6.1.0-edge.4",
160
+ "@memberjunction/ng-word-cloud": "6.1.0-edge.4",
161
+ "@memberjunction/predictive-studio-core": "6.1.0-edge.4",
162
+ "@memberjunction/tag-engine-base": "6.1.0-edge.4",
163
+ "@memberjunction/templates-base-types": "6.1.0-edge.4",
164
+ "@memberjunction/testing-engine-base": "6.1.0-edge.4",
165
+ "@memberjunction/theme-engine": "6.1.0-edge.4",
166
166
  "ag-grid-angular": "^35.0.1",
167
167
  "ag-grid-community": "^35.0.1",
168
168
  "angular-split": "^20.0.0",