@memberjunction/graphql-dataprovider 5.3.0 → 5.4.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.
- package/dist/index.cjs +184 -178
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +181 -73
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +181 -73
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +208 -202
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var j=Object.defineProperty;var p=(h,e)=>j(h,"name",{value:e,configurable:!0});import{gql as m,GraphQLClient as F}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as J,TransactionResult as W,LogError as c,LogStatus as L,LogErrorEx as A,ProviderBase as z,UserInfo as G,getGraphQLTypeNameBase as N,ProviderType as H,BaseEntityResult as T,EntityFieldTSType as P,TransactionItem as U,CompositeKey as X,UserRoleInfo as Y,InMemoryLocalStorageProvider as Z,ProviderConfigDataBase as ee,SetProvider as te,StartupManager as re,IsVerboseLoggingEnabled as se}from"@memberjunction/core";import{ViewInfo as V}from"@memberjunction/core-entities";import{Observable as M,Subject as ne,Subscription as oe}from"rxjs";import{createClient as ae}from"graphql-ws";import{v4 as ie}from"uuid";import{SafeJSONParse as $,MJGlobal as ue,MJEventType as ce}from"@memberjunction/global";import{openDB as le}from"@tempfix/idb";class b{static{p(this,"FieldMapper")}constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const t in e)t in this._fieldMap&&(e[this._fieldMap[t]]=e[t],delete e[t]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([t,r])=>r===e)?.[0]??e}ReverseMapFields(e){const t=Object.fromEntries(Object.entries(this._fieldMap).map(([r,s])=>[s,r]));for(const r in e)r in t&&(e[t[r]]=e[r],delete e[r]);return e}}class Q extends J{static{p(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=m`
|
|
2
2
|
mutation ExecuteTransactionGroup($group: TransactionInputType!) {
|
|
3
3
|
ExecuteTransactionGroup(group: $group) {
|
|
4
4
|
Success
|
|
@@ -6,7 +6,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
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,
|
|
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,o=[];for(let i=0;i<this.PendingTransactions.length;i++){const a=n.ResultsJSON[i],u=$(a),d=this.PendingTransactions[i];o.push(new W(d,u,u!==null))}return o}else throw new Error("Failed to execute transaction group")}}const de=900*1e3;class v{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}=v.createCompletionPromise();s=v.setupTimeout(i,e.timeoutMs,e.timeoutErrorMessage),r=v.subscribeToPubSub(e,o,s);const a=await v.executeMutation(e);if(!e.validateAck(a)){s&&clearTimeout(s);const u=a?.errorMessage??"Server rejected the request";return c(`[FireAndForget:${t}] Server rejected: ${u}`),e.createErrorResult(u)}return L(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await n}catch(n){throw s&&clearTimeout(s),c(`[FireAndForget:${t}] Error: ${n.message}`),n}finally{s&&clearTimeout(s),r&&r.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((s,n)=>{e=s,t=n}),resolve:e,reject:t}}static setupTimeout(e,t,r){const s=t??de,n=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(n))},s)}static subscribeToPubSub(e,t,r){const s=e.dataProvider.sessionId,n=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(s).subscribe(o=>{try{const i=JSON.parse(o);e.onMessage&&e.onMessage(i),e.isCompletionEvent(i)&&(clearTimeout(r),L(`[FireAndForget:${n}] Completion event received`),t(e.extractResult(i)))}catch(i){console.error(`[FireAndForget:${n}] Failed to parse PubSub message:`,i)}})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}}class _{static{p(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=m`
|
|
10
10
|
mutation RunAIPrompt(
|
|
11
11
|
$promptId: String!,
|
|
12
12
|
$data: String,
|
|
@@ -65,85 +65,87 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
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=JSON.parse(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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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=JSON.parse(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 c(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){try{const s=this.buildRunAIAgentMutation(),n=this.prepareAgentVariables(e,t,r);return n.fireAndForget=!0,await v.Execute({dataProvider:this._dataProvider,mutation:s,variables:n,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:p(o=>o?.success===!0,"validateAck"),isCompletionEvent:p(o=>this.isAgentCompletionEvent(o),"isCompletionEvent"),extractResult:p(o=>this.extractAgentResult(o),"extractResult"),onMessage:e.onProgress?o=>this.forwardAgentProgress(o,e.onProgress):void 0,createErrorResult:p(o=>this.createAgentErrorResult(o),"createErrorResult")})}catch(s){return this.handleAgentError(s)}}buildRunAIAgentMutation(){return m`
|
|
69
|
+
mutation RunAIAgent(
|
|
70
|
+
$agentId: String!,
|
|
71
|
+
$messages: String!,
|
|
72
|
+
$sessionId: String!,
|
|
73
|
+
$data: String,
|
|
74
|
+
$payload: String,
|
|
75
|
+
$templateData: String,
|
|
76
|
+
$lastRunId: String,
|
|
77
|
+
$autoPopulateLastRunPayload: Boolean,
|
|
78
|
+
$configurationId: String,
|
|
79
|
+
$conversationDetailId: String,
|
|
80
|
+
$createArtifacts: Boolean,
|
|
81
|
+
$createNotification: Boolean,
|
|
82
|
+
$sourceArtifactId: String,
|
|
83
|
+
$sourceArtifactVersionId: String,
|
|
84
|
+
$fireAndForget: Boolean
|
|
85
|
+
) {
|
|
86
|
+
RunAIAgent(
|
|
87
|
+
agentId: $agentId,
|
|
88
|
+
messages: $messages,
|
|
89
|
+
sessionId: $sessionId,
|
|
90
|
+
data: $data,
|
|
91
|
+
payload: $payload,
|
|
92
|
+
templateData: $templateData,
|
|
93
|
+
lastRunId: $lastRunId,
|
|
94
|
+
autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
|
|
95
|
+
configurationId: $configurationId,
|
|
96
|
+
conversationDetailId: $conversationDetailId,
|
|
97
|
+
createArtifacts: $createArtifacts,
|
|
98
|
+
createNotification: $createNotification,
|
|
99
|
+
sourceArtifactId: $sourceArtifactId,
|
|
100
|
+
sourceArtifactVersionId: $sourceArtifactVersionId,
|
|
101
|
+
fireAndForget: $fireAndForget
|
|
84
102
|
) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
data: $data,
|
|
90
|
-
payload: $payload,
|
|
91
|
-
templateData: $templateData,
|
|
92
|
-
lastRunId: $lastRunId,
|
|
93
|
-
autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
|
|
94
|
-
configurationId: $configurationId,
|
|
95
|
-
conversationDetailId: $conversationDetailId,
|
|
96
|
-
createArtifacts: $createArtifacts,
|
|
97
|
-
createNotification: $createNotification,
|
|
98
|
-
sourceArtifactId: $sourceArtifactId,
|
|
99
|
-
sourceArtifactVersionId: $sourceArtifactVersionId
|
|
100
|
-
) {
|
|
101
|
-
success
|
|
102
|
-
errorMessage
|
|
103
|
-
executionTimeMs
|
|
104
|
-
result
|
|
105
|
-
}
|
|
103
|
+
success
|
|
104
|
+
errorMessage
|
|
105
|
+
executionTimeMs
|
|
106
|
+
result
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
}
|
|
109
|
+
`}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),s}processAgentResult(e){return $(e)}handleAgentError(e){const r=e?.message||String(e);c(`Error running AI agent: ${r}`);const s=r.includes("Failed to fetch")||r.includes("NetworkError"),n=r.includes("timed out")||r.includes("timeout");let o;return s?o="Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":o=r,{success:!1,agentRun:void 0,errorMessage:o}}async RunAIAgentFromConversationDetail(e){try{const t=this.buildConversationDetailMutation(),r=this.prepareConversationDetailVariables(e);return await v.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:p(s=>s?.success===!0,"validateAck"),isCompletionEvent:p(s=>this.isConversationDetailCompletionEvent(s,e.conversationDetailId),"isCompletionEvent"),extractResult:p(s=>this.extractAgentResult(s),"extractResult"),onMessage:e.onProgress?s=>this.forwardConversationDetailProgress(s,e.onProgress):void 0,createErrorResult:p(s=>this.createAgentErrorResult(s),"createErrorResult")})}catch(t){return this.handleAgentError(t)}}buildConversationDetailMutation(){return m`
|
|
110
|
+
mutation RunAIAgentFromConversationDetail(
|
|
111
|
+
$conversationDetailId: String!,
|
|
112
|
+
$agentId: String!,
|
|
113
|
+
$sessionId: String!,
|
|
114
|
+
$maxHistoryMessages: Int,
|
|
115
|
+
$data: String,
|
|
116
|
+
$payload: String,
|
|
117
|
+
$lastRunId: String,
|
|
118
|
+
$autoPopulateLastRunPayload: Boolean,
|
|
119
|
+
$configurationId: String,
|
|
120
|
+
$createArtifacts: Boolean,
|
|
121
|
+
$createNotification: Boolean,
|
|
122
|
+
$sourceArtifactId: String,
|
|
123
|
+
$sourceArtifactVersionId: String,
|
|
124
|
+
$fireAndForget: Boolean
|
|
125
|
+
) {
|
|
126
|
+
RunAIAgentFromConversationDetail(
|
|
127
|
+
conversationDetailId: $conversationDetailId,
|
|
128
|
+
agentId: $agentId,
|
|
129
|
+
sessionId: $sessionId,
|
|
130
|
+
maxHistoryMessages: $maxHistoryMessages,
|
|
131
|
+
data: $data,
|
|
132
|
+
payload: $payload,
|
|
133
|
+
lastRunId: $lastRunId,
|
|
134
|
+
autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
|
|
135
|
+
configurationId: $configurationId,
|
|
136
|
+
createArtifacts: $createArtifacts,
|
|
137
|
+
createNotification: $createNotification,
|
|
138
|
+
sourceArtifactId: $sourceArtifactId,
|
|
139
|
+
sourceArtifactVersionId: $sourceArtifactVersionId,
|
|
140
|
+
fireAndForget: $fireAndForget
|
|
123
141
|
) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
maxHistoryMessages: $maxHistoryMessages,
|
|
129
|
-
data: $data,
|
|
130
|
-
payload: $payload,
|
|
131
|
-
lastRunId: $lastRunId,
|
|
132
|
-
autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
|
|
133
|
-
configurationId: $configurationId,
|
|
134
|
-
createArtifacts: $createArtifacts,
|
|
135
|
-
createNotification: $createNotification,
|
|
136
|
-
sourceArtifactId: $sourceArtifactId,
|
|
137
|
-
sourceArtifactVersionId: $sourceArtifactVersionId,
|
|
138
|
-
fireAndForget: $fireAndForget
|
|
139
|
-
) {
|
|
140
|
-
success
|
|
141
|
-
errorMessage
|
|
142
|
-
executionTimeMs
|
|
143
|
-
result
|
|
144
|
-
}
|
|
142
|
+
success
|
|
143
|
+
errorMessage
|
|
144
|
+
executionTimeMs
|
|
145
|
+
result
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
+
}
|
|
148
|
+
`}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.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}extractAgentResult(e){const t=e.data,r=t.result;return r?$(r):{success:t.success,agentRun:void 0}}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 s=e.data?.progress;s&&t({currentStep:s.currentStep,percentage:s.percentage,message:s.message,metadata:s})}createAgentErrorResult(e){return{success:!1,agentRun:void 0,errorMessage:e}}async ExecuteSimplePrompt(e){try{const t=m`
|
|
147
149
|
mutation ExecuteSimplePrompt(
|
|
148
150
|
$systemPrompt: String!,
|
|
149
151
|
$messages: String,
|
|
@@ -166,7 +168,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
166
168
|
executionTimeMs
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
|
-
`,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.ExecuteSimplePrompt)throw new Error("Invalid response from server");const n=s.ExecuteSimplePrompt;let
|
|
171
|
+
`,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.ExecuteSimplePrompt)throw new Error("Invalid response from server");const n=s.ExecuteSimplePrompt;let o;if(n.resultObject)try{o=JSON.parse(n.resultObject)}catch{o=n.resultObject}return{success:n.success,result:n.result,resultObject:o,modelName:n.modelName,error:n.error,executionTimeMs:n.executionTimeMs}}catch(t){const r=t;return c(`Error executing simple prompt: ${r}`),{success:!1,modelName:"Unknown",error:r.message||"Unknown error occurred"}}}async EmbedText(e){try{const t=m`
|
|
170
172
|
mutation EmbedText(
|
|
171
173
|
$textToEmbed: [String!]!,
|
|
172
174
|
$modelSize: String!
|
|
@@ -181,7 +183,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
181
183
|
error
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this._dataProvider.ExecuteGQL(t,s);if(!n?.EmbedText)throw new Error("Invalid response from server");const
|
|
186
|
+
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this._dataProvider.ExecuteGQL(t,s);if(!n?.EmbedText)throw new Error("Invalid response from server");const o=n.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?o.embeddings:o.embeddings[0],modelName:o.modelName,vectorDimensions:o.vectorDimensions,error:o.error}}catch(t){const r=t;return c(`Error generating embeddings: ${r}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}}const C="default";class O{static{p(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||C;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||C).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||C).set(e,t)}async Remove(e,t){this.getCategoryMap(t||C).delete(e)}async ClearCategory(e){const t=e||C;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||C);return t?Array.from(t.keys()):[]}}const ye="MJ_Metadata",me=3,q=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],k="Metadata_KVPairs";class K extends O{static{p(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=le(ye,me,{upgrade(e){try{e.objectStoreNames.contains(k)&&e.deleteObjectStore(k);for(const t of q)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(t){A({error:t,message:t?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{A({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return q.includes(t)}getStoreName(e){const t=e||C;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||C;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,n=this.getStoreName(r),o=this.getStoreKey(e,r),i=s.transaction(n,"readwrite");await i.objectStore(n).put(t,o),await i.done}catch(s){A({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),n=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(n)??null}catch(r){return A({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),o=r.transaction(s,"readwrite");await o.objectStore(s).delete(n),await o.done}catch(r){A({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||C,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}]:`,o=t.transaction("mj:default","readwrite"),i=o.objectStore("mj:default"),a=await i.getAllKeys();for(const u of a)typeof u=="string"&&u.startsWith(n)&&await i.delete(u);await o.done}}catch(t){A({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||C,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(u=>String(u));const a=`[${r}]:`;return i.map(u=>String(u)).filter(u=>u.startsWith(a)).map(u=>u.slice(a.length))}catch(t){return A({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}}class ge extends ee{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,n,o,i,a,u){super({Token:e,URL:t,WSURL:r,MJAPIKey:a,UserAPIKey:u,RefreshTokenFunction:s},n,o,i)}}class S extends z{static{p(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {
|
|
185
187
|
${this.userInfoString()}
|
|
186
188
|
MJUserRoles_UserIDArray {
|
|
187
189
|
${this.userRoleInfoString()}
|
|
@@ -189,7 +191,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
189
191
|
}
|
|
190
192
|
`,this._currentUserQuery=m`query CurrentUserAndRoles {
|
|
191
193
|
${this._innerCurrentUserQueryString}
|
|
192
|
-
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=1800*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=300*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=600*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,
|
|
194
|
+
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=1800*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=300*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=600*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,S._instance||(S._instance=this)}static get Instance(){return S._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new _(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return ie()}get LocalStoragePrefix(){if(this._configData===void 0||this._configData.URL===void 0)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)):(S.Instance._configData=e,S.Instance._sessionId===void 0&&(S.Instance._sessionId=await this.GetPreferredUUID(s)),S.Instance._client||(S.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,S.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await S.Instance.SaveStoredSessionID(S.Instance._sessionId),this._sessionId=S.Instance._sessionId,this._client=S.Instance._client),super.Config(e)}catch(n){throw c(n),n}}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(s=>this.ConvertBackToMJFields(s));return t.MJUserRoles_UserIDArray=r,new G(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=m`
|
|
193
195
|
query GetReportDataQuery ($ReportID: String!) {
|
|
194
196
|
GetReportData(ReportID: $ReportID) {
|
|
195
197
|
Success
|
|
@@ -204,25 +206,25 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
204
206
|
${this.QueryReturnFieldList}
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
|
-
`,n={SQL:e};r!==void 0&&(n.TimeoutSeconds=r);const
|
|
209
|
+
`,n={SQL:e};r!==void 0&&(n.TimeoutSeconds=r);const o=await this.ExecuteGQL(s,{input:n});return o?.ExecuteAdhocQuery?this.TransformQueryPayload(o.ExecuteAdhocQuery):{QueryID:"",QueryName:"Ad-Hoc Query",Success:!1,Results:[],RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Ad-hoc query execution failed \u2014 no response from server"}}async InternalRunQueries(e,t){const r=m`
|
|
208
210
|
query RunQueriesBatch($input: [RunQueryInput!]!) {
|
|
209
211
|
RunQueries(input: $input) {
|
|
210
212
|
${this.QueryReturnFieldList}
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
|
-
`,s=e.map(
|
|
215
|
+
`,s=e.map(o=>({QueryID:o.QueryID,QueryName:o.QueryName,CategoryID:o.CategoryID,CategoryPath:o.CategoryPath,Parameters:o.Parameters,MaxRows:o.MaxRows,StartRow:o.StartRow,ForceAuditLog:o.ForceAuditLog,AuditLogDescription:o.AuditLogDescription})),n=await this.ExecuteGQL(r,{input:s});return n&&n.RunQueries?n.RunQueries.map(o=>this.TransformQueryPayload(o)):[]}async RunQueryByID(e,t,r,s,n,o,i){const a=m`
|
|
214
216
|
query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
|
|
215
217
|
GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
216
218
|
${this.QueryReturnFieldList}
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
|
-
`,u={QueryID:e};t!==void 0&&(u.CategoryID=t),r!==void 0&&(u.CategoryPath=r),n!==void 0&&(u.Parameters=n),
|
|
221
|
+
`,u={QueryID:e};t!==void 0&&(u.CategoryID=t),r!==void 0&&(u.CategoryPath=r),n!==void 0&&(u.Parameters=n),o!==void 0&&(u.MaxRows=o),i!==void 0&&(u.StartRow=i);const d=await this.ExecuteGQL(a,u);if(d&&d.GetQueryData)return this.TransformQueryPayload(d.GetQueryData)}async RunQueryByName(e,t,r,s,n,o,i){const a=m`
|
|
220
222
|
query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
|
|
221
223
|
GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
222
224
|
${this.QueryReturnFieldList}
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
|
-
`,u={QueryName:e};t!==void 0&&(u.CategoryID=t),r!==void 0&&(u.CategoryPath=r),n!==void 0&&(u.Parameters=n),
|
|
227
|
+
`,u={QueryName:e};t!==void 0&&(u.CategoryID=t),r!==void 0&&(u.CategoryPath=r),n!==void 0&&(u.Parameters=n),o!==void 0&&(u.MaxRows=o),i!==void 0&&(u.StartRow=i);const d=await this.ExecuteGQL(a,u);if(d&&d.GetQueryDataByName)return this.TransformQueryPayload(d.GetQueryDataByName)}get QueryReturnFieldList(){return`
|
|
226
228
|
Success
|
|
227
229
|
QueryID
|
|
228
230
|
QueryName
|
|
@@ -231,7 +233,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
231
233
|
TotalRowCount
|
|
232
234
|
ExecutionTime
|
|
233
235
|
ErrorMessage
|
|
234
|
-
AppliedParameters`}TransformQueryPayload(e){try{return{QueryID:e.QueryID,QueryName:e.QueryName,Success:e.Success,Results:JSON.parse(e.Results),RowCount:e.RowCount,TotalRowCount:e.TotalRowCount,ExecutionTime:e.ExecutionTime,ErrorMessage:e.ErrorMessage,AppliedParameters:e.AppliedParameters?JSON.parse(e.AppliedParameters):void 0}}catch(t){return
|
|
236
|
+
AppliedParameters`}TransformQueryPayload(e){try{return{QueryID:e.QueryID,QueryName:e.QueryName,Success:e.Success,Results:JSON.parse(e.Results),RowCount:e.RowCount,TotalRowCount:e.TotalRowCount,ExecutionTime:e.ExecutionTime,ErrorMessage:e.ErrorMessage,AppliedParameters:e.AppliedParameters?JSON.parse(e.AppliedParameters):void 0}}catch(t){return c(`Error transforming query payload: ${t}`),null}}async RunQueriesWithCacheCheck(e,t){try{const r=e.map(a=>({params:{QueryID:a.params.QueryID||null,QueryName:a.params.QueryName||null,CategoryID:a.params.CategoryID||null,CategoryPath:a.params.CategoryPath||null,Parameters:a.params.Parameters||null,MaxRows:a.params.MaxRows??null,StartRow:a.params.StartRow??null,ForceAuditLog:a.params.ForceAuditLog||!1,AuditLogDescription:a.params.AuditLogDescription||null},cacheStatus:a.cacheStatus?{maxUpdatedAt:a.cacheStatus.maxUpdatedAt,rowCount:a.cacheStatus.rowCount}:null})),s=m`
|
|
235
237
|
query RunQueriesWithCacheCheckQuery($input: [RunQueryWithCacheCheckInput!]!) {
|
|
236
238
|
RunQueriesWithCacheCheck(input: $input) {
|
|
237
239
|
success
|
|
@@ -247,7 +249,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
|
-
`,
|
|
252
|
+
`,o=(await this.ExecuteGQL(s,{input:r}))?.RunQueriesWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map(a=>{if((a.status==="stale"||a.status==="no_validation")&&a.Results){const u=JSON.parse(a.Results);return{queryIndex:a.queryIndex,queryId:a.queryId,status:a.status,results:u,maxUpdatedAt:a.maxUpdatedAt,rowCount:a.rowCount,errorMessage:a.errorMessage}}return{queryIndex:a.queryIndex,queryId:a.queryId,status:a.status,maxUpdatedAt:a.maxUpdatedAt,rowCount:a.rowCount,errorMessage:a.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c(`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 o,i;if(e.ViewEntity)i=e.ViewEntity,o=i.Entity;else{const{entityName:g,v:I}=await this.getEntityNameAndUserView(e,t);i=I,o=g}const a=this.Entities.find(g=>g.Name===o);if(!a)throw new Error(`Entity ${o} not found in metadata`);let u=!1;const d=N(a);e.ViewID?(r=`Run${d}ViewByID`,s="RunViewByIDInput",n.ViewID=e.ViewID):e.ViewName?(r=`Run${d}ViewByName`,s="RunViewByNameInput",n.ViewName=e.ViewName):(u=!0,r=`Run${d}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),u||(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(g=>({expression:g.expression,alias:g.alias})));const f=this.getViewRunTimeFieldList(a,i,e,u),R=e.Aggregates&&e.Aggregates.length>0?`
|
|
251
253
|
AggregateResults {
|
|
252
254
|
alias
|
|
253
255
|
expression
|
|
@@ -266,16 +268,16 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
266
268
|
TotalRowCount
|
|
267
269
|
ExecutionTime
|
|
268
270
|
Success
|
|
269
|
-
ErrorMessage${
|
|
271
|
+
ErrorMessage${R}
|
|
270
272
|
}
|
|
271
|
-
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:
|
|
273
|
+
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:o,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const y=await this.ExecuteGQL(l,{input:n});if(y&&y[r]){const g=y[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:o,aggregateResultCount:g?.length||0,aggregateResults:g,aggregateExecutionTime:y[r].AggregateExecutionTime});const I=y[r].Results;if(I&&I.length>0){const w=a.Fields.filter(D=>D.CodeName!==D.Name&&D.CodeName!==void 0);I.forEach(D=>{this.ConvertBackToMJFields(D),w.forEach(x=>{D[x.Name]=D[x.CodeName]})})}return y[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw c(r),r}}async InternalRunViews(e,t){try{let r=[],s=[],n=[];for(const d of e){let f="",R="";const l={};let y=null,g=null;if(d.ViewEntity)g=d.ViewEntity,y=g.Get("Entity");else{const{entityName:D,v:x}=await this.getEntityNameAndUserView(d,t);g=x,y=D}const I=this.Entities.find(D=>D.Name===y);if(!I)throw new Error(`Entity ${y} not found in metadata`);s.push(I);let E=!1;const w=N(I);d.ViewID?(f=`Run${w}ViewByID`,R="RunViewByIDInput",l.ViewID=d.ViewID):d.ViewName?(f=`Run${w}ViewByName`,R="RunViewByNameInput",l.ViewName=d.ViewName):(E=!0,f=`Run${w}DynamicView`,R="RunDynamicViewInput",l.EntityName=d.EntityName),l.ExtraFilter=d.ExtraFilter||"",l.OrderBy=d.OrderBy||"",l.UserSearchString=d.UserSearchString||"",l.Fields=d.Fields,l.IgnoreMaxRows=d.IgnoreMaxRows||!1,d.MaxRows!==void 0&&(l.MaxRows=d.MaxRows),d.StartRow!==void 0&&(l.StartRow=d.StartRow),l.ForceAuditLog=d.ForceAuditLog||!1,l.ResultType=d.ResultType||"simple",d.AuditLogDescription&&d.AuditLogDescription.length>0&&(l.AuditLogDescription=d.AuditLogDescription),E||(l.ExcludeUserViewRunID=d.ExcludeUserViewRunID||"",l.ExcludeDataFromAllPriorViewRuns=d.ExcludeDataFromAllPriorViewRuns||!1,l.OverrideExcludeFilter=d.OverrideExcludeFilter||"",l.SaveViewResults=d.SaveViewResults||!1),d.Aggregates&&d.Aggregates.length>0&&(l.Aggregates=d.Aggregates.map(D=>({expression:D.expression,alias:D.alias}))),r.push(l),n.push(...this.getViewRunTimeFieldList(I,g,d,E))}const i=e.some(d=>d.Aggregates&&d.Aggregates.length>0)?`
|
|
272
274
|
AggregateResults {
|
|
273
275
|
alias
|
|
274
276
|
expression
|
|
275
277
|
value
|
|
276
278
|
error
|
|
277
279
|
}
|
|
278
|
-
AggregateExecutionTime`:"",
|
|
280
|
+
AggregateExecutionTime`:"",a=m`
|
|
279
281
|
query RunViewsQuery ($input: [RunViewGenericInput!]!) {
|
|
280
282
|
RunViews(input: $input) {
|
|
281
283
|
Results {
|
|
@@ -293,7 +295,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
293
295
|
Success
|
|
294
296
|
ErrorMessage${i}
|
|
295
297
|
}
|
|
296
|
-
}`,u=await this.ExecuteGQL(
|
|
298
|
+
}`,u=await this.ExecuteGQL(a,{input:r});if(u&&u.RunViews){const d=u.RunViews;for(const[f,R]of d.entries())R.Results=R.Results.map(l=>{let y=JSON.parse(l.Data);return this.ConvertBackToMJFields(y),y});return d}return null}catch(r){throw c(r),r}}async RunViewsWithCacheCheck(e,t){try{const r=e.map(a=>({params:{EntityName:a.params.EntityName||"",ExtraFilter:a.params.ExtraFilter||"",OrderBy:a.params.OrderBy||"",Fields:a.params.Fields,UserSearchString:a.params.UserSearchString||"",IgnoreMaxRows:a.params.IgnoreMaxRows||!1,MaxRows:a.params.MaxRows,StartRow:a.params.StartRow,ForceAuditLog:a.params.ForceAuditLog||!1,AuditLogDescription:a.params.AuditLogDescription||"",ResultType:a.params.ResultType||"simple"},cacheStatus:a.cacheStatus?{maxUpdatedAt:a.cacheStatus.maxUpdatedAt,rowCount:a.cacheStatus.rowCount}:null})),s=m`
|
|
297
299
|
query RunViewsWithCacheCheckQuery($input: [RunViewWithCacheCheckInput!]!) {
|
|
298
300
|
RunViewsWithCacheCheck(input: $input) {
|
|
299
301
|
success
|
|
@@ -326,7 +328,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
326
328
|
}
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
|
-
`,
|
|
331
|
+
`,o=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map((a,u)=>{const d=e[u];if(a.status==="differential"&&a.differentialData){const f=a.differentialData.updatedRows.map(R=>{const l=JSON.parse(R.Data);return this.ConvertBackToMJFields(l),l});return{viewIndex:a.viewIndex,status:a.status,results:void 0,differentialData:{updatedRows:f,deletedRecordIDs:a.differentialData.deletedRecordIDs},maxUpdatedAt:a.maxUpdatedAt,rowCount:a.rowCount,errorMessage:a.errorMessage}}if(a.status==="stale"&&a.Results){const f=a.Results.map(R=>{const l=JSON.parse(R.Data);return this.ConvertBackToMJFields(l),l});return{viewIndex:a.viewIndex,status:a.status,results:f,maxUpdatedAt:a.maxUpdatedAt,rowCount:a.rowCount,errorMessage:a.errorMessage}}return{viewIndex:a.viewIndex,status:a.status,results:void 0,maxUpdatedAt:a.maxUpdatedAt,rowCount:a.rowCount,errorMessage:a.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c(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 V.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await V.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=[],o=new b;if(r.Fields){for(const i of e.PrimaryKeys)r.Fields.find(a=>a.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&n.push(i.Name);r.Fields.forEach(i=>{n.push(o.MapFieldName(i))})}else if(s)e.Fields.forEach(i=>{i.IsBinaryFieldType||n.push(o.MapFieldName(i.CodeName))});else{for(const i of e.PrimaryKeys)n.find(a=>a.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&n.push(i.Name);t.Columns.forEach(i=>{i.hidden===!1&&!n.find(a=>a.trim().toLowerCase()===i.EntityField?.Name.trim().toLowerCase())&&i.EntityField&&n.push(o.MapFieldName(i.EntityField.CodeName))})}return n}get ProviderType(){return H.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,o)=>n.ChangedAt>o.ChangedAt?-1:1):null}catch(r){throw c(r),r}}async GetRecordDependencies(e,t){try{const r=m`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
330
332
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
331
333
|
EntityName
|
|
332
334
|
RelatedEntityName
|
|
@@ -338,7 +340,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
338
340
|
}
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
|
-
}`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw
|
|
343
|
+
}`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw c(r),r}}ensureKeyValuePairValueIsString(e){return e.map(t=>({FieldName:t.FieldName,Value:t.Value.toString()}))}async GetRecordDuplicates(e,t){if(!e)return null;const r=m`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
|
|
342
344
|
GetRecordDuplicates(params: $params) {
|
|
343
345
|
Status
|
|
344
346
|
ErrorMessage
|
|
@@ -360,7 +362,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
}
|
|
363
|
-
}`;let s={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(
|
|
365
|
+
}`;let s={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(o=>o.Copy())};const n=await this.ExecuteGQL(r,{params:s});if(n&&n.GetRecordDuplicates)return n.GetRecordDuplicates}async MergeRecords(e,t,r){const s=this.Entities.find(n=>n.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!s||!s.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const n=m`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
|
|
364
366
|
MergeRecords(request: $request) {
|
|
365
367
|
Success
|
|
366
368
|
OverallStatus
|
|
@@ -377,32 +379,32 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
377
379
|
Message
|
|
378
380
|
}
|
|
379
381
|
}
|
|
380
|
-
}`,
|
|
381
|
-
${e.Fields.map(l=>
|
|
382
|
+
}`,o={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(a=>({FieldName:a.FieldName,Value:a.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(a=>a.Copy())};return(await this.ExecuteGQL(n,{request:o}))?.MergeRecords}catch(n){return c(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 T;return n.StartedAt=new Date,n.EndedAt=new Date,n.Type=e.IsSaved?"update":"create",n.Success=!0,n.NewValues=e.GetAll(),e.ResultHistory.push(n),n.NewValues}const s=new T;try{e.RegisterTransactionPreprocessing();const n={input:{}},o=e.IsSaved?"Update":"Create";s.StartedAt=new Date,s.Type=e.IsSaved?"update":"create",s.OriginalValues=e.Fields.map(l=>({FieldName:l.CodeName,Value:l.Value})),e.ResultHistory.push(s);const i=N(e.EntityInfo),a=`${o}${i}`,u=e.Fields.filter(l=>!l.ReadOnly||l.IsPrimaryKey&&e.IsSaved),d=new b,f=` ${a}(input: $input) {
|
|
383
|
+
${e.Fields.map(l=>d.MapFieldName(l.CodeName)).join(`
|
|
382
384
|
`)}
|
|
383
|
-
}`,
|
|
385
|
+
}`,R=m`mutation ${o}${i} ($input: ${a}Input!) {
|
|
384
386
|
${f}
|
|
385
387
|
}
|
|
386
|
-
`;for(let l=0;l<u.length;l++){const y=u[l];let g=e.Get(y.Name);if(g)switch(y.EntityFieldInfo.TSType){case
|
|
387
|
-
${u}(${
|
|
388
|
+
`;for(let l=0;l<u.length;l++){const y=u[l];let g=e.Get(y.Name);if(g)switch(y.EntityFieldInfo.TSType){case P.Date:g=g.getTime();break;case P.Boolean:typeof g!="boolean"&&(g=parseInt(g)!==0);break;case P.Number:if(typeof g!="number"){const I=Number(g);isNaN(I)||(g=I)}break}g===null&&y.EntityFieldInfo.AllowsNull===!1&&(y.EntityFieldInfo.DefaultValue!==null?g=y.EntityFieldInfo.DefaultValue:y.FieldType===P.Number||y.FieldType===P.Boolean?g=0:g=""),n.input[y.CodeName]=g}if(o.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const l=[];e.Fields.forEach(y=>{let g=null;y.OldValue!==null&&y.OldValue!==void 0&&(y.EntityFieldInfo.TSType===P.Date?g=y.OldValue.getTime().toString():y.EntityFieldInfo.TSType===P.Boolean?g=y.OldValue===!0?"1":"0":typeof y.OldValue!="string"?g=y.OldValue.toString():g=y.OldValue),l.push({Key:y.CodeName,Value:g})}),n.input.OldValues___=l}if(e.TransactionGroup){const l=[{varName:"input",inputType:a+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new U(e,s.Type==="create"?"Create":"Update",f,n,{mutationName:a,mutationInputTypes:l},(y,g)=>{s.EndedAt=new Date,g&&y?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(y)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const l=await this.ExecuteGQL(R,n);if(l&&l[a])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(l[a]),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,c(n),null}}async Load(e,t,r=null,s){try{const n={};let o="",i="";for(let l=0;l<t.KeyValuePairs.length;l++){const y=e.Fields.find(E=>E.Name.trim().toLowerCase()===t.KeyValuePairs[l].FieldName.trim().toLowerCase()).EntityFieldInfo,g=t.GetValueByIndex(l),I=y.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${y.CodeName}: ${I}!`,o.length>0&&(o+=", "),o+=`${y.CodeName}: $${y.CodeName}`,y.TSType===P.Number){if(isNaN(t.GetValueByIndex(l)))throw new Error(`Primary Key value ${g} (${y.Name}) is not a valid number`);n[y.CodeName]=parseInt(g)}else n[y.CodeName]=g}const a=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",u=N(e.EntityInfo),d=new b,f=m`query Single${u}${a.length>0?"Full":""} (${i}) {
|
|
389
|
+
${u}(${o}) {
|
|
388
390
|
${e.Fields.filter(l=>!l.EntityFieldInfo.IsBinaryFieldType).map(l=>l.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?l.CodeName.replace("__mj_","_mj__"):l.CodeName).join(`
|
|
389
391
|
`)}
|
|
390
|
-
${
|
|
392
|
+
${a}
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
|
-
`,
|
|
395
|
+
`,R=await this.ExecuteGQL(f,n);return R&&R[u]?this.ConvertBackToMJFields(R[u]):null}catch(n){return c(n),null}}ConvertBackToMJFields(e){return new b().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],o=this.Entities.find(a=>a.ID===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+=`
|
|
394
396
|
${i} {
|
|
395
|
-
${
|
|
397
|
+
${o.Fields.map(a=>a.CodeName).join(`
|
|
396
398
|
`)}
|
|
397
399
|
}
|
|
398
|
-
`}return r}async Delete(e,t,r){const s=new
|
|
399
|
-
`),u+=`${g.CodeName}`}
|
|
400
|
+
`}return r}async Delete(e,t,r){const s=new T;try{e.RegisterTransactionPreprocessing(),s.StartedAt=new Date,s.Type="delete",s.OriginalValues=e.Fields.map(y=>({FieldName:y.CodeName,Value:y.Value})),e.ResultHistory.push(s);const n={},o=[];let i="",a="",u="";for(let y of e.PrimaryKey.KeyValuePairs){const g=e.Fields.find(I=>I.Name.trim().toLowerCase()===y.FieldName.trim().toLowerCase());n[g.CodeName]=g.Value,o.push({varName:g.CodeName,inputType:g.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${g.CodeName}: $${g.CodeName}`,a.length>0&&(a+=", "),a+=`$${g.CodeName}: ${g.EntityFieldInfo.GraphQLType}!`,u.length>0&&(u+=`
|
|
401
|
+
`),u+=`${g.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),n.options___={SkipEntityAIActions:t?.SkipEntityAIActions??!1,SkipEntityActions:t?.SkipEntityActions??!1,ReplayOnly:t?.ReplayOnly??!1,IsParentEntityDelete:t?.IsParentEntityDelete??!1};const f="Delete"+N(e.EntityInfo),R=m`${f}(${i}, options___: $options___) {
|
|
400
402
|
${u}
|
|
401
403
|
}
|
|
402
|
-
`,l=m`mutation ${f} (${
|
|
403
|
-
${
|
|
404
|
+
`,l=m`mutation ${f} (${a}, $options___: DeleteOptionsInput!) {
|
|
405
|
+
${R}
|
|
404
406
|
}
|
|
405
|
-
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new
|
|
407
|
+
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new U(e,"Delete",R,n,{mutationName:f,mutationInputTypes:o},(y,g)=>{if(s.EndedAt=new Date,g&&y){let I=!0;for(const E of e.PrimaryKey.KeyValuePairs)E.Value!==y[E.FieldName]&&(I=!1);I?s.Success=!0:(s.Success=!1,s.Message="Transaction failed to commit")}else s.Success=!1,s.Message="Transaction failed to commit"})),!0;{const y=await this.ExecuteGQL(l,n);if(y&&y[f]){const g=y[f];for(let I of e.PrimaryKey.KeyValuePairs){let E=g[I.FieldName],w=I.Value;if(typeof w=="number"&&(w=w.toString()),typeof E=="number"&&(E=E.toString()),w!==E)throw new Error(`Primary key value mismatch in server Delete response. Field: ${I.FieldName}, Original: ${w}, Returned: ${E}`)}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,c(n),!1}}async GetDatasetByName(e,t){const r=m`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
|
|
406
408
|
GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
|
|
407
409
|
DatasetID
|
|
408
410
|
DatasetName
|
|
@@ -420,16 +422,16 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
420
422
|
LatestUpdateDate
|
|
421
423
|
EntityUpdateDates
|
|
422
424
|
}
|
|
423
|
-
}`,s=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return s&&s.GetDatasetStatusByName&&s.GetDatasetStatusByName.Success?{DatasetID:s.GetDatasetStatusByName.DatasetID,DatasetName:s.GetDatasetStatusByName.DatasetName,Success:s.GetDatasetStatusByName.Success,Status:s.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(s.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(s.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new
|
|
425
|
+
}`,s=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return s&&s.GetDatasetStatusByName&&s.GetDatasetStatusByName.Success?{DatasetID:s.GetDatasetStatusByName.DatasetID,DatasetName:s.GetDatasetStatusByName.DatasetName,Success:s.GetDatasetStatusByName.Success,Status:s.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(s.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(s.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new Q(this)}async GetRecordFavoriteStatus(e,t,r){if(!r.Validate().IsValid)return!1;const n=this.Entities.find(a=>a.Name===t);if(!n)throw new Error(`Entity ${t} not found in metadata`);const o=m`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
|
|
424
426
|
GetRecordFavoriteStatus(params: $params) {
|
|
425
427
|
Success
|
|
426
428
|
IsFavorite
|
|
427
429
|
}
|
|
428
|
-
}`,i=await this.ExecuteGQL(
|
|
430
|
+
}`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:n.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}}});if(i&&i.GetRecordFavoriteStatus&&i.GetRecordFavoriteStatus.Success)return i.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,t,r,s,n){const o=this.Entities.find(u=>u.Name===t);if(!o)throw new Error(`Entity ${t} not found in metadata`);const i=m`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
|
|
429
431
|
SetRecordFavoriteStatus(params: $params){
|
|
430
432
|
Success
|
|
431
433
|
}
|
|
432
|
-
}`,
|
|
434
|
+
}`,a=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)},IsFavorite:s}});if(a&&a.SetRecordFavoriteStatus!==null)return a.SetRecordFavoriteStatus.Success}async InternalGetEntityRecordName(e,t){if(!e||!t||t.KeyValuePairs?.length===0)return null;const r=m`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
433
435
|
GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
|
|
434
436
|
Success
|
|
435
437
|
Status
|
|
@@ -448,47 +450,47 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
448
450
|
EntityName
|
|
449
451
|
RecordName
|
|
450
452
|
}
|
|
451
|
-
}`,r=await this.ExecuteGQL(t,{info:e.map(s=>({EntityName:s.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.CompositeKey.KeyValuePairs)}}))});if(r&&r.GetEntityRecordNames)return r.GetEntityRecordNames.map(s=>({...s,CompositeKey:new
|
|
453
|
+
}`,r=await this.ExecuteGQL(t,{info:e.map(s=>({EntityName:s.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.CompositeKey.KeyValuePairs)}}))});if(r&&r.GetEntityRecordNames)return r.GetEntityRecordNames.map(s=>({...s,CompositeKey:new X(s.CompositeKey.KeyValuePairs)}))}async GetDataContextData(e){try{const t=m`query GetDataContextData ($DataContextID: String!) {
|
|
452
454
|
GetDataContextData(DataContextID: $DataContextID) {
|
|
453
455
|
Success
|
|
454
456
|
ErrorMessages
|
|
455
457
|
Results
|
|
456
458
|
}
|
|
457
|
-
}`,r=await this.ExecuteGQL(t,{DataContextID:e});if(r&&r.GetDataContextData){if(r.GetDataContextData.Success)return r.GetDataContextData.Results.map(s=>JSON.parse(s));throw new Error(r.GetDataContextData.ErrorMessages.join(", "))}else throw new Error("GraphQL query failed")}catch(t){throw
|
|
459
|
+
}`,r=await this.ExecuteGQL(t,{DataContextID:e});if(r&&r.GetDataContextData){if(r.GetDataContextData.Success)return r.GetDataContextData.Results.map(s=>JSON.parse(s));throw new Error(r.GetDataContextData.ErrorMessages.join(", "))}else throw new Error("GraphQL query failed")}catch(t){throw c(t),t}}async GetDataContextItemData(e){try{const t=m`query GetDataContextItemData ($DataContextItemID: String!) {
|
|
458
460
|
GetDataContextItemData(DataContextItemID: $DataContextItemID) {
|
|
459
461
|
Success
|
|
460
462
|
ErrorMessage
|
|
461
463
|
Result
|
|
462
464
|
}
|
|
463
|
-
}`,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)}else throw new Error("GraphQL query failed")}catch(t){throw
|
|
465
|
+
}`,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)}else throw new Error("GraphQL query failed")}catch(t){throw c(t),t}}static async ExecuteGQL(e,t,r=!0){return S.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(s.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(r)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw c("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw c(s),s}}async RefreshToken(){const e=S.Instance&&S.Instance._configData===this._configData;if(e&&S.Instance._refreshPromise)return S.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(S.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&S.Instance&&(S.Instance._refreshPromise=null)}}async performTokenRefresh(){if(this._configData.Data.RefreshTokenFunction){const e=await this._configData.Data.RefreshTokenFunction();if(e){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,S.Instance&&S.Instance._configData===this._configData&&(S.Instance._client=t)}else throw new Error("Refresh token function returned null or undefined token")}else throw new Error("No refresh token function provided")}static async RefreshToken(){return S.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,s,n){const o={"x-session-id":r};return t&&(o.authorization="Bearer "+t),s&&(o["x-mj-api-key"]=s),n&&(o["x-api-key"]=n),new F(e,{headers:o})}userInfoString(){return this.infoString(new G(null,null))}userRoleInfoString(){return this.infoString(new Y(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
|
|
464
466
|
`:s.startsWith("_")||(t+=s+`
|
|
465
|
-
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new
|
|
467
|
+
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new K:this._localStorageProvider=new Z),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&&this._activeSubscriptionCount===0&&this.disposeWSClient(),this._wsClient||(this._wsClient=ae({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(r){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,r)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=this._pushStatusSubjects.size,r=Array.from(this._pushStatusSubjects.entries()),s=[];r.forEach(([n,o])=>{const i=e-o.lastRequestedAt,a=e-o.lastEmissionAt;o.activeSubscribers===0&&i>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&a>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${n} for cleanup: activeSubscribers=${o.activeSubscribers}, timeSinceRequested=${Math.round(i/1e3)}s, timeSinceEmission=${Math.round(a/1e3)}s`),s.push(n))}),s.forEach(n=>{const o=this._pushStatusSubjects.get(n);if(o)try{o.subject.complete(),o.subscription.unsubscribe(),this._pushStatusSubjects.delete(n),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${n}`)}catch(i){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${n}:`,i)}}),s.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${s.length} stale subscription(s)`),this._pushStatusSubjects.size===0&&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 M(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const n=s.subscribe({query:e,variables:t},{next:p(o=>{r.next(o.data)},"next"),error:p(async o=>{const i=o;if(i?.extensions?.code==="JWT_EXPIRED"||i?.message?.includes("token has expired")||i?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(u){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",u),r.error(u)}}else r.error(o)},"error"),complete:p(()=>{r.complete()},"complete")});return()=>{this._activeSubscriptionCount--,n()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new M(a=>{r.activeSubscribers++;const u=r.subject.subscribe(a);return()=>{const d=this._pushStatusSubjects.get(e);d&&d.activeSubscribers>0&&d.activeSubscribers--,u.unsubscribe()}});const s=m`subscription StatusUpdates($sessionId: String!) {
|
|
466
468
|
statusUpdates(sessionId: $sessionId) {
|
|
467
469
|
date
|
|
468
470
|
message
|
|
469
471
|
sessionId
|
|
470
472
|
}
|
|
471
473
|
}
|
|
472
|
-
`,n=new
|
|
474
|
+
`,n=new ne,o=this.getOrCreateWSClient(),i=new oe;return i.add(new M(a=>{const u=o.subscribe({query:s,variables:{sessionId:e}},{next:p(d=>{const f=this._pushStatusSubjects.get(e);f&&(f.lastEmissionAt=Date.now()),a.next(d.data.statusUpdates.message)},"next"),error:p(async d=>{const f=d;if(f?.extensions?.code==="JWT_EXPIRED"||f?.message?.includes("token has expired")||f?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),a.complete()}catch(l){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",l),a.error(l)}}else a.error(d)},"error"),complete:p(()=>{a.complete()},"complete")});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,u()}}).subscribe({next:p(a=>n.next(a),"next"),error:p(a=>{n.error(a),this._pushStatusSubjects.delete(e)},"error"),complete:p(()=>{n.complete(),this._pushStatusSubjects.delete(e)},"complete")})),this._pushStatusSubjects.set(e,{subject:n,subscription:i,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new M(a=>{const u=this._pushStatusSubjects.get(e);u&&u.activeSubscribers++;const d=n.subscribe(a);return()=>{const f=this._pushStatusSubjects.get(e);f&&f.activeSubscribers>0&&f.activeSubscribers--,d.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;const s=`query FindISAChildEntity($EntityName: String!, $RecordID: String!) {
|
|
473
475
|
FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {
|
|
474
476
|
Success
|
|
475
477
|
ChildEntityName
|
|
476
478
|
ErrorMessage
|
|
477
479
|
}
|
|
478
|
-
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntity?.Success&&n.FindISAChildEntity.ChildEntityName?{ChildEntityName:n.FindISAChildEntity.ChildEntityName}:null}catch(n){return
|
|
480
|
+
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntity?.Success&&n.FindISAChildEntity.ChildEntityName?{ChildEntityName:n.FindISAChildEntity.ChildEntityName}:null}catch(n){return c(`FindISAChildEntity failed for ${e.Name}: ${n}`),null}}async FindISAChildEntities(e,t,r){if(!e.IsParentType)return[];const s=`query FindISAChildEntities($EntityName: String!, $RecordID: String!) {
|
|
479
481
|
FindISAChildEntities(EntityName: $EntityName, RecordID: $RecordID) {
|
|
480
482
|
Success
|
|
481
483
|
ChildEntityNames
|
|
482
484
|
ErrorMessage
|
|
483
485
|
}
|
|
484
|
-
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(
|
|
486
|
+
}`;try{const n=await this.ExecuteGQL(s,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(o=>({ChildEntityName:o})):[]}catch(n){return c(`FindISAChildEntities failed for ${e.Name}: ${n}`),[]}}}async function pe(h){const e=Date.now();console.log(`[DIAG][${e}] setupGraphQLClient() ENTER`);const t=new S;console.log(`[DIAG][${e}] setupGraphQLClient() calling SetProvider() (Metadata.Provider will be set BEFORE Config completes)`),te(t),console.log(`[DIAG][${e}] setupGraphQLClient() SetProvider() done. Metadata.Provider is now set. Starting async Config()...`);const r=Date.now();await t.Config(h),console.log(`[DIAG][${e}] setupGraphQLClient() provider.Config() completed in ${Date.now()-r}ms. Provider is now fully ready.`);const s=Date.now();return console.log(`[DIAG][${e}] setupGraphQLClient() calling StartupManager.Startup()...`),await re.Instance.Startup(),console.log(`[DIAG][${e}] setupGraphQLClient() StartupManager.Startup() completed in ${Date.now()-s}ms`),ue.Instance.RaiseEvent({event:ce.LoggedIn,eventCode:null,component:this,args:null}),console.log(`[DIAG][${e}] setupGraphQLClient() EXIT - total time: ${Date.now()-e}ms`),t}p(pe,"setupGraphQLClient");class he{static{p(this,"SyncRolesAndUsersResult")}}class fe{static{p(this,"RoleInput")}}class Se{static{p(this,"UserInput")}}class Ie{static{p(this,"RolesAndUsersInput")}}var B=(h=>(h.Create="Create",h.Update="Update",h.CreateOrUpdate="CreateOrUpdate",h.Delete="Delete",h.DeleteWithFilter="DeleteWithFilter",h))(B||{});class Re{static{p(this,"ActionItemInput")}}class Ee{static{p(this,"SyncDataResult")}constructor(){this.Results=[]}}class De{static{p(this,"ActionItemOutput")}}class we{static{p(this,"GraphQLSystemUserClient")}get Client(){return this._client}constructor(e,t,r,s){const n={"x-session-id":r};this._sessionId=r,t&&(n.authorization="Bearer "+t),s&&(n["x-mj-api-key"]=s),this._client=new F(e,{headers:n})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
|
|
485
487
|
GetData(input: $input) {
|
|
486
488
|
Success
|
|
487
489
|
ErrorMessages
|
|
488
490
|
Queries
|
|
489
491
|
Results
|
|
490
492
|
}
|
|
491
|
-
}`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(n=>n
|
|
493
|
+
}`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(n=>n?$(n):null),ErrorMessages:s.GetData.ErrorMessages,Queries:s.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:s.GetData?.ErrorMessages??["Unknown error"],Queries:s.GetData?.Queries??e}}catch(r){let s=r instanceof Error?r.message:String(r);const n=s.match(/Error: ([^:]+)\./);if(n&&(s=n[1]+"."),se()){const o=`GraphQLSystemUserClient::GetData - Error getting data - ${r}`;c(o)}return{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
|
|
492
494
|
GetAllEntities {
|
|
493
495
|
Success
|
|
494
496
|
ErrorMessage
|
|
@@ -511,7 +513,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
511
513
|
}
|
|
512
514
|
}
|
|
513
515
|
}
|
|
514
|
-
}`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return
|
|
516
|
+
}`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return c(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const r=await this.Client.request(`mutation SyncData($items: [ActionItemInputType!]!) {
|
|
515
517
|
SyncData(items: $items) {
|
|
516
518
|
Success
|
|
517
519
|
Results {
|
|
@@ -535,11 +537,11 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
535
537
|
RecordJSON
|
|
536
538
|
}
|
|
537
539
|
}
|
|
538
|
-
}`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return
|
|
540
|
+
}`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return c(`GraphQLSystemUserClient::SyncData - Error syncing data - ${t}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const r=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
|
|
539
541
|
SyncRolesAndUsers(data: $data) {
|
|
540
542
|
Success
|
|
541
543
|
}
|
|
542
|
-
}`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return
|
|
544
|
+
}`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return c(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}async RunViewByName(e){try{const r=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
|
|
543
545
|
RunViewByNameSystemUser(input: $input) {
|
|
544
546
|
Results {
|
|
545
547
|
PrimaryKey {
|
|
@@ -556,7 +558,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
556
558
|
ErrorMessage
|
|
557
559
|
Success
|
|
558
560
|
}
|
|
559
|
-
}`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return
|
|
561
|
+
}`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return c(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunViewByID(e){try{const r=await this.Client.request(`query RunViewByIDSystemUser($input: RunViewByIDInput!) {
|
|
560
562
|
RunViewByIDSystemUser(input: $input) {
|
|
561
563
|
Results {
|
|
562
564
|
PrimaryKey {
|
|
@@ -573,7 +575,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
573
575
|
ErrorMessage
|
|
574
576
|
Success
|
|
575
577
|
}
|
|
576
|
-
}`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return
|
|
578
|
+
}`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return c(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunDynamicView(e){try{const r=await this.Client.request(`query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {
|
|
577
579
|
RunDynamicViewSystemUser(input: $input) {
|
|
578
580
|
Results {
|
|
579
581
|
PrimaryKey {
|
|
@@ -590,7 +592,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
590
592
|
ErrorMessage
|
|
591
593
|
Success
|
|
592
594
|
}
|
|
593
|
-
}`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return
|
|
595
|
+
}`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return c(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunViews(e){try{const r=await this.Client.request(`query RunViewsSystemUser($input: [RunViewGenericInput!]!) {
|
|
594
596
|
RunViewsSystemUser(input: $input) {
|
|
595
597
|
Results {
|
|
596
598
|
PrimaryKey {
|
|
@@ -607,7 +609,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
607
609
|
ErrorMessage
|
|
608
610
|
Success
|
|
609
611
|
}
|
|
610
|
-
}`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return
|
|
612
|
+
}`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return c(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${t}`),[]}}async GetQueryData(e){try{if(e.Parameters!==void 0&&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) {
|
|
611
613
|
GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
612
614
|
QueryID
|
|
613
615
|
QueryName
|
|
@@ -619,7 +621,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
619
621
|
ErrorMessage
|
|
620
622
|
AppliedParameters
|
|
621
623
|
}
|
|
622
|
-
}`,r={QueryID:e.QueryID};e.CategoryID!==void 0&&(r.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(r.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(r.Parameters=e.Parameters),e.MaxRows!==void 0&&(r.MaxRows=e.MaxRows),e.StartRow!==void 0&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results
|
|
624
|
+
}`,r={QueryID:e.QueryID};e.CategoryID!==void 0&&(r.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(r.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(r.Parameters=e.Parameters),e.MaxRows!==void 0&&(r.MaxRows=e.MaxRows),e.StartRow!==void 0&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results?$(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 c(`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(e.Parameters!==void 0&&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) {
|
|
623
625
|
GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
624
626
|
QueryID
|
|
625
627
|
QueryName
|
|
@@ -631,7 +633,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
631
633
|
ErrorMessage
|
|
632
634
|
AppliedParameters
|
|
633
635
|
}
|
|
634
|
-
}`,r={QueryName:e.QueryName};e.CategoryID!==void 0&&(r.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(r.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(r.Parameters=e.Parameters),e.MaxRows!==void 0&&(r.MaxRows=e.MaxRows),e.StartRow!==void 0&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results
|
|
636
|
+
}`,r={QueryName:e.QueryName};e.CategoryID!==void 0&&(r.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(r.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(r.Parameters=e.Parameters),e.MaxRows!==void 0&&(r.MaxRows=e.MaxRows),e.StartRow!==void 0&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results?$(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 c(`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 r=await this.Client.request(`mutation CreateQuerySystemUser($input: CreateQuerySystemUserInput!) {
|
|
635
637
|
CreateQuerySystemUser(input: $input) {
|
|
636
638
|
Success
|
|
637
639
|
ErrorMessage
|
|
@@ -686,7 +688,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
686
688
|
Role
|
|
687
689
|
}
|
|
688
690
|
}
|
|
689
|
-
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return
|
|
691
|
+
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return c(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async UpdateQuery(e){try{const r=await this.Client.request(`mutation UpdateQuerySystemUser($input: UpdateQuerySystemUserInput!) {
|
|
690
692
|
UpdateQuerySystemUser(input: $input) {
|
|
691
693
|
Success
|
|
692
694
|
ErrorMessage
|
|
@@ -741,14 +743,14 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
741
743
|
Role
|
|
742
744
|
}
|
|
743
745
|
}
|
|
744
|
-
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(t){return
|
|
746
|
+
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(t){return c(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async DeleteQuery(e,t){try{if(!e||e.trim()==="")return c("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) {
|
|
745
747
|
DeleteQuerySystemResolver(ID: $ID, options: $options) {
|
|
746
748
|
Success
|
|
747
749
|
ErrorMessage
|
|
748
750
|
ID
|
|
749
751
|
Name
|
|
750
752
|
}
|
|
751
|
-
}`,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.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{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
|
|
753
|
+
}`,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.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{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 c(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${s}`),{Success:!1,ErrorMessage:s}}}async RunAIPrompt(e){try{const t=m`
|
|
752
754
|
query RunAIPromptSystemUser(
|
|
753
755
|
$promptId: String!,
|
|
754
756
|
$data: String,
|
|
@@ -807,7 +809,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
807
809
|
chatResult
|
|
808
810
|
}
|
|
809
811
|
}
|
|
810
|
-
`,r=this.preparePromptVariables(e),s=await this.Client.request(t,r);return s&&s.RunAIPromptSystemUser?this.processPromptResult(s.RunAIPromptSystemUser):{success:!1,error:"Failed to execute AI prompt as system user"}}catch(t){return
|
|
812
|
+
`,r=this.preparePromptVariables(e),s=await this.Client.request(t,r);return s&&s.RunAIPromptSystemUser?this.processPromptResult(s.RunAIPromptSystemUser):{success:!1,error:"Failed to execute AI prompt as system user"}}catch(t){return c(`GraphQLSystemUserClient::RunAIPrompt - Error running AI prompt - ${t}`),{success:!1,error:t.toString()}}}async RunAIAgent(e){try{const t=m`
|
|
811
813
|
query RunAIAgentSystemUser(
|
|
812
814
|
$agentId: String!,
|
|
813
815
|
$messages: String!,
|
|
@@ -834,7 +836,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
834
836
|
result
|
|
835
837
|
}
|
|
836
838
|
}
|
|
837
|
-
`,r=this.prepareAgentVariables(e),s=await this.Client.request(t,r);return s&&s.RunAIAgentSystemUser?this.processAgentResult(s.RunAIAgentSystemUser.result):{success:!1,agentRun:void 0}}catch(t){return
|
|
839
|
+
`,r=this.prepareAgentVariables(e),s=await this.Client.request(t,r);return s&&s.RunAIAgentSystemUser?this.processAgentResult(s.RunAIAgentSystemUser.result):{success:!1,agentRun:void 0}}catch(t){return c(`GraphQLSystemUserClient::RunAIAgent - Error running AI agent - ${t}`),{success:!1,agentRun:void 0}}}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}prepareAgentVariables(e){const t={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._sessionId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),t}processPromptResult(e){let t,r,s;try{e.parsedResult&&(t=JSON.parse(e.parsedResult))}catch{t=e.parsedResult}try{e.validationResult&&(r=JSON.parse(e.validationResult))}catch{r=e.validationResult}try{e.chatResult&&(s=JSON.parse(e.chatResult))}catch{s=e.chatResult}return{success:e.success,output:e.output,parsedResult:t,error:e.error,executionTimeMs:e.executionTimeMs,tokensUsed:e.tokensUsed,promptRunId:e.promptRunId,rawResult:e.rawResult,validationResult:r,chatResult:s}}processAgentResult(e){return $(e)}async ExecuteSimplePrompt(e){try{const t=m`
|
|
838
840
|
query ExecuteSimplePromptSystemUser(
|
|
839
841
|
$systemPrompt: String!,
|
|
840
842
|
$messages: String,
|
|
@@ -857,7 +859,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
857
859
|
executionTimeMs
|
|
858
860
|
}
|
|
859
861
|
}
|
|
860
|
-
`,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const s=await this.Client.request(t,r);if(!s?.ExecuteSimplePromptSystemUser)return{success:!1,modelName:"Unknown",error:"Failed to execute simple prompt as system user"};const n=s.ExecuteSimplePromptSystemUser;let
|
|
862
|
+
`,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const s=await this.Client.request(t,r);if(!s?.ExecuteSimplePromptSystemUser)return{success:!1,modelName:"Unknown",error:"Failed to execute simple prompt as system user"};const n=s.ExecuteSimplePromptSystemUser;let o;if(n.resultObject)try{o=JSON.parse(n.resultObject)}catch{o=n.resultObject}return{success:n.success,result:n.result,resultObject:o,modelName:n.modelName,error:n.error,executionTimeMs:n.executionTimeMs}}catch(t){return c(`GraphQLSystemUserClient::ExecuteSimplePrompt - Error executing simple prompt - ${t}`),{success:!1,modelName:"Unknown",error:t.toString()}}}async EmbedText(e){try{const t=m`
|
|
861
863
|
query EmbedTextSystemUser(
|
|
862
864
|
$textToEmbed: [String!]!,
|
|
863
865
|
$modelSize: String!
|
|
@@ -872,7 +874,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
872
874
|
error
|
|
873
875
|
}
|
|
874
876
|
}
|
|
875
|
-
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,s);if(!n?.EmbedTextSystemUser)return{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const
|
|
877
|
+
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,s);if(!n?.EmbedTextSystemUser)return{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const o=n.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?o.embeddings:o.embeddings[0],modelName:o.modelName,vectorDimensions:o.vectorDimensions,error:o.error}}catch(t){return c(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class Ce{static{p(this,"GetDataOutput")}}class ve{static{p(this,"SimpleRemoteEntityOutput")}}class $e{static{p(this,"SimpleRemoteEntity")}}class Pe{static{p(this,"SimpleRemoteEntityField")}}class Ae{static{p(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),n=this.createActionVariables(e,s,r),o=await this.executeActionMutation(n);return this.processActionResult(o,t)}catch(s){return this.handleActionError(s,t)}}serializeActionParameters(e){if(e)return e.map(t=>{let r=t.Value;return r!=null&&typeof r=="object"&&(r=JSON.stringify(r)),{...t,Value:r}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=m`
|
|
876
878
|
mutation RunAction($input: RunActionInput!) {
|
|
877
879
|
RunAction(input: $input) {
|
|
878
880
|
Success
|
|
@@ -881,7 +883,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
881
883
|
ResultData
|
|
882
884
|
}
|
|
883
885
|
}
|
|
884
|
-
`;return await this._dataProvider.ExecuteGQL(t,e)}processActionResult(e,t){if(!e?.RunAction)throw new Error("Invalid response from server");let r;try{e.RunAction.ResultData&&(r=JSON.parse(e.RunAction.ResultData))}catch(s){
|
|
886
|
+
`;return await this._dataProvider.ExecuteGQL(t,e)}processActionResult(e,t){if(!e?.RunAction)throw new Error("Invalid response from server");let r;try{e.RunAction.ResultData&&(r=JSON.parse(e.RunAction.ResultData))}catch(s){c(`Failed to parse action result data: ${s}`)}return{Success:e.RunAction.Success,Message:e.RunAction.Message,Result:r,LogEntry:null,Params:t||[],RunParams:null}}handleActionError(e,t){const r=e;return c(`Error running action: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Result:null,LogEntry:null,Params:t||[],RunParams:null}}async RunEntityAction(e){try{const t=this.createEntityActionInput(e),r=await this.executeEntityActionMutation(t);return this.processEntityActionResult(r)}catch(t){return this.handleEntityActionError(t)}}createEntityActionInput(e){const t={EntityActionID:e.EntityAction.ID,InvocationType:e.InvocationType.Name,ListID:e.ListID,ViewID:e.ViewID};return e.Params&&(t.Params=this.convertActionParams(e.Params)),e.EntityObject&&this.addEntityInformation(t,e.EntityObject),t}convertActionParams(e){return e.map(t=>{let r=t.Value;return r!=null&&typeof r=="object"&&(r=JSON.stringify(r)),{Name:t.Name,Value:r,Type:t.Type}})}addEntityInformation(e,t){e.EntityName=t.EntityInfo?.Name,t.PrimaryKey&&(e.PrimaryKey=this.convertPrimaryKey(t.PrimaryKey))}convertPrimaryKey(e){return{KeyValuePairs:e.KeyValuePairs.map(t=>this.convertKeyValuePair(t))}}convertKeyValuePair(e){return{FieldName:e.FieldName,Value:e.Value!==null&&e.Value!==void 0?typeof e.Value=="object"?JSON.stringify(e.Value):e.Value.toString():null}}async executeEntityActionMutation(e){const t=m`
|
|
885
887
|
mutation RunEntityAction($input: EntityActionInput!) {
|
|
886
888
|
RunEntityAction(input: $input) {
|
|
887
889
|
Success
|
|
@@ -889,7 +891,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
889
891
|
ResultData
|
|
890
892
|
}
|
|
891
893
|
}
|
|
892
|
-
`;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(r){
|
|
894
|
+
`;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(r){c(`Failed to parse entity action result data: ${r}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return c(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class Ne{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(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=m`
|
|
893
895
|
mutation CreateAPIKey($input: CreateAPIKeyInput!) {
|
|
894
896
|
CreateAPIKey(input: $input) {
|
|
895
897
|
Success
|
|
@@ -898,68 +900,72 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
898
900
|
Error
|
|
899
901
|
}
|
|
900
902
|
}
|
|
901
|
-
`;return await this._dataProvider.ExecuteGQL(t,e)}processCreateAPIKeyResult(e){const t=e;return t?.CreateAPIKey?{Success:t.CreateAPIKey.Success,RawKey:t.CreateAPIKey.RawKey,APIKeyID:t.CreateAPIKey.APIKeyID,Error:t.CreateAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}handleCreateAPIKeyError(e){const t=e;return
|
|
903
|
+
`;return await this._dataProvider.ExecuteGQL(t,e)}processCreateAPIKeyResult(e){const t=e;return t?.CreateAPIKey?{Success:t.CreateAPIKey.Success,RawKey:t.CreateAPIKey.RawKey,APIKeyID:t.CreateAPIKey.APIKeyID,Error:t.CreateAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}handleCreateAPIKeyError(e){const t=e;return c(`Error creating API key: ${t.message}`),{Success:!1,Error:`Error: ${t.message}`}}async RevokeAPIKey(e){try{const t=m`
|
|
902
904
|
mutation RevokeAPIKey($apiKeyId: String!) {
|
|
903
905
|
RevokeAPIKey(apiKeyId: $apiKeyId) {
|
|
904
906
|
Success
|
|
905
907
|
Error
|
|
906
908
|
}
|
|
907
909
|
}
|
|
908
|
-
`,s=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return s?.RevokeAPIKey?{Success:s.RevokeAPIKey.Success,Error:s.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(t){const r=t;return
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
$verbose: Boolean,
|
|
912
|
-
$environment: String,
|
|
913
|
-
$tags: String,
|
|
914
|
-
$variables: String
|
|
915
|
-
) {
|
|
916
|
-
RunTest(
|
|
917
|
-
testId: $testId,
|
|
918
|
-
verbose: $verbose,
|
|
919
|
-
environment: $environment,
|
|
920
|
-
tags: $tags,
|
|
921
|
-
variables: $variables
|
|
922
|
-
) {
|
|
923
|
-
success
|
|
924
|
-
errorMessage
|
|
925
|
-
executionTimeMs
|
|
926
|
-
result
|
|
927
|
-
}
|
|
910
|
+
`,s=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return s?.RevokeAPIKey?{Success:s.RevokeAPIKey.Success,Error:s.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(t){const r=t;return c(`Error revoking API key: ${r.message}`),{Success:!1,Error:`Error: ${r.message}`}}}}class be{static{p(this,"GraphQLTestingClient")}constructor(e){this._dataProvider=e}async RunTest(e){try{const t=this.buildRunTestMutation(),r=this.buildRunTestVariables(e);return await v.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTest",operationLabel:"RunTest",validateAck:p(s=>s?.success===!0,"validateAck"),isCompletionEvent:p(s=>this.isTestCompletionEvent(s,e.testId),"isCompletionEvent"),extractResult:p(s=>this.extractTestResult(s),"extractResult"),onMessage:e.onProgress?s=>this.forwardTestProgress(s,e.onProgress):void 0,createErrorResult:p(s=>({success:!1,errorMessage:s,result:null}),"createErrorResult")})}catch(t){return this.handleError(t,"RunTest")}}async RunTestSuite(e){try{const t=this.buildRunTestSuiteMutation(),r=this.buildRunTestSuiteVariables(e);return await v.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunTestSuite",operationLabel:"RunTestSuite",validateAck:p(s=>s?.success===!0,"validateAck"),isCompletionEvent:p(s=>this.isSuiteCompletionEvent(s,e.suiteId),"isCompletionEvent"),extractResult:p(s=>this.extractSuiteResult(s),"extractResult"),onMessage:e.onProgress?s=>this.forwardTestProgress(s,e.onProgress):void 0,createErrorResult:p(s=>({success:!1,errorMessage:s,result:null}),"createErrorResult")})}catch(t){return this.handleError(t,"RunTestSuite")}}async IsTestRunning(e){try{const t=m`
|
|
911
|
+
query IsTestRunning($testId: String!) {
|
|
912
|
+
IsTestRunning(testId: $testId)
|
|
928
913
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
914
|
+
`;return(await this._dataProvider.ExecuteGQL(t,{testId:e})).IsTestRunning}catch(t){return c(`Error checking test running status: ${t.message}`),!1}}buildRunTestMutation(){return m`
|
|
915
|
+
mutation RunTest(
|
|
916
|
+
$testId: String!,
|
|
917
|
+
$verbose: Boolean,
|
|
918
|
+
$environment: String,
|
|
919
|
+
$tags: String,
|
|
920
|
+
$variables: String,
|
|
921
|
+
$fireAndForget: Boolean
|
|
922
|
+
) {
|
|
923
|
+
RunTest(
|
|
924
|
+
testId: $testId,
|
|
925
|
+
verbose: $verbose,
|
|
926
|
+
environment: $environment,
|
|
927
|
+
tags: $tags,
|
|
928
|
+
variables: $variables,
|
|
929
|
+
fireAndForget: $fireAndForget
|
|
940
930
|
) {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
parallel: $parallel,
|
|
946
|
-
tags: $tags,
|
|
947
|
-
variables: $variables,
|
|
948
|
-
selectedTestIds: $selectedTestIds,
|
|
949
|
-
sequenceStart: $sequenceStart,
|
|
950
|
-
sequenceEnd: $sequenceEnd
|
|
951
|
-
) {
|
|
952
|
-
success
|
|
953
|
-
errorMessage
|
|
954
|
-
executionTimeMs
|
|
955
|
-
result
|
|
956
|
-
}
|
|
931
|
+
success
|
|
932
|
+
errorMessage
|
|
933
|
+
executionTimeMs
|
|
934
|
+
result
|
|
957
935
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
936
|
+
}
|
|
937
|
+
`}buildRunTestSuiteMutation(){return m`
|
|
938
|
+
mutation RunTestSuite(
|
|
939
|
+
$suiteId: String!,
|
|
940
|
+
$verbose: Boolean,
|
|
941
|
+
$environment: String,
|
|
942
|
+
$parallel: Boolean,
|
|
943
|
+
$tags: String,
|
|
944
|
+
$variables: String,
|
|
945
|
+
$selectedTestIds: String,
|
|
946
|
+
$sequenceStart: Int,
|
|
947
|
+
$sequenceEnd: Int,
|
|
948
|
+
$fireAndForget: Boolean
|
|
949
|
+
) {
|
|
950
|
+
RunTestSuite(
|
|
951
|
+
suiteId: $suiteId,
|
|
952
|
+
verbose: $verbose,
|
|
953
|
+
environment: $environment,
|
|
954
|
+
parallel: $parallel,
|
|
955
|
+
tags: $tags,
|
|
956
|
+
variables: $variables,
|
|
957
|
+
selectedTestIds: $selectedTestIds,
|
|
958
|
+
sequenceStart: $sequenceStart,
|
|
959
|
+
sequenceEnd: $sequenceEnd,
|
|
960
|
+
fireAndForget: $fireAndForget
|
|
961
|
+
) {
|
|
962
|
+
success
|
|
963
|
+
errorMessage
|
|
964
|
+
executionTimeMs
|
|
965
|
+
result
|
|
961
966
|
}
|
|
962
|
-
|
|
967
|
+
}
|
|
968
|
+
`}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 e.resolver==="RunTestResolver"&&e.type==="FireAndForgetComplete"&&r?.type==="complete"&&r?.testId===t}isSuiteCompletionEvent(e,t){const r=e.data;return e.resolver==="RunTestResolver"&&e.type==="FireAndForgetSuiteComplete"&&r?.type==="complete"&&r?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?$(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?$(t.result):null}}forwardTestProgress(e,t){if(e.resolver==="RunTestResolver"&&e.type==="TestExecutionProgress"&&e.status==="ok"){const s=e.data?.progress;s&&t(s)}}handleError(e,t){const r=e.message;return c(`${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 xe{static{p(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=m`
|
|
963
969
|
query GetRegistryComponent(
|
|
964
970
|
$registryName: String!,
|
|
965
971
|
$namespace: String!,
|
|
@@ -980,7 +986,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
980
986
|
specification
|
|
981
987
|
}
|
|
982
988
|
}
|
|
983
|
-
`,r={registryName:e.registryName,namespace:e.namespace,name:e.name};e.version!==void 0&&(r.version=e.version),e.hash!==void 0&&(r.hash=e.hash);const s=await this._dataProvider.ExecuteGQL(t,r);if(s&&
|
|
989
|
+
`,r={registryName:e.registryName,namespace:e.namespace,name:e.name};e.version!==void 0&&(r.version=e.version),e.hash!==void 0&&(r.hash=e.hash);const s=Date.now();console.log(`[DIAG][${s}] GetRegistryComponent() calling ExecuteGQL for ${e.registryName}/${e.name}`,{variables:r,dataProviderType:this._dataProvider?.constructor?.name});const n=Date.now(),o=await this._dataProvider.ExecuteGQL(t,r);if(console.log(`[DIAG][${s}] GetRegistryComponent() ExecuteGQL returned in ${Date.now()-n}ms`,{resultExists:!!o,hasGetRegistryComponent:o?!!o.GetRegistryComponent:!1,resultKeys:o?Object.keys(o):[],rawResult:o?JSON.stringify(o).substring(0,500):"null"}),o&&o.GetRegistryComponent){const i=o.GetRegistryComponent;if(console.log(`[DIAG][${s}] GetRegistryComponent() response details:`,{notModified:i.notModified,hasSpecification:!!i.specification,specType:i.specification?typeof i.specification:"N/A",specLength:i.specification?typeof i.specification=="string"?i.specification.length:JSON.stringify(i.specification).length:0,hash:i.hash,message:i.message}),i.notModified&&!i.specification)return console.log(`[DIAG][${s}] GetRegistryComponent() returning null - notModified with no spec`),null;if(i.specification){if(typeof i.specification=="object")return console.log(`[DIAG][${s}] GetRegistryComponent() returning spec as object`),i.specification;try{const a=JSON.parse(i.specification);return console.log(`[DIAG][${s}] GetRegistryComponent() returning parsed spec`,{name:a.name,hasCode:!!a.code,codeLength:a.code?.length}),a}catch(a){return console.error(`[DIAG][${s}] GetRegistryComponent() JSON PARSE FAILED:`,a),c(`Failed to parse component specification: ${a}`),null}}return console.warn(`[DIAG][${s}] GetRegistryComponent() response has GetRegistryComponent but no specification - returning null`),null}return console.warn(`[DIAG][${s}] GetRegistryComponent() result missing GetRegistryComponent field - returning null`,{resultExists:!!o,resultKeys:o?Object.keys(o):[]}),null}catch(t){throw console.error("[DIAG] GetRegistryComponent() CAUGHT ERROR:",t),c(t),new Error(`Failed to get registry component: ${t instanceof Error?t.message:"Unknown error"}`)}}async GetRegistryComponentWithHash(e){try{const t=m`
|
|
984
990
|
query GetRegistryComponent(
|
|
985
991
|
$registryName: String!,
|
|
986
992
|
$namespace: String!,
|
|
@@ -1001,7 +1007,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1001
1007
|
specification
|
|
1002
1008
|
}
|
|
1003
1009
|
}
|
|
1004
|
-
`,r={registryName:e.registryName,namespace:e.namespace,name:e.name};e.version!==void 0&&(r.version=e.version),e.hash!==void 0&&(r.hash=e.hash);const s=await this._dataProvider.ExecuteGQL(t,r);if(s&&s.GetRegistryComponent){const n=s.GetRegistryComponent;let
|
|
1010
|
+
`,r={registryName:e.registryName,namespace:e.namespace,name:e.name};e.version!==void 0&&(r.version=e.version),e.hash!==void 0&&(r.hash=e.hash);const s=await this._dataProvider.ExecuteGQL(t,r);if(s&&s.GetRegistryComponent){const n=s.GetRegistryComponent;let o;if(n.specification)try{o=JSON.parse(n.specification)}catch(i){c(`Failed to parse component specification in GetRegistryComponentWithHash: ${i}`),o=void 0}return{specification:o,hash:n.hash,notModified:n.notModified,message:n.message}}return{specification:void 0,hash:"",notModified:!1,message:"Component not found"}}catch(t){throw c(t),new Error(`Failed to get registry component with hash: ${t instanceof Error?t.message:"Unknown error"}`)}}async SearchRegistryComponents(e){try{const t=m`
|
|
1005
1011
|
query SearchRegistryComponents($params: SearchRegistryComponentsInput!) {
|
|
1006
1012
|
SearchRegistryComponents(params: $params) {
|
|
1007
1013
|
components
|
|
@@ -1010,7 +1016,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1010
1016
|
limit
|
|
1011
1017
|
}
|
|
1012
1018
|
}
|
|
1013
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{params:e});if(r&&r.SearchRegistryComponents){const s=r.SearchRegistryComponents;return{components:s.components.map(n=>JSON.parse(n)),total:s.total,offset:s.offset,limit:s.limit}}return{components:[],total:0,offset:0,limit:e.limit||10}}catch(t){throw
|
|
1019
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{params:e});if(r&&r.SearchRegistryComponents){const s=r.SearchRegistryComponents;return{components:s.components.map(n=>JSON.parse(n)),total:s.total,offset:s.offset,limit:s.limit}}return{components:[],total:0,offset:0,limit:e.limit||10}}catch(t){throw c(t),new Error(`Failed to search registry components: ${t instanceof Error?t.message:"Unknown error"}`)}}async ResolveComponentDependencies(e,t){try{const r=m`
|
|
1014
1020
|
query ResolveComponentDependencies(
|
|
1015
1021
|
$registryId: String!,
|
|
1016
1022
|
$componentId: String!
|
|
@@ -1035,7 +1041,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1035
1041
|
}
|
|
1036
1042
|
}
|
|
1037
1043
|
}
|
|
1038
|
-
`,s=await this._dataProvider.ExecuteGQL(r,{registryId:e,componentId:t});return s&&s.ResolveComponentDependencies?s.ResolveComponentDependencies:null}catch(r){throw
|
|
1044
|
+
`,s=await this._dataProvider.ExecuteGQL(r,{registryId:e,componentId:t});return s&&s.ResolveComponentDependencies?s.ResolveComponentDependencies:null}catch(r){throw c(r),new Error(`Failed to resolve component dependencies: ${r instanceof Error?r.message:"Unknown error"}`)}}async ComponentExists(e){try{return await this.GetRegistryComponent(e)!==null}catch{return!1}}async GetLatestVersion(e,t,r){try{return(await this.GetRegistryComponent({registryName:e,namespace:t,name:r,version:"latest"}))?.version||null}catch(s){return c(s),null}}async SendComponentFeedback(e){try{const t=m`
|
|
1039
1045
|
mutation SendComponentFeedback($feedback: ComponentFeedbackInput!) {
|
|
1040
1046
|
SendComponentFeedback(feedback: $feedback) {
|
|
1041
1047
|
success
|
|
@@ -1043,7 +1049,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1043
1049
|
error
|
|
1044
1050
|
}
|
|
1045
1051
|
}
|
|
1046
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return
|
|
1052
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return c(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}}class Me{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(o=>{try{const i=JSON.parse(o);i.resolver==="VersionHistoryResolver"&&i.type==="CreateLabelProgress"&&i.status==="ok"&&i.data&&e.OnProgress(i.data)}catch{}}));const r=m`
|
|
1047
1053
|
mutation CreateVersionLabel($input: CreateVersionLabelInput!, $sessionId: String) {
|
|
1048
1054
|
CreateVersionLabel(input: $input, sessionId: $sessionId) {
|
|
1049
1055
|
Success
|
|
@@ -1059,7 +1065,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1059
1065
|
}
|
|
1060
1066
|
}
|
|
1061
1067
|
}
|
|
1062
|
-
`,s={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(r,s);return this.processResult(n)}catch(r){const s=r instanceof Error?r.message:String(r);return
|
|
1068
|
+
`,s={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(r,s);return this.processResult(n)}catch(r){const s=r instanceof Error?r.message:String(r);return c(`GraphQLVersionHistoryClient.CreateLabel error: ${s}`),{Success:!1,Error:s}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return e.Description!=null&&(t.Description=e.Description),e.Scope!=null&&(t.Scope=e.Scope),e.EntityName!=null&&(t.EntityName=e.EntityName),e.ParentID!=null&&(t.ParentID=e.ParentID),e.ExternalSystemID!=null&&(t.ExternalSystemID=e.ExternalSystemID),e.IncludeDependencies!=null&&(t.IncludeDependencies=e.IncludeDependencies),e.MaxDepth!=null&&(t.MaxDepth=e.MaxDepth),e.ExcludeEntities!=null&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(r=>({Key:r.Key,Value:r.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(s=>({EntityName:s.EntityName??"",RecordID:s.RecordID??"",ErrorMessage:s.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 Te{static{p(this,"GraphQLFileStorageClient")}constructor(e){this._dataProvider=e}async ListObjects(e,t="",r){try{const s=m`
|
|
1063
1069
|
query ListStorageObjects($input: ListStorageObjectsInput!) {
|
|
1064
1070
|
ListStorageObjects(input: $input) {
|
|
1065
1071
|
objects {
|
|
@@ -1076,34 +1082,34 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1076
1082
|
prefixes
|
|
1077
1083
|
}
|
|
1078
1084
|
}
|
|
1079
|
-
`,n={input:{AccountID:e,Prefix:t,Delimiter:r||"/"}},
|
|
1085
|
+
`,n={input:{AccountID:e,Prefix:t,Delimiter:r||"/"}},o=await this._dataProvider.ExecuteGQL(s,n);if(!o?.ListStorageObjects)throw new Error("Invalid response from server");return{objects:o.ListStorageObjects.objects.map(i=>({...i,lastModified:new Date(i.lastModified)})),prefixes:o.ListStorageObjects.prefixes}}catch(s){const n=s;throw c(`Error listing storage objects: ${n}`),n}}async DirectoryExists(e,t){try{const r=await this.ListObjects(e,t.endsWith("/")?t:`${t}/`,"/");return r.objects.length>0||r.prefixes.length>0}catch(r){return c(`Error checking directory existence: ${r}`),!1}}async CreateDirectory(e,t){try{const r=m`
|
|
1080
1086
|
mutation CreateDirectory($input: CreateDirectoryInput!) {
|
|
1081
1087
|
CreateDirectory(input: $input)
|
|
1082
1088
|
}
|
|
1083
|
-
`,s={input:{AccountID:e,Path:t}};return(await this._dataProvider.ExecuteGQL(r,s))?.CreateDirectory??!1}catch(r){return
|
|
1089
|
+
`,s={input:{AccountID:e,Path:t}};return(await this._dataProvider.ExecuteGQL(r,s))?.CreateDirectory??!1}catch(r){return c(`Error creating directory: ${r}`),!1}}async ObjectExists(e,t){try{const r=t.substring(0,t.lastIndexOf("/")+1),s=t.substring(t.lastIndexOf("/")+1);return(await this.ListObjects(e,r,"/")).objects.some(o=>o.name===s||o.fullPath===t)}catch(r){return c(`Error checking object existence: ${r}`),!1}}async CreatePreAuthUploadUrl(e,t,r){try{const s=m`
|
|
1084
1090
|
mutation CreatePreAuthUploadUrl($input: CreatePreAuthUploadUrlInput!) {
|
|
1085
1091
|
CreatePreAuthUploadUrl(input: $input) {
|
|
1086
1092
|
UploadUrl
|
|
1087
1093
|
ProviderKey
|
|
1088
1094
|
}
|
|
1089
1095
|
}
|
|
1090
|
-
`,n={input:{AccountID:e,ObjectName:t,ContentType:r}},
|
|
1096
|
+
`,n={input:{AccountID:e,ObjectName:t,ContentType:r}},o=await this._dataProvider.ExecuteGQL(s,n);if(!o?.CreatePreAuthUploadUrl)throw new Error("Invalid response from server");return{uploadUrl:o.CreatePreAuthUploadUrl.UploadUrl,providerKey:o.CreatePreAuthUploadUrl.ProviderKey}}catch(s){const n=s;throw c(`Error creating pre-auth upload URL: ${n}`),n}}async CreatePreAuthDownloadUrl(e,t){try{const r=m`
|
|
1091
1097
|
query CreatePreAuthDownloadUrl($input: CreatePreAuthDownloadUrlInput!) {
|
|
1092
1098
|
CreatePreAuthDownloadUrl(input: $input)
|
|
1093
1099
|
}
|
|
1094
|
-
`,s={input:{AccountID:e,ObjectName:t}},n=await this._dataProvider.ExecuteGQL(r,s);if(n?.CreatePreAuthDownloadUrl===void 0)throw new Error("Invalid response from server");return n.CreatePreAuthDownloadUrl}catch(r){const s=r;throw
|
|
1100
|
+
`,s={input:{AccountID:e,ObjectName:t}},n=await this._dataProvider.ExecuteGQL(r,s);if(n?.CreatePreAuthDownloadUrl===void 0)throw new Error("Invalid response from server");return n.CreatePreAuthDownloadUrl}catch(r){const s=r;throw c(`Error creating pre-auth download URL: ${s}`),s}}async DeleteObject(e,t){try{const r=m`
|
|
1095
1101
|
mutation DeleteStorageObject($input: DeleteStorageObjectInput!) {
|
|
1096
1102
|
DeleteStorageObject(input: $input)
|
|
1097
1103
|
}
|
|
1098
|
-
`,s={input:{AccountID:e,ObjectName:t}};return(await this._dataProvider.ExecuteGQL(r,s))?.DeleteStorageObject??!1}catch(r){return
|
|
1104
|
+
`,s={input:{AccountID:e,ObjectName:t}};return(await this._dataProvider.ExecuteGQL(r,s))?.DeleteStorageObject??!1}catch(r){return c(`Error deleting storage object: ${r}`),!1}}async MoveObject(e,t,r){try{const s=m`
|
|
1099
1105
|
mutation MoveStorageObject($input: MoveStorageObjectInput!) {
|
|
1100
1106
|
MoveStorageObject(input: $input)
|
|
1101
1107
|
}
|
|
1102
|
-
`,n={input:{AccountID:e,OldName:t,NewName:r}};return(await this._dataProvider.ExecuteGQL(s,n))?.MoveStorageObject??!1}catch(s){return
|
|
1108
|
+
`,n={input:{AccountID:e,OldName:t,NewName:r}};return(await this._dataProvider.ExecuteGQL(s,n))?.MoveStorageObject??!1}catch(s){return c(`Error moving storage object: ${s}`),!1}}async CopyObject(e,t,r){try{const s=m`
|
|
1103
1109
|
mutation CopyStorageObject($input: CopyStorageObjectInput!) {
|
|
1104
1110
|
CopyStorageObject(input: $input)
|
|
1105
1111
|
}
|
|
1106
|
-
`,n={input:{AccountID:e,SourceName:t,DestinationName:r}};return(await this._dataProvider.ExecuteGQL(s,n))?.CopyStorageObject??!1}catch(s){return
|
|
1112
|
+
`,n={input:{AccountID:e,SourceName:t,DestinationName:r}};return(await this._dataProvider.ExecuteGQL(s,n))?.CopyStorageObject??!1}catch(s){return c(`Error copying storage object: ${s}`),!1}}async CopyObjectBetweenAccounts(e,t,r,s){try{const n=m`
|
|
1107
1113
|
mutation CopyObjectBetweenAccounts($input: CopyObjectBetweenAccountsInput!) {
|
|
1108
1114
|
CopyObjectBetweenAccounts(input: $input) {
|
|
1109
1115
|
success
|
|
@@ -1115,7 +1121,7 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1115
1121
|
destinationPath
|
|
1116
1122
|
}
|
|
1117
1123
|
}
|
|
1118
|
-
`,
|
|
1124
|
+
`,o={input:{SourceAccountID:e,DestinationAccountID:t,SourcePath:r,DestinationPath:s}},i=await this._dataProvider.ExecuteGQL(n,o);if(!i?.CopyObjectBetweenAccounts)throw new Error("Invalid response from server");return{success:i.CopyObjectBetweenAccounts.success,message:i.CopyObjectBetweenAccounts.message,bytesTransferred:i.CopyObjectBetweenAccounts.bytesTransferred,sourceAccount:i.CopyObjectBetweenAccounts.sourceAccount,destinationAccount:i.CopyObjectBetweenAccounts.destinationAccount,sourcePath:i.CopyObjectBetweenAccounts.sourcePath,destinationPath:i.CopyObjectBetweenAccounts.destinationPath}}catch(n){const o=n;return c(`Error copying object between accounts: ${o}`),{success:!1,message:o.message,sourceAccount:"",destinationAccount:"",sourcePath:r,destinationPath:s}}}async SearchFiles(e,t,r){try{const s=m`
|
|
1119
1125
|
query SearchAcrossAccounts($input: SearchAcrossAccountsInput!) {
|
|
1120
1126
|
SearchAcrossAccounts(input: $input) {
|
|
1121
1127
|
accountResults {
|
|
@@ -1143,5 +1149,5 @@ var B=Object.defineProperty;var h=(S,e)=>B(S,"name",{value:e,configurable:!0});i
|
|
|
1143
1149
|
failedAccounts
|
|
1144
1150
|
}
|
|
1145
1151
|
}
|
|
1146
|
-
`,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:r?.maxResultsPerAccount,FileTypes:r?.fileTypes,SearchContent:r?.searchContent}},
|
|
1152
|
+
`,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:r?.maxResultsPerAccount,FileTypes:r?.fileTypes,SearchContent:r?.searchContent}},o=await this._dataProvider.ExecuteGQL(s,n);if(!o?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=o.SearchAcrossAccounts;return{accountResults:i.accountResults.map(a=>({accountId:a.accountID,accountName:a.accountName,success:a.success,errorMessage:a.errorMessage,results:a.results.map(u=>({path:u.path,name:u.name,size:u.size,contentType:u.contentType,lastModified:new Date(u.lastModified),relevance:u.relevance,excerpt:u.excerpt,matchInFilename:u.matchInFilename,objectId:u.objectId})),totalMatches:a.totalMatches,hasMore:a.hasMore,nextPageToken:a.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(s){return c(`Error searching across accounts: ${s}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}export{Re as ActionItemInput,De as ActionItemOutput,K as BrowserIndexedDBStorageProvider,O as BrowserStorageProviderBase,b as FieldMapper,v as FireAndForgetHelper,Ce as GetDataOutput,_ as GraphQLAIClient,Ae as GraphQLActionClient,xe as GraphQLComponentRegistryClient,S as GraphQLDataProvider,Ne as GraphQLEncryptionClient,Te as GraphQLFileStorageClient,ge as GraphQLProviderConfigData,we as GraphQLSystemUserClient,be as GraphQLTestingClient,Q as GraphQLTransactionGroup,Me as GraphQLVersionHistoryClient,fe as RoleInput,Ie as RolesAndUsersInput,$e as SimpleRemoteEntity,Pe as SimpleRemoteEntityField,ve as SimpleRemoteEntityOutput,B as SyncDataAction,Ee as SyncDataResult,he as SyncRolesAndUsersResult,Se as UserInput,Be as gql,pe as setupGraphQLClient};
|
|
1147
1153
|
//# sourceMappingURL=index.mjs.map
|