@memberjunction/graphql-dataprovider 2.92.0 → 2.93.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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0});import{gql as R,GraphQLClient as ue}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as Se,TransactionResult as fe,ProviderConfigDataBase as he,ProviderBase as ge,LogError as m,UserInfo as le,ProviderType as Ie,BaseEntityResult as ce,EntityFieldTSType as p,TransactionItem as ye,UserRoleInfo as pe,SetProvider as Ee}from"@memberjunction/core";import{ViewInfo as me}from"@memberjunction/core-entities";import{openDB as Ne}from"@tempfix/idb";import{Observable as de}from"rxjs";import{createClient as De}from"graphql-ws";import{v4 as Ce}from"uuid";import{SafeJSONParse as C,MJGlobal as Ve,MJEventType as $e}from"@memberjunction/global";const K=class K{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}};S(K,"FieldMapper");let N=K;const k=class k extends Se{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=R`
1
+ var Re=Object.defineProperty;var p=(I,e)=>Re(I,"name",{value:e,configurable:!0});import{gql as m,GraphQLClient as ce}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as De,TransactionResult as Ie,LogError as d,ProviderConfigDataBase as we,ProviderBase as he,UserInfo as de,ProviderType as Ee,BaseEntityResult as ye,EntityFieldTSType as h,TransactionItem as me,UserRoleInfo as Pe,SetProvider as $e}from"@memberjunction/core";import{ViewInfo as ge}from"@memberjunction/core-entities";import{openDB as Ne}from"@tempfix/idb";import{Observable as fe}from"rxjs";import{createClient as Se}from"graphql-ws";import{v4 as ve}from"uuid";import{SafeJSONParse as $,MJGlobal as Ce,MJEventType as Ve}from"@memberjunction/global";const K=class K{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}};p(K,"FieldMapper");let P=K;const J=class J extends De{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,15 +6,139 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
6
6
  ResultsJSON
7
7
  }
8
8
  }
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,o=[];for(let i=0;i<this.PendingTransactions.length;i++){const n=a.ResultsJSON[i],y=C(n),D=this.PendingTransactions[i];o.push(new fe(D,y,y!==null))}return o}else throw new Error("Failed to execute transaction group")}};S(k,"GraphQLTransactionGroup");let V=k;const J=class J extends he{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,o,i,n){super({Token:e,URL:t,WSURL:r,MJAPIKey:n,RefreshTokenFunction:s},a,o,i)}};S(J,"GraphQLProviderConfigData");let Q=J;const h=class h extends ge{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
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 i=0;i<this.PendingTransactions.length;i++){const o=a.ResultsJSON[i],y=$(o),f=this.PendingTransactions[i];n.push(new Ie(f,y,y!==null))}return n}else throw new Error("Failed to execute transaction group")}};p(J,"GraphQLTransactionGroup");let N=J;const j=class j{constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=m`
10
+ mutation RunAIPrompt(
11
+ $promptId: String!,
12
+ $data: String,
13
+ $overrideModelId: String,
14
+ $overrideVendorId: String,
15
+ $configurationId: String,
16
+ $skipValidation: Boolean,
17
+ $templateData: String,
18
+ $responseFormat: String,
19
+ $temperature: Float,
20
+ $topP: Float,
21
+ $topK: Int,
22
+ $minP: Float,
23
+ $frequencyPenalty: Float,
24
+ $presencePenalty: Float,
25
+ $seed: Int,
26
+ $stopSequences: [String!],
27
+ $includeLogProbs: Boolean,
28
+ $topLogProbs: Int,
29
+ $messages: String,
30
+ $rerunFromPromptRunID: String,
31
+ $systemPromptOverride: String
32
+ ) {
33
+ RunAIPrompt(
34
+ promptId: $promptId,
35
+ data: $data,
36
+ overrideModelId: $overrideModelId,
37
+ overrideVendorId: $overrideVendorId,
38
+ configurationId: $configurationId,
39
+ skipValidation: $skipValidation,
40
+ templateData: $templateData,
41
+ responseFormat: $responseFormat,
42
+ temperature: $temperature,
43
+ topP: $topP,
44
+ topK: $topK,
45
+ minP: $minP,
46
+ frequencyPenalty: $frequencyPenalty,
47
+ presencePenalty: $presencePenalty,
48
+ seed: $seed,
49
+ stopSequences: $stopSequences,
50
+ includeLogProbs: $includeLogProbs,
51
+ topLogProbs: $topLogProbs,
52
+ messages: $messages,
53
+ rerunFromPromptRunID: $rerunFromPromptRunID,
54
+ systemPromptOverride: $systemPromptOverride
55
+ ) {
56
+ success
57
+ output
58
+ parsedResult
59
+ error
60
+ executionTimeMs
61
+ tokensUsed
62
+ promptRunId
63
+ rawResult
64
+ validationResult
65
+ chatResult
66
+ }
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,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 d(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e){try{const t=m`
69
+ mutation RunAIAgent(
70
+ $agentId: String!,
71
+ $messages: String!,
72
+ $sessionId: String!,
73
+ $data: String,
74
+ $templateData: String,
75
+ $lastRunId: String,
76
+ $autoPopulateLastRunPayload: Boolean,
77
+ $configurationId: String
78
+ ) {
79
+ RunAIAgent(
80
+ agentId: $agentId,
81
+ messages: $messages,
82
+ sessionId: $sessionId,
83
+ data: $data,
84
+ templateData: $templateData,
85
+ lastRunId: $lastRunId,
86
+ autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
87
+ configurationId: $configurationId
88
+ ) {
89
+ success
90
+ errorMessage
91
+ executionTimeMs
92
+ payload
93
+ }
94
+ }
95
+ `,r=this.prepareAgentVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processAgentResult(s)}catch(t){return this.handleAgentError(t)}}prepareAgentVariables(e){const t={agentId:e.agentId,messages:JSON.stringify(e.messages),sessionId:e.sessionId};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.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),t}processAgentResult(e){if(!e?.RunAIAgent)throw new Error("Invalid response from server");const t=e.RunAIAgent;let r;try{t.payload&&(r=JSON.parse(t.payload))}catch{r=t.payload}return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,payload:r}}handleAgentError(e){const t=e;return d(`Error running AI agent: ${t}`),{success:!1,errorMessage:t.message||"Unknown error occurred"}}async ExecuteSimplePrompt(e){try{const t=m`
96
+ mutation ExecuteSimplePrompt(
97
+ $systemPrompt: String!,
98
+ $messages: String,
99
+ $preferredModels: [String!],
100
+ $modelPower: String,
101
+ $responseFormat: String
102
+ ) {
103
+ ExecuteSimplePrompt(
104
+ systemPrompt: $systemPrompt,
105
+ messages: $messages,
106
+ preferredModels: $preferredModels,
107
+ modelPower: $modelPower,
108
+ responseFormat: $responseFormat
109
+ ) {
110
+ success
111
+ result
112
+ resultObject
113
+ modelName
114
+ error
115
+ executionTimeMs
116
+ }
117
+ }
118
+ `,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 d(`Error executing simple prompt: ${r}`),{success:!1,modelName:"Unknown",error:r.message||"Unknown error occurred"}}}async EmbedText(e){try{const t=m`
119
+ mutation EmbedText(
120
+ $textToEmbed: [String!]!,
121
+ $modelSize: String!
122
+ ) {
123
+ EmbedText(
124
+ textToEmbed: $textToEmbed,
125
+ modelSize: $modelSize
126
+ ) {
127
+ embeddings
128
+ modelName
129
+ vectorDimensions
130
+ error
131
+ }
132
+ }
133
+ `,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 d(`Error generating embeddings: ${r}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}};p(j,"GraphQLAIClient");let v=j;const z=class z extends we{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,i,o){super({Token:e,URL:t,WSURL:r,MJAPIKey:o,RefreshTokenFunction:s},a,n,i)}};p(z,"GraphQLProviderConfigData");let V=z;const D=class D extends he{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
10
134
  ${this.userInfoString()}
11
135
  UserRoles_UserIDArray {
12
136
  ${this.userRoleInfoString()}
13
137
  }
14
138
  }
15
- `,this._currentUserQuery=R`query CurrentUserAndRoles {
139
+ `,this._currentUserQuery=m`query CurrentUserAndRoles {
16
140
  ${this._innerCurrentUserQueryString}
17
- }`,this._wsClient=null,this._pushStatusRequests=[],h._instance||(h._instance=this)}static get Instance(){return h._instance}get ConfigData(){return this._configData}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return Ce()}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 m(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 le(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=R`
141
+ }`,this._wsClient=null,this._pushStatusRequests=[],D._instance||(D._instance=this)}static get Instance(){return D._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new v(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return ve()}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)):(D.Instance._configData=e,D.Instance._sessionId===void 0&&(D.Instance._sessionId=await this.GetPreferredUUID(s)),D.Instance._client||(D.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,D.Instance._sessionId,e.MJAPIKey)),await D.Instance.SaveStoredSessionID(D.Instance._sessionId)),super.Config(e)}catch(a){throw d(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 de(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=m`
18
142
  query GetReportDataQuery ($ReportID: String!) {
19
143
  GetReportData(ReportID: $ReportID) {
20
144
  Success
@@ -23,19 +147,19 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
23
147
  ExecutionTime
24
148
  ErrorMessage
25
149
  }
26
- }`,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,o,i){const n=R`
150
+ }`,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,i){const o=m`
27
151
  query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
28
152
  GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
29
153
  ${this.QueryReturnFieldList}
30
154
  }
31
155
  }
32
- `,y={QueryID:e};t!==void 0&&(y.CategoryID=t),r!==void 0&&(y.CategoryPath=r),a!==void 0&&(y.Parameters=a),o!==void 0&&(y.MaxRows=o),i!==void 0&&(y.StartRow=i);const D=await this.ExecuteGQL(n,y);if(D&&D.GetQueryData)return this.TransformQueryPayload(D.GetQueryData)}async RunQueryByName(e,t,r,s,a,o,i){const n=R`
156
+ `,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),i!==void 0&&(y.StartRow=i);const f=await this.ExecuteGQL(o,y);if(f&&f.GetQueryData)return this.TransformQueryPayload(f.GetQueryData)}async RunQueryByName(e,t,r,s,a,n,i){const o=m`
33
157
  query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
34
158
  GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
35
159
  ${this.QueryReturnFieldList}
36
160
  }
37
161
  }
38
- `,y={QueryName:e};t!==void 0&&(y.CategoryID=t),r!==void 0&&(y.CategoryPath=r),a!==void 0&&(y.Parameters=a),o!==void 0&&(y.MaxRows=o),i!==void 0&&(y.StartRow=i);const D=await this.ExecuteGQL(n,y);if(D&&D.GetQueryDataByName)return this.TransformQueryPayload(D.GetQueryDataByName)}get QueryReturnFieldList(){return`
162
+ `,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),i!==void 0&&(y.StartRow=i);const f=await this.ExecuteGQL(o,y);if(f&&f.GetQueryDataByName)return this.TransformQueryPayload(f.GetQueryDataByName)}get QueryReturnFieldList(){return`
39
163
  Success
40
164
  QueryID
41
165
  QueryName
@@ -44,11 +168,11 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
44
168
  TotalRowCount
45
169
  ExecutionTime
46
170
  ErrorMessage
47
- 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 m(`Error transforming query payload: ${t}`),null}}async RunView(e,t){await this.PreProcessRunView(e,t);try{let r="",s="";if(e){const a={};let o,i;if(e.ViewEntity)i=e.ViewEntity,o=i.Entity;else{const{entityName:u,v:l}=await this.getEntityNameAndUserView(e,t);i=l,o=u}const n=this.Entities.find(u=>u.Name===o);if(!n)throw new Error(`Entity ${o} not found in metadata`);let y=!1;e.ViewID?(r=`Run${n.ClassName}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(r=`Run${n.ClassName}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(y=!0,r=`Run${n.ClassName}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 D=this.getViewRunTimeFieldList(n,i,e,y),d=R`
171
+ 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 d(`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,i;if(e.ViewEntity)i=e.ViewEntity,n=i.Entity;else{const{entityName:u,v:l}=await this.getEntityNameAndUserView(e,t);i=l,n=u}const o=this.Entities.find(u=>u.Name===n);if(!o)throw new Error(`Entity ${n} not found in metadata`);let y=!1;e.ViewID?(r=`Run${o.ClassName}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(r=`Run${o.ClassName}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(y=!0,r=`Run${o.ClassName}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 f=this.getViewRunTimeFieldList(o,i,e,y),g=m`
48
172
  query RunViewQuery ($input: ${s}!) {
49
173
  ${r}(input: $input) {
50
174
  Results {
51
- ${D.join(`
175
+ ${f.join(`
52
176
  `)}
53
177
  }
54
178
  UserViewRunID
@@ -58,7 +182,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
58
182
  Success
59
183
  ErrorMessage
60
184
  }
61
- }`,c=await this.ExecuteGQL(d,{input:a});if(c&&c[r]){const u=c[r].Results;if(u&&u.length>0){const f=n.Fields.filter(w=>w.CodeName!==w.Name&&w.CodeName!==void 0);u.forEach(w=>{this.ConvertBackToMJFields(w),f.forEach(I=>{w[I.Name]=w[I.CodeName]})})}const l=c[r];return await this.PostProcessRunView(l,e,t),l}}else throw"No parameters passed to RunView";return null}catch(r){throw m(r),r}}async RunViews(e,t){await this.PreProcessRunViews(e,t);try{let r=[],s=[],a=[];for(const n of e){let y="",D="";const d={};let c=null,u=null;if(n.ViewEntity)u=n.ViewEntity,c=u.Get("Entity");else{const{entityName:w,v:I}=await this.getEntityNameAndUserView(n,t);u=I,c=w}const l=this.Entities.find(w=>w.Name===c);if(!l)throw new Error(`Entity ${c} not found in metadata`);s.push(l);let f=!1;n.ViewID?(y=`Run${l.ClassName}ViewByID`,D="RunViewByIDInput",d.ViewID=n.ViewID):n.ViewName?(y=`Run${l.ClassName}ViewByName`,D="RunViewByNameInput",d.ViewName=n.ViewName):(f=!0,y=`Run${l.ClassName}DynamicView`,D="RunDynamicViewInput",d.EntityName=n.EntityName),d.ExtraFilter=n.ExtraFilter||"",d.OrderBy=n.OrderBy||"",d.UserSearchString=n.UserSearchString||"",d.Fields=n.Fields,d.IgnoreMaxRows=n.IgnoreMaxRows||!1,n.MaxRows!==void 0&&(d.MaxRows=n.MaxRows),n.StartRow!==void 0&&(d.StartRow=n.StartRow),d.ForceAuditLog=n.ForceAuditLog||!1,d.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(d.AuditLogDescription=n.AuditLogDescription),f||(d.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",d.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,d.OverrideExcludeFilter=n.OverrideExcludeFilter||"",d.SaveViewResults=n.SaveViewResults||!1),r.push(d),a.push(...this.getViewRunTimeFieldList(l,u,n,f))}const o=R`
185
+ }`,c=await this.ExecuteGQL(g,{input:a});if(c&&c[r]){const u=c[r].Results;if(u&&u.length>0){const R=o.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 l=c[r];return await this.PostProcessRunView(l,e,t),l}}else throw"No parameters passed to RunView";return null}catch(r){throw d(r),r}}async RunViews(e,t){await this.PreProcessRunViews(e,t);try{let r=[],s=[],a=[];for(const o of e){let y="",f="";const g={};let c=null,u=null;if(o.ViewEntity)u=o.ViewEntity,c=u.Get("Entity");else{const{entityName:S,v:w}=await this.getEntityNameAndUserView(o,t);u=w,c=S}const l=this.Entities.find(S=>S.Name===c);if(!l)throw new Error(`Entity ${c} not found in metadata`);s.push(l);let R=!1;o.ViewID?(y=`Run${l.ClassName}ViewByID`,f="RunViewByIDInput",g.ViewID=o.ViewID):o.ViewName?(y=`Run${l.ClassName}ViewByName`,f="RunViewByNameInput",g.ViewName=o.ViewName):(R=!0,y=`Run${l.ClassName}DynamicView`,f="RunDynamicViewInput",g.EntityName=o.EntityName),g.ExtraFilter=o.ExtraFilter||"",g.OrderBy=o.OrderBy||"",g.UserSearchString=o.UserSearchString||"",g.Fields=o.Fields,g.IgnoreMaxRows=o.IgnoreMaxRows||!1,o.MaxRows!==void 0&&(g.MaxRows=o.MaxRows),o.StartRow!==void 0&&(g.StartRow=o.StartRow),g.ForceAuditLog=o.ForceAuditLog||!1,g.ResultType=o.ResultType||"simple",o.AuditLogDescription&&o.AuditLogDescription.length>0&&(g.AuditLogDescription=o.AuditLogDescription),R||(g.ExcludeUserViewRunID=o.ExcludeUserViewRunID||"",g.ExcludeDataFromAllPriorViewRuns=o.ExcludeDataFromAllPriorViewRuns||!1,g.OverrideExcludeFilter=o.OverrideExcludeFilter||"",g.SaveViewResults=o.SaveViewResults||!1),r.push(g),a.push(...this.getViewRunTimeFieldList(l,u,o,R))}const n=m`
62
186
  query RunViewsQuery ($input: [RunViewGenericInput!]!) {
63
187
  RunViews(input: $input) {
64
188
  Results {
@@ -73,7 +197,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
73
197
  Success
74
198
  ErrorMessage
75
199
  }
76
- }`,i=await this.ExecuteGQL(o,{input:r});if(i&&i.RunViews){const n=i.RunViews;for(const[y,D]of n.entries())D.Results=D.Results.map(d=>{let c=JSON.parse(d.Data);return this.ConvertBackToMJFields(c),c});return await this.PostProcessRunViews(n,e,t),n}return null}catch(r){throw m(r),r}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await me.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await me.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=[],o=new N;if(r.Fields){for(const i of e.PrimaryKeys)r.Fields.find(n=>n.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&a.push(i.Name);r.Fields.forEach(i=>{a.push(o.MapFieldName(i))})}else if(s)e.Fields.forEach(i=>{i.IsBinaryFieldType||a.push(o.MapFieldName(i.CodeName))});else{for(const i of e.PrimaryKeys)a.find(n=>n.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&a.push(i.Name);t.Columns.forEach(i=>{i.hidden===!1&&!a.find(n=>n.trim().toLowerCase()===i.EntityField?.Name.trim().toLowerCase())&&i.EntityField&&a.push(o.MapFieldName(i.EntityField.CodeName))})}return a}get ProviderType(){return Ie.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,o)=>a.ChangedAt>o.ChangedAt?-1:1):null}catch(r){throw m(r),r}}async GetRecordDependencies(e,t){try{const r=R`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
200
+ }`,i=await this.ExecuteGQL(n,{input:r});if(i&&i.RunViews){const o=i.RunViews;for(const[y,f]of o.entries())f.Results=f.Results.map(g=>{let c=JSON.parse(g.Data);return this.ConvertBackToMJFields(c),c});return await this.PostProcessRunViews(o,e,t),o}return null}catch(r){throw d(r),r}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await ge.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await ge.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 P;if(r.Fields){for(const i of e.PrimaryKeys)r.Fields.find(o=>o.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&a.push(i.Name);r.Fields.forEach(i=>{a.push(n.MapFieldName(i))})}else if(s)e.Fields.forEach(i=>{i.IsBinaryFieldType||a.push(n.MapFieldName(i.CodeName))});else{for(const i of e.PrimaryKeys)a.find(o=>o.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&a.push(i.Name);t.Columns.forEach(i=>{i.hidden===!1&&!a.find(o=>o.trim().toLowerCase()===i.EntityField?.Name.trim().toLowerCase())&&i.EntityField&&a.push(n.MapFieldName(i.EntityField.CodeName))})}return a}get ProviderType(){return Ee.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 d(r),r}}async GetRecordDependencies(e,t){try{const r=m`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
77
201
  GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
78
202
  EntityName
79
203
  RelatedEntityName
@@ -85,7 +209,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
85
209
  }
86
210
  }
87
211
  }
88
- }`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw m(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=R`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
212
+ }`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw d(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!) {
89
213
  GetRecordDuplicates(params: $params) {
90
214
  Status
91
215
  ErrorMessage
@@ -107,7 +231,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
107
231
  }
108
232
  }
109
233
  }
110
- }`;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 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=R`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
234
+ }`;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!) {
111
235
  MergeRecords(request: $request) {
112
236
  Success
113
237
  OverallStatus
@@ -124,32 +248,32 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
124
248
  Message
125
249
  }
126
250
  }
127
- }`,o={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(n=>({FieldName:n.FieldName,Value:n.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(n=>n.Copy())};return(await this.ExecuteGQL(a,{request:o}))?.MergeRecords}catch(a){return m(a),{Success:!1,OverallStatus:a&&a.message?a.message:a,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){const s=new ce;try{e.RegisterTransactionPreprocessing();const a={input:{}},o=e.IsSaved?"Update":"Create";s.StartedAt=new Date,s.Type=e.IsSaved?"update":"create",s.OriginalValues=e.Fields.map(c=>({FieldName:c.CodeName,Value:c.Value})),e.ResultHistory.push(s);const i=`${o}${e.EntityInfo.ClassName}`,n=e.Fields.filter(c=>!c.ReadOnly||c.IsPrimaryKey&&e.IsSaved),y=new N,D=` ${i}(input: $input) {
251
+ }`,n={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(o=>({FieldName:o.FieldName,Value:o.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(o=>o.Copy())};return(await this.ExecuteGQL(a,{request:n}))?.MergeRecords}catch(a){return d(a),{Success:!1,OverallStatus:a&&a.message?a.message:a,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){const s=new ye;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(c=>({FieldName:c.CodeName,Value:c.Value})),e.ResultHistory.push(s);const i=`${n}${e.EntityInfo.ClassName}`,o=e.Fields.filter(c=>!c.ReadOnly||c.IsPrimaryKey&&e.IsSaved),y=new P,f=` ${i}(input: $input) {
128
252
  ${e.Fields.map(c=>y.MapFieldName(c.CodeName)).join(`
129
253
  `)}
130
- }`,d=R`mutation ${o}${e.EntityInfo.ClassName} ($input: ${i}Input!) {
131
- ${D}
254
+ }`,g=m`mutation ${n}${e.EntityInfo.ClassName} ($input: ${i}Input!) {
255
+ ${f}
132
256
  }
133
- `;for(let c=0;c<n.length;c++){const u=n[c];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case p.Date:l=l.getTime();break;case p.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case p.Number:if(typeof l!="number"){const f=Number(l);isNaN(f)||(l=f)}break}l===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?l=u.EntityFieldInfo.DefaultValue:u.FieldType===p.Number||u.FieldType===p.Boolean?l=0:l=""),a.input[u.CodeName]=l}if(o.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const c=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===p.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===p.Boolean?l=u.OldValue===!0?"1":"0":typeof u.OldValue!="string"?l=u.OldValue.toString():l=u.OldValue),c.push({Key:u.CodeName,Value:l})}),a.input.OldValues___=c}if(e.TransactionGroup){const c=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ye(e,s.Type==="create"?"Create":"Update",D,a,{mutationName:i,mutationInputTypes:c},(u,l)=>{s.EndedAt=new Date,l&&u?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(u)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const c=await this.ExecuteGQL(d,a);if(c&&c[o+e.EntityInfo.ClassName])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(c[o+e.EntityInfo.ClassName]),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,m(a),null}}async Load(e,t,r=null,s){try{const a={};let o="",i="";for(let c=0;c<t.KeyValuePairs.length;c++){const u=e.Fields.find(w=>w.Name.trim().toLowerCase()===t.KeyValuePairs[c].FieldName.trim().toLowerCase()).EntityFieldInfo,l=t.GetValueByIndex(c),f=u.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${u.CodeName}: ${f}!`,o.length>0&&(o+=", "),o+=`${u.CodeName}: $${u.CodeName}`,u.TSType===p.Number){if(isNaN(t.GetValueByIndex(c)))throw new Error(`Primary Key value ${l} (${u.Name}) is not a valid number`);a[u.CodeName]=parseInt(l)}else a[u.CodeName]=l}const n=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",y=new N,D=R`query Single${e.EntityInfo.ClassName}${n.length>0?"Full":""} (${i}) {
134
- ${e.EntityInfo.ClassName}(${o}) {
257
+ `;for(let c=0;c<o.length;c++){const u=o[c];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case h.Date:l=l.getTime();break;case h.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case h.Number:if(typeof l!="number"){const R=Number(l);isNaN(R)||(l=R)}break}l===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?l=u.EntityFieldInfo.DefaultValue:u.FieldType===h.Number||u.FieldType===h.Boolean?l=0:l=""),a.input[u.CodeName]=l}if(n.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const c=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===h.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===h.Boolean?l=u.OldValue===!0?"1":"0":typeof u.OldValue!="string"?l=u.OldValue.toString():l=u.OldValue),c.push({Key:u.CodeName,Value:l})}),a.input.OldValues___=c}if(e.TransactionGroup){const c=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new me(e,s.Type==="create"?"Create":"Update",f,a,{mutationName:i,mutationInputTypes:c},(u,l)=>{s.EndedAt=new Date,l&&u?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(u)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const c=await this.ExecuteGQL(g,a);if(c&&c[n+e.EntityInfo.ClassName])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(c[n+e.EntityInfo.ClassName]),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,d(a),null}}async Load(e,t,r=null,s){try{const a={};let n="",i="";for(let c=0;c<t.KeyValuePairs.length;c++){const u=e.Fields.find(S=>S.Name.trim().toLowerCase()===t.KeyValuePairs[c].FieldName.trim().toLowerCase()).EntityFieldInfo,l=t.GetValueByIndex(c),R=u.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${u.CodeName}: ${R}!`,n.length>0&&(n+=", "),n+=`${u.CodeName}: $${u.CodeName}`,u.TSType===h.Number){if(isNaN(t.GetValueByIndex(c)))throw new Error(`Primary Key value ${l} (${u.Name}) is not a valid number`);a[u.CodeName]=parseInt(l)}else a[u.CodeName]=l}const o=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",y=new P,f=m`query Single${e.EntityInfo.ClassName}${o.length>0?"Full":""} (${i}) {
258
+ ${e.EntityInfo.ClassName}(${n}) {
135
259
  ${e.Fields.filter(c=>!c.EntityFieldInfo.IsBinaryFieldType).map(c=>c.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?c.CodeName.replace("__mj_","_mj__"):c.CodeName).join(`
136
260
  `)}
137
- ${n}
261
+ ${o}
138
262
  }
139
263
  }
140
- `,d=await this.ExecuteGQL(D,a);return d&&d[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(d[e.EntityInfo.ClassName]):null}catch(a){return m(a),null}}ConvertBackToMJFields(e){return new N().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],o=this.Entities.find(n=>n.ID===a.RelatedEntityID);let i="";a.Type.toLowerCase().trim()==="many to many"?i=`${a.RelatedEntityCodeName}_${a.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${a.RelatedEntityCodeName}_${a.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
264
+ `,g=await this.ExecuteGQL(f,a);return g&&g[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(g[e.EntityInfo.ClassName]):null}catch(a){return d(a),null}}ConvertBackToMJFields(e){return new P().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(o=>o.ID===a.RelatedEntityID);let i="";a.Type.toLowerCase().trim()==="many to many"?i=`${a.RelatedEntityCodeName}_${a.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${a.RelatedEntityCodeName}_${a.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
141
265
  ${i} {
142
- ${o.Fields.map(n=>n.CodeName).join(`
266
+ ${n.Fields.map(o=>o.CodeName).join(`
143
267
  `)}
144
268
  }
145
- `}return r}async Delete(e,t,r){const s=new ce;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={},o=[];let i="",n="",y="";for(let u of e.PrimaryKey.KeyValuePairs){const l=e.Fields.find(f=>f.Name.trim().toLowerCase()===u.FieldName.trim().toLowerCase());a[l.CodeName]=l.Value,o.push({varName:l.CodeName,inputType:l.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${l.CodeName}: $${l.CodeName}`,n.length>0&&(n+=", "),n+=`$${l.CodeName}: ${l.EntityFieldInfo.GraphQLType}!`,y.length>0&&(y+=`
146
- `),y+=`${l.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const D="Delete"+e.EntityInfo.ClassName,d=R`${D}(${i}, options___: $options___) {
269
+ `}return r}async Delete(e,t,r){const s=new ye;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 i="",o="",y="";for(let u of e.PrimaryKey.KeyValuePairs){const l=e.Fields.find(R=>R.Name.trim().toLowerCase()===u.FieldName.trim().toLowerCase());a[l.CodeName]=l.Value,n.push({varName:l.CodeName,inputType:l.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${l.CodeName}: $${l.CodeName}`,o.length>0&&(o+=", "),o+=`$${l.CodeName}: ${l.EntityFieldInfo.GraphQLType}!`,y.length>0&&(y+=`
270
+ `),y+=`${l.CodeName}`}n.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const f="Delete"+e.EntityInfo.ClassName,g=m`${f}(${i}, options___: $options___) {
147
271
  ${y}
148
272
  }
149
- `,c=R`mutation ${D} (${n}, $options___: DeleteOptionsInput!) {
150
- ${d}
273
+ `,c=m`mutation ${f} (${o}, $options___: DeleteOptionsInput!) {
274
+ ${g}
151
275
  }
152
- `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ye(e,"Delete",d,a,{mutationName:D,mutationInputTypes:o},(u,l)=>{if(s.EndedAt=new Date,l&&u){let f=!0;for(const w of e.PrimaryKey.KeyValuePairs)w.Value!==u[w.FieldName]&&(f=!1);f?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(c,a);if(u&&u[D]){const l=u[D];for(let f of e.PrimaryKey.KeyValuePairs){let w=l[f.FieldName],I=f.Value;if(typeof I=="number"&&(I=I.toString()),typeof w=="number"&&(w=w.toString()),I!==w)throw new Error(`Primary key value mismatch in server Delete response. Field: ${f.FieldName}, Original: ${I}, Returned: ${w}`)}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,m(a),!1}}async GetDatasetByName(e,t){const r=R`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
276
+ `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new me(e,"Delete",g,a,{mutationName:f,mutationInputTypes:n},(u,l)=>{if(s.EndedAt=new Date,l&&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(c,a);if(u&&u[f]){const l=u[f];for(let R of e.PrimaryKey.KeyValuePairs){let S=l[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,d(a),!1}}async GetDatasetByName(e,t){const r=m`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
153
277
  GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
154
278
  DatasetID
155
279
  DatasetName
@@ -158,7 +282,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
158
282
  LatestUpdateDate
159
283
  Results
160
284
  }
161
- }`,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=R`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
285
+ }`,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!]) {
162
286
  GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
163
287
  DatasetID
164
288
  DatasetName
@@ -167,22 +291,22 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
167
291
  LatestUpdateDate
168
292
  EntityUpdateDates
169
293
  }
170
- }`,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(n=>n.Name===t);if(!a)throw new Error(`Entity ${t} not found in metadata`);const o=R`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
294
+ }`,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 N(this)}async GetRecordFavoriteStatus(e,t,r){if(!r.Validate().IsValid)return!1;const a=this.Entities.find(o=>o.Name===t);if(!a)throw new Error(`Entity ${t} not found in metadata`);const n=m`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
171
295
  GetRecordFavoriteStatus(params: $params) {
172
296
  Success
173
297
  IsFavorite
174
298
  }
175
- }`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:a.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}}});if(i&&i.GetRecordFavoriteStatus&&i.GetRecordFavoriteStatus.Success)return i.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,t,r,s,a){const o=this.Entities.find(y=>y.Name===t);if(!o)throw new Error(`Entity ${t} not found in metadata`);const i=R`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
299
+ }`,i=await this.ExecuteGQL(n,{params:{UserID:e,EntityID:a.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}}});if(i&&i.GetRecordFavoriteStatus&&i.GetRecordFavoriteStatus.Success)return i.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 i=m`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
176
300
  SetRecordFavoriteStatus(params: $params){
177
301
  Success
178
302
  }
179
- }`,n=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)},IsFavorite:s}});if(n&&n.SetRecordFavoriteStatus!==null)return n.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,t){if(!e||!t||t.KeyValuePairs?.length===0)return null;const r=R`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
303
+ }`,o=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:n.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)},IsFavorite:s}});if(o&&o.SetRecordFavoriteStatus!==null)return o.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,t){if(!e||!t||t.KeyValuePairs?.length===0)return null;const r=m`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
180
304
  GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
181
305
  Success
182
306
  Status
183
307
  RecordName
184
308
  }
185
- }`,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=R`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
309
+ }`,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!]!) {
186
310
  GetEntityRecordNames(info: $info) {
187
311
  Success
188
312
  Status
@@ -195,35 +319,35 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
195
319
  EntityName
196
320
  RecordName
197
321
  }
198
- }`,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=R`query GetDataContextData ($DataContextID: String!) {
322
+ }`,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!) {
199
323
  GetDataContextData(DataContextID: $DataContextID) {
200
324
  Success
201
325
  ErrorMessages
202
326
  Results
203
327
  }
204
- }`,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 m(t),t}}async GetDataContextItemData(e){try{const t=R`query GetDataContextItemData ($DataContextItemID: String!) {
328
+ }`,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 d(t),t}}async GetDataContextItemData(e){try{const t=m`query GetDataContextItemData ($DataContextItemID: String!) {
205
329
  GetDataContextItemData(DataContextItemID: $DataContextItemID) {
206
330
  Success
207
331
  ErrorMessage
208
332
  Result
209
333
  }
210
- }`,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 m(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 m("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw m(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 ue(e,{headers:a})}userInfoString(){return this.infoString(new le(null,null))}userRoleInfoString(){return this.infoString(new pe(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
334
+ }`,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 d(t),t}}static async ExecuteGQL(e,t,r=!0){return D.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 d("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw d(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 D.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 ce(e,{headers:a})}userInfoString(){return this.infoString(new de(null,null))}userRoleInfoString(){return this.infoString(new Pe(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
211
335
  `:s.startsWith("_")||(t+=s+`
212
- `);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new G),this._localStorageProvider}get Metadata(){return this}subscribe(e,t){return this._wsClient||(this._wsClient=De({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new de(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=De({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=R`subscription StatusUpdates($sessionId: String!) {
336
+ `);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new U),this._localStorageProvider}get Metadata(){return this}subscribe(e,t){return this._wsClient||(this._wsClient=Se({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new fe(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=Se({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!) {
213
337
  statusUpdates(sessionId: $sessionId) {
214
338
  date
215
339
  message
216
340
  sessionId
217
341
  }
218
342
  }
219
- `,s=new de(a=>(this._wsClient.subscribe({query:r,variables:{sessionId:e}},{next:o=>a.next(o.data.statusUpdates),error:o=>a.error(o),complete:()=>a.complete()}),()=>{console.log("would unsub here")}));return this._pushStatusRequests.push({sessionId:e,observable:s}),s}};S(h,"GraphQLDataProvider");let $=h;const j=class j{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()})}};S(j,"BrowserStorageProviderBase");let P=j;const Qe="MJ_Metadata",E="Metadata_KVPairs",W=class W extends P{constructor(){super(),this.dbPromise=Ne(Qe,1,{upgrade(e){e.objectStoreNames.contains(E)||e.createObjectStore(E)}})}async setItem(e,t){const s=(await this.dbPromise).transaction(E,"readwrite");await s.objectStore(E).put(t,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(E).objectStore(E).get(e)}async remove(e){const r=(await this.dbPromise).transaction(E,"readwrite");await r.objectStore(E).delete(e),await r.done}};S(W,"BrowserIndexedDBStorageProvider");let G=W;async function Pe(g){const e=new $;return Ee(e),await e.Config(g),Ve.Instance.RaiseEvent({event:$e.LoggedIn,eventCode:null,component:this,args:null}),e}S(Pe,"setupGraphQLClient");const z=class z{};S(z,"SyncRolesAndUsersResult");let U=z;const H=class H{};S(H,"RoleInput");let v=H;const X=class X{};S(X,"UserInput");let T=X;const Z=class Z{};S(Z,"RolesAndUsersInput");let x=Z;var Re=(g=>(g.Create="Create",g.Update="Update",g.CreateOrUpdate="CreateOrUpdate",g.Delete="Delete",g.DeleteWithFilter="DeleteWithFilter",g))(Re||{});const Y=class Y{};S(Y,"ActionItemInput");let F=Y;const ee=class ee{constructor(){this.Results=[]}};S(ee,"SyncDataResult");let M=ee;const te=class te{};S(te,"ActionItemOutput");let L=te;const re=class re{get Client(){return this._client}constructor(e,t,r,s){const a={"x-session-id":r};t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),this._client=new ue(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
343
+ `,s=new fe(a=>(this._wsClient.subscribe({query:r,variables:{sessionId:e}},{next:n=>a.next(n.data.statusUpdates),error:n=>a.error(n),complete:()=>a.complete()}),()=>{console.log("would unsub here")}));return this._pushStatusRequests.push({sessionId:e,observable:s}),s}};p(D,"GraphQLDataProvider");let C=D;const W=class W{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()})}};p(W,"BrowserStorageProviderBase");let x=W;const xe="MJ_Metadata",E="Metadata_KVPairs",H=class H extends x{constructor(){super(),this.dbPromise=Ne(xe,1,{upgrade(e){e.objectStoreNames.contains(E)||e.createObjectStore(E)}})}async setItem(e,t){const s=(await this.dbPromise).transaction(E,"readwrite");await s.objectStore(E).put(t,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(E).objectStore(E).get(e)}async remove(e){const r=(await this.dbPromise).transaction(E,"readwrite");await r.objectStore(E).delete(e),await r.done}};p(H,"BrowserIndexedDBStorageProvider");let U=H;async function Ue(I){const e=new C;return $e(e),await e.Config(I),Ce.Instance.RaiseEvent({event:Ve.LoggedIn,eventCode:null,component:this,args:null}),e}p(Ue,"setupGraphQLClient");const X=class X{};p(X,"SyncRolesAndUsersResult");let T=X;const Z=class Z{};p(Z,"RoleInput");let F=Z;const Y=class Y{};p(Y,"UserInput");let M=Y;const ee=class ee{};p(ee,"RolesAndUsersInput");let Q=ee;var pe=(I=>(I.Create="Create",I.Update="Update",I.CreateOrUpdate="CreateOrUpdate",I.Delete="Delete",I.DeleteWithFilter="DeleteWithFilter",I))(pe||{});const te=class te{};p(te,"ActionItemInput");let G=te;const re=class re{constructor(){this.Results=[]}};p(re,"SyncDataResult");let b=re;const se=class se{};p(se,"ActionItemOutput");let A=se;const ae=class ae{get Client(){return this._client}constructor(e,t,r,s){const a={"x-session-id":r};t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),this._client=new ce(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
220
344
  GetData(input: $input) {
221
345
  Success
222
346
  ErrorMessages
223
347
  Queries
224
348
  Results
225
349
  }
226
- }`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(a=>a?C(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 geta - ${r}`;return m(s),{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
350
+ }`,{input:{Queries:e,Token:t}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(a=>a?$(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 geta - ${r}`;return d(s),{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
227
351
  GetAllEntities {
228
352
  Success
229
353
  ErrorMessage
@@ -246,7 +370,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
246
370
  }
247
371
  }
248
372
  }
249
- }`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return m(`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!]!) {
373
+ }`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return d(`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!]!) {
250
374
  SyncData(items: $items) {
251
375
  Success
252
376
  Results {
@@ -270,11 +394,11 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
270
394
  RecordJSON
271
395
  }
272
396
  }
273
- }`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return m(`GraphQLSystemUserClient::SyncData - Error syncing data - ${t}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const r=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
397
+ }`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return d(`GraphQLSystemUserClient::SyncData - Error syncing data - ${t}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const r=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
274
398
  SyncRolesAndUsers(data: $data) {
275
399
  Success
276
400
  }
277
- }`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return m(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}async RunViewByName(e){try{const r=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
401
+ }`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return d(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}async RunViewByName(e){try{const r=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
278
402
  RunViewByNameSystemUser(input: $input) {
279
403
  Results {
280
404
  ID
@@ -288,7 +412,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
288
412
  ErrorMessage
289
413
  Success
290
414
  }
291
- }`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return m(`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!) {
415
+ }`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return d(`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!) {
292
416
  RunViewByIDSystemUser(input: $input) {
293
417
  Results {
294
418
  ID
@@ -302,7 +426,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
302
426
  ErrorMessage
303
427
  Success
304
428
  }
305
- }`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return m(`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!) {
429
+ }`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return d(`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!) {
306
430
  RunDynamicViewSystemUser(input: $input) {
307
431
  Results {
308
432
  ID
@@ -316,7 +440,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
316
440
  ErrorMessage
317
441
  Success
318
442
  }
319
- }`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return m(`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!]!) {
443
+ }`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return d(`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!]!) {
320
444
  RunViewsSystemUser(input: $input) {
321
445
  Results {
322
446
  ID
@@ -330,7 +454,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
330
454
  ErrorMessage
331
455
  Success
332
456
  }
333
- }`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return m(`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) {
457
+ }`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return d(`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) {
334
458
  GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
335
459
  QueryID
336
460
  QueryName
@@ -342,7 +466,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
342
466
  ErrorMessage
343
467
  AppliedParameters
344
468
  }
345
- }`,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?C(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 m(`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) {
469
+ }`,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 d(`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) {
346
470
  GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
347
471
  QueryID
348
472
  QueryName
@@ -354,7 +478,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
354
478
  ErrorMessage
355
479
  AppliedParameters
356
480
  }
357
- }`,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?C(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 m(`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!) {
481
+ }`,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 d(`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!) {
358
482
  CreateQuerySystemUser(input: $input) {
359
483
  Success
360
484
  ErrorMessage
@@ -393,7 +517,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
393
517
  RoleName
394
518
  }
395
519
  }
396
- }`,{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 m(`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!) {
520
+ }`,{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 d(`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!) {
397
521
  UpdateQuerySystemUser(input: $input) {
398
522
  Success
399
523
  ErrorMessage
@@ -433,13 +557,137 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
433
557
  RoleName
434
558
  }
435
559
  }
436
- }`,{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 m(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async DeleteQuery(e,t){try{if(!e||e.trim()==="")return m("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) {
560
+ }`,{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 d(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async DeleteQuery(e,t){try{if(!e||e.trim()==="")return d("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) {
437
561
  DeleteQuerySystemResolver(ID: $ID, options: $options) {
438
562
  Success
439
563
  ErrorMessage
440
564
  QueryData
441
565
  }
442
- }`,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 m(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${r}`),{Success:!1,ErrorMessage:r.toString()}}}};S(re,"GraphQLSystemUserClient");let A=re;const se=class se{};S(se,"GetDataOutput");let q=se;const ae=class ae{};S(ae,"SimpleRemoteEntityOutput");let _=ae;const ne=class ne{};S(ne,"SimpleRemoteEntity");let B=ne;const ie=class ie{};S(ie,"SimpleRemoteEntityField");let b=ie;const oe=class oe{constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),a=this.createActionVariables(e,s,r),o=await this.executeActionMutation(a);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=R`
566
+ }`,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 d(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${r}`),{Success:!1,ErrorMessage:r.toString()}}}async RunAIPrompt(e){try{const t=m`
567
+ query RunAIPromptSystemUser(
568
+ $promptId: String!,
569
+ $data: String,
570
+ $overrideModelId: String,
571
+ $overrideVendorId: String,
572
+ $configurationId: String,
573
+ $skipValidation: Boolean,
574
+ $templateData: String,
575
+ $responseFormat: String,
576
+ $temperature: Float,
577
+ $topP: Float,
578
+ $topK: Int,
579
+ $minP: Float,
580
+ $frequencyPenalty: Float,
581
+ $presencePenalty: Float,
582
+ $seed: Int,
583
+ $stopSequences: [String!],
584
+ $includeLogProbs: Boolean,
585
+ $topLogProbs: Int,
586
+ $messages: String,
587
+ $rerunFromPromptRunID: String,
588
+ $systemPromptOverride: String
589
+ ) {
590
+ RunAIPromptSystemUser(
591
+ promptId: $promptId,
592
+ data: $data,
593
+ overrideModelId: $overrideModelId,
594
+ overrideVendorId: $overrideVendorId,
595
+ configurationId: $configurationId,
596
+ skipValidation: $skipValidation,
597
+ templateData: $templateData,
598
+ responseFormat: $responseFormat,
599
+ temperature: $temperature,
600
+ topP: $topP,
601
+ topK: $topK,
602
+ minP: $minP,
603
+ frequencyPenalty: $frequencyPenalty,
604
+ presencePenalty: $presencePenalty,
605
+ seed: $seed,
606
+ stopSequences: $stopSequences,
607
+ includeLogProbs: $includeLogProbs,
608
+ topLogProbs: $topLogProbs,
609
+ messages: $messages,
610
+ rerunFromPromptRunID: $rerunFromPromptRunID,
611
+ systemPromptOverride: $systemPromptOverride
612
+ ) {
613
+ success
614
+ output
615
+ parsedResult
616
+ error
617
+ executionTimeMs
618
+ tokensUsed
619
+ promptRunId
620
+ rawResult
621
+ validationResult
622
+ chatResult
623
+ }
624
+ }
625
+ `,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 d(`GraphQLSystemUserClient::RunAIPrompt - Error running AI prompt - ${t}`),{success:!1,error:t.toString()}}}async RunAIAgent(e){try{const t=m`
626
+ query RunAIAgentSystemUser(
627
+ $agentId: String!,
628
+ $messages: String!,
629
+ $sessionId: String!,
630
+ $data: String,
631
+ $templateData: String,
632
+ $lastRunId: String,
633
+ $autoPopulateLastRunPayload: Boolean,
634
+ $configurationId: String
635
+ ) {
636
+ RunAIAgentSystemUser(
637
+ agentId: $agentId,
638
+ messages: $messages,
639
+ sessionId: $sessionId,
640
+ data: $data,
641
+ templateData: $templateData,
642
+ lastRunId: $lastRunId,
643
+ autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
644
+ configurationId: $configurationId
645
+ ) {
646
+ success
647
+ errorMessage
648
+ executionTimeMs
649
+ payload
650
+ }
651
+ }
652
+ `,r=this.prepareAgentVariables(e),s=await this.Client.request(t,r);return s&&s.RunAIAgentSystemUser?this.processAgentResult(s.RunAIAgentSystemUser):{success:!1,errorMessage:"Failed to execute AI agent as system user"}}catch(t){return d(`GraphQLSystemUserClient::RunAIAgent - Error running AI agent - ${t}`),{success:!1,errorMessage:t.toString()}}}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.agentId,messages:JSON.stringify(e.messages),sessionId:e.sessionId};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.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){let t;try{e.payload&&(t=JSON.parse(e.payload))}catch{t=e.payload}return{success:e.success,errorMessage:e.errorMessage,executionTimeMs:e.executionTimeMs,payload:t}}async ExecuteSimplePrompt(e){try{const t=m`
653
+ query ExecuteSimplePromptSystemUser(
654
+ $systemPrompt: String!,
655
+ $messages: String,
656
+ $preferredModels: [String!],
657
+ $modelPower: String,
658
+ $responseFormat: String
659
+ ) {
660
+ ExecuteSimplePromptSystemUser(
661
+ systemPrompt: $systemPrompt,
662
+ messages: $messages,
663
+ preferredModels: $preferredModels,
664
+ modelPower: $modelPower,
665
+ responseFormat: $responseFormat
666
+ ) {
667
+ success
668
+ result
669
+ resultObject
670
+ modelName
671
+ error
672
+ executionTimeMs
673
+ }
674
+ }
675
+ `,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 d(`GraphQLSystemUserClient::ExecuteSimplePrompt - Error executing simple prompt - ${t}`),{success:!1,modelName:"Unknown",error:t.toString()}}}async EmbedText(e){try{const t=m`
676
+ query EmbedTextSystemUser(
677
+ $textToEmbed: [String!]!,
678
+ $modelSize: String!
679
+ ) {
680
+ EmbedTextSystemUser(
681
+ textToEmbed: $textToEmbed,
682
+ modelSize: $modelSize
683
+ ) {
684
+ embeddings
685
+ modelName
686
+ vectorDimensions
687
+ error
688
+ }
689
+ }
690
+ `,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 d(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}};p(ae,"GraphQLSystemUserClient");let L=ae;const ne=class ne{};p(ne,"GetDataOutput");let q=ne;const oe=class oe{};p(oe,"SimpleRemoteEntityOutput");let O=oe;const ie=class ie{};p(ie,"SimpleRemoteEntity");let _=ie;const ue=class ue{};p(ue,"SimpleRemoteEntityField");let B=ue;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`
443
691
  mutation RunAction($input: RunActionInput!) {
444
692
  RunAction(input: $input) {
445
693
  Success
@@ -448,7 +696,7 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
448
696
  ResultData
449
697
  }
450
698
  }
451
- `;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){m(`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 m(`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=R`
699
+ `;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){d(`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 d(`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`
452
700
  mutation RunEntityAction($input: EntityActionInput!) {
453
701
  RunEntityAction(input: $input) {
454
702
  Success
@@ -456,5 +704,5 @@ var we=Object.defineProperty;var S=(g,e)=>we(g,"name",{value:e,configurable:!0})
456
704
  ResultData
457
705
  }
458
706
  }
459
- `;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){m(`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 m(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};S(oe,"GraphQLActionClient");let O=oe;export{F as ActionItemInput,L as ActionItemOutput,N as FieldMapper,q as GetDataOutput,O as GraphQLActionClient,$ as GraphQLDataProvider,Q as GraphQLProviderConfigData,A as GraphQLSystemUserClient,V as GraphQLTransactionGroup,v as RoleInput,x as RolesAndUsersInput,B as SimpleRemoteEntity,b as SimpleRemoteEntityField,_ as SimpleRemoteEntityOutput,Re as SyncDataAction,M as SyncDataResult,U as SyncRolesAndUsersResult,T as UserInput,Be as gql,Pe as setupGraphQLClient};
707
+ `;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){d(`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 d(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};p(le,"GraphQLActionClient");let k=le;export{G as ActionItemInput,A as ActionItemOutput,P as FieldMapper,q as GetDataOutput,v as GraphQLAIClient,k as GraphQLActionClient,C as GraphQLDataProvider,V as GraphQLProviderConfigData,L as GraphQLSystemUserClient,N as GraphQLTransactionGroup,F as RoleInput,Q as RolesAndUsersInput,_ as SimpleRemoteEntity,B as SimpleRemoteEntityField,O as SimpleRemoteEntityOutput,pe as SyncDataAction,b as SyncDataResult,T as SyncRolesAndUsersResult,M as UserInput,Be as gql,Ue as setupGraphQLClient};
460
708
  //# sourceMappingURL=index.mjs.map