@memberjunction/graphql-dataprovider 2.104.0 → 2.106.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 +27 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.mts +31 -1
- package/dist/index.mjs +67 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var we=Object.defineProperty;var f=(I,e)=>we(I,"name",{value:e,configurable:!0});var h;import{gql as m,GraphQLClient as ye}from"graphql-request";import{gql as je}from"graphql-request";import{TransactionGroupBase as Ee,TransactionResult as Pe,LogError as l,ProviderConfigDataBase as $e,ProviderBase as Ne,UserInfo as me,ProviderType as ve,BaseEntityResult as ge,EntityFieldTSType as E,TransactionItem as pe,UserRoleInfo as Ce,SetProvider as Ve}from"@memberjunction/core";import{ViewInfo as fe}from"@memberjunction/core-entities";import{openDB as xe}from"@tempfix/idb";import{Observable as Se}from"rxjs";import{createClient as Re}from"graphql-ws";import{v4 as Qe}from"uuid";import{SafeJSONParse as N,MJGlobal as Ge,MJEventType as Fe}from"@memberjunction/global";const J=class J{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}};f(J,"FieldMapper");let $=J;const j=class j extends Ee{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 Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
6
6
|
ResultsJSON
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,t=[];for(const
|
|
9
|
+
`,t=[];for(const a of this.PendingTransactions)t.push({EntityName:a.BaseEntity.EntityInfo.Name,EntityObjectJSON:await a.BaseEntity.GetDataObjectJSON(),OperationType:a.OperationType});const r={group:{Items:t,Variables:this.Variables.map(a=>({Name:a.Name,ItemIndex:this.MapVariableEntityObjectToPosition(a),FieldName:a.FieldName,Type:a.Type}))}},s=await this._provider.ExecuteGQL(e,r);if(s&&s.ExecuteTransactionGroup){const a=s.ExecuteTransactionGroup,n=[];for(let o=0;o<this.PendingTransactions.length;o++){const i=a.ResultsJSON[o],y=N(i),p=this.PendingTransactions[o];n.push(new Pe(p,y,y!==null))}return n}else throw new Error("Failed to execute transaction group")}};f(j,"GraphQLTransactionGroup");let v=j;const z=class z{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,12 +65,13 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
65
65
|
chatResult
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,r=this.preparePromptVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(s)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,
|
|
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,a;try{t.parsedResult&&(r=JSON.parse(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(a=JSON.parse(t.chatResult))}catch{a=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:a}}handlePromptError(e){const t=e;return l(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(n=>{try{console.log("[GraphQLAIClient] Received statusUpdate message:",n);const o=JSON.parse(n);if(console.log("[GraphQLAIClient] Parsed message:",o),o.resolver==="RunAIAgentResolver"&&o.type==="ExecutionProgress"&&o.status==="ok"&&o.data?.progress){console.log("[GraphQLAIClient] Forwarding progress to callback:",o.data.progress);const i={...o.data.progress,metadata:{...o.data.progress.metadata||{},agentRunId:o.data.agentRunId}};e.onProgress(i)}else console.log("[GraphQLAIClient] Message does not match filter criteria:",{resolver:o.resolver,type:o.type,status:o.status,hasProgress:!!o.data?.progress})}catch(o){console.error("[GraphQLAIClient] Failed to parse progress message:",o,"Raw message:",n)}}));const r=m`
|
|
69
69
|
mutation RunAIAgent(
|
|
70
70
|
$agentId: String!,
|
|
71
71
|
$messages: String!,
|
|
72
72
|
$sessionId: String!,
|
|
73
73
|
$data: String,
|
|
74
|
+
$payload: String,
|
|
74
75
|
$templateData: String,
|
|
75
76
|
$lastRunId: String,
|
|
76
77
|
$autoPopulateLastRunPayload: Boolean,
|
|
@@ -82,6 +83,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
82
83
|
messages: $messages,
|
|
83
84
|
sessionId: $sessionId,
|
|
84
85
|
data: $data,
|
|
86
|
+
payload: $payload,
|
|
85
87
|
templateData: $templateData,
|
|
86
88
|
lastRunId: $lastRunId,
|
|
87
89
|
autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
|
|
@@ -94,7 +96,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
94
96
|
result
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
|
-
`,s=this.prepareAgentVariables(e),
|
|
99
|
+
`,s=this.prepareAgentVariables(e),a=await this._dataProvider.ExecuteGQL(r,s);return this.processAgentResult(a.RunAIAgent?.result)}catch(r){return this.handleAgentError(r)}finally{t&&t.unsubscribe()}}prepareAgentVariables(e){const t={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return 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.conversationDetailId!==void 0&&(t.conversationDetailId=e.conversationDetailId),t}processAgentResult(e){return N(e)}handleAgentError(e){return l(`Error running AI agent: ${e}`),{success:!1,agentRun:void 0}}async ExecuteSimplePrompt(e){try{const t=m`
|
|
98
100
|
mutation ExecuteSimplePrompt(
|
|
99
101
|
$systemPrompt: String!,
|
|
100
102
|
$messages: String,
|
|
@@ -117,7 +119,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
117
119
|
executionTimeMs
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
`,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
|
|
122
|
+
`,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 a=s.ExecuteSimplePrompt;let n;if(a.resultObject)try{n=JSON.parse(a.resultObject)}catch{n=a.resultObject}return{success:a.success,result:a.result,resultObject:n,modelName:a.modelName,error:a.error,executionTimeMs:a.executionTimeMs}}catch(t){const r=t;return l(`Error executing simple prompt: ${r}`),{success:!1,modelName:"Unknown",error:r.message||"Unknown error occurred"}}}async EmbedText(e){try{const t=m`
|
|
121
123
|
mutation EmbedText(
|
|
122
124
|
$textToEmbed: [String!]!,
|
|
123
125
|
$modelSize: String!
|
|
@@ -132,15 +134,15 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
132
134
|
error
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
|
-
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},
|
|
137
|
+
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,s);if(!a?.EmbedText)throw new Error("Invalid response from server");const n=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){const r=t;return l(`Error generating embeddings: ${r}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}};f(z,"GraphQLAIClient");let C=z;const W=class W extends $e{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 URL(){return this.Data.URL}get WSURL(){return this.Data.WSURL}get RefreshTokenFunction(){return this.Data.RefreshFunction}constructor(e,t,r,s,a,n,o,i){super({Token:e,URL:t,WSURL:r,MJAPIKey:i,RefreshTokenFunction:s},a,n,o)}};f(W,"GraphQLProviderConfigData");let V=W;const he=(h=class extends Ne{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
|
|
136
138
|
${this.userInfoString()}
|
|
137
139
|
UserRoles_UserIDArray {
|
|
138
140
|
${this.userRoleInfoString()}
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
|
-
`,this._currentUserQuery=
|
|
143
|
+
`,this._currentUserQuery=m`query CurrentUserAndRoles {
|
|
142
144
|
${this._innerCurrentUserQueryString}
|
|
143
|
-
}`,this._wsClient=null,this._pushStatusRequests=[],h._instance||(h._instance=this)}static get Instance(){return h._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new
|
|
145
|
+
}`,this._wsClient=null,this._pushStatusRequests=[],h._instance||(h._instance=this)}static get Instance(){return h._instance}get ConfigData(){return this._configData}sanitizeGraphQLName(e){if(!e||e.length===0)return"";let t=e.replace(/[^A-Za-z0-9_]/g,"");return t.startsWith("__")&&(t=t.substring(2)),t=t.replace(/_/g,""),t.length===0||/^[0-9]/.test(t)?"_"+t:t}getGraphQLTypeNameBase(e){const t=e.SchemaName.trim().toLowerCase()===h.MJ_CORE_SCHEMA.trim().toLowerCase()?"MJ":this.sanitizeGraphQLName(e.SchemaName),r=this.sanitizeGraphQLName(e.BaseTable);return`${t}${r}`}get AI(){return this._aiClient||(this._aiClient=new C(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return Qe()}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 r?(this._configData=e,this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey),await this.SaveStoredSessionID(this._sessionId)):(h.Instance._configData=e,h.Instance._sessionId===void 0&&(h.Instance._sessionId=await this.GetPreferredUUID(s)),h.Instance._client||(h.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,h.Instance._sessionId,e.MJAPIKey)),await h.Instance.SaveStoredSessionID(h.Instance._sessionId)),super.Config(e)}catch(a){throw l(a),a}}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.UserRoles_UserIDArray.map(s=>this.ConvertBackToMJFields(s));return t.UserRoles_UserIDArray=r,new me(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=m`
|
|
144
146
|
query GetReportDataQuery ($ReportID: String!) {
|
|
145
147
|
GetReportData(ReportID: $ReportID) {
|
|
146
148
|
Success
|
|
@@ -149,19 +151,19 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
149
151
|
ExecutionTime
|
|
150
152
|
ErrorMessage
|
|
151
153
|
}
|
|
152
|
-
}`,s=await this.ExecuteGQL(r,{ReportID:e.ReportID});if(s&&s.GetReportData)return{ReportID:e.ReportID,Success:s.GetReportData.Success,Results:JSON.parse(s.GetReportData.Results),RowCount:s.GetReportData.RowCount,ExecutionTime:s.GetReportData.ExecutionTime,ErrorMessage:s.GetReportData.ErrorMessage}}async RunQuery(e,t){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);throw new Error("No QueryID or QueryName provided to RunQuery")}async RunQueryByID(e,t,r,s,n,
|
|
154
|
+
}`,s=await this.ExecuteGQL(r,{ReportID:e.ReportID});if(s&&s.GetReportData)return{ReportID:e.ReportID,Success:s.GetReportData.Success,Results:JSON.parse(s.GetReportData.Results),RowCount:s.GetReportData.RowCount,ExecutionTime:s.GetReportData.ExecutionTime,ErrorMessage:s.GetReportData.ErrorMessage}}async RunQuery(e,t){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);throw new Error("No QueryID or QueryName provided to RunQuery")}async RunQueryByID(e,t,r,s,a,n,o){const i=m`
|
|
153
155
|
query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
|
|
154
156
|
GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
155
157
|
${this.QueryReturnFieldList}
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
`,
|
|
160
|
+
`,y={QueryID:e};t!==void 0&&(y.CategoryID=t),r!==void 0&&(y.CategoryPath=r),a!==void 0&&(y.Parameters=a),n!==void 0&&(y.MaxRows=n),o!==void 0&&(y.StartRow=o);const p=await this.ExecuteGQL(i,y);if(p&&p.GetQueryData)return this.TransformQueryPayload(p.GetQueryData)}async RunQueryByName(e,t,r,s,a,n,o){const i=m`
|
|
159
161
|
query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
|
|
160
162
|
GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
161
163
|
${this.QueryReturnFieldList}
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
|
-
`,
|
|
166
|
+
`,y={QueryName:e};t!==void 0&&(y.CategoryID=t),r!==void 0&&(y.CategoryPath=r),a!==void 0&&(y.Parameters=a),n!==void 0&&(y.MaxRows=n),o!==void 0&&(y.StartRow=o);const p=await this.ExecuteGQL(i,y);if(p&&p.GetQueryDataByName)return this.TransformQueryPayload(p.GetQueryDataByName)}get QueryReturnFieldList(){return`
|
|
165
167
|
Success
|
|
166
168
|
QueryID
|
|
167
169
|
QueryName
|
|
@@ -170,11 +172,11 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
170
172
|
TotalRowCount
|
|
171
173
|
ExecutionTime
|
|
172
174
|
ErrorMessage
|
|
173
|
-
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
|
|
175
|
+
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 l(`Error transforming query payload: ${t}`),null}}async RunView(e,t){await this.PreProcessRunView(e,t);try{let r="",s="";if(e){const a={};let n,o;if(e.ViewEntity)o=e.ViewEntity,n=o.Entity;else{const{entityName:u,v:c}=await this.getEntityNameAndUserView(e,t);o=c,n=u}const i=this.Entities.find(u=>u.Name===n);if(!i)throw new Error(`Entity ${n} not found in metadata`);let y=!1;const p=this.getGraphQLTypeNameBase(i);e.ViewID?(r=`Run${p}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(r=`Run${p}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(y=!0,r=`Run${p}DynamicView`,s="RunDynamicViewInput",a.EntityName=e.EntityName),a.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",a.OrderBy=e.OrderBy?e.OrderBy:"",a.UserSearchString=e.UserSearchString?e.UserSearchString:"",a.Fields=e.Fields,a.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,e.MaxRows!==void 0&&(a.MaxRows=e.MaxRows),e.StartRow!==void 0&&(a.StartRow=e.StartRow),a.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,a.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(a.AuditLogDescription=e.AuditLogDescription),y||(a.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",a.ExcludeDataFromAllPriorViewRuns=e.ExcludeDataFromAllPriorViewRuns?e.ExcludeDataFromAllPriorViewRuns:!1,a.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",a.SaveViewResults=e.SaveViewResults?e.SaveViewResults:!1);const g=this.getViewRunTimeFieldList(i,o,e,y),D=m`
|
|
174
176
|
query RunViewQuery ($input: ${s}!) {
|
|
175
177
|
${r}(input: $input) {
|
|
176
178
|
Results {
|
|
177
|
-
${
|
|
179
|
+
${g.join(`
|
|
178
180
|
`)}
|
|
179
181
|
}
|
|
180
182
|
UserViewRunID
|
|
@@ -184,7 +186,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
184
186
|
Success
|
|
185
187
|
ErrorMessage
|
|
186
188
|
}
|
|
187
|
-
}`,d=await this.ExecuteGQL(
|
|
189
|
+
}`,d=await this.ExecuteGQL(D,{input:a});if(d&&d[r]){const u=d[r].Results;if(u&&u.length>0){const R=i.Fields.filter(S=>S.CodeName!==S.Name&&S.CodeName!==void 0);u.forEach(S=>{this.ConvertBackToMJFields(S),R.forEach(w=>{S[w.Name]=S[w.CodeName]})})}const c=d[r];return await this.PostProcessRunView(c,e,t),c}}else throw"No parameters passed to RunView";return null}catch(r){throw l(r),r}}async RunViews(e,t){await this.PreProcessRunViews(e,t);try{let r=[],s=[],a=[];for(const i of e){let y="",p="";const g={};let D=null,d=null;if(i.ViewEntity)d=i.ViewEntity,D=d.Get("Entity");else{const{entityName:S,v:w}=await this.getEntityNameAndUserView(i,t);d=w,D=S}const u=this.Entities.find(S=>S.Name===D);if(!u)throw new Error(`Entity ${D} not found in metadata`);s.push(u);let c=!1;const R=this.getGraphQLTypeNameBase(u);i.ViewID?(y=`Run${R}ViewByID`,p="RunViewByIDInput",g.ViewID=i.ViewID):i.ViewName?(y=`Run${R}ViewByName`,p="RunViewByNameInput",g.ViewName=i.ViewName):(c=!0,y=`Run${R}DynamicView`,p="RunDynamicViewInput",g.EntityName=i.EntityName),g.ExtraFilter=i.ExtraFilter||"",g.OrderBy=i.OrderBy||"",g.UserSearchString=i.UserSearchString||"",g.Fields=i.Fields,g.IgnoreMaxRows=i.IgnoreMaxRows||!1,i.MaxRows!==void 0&&(g.MaxRows=i.MaxRows),i.StartRow!==void 0&&(g.StartRow=i.StartRow),g.ForceAuditLog=i.ForceAuditLog||!1,g.ResultType=i.ResultType||"simple",i.AuditLogDescription&&i.AuditLogDescription.length>0&&(g.AuditLogDescription=i.AuditLogDescription),c||(g.ExcludeUserViewRunID=i.ExcludeUserViewRunID||"",g.ExcludeDataFromAllPriorViewRuns=i.ExcludeDataFromAllPriorViewRuns||!1,g.OverrideExcludeFilter=i.OverrideExcludeFilter||"",g.SaveViewResults=i.SaveViewResults||!1),r.push(g),a.push(...this.getViewRunTimeFieldList(u,d,i,c))}const n=m`
|
|
188
190
|
query RunViewsQuery ($input: [RunViewGenericInput!]!) {
|
|
189
191
|
RunViews(input: $input) {
|
|
190
192
|
Results {
|
|
@@ -202,7 +204,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
202
204
|
Success
|
|
203
205
|
ErrorMessage
|
|
204
206
|
}
|
|
205
|
-
}`,o=await this.ExecuteGQL(
|
|
207
|
+
}`,o=await this.ExecuteGQL(n,{input:r});if(o&&o.RunViews){const i=o.RunViews;for(const[y,p]of i.entries())p.Results=p.Results.map(g=>{let D=JSON.parse(g.Data);return this.ConvertBackToMJFields(D),D});return await this.PostProcessRunViews(i,e,t),i}return null}catch(r){throw l(r),r}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await fe.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await fe.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 a=[],n=new $;if(r.Fields){for(const o of e.PrimaryKeys)r.Fields.find(i=>i.trim().toLowerCase()===o.Name.toLowerCase())===void 0&&a.push(o.Name);r.Fields.forEach(o=>{a.push(n.MapFieldName(o))})}else if(s)e.Fields.forEach(o=>{o.IsBinaryFieldType||a.push(n.MapFieldName(o.CodeName))});else{for(const o of e.PrimaryKeys)a.find(i=>i.trim().toLowerCase()===o.Name.toLowerCase())===void 0&&a.push(o.Name);t.Columns.forEach(o=>{o.hidden===!1&&!a.find(i=>i.trim().toLowerCase()===o.EntityField?.Name.trim().toLowerCase())&&o.EntityField&&a.push(n.MapFieldName(o.EntityField.CodeName))})}return a}get ProviderType(){return ve.Network}async GetRecordChanges(e,t){try{const r={EntityName:"Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},s=await this.RunView(r);return s?s.Results.sort((a,n)=>a.ChangedAt>n.ChangedAt?-1:1):null}catch(r){throw l(r),r}}async GetRecordDependencies(e,t){try{const r=m`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
206
208
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
207
209
|
EntityName
|
|
208
210
|
RelatedEntityName
|
|
@@ -214,7 +216,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
|
-
}`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw
|
|
219
|
+
}`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw l(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!) {
|
|
218
220
|
GetRecordDuplicates(params: $params) {
|
|
219
221
|
Status
|
|
220
222
|
ErrorMessage
|
|
@@ -236,7 +238,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
}
|
|
239
|
-
}`;let s={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(
|
|
241
|
+
}`;let s={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(n=>n.Copy())};const a=await this.ExecuteGQL(r,{params:s});if(a&&a.GetRecordDuplicates)return a.GetRecordDuplicates}async MergeRecords(e,t,r){const s=this.Entities.find(a=>a.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 a=m`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
|
|
240
242
|
MergeRecords(request: $request) {
|
|
241
243
|
Success
|
|
242
244
|
OverallStatus
|
|
@@ -253,32 +255,32 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
253
255
|
Message
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
|
-
}`,
|
|
257
|
-
${e.Fields.map(d=>
|
|
258
|
+
}`,n={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(i=>({FieldName:i.FieldName,Value:i.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(i=>i.Copy())};return(await this.ExecuteGQL(a,{request:n}))?.MergeRecords}catch(a){return l(a),{Success:!1,OverallStatus:a&&a.message?a.message:a,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){const s=new ge;try{e.RegisterTransactionPreprocessing();const a={input:{}},n=e.IsSaved?"Update":"Create";s.StartedAt=new Date,s.Type=e.IsSaved?"update":"create",s.OriginalValues=e.Fields.map(d=>({FieldName:d.CodeName,Value:d.Value})),e.ResultHistory.push(s);const o=this.getGraphQLTypeNameBase(e.EntityInfo),i=`${n}${o}`,y=e.Fields.filter(d=>!d.ReadOnly||d.IsPrimaryKey&&e.IsSaved),p=new $,g=` ${i}(input: $input) {
|
|
259
|
+
${e.Fields.map(d=>p.MapFieldName(d.CodeName)).join(`
|
|
258
260
|
`)}
|
|
259
|
-
}`,
|
|
260
|
-
${
|
|
261
|
+
}`,D=m`mutation ${n}${o} ($input: ${i}Input!) {
|
|
262
|
+
${g}
|
|
261
263
|
}
|
|
262
|
-
`;for(let d=0;d<
|
|
263
|
-
${
|
|
264
|
+
`;for(let d=0;d<y.length;d++){const u=y[d];let c=u.Value;if(c)switch(u.EntityFieldInfo.TSType){case E.Date:c=c.getTime();break;case E.Boolean:typeof c!="boolean"&&(c=parseInt(c)!==0);break;case E.Number:if(typeof c!="number"){const R=Number(c);isNaN(R)||(c=R)}break}c===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?c=u.EntityFieldInfo.DefaultValue:u.FieldType===E.Number||u.FieldType===E.Boolean?c=0:c=""),a.input[u.CodeName]=c}if(n.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const d=[];e.Fields.forEach(u=>{let c=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===E.Date?c=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===E.Boolean?c=u.OldValue===!0?"1":"0":typeof u.OldValue!="string"?c=u.OldValue.toString():c=u.OldValue),d.push({Key:u.CodeName,Value:c})}),a.input.OldValues___=d}if(e.TransactionGroup){const d=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new pe(e,s.Type==="create"?"Create":"Update",g,a,{mutationName:i,mutationInputTypes:d},(u,c)=>{s.EndedAt=new Date,c&&u?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(u)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const d=await this.ExecuteGQL(D,a);if(d&&d[i])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(d[i]),s.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(a){return s.Success=!1,s.EndedAt=new Date,s.Message=a.response?.errors?.length>0?a.response.errors[0].message:a.message,l(a),null}}async Load(e,t,r=null,s){try{const a={};let n="",o="";for(let d=0;d<t.KeyValuePairs.length;d++){const u=e.Fields.find(S=>S.Name.trim().toLowerCase()===t.KeyValuePairs[d].FieldName.trim().toLowerCase()).EntityFieldInfo,c=t.GetValueByIndex(d),R=u.GraphQLType;if(o.length>0&&(o+=", "),o+=`$${u.CodeName}: ${R}!`,n.length>0&&(n+=", "),n+=`${u.CodeName}: $${u.CodeName}`,u.TSType===E.Number){if(isNaN(t.GetValueByIndex(d)))throw new Error(`Primary Key value ${c} (${u.Name}) is not a valid number`);a[u.CodeName]=parseInt(c)}else a[u.CodeName]=c}const i=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",y=this.getGraphQLTypeNameBase(e.EntityInfo),p=new $,g=m`query Single${y}${i.length>0?"Full":""} (${o}) {
|
|
265
|
+
${y}(${n}) {
|
|
264
266
|
${e.Fields.filter(d=>!d.EntityFieldInfo.IsBinaryFieldType).map(d=>d.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?d.CodeName.replace("__mj_","_mj__"):d.CodeName).join(`
|
|
265
267
|
`)}
|
|
266
268
|
${i}
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
|
-
`,
|
|
271
|
+
`,D=await this.ExecuteGQL(g,a);return D&&D[y]?this.ConvertBackToMJFields(D[y]):null}catch(a){return l(a),null}}ConvertBackToMJFields(e){return new $().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 a=e.RelatedEntities[s],n=this.Entities.find(i=>i.ID===a.RelatedEntityID);let o="";a.Type.toLowerCase().trim()==="many to many"?o=`${a.RelatedEntityCodeName}_${a.JoinEntityJoinField.replace(/\s/g,"")}`:o=`${a.RelatedEntityCodeName}_${a.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
|
|
270
272
|
${o} {
|
|
271
|
-
${
|
|
273
|
+
${n.Fields.map(i=>i.CodeName).join(`
|
|
272
274
|
`)}
|
|
273
275
|
}
|
|
274
|
-
`}return r}async Delete(e,t,r){const s=new ge;try{e.RegisterTransactionPreprocessing(),s.StartedAt=new Date,s.Type="delete",s.OriginalValues=e.Fields.map(u=>({FieldName:u.CodeName,Value:u.Value})),e.ResultHistory.push(s);const
|
|
275
|
-
`),
|
|
276
|
-
${
|
|
276
|
+
`}return r}async Delete(e,t,r){const s=new ge;try{e.RegisterTransactionPreprocessing(),s.StartedAt=new Date,s.Type="delete",s.OriginalValues=e.Fields.map(u=>({FieldName:u.CodeName,Value:u.Value})),e.ResultHistory.push(s);const a={},n=[];let o="",i="",y="";for(let u of e.PrimaryKey.KeyValuePairs){const c=e.Fields.find(R=>R.Name.trim().toLowerCase()===u.FieldName.trim().toLowerCase());a[c.CodeName]=c.Value,n.push({varName:c.CodeName,inputType:c.EntityFieldInfo.GraphQLType+"!"}),o.length>0&&(o+=", "),o+=`${c.CodeName}: $${c.CodeName}`,i.length>0&&(i+=", "),i+=`$${c.CodeName}: ${c.EntityFieldInfo.GraphQLType}!`,y.length>0&&(y+=`
|
|
277
|
+
`),y+=`${c.CodeName}`}n.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const g="Delete"+this.getGraphQLTypeNameBase(e.EntityInfo),D=m`${g}(${o}, options___: $options___) {
|
|
278
|
+
${y}
|
|
277
279
|
}
|
|
278
|
-
`,d=
|
|
279
|
-
${
|
|
280
|
+
`,d=m`mutation ${g} (${i}, $options___: DeleteOptionsInput!) {
|
|
281
|
+
${D}
|
|
280
282
|
}
|
|
281
|
-
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new pe(e,"Delete",
|
|
283
|
+
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new pe(e,"Delete",D,a,{mutationName:g,mutationInputTypes:n},(u,c)=>{if(s.EndedAt=new Date,c&&u){let R=!0;for(const S of e.PrimaryKey.KeyValuePairs)S.Value!==u[S.FieldName]&&(R=!1);R?s.Success=!0:(s.Success=!1,s.Message="Transaction failed to commit")}else s.Success=!1,s.Message="Transaction failed to commit"})),!0;{const u=await this.ExecuteGQL(d,a);if(u&&u[g]){const c=u[g];for(let R of e.PrimaryKey.KeyValuePairs){let S=c[R.FieldName],w=R.Value;if(typeof w=="number"&&(w=w.toString()),typeof S=="number"&&(S=S.toString()),w!==S)throw new Error(`Primary key value mismatch in server Delete response. Field: ${R.FieldName}, Original: ${w}, Returned: ${S}`)}return s.Success=!0,s.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(a){return s.EndedAt=new Date,s.Success=!1,s.Message=a.response?.errors?.length>0?a.response.errors[0].message:a.message,l(a),!1}}async GetDatasetByName(e,t){const r=m`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
|
|
282
284
|
GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
|
|
283
285
|
DatasetID
|
|
284
286
|
DatasetName
|
|
@@ -287,7 +289,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
287
289
|
LatestUpdateDate
|
|
288
290
|
Results
|
|
289
291
|
}
|
|
290
|
-
}`,s=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return s&&s.GetDatasetByName&&s.GetDatasetByName.Success?{DatasetID:s.GetDatasetByName.DatasetID,DatasetName:s.GetDatasetByName.DatasetName,Success:s.GetDatasetByName.Success,Status:s.GetDatasetByName.Status,LatestUpdateDate:new Date(s.GetDatasetByName.LatestUpdateDate),Results:JSON.parse(s.GetDatasetByName.Results)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,Results:null}}async GetDatasetStatusByName(e,t){const r=
|
|
292
|
+
}`,s=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return s&&s.GetDatasetByName&&s.GetDatasetByName.Success?{DatasetID:s.GetDatasetByName.DatasetID,DatasetName:s.GetDatasetByName.DatasetName,Success:s.GetDatasetByName.Success,Status:s.GetDatasetByName.Status,LatestUpdateDate:new Date(s.GetDatasetByName.LatestUpdateDate),Results:JSON.parse(s.GetDatasetByName.Results)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,Results:null}}async GetDatasetStatusByName(e,t){const r=m`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
|
|
291
293
|
GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
|
|
292
294
|
DatasetID
|
|
293
295
|
DatasetName
|
|
@@ -296,22 +298,22 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
296
298
|
LatestUpdateDate
|
|
297
299
|
EntityUpdateDates
|
|
298
300
|
}
|
|
299
|
-
}`,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
|
|
301
|
+
}`,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 v(this)}async GetRecordFavoriteStatus(e,t,r){if(!r.Validate().IsValid)return!1;const a=this.Entities.find(i=>i.Name===t);if(!a)throw new Error(`Entity ${t} not found in metadata`);const n=m`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
|
|
300
302
|
GetRecordFavoriteStatus(params: $params) {
|
|
301
303
|
Success
|
|
302
304
|
IsFavorite
|
|
303
305
|
}
|
|
304
|
-
}`,o=await this.ExecuteGQL(
|
|
306
|
+
}`,o=await this.ExecuteGQL(n,{params:{UserID:e,EntityID:a.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}}});if(o&&o.GetRecordFavoriteStatus&&o.GetRecordFavoriteStatus.Success)return o.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,t,r,s,a){const n=this.Entities.find(y=>y.Name===t);if(!n)throw new Error(`Entity ${t} not found in metadata`);const o=m`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
|
|
305
307
|
SetRecordFavoriteStatus(params: $params){
|
|
306
308
|
Success
|
|
307
309
|
}
|
|
308
|
-
}`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:
|
|
310
|
+
}`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:n.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)},IsFavorite:s}});if(i&&i.SetRecordFavoriteStatus!==null)return i.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,t){if(!e||!t||t.KeyValuePairs?.length===0)return null;const r=m`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
309
311
|
GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
|
|
310
312
|
Success
|
|
311
313
|
Status
|
|
312
314
|
RecordName
|
|
313
315
|
}
|
|
314
|
-
}`,s=await this.ExecuteGQL(r,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}});if(s&&s.GetEntityRecordName&&s.GetEntityRecordName.Success)return s.GetEntityRecordName.RecordName}async GetEntityRecordNames(e){if(!e)return null;const t=
|
|
316
|
+
}`,s=await this.ExecuteGQL(r,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}});if(s&&s.GetEntityRecordName&&s.GetEntityRecordName.Success)return s.GetEntityRecordName.RecordName}async GetEntityRecordNames(e){if(!e)return null;const t=m`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
|
|
315
317
|
GetEntityRecordNames(info: $info) {
|
|
316
318
|
Success
|
|
317
319
|
Status
|
|
@@ -324,35 +326,35 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
324
326
|
EntityName
|
|
325
327
|
RecordName
|
|
326
328
|
}
|
|
327
|
-
}`,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}async GetDataContextData(e){try{const t=
|
|
329
|
+
}`,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}async GetDataContextData(e){try{const t=m`query GetDataContextData ($DataContextID: String!) {
|
|
328
330
|
GetDataContextData(DataContextID: $DataContextID) {
|
|
329
331
|
Success
|
|
330
332
|
ErrorMessages
|
|
331
333
|
Results
|
|
332
334
|
}
|
|
333
|
-
}`,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
|
|
335
|
+
}`,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 l(t),t}}async GetDataContextItemData(e){try{const t=m`query GetDataContextItemData ($DataContextItemID: String!) {
|
|
334
336
|
GetDataContextItemData(DataContextItemID: $DataContextItemID) {
|
|
335
337
|
Success
|
|
336
338
|
ErrorMessage
|
|
337
339
|
Result
|
|
338
340
|
}
|
|
339
|
-
}`,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
|
|
341
|
+
}`,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 l(t),t}}static async ExecuteGQL(e,t,r=!0){return h.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(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 l("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw l(s),s}}async RefreshToken(){if(this._configData.Data.RefreshTokenFunction){const e=await this._configData.Data.RefreshTokenFunction();if(e)this._configData.Token=e,this._client=this.CreateNewGraphQLClient(this._configData.URL,this._configData.Token,this._sessionId,this._configData.MJAPIKey);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 h.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,s){const a={"x-session-id":r};return t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),new ye(e,{headers:a})}userInfoString(){return this.infoString(new me(null,null))}userRoleInfoString(){return this.infoString(new Ce(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
|
|
340
342
|
`:s.startsWith("_")||(t+=s+`
|
|
341
|
-
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new
|
|
343
|
+
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new Q),this._localStorageProvider}get Metadata(){return this}subscribe(e,t){return this._wsClient||(this._wsClient=Re({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new Se(r=>{const s=this._wsClient.subscribe({query:e,variables:t},{next:a=>{r.next(a.data)},error:a=>{r.error(a)},complete:()=>{r.complete()}});return()=>{s()}})}PushStatusUpdates(e=null){e||(e=this.sessionId),this._wsClient||(this._wsClient=Re({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}}));const t=this._pushStatusRequests.find(a=>a.sessionId===e);if(t)return t.observable;const r=m`subscription StatusUpdates($sessionId: String!) {
|
|
342
344
|
statusUpdates(sessionId: $sessionId) {
|
|
343
345
|
date
|
|
344
346
|
message
|
|
345
347
|
sessionId
|
|
346
348
|
}
|
|
347
349
|
}
|
|
348
|
-
`,s=new Se(
|
|
350
|
+
`,s=new Se(a=>(this._wsClient.subscribe({query:r,variables:{sessionId:e}},{next:n=>a.next(n.data.statusUpdates.message),error:n=>a.error(n),complete:()=>a.complete()}),()=>{console.log("would unsub here")}));return this._pushStatusRequests.push({sessionId:e,observable:s}),s}},f(h,"_GraphQLDataProvider"),h);he.MJ_CORE_SCHEMA="__mj";let De=he;const H=class H{constructor(){this._localStorage={}}async GetItem(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)?t(this._localStorage[e]):t(null)})}async SetItem(e,t){return new Promise(r=>{this._localStorage[e]=t,r()})}async Remove(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],t()})}};f(H,"BrowserStorageProviderBase");let x=H;const Te="MJ_Metadata",P="Metadata_KVPairs",X=class X extends x{constructor(){super(),this.dbPromise=xe(Te,1,{upgrade(e){e.objectStoreNames.contains(P)||e.createObjectStore(P)}})}async setItem(e,t){const s=(await this.dbPromise).transaction(P,"readwrite");await s.objectStore(P).put(t,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(P).objectStore(P).get(e)}async remove(e){const r=(await this.dbPromise).transaction(P,"readwrite");await r.objectStore(P).delete(e),await r.done}};f(X,"BrowserIndexedDBStorageProvider");let Q=X;async function Ue(I){const e=new De;return Ve(e),await e.Config(I),Ge.Instance.RaiseEvent({event:Fe.LoggedIn,eventCode:null,component:this,args:null}),e}f(Ue,"setupGraphQLClient");const Z=class Z{};f(Z,"SyncRolesAndUsersResult");let G=Z;const Y=class Y{};f(Y,"RoleInput");let F=Y;const ee=class ee{};f(ee,"UserInput");let T=ee;const te=class te{};f(te,"RolesAndUsersInput");let U=te;var Ie=(I=>(I.Create="Create",I.Update="Update",I.CreateOrUpdate="CreateOrUpdate",I.Delete="Delete",I.DeleteWithFilter="DeleteWithFilter",I))(Ie||{});const re=class re{};f(re,"ActionItemInput");let b=re;const se=class se{constructor(){this.Results=[]}};f(se,"SyncDataResult");let M=se;const ae=class ae{};f(ae,"ActionItemOutput");let L=ae;const ne=class ne{get Client(){return this._client}constructor(e,t,r,s){const a={"x-session-id":r};this._sessionId=r,t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),this._client=new ye(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
|
|
349
351
|
GetData(input: $input) {
|
|
350
352
|
Success
|
|
351
353
|
ErrorMessages
|
|
352
354
|
Queries
|
|
353
355
|
Results
|
|
354
356
|
}
|
|
355
|
-
}`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(
|
|
357
|
+
}`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(a=>a?N(a):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){const s=`GraphQLSystemUserClient::GetData - Error getting data - ${r}`;return l(s),{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
|
|
356
358
|
GetAllEntities {
|
|
357
359
|
Success
|
|
358
360
|
ErrorMessage
|
|
@@ -375,7 +377,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
379
|
}
|
|
378
|
-
}`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return
|
|
380
|
+
}`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return l(`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!]!) {
|
|
379
381
|
SyncData(items: $items) {
|
|
380
382
|
Success
|
|
381
383
|
Results {
|
|
@@ -399,11 +401,11 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
399
401
|
RecordJSON
|
|
400
402
|
}
|
|
401
403
|
}
|
|
402
|
-
}`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return
|
|
404
|
+
}`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return l(`GraphQLSystemUserClient::SyncData - Error syncing data - ${t}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const r=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
|
|
403
405
|
SyncRolesAndUsers(data: $data) {
|
|
404
406
|
Success
|
|
405
407
|
}
|
|
406
|
-
}`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return
|
|
408
|
+
}`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return l(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}async RunViewByName(e){try{const r=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
|
|
407
409
|
RunViewByNameSystemUser(input: $input) {
|
|
408
410
|
Results {
|
|
409
411
|
PrimaryKey {
|
|
@@ -420,7 +422,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
420
422
|
ErrorMessage
|
|
421
423
|
Success
|
|
422
424
|
}
|
|
423
|
-
}`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return
|
|
425
|
+
}`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return l(`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!) {
|
|
424
426
|
RunViewByIDSystemUser(input: $input) {
|
|
425
427
|
Results {
|
|
426
428
|
PrimaryKey {
|
|
@@ -437,7 +439,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
437
439
|
ErrorMessage
|
|
438
440
|
Success
|
|
439
441
|
}
|
|
440
|
-
}`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return
|
|
442
|
+
}`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return l(`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!) {
|
|
441
443
|
RunDynamicViewSystemUser(input: $input) {
|
|
442
444
|
Results {
|
|
443
445
|
PrimaryKey {
|
|
@@ -454,7 +456,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
454
456
|
ErrorMessage
|
|
455
457
|
Success
|
|
456
458
|
}
|
|
457
|
-
}`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return
|
|
459
|
+
}`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return l(`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!]!) {
|
|
458
460
|
RunViewsSystemUser(input: $input) {
|
|
459
461
|
Results {
|
|
460
462
|
PrimaryKey {
|
|
@@ -471,7 +473,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
471
473
|
ErrorMessage
|
|
472
474
|
Success
|
|
473
475
|
}
|
|
474
|
-
}`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return
|
|
476
|
+
}`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return l(`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) {
|
|
475
477
|
GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
476
478
|
QueryID
|
|
477
479
|
QueryName
|
|
@@ -483,7 +485,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
483
485
|
ErrorMessage
|
|
484
486
|
AppliedParameters
|
|
485
487
|
}
|
|
486
|
-
}`,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
|
|
488
|
+
}`,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?N(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 l(`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) {
|
|
487
489
|
GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
|
|
488
490
|
QueryID
|
|
489
491
|
QueryName
|
|
@@ -495,7 +497,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
495
497
|
ErrorMessage
|
|
496
498
|
AppliedParameters
|
|
497
499
|
}
|
|
498
|
-
}`,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
|
|
500
|
+
}`,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?N(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 l(`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!) {
|
|
499
501
|
CreateQuerySystemUser(input: $input) {
|
|
500
502
|
Success
|
|
501
503
|
ErrorMessage
|
|
@@ -534,7 +536,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
534
536
|
RoleName
|
|
535
537
|
}
|
|
536
538
|
}
|
|
537
|
-
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser.Success&&r.CreateQuerySystemUser.QueryData?{...r.CreateQuerySystemUser,QueryData:r.CreateQuerySystemUser.QueryData}:r.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return
|
|
539
|
+
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser.Success&&r.CreateQuerySystemUser.QueryData?{...r.CreateQuerySystemUser,QueryData:r.CreateQuerySystemUser.QueryData}:r.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return l(`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!) {
|
|
538
540
|
UpdateQuerySystemUser(input: $input) {
|
|
539
541
|
Success
|
|
540
542
|
ErrorMessage
|
|
@@ -574,13 +576,13 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
574
576
|
RoleName
|
|
575
577
|
}
|
|
576
578
|
}
|
|
577
|
-
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser.Success&&r.UpdateQuerySystemUser.QueryData?{...r.UpdateQuerySystemUser,QueryData:r.UpdateQuerySystemUser.QueryData}:r.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(t){return
|
|
579
|
+
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser.Success&&r.UpdateQuerySystemUser.QueryData?{...r.UpdateQuerySystemUser,QueryData:r.UpdateQuerySystemUser.QueryData}:r.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(t){return l(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async DeleteQuery(e,t){try{if(!e||e.trim()==="")return l("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) {
|
|
578
580
|
DeleteQuerySystemResolver(ID: $ID, options: $options) {
|
|
579
581
|
Success
|
|
580
582
|
ErrorMessage
|
|
581
583
|
QueryData
|
|
582
584
|
}
|
|
583
|
-
}`,s={ID:e};t!==void 0&&(s.options=t);const
|
|
585
|
+
}`,s={ID:e};t!==void 0&&(s.options=t);const a=await this.Client.request(r,s);return a&&a.DeleteQuerySystemResolver?a.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){return l(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${r}`),{Success:!1,ErrorMessage:r.toString()}}}async RunAIPrompt(e){try{const t=m`
|
|
584
586
|
query RunAIPromptSystemUser(
|
|
585
587
|
$promptId: String!,
|
|
586
588
|
$data: String,
|
|
@@ -639,7 +641,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
639
641
|
chatResult
|
|
640
642
|
}
|
|
641
643
|
}
|
|
642
|
-
`,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
|
|
644
|
+
`,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 l(`GraphQLSystemUserClient::RunAIPrompt - Error running AI prompt - ${t}`),{success:!1,error:t.toString()}}}async RunAIAgent(e){try{const t=m`
|
|
643
645
|
query RunAIAgentSystemUser(
|
|
644
646
|
$agentId: String!,
|
|
645
647
|
$messages: String!,
|
|
@@ -666,7 +668,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
666
668
|
result
|
|
667
669
|
}
|
|
668
670
|
}
|
|
669
|
-
`,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
|
|
671
|
+
`,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 l(`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 N(e)}async ExecuteSimplePrompt(e){try{const t=m`
|
|
670
672
|
query ExecuteSimplePromptSystemUser(
|
|
671
673
|
$systemPrompt: String!,
|
|
672
674
|
$messages: String,
|
|
@@ -689,7 +691,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
689
691
|
executionTimeMs
|
|
690
692
|
}
|
|
691
693
|
}
|
|
692
|
-
`,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
|
|
694
|
+
`,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 a=s.ExecuteSimplePromptSystemUser;let n;if(a.resultObject)try{n=JSON.parse(a.resultObject)}catch{n=a.resultObject}return{success:a.success,result:a.result,resultObject:n,modelName:a.modelName,error:a.error,executionTimeMs:a.executionTimeMs}}catch(t){return l(`GraphQLSystemUserClient::ExecuteSimplePrompt - Error executing simple prompt - ${t}`),{success:!1,modelName:"Unknown",error:t.toString()}}}async EmbedText(e){try{const t=m`
|
|
693
695
|
query EmbedTextSystemUser(
|
|
694
696
|
$textToEmbed: [String!]!,
|
|
695
697
|
$modelSize: String!
|
|
@@ -704,7 +706,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
704
706
|
error
|
|
705
707
|
}
|
|
706
708
|
}
|
|
707
|
-
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},
|
|
709
|
+
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this.Client.request(t,s);if(!a?.EmbedTextSystemUser)return{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const n=a.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){return l(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}};f(ne,"GraphQLSystemUserClient");let A=ne;const oe=class oe{};f(oe,"GetDataOutput");let q=oe;const ie=class ie{};f(ie,"SimpleRemoteEntityOutput");let _=ie;const ue=class ue{};f(ue,"SimpleRemoteEntity");let O=ue;const ce=class ce{};f(ce,"SimpleRemoteEntityField");let B=ce;const le=class le{constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),a=this.createActionVariables(e,s,r),n=await this.executeActionMutation(a);return this.processActionResult(n,t)}catch(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`
|
|
708
710
|
mutation RunAction($input: RunActionInput!) {
|
|
709
711
|
RunAction(input: $input) {
|
|
710
712
|
Success
|
|
@@ -713,7 +715,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
713
715
|
ResultData
|
|
714
716
|
}
|
|
715
717
|
}
|
|
716
|
-
`;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){
|
|
718
|
+
`;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){l(`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 l(`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`
|
|
717
719
|
mutation RunEntityAction($input: EntityActionInput!) {
|
|
718
720
|
RunEntityAction(input: $input) {
|
|
719
721
|
Success
|
|
@@ -721,7 +723,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
721
723
|
ResultData
|
|
722
724
|
}
|
|
723
725
|
}
|
|
724
|
-
`;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){
|
|
726
|
+
`;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){l(`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 l(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};f(le,"GraphQLActionClient");let k=le;const de=class de{constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=m`
|
|
725
727
|
query GetRegistryComponent(
|
|
726
728
|
$registryName: String!,
|
|
727
729
|
$namespace: String!,
|
|
@@ -742,7 +744,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
742
744
|
specification
|
|
743
745
|
}
|
|
744
746
|
}
|
|
745
|
-
`,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
|
|
747
|
+
`,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 a=s.GetRegistryComponent;if(a.notModified&&!a.specification)return null;if(a.specification){if(typeof a.specification=="object")return a.specification;try{return JSON.parse(a.specification)}catch(n){return l(`Failed to parse component specification: ${n}`),null}}return null}return null}catch(t){throw l(t),new Error(`Failed to get registry component: ${t instanceof Error?t.message:"Unknown error"}`)}}async GetRegistryComponentWithHash(e){try{const t=m`
|
|
746
748
|
query GetRegistryComponent(
|
|
747
749
|
$registryName: String!,
|
|
748
750
|
$namespace: String!,
|
|
@@ -763,7 +765,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
763
765
|
specification
|
|
764
766
|
}
|
|
765
767
|
}
|
|
766
|
-
`,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
|
|
768
|
+
`,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 a=s.GetRegistryComponent;let n;if(a.specification)try{n=JSON.parse(a.specification)}catch(o){l(`Failed to parse component specification in GetRegistryComponentWithHash: ${o}`),n=void 0}return{specification:n,hash:a.hash,notModified:a.notModified,message:a.message}}return{specification:void 0,hash:"",notModified:!1,message:"Component not found"}}catch(t){throw l(t),new Error(`Failed to get registry component with hash: ${t instanceof Error?t.message:"Unknown error"}`)}}async SearchRegistryComponents(e){try{const t=m`
|
|
767
769
|
query SearchRegistryComponents($params: SearchRegistryComponentsInput!) {
|
|
768
770
|
SearchRegistryComponents(params: $params) {
|
|
769
771
|
components
|
|
@@ -772,7 +774,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
772
774
|
limit
|
|
773
775
|
}
|
|
774
776
|
}
|
|
775
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{params:e});if(r&&r.SearchRegistryComponents){const s=r.SearchRegistryComponents;return{components:s.components.map(
|
|
777
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{params:e});if(r&&r.SearchRegistryComponents){const s=r.SearchRegistryComponents;return{components:s.components.map(a=>JSON.parse(a)),total:s.total,offset:s.offset,limit:s.limit}}return{components:[],total:0,offset:0,limit:e.limit||10}}catch(t){throw l(t),new Error(`Failed to search registry components: ${t instanceof Error?t.message:"Unknown error"}`)}}async ResolveComponentDependencies(e,t){try{const r=m`
|
|
776
778
|
query ResolveComponentDependencies(
|
|
777
779
|
$registryId: String!,
|
|
778
780
|
$componentId: String!
|
|
@@ -797,7 +799,7 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
797
799
|
}
|
|
798
800
|
}
|
|
799
801
|
}
|
|
800
|
-
`,s=await this._dataProvider.ExecuteGQL(r,{registryId:e,componentId:t});return s&&s.ResolveComponentDependencies?s.ResolveComponentDependencies:null}catch(r){throw
|
|
802
|
+
`,s=await this._dataProvider.ExecuteGQL(r,{registryId:e,componentId:t});return s&&s.ResolveComponentDependencies?s.ResolveComponentDependencies:null}catch(r){throw l(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 l(s),null}}async SendComponentFeedback(e){try{const t=m`
|
|
801
803
|
mutation SendComponentFeedback($feedback: ComponentFeedbackInput!) {
|
|
802
804
|
SendComponentFeedback(feedback: $feedback) {
|
|
803
805
|
success
|
|
@@ -805,5 +807,5 @@ var Ie=Object.defineProperty;var f=(I,e)=>Ie(I,"name",{value:e,configurable:!0})
|
|
|
805
807
|
error
|
|
806
808
|
}
|
|
807
809
|
}
|
|
808
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return
|
|
810
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return l(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}};f(de,"GraphQLComponentRegistryClient");let K=de;export{b as ActionItemInput,L as ActionItemOutput,$ as FieldMapper,q as GetDataOutput,C as GraphQLAIClient,k as GraphQLActionClient,K as GraphQLComponentRegistryClient,De as GraphQLDataProvider,V as GraphQLProviderConfigData,A as GraphQLSystemUserClient,v as GraphQLTransactionGroup,F as RoleInput,U as RolesAndUsersInput,O as SimpleRemoteEntity,B as SimpleRemoteEntityField,_ as SimpleRemoteEntityOutput,Ie as SyncDataAction,M as SyncDataResult,G as SyncRolesAndUsersResult,T as UserInput,je as gql,Ue as setupGraphQLClient};
|
|
809
811
|
//# sourceMappingURL=index.mjs.map
|