@memberjunction/graphql-dataprovider 6.1.0-edge.4 → 6.1.0-edge.6
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.
- package/dist/index.cjs +24 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +49 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +27 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0});import{gql as c,GraphQLClient as B}from"graphql-request";import{gql as bt}from"graphql-request";import{TransactionGroupBase as de,TransactionResult as ye,LogError as y,LogStatus as P,LogErrorEx as b,ProviderBase as me,UserInfo as j,getGraphQLTypeNameBase as T,ProviderType as ge,BaseEntityResult as
|
|
1
|
+
var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0});import{gql as c,GraphQLClient as B}from"graphql-request";import{gql as bt}from"graphql-request";import{TransactionGroupBase as de,TransactionResult as ye,LogError as y,LogStatus as P,LogErrorEx as b,ProviderBase as me,UserInfo as j,getGraphQLTypeNameBase as T,ProviderType as ge,BaseEntityResult as Q,EntityFieldTSType as N,TransactionItem as J,CompositeKey as Se,UserRoleInfo as pe,InMemoryLocalStorageProvider as he,BaseEntity as Ie,ProviderConfigDataBase as fe,SetProvider as Re,StartupManager as Ee,IsPlatformSQL as De,IsVerboseLoggingEnabled as ve}from"@memberjunction/core";import{SafeJSONParse as v,CleanAndParseJSON as Ce,GetGlobalObjectStore as W,MJGlobal as H,MJEventType as z}from"@memberjunction/global";import{ViewInfo as X}from"@memberjunction/core-entities";import{BehaviorSubject as we,Observable as x,Subject as Y,Subscription as Z}from"rxjs";import{createClient as $e}from"graphql-ws";import{v4 as Pe}from"uuid";import{openDB as be}from"@tempfix/idb";class A{static{l(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(A.DB_PREFIX)?A.GQL_PREFIX+e.substring(A.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(A.GQL_PREFIX)?A.DB_PREFIX+e.substring(A.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 ee extends de{static{l(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=c`
|
|
2
2
|
mutation ExecuteTransactionGroup($group: TransactionInputType!) {
|
|
3
3
|
ExecuteTransactionGroup(group: $group) {
|
|
4
4
|
Success
|
|
@@ -6,7 +6,7 @@ var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0})
|
|
|
6
6
|
ResultsJSON
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,t=[];for(const n of this.PendingTransactions)t.push({EntityName:n.BaseEntity.EntityInfo.Name,EntityObjectJSON:await n.BaseEntity.GetDataObjectJSON(),OperationType:n.OperationType});const r={group:{Items:t,Variables:this.Variables.map(n=>({Name:n.Name,ItemIndex:this.MapVariableEntityObjectToPosition(n),FieldName:n.FieldName,Type:n.Type}))}},s=await this._provider.ExecuteGQL(e,r);if(s&&s.ExecuteTransactionGroup){const n=s.ExecuteTransactionGroup,a=n.Success===!0,i=[];for(let o=0;o<this.PendingTransactions.length;o++){const m=n.ResultsJSON[o],u=v(m),S=this.PendingTransactions[o];i.push(new ye(S,u,a&&u!==null))}return i}else throw new Error("Failed to execute transaction group")}}const
|
|
9
|
+
`,t=[];for(const n of this.PendingTransactions)t.push({EntityName:n.BaseEntity.EntityInfo.Name,EntityObjectJSON:await n.BaseEntity.GetDataObjectJSON(),OperationType:n.OperationType});const r={group:{Items:t,Variables:this.Variables.map(n=>({Name:n.Name,ItemIndex:this.MapVariableEntityObjectToPosition(n),FieldName:n.FieldName,Type:n.Type}))}},s=await this._provider.ExecuteGQL(e,r);if(s&&s.ExecuteTransactionGroup){const n=s.ExecuteTransactionGroup,a=n.Success===!0,i=[];for(let o=0;o<this.PendingTransactions.length;o++){const m=n.ResultsJSON[o],u=v(m),S=this.PendingTransactions[o];i.push(new ye(S,u,a&&u!==null))}return i}else throw new Error("Failed to execute transaction group")}}const Me=720*1e3,Ae=6;class w{static{l(this,"FireAndForgetHelper")}static async Execute(e){const t=e.operationLabel??e.mutationFieldName;if(!(typeof e.dataProvider.PushStatusUpdates=="function"))return w.executeSynchronously(e);const s=e.timeoutMs??Me,n=e.maxStallReconciles??Ae;let a,i=!1,o=0;const{promise:m,resolve:u,reject:S}=w.createCompletionPromise(),h=l(R=>{i||(i=!0,E.clear(),R())},"finish"),g=l(R=>h(()=>u(R)),"settleResolve"),p=l(R=>h(()=>S(R)),"settleReject"),I=l(async()=>{if(i)return;if(!e.onStall){p(new Error(w.timeoutMessage(e.timeoutErrorMessage,s)));return}let R;try{P(`[FireAndForget:${t}] Idle window elapsed, reconciling against server run record`),R=await e.onStall()}catch(D){p(D);return}i||(R==="continue"?++o>n?p(new Error(`The operation is still reported as running but no signal has arrived after ${o} checks. Please refresh the page to check the latest status.`)):E.reset():"resolve"in R?(P(`[FireAndForget:${t}] Reconciliation recovered a completed run`),g(R.resolve)):p(R.reject))},"onStall"),E=w.createIdleTimer(s,()=>{I()});try{E.reset(),a=w.subscribeToPubSub(e,{onActivity:l(()=>{o=0,E.reset()},"onActivity"),onCompletion:l(D=>g(D),"onCompletion"),onStreamEnd:l(()=>{I()},"onStreamEnd")});const R=await w.executeMutation(e);if(!e.validateAck(R)){E.clear();const D=R?.errorMessage??"Server rejected the request";return y(`[FireAndForget:${t}] Server rejected: ${D}`),e.createErrorResult(D)}return P(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await m}catch(R){throw y(`[FireAndForget:${t}] Error: ${R.message}`),R}finally{E.clear(),a&&a.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((s,n)=>{e=s,t=n}),resolve:e,reject:t}}static createIdleTimer(e,t){let r;return{reset:l(()=>{r&&clearTimeout(r),r=setTimeout(t,e)},"reset"),clear:l(()=>{r&&clearTimeout(r),r=void 0},"clear")}}static timeoutMessage(e,t){const r=Math.round(t/6e4);return e??`The operation may still be running on the server but the client received no updates for ${r} minutes. Please refresh the page to check the latest status.`}static subscribeToPubSub(e,t){const r=e.dataProvider.sessionId,s=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(r).subscribe({next:l(n=>{t.onActivity();try{const a=JSON.parse(n);e.onMessage&&e.onMessage(a),e.isCompletionEvent(a)&&(P(`[FireAndForget:${s}] Completion event received`),t.onCompletion(e.extractResult(a)))}catch(a){console.error(`[FireAndForget:${s}] Failed to parse PubSub message:`,a)}},"next"),error:l(()=>t.onStreamEnd(),"error"),complete:l(()=>t.onStreamEnd(),"complete")})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}static async executeSynchronously(e){const t=e.operationLabel??e.mutationFieldName;P(`[FireAndForget:${t}] Provider has no PushStatusUpdates channel \u2014 running synchronously (fireAndForget disabled)`);const r={...e.variables,fireAndForget:!1},n=(await e.dataProvider.ExecuteGQL(e.mutation,r))?.[e.mutationFieldName];return n?e.extractSyncResult?(P(`[FireAndForget:${t}] Synchronous execution completed`),e.extractSyncResult(n)):e.createErrorResult(`${t} cannot run on this data provider: it has no PushStatusUpdates channel and no synchronous result extractor is configured for this operation.`):(y(`[FireAndForget:${t}] Synchronous execution returned no '${e.mutationFieldName}' payload`),e.createErrorResult(`Server returned no '${e.mutationFieldName}' result for ${t}`))}}class te{static{l(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=c`
|
|
10
10
|
mutation RunAIPrompt(
|
|
11
11
|
$promptId: String!,
|
|
12
12
|
$data: String,
|
|
@@ -65,7 +65,7 @@ var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0})
|
|
|
65
65
|
chatResult
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,r=this.preparePromptVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(s)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,n;try{t.parsedResult&&(r=Ce(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(n=JSON.parse(t.chatResult))}catch{n=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:n}}handlePromptError(e){const t=e;return y(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){try{const
|
|
68
|
+
`,r=this.preparePromptVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(s)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,n;try{t.parsedResult&&(r=Ce(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(n=JSON.parse(t.chatResult))}catch{n=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:n}}handlePromptError(e){const t=e;return y(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){let s=!1;try{const n=this.buildRunAIAgentMutation(),a=this.prepareAgentVariables(e,t,r);a.fireAndForget=!0;const i={};return await w.Execute({dataProvider:this._dataProvider,mutation:n,variables:a,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:l(o=>{const m=o?.success===!0;return m&&(s=!0),m},"validateAck"),isCompletionEvent:l(o=>this.isAgentCompletionEvent(o),"isCompletionEvent"),extractResult:l(o=>this.extractAgentResult(o),"extractResult"),extractSyncResult:l(o=>this.extractAgentResultFromAck(o),"extractSyncResult"),onMessage:l(o=>{this.captureAgentRunId(o,i),e.onProgress&&this.forwardAgentProgress(o,e.onProgress)},"onMessage"),onStall:l(()=>this.reconcileAgentRun(i.id?`ID='${i.id}'`:void 0),"onStall"),createErrorResult:l(o=>this.createAgentErrorResult(o,s),"createErrorResult")})}catch(n){return this.handleAgentError(n,s)}}buildRunAIAgentMutation(){return c`
|
|
69
69
|
mutation RunAIAgent(
|
|
70
70
|
$agentId: String!,
|
|
71
71
|
$messages: String!,
|
|
@@ -112,7 +112,7 @@ var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0})
|
|
|
112
112
|
result
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
`}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return e.data!==void 0&&(s.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(s.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(s.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(s.configurationId=e.configurationId),e.conversationDetailId!==void 0&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),t!==void 0&&(s.sourceArtifactId=t),r!==void 0&&(s.sourceArtifactVersionId=r),e.planMode!==void 0&&(s.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(s.requestedSkillIDs=e.requestedSkillIDs),e.taskGraphDebug!==void 0&&(s.taskGraphDebug=JSON.stringify(e.taskGraphDebug)),s}processAgentResult(e){return v(e)}handleAgentError(e){const
|
|
115
|
+
`}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return e.data!==void 0&&(s.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(s.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(s.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(s.configurationId=e.configurationId),e.conversationDetailId!==void 0&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),t!==void 0&&(s.sourceArtifactId=t),r!==void 0&&(s.sourceArtifactVersionId=r),e.planMode!==void 0&&(s.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(s.requestedSkillIDs=e.requestedSkillIDs),e.taskGraphDebug!==void 0&&(s.taskGraphDebug=JSON.stringify(e.taskGraphDebug)),s}processAgentResult(e){return v(e)}handleAgentError(e,t=!1){const s=e?.message||String(e);y(`Error running AI agent: ${s}`);const n=s.includes("Failed to fetch")||s.includes("NetworkError"),a=s.includes("timed out")||s.includes("timeout");let i;return n&&t?i="Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":n?i="Could not reach the server. The request may not have started. Please try again.":i=s,{success:!1,agentRun:void 0,errorMessage:i,requestAcknowledged:t}}async RunAIAgentFromConversationDetail(e){let t=!1;try{const r=this.buildConversationDetailMutation(),s=this.prepareConversationDetailVariables(e);return await w.Execute({dataProvider:this._dataProvider,mutation:r,variables:s,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:l(n=>{const a=n?.success===!0;return a&&(t=!0),a},"validateAck"),isCompletionEvent:l(n=>this.isConversationDetailCompletionEvent(n,e.conversationDetailId),"isCompletionEvent"),extractResult:l(n=>this.extractAgentResult(n),"extractResult"),extractSyncResult:l(n=>this.extractAgentResultFromAck(n),"extractSyncResult"),onMessage:e.onProgress?n=>this.forwardConversationDetailProgress(n,e.onProgress):void 0,onStall:l(()=>this.reconcileAgentRun(`ConversationDetailID='${e.conversationDetailId}'`),"onStall"),createErrorResult:l(n=>this.createAgentErrorResult(n,t),"createErrorResult")})}catch(r){return this.handleAgentError(r,t)}}buildConversationDetailMutation(){return c`
|
|
116
116
|
mutation RunAIAgentFromConversationDetail(
|
|
117
117
|
$conversationDetailId: String!,
|
|
118
118
|
$agentId: String!,
|
|
@@ -155,7 +155,7 @@ var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0})
|
|
|
155
155
|
result
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return e.maxHistoryMessages!==void 0&&(t.maxHistoryMessages=e.maxHistoryMessages),e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(t.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.planMode!==void 0&&(t.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(t.requestedSkillIDs=e.requestedSkillIDs),e.createArtifacts!==void 0&&(t.createArtifacts=e.createArtifacts),e.createNotification!==void 0&&(t.createNotification=e.createNotification),e.sourceArtifactId!==void 0&&(t.sourceArtifactId=e.sourceArtifactId),e.sourceArtifactVersionId!==void 0&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&t?.type==="complete"}isConversationDetailCompletionEvent(e,t){const r=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&r?.type==="complete"&&r?.conversationDetailId===t}captureAgentRunId(e,t){const r=e.data,s=r?.agentRunId??r?.runId;s&&s!=="unknown"&&(t.id=s)}async reconcileAgentRun(e){if(!e)return"continue";const t=await this._dataProvider.RunView({EntityName:"MJ: AI Agent Runs",ExtraFilter:e,OrderBy:"__mj_CreatedAt DESC",ResultType:"entity_object",BypassCache:!0}),r=t.Success?t.Results?.[0]:void 0;return!r||r.Status==="Running"?"continue":{resolve:{success:r.Status==="Completed"||r.Status==="Paused"||r.Status==="AwaitingFeedback",agentRun:r,payload:r.Result?v(r.Result)??void 0:void 0,errorMessage:r.ErrorMessage??void 0}}}extractAgentResult(e){const t=e.data,r=t.result;
|
|
158
|
+
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return e.maxHistoryMessages!==void 0&&(t.maxHistoryMessages=e.maxHistoryMessages),e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(t.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.planMode!==void 0&&(t.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(t.requestedSkillIDs=e.requestedSkillIDs),e.createArtifacts!==void 0&&(t.createArtifacts=e.createArtifacts),e.createNotification!==void 0&&(t.createNotification=e.createNotification),e.sourceArtifactId!==void 0&&(t.sourceArtifactId=e.sourceArtifactId),e.sourceArtifactVersionId!==void 0&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&t?.type==="complete"}isConversationDetailCompletionEvent(e,t){const r=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&r?.type==="complete"&&r?.conversationDetailId===t}captureAgentRunId(e,t){const r=e.data,s=r?.agentRunId??r?.runId;s&&s!=="unknown"&&(t.id=s)}async reconcileAgentRun(e){if(!e)return"continue";const t=await this._dataProvider.RunView({EntityName:"MJ: AI Agent Runs",ExtraFilter:e,OrderBy:"__mj_CreatedAt DESC",ResultType:"entity_object",BypassCache:!0}),r=t.Success?t.Results?.[0]:void 0;return!r||r.Status==="Running"?"continue":{resolve:{success:r.Status==="Completed"||r.Status==="Paused"||r.Status==="AwaitingFeedback",agentRun:r,payload:r.Result?v(r.Result)??void 0:void 0,errorMessage:r.ErrorMessage??void 0}}}extractAgentResult(e){const t=e.data,r=t.result;if(r){const a=v(r);if(a)return!a.errorMessage&&typeof t.errorMessage=="string"&&(a.errorMessage=t.errorMessage),a}const s=!!t.success,n=typeof t.errorMessage=="string"&&t.errorMessage?t.errorMessage:void 0;return{success:s,agentRun:void 0,errorMessage:n??(s?void 0:"Agent execution ended without a result payload")}}extractAgentResultFromAck(e){const t=e.result;if(t){const r=v(t);if(r)return r}return{success:e.success,agentRun:void 0,errorMessage:e.errorMessage}}forwardAgentProgress(e,t){if(e.resolver!=="RunAIAgentResolver"||e.type!=="ExecutionProgress"||e.status!=="ok")return;const s=e.data?.progress;s&&t({step:s.currentStep,percentage:s.percentage,message:s.message,metadata:s})}forwardConversationDetailProgress(e,t){if(e.resolver!=="RunAIAgentResolver"||e.type!=="ExecutionProgress"||e.status!=="ok")return;const r=e.data,s=r?.progress;s&&t({currentStep:s.currentStep,percentage:s.percentage,message:s.message,metadata:{...s,agentRun:r?.agentRun,agentRunId:r?.agentRunId}})}createAgentErrorResult(e,t=!1){return{success:!1,agentRun:void 0,errorMessage:e,requestAcknowledged:t}}async ExecuteSimplePrompt(e){try{const t=c`
|
|
159
159
|
mutation ExecuteSimplePrompt(
|
|
160
160
|
$systemPrompt: String!,
|
|
161
161
|
$messages: String,
|
|
@@ -307,9 +307,9 @@ var le=Object.defineProperty;var l=(d,e)=>le(d,"name",{value:e,configurable:!0})
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
`,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return y("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const F="6.1.0-edge.
|
|
311
|
-
${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))}l(ae,"ToSafeGraphQLError");const Fe=3,Ge=25;function V(d,e=0){if(d===null)return"null";if(d===void 0)return"undefined";if(Array.isArray(d))return d.length===0?"array(empty)":`array(${d.length} \xD7 ${
|
|
312
|
-
at `);return e===-1?"":d.slice(e+1)}l(
|
|
310
|
+
`,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return y("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const F="6.1.0-edge.6",$="default";class re{static{l(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}get SharesReferences(){return!0}getCategoryMap(e){const t=e||$;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){const s=this.getCategoryMap(t||$).get(e);return s===void 0?null:s}async GetItems(e,t){const r=new Map;if(e.length===0)return r;const s=this.getCategoryMap(t||$);for(const n of new Set(e)){const a=s.get(n);r.set(n,a===void 0?null:a)}return r}async SetItem(e,t,r){this.getCategoryMap(r||$).set(e,t)}async Remove(e,t){this.getCategoryMap(t||$).delete(e)}async ClearCategory(e){const t=e||$;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||$);return t?Array.from(t.keys()):[]}}const Ne="MJ_Metadata",xe=0;function Te(){try{const d=F.split("."),e=parseInt(d[0],10),t=parseInt(d[1],10);if(!Number.isFinite(e)||!Number.isFinite(t))throw new Error(`Could not parse major.minor from version "${F}"`);return e*1e3+t+xe}catch(d){return b({error:d,message:"Failed to derive IDB version from PACKAGE_VERSION; using fallback 99999"}),99999}}l(Te,"computeIdbVersion");const Le=Te(),se=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"];class ne extends re{static{l(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=be(Ne,Le,{upgrade:l((e,t,r)=>{try{P(`[IDBCache] Upgrading IndexedDB schema v${t} \u2192 v${r} (package ${F}). Dropping all stores; caches will repopulate on first use.`);for(const s of Array.from(e.objectStoreNames))e.deleteObjectStore(s);for(const s of se)e.objectStoreNames.contains(s)||e.createObjectStore(s)}catch(s){b({error:s,message:s?.message})}},"upgrade"),blocked:l((e,t)=>{P(`[IDBCache] Upgrade from v${e} to v${t} blocked by another tab. Close other tabs to allow the upgrade to proceed.`)},"blocked")}),this.dbPromise.then(e=>{this._dbReady=!0,e.onversionchange=()=>{P("[IDBCache] DB schema upgraded in another tab \u2014 closing local connection."),e.close(),this._dbReady=!1}}).catch(e=>{b({error:e,message:"IndexedDB initialization failed: "+e?.message})})}get SharesReferences(){return!1}get IsReady(){return this._dbReady}isKnownCategory(e){const t=`mj:${e}`;return se.includes(t)}getStoreName(e){const t=e||$;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||$;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,n=this.getStoreName(r),a=this.getStoreKey(e,r),i=s.transaction(n,"readwrite");await i.objectStore(n).put(t,a),await i.done}catch(s){b({error:s,message:s?.message})}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=await r.transaction(s).objectStore(s).get(n);return a===void 0?null:a}catch(r){return b({error:r,message:r?.message}),null}}async GetItems(e,t){const r=new Map;if(e.length===0)return r;try{const s=await this.dbPromise,n=this.getStoreName(t),a=Array.from(new Set(e)),i=a.map(h=>this.getStoreKey(h,t)),o=s.transaction(n,"readonly"),m=o.objectStore(n),u=i.map(h=>m.get(h)),S=await Promise.all(u);await o.done;for(let h=0;h<a.length;h++){const g=S[h];r.set(a[h],g===void 0?null:g)}return r}catch(s){b({error:s,message:s?.message});for(const n of new Set(e))r.set(n,null);return r}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=r.transaction(s,"readwrite");await a.objectStore(s).delete(n),await a.done}catch(r){b({error:r,message:r?.message})}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||$,s=this.getStoreName(e);if(this.isKnownCategory(r)){const n=t.transaction(s,"readwrite");await n.objectStore(s).clear(),await n.done}else{const n=`[${r}]:`,a=t.transaction("mj:default","readwrite"),i=a.objectStore("mj:default"),o=await i.getAllKeys();for(const m of o)typeof m=="string"&&m.startsWith(n)&&await i.delete(m);await a.done}}catch(t){b({error:t,message:t?.message})}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||$,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(m=>String(m));const o=`[${r}]:`;return i.map(m=>String(m)).filter(m=>m.startsWith(o)).map(m=>m.slice(o.length))}catch(t){return b({error:t,message:t?.message}),[]}}}class _ extends Error{static{l(this,"SafeGraphQLError")}constructor(e){super(e.message),this.name=e.name,this.response={status:e.status,errors:e.errors},this.request={query:e.query},this.Code=e.code,this.VariableShape=e.variableShape,this.stack=e.stackFrames?`${e.name}: ${e.message}
|
|
311
|
+
${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))}l(ae,"ToSafeGraphQLError");const Fe=3,Ge=25;function V(d,e=0){if(d===null)return"null";if(d===void 0)return"undefined";if(Array.isArray(d))return d.length===0?"array(empty)":`array(${d.length} \xD7 ${Ue(V(d[0],e+1))})`;if(typeof d=="object"){if(e>=Fe)return"object(\u2026)";const t=Object.keys(d);if(t.length>Ge)return`object(${t.length} keys)`;const r={};for(const s of t)r[s]=V(d[s],e+1);return r}return typeof d=="string"?d.length===0?"string(empty)":"string":typeof d}l(V,"describeShape");function Ue(d){return typeof d=="string"?d:"object"}l(Ue,"typeOf");function Qe(d){const e=d.indexOf(`
|
|
312
|
+
at `);return e===-1?"":d.slice(e+1)}l(Qe,"stripStackHeader");function _e(d,e){const t=d?.[0]?.message;return typeof t=="string"&&t.length>0?t:`GraphQL Error (Code: ${String(e??"unknown")})`}l(_e,"deriveMessage");function Ve(d){if(Array.isArray(d))return d.map(e=>{const t=e??{};return{message:typeof t.message=="string"?t.message:void 0,path:Array.isArray(t.path)?t.path:void 0,extensions:t.extensions&&typeof t.extensions=="object"?t.extensions:void 0}})}l(Ve,"extractErrors");function k(d,e=!1){if(!d||typeof d!="object")return{name:typeof d,message:"Non-object value thrown; contents withheld",variables:"[REDACTED]"};const t=d,r=typeof t.response?.status=="number"?t.response.status:void 0,s=Ve(t.response?.errors),n=s?.[0]?.extensions?.code;return{name:typeof t.name=="string"?t.name:"Error",message:_e(s,r),status:r,errors:s,code:typeof n=="string"?n:void 0,query:typeof t.request?.query=="string"?t.request.query:void 0,stackFrames:typeof t.stack=="string"?Qe(t.stack):void 0,variables:e?t.request?.variables:"[REDACTED]",variableShape:t.request?.variables===void 0?void 0:V(t.request.variables)}}l(k,"SanitizeGraphQLError");const M=new A,ke=c`subscription RemoteOperationProgress($channelId: ID!) {
|
|
313
313
|
RemoteOperationProgress(channelId: $channelId) {
|
|
314
314
|
ChannelId
|
|
315
315
|
ProgressJSON
|
|
@@ -372,7 +372,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
`,a=(await this.ExecuteGQL(s,{input:r}))?.RunQueriesWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map(o=>{if((o.status==="stale"||o.status==="no_validation")&&o.Results){const m=JSON.parse(o.Results);return{queryIndex:o.queryIndex,queryId:o.queryId,status:o.status,results:m,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}return{queryIndex:o.queryIndex,queryId:o.queryId,status:o.status,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.errorMessage}}catch(r){return y(`Error in RunQueriesWithCacheCheck: ${r}`),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async InternalRunView(e,t){try{let r="",s="";if(e){const n={};let a,i;if(e.ViewEntity)i=e.ViewEntity,a=i.Entity;else{const{entityName:I,v:
|
|
375
|
+
`,a=(await this.ExecuteGQL(s,{input:r}))?.RunQueriesWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map(o=>{if((o.status==="stale"||o.status==="no_validation")&&o.Results){const m=JSON.parse(o.Results);return{queryIndex:o.queryIndex,queryId:o.queryId,status:o.status,results:m,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}return{queryIndex:o.queryIndex,queryId:o.queryId,status:o.status,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.errorMessage}}catch(r){return y(`Error in RunQueriesWithCacheCheck: ${r}`),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async InternalRunView(e,t){try{let r="",s="";if(e){const n={};let a,i;if(e.ViewEntity)i=e.ViewEntity,a=i.Entity;else{const{entityName:I,v:E}=await this.getEntityNameAndUserView(e,t);i=E,a=I}const o=this.EntityByName(a);if(!o)throw new Error(`Entity ${a} not found in metadata`);let m=!1;const u=T(o);e.ViewID?(r=`Run${u}ViewByID`,s="RunViewByIDInput",n.ViewID=e.ViewID):e.ViewName?(r=`Run${u}ViewByName`,s="RunViewByNameInput",n.ViewName=e.ViewName):(m=!0,r=`Run${u}DynamicView`,s="RunDynamicViewInput",n.EntityName=e.EntityName),n.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",n.OrderBy=e.OrderBy?e.OrderBy:"",n.UserSearchString=e.UserSearchString?e.UserSearchString:"",n.Fields=e.Fields,n.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,e.MaxRows!==void 0&&(n.MaxRows=e.MaxRows),e.StartRow!==void 0&&(n.StartRow=e.StartRow),n.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,n.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(n.AuditLogDescription=e.AuditLogDescription),e.BypassCache!==void 0&&(n.BypassCache=e.BypassCache),e.DataSource!==void 0&&(n.DataSource=e.DataSource),m||(n.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",n.ExcludeDataFromAllPriorViewRuns=e.ExcludeDataFromAllPriorViewRuns?e.ExcludeDataFromAllPriorViewRuns:!1,n.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",n.SaveViewResults=e.SaveViewResults?e.SaveViewResults:!1),e.Aggregates&&e.Aggregates.length>0&&(n.Aggregates=e.Aggregates.map(I=>({expression:I.expression,alias:I.alias})));const S=this.getViewRunTimeFieldList(o,i,e,m),h=e.Aggregates&&e.Aggregates.length>0?`
|
|
376
376
|
AggregateResults {
|
|
377
377
|
alias
|
|
378
378
|
expression
|
|
@@ -393,7 +393,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
393
393
|
Success
|
|
394
394
|
ErrorMessage${h}
|
|
395
395
|
}
|
|
396
|
-
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(g,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const
|
|
396
|
+
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(g,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const E=p[r].Results;if(E&&E.length>0){const D=o.Fields.filter(C=>C.CodeName!==C.Name&&C.CodeName!==void 0);E.forEach(C=>{this.ConvertBackToMJFields(C),D.forEach(L=>{C[L.Name]=C[L.CodeName]})})}return p[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw y(r),r}}async InternalRunViews(e,t){try{let r=[],s=[],n=[];for(const u of e){let S="",h="";const g={};let p=null,I=null;if(u.ViewEntity)I=u.ViewEntity,p=I.Get("Entity");else{const{entityName:C,v:L}=await this.getEntityNameAndUserView(u,t);I=L,p=C}const E=this.EntityByName(p);if(!E)throw new Error(`Entity ${p} not found in metadata`);s.push(E);let R=!1;const D=T(E);u.ViewID?(S=`Run${D}ViewByID`,h="RunViewByIDInput",g.ViewID=u.ViewID):u.ViewName?(S=`Run${D}ViewByName`,h="RunViewByNameInput",g.ViewName=u.ViewName):(R=!0,S=`Run${D}DynamicView`,h="RunDynamicViewInput",g.EntityName=u.EntityName),g.ExtraFilter=u.ExtraFilter||"",g.OrderBy=u.OrderBy||"",g.UserSearchString=u.UserSearchString||"",g.Fields=u.Fields,g.IgnoreMaxRows=u.IgnoreMaxRows||!1,u.MaxRows!==void 0&&(g.MaxRows=u.MaxRows),u.StartRow!==void 0&&(g.StartRow=u.StartRow),u.AfterKey&&(g.AfterKey={KeyValuePairs:u.AfterKey.KeyValuePairs}),g.ForceAuditLog=u.ForceAuditLog||!1,g.ResultType=u.ResultType||"simple",u.AuditLogDescription&&u.AuditLogDescription.length>0&&(g.AuditLogDescription=u.AuditLogDescription),u.BypassCache!==void 0&&(g.BypassCache=u.BypassCache),u.DataSource!==void 0&&(g.DataSource=u.DataSource),R||(g.ExcludeUserViewRunID=u.ExcludeUserViewRunID||"",g.ExcludeDataFromAllPriorViewRuns=u.ExcludeDataFromAllPriorViewRuns||!1,g.OverrideExcludeFilter=u.OverrideExcludeFilter||"",g.SaveViewResults=u.SaveViewResults||!1),u.Aggregates&&u.Aggregates.length>0&&(g.Aggregates=u.Aggregates.map(C=>({expression:C.expression,alias:C.alias}))),r.push(g),n.push(...this.getViewRunTimeFieldList(E,I,u,R))}const i=e.some(u=>u.Aggregates&&u.Aggregates.length>0)?`
|
|
397
397
|
AggregateResults {
|
|
398
398
|
alias
|
|
399
399
|
expression
|
|
@@ -457,7 +457,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
`,a=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,m)=>{const u=e[m];if(o.status==="differential"&&o.differentialData){const S=o.differentialData.updatedRows.map(h=>{const g=JSON.parse(h.Data);return this.ConvertBackToMJFields(g),g});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:S,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const S=o.Results.map(g=>{const p=JSON.parse(g.Data);return this.ConvertBackToMJFields(p),p}),h=o.aggregateResults?.map(g=>({expression:g.expression,alias:g.alias,value:g.value!==void 0&&g.value!==null?JSON.parse(g.value):null,error:g.error}));return{viewIndex:o.viewIndex,status:o.status,results:S,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage,aggregateResults:h}}return{viewIndex:o.viewIndex,status:o.status,results:void 0,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.errorMessage}}catch(r){return y(r),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await X.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await X.GetViewEntityByName(e.ViewName,t),r=s.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:r,v:s}}getViewRunTimeFieldList(e,t,r,s){const n=[];if(r.Fields){for(const a of e.PrimaryKeys)r.Fields.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(
|
|
460
|
+
`,a=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,m)=>{const u=e[m];if(o.status==="differential"&&o.differentialData){const S=o.differentialData.updatedRows.map(h=>{const g=JSON.parse(h.Data);return this.ConvertBackToMJFields(g),g});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:S,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const S=o.Results.map(g=>{const p=JSON.parse(g.Data);return this.ConvertBackToMJFields(p),p}),h=o.aggregateResults?.map(g=>({expression:g.expression,alias:g.alias,value:g.value!==void 0&&g.value!==null?JSON.parse(g.value):null,error:g.error}));return{viewIndex:o.viewIndex,status:o.status,results:S,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage,aggregateResults:h}}return{viewIndex:o.viewIndex,status:o.status,results:void 0,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.errorMessage}}catch(r){return y(r),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await X.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await X.GetViewEntityByName(e.ViewName,t),r=s.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:r,v:s}}getViewRunTimeFieldList(e,t,r,s){const n=[];if(r.Fields){for(const a of e.PrimaryKeys)r.Fields.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(M.MapFieldName(a.Name));r.Fields.forEach(a=>{n.push(M.MapFieldName(a))})}else if(s)e.Fields.forEach(a=>{a.IsBinaryFieldType||n.push(M.MapFieldName(a.CodeName))});else{for(const a of e.PrimaryKeys)n.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(M.MapFieldName(a.Name));t.Columns.forEach(a=>{a.hidden===!1&&!n.find(i=>i.trim().toLowerCase()===a.EntityField?.Name.trim().toLowerCase())&&a.EntityField&&n.push(M.MapFieldName(a.EntityField.CodeName))})}return n}get ProviderType(){return ge.Network}async GetRecordChanges(e,t){try{const r={EntityName:"MJ: Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},s=await this.RunView(r);return s?s.Results.sort((n,a)=>n.ChangedAt>a.ChangedAt?-1:1):null}catch(r){throw y(r),r}}async GetRecordDependencies(e,t){try{const r=c`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
461
461
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
462
462
|
EntityName
|
|
463
463
|
RelatedEntityName
|
|
@@ -532,32 +532,32 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
532
532
|
Message
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
|
-
}`,a={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(o=>({FieldName:o.FieldName,Value:o.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(o=>o.Copy())};return(await this.ExecuteGQL(n,{request:a}))?.MergeRecords}catch(n){return y(n),{Success:!1,OverallStatus:n&&n.message?n.message:n,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){if(r?.IsParentEntitySave){const n=new
|
|
536
|
-
${e.Fields.map(g=>
|
|
535
|
+
}`,a={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(o=>({FieldName:o.FieldName,Value:o.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(o=>o.Copy())};return(await this.ExecuteGQL(n,{request:a}))?.MergeRecords}catch(n){return y(n),{Success:!1,OverallStatus:n&&n.message?n.message:n,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){if(r?.IsParentEntitySave){const n=new Q;return n.StartedAt=new Date,n.EndedAt=new Date,n.Type=e.IsSaved?"update":"create",n.Success=!0,n.NewValues=e.GetAll(),e.RegisterResultHistoryEntry(n),n.NewValues}const s=new Q;try{e.RegisterTransactionPreprocessing();const n={input:{}},a=e.IsSaved?"Update":"Create";s.StartedAt=new Date,s.Type=e.IsSaved?"update":"create",s.OriginalValues=e.Fields.map(g=>({FieldName:g.CodeName,Value:g.Value})),e.RegisterResultHistoryEntry(s);const i=T(e.EntityInfo),o=`${a}${i}`,m=e.Fields.filter(g=>!g.ReadOnly||g.IsPrimaryKey&&e.IsSaved),u=` ${o}(input: $input) {
|
|
536
|
+
${e.Fields.map(g=>M.MapFieldName(g.CodeName)).join(`
|
|
537
537
|
`)}
|
|
538
538
|
}`,S=c`mutation ${a}${i} ($input: ${o}Input!) {
|
|
539
539
|
${u}
|
|
540
540
|
}
|
|
541
|
-
`;for(let g=0;g<m.length;g++){const p=m[g];let I=e.Get(p.Name);if(I)switch(p.EntityFieldInfo.TSType){case N.Date:I=I.getTime();break;case N.Boolean:typeof I!="boolean"&&(I=parseInt(I)!==0);break;case N.Number:if(typeof I!="number"){const
|
|
541
|
+
`;for(let g=0;g<m.length;g++){const p=m[g];let I=e.Get(p.Name);if(I)switch(p.EntityFieldInfo.TSType){case N.Date:I=I.getTime();break;case N.Boolean:typeof I!="boolean"&&(I=parseInt(I)!==0);break;case N.Number:if(typeof I!="number"){const E=Number(I);isNaN(E)||(I=E)}break}I===null&&p.EntityFieldInfo.AllowsNull===!1&&(p.EntityFieldInfo.DefaultValue!==null?I=p.EntityFieldInfo.DefaultValue:p.FieldType===N.Number||p.FieldType===N.Boolean?I=0:I=""),n.input[M.MapFieldName(p.CodeName)]=I}const h=e.RestoreContext;if(h&&(n.input.RestoreContext___={SourceChangeID:h.SourceChangeID,Reason:h.Reason}),a.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const g=[];e.Fields.forEach(p=>{let I=null;p.OldValue!==null&&p.OldValue!==void 0&&(p.EntityFieldInfo.TSType===N.Date?I=p.OldValue.getTime().toString():p.EntityFieldInfo.TSType===N.Boolean?I=p.OldValue===!0?"1":"0":typeof p.OldValue!="string"?I=p.OldValue.toString():I=p.OldValue),g.push({Key:M.MapFieldName(p.CodeName),Value:I})}),n.input.OldValues___=g}if(e.TransactionGroup){const g=[{varName:"input",inputType:o+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new J(e,s.Type==="create"?"Create":"Update",u,n,{mutationName:o,mutationInputTypes:g},(p,I)=>{s.EndedAt=new Date,I&&p?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(p)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const g=await this.ExecuteGQL(S,n);if(g&&g[o])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(g[o]),s.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(n){return s.Success=!1,s.EndedAt=new Date,s.Message=n.response?.errors?.length>0?n.response.errors[0].message:n.message,y(n),null}}async Load(e,t,r=null,s){try{const n={};let a="",i="";for(let h=0;h<t.KeyValuePairs.length;h++){const g=e.Fields.find(R=>R.Name.trim().toLowerCase()===t.KeyValuePairs[h].FieldName.trim().toLowerCase()).EntityFieldInfo,p=t.GetValueByIndex(h),I=g.GraphQLType;i.length>0&&(i+=", "),i+=`$${g.CodeName}: ${I}!`,a.length>0&&(a+=", ");const E=g.CodeName.startsWith("__mj_")?g.CodeName.replace("__mj_","_mj__"):g.CodeName;if(a+=`${E}: $${g.CodeName}`,g.TSType===N.Number){if(isNaN(t.GetValueByIndex(h)))throw new Error(`Primary Key value ${p} (${g.Name}) is not a valid number`);n[g.CodeName]=parseInt(p)}else n[g.CodeName]=p}const o=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",m=T(e.EntityInfo),u=c`query Single${m}${o.length>0?"Full":""} (${i}) {
|
|
542
542
|
${m}(${a}) {
|
|
543
543
|
${e.Fields.filter(h=>!h.EntityFieldInfo.IsBinaryFieldType).map(h=>h.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?h.CodeName.replace("__mj_","_mj__"):h.CodeName).join(`
|
|
544
544
|
`)}
|
|
545
545
|
${o}
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
`,S=await this.ExecuteGQL(u,n);return S&&S[m]?this.ConvertBackToMJFields(S[m]):null}catch(n){return y(n),null}}ConvertBackToMJFields(e){return
|
|
548
|
+
`,S=await this.ExecuteGQL(u,n);return S&&S[m]?this.ConvertBackToMJFields(S[m]):null}catch(n){return y(n),null}}ConvertBackToMJFields(e){return M.ReverseMapFields(e),e}getRelatedEntityString(e,t){let r="";for(let s=0;s<e.RelatedEntities.length;s++)if(t.indexOf(e.RelatedEntities[s].RelatedEntity)>=0){const n=e.RelatedEntities[s],a=this.EntityByID(n.RelatedEntityID);let i="";n.Type.toLowerCase().trim()==="many to many"?i=`${n.RelatedEntityCodeName}_${n.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${n.RelatedEntityCodeName}_${n.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
|
|
549
549
|
${i} {
|
|
550
550
|
${a.Fields.map(o=>o.CodeName).join(`
|
|
551
551
|
`)}
|
|
552
552
|
}
|
|
553
|
-
`}return r}async Delete(e,t,r){const s=new
|
|
554
|
-
`),m+=`${
|
|
553
|
+
`}return r}async Delete(e,t,r){const s=new Q;try{e.RegisterTransactionPreprocessing(),s.StartedAt=new Date,s.Type="delete",s.OriginalValues=e.Fields.map(p=>({FieldName:p.CodeName,Value:p.Value})),e.RegisterResultHistoryEntry(s);const n={},a=[];let i="",o="",m="";for(let p of e.PrimaryKey.KeyValuePairs){const I=e.Fields.find(R=>R.Name.trim().toLowerCase()===p.FieldName.trim().toLowerCase());n[I.CodeName]=I.Value,a.push({varName:I.CodeName,inputType:I.EntityFieldInfo.GraphQLType+"!"});const E=I.CodeName.startsWith("__mj_")?I.CodeName.replace("__mj_","_mj__"):I.CodeName;i.length>0&&(i+=", "),i+=`${E}: $${I.CodeName}`,o.length>0&&(o+=", "),o+=`$${I.CodeName}: ${I.EntityFieldInfo.GraphQLType}!`,m.length>0&&(m+=`
|
|
554
|
+
`),m+=`${E}`}a.push({varName:"options___",inputType:"DeleteOptionsInput!"}),n.options___={SkipEntityAIActions:t?.SkipEntityAIActions??!1,SkipEntityActions:t?.SkipEntityActions??!1,ReplayOnly:t?.ReplayOnly??!1,IsParentEntityDelete:t?.IsParentEntityDelete??!1,SkipRecordChanges:t?.SkipRecordChanges??!1};const S="Delete"+T(e.EntityInfo),h=c`${S}(${i}, options___: $options___) {
|
|
555
555
|
${m}
|
|
556
556
|
}
|
|
557
557
|
`,g=c`mutation ${S} (${o}, $options___: DeleteOptionsInput!) {
|
|
558
558
|
${h}
|
|
559
559
|
}
|
|
560
|
-
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new J(e,"Delete",h,n,{mutationName:S,mutationInputTypes:a},(p,I)=>{if(s.EndedAt=new Date,I&&p){let
|
|
560
|
+
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new J(e,"Delete",h,n,{mutationName:S,mutationInputTypes:a},(p,I)=>{if(s.EndedAt=new Date,I&&p){let E=!0;for(const R of e.PrimaryKey.KeyValuePairs)R.Value!==p[R.FieldName]&&(E=!1);E?s.Success=!0:(s.Success=!1,s.Message="Transaction failed to commit")}else s.Success=!1,s.Message="Transaction failed to commit"})),!0;{const p=await this.ExecuteGQL(g,n);if(p&&p[S]){const I=p[S];for(let E of e.PrimaryKey.KeyValuePairs){let R=I[E.FieldName],D=E.Value;if(typeof D=="number"&&(D=D.toString()),typeof R=="number"&&(R=R.toString()),D!==R)throw new Error(`Primary key value mismatch in server Delete response. Field: ${E.FieldName}, Original: ${D}, Returned: ${R}`)}return s.Success=!0,s.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(n){return s.EndedAt=new Date,s.Success=!1,s.Message=n.response?.errors?.length>0?n.response.errors[0].message:n.message,y(n),!1}}async GetDatasetByName(e,t){const r=c`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
|
|
561
561
|
GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
|
|
562
562
|
DatasetID
|
|
563
563
|
DatasetName
|
|
@@ -683,7 +683,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
683
683
|
OriginSessionID
|
|
684
684
|
RecordData
|
|
685
685
|
}
|
|
686
|
-
}`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:l(r=>{const s=r?.cacheInvalidation;if(!s)return;if(s.OriginSessionID&&s.OriginSessionID===this.sessionId){f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${s.EntityName}" (action: ${s.Action})`);return}f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Cache invalidation received: ${s.Action} for "${s.EntityName}" from server ${s.SourceServerID?.substring(0,8)||"unknown"}`);const n={type:"remote-invalidate",entityName:s.EntityName,baseEntity:null,provider:this,payload:{primaryKeyValues:s.PrimaryKeyValues,action:s.Action,sourceServerId:s.SourceServerID,timestamp:s.Timestamp,recordData:s.RecordData}};H.Instance.RaiseEvent({event:z.ComponentEvent,eventCode:Ie.BaseEventCode,args:n,component:this})},"next"),error:l(r=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",r),this._cacheInvalidationSubscription=null},"error"),complete:l(()=>{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;const s=`query FindISAChildEntity($EntityName: String!, $RecordID: String!) {
|
|
686
|
+
}`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:l(r=>{const s=r?.cacheInvalidation;if(!s)return;if(s.OriginSessionID&&s.OriginSessionID===this.sessionId){f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${s.EntityName}" (action: ${s.Action})`);return}f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Cache invalidation received: ${s.Action} for "${s.EntityName}" from server ${s.SourceServerID?.substring(0,8)||"unknown"}`);const n={type:"remote-invalidate",entityName:s.EntityName,baseEntity:null,provider:this,payload:{primaryKeyValues:s.PrimaryKeyValues,action:s.Action,sourceServerId:s.SourceServerID,timestamp:s.Timestamp,recordData:s.RecordData}};H.Instance.RaiseEvent({event:z.ComponentEvent,eventCode:Ie.BaseEventCode,args:n,component:this})},"next"),error:l(r=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",r),this._cacheInvalidationSubscription=null},"error"),complete:l(()=>{console.log("[GraphQLDataProvider] Cache invalidation subscription completed, will re-establish on next WebSocket creation"),this._cacheInvalidationSubscription=null},"complete")})}static{this.ClientMemberRefreshWindowMinMs=15e3}static{this.ClientMemberRefreshWindowJitterMs=3e4}get MetadataMemberRefreshDelayMs(){return f.ClientMemberRefreshWindowMinMs+Math.random()*f.ClientMemberRefreshWindowJitterMs}get MetadataMemberRefreshRearmsOnNewEvents(){return!1}async RefreshAfterMetadataMemberChange(){return this.RefreshIfNeeded(void 0,!0)}UnsubscribeFromCacheInvalidation(){this.CancelPendingMetadataMemberRefresh(),this._cacheInvalidationSubscription&&(this._cacheInvalidationSubscription.unsubscribe(),this._cacheInvalidationSubscription=null)}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;const s=`query FindISAChildEntity($EntityName: String!, $RecordID: String!) {
|
|
687
687
|
FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {
|
|
688
688
|
Success
|
|
689
689
|
ChildEntityName
|
|
@@ -695,7 +695,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
695
695
|
ChildEntityNames
|
|
696
696
|
ErrorMessage
|
|
697
697
|
}
|
|
698
|
-
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(a=>({ChildEntityName:a})):[]}catch(n){return y(`FindISAChildEntities failed for ${e.Name}: ${n}`),[]}}}async function qe(d){const e=new f;return
|
|
698
|
+
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(a=>({ChildEntityName:a})):[]}catch(n){return y(`FindISAChildEntities failed for ${e.Name}: ${n}`),[]}}}async function qe(d){const e=new f;return Re(e),await e.Config(d),await e.preValidateAndRefresh(),H.Instance.RaiseEvent({event:z.LoggedIn,eventCode:null,component:this,args:null}),await Ee.Instance.Startup(),e}l(qe,"setupGraphQLClient");class Ke{static{l(this,"SyncRolesAndUsersResult")}}class Be{static{l(this,"RoleInput")}}class je{static{l(this,"UserInput")}}class Je{static{l(this,"RolesAndUsersInput")}}var oe=(d=>(d.Create="Create",d.Update="Update",d.CreateOrUpdate="CreateOrUpdate",d.Delete="Delete",d.DeleteWithFilter="DeleteWithFilter",d))(oe||{});class We{static{l(this,"ActionItemInput")}}class He{static{l(this,"SyncDataResult")}constructor(){this.Results=[]}}class ze{static{l(this,"ActionItemOutput")}}const ie=`Success
|
|
699
699
|
ErrorMessage
|
|
700
700
|
Query {
|
|
701
701
|
ID
|
|
@@ -915,7 +915,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
915
915
|
ID
|
|
916
916
|
Name
|
|
917
917
|
}
|
|
918
|
-
}`,s={ID:e};t!==void 0&&(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.DeleteQueryExtended?n.DeleteQueryExtended:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){let s="";if(r instanceof Error){if(s=r.message,"cause"in r&&r.cause){const n=r.cause;s+=` | Cause: ${n.message||n}`,"code"in n&&(s+=` | Code: ${n.code}`)}if("response"in r){const n=r.response;n?.status&&(s+=` | HTTP Status: ${n.status}`),n?.errors&&(s+=` | GraphQL Errors: ${JSON.stringify(n.errors)}`)}r.stack&&console.error("DeleteQuery stack trace:",r.stack)}else s=String(r);return y(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${s}`),{Success:!1,ErrorMessage:s}}}async RunAIPrompt(e){try{const t=c`
|
|
918
|
+
}`,s={ID:e};t!==void 0&&(s.options={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1,SkipRecordChanges:t.SkipRecordChanges??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQueryExtended?n.DeleteQueryExtended:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){let s="";if(r instanceof Error){if(s=r.message,"cause"in r&&r.cause){const n=r.cause;s+=` | Cause: ${n.message||n}`,"code"in n&&(s+=` | Code: ${n.code}`)}if("response"in r){const n=r.response;n?.status&&(s+=` | HTTP Status: ${n.status}`),n?.errors&&(s+=` | GraphQL Errors: ${JSON.stringify(n.errors)}`)}r.stack&&console.error("DeleteQuery stack trace:",r.stack)}else s=String(r);return y(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${s}`),{Success:!1,ErrorMessage:s}}}async RunAIPrompt(e){try{const t=c`
|
|
919
919
|
query RunAIPromptSystemUser(
|
|
920
920
|
$promptId: String!,
|
|
921
921
|
$data: String,
|
|
@@ -1184,28 +1184,28 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
1186
|
${G}
|
|
1187
|
-
`,r=await this.dataProvider.ExecuteGQL(t,{input:{TargetListId:e.Delta.TargetListId,EntityName:e.Delta.EntityName,ToAdd:e.Delta.ToAdd,ToRemove:e.Delta.ToRemove,Unchanged:e.Delta.Unchanged,AddCount:e.Delta.Counts.Add,RemoveCount:e.Delta.Counts.Remove,UnchangedCount:e.Delta.Counts.Unchanged,SourceTotal:e.Delta.Counts.SourceTotal,TargetTotal:e.Delta.Counts.TargetTotal,DeltaToken:e.Delta.DeltaToken,ConfirmDrops:e.ConfirmDrops}});return
|
|
1187
|
+
`,r=await this.dataProvider.ExecuteGQL(t,{input:{TargetListId:e.Delta.TargetListId,EntityName:e.Delta.EntityName,ToAdd:e.Delta.ToAdd,ToRemove:e.Delta.ToRemove,Unchanged:e.Delta.Unchanged,AddCount:e.Delta.Counts.Add,RemoveCount:e.Delta.Counts.Remove,UnchangedCount:e.Delta.Counts.Unchanged,SourceTotal:e.Delta.Counts.SourceTotal,TargetTotal:e.Delta.Counts.TargetTotal,DeltaToken:e.Delta.DeltaToken,ConfirmDrops:e.ConfirmDrops}});return U(r?.ApplyListDelta)}async MaterializeFromView(e,t){const r=c`
|
|
1188
1188
|
mutation MaterializeListFromView($viewId: String!, $options: MaterializeOptionsInput!) {
|
|
1189
1189
|
MaterializeListFromView(viewId: $viewId, options: $options) {
|
|
1190
1190
|
...ApplyResultFields
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
1193
|
${G}
|
|
1194
|
-
`,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,options:{ListName:t.ListName,CategoryId:t.CategoryId,Description:t.Description,RememberLineage:t.RememberLineage,UseSnapshot:t.UseSnapshot,RefreshMode:t.RefreshMode}});return
|
|
1194
|
+
`,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,options:{ListName:t.ListName,CategoryId:t.CategoryId,Description:t.Description,RememberLineage:t.RememberLineage,UseSnapshot:t.UseSnapshot,RefreshMode:t.RefreshMode}});return U(s?.MaterializeListFromView)}async AddViewResultsToList(e,t){const r=c`
|
|
1195
1195
|
mutation AddViewResultsToList($viewId: String!, $listId: String!) {
|
|
1196
1196
|
AddViewResultsToList(viewId: $viewId, listId: $listId) {
|
|
1197
1197
|
...ApplyResultFields
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
1200
|
${G}
|
|
1201
|
-
`,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,listId:t});return
|
|
1201
|
+
`,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,listId:t});return U(s?.AddViewResultsToList)}async RefreshFromSource(e){const t=c`
|
|
1202
1202
|
mutation RefreshListFromSource($listId: String!, $mode: String!, $confirmDrops: Boolean!) {
|
|
1203
1203
|
RefreshListFromSource(listId: $listId, mode: $mode, confirmDrops: $confirmDrops) {
|
|
1204
1204
|
...ApplyResultFields
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
1207
|
${G}
|
|
1208
|
-
`,r=await this.dataProvider.ExecuteGQL(t,{listId:e.ListId,mode:e.Mode,confirmDrops:e.ConfirmDrops});return
|
|
1208
|
+
`,r=await this.dataProvider.ExecuteGQL(t,{listId:e.ListId,mode:e.Mode,confirmDrops:e.ConfirmDrops});return U(r?.RefreshListFromSource)}async ComposeLists(e){const t=c`
|
|
1209
1209
|
mutation ComposeLists($input: ComposeListsInput!) {
|
|
1210
1210
|
ComposeLists(input: $input) {
|
|
1211
1211
|
...ListDeltaFields
|
|
@@ -1320,7 +1320,7 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
1320
1320
|
Message
|
|
1321
1321
|
PermissionID
|
|
1322
1322
|
}
|
|
1323
|
-
`;function nt(d){return d.kind==="user"?{Kind:"user",UserID:d.userId}:{Kind:"role",RoleID:d.roleId}}l(nt,"serializeShareTarget");function q(d){if(!d||typeof d!="object")throw new Error("GraphQLListsClient: empty/invalid ShareResult response");const e=d;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,PermissionID:e.PermissionID??void 0}}l(q,"parseShareResult");function at(d){const e=d,t=e.Target.Kind==="user"?{kind:"user",userId:e.Target.UserID}:{kind:"role",roleId:e.Target.RoleID};return{PermissionID:e.PermissionID,ListID:e.ListID,Target:t,PermissionLevel:e.PermissionLevel,Status:e.Status,SharedByUserID:e.SharedByUserID??null,CreatedAt:new Date(e.CreatedAt)}}l(at,"parseShareSummary");function K(d){switch(d.kind){case"list":return{Kind:"list",ListID:d.listId};case"view":return{Kind:"view",ViewID:d.viewId};case"adhoc":return{Kind:"adhoc",EntityName:d.entityName,ExtraFilter:d.extraFilter}}}l(K,"serializeListSource");function ue(d){if(!d||typeof d!="object")throw new Error("GraphQLListsClient: empty/invalid ListDelta response from server");const e=d;return{TargetListId:e.TargetListId,EntityName:e.EntityName,ToAdd:e.ToAdd,ToRemove:e.ToRemove,Unchanged:e.Unchanged,Counts:e.Counts,Warnings:e.Warnings.map(ot),DeltaToken:e.DeltaToken}}l(ue,"parseListDelta");function ot(d){let e;if(d.DetailsJSON)try{e=JSON.parse(d.DetailsJSON)}catch(t){y(`GraphQLListsClient: failed to parse warning details JSON: ${t}`)}return{Code:d.Code,Message:d.Message,Details:e}}l(ot,"parseWarning");function
|
|
1323
|
+
`;function nt(d){return d.kind==="user"?{Kind:"user",UserID:d.userId}:{Kind:"role",RoleID:d.roleId}}l(nt,"serializeShareTarget");function q(d){if(!d||typeof d!="object")throw new Error("GraphQLListsClient: empty/invalid ShareResult response");const e=d;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,PermissionID:e.PermissionID??void 0}}l(q,"parseShareResult");function at(d){const e=d,t=e.Target.Kind==="user"?{kind:"user",userId:e.Target.UserID}:{kind:"role",roleId:e.Target.RoleID};return{PermissionID:e.PermissionID,ListID:e.ListID,Target:t,PermissionLevel:e.PermissionLevel,Status:e.Status,SharedByUserID:e.SharedByUserID??null,CreatedAt:new Date(e.CreatedAt)}}l(at,"parseShareSummary");function K(d){switch(d.kind){case"list":return{Kind:"list",ListID:d.listId};case"view":return{Kind:"view",ViewID:d.viewId};case"adhoc":return{Kind:"adhoc",EntityName:d.entityName,ExtraFilter:d.extraFilter}}}l(K,"serializeListSource");function ue(d){if(!d||typeof d!="object")throw new Error("GraphQLListsClient: empty/invalid ListDelta response from server");const e=d;return{TargetListId:e.TargetListId,EntityName:e.EntityName,ToAdd:e.ToAdd,ToRemove:e.ToRemove,Unchanged:e.Unchanged,Counts:e.Counts,Warnings:e.Warnings.map(ot),DeltaToken:e.DeltaToken}}l(ue,"parseListDelta");function ot(d){let e;if(d.DetailsJSON)try{e=JSON.parse(d.DetailsJSON)}catch(t){y(`GraphQLListsClient: failed to parse warning details JSON: ${t}`)}return{Code:d.Code,Message:d.Message,Details:e}}l(ot,"parseWarning");function U(d){if(!d||typeof d!="object")throw new Error("GraphQLListsClient: empty/invalid ApplyResult response from server");const e=d;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,CreatedListId:e.CreatedListId??void 0,TargetListId:e.TargetListId??void 0,Counts:e.AddedCount!=null||e.RemovedCount!=null||e.FailedCount!=null?{Added:e.AddedCount??0,Removed:e.RemovedCount??0,Failed:e.FailedCount??0}:void 0,Errors:e.Errors??void 0}}l(U,"parseApplyResult");class it{static{l(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(t){return this.handleCreateAPIKeyError(t)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=c`
|
|
1324
1324
|
mutation CreateAPIKey($input: CreateAPIKeyInput!) {
|
|
1325
1325
|
CreateAPIKey(input: $input) {
|
|
1326
1326
|
Success
|
|
@@ -2018,5 +2018,5 @@ ${e.stackFrames}`:this.stack}}function ae(d){return d instanceof _?d:new _(k(d))
|
|
|
2018
2018
|
IntegrationGetConnectorCapabilities(companyIntegrationID: $companyIntegrationID) {
|
|
2019
2019
|
Success Message SupportsGet SupportsCreate SupportsUpdate SupportsDelete SupportsSearch
|
|
2020
2020
|
}
|
|
2021
|
-
}`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return y(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}export{We as ActionItemInput,ze as ActionItemOutput,ne as BrowserIndexedDBStorageProvider,re as BrowserStorageProviderBase,
|
|
2021
|
+
}`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return y(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}export{We as ActionItemInput,ze as ActionItemOutput,ne as BrowserIndexedDBStorageProvider,re as BrowserStorageProviderBase,A as FieldMapper,w as FireAndForgetHelper,Ye as GetDataOutput,te as GraphQLAIClient,rt as GraphQLActionClient,lt as GraphQLClassifyClient,ct as GraphQLClusterClient,yt as GraphQLComponentRegistryClient,f as GraphQLDataProvider,it as GraphQLEncryptionClient,gt as GraphQLFileStorageClient,pt as GraphQLIntegrationClient,st as GraphQLListsClient,ut as GraphQLLiveKitClient,Oe as GraphQLProviderConfigData,St as GraphQLSearchClient,Xe as GraphQLSystemUserClient,dt as GraphQLTestingClient,ee as GraphQLTransactionGroup,mt as GraphQLVersionHistoryClient,F as PACKAGE_VERSION,Be as RoleInput,Je as RolesAndUsersInput,_ as SafeGraphQLError,k as SanitizeGraphQLError,et as SimpleRemoteEntity,tt as SimpleRemoteEntityField,Ze as SimpleRemoteEntityOutput,oe as SyncDataAction,He as SyncDataResult,Ke as SyncRolesAndUsersResult,ae as ToSafeGraphQLError,je as UserInput,bt as gql,qe as setupGraphQLClient};
|
|
2022
2022
|
//# sourceMappingURL=index.mjs.map
|