@memberjunction/react-runtime 5.9.0 → 5.10.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.
@@ -1,32 +1,32 @@
1
1
 
2
- > @memberjunction/react-runtime@5.9.0 build
2
+ > @memberjunction/react-runtime@5.10.0 build
3
3
  > npm run build:node && npm run build:umd
4
4
 
5
5
 
6
- > @memberjunction/react-runtime@5.9.0 build:node
6
+ > @memberjunction/react-runtime@5.10.0 build:node
7
7
  > tsc
8
8
 
9
9
 
10
- > @memberjunction/react-runtime@5.9.0 build:umd
10
+ > @memberjunction/react-runtime@5.10.0 build:umd
11
11
  > webpack --config webpack.umd.config.cjs
12
12
 
13
13
  [BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/MJ/MJ/packages/MJCoreEntities/dist/generated/entity_subclasses.js as it exceeds the max of 500KB.
14
- asset runtime.umd.js 2.37 MiB [emitted] [minimized] [big] (name: main) 1 related asset
15
- asset 324.runtime.umd.js 125 KiB [emitted] [minimized]
14
+ asset runtime.umd.js 2.38 MiB [emitted] [minimized] [big] (name: main) 1 related asset
15
+ asset 324.runtime.umd.js 126 KiB [emitted] [minimized]
16
16
  asset 490.runtime.umd.js 61.7 KiB [emitted] [minimized] (id hint: vendors)
17
- orphan modules 5.78 MiB [orphan] 491 modules
17
+ orphan modules 5.81 MiB [orphan] 491 modules
18
18
  runtime modules 6.94 KiB 10 modules
19
- built modules 5.9 MiB [built]
19
+ built modules 5.93 MiB [built]
20
20
  modules by path ../../../node_modules/ 780 KiB 23 modules
21
21
  modules by path ../../MJGlobal/dist/ 196 KiB
22
22
  ../../MJGlobal/dist/index.js + 17 modules 196 KiB [built] [code generated]
23
23
  ../../MJGlobal/dist/ lazy strict namespace object 160 bytes [built] [code generated]
24
- modules by path ../../MJCoreEntities/dist/ 3.26 MiB
25
- ../../MJCoreEntities/dist/index.js + 23 modules 3.24 MiB [built] [code generated]
26
- ../../MJCoreEntities/dist/engines/UserViewEngine.js 18.9 KiB [built] [code generated]
24
+ modules by path ../../MJCoreEntities/dist/ 3.27 MiB
25
+ ../../MJCoreEntities/dist/index.js + 23 modules 3.25 MiB [built] [code generated]
26
+ ../../MJCoreEntities/dist/engines/UserViewEngine.js 19.6 KiB [built] [code generated]
27
27
  ./dist/index.js + 27 modules 423 KiB [built] [code generated]
28
- ../../MJCore/dist/index.js + 74 modules 1.15 MiB [built] [code generated]
29
- ../../GraphQLDataProvider/dist/index.mjs 125 KiB [built] [code generated]
28
+ ../../MJCore/dist/index.js + 74 modules 1.18 MiB [built] [code generated]
29
+ ../../GraphQLDataProvider/dist/index.mjs 126 KiB [built] [code generated]
30
30
 
31
31
  WARNING in ../../MJGlobal/dist/DynamicPackageLoader.js 83:21-44
32
32
  Critical dependency: the request of a dependency is an expression
@@ -38,4 +38,4 @@ built modules 5.9 MiB [built]
38
38
  1 warning has detailed information that is not shown.
39
39
  Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
40
40
 
41
- webpack 5.105.0 compiled with 1 warning in 140103 ms
41
+ webpack 5.105.0 compiled with 1 warning in 146824 ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 5.10.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f2df653]
8
+ - Updated dependencies [4e298b7]
9
+ - Updated dependencies [98e9f15]
10
+ - Updated dependencies [5ce18ff]
11
+ - Updated dependencies [75dd36b]
12
+ - @memberjunction/core@5.10.0
13
+ - @memberjunction/core-entities@5.10.0
14
+ - @memberjunction/graphql-dataprovider@5.10.0
15
+ - @memberjunction/interactive-component-types@5.10.0
16
+ - @memberjunction/global@5.10.0
17
+
3
18
  ## 5.9.0
4
19
 
5
20
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- "use strict";(this.webpackChunkMJReactRuntime=this.webpackChunkMJReactRuntime||[]).push([[324],{324(e,t,r){r.r(t),r.d(t,{ActionItemInput:()=>F,ActionItemOutput:()=>L,BrowserIndexedDBStorageProvider:()=>v,BrowserStorageProviderBase:()=>D,FieldMapper:()=>g,FireAndForgetHelper:()=>I,GetDataOutput:()=>G,GraphQLAIClient:()=>S,GraphQLActionClient:()=>O,GraphQLComponentRegistryClient:()=>k,GraphQLDataProvider:()=>P,GraphQLEncryptionClient:()=>K,GraphQLFileStorageClient:()=>B,GraphQLIntegrationClient:()=>q,GraphQLProviderConfigData:()=>f,GraphQLSystemUserClient:()=>T,GraphQLTestingClient:()=>j,GraphQLTransactionGroup:()=>h,GraphQLVersionHistoryClient:()=>J,RoleInput:()=>A,RolesAndUsersInput:()=>b,SimpleRemoteEntity:()=>U,SimpleRemoteEntityField:()=>_,SimpleRemoteEntityOutput:()=>V,SyncDataAction:()=>M,SyncDataResult:()=>Q,SyncRolesAndUsersResult:()=>$,UserInput:()=>N,gql:()=>s.J1,setupGraphQLClient:()=>C});var s=r(215),a=r(654),n=r(865),o=r(429),i=r(600),u=r(49),c=r(226),l=r(497),d=r(718),m=r(196),p=Object.defineProperty,y=(e,t)=>p(e,"name",{value:t,configurable:!0});class g{static{y(this,"FieldMapper")}static{this.DB_PREFIX="__mj_"}static{this.GQL_PREFIX="_mj__"}constructor(){}MapFields(e){if(e)for(const t in e){const r=this.MapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}MapFieldName(e){return e.startsWith(g.DB_PREFIX)?g.GQL_PREFIX+e.substring(g.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(g.GQL_PREFIX)?g.DB_PREFIX+e.substring(g.GQL_PREFIX.length):e}ReverseMapFields(e){for(const t in e){const r=this.ReverseMapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}}class h extends a.VH{static{y(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=s.J1`
1
+ "use strict";(this.webpackChunkMJReactRuntime=this.webpackChunkMJReactRuntime||[]).push([[324],{324(e,t,r){r.r(t),r.d(t,{ActionItemInput:()=>F,ActionItemOutput:()=>L,BrowserIndexedDBStorageProvider:()=>v,BrowserStorageProviderBase:()=>D,FieldMapper:()=>g,FireAndForgetHelper:()=>I,GetDataOutput:()=>G,GraphQLAIClient:()=>S,GraphQLActionClient:()=>O,GraphQLComponentRegistryClient:()=>k,GraphQLDataProvider:()=>P,GraphQLEncryptionClient:()=>j,GraphQLFileStorageClient:()=>B,GraphQLIntegrationClient:()=>q,GraphQLProviderConfigData:()=>f,GraphQLSystemUserClient:()=>T,GraphQLTestingClient:()=>K,GraphQLTransactionGroup:()=>h,GraphQLVersionHistoryClient:()=>J,RoleInput:()=>A,RolesAndUsersInput:()=>b,SimpleRemoteEntity:()=>U,SimpleRemoteEntityField:()=>_,SimpleRemoteEntityOutput:()=>V,SyncDataAction:()=>M,SyncDataResult:()=>Q,SyncRolesAndUsersResult:()=>$,UserInput:()=>N,gql:()=>s.J1,setupGraphQLClient:()=>C});var s=r(215),a=r(654),n=r(865),o=r(429),i=r(600),u=r(49),c=r(226),l=r(497),d=r(718),m=r(196),y=Object.defineProperty,p=(e,t)=>y(e,"name",{value:t,configurable:!0});class g{static{p(this,"FieldMapper")}static{this.DB_PREFIX="__mj_"}static{this.GQL_PREFIX="_mj__"}constructor(){}MapFields(e){if(e)for(const t in e){const r=this.MapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}MapFieldName(e){return e.startsWith(g.DB_PREFIX)?g.GQL_PREFIX+e.substring(g.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(g.GQL_PREFIX)?g.DB_PREFIX+e.substring(g.GQL_PREFIX.length):e}ReverseMapFields(e){for(const t in e){const r=this.ReverseMapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}}class h extends a.VH{static{p(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=s.J1`
2
2
  mutation ExecuteTransactionGroup($group: TransactionInputType!) {
3
3
  ExecuteTransactionGroup(group: $group) {
4
4
  Success
@@ -6,7 +6,7 @@
6
6
  ResultsJSON
7
7
  }
8
8
  }
9
- `,t=[];for(const e of this.PendingTransactions)t.push({EntityName:e.BaseEntity.EntityInfo.Name,EntityObjectJSON:await e.BaseEntity.GetDataObjectJSON(),OperationType:e.OperationType});const r={group:{Items:t,Variables:this.Variables.map(e=>({Name:e.Name,ItemIndex:this.MapVariableEntityObjectToPosition(e),FieldName:e.FieldName,Type:e.Type}))}},o=await this._provider.ExecuteGQL(e,r);if(o&&o.ExecuteTransactionGroup){const e=o.ExecuteTransactionGroup,t=[];for(let r=0;r<this.PendingTransactions.length;r++){const s=e.ResultsJSON[r],o=(0,n.NG)(s),i=this.PendingTransactions[r];t.push(new a.qT(i,o,null!==o))}return t}throw new Error("Failed to execute transaction group")}}class I{static{y(this,"FireAndForgetHelper")}static async Execute(e){const t=e.operationLabel??e.mutationFieldName;let r,s;try{const{promise:n,resolve:o,reject:i}=I.createCompletionPromise();s=I.setupTimeout(i,e.timeoutMs,e.timeoutErrorMessage),r=I.subscribeToPubSub(e,o,s);const u=await I.executeMutation(e);if(!e.validateAck(u)){s&&clearTimeout(s);const r=u?.errorMessage??"Server rejected the request";return(0,a.ZI)(`[FireAndForget:${t}] Server rejected: ${r}`),e.createErrorResult(r)}return(0,a.b0)(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await n}catch(e){throw s&&clearTimeout(s),(0,a.ZI)(`[FireAndForget:${t}] Error: ${e.message}`),e}finally{s&&clearTimeout(s),r&&r.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}static setupTimeout(e,t,r){const s=r??"The operation may still be running on the server but the client timed out after 15 minutes. Please refresh the page to check the latest status.";return setTimeout(()=>{e(new Error(s))},t??9e5)}static subscribeToPubSub(e,t,r){const s=e.dataProvider.sessionId,n=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(s).subscribe(s=>{try{const o=JSON.parse(s);e.onMessage&&e.onMessage(o),e.isCompletionEvent(o)&&(clearTimeout(r),(0,a.b0)(`[FireAndForget:${n}] Completion event received`),t(e.extractResult(o)))}catch(e){console.error(`[FireAndForget:${n}] Failed to parse PubSub message:`,e)}})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}}class S{static{y(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=s.J1`
9
+ `,t=[];for(const e of this.PendingTransactions)t.push({EntityName:e.BaseEntity.EntityInfo.Name,EntityObjectJSON:await e.BaseEntity.GetDataObjectJSON(),OperationType:e.OperationType});const r={group:{Items:t,Variables:this.Variables.map(e=>({Name:e.Name,ItemIndex:this.MapVariableEntityObjectToPosition(e),FieldName:e.FieldName,Type:e.Type}))}},o=await this._provider.ExecuteGQL(e,r);if(o&&o.ExecuteTransactionGroup){const e=o.ExecuteTransactionGroup,t=[];for(let r=0;r<this.PendingTransactions.length;r++){const s=e.ResultsJSON[r],o=(0,n.NG)(s),i=this.PendingTransactions[r];t.push(new a.qT(i,o,null!==o))}return t}throw new Error("Failed to execute transaction group")}}class I{static{p(this,"FireAndForgetHelper")}static async Execute(e){const t=e.operationLabel??e.mutationFieldName;let r,s;try{const{promise:n,resolve:o,reject:i}=I.createCompletionPromise();s=I.setupTimeout(i,e.timeoutMs,e.timeoutErrorMessage),r=I.subscribeToPubSub(e,o,s);const u=await I.executeMutation(e);if(!e.validateAck(u)){s&&clearTimeout(s);const r=u?.errorMessage??"Server rejected the request";return(0,a.ZI)(`[FireAndForget:${t}] Server rejected: ${r}`),e.createErrorResult(r)}return(0,a.b0)(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await n}catch(e){throw s&&clearTimeout(s),(0,a.ZI)(`[FireAndForget:${t}] Error: ${e.message}`),e}finally{s&&clearTimeout(s),r&&r.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}static setupTimeout(e,t,r){const s=r??"The operation may still be running on the server but the client timed out after 15 minutes. Please refresh the page to check the latest status.";return setTimeout(()=>{e(new Error(s))},t??9e5)}static subscribeToPubSub(e,t,r){const s=e.dataProvider.sessionId,n=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(s).subscribe(s=>{try{const o=JSON.parse(s);e.onMessage&&e.onMessage(o),e.isCompletionEvent(o)&&(clearTimeout(r),(0,a.b0)(`[FireAndForget:${n}] Completion event received`),t(e.extractResult(o)))}catch(e){console.error(`[FireAndForget:${n}] Failed to parse PubSub message:`,e)}})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}}class S{static{p(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=s.J1`
10
10
  mutation RunAIPrompt(
11
11
  $promptId: String!,
12
12
  $data: String,
@@ -65,7 +65,7 @@
65
65
  chatResult
66
66
  }
67
67
  }
68
- `,r=this.preparePromptVariables(e),a=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(a)}catch(e){return this.handlePromptError(e)}}preparePromptVariables(e){const t={promptId:e.promptId};return void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.templateData&&(t.templateData="object"==typeof e.templateData?JSON.stringify(e.templateData):e.templateData),void 0!==e.messages&&(t.messages=JSON.stringify(e.messages)),void 0!==e.overrideModelId&&(t.overrideModelId=e.overrideModelId),void 0!==e.overrideVendorId&&(t.overrideVendorId=e.overrideVendorId),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.skipValidation&&(t.skipValidation=e.skipValidation),void 0!==e.responseFormat&&(t.responseFormat=e.responseFormat),void 0!==e.temperature&&(t.temperature=e.temperature),void 0!==e.topP&&(t.topP=e.topP),void 0!==e.topK&&(t.topK=e.topK),void 0!==e.minP&&(t.minP=e.minP),void 0!==e.frequencyPenalty&&(t.frequencyPenalty=e.frequencyPenalty),void 0!==e.presencePenalty&&(t.presencePenalty=e.presencePenalty),void 0!==e.seed&&(t.seed=e.seed),void 0!==e.stopSequences&&(t.stopSequences=e.stopSequences),void 0!==e.includeLogProbs&&(t.includeLogProbs=e.includeLogProbs),void 0!==e.topLogProbs&&(t.topLogProbs=e.topLogProbs),void 0!==e.rerunFromPromptRunID&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),void 0!==e.systemPromptOverride&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,a;try{t.parsedResult&&(r=JSON.parse(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(a=JSON.parse(t.chatResult))}catch{a=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:a}}handlePromptError(e){const t=e;return(0,a.ZI)(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){try{const s=this.buildRunAIAgentMutation(),a=this.prepareAgentVariables(e,t,r);return a.fireAndForget=!0,await I.Execute({dataProvider:this._dataProvider,mutation:s,variables:a,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:y(e=>!0===e?.success,"validateAck"),isCompletionEvent:y(e=>this.isAgentCompletionEvent(e),"isCompletionEvent"),extractResult:y(e=>this.extractAgentResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardAgentProgress(t,e.onProgress):void 0,createErrorResult:y(e=>this.createAgentErrorResult(e),"createErrorResult")})}catch(e){return this.handleAgentError(e)}}buildRunAIAgentMutation(){return s.J1`
68
+ `,r=this.preparePromptVariables(e),a=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(a)}catch(e){return this.handlePromptError(e)}}preparePromptVariables(e){const t={promptId:e.promptId};return void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.templateData&&(t.templateData="object"==typeof e.templateData?JSON.stringify(e.templateData):e.templateData),void 0!==e.messages&&(t.messages=JSON.stringify(e.messages)),void 0!==e.overrideModelId&&(t.overrideModelId=e.overrideModelId),void 0!==e.overrideVendorId&&(t.overrideVendorId=e.overrideVendorId),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.skipValidation&&(t.skipValidation=e.skipValidation),void 0!==e.responseFormat&&(t.responseFormat=e.responseFormat),void 0!==e.temperature&&(t.temperature=e.temperature),void 0!==e.topP&&(t.topP=e.topP),void 0!==e.topK&&(t.topK=e.topK),void 0!==e.minP&&(t.minP=e.minP),void 0!==e.frequencyPenalty&&(t.frequencyPenalty=e.frequencyPenalty),void 0!==e.presencePenalty&&(t.presencePenalty=e.presencePenalty),void 0!==e.seed&&(t.seed=e.seed),void 0!==e.stopSequences&&(t.stopSequences=e.stopSequences),void 0!==e.includeLogProbs&&(t.includeLogProbs=e.includeLogProbs),void 0!==e.topLogProbs&&(t.topLogProbs=e.topLogProbs),void 0!==e.rerunFromPromptRunID&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),void 0!==e.systemPromptOverride&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,a;try{t.parsedResult&&(r=JSON.parse(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(a=JSON.parse(t.chatResult))}catch{a=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:a}}handlePromptError(e){const t=e;return(0,a.ZI)(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){try{const s=this.buildRunAIAgentMutation(),a=this.prepareAgentVariables(e,t,r);return a.fireAndForget=!0,await I.Execute({dataProvider:this._dataProvider,mutation:s,variables:a,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:p(e=>!0===e?.success,"validateAck"),isCompletionEvent:p(e=>this.isAgentCompletionEvent(e),"isCompletionEvent"),extractResult:p(e=>this.extractAgentResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardAgentProgress(t,e.onProgress):void 0,createErrorResult:p(e=>this.createAgentErrorResult(e),"createErrorResult")})}catch(e){return this.handleAgentError(e)}}buildRunAIAgentMutation(){return s.J1`
69
69
  mutation RunAIAgent(
70
70
  $agentId: String!,
71
71
  $messages: String!,
@@ -106,7 +106,7 @@
106
106
  result
107
107
  }
108
108
  }
109
- `}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return void 0!==e.data&&(s.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(s.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(s.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(s.configurationId=e.configurationId),void 0!==e.conversationDetailId&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),void 0!==t&&(s.sourceArtifactId=t),void 0!==r&&(s.sourceArtifactVersionId=r),s}processAgentResult(e){return(0,n.NG)(e)}handleAgentError(e){const t=e?.message||String(e);(0,a.ZI)(`Error running AI agent: ${t}`);const r=t.includes("Failed to fetch")||t.includes("NetworkError");let s;return t.includes("timed out")||t.includes("timeout"),s=r?"Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":t,{success:!1,agentRun:void 0,errorMessage:s}}async RunAIAgentFromConversationDetail(e){try{const t=this.buildConversationDetailMutation(),r=this.prepareConversationDetailVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:y(e=>!0===e?.success,"validateAck"),isCompletionEvent:y(t=>this.isConversationDetailCompletionEvent(t,e.conversationDetailId),"isCompletionEvent"),extractResult:y(e=>this.extractAgentResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardConversationDetailProgress(t,e.onProgress):void 0,createErrorResult:y(e=>this.createAgentErrorResult(e),"createErrorResult")})}catch(e){return this.handleAgentError(e)}}buildConversationDetailMutation(){return s.J1`
109
+ `}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return void 0!==e.data&&(s.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(s.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(s.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(s.configurationId=e.configurationId),void 0!==e.conversationDetailId&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),void 0!==t&&(s.sourceArtifactId=t),void 0!==r&&(s.sourceArtifactVersionId=r),s}processAgentResult(e){return(0,n.NG)(e)}handleAgentError(e){const t=e?.message||String(e);(0,a.ZI)(`Error running AI agent: ${t}`);const r=t.includes("Failed to fetch")||t.includes("NetworkError");let s;return t.includes("timed out")||t.includes("timeout"),s=r?"Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":t,{success:!1,agentRun:void 0,errorMessage:s}}async RunAIAgentFromConversationDetail(e){try{const t=this.buildConversationDetailMutation(),r=this.prepareConversationDetailVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:p(e=>!0===e?.success,"validateAck"),isCompletionEvent:p(t=>this.isConversationDetailCompletionEvent(t,e.conversationDetailId),"isCompletionEvent"),extractResult:p(e=>this.extractAgentResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardConversationDetailProgress(t,e.onProgress):void 0,createErrorResult:p(e=>this.createAgentErrorResult(e),"createErrorResult")})}catch(e){return this.handleAgentError(e)}}buildConversationDetailMutation(){return s.J1`
110
110
  mutation RunAIAgentFromConversationDetail(
111
111
  $conversationDetailId: String!,
112
112
  $agentId: String!,
@@ -183,9 +183,10 @@
183
183
  error
184
184
  }
185
185
  }
186
- `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,r);if(!a?.EmbedText)throw new Error("Invalid response from server");const n=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){const r=t;return(0,a.ZI)(`Error generating embeddings: ${r}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}}const R="default";class D{static{y(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||R;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){return this.getCategoryMap(t||R).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||R).set(e,t)}async Remove(e,t){this.getCategoryMap(t||R).delete(e)}async ClearCategory(e){const t=e||R;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||R);return t?Array.from(t.keys()):[]}}const E=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],w="Metadata_KVPairs";class v extends D{static{y(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=(0,m.P2)("MJ_Metadata",3,{upgrade(e){try{e.objectStoreNames.contains(w)&&e.deleteObjectStore(w);for(const t of E)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(e){(0,a.Q1)({error:e,message:e?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{(0,a.Q1)({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return E.includes(t)}getStoreName(e){const t=e||R;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||R;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,a=this.getStoreName(r),n=this.getStoreKey(e,r),o=s.transaction(a,"readwrite");await o.objectStore(a).put(t,n),await o.done}catch(s){(0,a.Q1)({error:s,message:s?.message}),await super.SetItem(e,t,r)}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(a)??null}catch(r){return(0,a.Q1)({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t),n=r.transaction(s,"readwrite");await n.objectStore(s).delete(a),await n.done}catch(r){(0,a.Q1)({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||R,s=this.getStoreName(e);if(this.isKnownCategory(r)){const e=t.transaction(s,"readwrite");await e.objectStore(s).clear(),await e.done}else{const e=`[${r}]:`,s=t.transaction("mj:default","readwrite"),a=s.objectStore("mj:default"),n=await a.getAllKeys();for(const t of n)"string"==typeof t&&t.startsWith(e)&&await a.delete(t);await s.done}}catch(t){(0,a.Q1)({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||R,s=this.getStoreName(e),a=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return a.map(e=>String(e));const n=`[${r}]:`;return a.map(e=>String(e)).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))}catch(t){return(0,a.Q1)({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}}class f extends a.dZ{static{y(this,"GraphQLProviderConfigData")}get Token(){return this.Data.Token}set Token(e){this.Data.Token=e}get MJAPIKey(){return this.Data.MJAPIKey}set MJAPIKey(e){this.Data.MJAPIKey=e}get UserAPIKey(){return this.Data.UserAPIKey}set UserAPIKey(e){this.Data.UserAPIKey=e}get URL(){return this.Data.URL}get WSURL(){return this.Data.WSURL}get RefreshTokenFunction(){return this.Data.RefreshFunction}constructor(e,t,r,s,a,n,o,i,u){super({Token:e,URL:t,WSURL:r,MJAPIKey:i,UserAPIKey:u,RefreshTokenFunction:s},a,n,o)}}class P extends a.Dn{static{y(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {\n ${this.userInfoString()}\n MJUserRoles_UserIDArray {\n ${this.userRoleInfoString()}\n }\n }\n `,this._currentUserQuery=s.J1`query CurrentUserAndRoles {
186
+ `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,r);if(!a?.EmbedText)throw new Error("Invalid response from server");const n=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){const r=t;return(0,a.ZI)(`Error generating embeddings: ${r}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}}const R="default";class D{static{p(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||R;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){return this.getCategoryMap(t||R).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||R).set(e,t)}async Remove(e,t){this.getCategoryMap(t||R).delete(e)}async ClearCategory(e){const t=e||R;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||R);return t?Array.from(t.keys()):[]}}const E=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],w="Metadata_KVPairs";class v extends D{static{p(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=(0,m.P2)("MJ_Metadata",3,{upgrade(e){try{e.objectStoreNames.contains(w)&&e.deleteObjectStore(w);for(const t of E)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(e){(0,a.Q1)({error:e,message:e?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{(0,a.Q1)({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return E.includes(t)}getStoreName(e){const t=e||R;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||R;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,a=this.getStoreName(r),n=this.getStoreKey(e,r),o=s.transaction(a,"readwrite");await o.objectStore(a).put(t,n),await o.done}catch(s){(0,a.Q1)({error:s,message:s?.message}),await super.SetItem(e,t,r)}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(a)??null}catch(r){return(0,a.Q1)({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t),n=r.transaction(s,"readwrite");await n.objectStore(s).delete(a),await n.done}catch(r){(0,a.Q1)({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||R,s=this.getStoreName(e);if(this.isKnownCategory(r)){const e=t.transaction(s,"readwrite");await e.objectStore(s).clear(),await e.done}else{const e=`[${r}]:`,s=t.transaction("mj:default","readwrite"),a=s.objectStore("mj:default"),n=await a.getAllKeys();for(const t of n)"string"==typeof t&&t.startsWith(e)&&await a.delete(t);await s.done}}catch(t){(0,a.Q1)({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||R,s=this.getStoreName(e),a=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return a.map(e=>String(e));const n=`[${r}]:`;return a.map(e=>String(e)).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))}catch(t){return(0,a.Q1)({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}}class f extends a.dZ{static{p(this,"GraphQLProviderConfigData")}get Token(){return this.Data.Token}set Token(e){this.Data.Token=e}get MJAPIKey(){return this.Data.MJAPIKey}set MJAPIKey(e){this.Data.MJAPIKey=e}get UserAPIKey(){return this.Data.UserAPIKey}set UserAPIKey(e){this.Data.UserAPIKey=e}get URL(){return this.Data.URL}get WSURL(){return this.Data.WSURL}get RefreshTokenFunction(){return this.Data.RefreshFunction}constructor(e,t,r,s,a,n,o,i,u){super({Token:e,URL:t,WSURL:r,MJAPIKey:i,UserAPIKey:u,RefreshTokenFunction:s},a,n,o)}}class P extends a.Dn{static{p(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._dynamicHeaders=new Map,this._innerCurrentUserQueryString=`CurrentUser {\n ${this.userInfoString()}\n MJUserRoles_UserIDArray {\n ${this.userRoleInfoString()}\n }\n }\n `,this._currentUserQuery=s.J1`query CurrentUserAndRoles {
187
187
  ${this._innerCurrentUserQueryString}
188
- }`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=18e5,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=3e5,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=6e5,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,this._cacheInvalidationSubscription=null,P._instance||(P._instance=this)}static get Instance(){return P._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new S(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return(0,d.A)()}get LocalStoragePrefix(){if(void 0===this._configData||void 0===this._configData.URL)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.GetItem(t)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const t=this.LocalStorageProvider;if(t){const r=this.LocalStoragePrefix+"sessionId";await t.SetItem(r,e)}}catch{}}async GetPreferredUUID(e){const t=await this.GetStoredSessionID();return e||!t?this.GenerateUUID():t}async Config(e,t,r,s){try{return this._configData=e,r?(this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey,e.UserAPIKey),await this.SaveStoredSessionID(this._sessionId)):(P.Instance._configData=e,void 0===P.Instance._sessionId&&(P.Instance._sessionId=await this.GetPreferredUUID(s)),P.Instance._client||(P.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,P.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await P.Instance.SaveStoredSessionID(P.Instance._sessionId),this._sessionId=P.Instance._sessionId,this._client=P.Instance._client),super.Config(e)}catch(e){throw(0,a.ZI)(e),e}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const t=this.ConvertBackToMJFields(e.CurrentUser),r=t.MJUserRoles_UserIDArray.map(e=>this.ConvertBackToMJFields(e));return t.MJUserRoles_UserIDArray=r,new a.oq(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=s.J1`
188
+ CurrentUserTenantContext
189
+ }`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=18e5,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=3e5,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=6e5,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,this._cacheInvalidationSubscription=null,P._instance||(P._instance=this)}static get Instance(){return P._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new S(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return(0,d.A)()}get LocalStoragePrefix(){if(void 0===this._configData||void 0===this._configData.URL)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.GetItem(t)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const t=this.LocalStorageProvider;if(t){const r=this.LocalStoragePrefix+"sessionId";await t.SetItem(r,e)}}catch{}}async GetPreferredUUID(e){const t=await this.GetStoredSessionID();return e||!t?this.GenerateUUID():t}async Config(e,t,r,s){try{return this._configData=e,r?(this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey,e.UserAPIKey),await this.SaveStoredSessionID(this._sessionId)):(P.Instance._configData=e,void 0===P.Instance._sessionId&&(P.Instance._sessionId=await this.GetPreferredUUID(s)),P.Instance._client||(P.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,P.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await P.Instance.SaveStoredSessionID(P.Instance._sessionId),this._sessionId=P.Instance._sessionId,this._client=P.Instance._client),super.Config(e)}catch(e){throw(0,a.ZI)(e),e}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}SetDynamicHeader(e,t){this._dynamicHeaders.set(e,t),this._client&&this._client.setHeader(e,t),P.Instance&&P.Instance!==this&&P.Instance._configData===this._configData&&(P.Instance._dynamicHeaders.set(e,t),P.Instance._client&&P.Instance._client.setHeader(e,t))}RemoveDynamicHeader(e){this._dynamicHeaders.delete(e),this._client&&this._client.setHeader(e,""),P.Instance&&P.Instance!==this&&P.Instance._configData===this._configData&&(P.Instance._dynamicHeaders.delete(e),P.Instance._client&&P.Instance._client.setHeader(e,""))}GetDynamicHeaders(){return this._dynamicHeaders}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const t=this.ConvertBackToMJFields(e.CurrentUser),r=t.MJUserRoles_UserIDArray.map(e=>this.ConvertBackToMJFields(e));t.MJUserRoles_UserIDArray=r;const s=new a.oq(this,{...t,UserRoles:r});return e.CurrentUserTenantContext&&"object"==typeof e.CurrentUserTenantContext&&(s.TenantContext=e.CurrentUserTenantContext),s}}async RunReport(e,t){const r=s.J1`
189
190
  query GetReportDataQuery ($ReportID: String!) {
190
191
  GetReportData(ReportID: $ReportID) {
191
192
  Success
@@ -234,7 +235,7 @@
234
235
  }
235
236
  }
236
237
  }
237
- `,a=(await this.ExecuteGQL(r,{input:t}))?.RunQueriesWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const n=a.results.map(e=>{if(("stale"===e.status||"no_validation"===e.status)&&e.Results){const t=JSON.parse(e.Results);return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,results:t,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}}return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}});return{success:a.success,results:n,errorMessage:a.errorMessage}}catch(e){return(0,a.ZI)(`Error in RunQueriesWithCacheCheck: ${e}`),{success:!1,results:[],errorMessage:e instanceof Error?e.message:String(e)}}}async InternalRunView(e,t){try{let r="",n="";if(!e)throw"No parameters passed to RunView";{const o={};let i,u;if(e.ViewEntity)u=e.ViewEntity,i=u.Entity;else{const{entityName:r,v:s}=await this.getEntityNameAndUserView(e,t);u=s,i=r}const c=this.Entities.find(e=>e.Name===i);if(!c)throw new Error(`Entity ${i} not found in metadata`);let l=!1;const d=(0,a.I)(c);e.ViewID?(r=`Run${d}ViewByID`,n="RunViewByIDInput",o.ViewID=e.ViewID):e.ViewName?(r=`Run${d}ViewByName`,n="RunViewByNameInput",o.ViewName=e.ViewName):(l=!0,r=`Run${d}DynamicView`,n="RunDynamicViewInput",o.EntityName=e.EntityName),o.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",o.OrderBy=e.OrderBy?e.OrderBy:"",o.UserSearchString=e.UserSearchString?e.UserSearchString:"",o.Fields=e.Fields,o.IgnoreMaxRows=!!e.IgnoreMaxRows&&e.IgnoreMaxRows,void 0!==e.MaxRows&&(o.MaxRows=e.MaxRows),void 0!==e.StartRow&&(o.StartRow=e.StartRow),o.ForceAuditLog=!!e.ForceAuditLog&&e.ForceAuditLog,o.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(o.AuditLogDescription=e.AuditLogDescription),l||(o.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",o.ExcludeDataFromAllPriorViewRuns=!!e.ExcludeDataFromAllPriorViewRuns&&e.ExcludeDataFromAllPriorViewRuns,o.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",o.SaveViewResults=!!e.SaveViewResults&&e.SaveViewResults),e.Aggregates&&e.Aggregates.length>0&&(o.Aggregates=e.Aggregates.map(e=>({expression:e.expression,alias:e.alias})));const m=this.getViewRunTimeFieldList(c,u,e,l),p=e.Aggregates&&e.Aggregates.length>0?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",y=s.J1`
238
+ `,a=(await this.ExecuteGQL(r,{input:t}))?.RunQueriesWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const n=a.results.map(e=>{if(("stale"===e.status||"no_validation"===e.status)&&e.Results){const t=JSON.parse(e.Results);return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,results:t,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}}return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}});return{success:a.success,results:n,errorMessage:a.errorMessage}}catch(e){return(0,a.ZI)(`Error in RunQueriesWithCacheCheck: ${e}`),{success:!1,results:[],errorMessage:e instanceof Error?e.message:String(e)}}}async InternalRunView(e,t){try{let r="",n="";if(!e)throw"No parameters passed to RunView";{const o={};let i,u;if(e.ViewEntity)u=e.ViewEntity,i=u.Entity;else{const{entityName:r,v:s}=await this.getEntityNameAndUserView(e,t);u=s,i=r}const c=this.Entities.find(e=>e.Name===i);if(!c)throw new Error(`Entity ${i} not found in metadata`);let l=!1;const d=(0,a.I)(c);e.ViewID?(r=`Run${d}ViewByID`,n="RunViewByIDInput",o.ViewID=e.ViewID):e.ViewName?(r=`Run${d}ViewByName`,n="RunViewByNameInput",o.ViewName=e.ViewName):(l=!0,r=`Run${d}DynamicView`,n="RunDynamicViewInput",o.EntityName=e.EntityName),o.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",o.OrderBy=e.OrderBy?e.OrderBy:"",o.UserSearchString=e.UserSearchString?e.UserSearchString:"",o.Fields=e.Fields,o.IgnoreMaxRows=!!e.IgnoreMaxRows&&e.IgnoreMaxRows,void 0!==e.MaxRows&&(o.MaxRows=e.MaxRows),void 0!==e.StartRow&&(o.StartRow=e.StartRow),o.ForceAuditLog=!!e.ForceAuditLog&&e.ForceAuditLog,o.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(o.AuditLogDescription=e.AuditLogDescription),l||(o.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",o.ExcludeDataFromAllPriorViewRuns=!!e.ExcludeDataFromAllPriorViewRuns&&e.ExcludeDataFromAllPriorViewRuns,o.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",o.SaveViewResults=!!e.SaveViewResults&&e.SaveViewResults),e.Aggregates&&e.Aggregates.length>0&&(o.Aggregates=e.Aggregates.map(e=>({expression:e.expression,alias:e.alias})));const m=this.getViewRunTimeFieldList(c,u,e,l),y=e.Aggregates&&e.Aggregates.length>0?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",p=s.J1`
238
239
  query RunViewQuery ($input: ${n}!) {
239
240
  ${r}(input: $input) {
240
241
  Results {
@@ -245,9 +246,9 @@
245
246
  TotalRowCount
246
247
  ExecutionTime
247
248
  Success
248
- ErrorMessage${p}
249
+ ErrorMessage${y}
249
250
  }
250
- }`;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:i,queryName:r,aggregateCount:o.Aggregates.length,aggregates:o.Aggregates});const g=await this.ExecuteGQL(y,{input:o});if(g&&g[r]){const e=g[r].AggregateResults;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:i,aggregateResultCount:e?.length||0,aggregateResults:e,aggregateExecutionTime:g[r].AggregateExecutionTime});const t=g[r].Results;if(t&&t.length>0){const e=c.Fields.filter(e=>e.CodeName!==e.Name&&void 0!==e.CodeName);t.forEach(t=>{this.ConvertBackToMJFields(t),e.forEach(e=>{t[e.Name]=t[e.CodeName]})})}return g[r]}}return null}catch(e){throw(0,a.ZI)(e),e}}async InternalRunViews(e,t){try{let r=[],n=[],o=[];for(const s of e){let e="",i="";const u={};let c=null,l=null;if(s.ViewEntity)l=s.ViewEntity,c=l.Get("Entity");else{const{entityName:e,v:r}=await this.getEntityNameAndUserView(s,t);l=r,c=e}const d=this.Entities.find(e=>e.Name===c);if(!d)throw new Error(`Entity ${c} not found in metadata`);n.push(d);let m=!1;const p=(0,a.I)(d);s.ViewID?(e=`Run${p}ViewByID`,i="RunViewByIDInput",u.ViewID=s.ViewID):s.ViewName?(e=`Run${p}ViewByName`,i="RunViewByNameInput",u.ViewName=s.ViewName):(m=!0,e=`Run${p}DynamicView`,i="RunDynamicViewInput",u.EntityName=s.EntityName),u.ExtraFilter=s.ExtraFilter||"",u.OrderBy=s.OrderBy||"",u.UserSearchString=s.UserSearchString||"",u.Fields=s.Fields,u.IgnoreMaxRows=s.IgnoreMaxRows||!1,void 0!==s.MaxRows&&(u.MaxRows=s.MaxRows),void 0!==s.StartRow&&(u.StartRow=s.StartRow),u.ForceAuditLog=s.ForceAuditLog||!1,u.ResultType=s.ResultType||"simple",s.AuditLogDescription&&s.AuditLogDescription.length>0&&(u.AuditLogDescription=s.AuditLogDescription),m||(u.ExcludeUserViewRunID=s.ExcludeUserViewRunID||"",u.ExcludeDataFromAllPriorViewRuns=s.ExcludeDataFromAllPriorViewRuns||!1,u.OverrideExcludeFilter=s.OverrideExcludeFilter||"",u.SaveViewResults=s.SaveViewResults||!1),s.Aggregates&&s.Aggregates.length>0&&(u.Aggregates=s.Aggregates.map(e=>({expression:e.expression,alias:e.alias}))),r.push(u),o.push(...this.getViewRunTimeFieldList(d,l,s,m))}const i=e.some(e=>e.Aggregates&&e.Aggregates.length>0)?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",u=s.J1`
251
+ }`;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:i,queryName:r,aggregateCount:o.Aggregates.length,aggregates:o.Aggregates});const g=await this.ExecuteGQL(p,{input:o});if(g&&g[r]){const e=g[r].AggregateResults;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:i,aggregateResultCount:e?.length||0,aggregateResults:e,aggregateExecutionTime:g[r].AggregateExecutionTime});const t=g[r].Results;if(t&&t.length>0){const e=c.Fields.filter(e=>e.CodeName!==e.Name&&void 0!==e.CodeName);t.forEach(t=>{this.ConvertBackToMJFields(t),e.forEach(e=>{t[e.Name]=t[e.CodeName]})})}return g[r]}}return null}catch(e){throw(0,a.ZI)(e),e}}async InternalRunViews(e,t){try{let r=[],n=[],o=[];for(const s of e){let e="",i="";const u={};let c=null,l=null;if(s.ViewEntity)l=s.ViewEntity,c=l.Get("Entity");else{const{entityName:e,v:r}=await this.getEntityNameAndUserView(s,t);l=r,c=e}const d=this.Entities.find(e=>e.Name===c);if(!d)throw new Error(`Entity ${c} not found in metadata`);n.push(d);let m=!1;const y=(0,a.I)(d);s.ViewID?(e=`Run${y}ViewByID`,i="RunViewByIDInput",u.ViewID=s.ViewID):s.ViewName?(e=`Run${y}ViewByName`,i="RunViewByNameInput",u.ViewName=s.ViewName):(m=!0,e=`Run${y}DynamicView`,i="RunDynamicViewInput",u.EntityName=s.EntityName),u.ExtraFilter=s.ExtraFilter||"",u.OrderBy=s.OrderBy||"",u.UserSearchString=s.UserSearchString||"",u.Fields=s.Fields,u.IgnoreMaxRows=s.IgnoreMaxRows||!1,void 0!==s.MaxRows&&(u.MaxRows=s.MaxRows),void 0!==s.StartRow&&(u.StartRow=s.StartRow),u.ForceAuditLog=s.ForceAuditLog||!1,u.ResultType=s.ResultType||"simple",s.AuditLogDescription&&s.AuditLogDescription.length>0&&(u.AuditLogDescription=s.AuditLogDescription),m||(u.ExcludeUserViewRunID=s.ExcludeUserViewRunID||"",u.ExcludeDataFromAllPriorViewRuns=s.ExcludeDataFromAllPriorViewRuns||!1,u.OverrideExcludeFilter=s.OverrideExcludeFilter||"",u.SaveViewResults=s.SaveViewResults||!1),s.Aggregates&&s.Aggregates.length>0&&(u.Aggregates=s.Aggregates.map(e=>({expression:e.expression,alias:e.alias}))),r.push(u),o.push(...this.getViewRunTimeFieldList(d,l,s,m))}const i=e.some(e=>e.Aggregates&&e.Aggregates.length>0)?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",u=s.J1`
251
252
  query RunViewsQuery ($input: [RunViewGenericInput!]!) {
252
253
  RunViews(input: $input) {
253
254
  Results {
@@ -422,14 +423,14 @@
422
423
  ErrorMessage
423
424
  Result
424
425
  }
425
- }`,r=await this.ExecuteGQL(t,{DataContextItemID:e});if(r&&r.GetDataContextItemData){if(r.GetDataContextItemData.Success)return JSON.parse(r.GetDataContextItemData.Result);throw new Error(r.GetDataContextItemData.ErrorMessage)}throw new Error("GraphQL query failed")}catch(e){throw(0,a.ZI)(e),e}}static async ExecuteGQL(e,t,r=!0){return P.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(console.error("[GraphQL] ExecuteGQL error caught:",{hasResponse:!!s?.response,hasErrors:!!s?.response?.errors,errorCount:s?.response?.errors?.length,firstError:s?.response?.errors?.[0],errorCode:s?.response?.errors?.[0]?.extensions?.code,errorMessage:s?.response?.errors?.[0]?.message,fullError:s}),s&&s.response&&s.response.errors?.length>0){if("JWT_EXPIRED"===s.response.errors[0]?.extensions?.code?.toUpperCase().trim()){if(r)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw(0,a.ZI)("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}throw s}throw(0,a.ZI)(s),s}}async RefreshToken(){const e=P.Instance&&P.Instance._configData===this._configData;if(e&&P.Instance._refreshPromise)return P.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(P.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&P.Instance&&(P.Instance._refreshPromise=null)}}async performTokenRefresh(){if(!this._configData.Data.RefreshTokenFunction)throw new Error("No refresh token function provided");{const e=await this._configData.Data.RefreshTokenFunction();if(!e)throw new Error("Refresh token function returned null or undefined token");{this._configData.Token=e;const t=this.CreateNewGraphQLClient(this._configData.URL,this._configData.Token,this._sessionId,this._configData.MJAPIKey,this._configData.UserAPIKey);this._client=t,P.Instance&&P.Instance._configData===this._configData&&(P.Instance._client=t)}}}static async RefreshToken(){return P.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,a,n){const o={"x-session-id":r};return t&&(o.authorization="Bearer "+t),a&&(o["x-mj-api-key"]=a),n&&(o["x-api-key"]=n),new s.l4(e,{headers:o})}userInfoString(){return this.infoString(new a.oq(null,null))}userRoleInfoString(){return this.infoString(new a.St(null))}infoString(e){let t="";const r=Object.keys(e);for(const e of r)e.startsWith("__mj_")?t+=e.replace("__mj_","_mj__")+"\n ":e.startsWith("_")||(t+=e+"\n ");return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new v:this._localStorageProvider=new a.KW),this._localStorageProvider}get Metadata(){return this}getOrCreateWSClient(){const e=Date.now();return this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&0===this._activeSubscriptionCount&&this.disposeWSClient(),this._wsClient||(this._wsClient=(0,l.UU)({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:y(()=>!0,"shouldRetry")}),this._wsClientCreatedAt=e,this._subscriptionCleanupTimer||(this._subscriptionCleanupTimer=setInterval(()=>{this.cleanupStaleSubscriptions()},this.SUBSCRIPTION_CLEANUP_INTERVAL_MS))),this._wsClient}disposeWSClient(){if(this._wsClient){try{this._wsClient.dispose()}catch(e){console.error("[GraphQLDataProvider] Error disposing WebSocket client:",e)}this._wsClient=null,this._wsClientCreatedAt=null}}completeAllSubjects(){this._pushStatusSubjects.forEach((e,t)=>{try{e.subject.complete(),e.subscription.unsubscribe()}catch(e){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,e)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=(this._pushStatusSubjects.size,Array.from(this._pushStatusSubjects.entries())),r=[];t.forEach(([t,s])=>{const a=e-s.lastRequestedAt,n=e-s.lastEmissionAt;0===s.activeSubscribers&&a>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&n>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${t} for cleanup: activeSubscribers=${s.activeSubscribers}, timeSinceRequested=${Math.round(a/1e3)}s, timeSinceEmission=${Math.round(n/1e3)}s`),r.push(t))}),r.forEach(e=>{const t=this._pushStatusSubjects.get(e);if(t)try{t.subject.complete(),t.subscription.unsubscribe(),this._pushStatusSubjects.delete(e),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${e}`)}catch(t){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${e}:`,t)}}),r.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${r.length} stale subscription(s)`),0===this._pushStatusSubjects.size&&this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&(console.log("[GraphQLDataProvider] Disposing of idle WebSocket client"),this.disposeWSClient())}finally{this._isCleaningUp=!1}}}subscribe(e,t){return new i.c(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const a=s.subscribe({query:e,variables:t},{next:y(e=>{r.next(e.data)},"next"),error:y(async e=>{const t=e;if("JWT_EXPIRED"===t?.extensions?.code||t?.message?.includes("token has expired")||t?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",e),r.error(e)}}else r.error(e)},"error"),complete:y(()=>{r.complete()},"complete")});return()=>{this._activeSubscriptionCount--,a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new i.c(t=>{r.activeSubscribers++;const s=r.subject.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}});const a=s.J1`subscription StatusUpdates($sessionId: String!) {
426
+ }`,r=await this.ExecuteGQL(t,{DataContextItemID:e});if(r&&r.GetDataContextItemData){if(r.GetDataContextItemData.Success)return JSON.parse(r.GetDataContextItemData.Result);throw new Error(r.GetDataContextItemData.ErrorMessage)}throw new Error("GraphQL query failed")}catch(e){throw(0,a.ZI)(e),e}}static async ExecuteGQL(e,t,r=!0){return P.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(console.error("[GraphQL] ExecuteGQL error caught:",{hasResponse:!!s?.response,hasErrors:!!s?.response?.errors,errorCount:s?.response?.errors?.length,firstError:s?.response?.errors?.[0],errorCode:s?.response?.errors?.[0]?.extensions?.code,errorMessage:s?.response?.errors?.[0]?.message,fullError:s}),s&&s.response&&s.response.errors?.length>0){if("JWT_EXPIRED"===s.response.errors[0]?.extensions?.code?.toUpperCase().trim()){if(r)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw(0,a.ZI)("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}throw s}throw(0,a.ZI)(s),s}}async RefreshToken(){const e=P.Instance&&P.Instance._configData===this._configData;if(e&&P.Instance._refreshPromise)return P.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(P.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&P.Instance&&(P.Instance._refreshPromise=null)}}async performTokenRefresh(){if(!this._configData.Data.RefreshTokenFunction)throw new Error("No refresh token function provided");{const e=await this._configData.Data.RefreshTokenFunction();if(!e)throw new Error("Refresh token function returned null or undefined token");{this._configData.Token=e;const t=this.CreateNewGraphQLClient(this._configData.URL,this._configData.Token,this._sessionId,this._configData.MJAPIKey,this._configData.UserAPIKey);this._client=t,P.Instance&&P.Instance._configData===this._configData&&(P.Instance._client=t)}}}static async RefreshToken(){return P.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,a,n){const o={"x-session-id":r};t&&(o.authorization="Bearer "+t),a&&(o["x-mj-api-key"]=a),n&&(o["x-api-key"]=n);const i=new s.l4(e,{headers:o});for(const[e,t]of this._dynamicHeaders)i.setHeader(e,t);return i}userInfoString(){return this.infoString(new a.oq(null,null))}userRoleInfoString(){return this.infoString(new a.St(null))}infoString(e){let t="";const r=Object.keys(e);for(const e of r)e.startsWith("__mj_")?t+=e.replace("__mj_","_mj__")+"\n ":e.startsWith("_")||(t+=e+"\n ");return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new v:this._localStorageProvider=new a.KW),this._localStorageProvider}get Metadata(){return this}getOrCreateWSClient(){const e=Date.now();return this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&0===this._activeSubscriptionCount&&this.disposeWSClient(),this._wsClient||(this._wsClient=(0,l.UU)({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:p(()=>!0,"shouldRetry")}),this._wsClientCreatedAt=e,this._subscriptionCleanupTimer||(this._subscriptionCleanupTimer=setInterval(()=>{this.cleanupStaleSubscriptions()},this.SUBSCRIPTION_CLEANUP_INTERVAL_MS))),this._wsClient}disposeWSClient(){if(this._wsClient){try{this._wsClient.dispose()}catch(e){console.error("[GraphQLDataProvider] Error disposing WebSocket client:",e)}this._wsClient=null,this._wsClientCreatedAt=null}}completeAllSubjects(){this._pushStatusSubjects.forEach((e,t)=>{try{e.subject.complete(),e.subscription.unsubscribe()}catch(e){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,e)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=(this._pushStatusSubjects.size,Array.from(this._pushStatusSubjects.entries())),r=[];t.forEach(([t,s])=>{const a=e-s.lastRequestedAt,n=e-s.lastEmissionAt;0===s.activeSubscribers&&a>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&n>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${t} for cleanup: activeSubscribers=${s.activeSubscribers}, timeSinceRequested=${Math.round(a/1e3)}s, timeSinceEmission=${Math.round(n/1e3)}s`),r.push(t))}),r.forEach(e=>{const t=this._pushStatusSubjects.get(e);if(t)try{t.subject.complete(),t.subscription.unsubscribe(),this._pushStatusSubjects.delete(e),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${e}`)}catch(t){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${e}:`,t)}}),r.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${r.length} stale subscription(s)`),0===this._pushStatusSubjects.size&&this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&(console.log("[GraphQLDataProvider] Disposing of idle WebSocket client"),this.disposeWSClient())}finally{this._isCleaningUp=!1}}}subscribe(e,t){return new i.c(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const a=s.subscribe({query:e,variables:t},{next:p(e=>{r.next(e.data)},"next"),error:p(async e=>{const t=e;if("JWT_EXPIRED"===t?.extensions?.code||t?.message?.includes("token has expired")||t?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",e),r.error(e)}}else r.error(e)},"error"),complete:p(()=>{r.complete()},"complete")});return()=>{this._activeSubscriptionCount--,a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new i.c(t=>{r.activeSubscribers++;const s=r.subject.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}});const a=s.J1`subscription StatusUpdates($sessionId: String!) {
426
427
  statusUpdates(sessionId: $sessionId) {
427
428
  date
428
429
  message
429
430
  sessionId
430
431
  }
431
432
  }
432
- `,n=new u.B,o=this.getOrCreateWSClient(),l=new c.yU;return l.add(new i.c(t=>{const r=o.subscribe({query:a,variables:{sessionId:e}},{next:y(r=>{const s=this._pushStatusSubjects.get(e);s&&(s.lastEmissionAt=Date.now()),t.next(r.data.statusUpdates.message)},"next"),error:y(async e=>{const r=e;if("JWT_EXPIRED"===r?.extensions?.code||r?.message?.includes("token has expired")||r?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),t.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",e),t.error(e)}}else t.error(e)},"error"),complete:y(()=>{t.complete()},"complete")});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,r()}}).subscribe({next:y(e=>n.next(e),"next"),error:y(t=>{n.error(t),this._pushStatusSubjects.delete(e)},"error"),complete:y(()=>{n.complete(),this._pushStatusSubjects.delete(e)},"complete")})),this._pushStatusSubjects.set(e,{subject:n,subscription:l,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new i.c(t=>{const r=this._pushStatusSubjects.get(e);r&&r.activeSubscribers++;const s=n.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.UnsubscribeFromCacheInvalidation(),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}SubscribeToCacheInvalidation(){if(this._cacheInvalidationSubscription||!this.ConfigData?.WSURL)return;const e=s.J1`subscription CacheInvalidation {
433
+ `,n=new u.B,o=this.getOrCreateWSClient(),l=new c.yU;return l.add(new i.c(t=>{const r=o.subscribe({query:a,variables:{sessionId:e}},{next:p(r=>{const s=this._pushStatusSubjects.get(e);s&&(s.lastEmissionAt=Date.now()),t.next(r.data.statusUpdates.message)},"next"),error:p(async e=>{const r=e;if("JWT_EXPIRED"===r?.extensions?.code||r?.message?.includes("token has expired")||r?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),t.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",e),t.error(e)}}else t.error(e)},"error"),complete:p(()=>{t.complete()},"complete")});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,r()}}).subscribe({next:p(e=>n.next(e),"next"),error:p(t=>{n.error(t),this._pushStatusSubjects.delete(e)},"error"),complete:p(()=>{n.complete(),this._pushStatusSubjects.delete(e)},"complete")})),this._pushStatusSubjects.set(e,{subject:n,subscription:l,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new i.c(t=>{const r=this._pushStatusSubjects.get(e);r&&r.activeSubscribers++;const s=n.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.UnsubscribeFromCacheInvalidation(),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}SubscribeToCacheInvalidation(){if(this._cacheInvalidationSubscription||!this.ConfigData?.WSURL)return;const e=s.J1`subscription CacheInvalidation {
433
434
  cacheInvalidation {
434
435
  EntityName
435
436
  PrimaryKeyValues
@@ -439,7 +440,7 @@
439
440
  OriginSessionID
440
441
  RecordData
441
442
  }
442
- }`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:y(e=>{const t=e?.cacheInvalidation;if(!t)return;if(t.OriginSessionID&&t.OriginSessionID===this.sessionId)return void console.log(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${t.EntityName}" (action: ${t.Action})`);console.log(`[GraphQLDataProvider] Cache invalidation received: ${t.Action} for "${t.EntityName}" from server ${t.SourceServerID?.substring(0,8)||"unknown"}`);const r={type:"remote-invalidate",entityName:t.EntityName,baseEntity:null,payload:{primaryKeyValues:t.PrimaryKeyValues,action:t.Action,sourceServerId:t.SourceServerID,timestamp:t.Timestamp,recordData:t.RecordData}};n.rt.Instance.RaiseEvent({event:n.UK.ComponentEvent,eventCode:a.HC.BaseEventCode,args:r,component:this})},"next"),error:y(e=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",e),this._cacheInvalidationSubscription=null},"error"),complete:y(()=>{console.log("[GraphQLDataProvider] Cache invalidation subscription completed, will re-establish on next WebSocket creation"),this._cacheInvalidationSubscription=null},"complete")})}UnsubscribeFromCacheInvalidation(){this._cacheInvalidationSubscription&&(this._cacheInvalidationSubscription.unsubscribe(),this._cacheInvalidationSubscription=null)}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;try{const r=await this.ExecuteGQL("query FindISAChildEntity($EntityName: String!, $RecordID: String!) {\n FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityName\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntity?.Success&&r.FindISAChildEntity.ChildEntityName?{ChildEntityName:r.FindISAChildEntity.ChildEntityName}:null}catch(t){return(0,a.ZI)(`FindISAChildEntity failed for ${e.Name}: ${t}`),null}}async FindISAChildEntities(e,t,r){if(!e.IsParentType)return[];try{const r=await this.ExecuteGQL("query FindISAChildEntities($EntityName: String!, $RecordID: String!) {\n FindISAChildEntities(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityNames\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntities?.Success&&r.FindISAChildEntities.ChildEntityNames?r.FindISAChildEntities.ChildEntityNames.map(e=>({ChildEntityName:e})):[]}catch(t){return(0,a.ZI)(`FindISAChildEntities failed for ${e.Name}: ${t}`),[]}}}async function C(e){const t=new P;return(0,a.YE)(t),await t.Config(e),await a.jF.Instance.Startup(),n.rt.Instance.RaiseEvent({event:n.UK.LoggedIn,eventCode:null,component:this,args:null}),t}y(C,"setupGraphQLClient");class ${static{y(this,"SyncRolesAndUsersResult")}}class A{static{y(this,"RoleInput")}}class N{static{y(this,"UserInput")}}class b{static{y(this,"RolesAndUsersInput")}}var x,M=((x=M||{}).Create="Create",x.Update="Update",x.CreateOrUpdate="CreateOrUpdate",x.Delete="Delete",x.DeleteWithFilter="DeleteWithFilter",x);class F{static{y(this,"ActionItemInput")}}class Q{static{y(this,"SyncDataResult")}constructor(){this.Results=[]}}class L{static{y(this,"ActionItemOutput")}}class T{static{y(this,"GraphQLSystemUserClient")}get Client(){return this._client}constructor(e,t,r,a){const n={"x-session-id":r};this._sessionId=r,t&&(n.authorization="Bearer "+t),a&&(n["x-mj-api-key"]=a),this._client=new s.l4(e,{headers:n})}resolvePlatformSQL(e){if(null!=e)return(0,a.WV)(e)?e.default:e}async GetData(e,t){try{const r=await this.Client.request("query GetData($input: GetDataInputType!) {\n GetData(input: $input) {\n Success\n ErrorMessages\n Queries\n Results\n }\n }",{input:{Queries:e,Token:t}});return r&&r.GetData?{Success:r.GetData.Success,Results:r.GetData.Results.map(e=>e?(0,n.NG)(e):null),ErrorMessages:r.GetData.ErrorMessages,Queries:r.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:r.GetData?.ErrorMessages??["Unknown error"],Queries:r.GetData?.Queries??e}}catch(t){let r=t instanceof Error?t.message:String(t);const s=r.match(/Error: ([^:]+)\./);if(s&&(r=s[1]+"."),(0,a.l9)()){const e=`GraphQLSystemUserClient::GetData - Error getting data - ${t}`;(0,a.ZI)(e)}return{Success:!1,Results:[],ErrorMessages:[r],Queries:e}}}async GetAllRemoteEntities(){try{const e=await this.Client.request("query GetAllEntities {\n GetAllEntities {\n Success\n ErrorMessage\n Results {\n ID\n Name\n Description\n SchemaName\n BaseView\n BaseTable\n CodeName\n ClassName\n Fields {\n ID\n Name\n Description\n Type\n AllowsNull\n MaxLength\n }\n }\n }\n }");return e&&e.GetAllEntities?e.GetAllEntities:{Success:!1,Results:[],ErrorMessage:e.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const t=await this.Client.request("mutation SyncData($items: [ActionItemInputType!]!) {\n SyncData(items: $items) {\n Success\n Results {\n Success\n ErrorMessage\n EntityName\n Type\n PrimaryKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n AlternateKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n DeleteFilter\n RecordJSON\n }\n }\n }",{items:e});return t&&t.SyncData?t.SyncData:{Success:!1,Results:[]}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncData - Error syncing data - ${e}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const t=await this.Client.request("mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {\n SyncRolesAndUsers(data: $data) {\n Success\n }\n }",{data:e});return t&&t.SyncRolesAndUsers?t.SyncRolesAndUsers:{Success:!1}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${e}`),{Success:!1}}}async RunViewByName(e){try{const t="query RunViewByNameSystemUser($input: RunViewByNameInput!) {\n RunViewByNameSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunViewByNameSystemUser?s.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViewByID(e){try{const t="query RunViewByIDSystemUser($input: RunViewByIDInput!) {\n RunViewByIDSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunViewByIDSystemUser?s.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunDynamicView(e){try{const t="query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {\n RunDynamicViewSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunDynamicViewSystemUser?s.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViews(e){try{const t="query RunViewsSystemUser($input: [RunViewGenericInput!]!) {\n RunViewsSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r=e.map(e=>({...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)})),s=await this.Client.request(t,{input:r});return s&&s.RunViewsSystemUser?s.RunViewsSystemUser:[]}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${e}`),[]}}async GetQueryData(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataSystemUser($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryID:e.QueryID};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results?(0,n.NG)(s.GetQueryDataSystemUser.Results):null}:{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataSystemUser - Error executing query - ${t}`),{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async GetQueryDataByName(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataByNameSystemUser($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryName:e.QueryName};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results?(0,n.NG)(s.GetQueryDataByNameSystemUser.Results):null}:{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataByNameSystemUser - Error executing query - ${t}`),{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async CreateQuery(e){try{const t=await this.Client.request("mutation CreateQuerySystemUser($input: CreateQuerySystemUserInput!) {\n CreateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.CreateQuerySystemUser?t.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async UpdateQuery(e){try{const t=await this.Client.request("mutation UpdateQuerySystemUser($input: UpdateQuerySystemUserInput!) {\n UpdateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.UpdateQuerySystemUser?t.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async DeleteQuery(e,t){try{if(!e||""===e.trim())return(0,a.ZI)("GraphQLSystemUserClient::DeleteQuery - Invalid query ID: ID cannot be null or empty"),{Success:!1,ErrorMessage:"Invalid query ID: ID cannot be null or empty"};const r="mutation DeleteQuerySystemResolver($ID: String!, $options: DeleteOptionsInput) {\n DeleteQuerySystemResolver(ID: $ID, options: $options) {\n Success\n ErrorMessage\n ID\n Name\n }\n }",s={ID:e};void 0!==t&&(s.options={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(e){let t="";if(e instanceof Error){if(t=e.message,"cause"in e&&e.cause){const r=e.cause;t+=` | Cause: ${r.message||r}`,"code"in r&&(t+=` | Code: ${r.code}`)}if("response"in e){const r=e.response;r?.status&&(t+=` | HTTP Status: ${r.status}`),r?.errors&&(t+=` | GraphQL Errors: ${JSON.stringify(r.errors)}`)}e.stack&&console.error("DeleteQuery stack trace:",e.stack)}else t=String(e);return(0,a.ZI)(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${t}`),{Success:!1,ErrorMessage:t}}}async RunAIPrompt(e){try{const t=s.J1`
443
+ }`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:p(e=>{const t=e?.cacheInvalidation;if(!t)return;if(t.OriginSessionID&&t.OriginSessionID===this.sessionId)return void console.debug(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${t.EntityName}" (action: ${t.Action})`);console.debug(`[GraphQLDataProvider] Cache invalidation received: ${t.Action} for "${t.EntityName}" from server ${t.SourceServerID?.substring(0,8)||"unknown"}`);const r={type:"remote-invalidate",entityName:t.EntityName,baseEntity:null,payload:{primaryKeyValues:t.PrimaryKeyValues,action:t.Action,sourceServerId:t.SourceServerID,timestamp:t.Timestamp,recordData:t.RecordData}};n.rt.Instance.RaiseEvent({event:n.UK.ComponentEvent,eventCode:a.HC.BaseEventCode,args:r,component:this})},"next"),error:p(e=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",e),this._cacheInvalidationSubscription=null},"error"),complete:p(()=>{console.log("[GraphQLDataProvider] Cache invalidation subscription completed, will re-establish on next WebSocket creation"),this._cacheInvalidationSubscription=null},"complete")})}UnsubscribeFromCacheInvalidation(){this._cacheInvalidationSubscription&&(this._cacheInvalidationSubscription.unsubscribe(),this._cacheInvalidationSubscription=null)}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;try{const r=await this.ExecuteGQL("query FindISAChildEntity($EntityName: String!, $RecordID: String!) {\n FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityName\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntity?.Success&&r.FindISAChildEntity.ChildEntityName?{ChildEntityName:r.FindISAChildEntity.ChildEntityName}:null}catch(t){return(0,a.ZI)(`FindISAChildEntity failed for ${e.Name}: ${t}`),null}}async FindISAChildEntities(e,t,r){if(!e.IsParentType)return[];try{const r=await this.ExecuteGQL("query FindISAChildEntities($EntityName: String!, $RecordID: String!) {\n FindISAChildEntities(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityNames\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntities?.Success&&r.FindISAChildEntities.ChildEntityNames?r.FindISAChildEntities.ChildEntityNames.map(e=>({ChildEntityName:e})):[]}catch(t){return(0,a.ZI)(`FindISAChildEntities failed for ${e.Name}: ${t}`),[]}}}async function C(e){const t=new P;return(0,a.YE)(t),await t.Config(e),await a.jF.Instance.Startup(),n.rt.Instance.RaiseEvent({event:n.UK.LoggedIn,eventCode:null,component:this,args:null}),t}p(C,"setupGraphQLClient");class ${static{p(this,"SyncRolesAndUsersResult")}}class A{static{p(this,"RoleInput")}}class N{static{p(this,"UserInput")}}class b{static{p(this,"RolesAndUsersInput")}}var x,M=((x=M||{}).Create="Create",x.Update="Update",x.CreateOrUpdate="CreateOrUpdate",x.Delete="Delete",x.DeleteWithFilter="DeleteWithFilter",x);class F{static{p(this,"ActionItemInput")}}class Q{static{p(this,"SyncDataResult")}constructor(){this.Results=[]}}class L{static{p(this,"ActionItemOutput")}}class T{static{p(this,"GraphQLSystemUserClient")}get Client(){return this._client}constructor(e,t,r,a){const n={"x-session-id":r};this._sessionId=r,t&&(n.authorization="Bearer "+t),a&&(n["x-mj-api-key"]=a),this._client=new s.l4(e,{headers:n})}resolvePlatformSQL(e){if(null!=e)return(0,a.WV)(e)?e.default:e}async GetData(e,t){try{const r=await this.Client.request("query GetData($input: GetDataInputType!) {\n GetData(input: $input) {\n Success\n ErrorMessages\n Queries\n Results\n }\n }",{input:{Queries:e,Token:t}});return r&&r.GetData?{Success:r.GetData.Success,Results:r.GetData.Results.map(e=>e?(0,n.NG)(e):null),ErrorMessages:r.GetData.ErrorMessages,Queries:r.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:r.GetData?.ErrorMessages??["Unknown error"],Queries:r.GetData?.Queries??e}}catch(t){let r=t instanceof Error?t.message:String(t);const s=r.match(/Error: ([^:]+)\./);if(s&&(r=s[1]+"."),(0,a.l9)()){const e=`GraphQLSystemUserClient::GetData - Error getting data - ${t}`;(0,a.ZI)(e)}return{Success:!1,Results:[],ErrorMessages:[r],Queries:e}}}async GetAllRemoteEntities(){try{const e=await this.Client.request("query GetAllEntities {\n GetAllEntities {\n Success\n ErrorMessage\n Results {\n ID\n Name\n Description\n SchemaName\n BaseView\n BaseTable\n CodeName\n ClassName\n Fields {\n ID\n Name\n Description\n Type\n AllowsNull\n MaxLength\n }\n }\n }\n }");return e&&e.GetAllEntities?e.GetAllEntities:{Success:!1,Results:[],ErrorMessage:e.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const t=await this.Client.request("mutation SyncData($items: [ActionItemInputType!]!) {\n SyncData(items: $items) {\n Success\n Results {\n Success\n ErrorMessage\n EntityName\n Type\n PrimaryKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n AlternateKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n DeleteFilter\n RecordJSON\n }\n }\n }",{items:e});return t&&t.SyncData?t.SyncData:{Success:!1,Results:[]}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncData - Error syncing data - ${e}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const t=await this.Client.request("mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {\n SyncRolesAndUsers(data: $data) {\n Success\n }\n }",{data:e});return t&&t.SyncRolesAndUsers?t.SyncRolesAndUsers:{Success:!1}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${e}`),{Success:!1}}}async RunViewByName(e){try{const t="query RunViewByNameSystemUser($input: RunViewByNameInput!) {\n RunViewByNameSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunViewByNameSystemUser?s.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViewByID(e){try{const t="query RunViewByIDSystemUser($input: RunViewByIDInput!) {\n RunViewByIDSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunViewByIDSystemUser?s.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunDynamicView(e){try{const t="query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {\n RunDynamicViewSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r={...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)},s=await this.Client.request(t,{input:r});return s&&s.RunDynamicViewSystemUser?s.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViews(e){try{const t="query RunViewsSystemUser($input: [RunViewGenericInput!]!) {\n RunViewsSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",r=e.map(e=>({...e,ExtraFilter:this.resolvePlatformSQL(e.ExtraFilter),OrderBy:this.resolvePlatformSQL(e.OrderBy)})),s=await this.Client.request(t,{input:r});return s&&s.RunViewsSystemUser?s.RunViewsSystemUser:[]}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${e}`),[]}}async GetQueryData(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataSystemUser($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryID:e.QueryID};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results?(0,n.NG)(s.GetQueryDataSystemUser.Results):null}:{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataSystemUser - Error executing query - ${t}`),{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async GetQueryDataByName(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataByNameSystemUser($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryName:e.QueryName};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results?(0,n.NG)(s.GetQueryDataByNameSystemUser.Results):null}:{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataByNameSystemUser - Error executing query - ${t}`),{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async CreateQuery(e){try{const t=await this.Client.request("mutation CreateQuerySystemUser($input: CreateQuerySystemUserInput!) {\n CreateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.CreateQuerySystemUser?t.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async UpdateQuery(e){try{const t=await this.Client.request("mutation UpdateQuerySystemUser($input: UpdateQuerySystemUserInput!) {\n UpdateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.UpdateQuerySystemUser?t.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async DeleteQuery(e,t){try{if(!e||""===e.trim())return(0,a.ZI)("GraphQLSystemUserClient::DeleteQuery - Invalid query ID: ID cannot be null or empty"),{Success:!1,ErrorMessage:"Invalid query ID: ID cannot be null or empty"};const r="mutation DeleteQuerySystemResolver($ID: String!, $options: DeleteOptionsInput) {\n DeleteQuerySystemResolver(ID: $ID, options: $options) {\n Success\n ErrorMessage\n ID\n Name\n }\n }",s={ID:e};void 0!==t&&(s.options={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(e){let t="";if(e instanceof Error){if(t=e.message,"cause"in e&&e.cause){const r=e.cause;t+=` | Cause: ${r.message||r}`,"code"in r&&(t+=` | Code: ${r.code}`)}if("response"in e){const r=e.response;r?.status&&(t+=` | HTTP Status: ${r.status}`),r?.errors&&(t+=` | GraphQL Errors: ${JSON.stringify(r.errors)}`)}e.stack&&console.error("DeleteQuery stack trace:",e.stack)}else t=String(e);return(0,a.ZI)(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${t}`),{Success:!1,ErrorMessage:t}}}async RunAIPrompt(e){try{const t=s.J1`
443
444
  query RunAIPromptSystemUser(
444
445
  $promptId: String!,
445
446
  $data: String,
@@ -563,7 +564,7 @@
563
564
  error
564
565
  }
565
566
  }
566
- `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this.Client.request(t,r);if(!a?.EmbedTextSystemUser)return{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const n=a.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class G{static{y(this,"GetDataOutput")}}class V{static{y(this,"SimpleRemoteEntityOutput")}}class U{static{y(this,"SimpleRemoteEntity")}}class _{static{y(this,"SimpleRemoteEntityField")}}class O{static{y(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),a=this.createActionVariables(e,s,r),n=await this.executeActionMutation(a);return this.processActionResult(n,t)}catch(e){return this.handleActionError(e,t)}}serializeActionParameters(e){if(e)return e.map(e=>{let t=e.Value;return null!=t&&"object"==typeof t&&(t=JSON.stringify(t)),{...e,Value:t}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=s.J1`
567
+ `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this.Client.request(t,r);if(!a?.EmbedTextSystemUser)return{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const n=a.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class G{static{p(this,"GetDataOutput")}}class V{static{p(this,"SimpleRemoteEntityOutput")}}class U{static{p(this,"SimpleRemoteEntity")}}class _{static{p(this,"SimpleRemoteEntityField")}}class O{static{p(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),a=this.createActionVariables(e,s,r),n=await this.executeActionMutation(a);return this.processActionResult(n,t)}catch(e){return this.handleActionError(e,t)}}serializeActionParameters(e){if(e)return e.map(e=>{let t=e.Value;return null!=t&&"object"==typeof t&&(t=JSON.stringify(t)),{...e,Value:t}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=s.J1`
567
568
  mutation RunAction($input: RunActionInput!) {
568
569
  RunAction(input: $input) {
569
570
  Success
@@ -580,7 +581,7 @@
580
581
  ResultData
581
582
  }
582
583
  }
583
- `;return await this._dataProvider.ExecuteGQL(t,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let t={};try{e.RunEntityAction.ResultData&&(t=JSON.parse(e.RunEntityAction.ResultData))}catch(e){(0,a.ZI)(`Failed to parse entity action result data: ${e}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return(0,a.ZI)(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class K{static{y(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),r=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(r)}catch(e){return this.handleCreateAPIKeyError(e)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=s.J1`
584
+ `;return await this._dataProvider.ExecuteGQL(t,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let t={};try{e.RunEntityAction.ResultData&&(t=JSON.parse(e.RunEntityAction.ResultData))}catch(e){(0,a.ZI)(`Failed to parse entity action result data: ${e}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return(0,a.ZI)(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class j{static{p(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),r=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(r)}catch(e){return this.handleCreateAPIKeyError(e)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=s.J1`
584
585
  mutation CreateAPIKey($input: CreateAPIKeyInput!) {
585
586
  CreateAPIKey(input: $input) {
586
587
  Success
@@ -596,7 +597,7 @@
596
597
  Error
597
598
  }
598
599
  }
599
- `,r=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return r?.RevokeAPIKey?{Success:r.RevokeAPIKey.Success,Error:r.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(e){const t=e;return(0,a.ZI)(`Error revoking API key: ${t.message}`),{Success:!1,Error:`Error: ${t.message}`}}}}class j{static{y(this,"GraphQLTestingClient")}constructor(e){this._dataProvider=e}async RunTest(e){try{const t=this.buildRunTestMutation(),r=this.buildRunTestVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTest",operationLabel:"RunTest",validateAck:y(e=>!0===e?.success,"validateAck"),isCompletionEvent:y(t=>this.isTestCompletionEvent(t,e.testId),"isCompletionEvent"),extractResult:y(e=>this.extractTestResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardTestProgress(t,e.onProgress):void 0,createErrorResult:y(e=>({success:!1,errorMessage:e,result:null}),"createErrorResult")})}catch(e){return this.handleError(e,"RunTest")}}async RunTestSuite(e){try{const t=this.buildRunTestSuiteMutation(),r=this.buildRunTestSuiteVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTestSuite",operationLabel:"RunTestSuite",validateAck:y(e=>!0===e?.success,"validateAck"),isCompletionEvent:y(t=>this.isSuiteCompletionEvent(t,e.suiteId),"isCompletionEvent"),extractResult:y(e=>this.extractSuiteResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardTestProgress(t,e.onProgress):void 0,createErrorResult:y(e=>({success:!1,errorMessage:e,result:null}),"createErrorResult")})}catch(e){return this.handleError(e,"RunTestSuite")}}async IsTestRunning(e){try{const t=s.J1`
600
+ `,r=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return r?.RevokeAPIKey?{Success:r.RevokeAPIKey.Success,Error:r.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(e){const t=e;return(0,a.ZI)(`Error revoking API key: ${t.message}`),{Success:!1,Error:`Error: ${t.message}`}}}}class K{static{p(this,"GraphQLTestingClient")}constructor(e){this._dataProvider=e}async RunTest(e){try{const t=this.buildRunTestMutation(),r=this.buildRunTestVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTest",operationLabel:"RunTest",validateAck:p(e=>!0===e?.success,"validateAck"),isCompletionEvent:p(t=>this.isTestCompletionEvent(t,e.testId),"isCompletionEvent"),extractResult:p(e=>this.extractTestResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardTestProgress(t,e.onProgress):void 0,createErrorResult:p(e=>({success:!1,errorMessage:e,result:null}),"createErrorResult")})}catch(e){return this.handleError(e,"RunTest")}}async RunTestSuite(e){try{const t=this.buildRunTestSuiteMutation(),r=this.buildRunTestSuiteVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTestSuite",operationLabel:"RunTestSuite",validateAck:p(e=>!0===e?.success,"validateAck"),isCompletionEvent:p(t=>this.isSuiteCompletionEvent(t,e.suiteId),"isCompletionEvent"),extractResult:p(e=>this.extractSuiteResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardTestProgress(t,e.onProgress):void 0,createErrorResult:p(e=>({success:!1,errorMessage:e,result:null}),"createErrorResult")})}catch(e){return this.handleError(e,"RunTestSuite")}}async IsTestRunning(e){try{const t=s.J1`
600
601
  query IsTestRunning($testId: String!) {
601
602
  IsTestRunning(testId: $testId)
602
603
  }
@@ -654,7 +655,7 @@
654
655
  result
655
656
  }
656
657
  }
657
- `}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:r,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0,s=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:r,selectedTestIds:s,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetComplete"===e.type&&"complete"===r?.type&&r?.testId===t}isSuiteCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetSuiteComplete"===e.type&&"complete"===r?.type&&r?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}forwardTestProgress(e,t){if("RunTestResolver"===e.resolver&&"TestExecutionProgress"===e.type&&"ok"===e.status){const r=e.data?.progress;r&&t(r)}}handleError(e,t){const r=e.message;return(0,a.ZI)(`${t} failed: ${r}`),{success:!1,errorMessage:r.includes("Failed to fetch")||r.includes("NetworkError")?"Lost connection to the server. The test may still be running. Please refresh to check the latest status.":r,result:null}}}class k{static{y(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=s.J1`
658
+ `}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:r,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0,s=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:r,selectedTestIds:s,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetComplete"===e.type&&"complete"===r?.type&&r?.testId===t}isSuiteCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetSuiteComplete"===e.type&&"complete"===r?.type&&r?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}forwardTestProgress(e,t){if("RunTestResolver"===e.resolver&&"TestExecutionProgress"===e.type&&"ok"===e.status){const r=e.data?.progress;r&&t(r)}}handleError(e,t){const r=e.message;return(0,a.ZI)(`${t} failed: ${r}`),{success:!1,errorMessage:r.includes("Failed to fetch")||r.includes("NetworkError")?"Lost connection to the server. The test may still be running. Please refresh to check the latest status.":r,result:null}}}class k{static{p(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=s.J1`
658
659
  query GetRegistryComponent(
659
660
  $registryName: String!,
660
661
  $namespace: String!,
@@ -738,7 +739,7 @@
738
739
  error
739
740
  }
740
741
  }
741
- `,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(e){return(0,a.ZI)(e),{success:!1,error:e instanceof Error?e.message:"Unknown error"}}}}class J{static{y(this,"GraphQLVersionHistoryClient")}constructor(e){this._dataProvider=e}async CreateLabel(e){let t;try{e.OnProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);"VersionHistoryResolver"===r.resolver&&"CreateLabelProgress"===r.type&&"ok"===r.status&&r.data&&e.OnProgress(r.data)}catch{}}));const r=s.J1`
742
+ `,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(e){return(0,a.ZI)(e),{success:!1,error:e instanceof Error?e.message:"Unknown error"}}}}class J{static{p(this,"GraphQLVersionHistoryClient")}constructor(e){this._dataProvider=e}async CreateLabel(e){let t;try{e.OnProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);"VersionHistoryResolver"===r.resolver&&"CreateLabelProgress"===r.type&&"ok"===r.status&&r.data&&e.OnProgress(r.data)}catch{}}));const r=s.J1`
742
743
  mutation CreateVersionLabel($input: CreateVersionLabelInput!, $sessionId: String) {
743
744
  CreateVersionLabel(input: $input, sessionId: $sessionId) {
744
745
  Success
@@ -754,7 +755,7 @@
754
755
  }
755
756
  }
756
757
  }
757
- `,a={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(r,a);return this.processResult(n)}catch(e){const t=e instanceof Error?e.message:String(e);return(0,a.ZI)(`GraphQLVersionHistoryClient.CreateLabel error: ${t}`),{Success:!1,Error:t}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return null!=e.Description&&(t.Description=e.Description),null!=e.Scope&&(t.Scope=e.Scope),null!=e.EntityName&&(t.EntityName=e.EntityName),null!=e.ParentID&&(t.ParentID=e.ParentID),null!=e.ExternalSystemID&&(t.ExternalSystemID=e.ExternalSystemID),null!=e.IncludeDependencies&&(t.IncludeDependencies=e.IncludeDependencies),null!=e.MaxDepth&&(t.MaxDepth=e.MaxDepth),null!=e.ExcludeEntities&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(e=>({Key:e.Key,Value:e.Value}))),t}processResult(e){const t=e?.CreateVersionLabel;if(!t)return{Success:!1,Error:"Invalid response from server."};const r=Array.isArray(t.CaptureErrors)?t.CaptureErrors.map(e=>({EntityName:e.EntityName??"",RecordID:e.RecordID??"",ErrorMessage:e.ErrorMessage??""})):void 0;return{Success:t.Success,LabelID:t.LabelID,LabelName:t.LabelName,ItemsCaptured:t.ItemsCaptured,SyntheticSnapshotsCreated:t.SyntheticSnapshotsCreated,Error:t.Error,CaptureErrors:r}}}class B{static{y(this,"GraphQLFileStorageClient")}constructor(e){this._dataProvider=e}async ListObjects(e,t="",r){try{const a=s.J1`
758
+ `,a={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(r,a);return this.processResult(n)}catch(e){const t=e instanceof Error?e.message:String(e);return(0,a.ZI)(`GraphQLVersionHistoryClient.CreateLabel error: ${t}`),{Success:!1,Error:t}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return null!=e.Description&&(t.Description=e.Description),null!=e.Scope&&(t.Scope=e.Scope),null!=e.EntityName&&(t.EntityName=e.EntityName),null!=e.ParentID&&(t.ParentID=e.ParentID),null!=e.ExternalSystemID&&(t.ExternalSystemID=e.ExternalSystemID),null!=e.IncludeDependencies&&(t.IncludeDependencies=e.IncludeDependencies),null!=e.MaxDepth&&(t.MaxDepth=e.MaxDepth),null!=e.ExcludeEntities&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(e=>({Key:e.Key,Value:e.Value}))),t}processResult(e){const t=e?.CreateVersionLabel;if(!t)return{Success:!1,Error:"Invalid response from server."};const r=Array.isArray(t.CaptureErrors)?t.CaptureErrors.map(e=>({EntityName:e.EntityName??"",RecordID:e.RecordID??"",ErrorMessage:e.ErrorMessage??""})):void 0;return{Success:t.Success,LabelID:t.LabelID,LabelName:t.LabelName,ItemsCaptured:t.ItemsCaptured,SyntheticSnapshotsCreated:t.SyntheticSnapshotsCreated,Error:t.Error,CaptureErrors:r}}}class B{static{p(this,"GraphQLFileStorageClient")}constructor(e){this._dataProvider=e}async ListObjects(e,t="",r){try{const a=s.J1`
758
759
  query ListStorageObjects($input: ListStorageObjectsInput!) {
759
760
  ListStorageObjects(input: $input) {
760
761
  objects {
@@ -838,7 +839,7 @@
838
839
  failedAccounts
839
840
  }
840
841
  }
841
- `,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:r?.maxResultsPerAccount,FileTypes:r?.fileTypes,SearchContent:r?.searchContent}},o=await this._dataProvider.ExecuteGQL(a,n);if(!o?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=o.SearchAcrossAccounts;return{accountResults:i.accountResults.map(e=>({accountId:e.accountID,accountName:e.accountName,success:e.success,errorMessage:e.errorMessage,results:e.results.map(e=>({path:e.path,name:e.name,size:e.size,contentType:e.contentType,lastModified:new Date(e.lastModified),relevance:e.relevance,excerpt:e.excerpt,matchInFilename:e.matchInFilename,objectId:e.objectId})),totalMatches:e.totalMatches,hasMore:e.hasMore,nextPageToken:e.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(t){return(0,a.ZI)(`Error searching across accounts: ${t}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}class q{static{y(this,"GraphQLIntegrationClient")}constructor(e){this._dataProvider=e}async DiscoverObjects(e){try{const t=s.J1`
842
+ `,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:r?.maxResultsPerAccount,FileTypes:r?.fileTypes,SearchContent:r?.searchContent}},o=await this._dataProvider.ExecuteGQL(a,n);if(!o?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=o.SearchAcrossAccounts;return{accountResults:i.accountResults.map(e=>({accountId:e.accountID,accountName:e.accountName,success:e.success,errorMessage:e.errorMessage,results:e.results.map(e=>({path:e.path,name:e.name,size:e.size,contentType:e.contentType,lastModified:new Date(e.lastModified),relevance:e.relevance,excerpt:e.excerpt,matchInFilename:e.matchInFilename,objectId:e.objectId})),totalMatches:e.totalMatches,hasMore:e.hasMore,nextPageToken:e.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(t){return(0,a.ZI)(`Error searching across accounts: ${t}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}class q{static{p(this,"GraphQLIntegrationClient")}constructor(e){this._dataProvider=e}async DiscoverObjects(e){try{const t=s.J1`
842
843
  query IntegrationDiscoverObjects($companyIntegrationID: String!) {
843
844
  IntegrationDiscoverObjects(companyIntegrationID: $companyIntegrationID) {
844
845
  Success