@memberjunction/graphql-dataprovider 2.74.0 → 2.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ye=Object.defineProperty;var S=(f,e)=>ye(f,"name",{value:e,configurable:!0});var g=require("graphql-request"),c=require("@memberjunction/core"),oe=require("@memberjunction/core-entities"),de=require("@tempfix/idb"),ue=require("rxjs"),le=require("graphql-ws"),me=require("uuid"),N=require("@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 I=K;const b=class b extends c.TransactionGroupBase{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=g.gql`
1
+ "use strict";var ye=Object.defineProperty;var S=(f,e)=>ye(f,"name",{value:e,configurable:!0});var R=require("graphql-request"),c=require("@memberjunction/core"),oe=require("@memberjunction/core-entities"),de=require("@tempfix/idb"),ue=require("rxjs"),le=require("graphql-ws"),me=require("uuid"),N=require("@memberjunction/global");const b=class b{constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const r in e)r in this._fieldMap&&(e[this._fieldMap[r]]=e[r],delete e[r]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([r,t])=>t===e)?.[0]??e}ReverseMapFields(e){const r=Object.fromEntries(Object.entries(this._fieldMap).map(([t,s])=>[s,t]));for(const t in e)t in r&&(e[r[t]]=e[t],delete e[t]);return e}};S(b,"FieldMapper");let I=b;const K=class K extends c.TransactionGroupBase{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=R.gql`
2
2
  mutation ExecuteTransactionGroup($group: TransactionInputType!) {
3
3
  ExecuteTransactionGroup(group: $group) {
4
4
  Success
@@ -6,15 +6,15 @@
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],d=N.SafeJSONParse(n),D=this.PendingTransactions[i];o.push(new c.TransactionResult(D,d,d!==null))}return o}else throw new Error("Failed to execute transaction group")}};S(b,"GraphQLTransactionGroup");let C=b;const k=class k extends c.ProviderConfigDataBase{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(k,"GraphQLProviderConfigData");let G=k;const w=class w extends c.ProviderBase{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
9
+ `,r=[];for(const a of this.PendingTransactions)r.push({EntityName:a.BaseEntity.EntityInfo.Name,EntityObjectJSON:await a.BaseEntity.GetDataObjectJSON(),OperationType:a.OperationType});const t={group:{Items:r,Variables:this.Variables.map(a=>({Name:a.Name,ItemIndex:this.MapVariableEntityObjectToPosition(a),FieldName:a.FieldName,Type:a.Type}))}},s=await this._provider.ExecuteGQL(e,t);if(s&&s.ExecuteTransactionGroup){const a=s.ExecuteTransactionGroup,o=[];for(let i=0;i<this.PendingTransactions.length;i++){const n=a.ResultsJSON[i],d=N.SafeJSONParse(n),D=this.PendingTransactions[i];o.push(new c.TransactionResult(D,d,d!==null))}return o}else throw new Error("Failed to execute transaction group")}};S(K,"GraphQLTransactionGroup");let C=K;const k=class k extends c.ProviderConfigDataBase{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,r,t,s,a,o,i,n){super({Token:e,URL:r,WSURL:t,MJAPIKey:n,RefreshTokenFunction:s},a,o,i)}};S(k,"GraphQLProviderConfigData");let $=k;const h=class h extends c.ProviderBase{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
10
10
  ${this.userInfoString()}
11
11
  UserRoles_UserIDArray {
12
12
  ${this.userRoleInfoString()}
13
13
  }
14
14
  }
15
- `,this._currentUserQuery=g.gql`query CurrentUserAndRoles {
15
+ `,this._currentUserQuery=R.gql`query CurrentUserAndRoles {
16
16
  ${this._innerCurrentUserQueryString}
17
- }`,this._wsClient=null,this._pushStatusRequests=[],w._instance||(w._instance=this)}static get Instance(){return w._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 me.v4()}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){try{return t?(this._configData=e,this._sessionId=await this.GetPreferredUUID(r),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey),await this.SaveStoredSessionID(this._sessionId)):(w.Instance._configData=e,w.Instance._sessionId===void 0&&(w.Instance._sessionId=await this.GetPreferredUUID(r)),w.Instance._client||(w.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,w.Instance._sessionId,e.MJAPIKey)),await w.Instance.SaveStoredSessionID(w.Instance._sessionId)),super.Config(e)}catch(s){throw c.LogError(s),s}}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 c.UserInfo(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=g.gql`
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 me.v4()}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 r=this.LocalStoragePrefix+"sessionId";return await e.GetItem(r)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const r=this.LocalStorageProvider;if(r){const t=this.LocalStoragePrefix+"sessionId";await r.SetItem(t,e)}}catch{}}async GetPreferredUUID(e){const r=await this.GetStoredSessionID();return e||!r?this.GenerateUUID():r}async Config(e,r,t){try{return r?(this._configData=e,this._sessionId=await this.GetPreferredUUID(t),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(t)),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(s){throw c.LogError(s),s}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const r=this.ConvertBackToMJFields(e.CurrentUser),t=r.UserRoles_UserIDArray.map(s=>this.ConvertBackToMJFields(s));return r.UserRoles_UserIDArray=t,new c.UserInfo(this,{...r,UserRoles:t})}}async RunReport(e,r){const t=R.gql`
18
18
  query GetReportDataQuery ($ReportID: String!) {
19
19
  GetReportData(ReportID: $ReportID) {
20
20
  Success
@@ -23,19 +23,19 @@
23
23
  ExecutionTime
24
24
  ErrorMessage
25
25
  }
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.CategoryName,t,e.Parameters,e.MaxRows,e.StartRow);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryName,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=g.gql`
27
- query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryName: String, $Parameters: JSON, $MaxRows: Int, $StartRow: Int) {
28
- GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryName: $CategoryName, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
26
+ }`,s=await this.ExecuteGQL(t,{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,r){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryPath,r,e.Parameters,e.MaxRows,e.StartRow);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryPath,r,e.Parameters,e.MaxRows,e.StartRow);throw new Error("No QueryID or QueryName provided to RunQuery")}async RunQueryByID(e,r,t,s,a,o,i){const n=R.gql`
27
+ query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
28
+ GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
29
29
  ${this.QueryReturnFieldList}
30
30
  }
31
31
  }
32
- `,d={QueryID:e};t!==void 0&&(d.CategoryID=t),r!==void 0&&(d.CategoryName=r),a!==void 0&&(d.Parameters=a),o!==void 0&&(d.MaxRows=o),i!==void 0&&(d.StartRow=i);const D=await this.ExecuteGQL(n,d);if(D&&D.GetQueryData)return this.TransformQueryPayload(D.GetQueryData)}async RunQueryByName(e,t,r,s,a,o,i){const n=g.gql`
33
- query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryName: String, $Parameters: JSON, $MaxRows: Int, $StartRow: Int) {
34
- GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryName: $CategoryName, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
32
+ `,d={QueryID:e};r!==void 0&&(d.CategoryID=r),t!==void 0&&(d.CategoryPath=t),a!==void 0&&(d.Parameters=a),o!==void 0&&(d.MaxRows=o),i!==void 0&&(d.StartRow=i);const D=await this.ExecuteGQL(n,d);if(D&&D.GetQueryData)return this.TransformQueryPayload(D.GetQueryData)}async RunQueryByName(e,r,t,s,a,o,i){const n=R.gql`
33
+ query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
34
+ GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
35
35
  ${this.QueryReturnFieldList}
36
36
  }
37
37
  }
38
- `,d={QueryName:e};t!==void 0&&(d.CategoryID=t),r!==void 0&&(d.CategoryName=r),a!==void 0&&(d.Parameters=a),o!==void 0&&(d.MaxRows=o),i!==void 0&&(d.StartRow=i);const D=await this.ExecuteGQL(n,d);if(D&&D.GetQueryDataByName)return this.TransformQueryPayload(D.GetQueryDataByName)}get QueryReturnFieldList(){return`
38
+ `,d={QueryName:e};r!==void 0&&(d.CategoryID=r),t!==void 0&&(d.CategoryPath=t),a!==void 0&&(d.Parameters=a),o!==void 0&&(d.MaxRows=o),i!==void 0&&(d.StartRow=i);const D=await this.ExecuteGQL(n,d);if(D&&D.GetQueryDataByName)return this.TransformQueryPayload(D.GetQueryDataByName)}get QueryReturnFieldList(){return`
39
39
  Success
40
40
  QueryID
41
41
  QueryName
@@ -44,9 +44,9 @@
44
44
  TotalRowCount
45
45
  ExecutionTime
46
46
  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 c.LogError(`Error transforming query payload: ${t}`),null}}async RunView(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 d=!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):(d=!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,a.MaxRows=e.MaxRows?e.MaxRows:0,a.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,a.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(a.AuditLogDescription=e.AuditLogDescription),d||(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,d),m=g.gql`
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(r){return c.LogError(`Error transforming query payload: ${r}`),null}}async RunView(e,r){try{let t="",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,r);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 d=!1;e.ViewID?(t=`Run${n.ClassName}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(t=`Run${n.ClassName}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(d=!0,t=`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,a.MaxRows=e.MaxRows?e.MaxRows:0,a.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,a.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(a.AuditLogDescription=e.AuditLogDescription),d||(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,d),m=R.gql`
48
48
  query RunViewQuery ($input: ${s}!) {
49
- ${r}(input: $input) {
49
+ ${t}(input: $input) {
50
50
  Results {
51
51
  ${D.join(`
52
52
  `)}
@@ -58,7 +58,7 @@
58
58
  Success
59
59
  ErrorMessage
60
60
  }
61
- }`,y=await this.ExecuteGQL(m,{input:a});if(y&&y[r]){const u=y[r].Results;if(u&&u.length>0){const l=n.Fields.filter(R=>R.CodeName!==R.Name&&R.CodeName!==void 0);u.forEach(R=>{this.ConvertBackToMJFields(R),l.forEach(E=>{R[E.Name]=R[E.CodeName]})})}return y[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw c.LogError(r),r}}async RunViews(e,t){try{let r=[],s=[],a=[];for(const n of e){let d="",D="";const m={};let y=null,u=null;if(n.ViewEntity)u=n.ViewEntity,y=u.Get("Entity");else{const{entityName:E,v:p}=await this.getEntityNameAndUserView(n,t);u=p,y=E}const l=this.Entities.find(E=>E.Name===y);if(!l)throw new Error(`Entity ${y} not found in metadata`);s.push(l);let R=!1;n.ViewID?(d=`Run${l.ClassName}ViewByID`,D="RunViewByIDInput",m.ViewID=n.ViewID):n.ViewName?(d=`Run${l.ClassName}ViewByName`,D="RunViewByNameInput",m.ViewName=n.ViewName):(R=!0,d=`Run${l.ClassName}DynamicView`,D="RunDynamicViewInput",m.EntityName=n.EntityName),m.ExtraFilter=n.ExtraFilter||"",m.OrderBy=n.OrderBy||"",m.UserSearchString=n.UserSearchString||"",m.Fields=n.Fields,m.IgnoreMaxRows=n.IgnoreMaxRows||!1,m.MaxRows=n.MaxRows||0,m.ForceAuditLog=n.ForceAuditLog||!1,m.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(m.AuditLogDescription=n.AuditLogDescription),R||(m.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",m.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,m.OverrideExcludeFilter=n.OverrideExcludeFilter||"",m.SaveViewResults=n.SaveViewResults||!1),r.push(m),a.push(...this.getViewRunTimeFieldList(l,u,n,R))}const o=g.gql`
61
+ }`,y=await this.ExecuteGQL(m,{input:a});if(y&&y[t]){const u=y[t].Results;if(u&&u.length>0){const l=n.Fields.filter(g=>g.CodeName!==g.Name&&g.CodeName!==void 0);u.forEach(g=>{this.ConvertBackToMJFields(g),l.forEach(w=>{g[w.Name]=g[w.CodeName]})})}return y[t]}}else throw"No parameters passed to RunView";return null}catch(t){throw c.LogError(t),t}}async RunViews(e,r){try{let t=[],s=[],a=[];for(const n of e){let d="",D="";const m={};let y=null,u=null;if(n.ViewEntity)u=n.ViewEntity,y=u.Get("Entity");else{const{entityName:w,v:p}=await this.getEntityNameAndUserView(n,r);u=p,y=w}const l=this.Entities.find(w=>w.Name===y);if(!l)throw new Error(`Entity ${y} not found in metadata`);s.push(l);let g=!1;n.ViewID?(d=`Run${l.ClassName}ViewByID`,D="RunViewByIDInput",m.ViewID=n.ViewID):n.ViewName?(d=`Run${l.ClassName}ViewByName`,D="RunViewByNameInput",m.ViewName=n.ViewName):(g=!0,d=`Run${l.ClassName}DynamicView`,D="RunDynamicViewInput",m.EntityName=n.EntityName),m.ExtraFilter=n.ExtraFilter||"",m.OrderBy=n.OrderBy||"",m.UserSearchString=n.UserSearchString||"",m.Fields=n.Fields,m.IgnoreMaxRows=n.IgnoreMaxRows||!1,m.MaxRows=n.MaxRows||0,m.ForceAuditLog=n.ForceAuditLog||!1,m.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(m.AuditLogDescription=n.AuditLogDescription),g||(m.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",m.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,m.OverrideExcludeFilter=n.OverrideExcludeFilter||"",m.SaveViewResults=n.SaveViewResults||!1),t.push(m),a.push(...this.getViewRunTimeFieldList(l,u,n,g))}const o=R.gql`
62
62
  query RunViewsQuery ($input: [RunViewGenericInput!]!) {
63
63
  RunViews(input: $input) {
64
64
  Results {
@@ -73,7 +73,7 @@
73
73
  Success
74
74
  ErrorMessage
75
75
  }
76
- }`,i=await this.ExecuteGQL(o,{input:r});if(i&&i.RunViews){const n=i.RunViews;for(const[d,D]of n.entries())D.Results=D.Results.map(m=>{let y=JSON.parse(m.Data);return this.ConvertBackToMJFields(y),y});return n}return null}catch(r){throw c.LogError(r),r}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await oe.ViewInfo.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await oe.ViewInfo.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 I;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 c.ProviderType.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 c.LogError(r),r}}async GetRecordDependencies(e,t){try{const r=g.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
76
+ }`,i=await this.ExecuteGQL(o,{input:t});if(i&&i.RunViews){const n=i.RunViews;for(const[d,D]of n.entries())D.Results=D.Results.map(m=>{let y=JSON.parse(m.Data);return this.ConvertBackToMJFields(y),y});return n}return null}catch(t){throw c.LogError(t),t}}async getEntityNameAndUserView(e,r){let t,s;if(e.EntityName)t=e.EntityName;else if(e.ViewID)s=await oe.ViewInfo.GetViewEntity(e.ViewID,r),t=s.Entity;else if(e.ViewName)s=await oe.ViewInfo.GetViewEntityByName(e.ViewName,r),t=s.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:t,v:s}}getViewRunTimeFieldList(e,r,t,s){const a=[],o=new I;if(t.Fields){for(const i of e.PrimaryKeys)t.Fields.find(n=>n.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&a.push(i.Name);t.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);r.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 c.ProviderType.Network}async GetRecordChanges(e,r){try{const t={EntityName:"Record Changes",ExtraFilter:`RecordID = '${r.Values()}' AND Entity = '${e}'`},s=await this.RunView(t);return s?s.Results.sort((a,o)=>a.ChangedAt>o.ChangedAt?-1:1):null}catch(t){throw c.LogError(t),t}}async GetRecordDependencies(e,r){try{const t=R.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
77
77
  GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
78
78
  EntityName
79
79
  RelatedEntityName
@@ -85,7 +85,7 @@
85
85
  }
86
86
  }
87
87
  }
88
- }`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,s))?.GetRecordDependencies}catch(r){throw c.LogError(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=g.gql`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
88
+ }`,s={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}};return(await this.ExecuteGQL(t,s))?.GetRecordDependencies}catch(t){throw c.LogError(t),t}}ensureKeyValuePairValueIsString(e){return e.map(r=>({FieldName:r.FieldName,Value:r.Value.toString()}))}async GetRecordDuplicates(e,r){if(!e)return null;const t=R.gql`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
89
89
  GetRecordDuplicates(params: $params) {
90
90
  Status
91
91
  ErrorMessage
@@ -107,7 +107,7 @@
107
107
  }
108
108
  }
109
109
  }
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){const t=this.Entities.find(r=>r.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!t||!t.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const r=g.gql`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
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(t,{params:s});if(a&&a.GetRecordDuplicates)return a.GetRecordDuplicates}async MergeRecords(e){const r=this.Entities.find(t=>t.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!r||!r.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const t=R.gql`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
111
111
  MergeRecords(request: $request) {
112
112
  Success
113
113
  OverallStatus
@@ -124,32 +124,32 @@
124
124
  Message
125
125
  }
126
126
  }
127
- }`,s={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(r,{request:s}))?.MergeRecords}catch(r){return c.LogError(r),{Success:!1,OverallStatus:r&&r.message?r.message:r,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){const s=new c.BaseEntityResult;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(y=>({FieldName:y.CodeName,Value:y.Value})),e.ResultHistory.push(s);const i=`${o}${e.EntityInfo.ClassName}`,n=e.Fields.filter(y=>!y.ReadOnly||y.IsPrimaryKey&&e.IsSaved),d=new I,D=` ${i}(input: $input) {
127
+ }`,s={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(t,{request:s}))?.MergeRecords}catch(t){return c.LogError(t),{Success:!1,OverallStatus:t&&t.message?t.message:t,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,r,t){const s=new c.BaseEntityResult;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(y=>({FieldName:y.CodeName,Value:y.Value})),e.ResultHistory.push(s);const i=`${o}${e.EntityInfo.ClassName}`,n=e.Fields.filter(y=>!y.ReadOnly||y.IsPrimaryKey&&e.IsSaved),d=new I,D=` ${i}(input: $input) {
128
128
  ${e.Fields.map(y=>d.MapFieldName(y.CodeName)).join(`
129
129
  `)}
130
- }`,m=g.gql`mutation ${o}${e.EntityInfo.ClassName} ($input: ${i}Input!) {
130
+ }`,m=R.gql`mutation ${o}${e.EntityInfo.ClassName} ($input: ${i}Input!) {
131
131
  ${D}
132
132
  }
133
- `;for(let y=0;y<n.length;y++){const u=n[y];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:l=l.getTime();break;case c.EntityFieldTSType.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case c.EntityFieldTSType.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===c.EntityFieldTSType.Number||u.FieldType===c.EntityFieldTSType.Boolean?l=0:l=""),a.input[u.CodeName]=l}if(o.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const y=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?l=u.OldValue===!0?"1":"0":typeof u.OldValue!="string"?l=u.OldValue.toString():l=u.OldValue),y.push({Key:u.CodeName,Value:l})}),a.input.OldValues___=y}if(e.TransactionGroup){const y=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",D,a,{mutationName:i,mutationInputTypes:y},(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 y=await this.ExecuteGQL(m,a);if(y&&y[o+e.EntityInfo.ClassName])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(y[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,c.LogError(a),null}}async Load(e,t,r=null,s){try{const a={};let o="",i="";for(let y=0;y<t.KeyValuePairs.length;y++){const u=e.Fields.find(E=>E.Name.trim().toLowerCase()===t.KeyValuePairs[y].FieldName.trim().toLowerCase()).EntityFieldInfo,l=t.GetValueByIndex(y),R=u.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${u.CodeName}: ${R}!`,o.length>0&&(o+=", "),o+=`${u.CodeName}: $${u.CodeName}`,u.TSType===c.EntityFieldTSType.Number){if(isNaN(t.GetValueByIndex(y)))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):"",d=new I,D=g.gql`query Single${e.EntityInfo.ClassName}${n.length>0?"Full":""} (${i}) {
133
+ `;for(let y=0;y<n.length;y++){const u=n[y];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:l=l.getTime();break;case c.EntityFieldTSType.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case c.EntityFieldTSType.Number:if(typeof l!="number"){const g=Number(l);isNaN(g)||(l=g)}break}l===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?l=u.EntityFieldInfo.DefaultValue:u.FieldType===c.EntityFieldTSType.Number||u.FieldType===c.EntityFieldTSType.Boolean?l=0:l=""),a.input[u.CodeName]=l}if(o.trim().toLowerCase()==="update"&&t.SkipOldValuesCheck===!1){const y=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?l=u.OldValue===!0?"1":"0":typeof u.OldValue!="string"?l=u.OldValue.toString():l=u.OldValue),y.push({Key:u.CodeName,Value:l})}),a.input.OldValues___=y}if(e.TransactionGroup){const y=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",D,a,{mutationName:i,mutationInputTypes:y},(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 y=await this.ExecuteGQL(m,a);if(y&&y[o+e.EntityInfo.ClassName])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(y[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,c.LogError(a),null}}async Load(e,r,t=null,s){try{const a={};let o="",i="";for(let y=0;y<r.KeyValuePairs.length;y++){const u=e.Fields.find(w=>w.Name.trim().toLowerCase()===r.KeyValuePairs[y].FieldName.trim().toLowerCase()).EntityFieldInfo,l=r.GetValueByIndex(y),g=u.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${u.CodeName}: ${g}!`,o.length>0&&(o+=", "),o+=`${u.CodeName}: $${u.CodeName}`,u.TSType===c.EntityFieldTSType.Number){if(isNaN(r.GetValueByIndex(y)))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=t&&t.length>0?this.getRelatedEntityString(e.EntityInfo,t):"",d=new I,D=R.gql`query Single${e.EntityInfo.ClassName}${n.length>0?"Full":""} (${i}) {
134
134
  ${e.EntityInfo.ClassName}(${o}) {
135
135
  ${e.Fields.filter(y=>!y.EntityFieldInfo.IsBinaryFieldType).map(y=>y.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?y.CodeName.replace("__mj_","_mj__"):y.CodeName).join(`
136
136
  `)}
137
137
  ${n}
138
138
  }
139
139
  }
140
- `,m=await this.ExecuteGQL(D,a);return m&&m[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(m[e.EntityInfo.ClassName]):null}catch(a){return c.LogError(a),null}}ConvertBackToMJFields(e){return new I().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+=`
140
+ `,m=await this.ExecuteGQL(D,a);return m&&m[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(m[e.EntityInfo.ClassName]):null}catch(a){return c.LogError(a),null}}ConvertBackToMJFields(e){return new I().ReverseMapFields(e),e}getRelatedEntityString(e,r){let t="";for(let s=0;s<e.RelatedEntities.length;s++)if(r.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,"")}`,t+=`
141
141
  ${i} {
142
142
  ${o.Fields.map(n=>n.CodeName).join(`
143
143
  `)}
144
144
  }
145
- `}return r}async Delete(e,t,r){const s=new c.BaseEntityResult;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="",d="";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,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}!`,d.length>0&&(d+=`
146
- `),d+=`${l.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const D="Delete"+e.EntityInfo.ClassName,m=g.gql`${D}(${i}, options___: $options___) {
145
+ `}return t}async Delete(e,r,t){const s=new c.BaseEntityResult;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="",d="";for(let u of e.PrimaryKey.KeyValuePairs){const l=e.Fields.find(g=>g.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}!`,d.length>0&&(d+=`
146
+ `),d+=`${l.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=r||{SkipEntityAIActions:!1,SkipEntityActions:!1};const D="Delete"+e.EntityInfo.ClassName,m=R.gql`${D}(${i}, options___: $options___) {
147
147
  ${d}
148
148
  }
149
- `,y=g.gql`mutation ${D} (${n}, $options___: DeleteOptionsInput!) {
149
+ `,y=R.gql`mutation ${D} (${n}, $options___: DeleteOptionsInput!) {
150
150
  ${m}
151
151
  }
152
- `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,"Delete",m,a,{mutationName:D,mutationInputTypes:o},(u,l)=>{if(s.EndedAt=new Date,l&&u){let R=!0;for(const E of e.PrimaryKey.KeyValuePairs)E.Value!==u[E.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(y,a);if(u&&u[D]){const l=u[D];for(let R of e.PrimaryKey.KeyValuePairs){let E=l[R.FieldName],p=R.Value;if(typeof p=="number"&&(p=p.toString()),typeof E=="number"&&(E=E.toString()),p!==E)throw new Error(`Primary key value mismatch in server Delete response. Field: ${R.FieldName}, Original: ${p}, Returned: ${E}`)}return s.Success=!0,s.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(a){return s.EndedAt=new Date,s.Success=!1,s.Message=a.response?.errors?.length>0?a.response.errors[0].message:a.message,c.LogError(a),!1}}async GetDatasetByName(e,t){const r=g.gql`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
152
+ `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,"Delete",m,a,{mutationName:D,mutationInputTypes:o},(u,l)=>{if(s.EndedAt=new Date,l&&u){let g=!0;for(const w of e.PrimaryKey.KeyValuePairs)w.Value!==u[w.FieldName]&&(g=!1);g?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(y,a);if(u&&u[D]){const l=u[D];for(let g of e.PrimaryKey.KeyValuePairs){let w=l[g.FieldName],p=g.Value;if(typeof p=="number"&&(p=p.toString()),typeof w=="number"&&(w=w.toString()),p!==w)throw new Error(`Primary key value mismatch in server Delete response. Field: ${g.FieldName}, Original: ${p}, 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,c.LogError(a),!1}}async GetDatasetByName(e,r){const t=R.gql`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
153
153
  GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
154
154
  DatasetID
155
155
  DatasetName
@@ -158,7 +158,7 @@
158
158
  LatestUpdateDate
159
159
  Results
160
160
  }
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=g.gql`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
161
+ }`,s=await this.ExecuteGQL(t,{DatasetName:e,ItemFilters:r});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,r){const t=R.gql`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
162
162
  GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
163
163
  DatasetID
164
164
  DatasetName
@@ -167,22 +167,22 @@
167
167
  LatestUpdateDate
168
168
  EntityUpdateDates
169
169
  }
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 C(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=g.gql`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
170
+ }`,s=await this.ExecuteGQL(t,{DatasetName:e,ItemFilters:r});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 C(this)}async GetRecordFavoriteStatus(e,r,t){if(!t.Validate().IsValid)return!1;const a=this.Entities.find(n=>n.Name===r);if(!a)throw new Error(`Entity ${r} not found in metadata`);const o=R.gql`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
171
171
  GetRecordFavoriteStatus(params: $params) {
172
172
  Success
173
173
  IsFavorite
174
174
  }
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(d=>d.Name===t);if(!o)throw new Error(`Entity ${t} not found in metadata`);const i=g.gql`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
175
+ }`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:a.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}}});if(i&&i.GetRecordFavoriteStatus&&i.GetRecordFavoriteStatus.Success)return i.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,r,t,s,a){const o=this.Entities.find(d=>d.Name===r);if(!o)throw new Error(`Entity ${r} not found in metadata`);const i=R.gql`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
176
176
  SetRecordFavoriteStatus(params: $params){
177
177
  Success
178
178
  }
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=g.gql`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
179
+ }`,n=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)},IsFavorite:s}});if(n&&n.SetRecordFavoriteStatus!==null)return n.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,r){if(!e||!r||r.KeyValuePairs?.length===0)return null;const t=R.gql`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
180
180
  GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
181
181
  Success
182
182
  Status
183
183
  RecordName
184
184
  }
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=g.gql`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
185
+ }`,s=await this.ExecuteGQL(t,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}});if(s&&s.GetEntityRecordName&&s.GetEntityRecordName.Success)return s.GetEntityRecordName.RecordName}async GetEntityRecordNames(e){if(!e)return null;const r=R.gql`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
186
186
  GetEntityRecordNames(info: $info) {
187
187
  Success
188
188
  Status
@@ -195,35 +195,35 @@
195
195
  EntityName
196
196
  RecordName
197
197
  }
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=g.gql`query GetDataContextData ($DataContextID: String!) {
198
+ }`,t=await this.ExecuteGQL(r,{info:e.map(s=>({EntityName:s.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.CompositeKey.KeyValuePairs)}}))});if(t&&t.GetEntityRecordNames)return t.GetEntityRecordNames}async GetDataContextData(e){try{const r=R.gql`query GetDataContextData ($DataContextID: String!) {
199
199
  GetDataContextData(DataContextID: $DataContextID) {
200
200
  Success
201
201
  ErrorMessages
202
202
  Results
203
203
  }
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 c.LogError(t),t}}async GetDataContextItemData(e){try{const t=g.gql`query GetDataContextItemData ($DataContextItemID: String!) {
204
+ }`,t=await this.ExecuteGQL(r,{DataContextID:e});if(t&&t.GetDataContextData){if(t.GetDataContextData.Success)return t.GetDataContextData.Results.map(s=>JSON.parse(s));throw new Error(t.GetDataContextData.ErrorMessages.join(", "))}else throw new Error("GraphQL query failed")}catch(r){throw c.LogError(r),r}}async GetDataContextItemData(e){try{const r=R.gql`query GetDataContextItemData ($DataContextItemID: String!) {
205
205
  GetDataContextItemData(DataContextItemID: $DataContextItemID) {
206
206
  Success
207
207
  ErrorMessage
208
208
  Result
209
209
  }
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 c.LogError(t),t}}static async ExecuteGQL(e,t,r=!0){return w.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 c.LogError("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw c.LogError(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 w.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 g.GraphQLClient(e,{headers:a})}userInfoString(){return this.infoString(new c.UserInfo(null,null))}userRoleInfoString(){return this.infoString(new c.UserRoleInfo(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
211
- `:s.startsWith("_")||(t+=s+`
212
- `);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new T),this._localStorageProvider}get Metadata(){return this}subscribe(e,t){return this._wsClient||(this._wsClient=le.createClient({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new ue.Observable(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=le.createClient({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=g.gql`subscription StatusUpdates($sessionId: String!) {
210
+ }`,t=await this.ExecuteGQL(r,{DataContextItemID:e});if(t&&t.GetDataContextItemData){if(t.GetDataContextItemData.Success)return JSON.parse(t.GetDataContextItemData.Result);throw new Error(t.GetDataContextItemData.ErrorMessage)}else throw new Error("GraphQL query failed")}catch(r){throw c.LogError(r),r}}static async ExecuteGQL(e,r,t=!0){return h.Instance.ExecuteGQL(e,r,t)}async ExecuteGQL(e,r,t=!0){try{return await this._client.request(e,r)}catch(s){if(s&&s.response&&s.response.errors?.length>0)if(s.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(t)return await this.RefreshToken(),await this.ExecuteGQL(e,r,!1);throw c.LogError("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw c.LogError(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,r,t,s){const a={"x-session-id":t};return r&&(a.authorization="Bearer "+r),s&&(a["x-mj-api-key"]=s),new R.GraphQLClient(e,{headers:a})}userInfoString(){return this.infoString(new c.UserInfo(null,null))}userRoleInfoString(){return this.infoString(new c.UserRoleInfo(null))}infoString(e){let r="";const t=Object.keys(e);for(const s of t)s.startsWith("__mj_")?r+=s.replace("__mj_","_mj__")+`
211
+ `:s.startsWith("_")||(r+=s+`
212
+ `);return r}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new P),this._localStorageProvider}get Metadata(){return this}subscribe(e,r){return this._wsClient||(this._wsClient=le.createClient({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new ue.Observable(t=>{const s=this._wsClient.subscribe({query:e,variables:r},{next:a=>{t.next(a.data)},error:a=>{t.error(a)},complete:()=>{t.complete()}});return()=>{s()}})}PushStatusUpdates(e=null){e||(e=this.sessionId),this._wsClient||(this._wsClient=le.createClient({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}}));const r=this._pushStatusRequests.find(a=>a.sessionId===e);if(r)return r.observable;const t=R.gql`subscription StatusUpdates($sessionId: String!) {
213
213
  statusUpdates(sessionId: $sessionId) {
214
214
  date
215
215
  message
216
216
  sessionId
217
217
  }
218
218
  }
219
- `,s=new ue.Observable(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(w,"GraphQLDataProvider");let V=w;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 $=J;const De="MJ_Metadata",h="Metadata_KVPairs",j=class j extends ${constructor(){super(),this.dbPromise=de.openDB(De,1,{upgrade(e){e.objectStoreNames.contains(h)||e.createObjectStore(h)}})}async setItem(e,t){const s=(await this.dbPromise).transaction(h,"readwrite");await s.objectStore(h).put(t,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(h).objectStore(h).get(e)}async remove(e){const r=(await this.dbPromise).transaction(h,"readwrite");await r.objectStore(h).delete(e),await r.done}};S(j,"BrowserIndexedDBStorageProvider");let T=j;async function ge(f){const e=new V;return c.SetProvider(e),await e.Config(f),N.MJGlobal.Instance.RaiseEvent({event:N.MJEventType.LoggedIn,eventCode:null,component:this,args:null}),e}S(ge,"setupGraphQLClient");const W=class W{};S(W,"SyncRolesAndUsersResult");let Q=W;const z=class z{};S(z,"RoleInput");let F=z;const H=class H{};S(H,"UserInput");let U=H;const X=class X{};S(X,"RolesAndUsersInput");let L=X;var ce=(f=>(f.Create="Create",f.Update="Update",f.CreateOrUpdate="CreateOrUpdate",f.Delete="Delete",f.DeleteWithFilter="DeleteWithFilter",f))(ce||{});const Z=class Z{};S(Z,"ActionItemInput");let v=Z;const Y=class Y{constructor(){this.Results=[]}};S(Y,"SyncDataResult");let P=Y;const ee=class ee{};S(ee,"ActionItemOutput");let x=ee;const te=class te{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 g.GraphQLClient(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
219
+ `,s=new ue.Observable(a=>(this._wsClient.subscribe({query:t,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 V=h;const J=class J{constructor(){this._localStorage={}}async GetItem(e){return new Promise(r=>{this._localStorage.hasOwnProperty(e)?r(this._localStorage[e]):r(null)})}async SetItem(e,r){return new Promise(t=>{this._localStorage[e]=r,t()})}async Remove(e){return new Promise(r=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],r()})}};S(J,"BrowserStorageProviderBase");let G=J;const De="MJ_Metadata",E="Metadata_KVPairs",j=class j extends G{constructor(){super(),this.dbPromise=de.openDB(De,1,{upgrade(e){e.objectStoreNames.contains(E)||e.createObjectStore(E)}})}async setItem(e,r){const s=(await this.dbPromise).transaction(E,"readwrite");await s.objectStore(E).put(r,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(E).objectStore(E).get(e)}async remove(e){const t=(await this.dbPromise).transaction(E,"readwrite");await t.objectStore(E).delete(e),await t.done}};S(j,"BrowserIndexedDBStorageProvider");let P=j;async function Re(f){const e=new V;return c.SetProvider(e),await e.Config(f),N.MJGlobal.Instance.RaiseEvent({event:N.MJEventType.LoggedIn,eventCode:null,component:this,args:null}),e}S(Re,"setupGraphQLClient");const W=class W{};S(W,"SyncRolesAndUsersResult");let Q=W;const z=class z{};S(z,"RoleInput");let T=z;const H=class H{};S(H,"UserInput");let v=H;const X=class X{};S(X,"RolesAndUsersInput");let U=X;var ce=(f=>(f.Create="Create",f.Update="Update",f.CreateOrUpdate="CreateOrUpdate",f.Delete="Delete",f.DeleteWithFilter="DeleteWithFilter",f))(ce||{});const Z=class Z{};S(Z,"ActionItemInput");let F=Z;const Y=class Y{constructor(){this.Results=[]}};S(Y,"SyncDataResult");let x=Y;const ee=class ee{};S(ee,"ActionItemOutput");let L=ee;const te=class te{get Client(){return this._client}constructor(e,r,t,s){const a={"x-session-id":t};r&&(a.authorization="Bearer "+r),s&&(a["x-mj-api-key"]=s),this._client=new R.GraphQLClient(e,{headers:a})}async GetData(e,r){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
220
220
  GetData(input: $input) {
221
221
  Success
222
222
  ErrorMessages
223
223
  Queries
224
224
  Results
225
225
  }
226
- }`,{input:{Queries:e,Token:"nope"}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(a=>a?N.SafeJSONParse(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 c.LogError(s),{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
226
+ }`,{input:{Queries:e,Token:r}});return s&&s.GetData?{Success:s.GetData.Success,Results:s.GetData.Results.map(a=>a?N.SafeJSONParse(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(t){const s=`GraphQLSystemUserClient::GetData - Error getting geta - ${t}`;return c.LogError(s),{Success:!1,Results:[],ErrorMessages:[s],Queries:e}}}async GetAllRemoteEntities(){try{const r=await this.Client.request(`query GetAllEntities {
227
227
  GetAllEntities {
228
228
  Success
229
229
  ErrorMessage
@@ -246,7 +246,7 @@
246
246
  }
247
247
  }
248
248
  }
249
- }`);return t&&t.GetAllEntities?t.GetAllEntities:{Success:!1,Results:[],ErrorMessage:t.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return c.LogError(`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!]!) {
249
+ }`);return r&&r.GetAllEntities?r.GetAllEntities:{Success:!1,Results:[],ErrorMessage:r.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return c.LogError(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const t=await this.Client.request(`mutation SyncData($items: [ActionItemInputType!]!) {
250
250
  SyncData(items: $items) {
251
251
  Success
252
252
  Results {
@@ -270,11 +270,11 @@
270
270
  RecordJSON
271
271
  }
272
272
  }
273
- }`,{items:e});return r&&r.SyncData?r.SyncData:{Success:!1,Results:[]}}catch(t){return c.LogError(`GraphQLSystemUserClient::SyncData - Error syncing data - ${t}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const r=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
273
+ }`,{items:e});return t&&t.SyncData?t.SyncData:{Success:!1,Results:[]}}catch(r){return c.LogError(`GraphQLSystemUserClient::SyncData - Error syncing data - ${r}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const t=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
274
274
  SyncRolesAndUsers(data: $data) {
275
275
  Success
276
276
  }
277
- }`,{data:e});return r&&r.SyncRolesAndUsers?r.SyncRolesAndUsers:{Success:!1}}catch(t){return c.LogError(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}async RunViewByNameSystemUser(e){try{const r=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
277
+ }`,{data:e});return t&&t.SyncRolesAndUsers?t.SyncRolesAndUsers:{Success:!1}}catch(r){return c.LogError(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${r}`),{Success:!1}}}async RunViewByName(e){try{const t=await this.Client.request(`query RunViewByNameSystemUser($input: RunViewByNameInput!) {
278
278
  RunViewByNameSystemUser(input: $input) {
279
279
  Results {
280
280
  ID
@@ -288,7 +288,7 @@
288
288
  ErrorMessage
289
289
  Success
290
290
  }
291
- }`,{input:e});return r&&r.RunViewByNameSystemUser?r.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(t){return c.LogError(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunViewByIDSystemUser(e){try{const r=await this.Client.request(`query RunViewByIDSystemUser($input: RunViewByIDInput!) {
291
+ }`,{input:e});return t&&t.RunViewByNameSystemUser?t.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(r){return c.LogError(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${r}`),{Results:[],Success:!1,ErrorMessage:r.toString()}}}async RunViewByID(e){try{const t=await this.Client.request(`query RunViewByIDSystemUser($input: RunViewByIDInput!) {
292
292
  RunViewByIDSystemUser(input: $input) {
293
293
  Results {
294
294
  ID
@@ -302,7 +302,7 @@
302
302
  ErrorMessage
303
303
  Success
304
304
  }
305
- }`,{input:e});return r&&r.RunViewByIDSystemUser?r.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(t){return c.LogError(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunDynamicViewSystemUser(e){try{const r=await this.Client.request(`query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {
305
+ }`,{input:e});return t&&t.RunViewByIDSystemUser?t.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(r){return c.LogError(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${r}`),{Results:[],Success:!1,ErrorMessage:r.toString()}}}async RunDynamicView(e){try{const t=await this.Client.request(`query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {
306
306
  RunDynamicViewSystemUser(input: $input) {
307
307
  Results {
308
308
  ID
@@ -316,7 +316,7 @@
316
316
  ErrorMessage
317
317
  Success
318
318
  }
319
- }`,{input:e});return r&&r.RunDynamicViewSystemUser?r.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(t){return c.LogError(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${t}`),{Results:[],Success:!1,ErrorMessage:t.toString()}}}async RunViewsSystemUser(e){try{const r=await this.Client.request(`query RunViewsSystemUser($input: [RunViewGenericInput!]!) {
319
+ }`,{input:e});return t&&t.RunDynamicViewSystemUser?t.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(r){return c.LogError(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${r}`),{Results:[],Success:!1,ErrorMessage:r.toString()}}}async RunViews(e){try{const t=await this.Client.request(`query RunViewsSystemUser($input: [RunViewGenericInput!]!) {
320
320
  RunViewsSystemUser(input: $input) {
321
321
  Results {
322
322
  ID
@@ -330,33 +330,43 @@
330
330
  ErrorMessage
331
331
  Success
332
332
  }
333
- }`,{input:e});return r&&r.RunViewsSystemUser?r.RunViewsSystemUser:[]}catch(t){return c.LogError(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${t}`),[]}}async GetQueryDataSystemUser(e,t,r){try{const a=await this.Client.request(`query GetQueryDataSystemUser($QueryID: String!, $CategoryID: String, $CategoryName: String) {
334
- GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryName: $CategoryName) {
333
+ }`,{input:e});return t&&t.RunViewsSystemUser?t.RunViewsSystemUser:[]}catch(r){return c.LogError(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${r}`),[]}}async GetQueryData(e){try{const r=`query GetQueryDataSystemUser($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
334
+ GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
335
335
  QueryID
336
336
  QueryName
337
337
  Success
338
338
  Results
339
339
  RowCount
340
+ TotalRowCount
340
341
  ExecutionTime
341
342
  ErrorMessage
343
+ AppliedParameters
342
344
  }
343
- }`,{QueryID:e,CategoryID:t,CategoryName:r});return a&&a.GetQueryDataSystemUser?{...a.GetQueryDataSystemUser,Results:a.GetQueryDataSystemUser.Results?N.SafeJSONParse(a.GetQueryDataSystemUser.Results):null}:{QueryID:e,QueryName:"",Success:!1,Results:null,RowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(s){return c.LogError(`GraphQLSystemUserClient::GetQueryDataSystemUser - Error executing query - ${s}`),{QueryID:e,QueryName:"",Success:!1,Results:null,RowCount:0,ExecutionTime:0,ErrorMessage:s.toString()}}}async GetQueryDataByNameSystemUser(e,t,r){try{const a=await this.Client.request(`query GetQueryDataByNameSystemUser($QueryName: String!, $CategoryID: String, $CategoryName: String) {
344
- GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryName: $CategoryName) {
345
+ }`,t={QueryID:e.QueryID};e.CategoryID!==void 0&&(t.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(t.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(t.Parameters=e.Parameters),e.MaxRows!==void 0&&(t.MaxRows=e.MaxRows),e.StartRow!==void 0&&(t.StartRow=e.StartRow);const s=await this.Client.request(r,t);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results?N.SafeJSONParse(s.GetQueryDataSystemUser.Results):null}:{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(r){return c.LogError(`GraphQLSystemUserClient::GetQueryDataSystemUser - Error executing query - ${r}`),{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:r.toString()}}}async GetQueryDataByName(e){try{const r=`query GetQueryDataByNameSystemUser($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
346
+ GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
345
347
  QueryID
346
348
  QueryName
347
349
  Success
348
350
  Results
349
351
  RowCount
352
+ TotalRowCount
350
353
  ExecutionTime
351
354
  ErrorMessage
355
+ AppliedParameters
356
+ }
357
+ }`,t={QueryName:e.QueryName};e.CategoryID!==void 0&&(t.CategoryID=e.CategoryID),e.CategoryPath!==void 0&&(t.CategoryPath=e.CategoryPath),e.Parameters!==void 0&&(t.Parameters=e.Parameters),e.MaxRows!==void 0&&(t.MaxRows=e.MaxRows),e.StartRow!==void 0&&(t.StartRow=e.StartRow);const s=await this.Client.request(r,t);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results?N.SafeJSONParse(s.GetQueryDataByNameSystemUser.Results):null}:{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(r){return c.LogError(`GraphQLSystemUserClient::GetQueryDataByNameSystemUser - Error executing query - ${r}`),{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:r.toString()}}}async CreateQuery(e){try{const t=await this.Client.request(`mutation CreateQuerySystemUser($input: CreateQuerySystemUserInput!) {
358
+ CreateQuerySystemUser(input: $input) {
359
+ Success
360
+ ErrorMessage
361
+ QueryData
352
362
  }
353
- }`,{QueryName:e,CategoryID:t,CategoryName:r});return a&&a.GetQueryDataByNameSystemUser?{...a.GetQueryDataByNameSystemUser,Results:a.GetQueryDataByNameSystemUser.Results?N.SafeJSONParse(a.GetQueryDataByNameSystemUser.Results):null}:{QueryID:"",QueryName:e,Success:!1,Results:null,RowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(s){return c.LogError(`GraphQLSystemUserClient::GetQueryDataByNameSystemUser - Error executing query - ${s}`),{QueryID:"",QueryName:e,Success:!1,Results:null,RowCount:0,ExecutionTime:0,ErrorMessage:s.toString()}}}async CreateQuery(e){try{const r=await this.Client.request(`mutation CreateQuery($input: CreateQueryInputType!) {
354
- CreateQuery(input: $input) {
363
+ }`,{input:e});return t&&t.CreateQuerySystemUser?t.CreateQuerySystemUser.Success&&t.CreateQuerySystemUser.QueryData?{...t.CreateQuerySystemUser,QueryData:t.CreateQuerySystemUser.QueryData}:t.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(r){return c.LogError(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${r}`),{Success:!1,ErrorMessage:r.toString()}}}async DeleteQuery(e,r){try{const t=`mutation DeleteQuerySystemResolver($ID: String!, $options: DeleteOptionsInput) {
364
+ DeleteQuerySystemResolver(ID: $ID, options: $options) {
355
365
  Success
356
366
  ErrorMessage
357
367
  QueryData
358
368
  }
359
- }`,{input:e});return r&&r.CreateQuery?r.CreateQuery.Success&&r.CreateQuery.QueryData?{...r.CreateQuery,QueryData:r.CreateQuery.QueryData}:r.CreateQuery:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return c.LogError(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}};S(te,"GraphQLSystemUserClient");let M=te;const re=class re{};S(re,"GetDataOutput");let q=re;const se=class se{};S(se,"SimpleRemoteEntityOutput");let A=se;const ae=class ae{};S(ae,"SimpleRemoteEntity");let _=ae;const ne=class ne{};S(ne,"SimpleRemoteEntityField");let B=ne;const ie=class ie{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=g.gql`
369
+ }`,s={ID:e};r!==void 0&&(s.options=r);const a=await this.Client.request(t,s);return a&&a.DeleteQuerySystemResolver?a.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(t){return c.LogError(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}};S(te,"GraphQLSystemUserClient");let M=te;const re=class re{};S(re,"GetDataOutput");let q=re;const se=class se{};S(se,"SimpleRemoteEntityOutput");let A=se;const ae=class ae{};S(ae,"SimpleRemoteEntity");let _=ae;const ne=class ne{};S(ne,"SimpleRemoteEntityField");let B=ne;const ie=class ie{constructor(e){this._dataProvider=e}async RunAction(e,r,t=!1){try{const s=this.serializeActionParameters(r),a=this.createActionVariables(e,s,t),o=await this.executeActionMutation(a);return this.processActionResult(o,r)}catch(s){return this.handleActionError(s,r)}}serializeActionParameters(e){if(e)return e.map(r=>{let t=r.Value;return t!=null&&typeof t=="object"&&(t=JSON.stringify(t)),{...r,Value:t}})}createActionVariables(e,r,t=!1){return{input:{ActionID:e,Params:r,SkipActionLog:t}}}async executeActionMutation(e){const r=R.gql`
360
370
  mutation RunAction($input: RunActionInput!) {
361
371
  RunAction(input: $input) {
362
372
  Success
@@ -365,7 +375,7 @@
365
375
  ResultData
366
376
  }
367
377
  }
368
- `;return await this._dataProvider.ExecuteGQL(t,e)}processActionResult(e,t){if(!e?.RunAction)throw new Error("Invalid response from server");let r;try{e.RunAction.ResultData&&(r=JSON.parse(e.RunAction.ResultData))}catch(s){c.LogError(`Failed to parse action result data: ${s}`)}return{Success:e.RunAction.Success,Message:e.RunAction.Message,Result:r,LogEntry:null,Params:t||[],RunParams:null}}handleActionError(e,t){const r=e;return c.LogError(`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=g.gql`
378
+ `;return await this._dataProvider.ExecuteGQL(r,e)}processActionResult(e,r){if(!e?.RunAction)throw new Error("Invalid response from server");let t;try{e.RunAction.ResultData&&(t=JSON.parse(e.RunAction.ResultData))}catch(s){c.LogError(`Failed to parse action result data: ${s}`)}return{Success:e.RunAction.Success,Message:e.RunAction.Message,Result:t,LogEntry:null,Params:r||[],RunParams:null}}handleActionError(e,r){const t=e;return c.LogError(`Error running action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,Result:null,LogEntry:null,Params:r||[],RunParams:null}}async RunEntityAction(e){try{const r=this.createEntityActionInput(e),t=await this.executeEntityActionMutation(r);return this.processEntityActionResult(t)}catch(r){return this.handleEntityActionError(r)}}createEntityActionInput(e){const r={EntityActionID:e.EntityAction.ID,InvocationType:e.InvocationType.Name,ListID:e.ListID,ViewID:e.ViewID};return e.Params&&(r.Params=this.convertActionParams(e.Params)),e.EntityObject&&this.addEntityInformation(r,e.EntityObject),r}convertActionParams(e){return e.map(r=>{let t=r.Value;return t!=null&&typeof t=="object"&&(t=JSON.stringify(t)),{Name:r.Name,Value:t,Type:r.Type}})}addEntityInformation(e,r){e.EntityName=r.EntityInfo?.Name,r.PrimaryKey&&(e.PrimaryKey=this.convertPrimaryKey(r.PrimaryKey))}convertPrimaryKey(e){return{KeyValuePairs:e.KeyValuePairs.map(r=>this.convertKeyValuePair(r))}}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 r=R.gql`
369
379
  mutation RunEntityAction($input: EntityActionInput!) {
370
380
  RunEntityAction(input: $input) {
371
381
  Success
@@ -373,5 +383,5 @@
373
383
  ResultData
374
384
  }
375
385
  }
376
- `;return await this._dataProvider.ExecuteGQL(t,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let t={};try{e.RunEntityAction.ResultData&&(t=JSON.parse(e.RunEntityAction.ResultData))}catch(r){c.LogError(`Failed to parse entity action result data: ${r}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return c.LogError(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};S(ie,"GraphQLActionClient");let O=ie;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return g.gql}}),exports.ActionItemInput=v,exports.ActionItemOutput=x,exports.FieldMapper=I,exports.GetDataOutput=q,exports.GraphQLActionClient=O,exports.GraphQLDataProvider=V,exports.GraphQLProviderConfigData=G,exports.GraphQLSystemUserClient=M,exports.GraphQLTransactionGroup=C,exports.RoleInput=F,exports.RolesAndUsersInput=L,exports.SimpleRemoteEntity=_,exports.SimpleRemoteEntityField=B,exports.SimpleRemoteEntityOutput=A,exports.SyncDataAction=ce,exports.SyncDataResult=P,exports.SyncRolesAndUsersResult=Q,exports.UserInput=U,exports.setupGraphQLClient=ge;
386
+ `;return await this._dataProvider.ExecuteGQL(r,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let r={};try{e.RunEntityAction.ResultData&&(r=JSON.parse(e.RunEntityAction.ResultData))}catch(t){c.LogError(`Failed to parse entity action result data: ${t}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...r}}handleEntityActionError(e){const r=e;return c.LogError(`Error running entity action: ${r}`),{Success:!1,Message:`Error: ${r.message}`,RunParams:null,LogEntry:null}}};S(ie,"GraphQLActionClient");let O=ie;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return R.gql}}),exports.ActionItemInput=F,exports.ActionItemOutput=L,exports.FieldMapper=I,exports.GetDataOutput=q,exports.GraphQLActionClient=O,exports.GraphQLDataProvider=V,exports.GraphQLProviderConfigData=$,exports.GraphQLSystemUserClient=M,exports.GraphQLTransactionGroup=C,exports.RoleInput=T,exports.RolesAndUsersInput=U,exports.SimpleRemoteEntity=_,exports.SimpleRemoteEntityField=B,exports.SimpleRemoteEntityOutput=A,exports.SyncDataAction=ce,exports.SyncDataResult=x,exports.SyncRolesAndUsersResult=Q,exports.UserInput=v,exports.setupGraphQLClient=Re;
377
387
  //# sourceMappingURL=index.cjs.map