@memberjunction/graphql-dataprovider 2.30.0 → 2.32.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.d.cts CHANGED
@@ -168,6 +168,18 @@ declare class GraphQLDataProvider extends ProviderBase implements IEntityDataPro
168
168
  SetRecordFavoriteStatus(userId: string, entityName: string, primaryKey: CompositeKey, isFavorite: boolean, contextUser: UserInfo): Promise<void>;
169
169
  GetEntityRecordName(entityName: string, primaryKey: CompositeKey): Promise<string>;
170
170
  GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
171
+ /**
172
+ * Retrieves all of the data context data for the specified data context ID.
173
+ * @param dataContextID
174
+ * @returns
175
+ */
176
+ GetDataContextData(dataContextID: string): Promise<any>;
177
+ /**
178
+ * Retrieves the data context item data for the specified data context item ID.
179
+ * @param dataContextItemID
180
+ * @returns
181
+ */
182
+ GetDataContextItemData(dataContextItemID: string): Promise<any>;
171
183
  /**
172
184
  * Static version of the ExecuteGQL method that will use the global instance of the GraphQLDataProvider and execute the specified query with the provided variables.
173
185
  * If the token is expired, it will attempt to refresh the token and then re-execute the query. If the token is expired and the refresh fails, it will throw an error.
package/dist/index.d.mts CHANGED
@@ -168,6 +168,18 @@ declare class GraphQLDataProvider extends ProviderBase implements IEntityDataPro
168
168
  SetRecordFavoriteStatus(userId: string, entityName: string, primaryKey: CompositeKey, isFavorite: boolean, contextUser: UserInfo): Promise<void>;
169
169
  GetEntityRecordName(entityName: string, primaryKey: CompositeKey): Promise<string>;
170
170
  GetEntityRecordNames(info: EntityRecordNameInput[]): Promise<EntityRecordNameResult[]>;
171
+ /**
172
+ * Retrieves all of the data context data for the specified data context ID.
173
+ * @param dataContextID
174
+ * @returns
175
+ */
176
+ GetDataContextData(dataContextID: string): Promise<any>;
177
+ /**
178
+ * Retrieves the data context item data for the specified data context item ID.
179
+ * @param dataContextItemID
180
+ * @returns
181
+ */
182
+ GetDataContextItemData(dataContextItemID: string): Promise<any>;
171
183
  /**
172
184
  * Static version of the ExecuteGQL method that will use the global instance of the GraphQLDataProvider and execute the specified query with the provided variables.
173
185
  * If the token is expired, it will attempt to refresh the token and then re-execute the query. If the token is expired and the refresh fails, it will throw an error.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0});import{gql as p,GraphQLClient as ie}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as me,TransactionResult as fe,ProviderConfigDataBase as pe,ProviderBase as he,LogError as N,UserInfo as ne,ProviderType as De,BaseEntityResult as oe,EntityFieldTSType as g,TransactionItem as ue,UserRoleInfo as Ne,SetProvider as we}from"@memberjunction/core";import{ViewInfo as le}from"@memberjunction/core-entities";import{openDB as Re}from"@tempfix/idb";import{Observable as ge}from"rxjs";import{createClient as Ee}from"graphql-ws";import{v4 as Se}from"uuid";import{SafeJSONParse as ce,MJGlobal as Ie,MJEventType as Ce}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 a in e)a in this._fieldMap&&(e[this._fieldMap[a]]=e[a],delete e[a]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([a,s])=>s===e)?.[0]??e}ReverseMapFields(e){const a=Object.fromEntries(Object.entries(this._fieldMap).map(([s,t])=>[t,s]));for(const s in e)s in a&&(e[a[s]]=e[s],delete e[s]);return e}};h(k,"FieldMapper");let I=k;const O=class O extends me{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=p`
1
+ var de=Object.defineProperty;var p=(R,e)=>de(R,"name",{value:e,configurable:!0});import{gql as m,GraphQLClient as ne}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as me,TransactionResult as De,ProviderConfigDataBase as fe,ProviderBase as pe,LogError as h,UserInfo as ie,ProviderType as he,BaseEntityResult as oe,EntityFieldTSType as g,TransactionItem as ue,UserRoleInfo as we,SetProvider as Ne}from"@memberjunction/core";import{ViewInfo as le}from"@memberjunction/core-entities";import{openDB as Re}from"@tempfix/idb";import{Observable as ge}from"rxjs";import{createClient as Ee}from"graphql-ws";import{v4 as Se}from"uuid";import{SafeJSONParse as ce,MJGlobal as Ie,MJEventType as Ce}from"@memberjunction/global";const q=class q{constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const a in e)a in this._fieldMap&&(e[this._fieldMap[a]]=e[a],delete e[a]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([a,s])=>s===e)?.[0]??e}ReverseMapFields(e){const a=Object.fromEntries(Object.entries(this._fieldMap).map(([s,t])=>[t,s]));for(const s in e)s in a&&(e[a[s]]=e[s],delete e[s]);return e}};p(q,"FieldMapper");let I=q;const k=class k extends me{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,15 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
6
6
  ResultsJSON
7
7
  }
8
8
  }
9
- `,a=[];for(const r of this.PendingTransactions)a.push({EntityName:r.BaseEntity.EntityInfo.Name,EntityObjectJSON:await r.BaseEntity.GetDataObjectJSON(),OperationType:r.OperationType});const s={group:{Items:a,Variables:this.Variables.map(r=>({Name:r.Name,ItemIndex:this.MapVariableEntityObjectToPosition(r),FieldName:r.FieldName,Type:r.Type}))}},t=await this._provider.ExecuteGQL(e,s);if(t&&t.ExecuteTransactionGroup){const r=t.ExecuteTransactionGroup,o=[];for(let i=0;i<this.PendingTransactions.length;i++){const n=r.ResultsJSON[i],m=ce(n),f=this.PendingTransactions[i];o.push(new fe(f,m,m!==null))}return o}else throw new Error("Failed to execute transaction group")}};h(O,"GraphQLTransactionGroup");let C=O;const q=class q extends pe{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,a,s,t,r,o,i,n){super({Token:e,URL:a,WSURL:s,MJAPIKey:n,RefreshTokenFunction:t},r,o,i)}};h(q,"GraphQLProviderConfigData");let F=q;const w=class w extends he{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
9
+ `,a=[];for(const r of this.PendingTransactions)a.push({EntityName:r.BaseEntity.EntityInfo.Name,EntityObjectJSON:await r.BaseEntity.GetDataObjectJSON(),OperationType:r.OperationType});const s={group:{Items:a,Variables:this.Variables.map(r=>({Name:r.Name,ItemIndex:this.MapVariableEntityObjectToPosition(r),FieldName:r.FieldName,Type:r.Type}))}},t=await this._provider.ExecuteGQL(e,s);if(t&&t.ExecuteTransactionGroup){const r=t.ExecuteTransactionGroup,o=[];for(let n=0;n<this.PendingTransactions.length;n++){const i=r.ResultsJSON[n],D=ce(i),f=this.PendingTransactions[n];o.push(new De(f,D,D!==null))}return o}else throw new Error("Failed to execute transaction group")}};p(k,"GraphQLTransactionGroup");let C=k;const O=class O extends fe{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,a,s,t,r,o,n,i){super({Token:e,URL:a,WSURL:s,MJAPIKey:i,RefreshTokenFunction:t},r,o,n)}};p(O,"GraphQLProviderConfigData");let G=O;const N=class N extends pe{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
10
10
  ${this.userInfoString()}
11
11
  UserRoles_UserIDArray {
12
12
  ${this.userRoleInfoString()}
13
13
  }
14
14
  }
15
- `,this._currentUserQuery=p`query CurrentUserAndRoles {
15
+ `,this._currentUserQuery=m`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 Se()}get LocalStoragePrefix(){return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async Config(e,a){try{const s=this.GenerateUUID();return a?(this._sessionId=s,this._configData=e,this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey)):(w.Instance._sessionId===void 0&&(w.Instance._sessionId=s),w.Instance._configData=e,w.Instance._client||(w.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,w.Instance._sessionId,e.MJAPIKey))),super.Config(e)}catch(s){throw N(s),s}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const a=this.ConvertBackToMJFields(e.CurrentUser),s=a.UserRoles_UserIDArray.map(t=>this.ConvertBackToMJFields(t));return a.UserRoles_UserIDArray=s,new ne(this,{...a,UserRoles:s})}}async RunReport(e,a){const s=p`
17
+ }`,this._wsClient=null,this._pushStatusRequests=[],N._instance||(N._instance=this)}static get Instance(){return N._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 Se()}get LocalStoragePrefix(){return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async Config(e,a){try{const s=this.GenerateUUID();return a?(this._sessionId=s,this._configData=e,this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey)):(N.Instance._sessionId===void 0&&(N.Instance._sessionId=s),N.Instance._configData=e,N.Instance._client||(N.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,N.Instance._sessionId,e.MJAPIKey))),super.Config(e)}catch(s){throw h(s),s}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const a=this.ConvertBackToMJFields(e.CurrentUser),s=a.UserRoles_UserIDArray.map(t=>this.ConvertBackToMJFields(t));return a.UserRoles_UserIDArray=s,new ie(this,{...a,UserRoles:s})}}async RunReport(e,a){const s=m`
18
18
  query GetReportDataQuery ($ReportID: String!) {
19
19
  GetReportData(ReportID: $ReportID) {
20
20
  Success
@@ -23,26 +23,26 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
23
23
  ExecutionTime
24
24
  ErrorMessage
25
25
  }
26
- }`,t=await this.ExecuteGQL(s,{ReportID:e.ReportID});if(t&&t.GetReportData)return{ReportID:e.ReportID,Success:t.GetReportData.Success,Results:JSON.parse(t.GetReportData.Results),RowCount:t.GetReportData.RowCount,ExecutionTime:t.GetReportData.ExecutionTime,ErrorMessage:t.GetReportData.ErrorMessage}}async RunQuery(e,a){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryName,a);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryName,a);throw new Error("No QueryID or QueryName provided to RunQuery")}async RunQueryByID(e,a,s,t){const r=p`
26
+ }`,t=await this.ExecuteGQL(s,{ReportID:e.ReportID});if(t&&t.GetReportData)return{ReportID:e.ReportID,Success:t.GetReportData.Success,Results:JSON.parse(t.GetReportData.Results),RowCount:t.GetReportData.RowCount,ExecutionTime:t.GetReportData.ExecutionTime,ErrorMessage:t.GetReportData.ErrorMessage}}async RunQuery(e,a){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryName,a);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryName,a);throw new Error("No QueryID or QueryName provided to RunQuery")}async RunQueryByID(e,a,s,t){const r=m`
27
27
  query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryName: String) {
28
28
  GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryName: $CategoryName) {
29
29
  ${this.QueryReturnFieldList}
30
30
  }
31
31
  }
32
- `,o={QueryID:e};a!==void 0&&(o.CategoryID=a),s!==void 0&&(o.CategoryName=s);const i=await this.ExecuteGQL(r,o);if(i&&i.GetQueryData)return this.TransformQueryPayload(i.GetQueryData)}async RunQueryByName(e,a,s,t){const r=p`
32
+ `,o={QueryID:e};a!==void 0&&(o.CategoryID=a),s!==void 0&&(o.CategoryName=s);const n=await this.ExecuteGQL(r,o);if(n&&n.GetQueryData)return this.TransformQueryPayload(n.GetQueryData)}async RunQueryByName(e,a,s,t){const r=m`
33
33
  query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryName: String) {
34
34
  GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryName: $CategoryName) {
35
35
  ${this.QueryReturnFieldList}
36
36
  }
37
37
  }
38
- `,o={QueryName:e,CategoryID:a,CategoryName:s},i=await this.ExecuteGQL(r,o);if(i&&i.GetQueryDataByName)return this.TransformQueryPayload(i.GetQueryDataByName)}get QueryReturnFieldList(){return`
38
+ `,o={QueryName:e,CategoryID:a,CategoryName:s},n=await this.ExecuteGQL(r,o);if(n&&n.GetQueryDataByName)return this.TransformQueryPayload(n.GetQueryDataByName)}get QueryReturnFieldList(){return`
39
39
  Success
40
40
  QueryID
41
41
  QueryName
42
42
  Results
43
43
  RowCount
44
44
  ExecutionTime
45
- ErrorMessage`}TransformQueryPayload(e){try{return{QueryID:e.QueryID,QueryName:e.QueryName,Success:e.Success,Results:JSON.parse(e.Results),RowCount:e.RowCount,ExecutionTime:e.ExecutionTime,ErrorMessage:e.ErrorMessage}}catch(a){return N(`Error transforming query payload: ${a}`),null}}async RunView(e,a){try{let s="",t="";if(e){const r={};let o,i;if(e.ViewEntity)i=e.ViewEntity,o=i.Entity;else{const{entityName:u,v:l}=await this.getEntityNameAndUserView(e,a);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 m=!1;e.ViewID?(s=`Run${n.ClassName}ViewByID`,t="RunViewByIDInput",r.ViewID=e.ViewID):e.ViewName?(s=`Run${n.ClassName}ViewByName`,t="RunViewByNameInput",r.ViewName=e.ViewName):(m=!0,s=`Run${n.ClassName}DynamicView`,t="RunDynamicViewInput",r.EntityName=e.EntityName),r.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",r.OrderBy=e.OrderBy?e.OrderBy:"",r.UserSearchString=e.UserSearchString?e.UserSearchString:"",r.Fields=e.Fields,r.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,r.MaxRows=e.MaxRows?e.MaxRows:0,r.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,r.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(r.AuditLogDescription=e.AuditLogDescription),m||(r.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",r.ExcludeDataFromAllPriorViewRuns=e.ExcludeDataFromAllPriorViewRuns?e.ExcludeDataFromAllPriorViewRuns:!1,r.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",r.SaveViewResults=e.SaveViewResults?e.SaveViewResults:!1);const f=this.getViewRunTimeFieldList(n,i,e,m),d=p`
45
+ ErrorMessage`}TransformQueryPayload(e){try{return{QueryID:e.QueryID,QueryName:e.QueryName,Success:e.Success,Results:JSON.parse(e.Results),RowCount:e.RowCount,ExecutionTime:e.ExecutionTime,ErrorMessage:e.ErrorMessage}}catch(a){return h(`Error transforming query payload: ${a}`),null}}async RunView(e,a){try{let s="",t="";if(e){const r={};let o,n;if(e.ViewEntity)n=e.ViewEntity,o=n.Entity;else{const{entityName:u,v:l}=await this.getEntityNameAndUserView(e,a);n=l,o=u}const i=this.Entities.find(u=>u.Name===o);if(!i)throw new Error(`Entity ${o} not found in metadata`);let D=!1;e.ViewID?(s=`Run${i.ClassName}ViewByID`,t="RunViewByIDInput",r.ViewID=e.ViewID):e.ViewName?(s=`Run${i.ClassName}ViewByName`,t="RunViewByNameInput",r.ViewName=e.ViewName):(D=!0,s=`Run${i.ClassName}DynamicView`,t="RunDynamicViewInput",r.EntityName=e.EntityName),r.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",r.OrderBy=e.OrderBy?e.OrderBy:"",r.UserSearchString=e.UserSearchString?e.UserSearchString:"",r.Fields=e.Fields,r.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,r.MaxRows=e.MaxRows?e.MaxRows:0,r.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,r.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(r.AuditLogDescription=e.AuditLogDescription),D||(r.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",r.ExcludeDataFromAllPriorViewRuns=e.ExcludeDataFromAllPriorViewRuns?e.ExcludeDataFromAllPriorViewRuns:!1,r.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",r.SaveViewResults=e.SaveViewResults?e.SaveViewResults:!1);const f=this.getViewRunTimeFieldList(i,n,e,D),y=m`
46
46
  query RunViewQuery ($input: ${t}!) {
47
47
  ${s}(input: $input) {
48
48
  Results {
@@ -56,7 +56,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
56
56
  Success
57
57
  ErrorMessage
58
58
  }
59
- }`,c=await this.ExecuteGQL(d,{input:r});if(c&&c[s]){const u=c[s].Results;if(u&&u.length>0){const l=n.Fields.filter(y=>y.CodeName!==y.Name&&y.CodeName!==void 0);u.forEach(y=>{this.ConvertBackToMJFields(y),l.forEach(D=>{y[D.Name]=y[D.CodeName]})})}return c[s]}}else throw"No parameters passed to RunView";return null}catch(s){throw N(s),s}}async RunViews(e,a){try{let s=[],t=[],r=[];for(const n of e){let m="",f="";const d={};let c=null,u=null;if(n.ViewEntity)u=n.ViewEntity,c=u.Get("Entity");else{const{entityName:D,v:S}=await this.getEntityNameAndUserView(n,a);u=S,c=D}const l=this.Entities.find(D=>D.Name===c);if(!l)throw new Error(`Entity ${c} not found in metadata`);t.push(l);let y=!1;n.ViewID?(m=`Run${l.ClassName}ViewByID`,f="RunViewByIDInput",d.ViewID=n.ViewID):n.ViewName?(m=`Run${l.ClassName}ViewByName`,f="RunViewByNameInput",d.ViewName=n.ViewName):(y=!0,m=`Run${l.ClassName}DynamicView`,f="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,d.MaxRows=n.MaxRows||0,d.ForceAuditLog=n.ForceAuditLog||!1,d.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(d.AuditLogDescription=n.AuditLogDescription),y||(d.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",d.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,d.OverrideExcludeFilter=n.OverrideExcludeFilter||"",d.SaveViewResults=n.SaveViewResults||!1),s.push(d),r.push(...this.getViewRunTimeFieldList(l,u,n,y))}const o=p`
59
+ }`,c=await this.ExecuteGQL(y,{input:r});if(c&&c[s]){const u=c[s].Results;if(u&&u.length>0){const l=i.Fields.filter(d=>d.CodeName!==d.Name&&d.CodeName!==void 0);u.forEach(d=>{this.ConvertBackToMJFields(d),l.forEach(w=>{d[w.Name]=d[w.CodeName]})})}return c[s]}}else throw"No parameters passed to RunView";return null}catch(s){throw h(s),s}}async RunViews(e,a){try{let s=[],t=[],r=[];for(const i of e){let D="",f="";const y={};let c=null,u=null;if(i.ViewEntity)u=i.ViewEntity,c=u.Get("Entity");else{const{entityName:w,v:S}=await this.getEntityNameAndUserView(i,a);u=S,c=w}const l=this.Entities.find(w=>w.Name===c);if(!l)throw new Error(`Entity ${c} not found in metadata`);t.push(l);let d=!1;i.ViewID?(D=`Run${l.ClassName}ViewByID`,f="RunViewByIDInput",y.ViewID=i.ViewID):i.ViewName?(D=`Run${l.ClassName}ViewByName`,f="RunViewByNameInput",y.ViewName=i.ViewName):(d=!0,D=`Run${l.ClassName}DynamicView`,f="RunDynamicViewInput",y.EntityName=i.EntityName),y.ExtraFilter=i.ExtraFilter||"",y.OrderBy=i.OrderBy||"",y.UserSearchString=i.UserSearchString||"",y.Fields=i.Fields,y.IgnoreMaxRows=i.IgnoreMaxRows||!1,y.MaxRows=i.MaxRows||0,y.ForceAuditLog=i.ForceAuditLog||!1,y.ResultType=i.ResultType||"simple",i.AuditLogDescription&&i.AuditLogDescription.length>0&&(y.AuditLogDescription=i.AuditLogDescription),d||(y.ExcludeUserViewRunID=i.ExcludeUserViewRunID||"",y.ExcludeDataFromAllPriorViewRuns=i.ExcludeDataFromAllPriorViewRuns||!1,y.OverrideExcludeFilter=i.OverrideExcludeFilter||"",y.SaveViewResults=i.SaveViewResults||!1),s.push(y),r.push(...this.getViewRunTimeFieldList(l,u,i,d))}const o=m`
60
60
  query RunViewsQuery ($input: [RunViewGenericInput!]!) {
61
61
  RunViews(input: $input) {
62
62
  Results {
@@ -71,7 +71,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
71
71
  Success
72
72
  ErrorMessage
73
73
  }
74
- }`,i=await this.ExecuteGQL(o,{input:s});if(i&&i.RunViews){const n=i.RunViews;for(const[m,f]of n.entries())f.Results=f.Results.map(d=>{let c=JSON.parse(d.Data);return this.ConvertBackToMJFields(c),c});return n}return null}catch(s){throw N(s),s}}async getEntityNameAndUserView(e,a){let s,t;if(e.EntityName)s=e.EntityName;else if(e.ViewID)t=await le.GetViewEntity(e.ViewID,a),s=t.Entity;else if(e.ViewName)t=await le.GetViewEntityByName(e.ViewName,a),s=t.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:s,v:t}}getViewRunTimeFieldList(e,a,s,t){const r=[],o=new I;if(s.Fields){for(const i of e.PrimaryKeys)s.Fields.find(n=>n.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&r.push(i.Name);s.Fields.forEach(i=>{r.push(o.MapFieldName(i))})}else if(t)e.Fields.forEach(i=>{i.IsBinaryFieldType||r.push(o.MapFieldName(i.CodeName))});else{for(const i of e.PrimaryKeys)r.find(n=>n.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&r.push(i.Name);a.Columns.forEach(i=>{i.hidden===!1&&!r.find(n=>n.trim().toLowerCase()===i.EntityField?.Name.trim().toLowerCase())&&i.EntityField&&r.push(o.MapFieldName(i.EntityField.CodeName))})}return r}get ProviderType(){return De.Network}async GetRecordChanges(e,a){try{const s={EntityName:"Record Changes",ExtraFilter:`RecordID = '${a.Values()}' AND Entity = '${e}'`},t=await this.RunView(s);return t?t.Results.sort((r,o)=>r.ChangedAt>o.ChangedAt?-1:1):null}catch(s){throw N(s),s}}async GetRecordDependencies(e,a){try{const s=p`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
74
+ }`,n=await this.ExecuteGQL(o,{input:s});if(n&&n.RunViews){const i=n.RunViews;for(const[D,f]of i.entries())f.Results=f.Results.map(y=>{let c=JSON.parse(y.Data);return this.ConvertBackToMJFields(c),c});return i}return null}catch(s){throw h(s),s}}async getEntityNameAndUserView(e,a){let s,t;if(e.EntityName)s=e.EntityName;else if(e.ViewID)t=await le.GetViewEntity(e.ViewID,a),s=t.Entity;else if(e.ViewName)t=await le.GetViewEntityByName(e.ViewName,a),s=t.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:s,v:t}}getViewRunTimeFieldList(e,a,s,t){const r=[],o=new I;if(s.Fields){for(const n of e.PrimaryKeys)s.Fields.find(i=>i.trim().toLowerCase()===n.Name.toLowerCase())===void 0&&r.push(n.Name);s.Fields.forEach(n=>{r.push(o.MapFieldName(n))})}else if(t)e.Fields.forEach(n=>{n.IsBinaryFieldType||r.push(o.MapFieldName(n.CodeName))});else{for(const n of e.PrimaryKeys)r.find(i=>i.trim().toLowerCase()===n.Name.toLowerCase())===void 0&&r.push(n.Name);a.Columns.forEach(n=>{n.hidden===!1&&!r.find(i=>i.trim().toLowerCase()===n.EntityField?.Name.trim().toLowerCase())&&n.EntityField&&r.push(o.MapFieldName(n.EntityField.CodeName))})}return r}get ProviderType(){return he.Network}async GetRecordChanges(e,a){try{const s={EntityName:"Record Changes",ExtraFilter:`RecordID = '${a.Values()}' AND Entity = '${e}'`},t=await this.RunView(s);return t?t.Results.sort((r,o)=>r.ChangedAt>o.ChangedAt?-1:1):null}catch(s){throw h(s),s}}async GetRecordDependencies(e,a){try{const s=m`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
75
75
  GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
76
76
  EntityName
77
77
  RelatedEntityName
@@ -83,7 +83,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
83
83
  }
84
84
  }
85
85
  }
86
- }`,t={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(a.KeyValuePairs)}};return(await this.ExecuteGQL(s,t))?.GetRecordDependencies}catch(s){throw N(s),s}}ensureKeyValuePairValueIsString(e){return e.map(a=>({FieldName:a.FieldName,Value:a.Value.toString()}))}async GetRecordDuplicates(e,a){if(!e)return null;const s=p`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
86
+ }`,t={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(a.KeyValuePairs)}};return(await this.ExecuteGQL(s,t))?.GetRecordDependencies}catch(s){throw h(s),s}}ensureKeyValuePairValueIsString(e){return e.map(a=>({FieldName:a.FieldName,Value:a.Value.toString()}))}async GetRecordDuplicates(e,a){if(!e)return null;const s=m`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
87
87
  GetRecordDuplicates(params: $params) {
88
88
  Status
89
89
  ErrorMessage
@@ -105,7 +105,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
105
105
  }
106
106
  }
107
107
  }
108
- }`;let t={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(o=>o.Copy())};const r=await this.ExecuteGQL(s,{params:t});if(r&&r.GetRecordDuplicates)return r.GetRecordDuplicates}async MergeRecords(e){const a=this.Entities.find(s=>s.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!a||!a.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const s=p`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
108
+ }`;let t={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(o=>o.Copy())};const r=await this.ExecuteGQL(s,{params:t});if(r&&r.GetRecordDuplicates)return r.GetRecordDuplicates}async MergeRecords(e){const a=this.Entities.find(s=>s.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!a||!a.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const s=m`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
109
109
  MergeRecords(request: $request) {
110
110
  Success
111
111
  OverallStatus
@@ -122,32 +122,32 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
122
122
  Message
123
123
  }
124
124
  }
125
- }`,t={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(s,{request:t}))?.MergeRecords}catch(s){return N(s),{Success:!1,OverallStatus:s&&s.message?s.message:s,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,a,s){const t=new oe;try{e.RegisterTransactionPreprocessing();const r={input:{}},o=e.IsSaved?"Update":"Create";t.StartedAt=new Date,t.Type=e.IsSaved?"update":"create",t.OriginalValues=e.Fields.map(c=>({FieldName:c.CodeName,Value:c.Value})),e.ResultHistory.push(t);const i=`${o}${e.EntityInfo.ClassName}`,n=e.Fields.filter(c=>!c.ReadOnly||c.IsPrimaryKey&&e.IsSaved),m=new I,f=` ${i}(input: $input) {
126
- ${e.Fields.map(c=>m.MapFieldName(c.CodeName)).join(`
125
+ }`,t={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(s,{request:t}))?.MergeRecords}catch(s){return h(s),{Success:!1,OverallStatus:s&&s.message?s.message:s,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,a,s){const t=new oe;try{e.RegisterTransactionPreprocessing();const r={input:{}},o=e.IsSaved?"Update":"Create";t.StartedAt=new Date,t.Type=e.IsSaved?"update":"create",t.OriginalValues=e.Fields.map(c=>({FieldName:c.CodeName,Value:c.Value})),e.ResultHistory.push(t);const n=`${o}${e.EntityInfo.ClassName}`,i=e.Fields.filter(c=>!c.ReadOnly||c.IsPrimaryKey&&e.IsSaved),D=new I,f=` ${n}(input: $input) {
126
+ ${e.Fields.map(c=>D.MapFieldName(c.CodeName)).join(`
127
127
  `)}
128
- }`,d=p`mutation ${o}${e.EntityInfo.ClassName} ($input: ${i}Input!) {
128
+ }`,y=m`mutation ${o}${e.EntityInfo.ClassName} ($input: ${n}Input!) {
129
129
  ${f}
130
130
  }
131
- `;for(let c=0;c<n.length;c++){const u=n[c];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case g.Date:l=l.getTime();break;case g.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case g.Number:if(typeof l!="number"){const y=Number(l);isNaN(y)||(l=y)}break}l===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?l=u.EntityFieldInfo.DefaultValue:u.FieldType===g.Number||u.FieldType===g.Boolean?l=0:l=""),r.input[u.CodeName]=l}if(o.trim().toLowerCase()==="update"&&s.SkipOldValuesCheck===!1){const c=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===g.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===g.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})}),r.input.OldValues___=c}if(e.TransactionGroup){const c=[{varName:"input",inputType:i+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ue(e,t.Type==="create"?"Create":"Update",f,r,{mutationName:i,mutationInputTypes:c},(u,l)=>{t.EndedAt=new Date,l&&u?(t.Success=!0,t.NewValues=this.ConvertBackToMJFields(u)):(t.Success=!1,t.Message="Transaction failed")})),!0}else{const c=await this.ExecuteGQL(d,r);if(c&&c[o+e.EntityInfo.ClassName])return t.Success=!0,t.EndedAt=new Date,t.NewValues=this.ConvertBackToMJFields(c[o+e.EntityInfo.ClassName]),t.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(r){return t.Success=!1,t.EndedAt=new Date,t.Message=r.response?.errors?.length>0?r.response.errors[0].message:r.message,N(r),null}}async Load(e,a,s=null,t){try{const r={};let o="",i="";for(let c=0;c<a.KeyValuePairs.length;c++){const u=e.Fields.find(D=>D.Name.trim().toLowerCase()===a.KeyValuePairs[c].FieldName.trim().toLowerCase()).EntityFieldInfo,l=a.GetValueByIndex(c),y=u.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${u.CodeName}: ${y}!`,o.length>0&&(o+=", "),o+=`${u.CodeName}: $${u.CodeName}`,u.TSType===g.Number){if(isNaN(a.GetValueByIndex(c)))throw new Error(`Primary Key value ${l} (${u.Name}) is not a valid number`);r[u.CodeName]=parseInt(l)}else r[u.CodeName]=l}const n=s&&s.length>0?this.getRelatedEntityString(e.EntityInfo,s):"",m=new I,f=p`query Single${e.EntityInfo.ClassName}${n.length>0?"Full":""} (${i}) {
131
+ `;for(let c=0;c<i.length;c++){const u=i[c];let l=u.Value;if(l)switch(u.EntityFieldInfo.TSType){case g.Date:l=l.getTime();break;case g.Boolean:typeof l!="boolean"&&(l=parseInt(l)!==0);break;case g.Number:if(typeof l!="number"){const d=Number(l);isNaN(d)||(l=d)}break}l===null&&u.EntityFieldInfo.AllowsNull===!1&&(u.EntityFieldInfo.DefaultValue!==null?l=u.EntityFieldInfo.DefaultValue:u.FieldType===g.Number||u.FieldType===g.Boolean?l=0:l=""),r.input[u.CodeName]=l}if(o.trim().toLowerCase()==="update"&&s.SkipOldValuesCheck===!1){const c=[];e.Fields.forEach(u=>{let l=null;u.OldValue!==null&&u.OldValue!==void 0&&(u.EntityFieldInfo.TSType===g.Date?l=u.OldValue.getTime().toString():u.EntityFieldInfo.TSType===g.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})}),r.input.OldValues___=c}if(e.TransactionGroup){const c=[{varName:"input",inputType:n+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ue(e,t.Type==="create"?"Create":"Update",f,r,{mutationName:n,mutationInputTypes:c},(u,l)=>{t.EndedAt=new Date,l&&u?(t.Success=!0,t.NewValues=this.ConvertBackToMJFields(u)):(t.Success=!1,t.Message="Transaction failed")})),!0}else{const c=await this.ExecuteGQL(y,r);if(c&&c[o+e.EntityInfo.ClassName])return t.Success=!0,t.EndedAt=new Date,t.NewValues=this.ConvertBackToMJFields(c[o+e.EntityInfo.ClassName]),t.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(r){return t.Success=!1,t.EndedAt=new Date,t.Message=r.response?.errors?.length>0?r.response.errors[0].message:r.message,h(r),null}}async Load(e,a,s=null,t){try{const r={};let o="",n="";for(let c=0;c<a.KeyValuePairs.length;c++){const u=e.Fields.find(w=>w.Name.trim().toLowerCase()===a.KeyValuePairs[c].FieldName.trim().toLowerCase()).EntityFieldInfo,l=a.GetValueByIndex(c),d=u.GraphQLType;if(n.length>0&&(n+=", "),n+=`$${u.CodeName}: ${d}!`,o.length>0&&(o+=", "),o+=`${u.CodeName}: $${u.CodeName}`,u.TSType===g.Number){if(isNaN(a.GetValueByIndex(c)))throw new Error(`Primary Key value ${l} (${u.Name}) is not a valid number`);r[u.CodeName]=parseInt(l)}else r[u.CodeName]=l}const i=s&&s.length>0?this.getRelatedEntityString(e.EntityInfo,s):"",D=new I,f=m`query Single${e.EntityInfo.ClassName}${i.length>0?"Full":""} (${n}) {
132
132
  ${e.EntityInfo.ClassName}(${o}) {
133
133
  ${e.Fields.filter(c=>!c.EntityFieldInfo.IsBinaryFieldType).map(c=>c.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?c.CodeName.replace("__mj_","_mj__"):c.CodeName).join(`
134
134
  `)}
135
- ${n}
135
+ ${i}
136
136
  }
137
137
  }
138
- `,d=await this.ExecuteGQL(f,r);return d&&d[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(d[e.EntityInfo.ClassName]):null}catch(r){return N(r),null}}ConvertBackToMJFields(e){return new I().ReverseMapFields(e),e}getRelatedEntityString(e,a){let s="";for(let t=0;t<e.RelatedEntities.length;t++)if(a.indexOf(e.RelatedEntities[t].RelatedEntity)>=0){const r=e.RelatedEntities[t],o=this.Entities.find(n=>n.ID===r.RelatedEntityID);let i="";r.Type.toLowerCase().trim()==="many to many"?i=`${r.RelatedEntityCodeName}_${r.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${r.RelatedEntityCodeName}_${r.RelatedEntityJoinField.replace(/\s/g,"")}`,s+=`
139
- ${i} {
140
- ${o.Fields.map(n=>n.CodeName).join(`
138
+ `,y=await this.ExecuteGQL(f,r);return y&&y[e.EntityInfo.ClassName]?this.ConvertBackToMJFields(y[e.EntityInfo.ClassName]):null}catch(r){return h(r),null}}ConvertBackToMJFields(e){return new I().ReverseMapFields(e),e}getRelatedEntityString(e,a){let s="";for(let t=0;t<e.RelatedEntities.length;t++)if(a.indexOf(e.RelatedEntities[t].RelatedEntity)>=0){const r=e.RelatedEntities[t],o=this.Entities.find(i=>i.ID===r.RelatedEntityID);let n="";r.Type.toLowerCase().trim()==="many to many"?n=`${r.RelatedEntityCodeName}_${r.JoinEntityJoinField.replace(/\s/g,"")}`:n=`${r.RelatedEntityCodeName}_${r.RelatedEntityJoinField.replace(/\s/g,"")}`,s+=`
139
+ ${n} {
140
+ ${o.Fields.map(i=>i.CodeName).join(`
141
141
  `)}
142
142
  }
143
- `}return s}async Delete(e,a,s){const t=new oe;try{e.RegisterTransactionPreprocessing(),t.StartedAt=new Date,t.Type="delete",t.OriginalValues=e.Fields.map(u=>({FieldName:u.CodeName,Value:u.Value})),e.ResultHistory.push(t);const r={},o=[];let i="",n="",m="";for(let u of e.PrimaryKey.KeyValuePairs){const l=e.Fields.find(y=>y.Name.trim().toLowerCase()===u.FieldName.trim().toLowerCase());r[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}!`,m.length>0&&(m+=`
144
- `),m+=`${l.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),r.options___=a||{SkipEntityAIActions:!1,SkipEntityActions:!1};const f="Delete"+e.EntityInfo.ClassName,d=p`${f}(${i}, options___: $options___) {
145
- ${m}
143
+ `}return s}async Delete(e,a,s){const t=new oe;try{e.RegisterTransactionPreprocessing(),t.StartedAt=new Date,t.Type="delete",t.OriginalValues=e.Fields.map(u=>({FieldName:u.CodeName,Value:u.Value})),e.ResultHistory.push(t);const r={},o=[];let n="",i="",D="";for(let u of e.PrimaryKey.KeyValuePairs){const l=e.Fields.find(d=>d.Name.trim().toLowerCase()===u.FieldName.trim().toLowerCase());r[l.CodeName]=l.Value,o.push({varName:l.CodeName,inputType:l.EntityFieldInfo.GraphQLType+"!"}),n.length>0&&(n+=", "),n+=`${l.CodeName}: $${l.CodeName}`,i.length>0&&(i+=", "),i+=`$${l.CodeName}: ${l.EntityFieldInfo.GraphQLType}!`,D.length>0&&(D+=`
144
+ `),D+=`${l.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),r.options___=a||{SkipEntityAIActions:!1,SkipEntityActions:!1};const f="Delete"+e.EntityInfo.ClassName,y=m`${f}(${n}, options___: $options___) {
145
+ ${D}
146
146
  }
147
- `,c=p`mutation ${f} (${n}, $options___: DeleteOptionsInput!) {
148
- ${d}
147
+ `,c=m`mutation ${f} (${i}, $options___: DeleteOptionsInput!) {
148
+ ${y}
149
149
  }
150
- `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ue(e,"Delete",d,r,{mutationName:f,mutationInputTypes:o},(u,l)=>{if(t.EndedAt=new Date,l&&u){let y=!0;for(const D of e.PrimaryKey.KeyValuePairs)D.Value!==u[D.FieldName]&&(y=!1);y?t.Success=!0:(t.Success=!1,t.Message="Transaction failed to commit")}else t.Success=!1,t.Message="Transaction failed to commit"})),!0;{const u=await this.ExecuteGQL(c,r);if(u&&u[f]){const l=u[f];for(let y of e.PrimaryKey.KeyValuePairs){let D=l[y.FieldName],S=y.Value;if(typeof S=="number"&&(S=S.toString()),typeof D=="number"&&(D=D.toString()),S!==D)throw new Error(`Primary key value mismatch in server Delete response. Field: ${y.FieldName}, Original: ${S}, Returned: ${D}`)}return t.Success=!0,t.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(r){return t.EndedAt=new Date,t.Success=!1,t.Message=r.response?.errors?.length>0?r.response.errors[0].message:r.message,N(r),!1}}async GetDatasetByName(e,a){const s=p`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
150
+ `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new ue(e,"Delete",y,r,{mutationName:f,mutationInputTypes:o},(u,l)=>{if(t.EndedAt=new Date,l&&u){let d=!0;for(const w of e.PrimaryKey.KeyValuePairs)w.Value!==u[w.FieldName]&&(d=!1);d?t.Success=!0:(t.Success=!1,t.Message="Transaction failed to commit")}else t.Success=!1,t.Message="Transaction failed to commit"})),!0;{const u=await this.ExecuteGQL(c,r);if(u&&u[f]){const l=u[f];for(let d of e.PrimaryKey.KeyValuePairs){let w=l[d.FieldName],S=d.Value;if(typeof S=="number"&&(S=S.toString()),typeof w=="number"&&(w=w.toString()),S!==w)throw new Error(`Primary key value mismatch in server Delete response. Field: ${d.FieldName}, Original: ${S}, Returned: ${w}`)}return t.Success=!0,t.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(r){return t.EndedAt=new Date,t.Success=!1,t.Message=r.response?.errors?.length>0?r.response.errors[0].message:r.message,h(r),!1}}async GetDatasetByName(e,a){const s=m`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
151
151
  GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
152
152
  DatasetID
153
153
  DatasetName
@@ -156,7 +156,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
156
156
  LatestUpdateDate
157
157
  Results
158
158
  }
159
- }`,t=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:a});return t&&t.GetDatasetByName&&t.GetDatasetByName.Success?{DatasetID:t.GetDatasetByName.DatasetID,DatasetName:t.GetDatasetByName.DatasetName,Success:t.GetDatasetByName.Success,Status:t.GetDatasetByName.Status,LatestUpdateDate:new Date(t.GetDatasetByName.LatestUpdateDate),Results:JSON.parse(t.GetDatasetByName.Results)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,Results:null}}async GetDatasetStatusByName(e,a){const s=p`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
159
+ }`,t=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:a});return t&&t.GetDatasetByName&&t.GetDatasetByName.Success?{DatasetID:t.GetDatasetByName.DatasetID,DatasetName:t.GetDatasetByName.DatasetName,Success:t.GetDatasetByName.Success,Status:t.GetDatasetByName.Status,LatestUpdateDate:new Date(t.GetDatasetByName.LatestUpdateDate),Results:JSON.parse(t.GetDatasetByName.Results)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,Results:null}}async GetDatasetStatusByName(e,a){const s=m`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
160
160
  GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
161
161
  DatasetID
162
162
  DatasetName
@@ -165,22 +165,22 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
165
165
  LatestUpdateDate
166
166
  EntityUpdateDates
167
167
  }
168
- }`,t=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:a});return t&&t.GetDatasetStatusByName&&t.GetDatasetStatusByName.Success?{DatasetID:t.GetDatasetStatusByName.DatasetID,DatasetName:t.GetDatasetStatusByName.DatasetName,Success:t.GetDatasetStatusByName.Success,Status:t.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(t.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(t.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new C(this)}async GetRecordFavoriteStatus(e,a,s){if(!s.Validate().IsValid)return!1;const r=this.Entities.find(n=>n.Name===a);if(!r)throw new Error(`Entity ${a} not found in metadata`);const o=p`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
168
+ }`,t=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:a});return t&&t.GetDatasetStatusByName&&t.GetDatasetStatusByName.Success?{DatasetID:t.GetDatasetStatusByName.DatasetID,DatasetName:t.GetDatasetStatusByName.DatasetName,Success:t.GetDatasetStatusByName.Success,Status:t.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(t.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(t.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new C(this)}async GetRecordFavoriteStatus(e,a,s){if(!s.Validate().IsValid)return!1;const r=this.Entities.find(i=>i.Name===a);if(!r)throw new Error(`Entity ${a} not found in metadata`);const o=m`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
169
169
  GetRecordFavoriteStatus(params: $params) {
170
170
  Success
171
171
  IsFavorite
172
172
  }
173
- }`,i=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:r.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.KeyValuePairs)}}});if(i&&i.GetRecordFavoriteStatus&&i.GetRecordFavoriteStatus.Success)return i.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,a,s,t,r){const o=this.Entities.find(m=>m.Name===a);if(!o)throw new Error(`Entity ${a} not found in metadata`);const i=p`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
173
+ }`,n=await this.ExecuteGQL(o,{params:{UserID:e,EntityID:r.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.KeyValuePairs)}}});if(n&&n.GetRecordFavoriteStatus&&n.GetRecordFavoriteStatus.Success)return n.GetRecordFavoriteStatus.IsFavorite}async SetRecordFavoriteStatus(e,a,s,t,r){const o=this.Entities.find(D=>D.Name===a);if(!o)throw new Error(`Entity ${a} not found in metadata`);const n=m`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
174
174
  SetRecordFavoriteStatus(params: $params){
175
175
  Success
176
176
  }
177
- }`,n=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.KeyValuePairs)},IsFavorite:t}});if(n&&n.SetRecordFavoriteStatus!==null)return n.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,a){if(!e||!a||a.KeyValuePairs?.length===0)return null;const s=p`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
177
+ }`,i=await this.ExecuteGQL(n,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(s.KeyValuePairs)},IsFavorite:t}});if(i&&i.SetRecordFavoriteStatus!==null)return i.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,a){if(!e||!a||a.KeyValuePairs?.length===0)return null;const s=m`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
178
178
  GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
179
179
  Success
180
180
  Status
181
181
  RecordName
182
182
  }
183
- }`,t=await this.ExecuteGQL(s,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(a.KeyValuePairs)}});if(t&&t.GetEntityRecordName&&t.GetEntityRecordName.Success)return t.GetEntityRecordName.RecordName}async GetEntityRecordNames(e){if(!e)return null;const a=p`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
183
+ }`,t=await this.ExecuteGQL(s,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(a.KeyValuePairs)}});if(t&&t.GetEntityRecordName&&t.GetEntityRecordName.Success)return t.GetEntityRecordName.RecordName}async GetEntityRecordNames(e){if(!e)return null;const a=m`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
184
184
  GetEntityRecordNames(info: $info) {
185
185
  Success
186
186
  Status
@@ -193,23 +193,35 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
193
193
  EntityName
194
194
  RecordName
195
195
  }
196
- }`,s=await this.ExecuteGQL(a,{info:e.map(t=>({EntityName:t.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.CompositeKey.KeyValuePairs)}}))});if(s&&s.GetEntityRecordNames)return s.GetEntityRecordNames}static async ExecuteGQL(e,a,s=!0){return w.Instance.ExecuteGQL(e,a,s)}async ExecuteGQL(e,a,s=!0){try{return await this._client.request(e,a)}catch(t){if(t&&t.response&&t.response.errors?.length>0)if(t.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(s)return await this.RefreshToken(),await this.ExecuteGQL(e,a,!1);throw N("JWT_EXPIRED and refreshTokenIfNeeded is false"),t}else throw t;else throw N(t),t}}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,a,s,t){const r={"x-session-id":s};return a&&(r.authorization="Bearer "+a),t&&(r["x-mj-api-key"]=t),new ie(e,{headers:r})}userInfoString(){return this.infoString(new ne(null,null))}userRoleInfoString(){return this.infoString(new Ne(null))}infoString(e){let a="";const s=Object.keys(e);for(const t of s)t.startsWith("__mj_")?a+=t.replace("__mj_","_mj__")+`
196
+ }`,s=await this.ExecuteGQL(a,{info:e.map(t=>({EntityName:t.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.CompositeKey.KeyValuePairs)}}))});if(s&&s.GetEntityRecordNames)return s.GetEntityRecordNames}async GetDataContextData(e){try{const a=m`query GetDataContextData ($DataContextID: String!) {
197
+ GetDataContextData(DataContextID: $DataContextID) {
198
+ Success
199
+ ErrorMessages
200
+ Results
201
+ }
202
+ }`,s=await this.ExecuteGQL(a,{DataContextID:e});if(s&&s.GetDataContextData){if(s.GetDataContextData.Success)return s.GetDataContextData.Results.map(t=>JSON.parse(t));throw new Error(s.GetDataContextData.ErrorMessages.join(", "))}else throw new Error("GraphQL query failed")}catch(a){throw h(a),a}}async GetDataContextItemData(e){try{const a=m`query GetDataContextItemData ($DataContextItemID: String!) {
203
+ GetDataContextItemData(DataContextItemID: $DataContextItemID) {
204
+ Success
205
+ ErrorMessage
206
+ Result
207
+ }
208
+ }`,s=await this.ExecuteGQL(a,{DataContextItemID:e});if(s&&s.GetDataContextItemData){if(s.GetDataContextItemData.Success)return JSON.parse(s.GetDataContextItemData.Result);throw new Error(s.GetDataContextItemData.ErrorMessage)}else throw new Error("GraphQL query failed")}catch(a){throw h(a),a}}static async ExecuteGQL(e,a,s=!0){return N.Instance.ExecuteGQL(e,a,s)}async ExecuteGQL(e,a,s=!0){try{return await this._client.request(e,a)}catch(t){if(t&&t.response&&t.response.errors?.length>0)if(t.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(s)return await this.RefreshToken(),await this.ExecuteGQL(e,a,!1);throw h("JWT_EXPIRED and refreshTokenIfNeeded is false"),t}else throw t;else throw h(t),t}}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 N.Instance.RefreshToken()}CreateNewGraphQLClient(e,a,s,t){const r={"x-session-id":s};return a&&(r.authorization="Bearer "+a),t&&(r["x-mj-api-key"]=t),new ne(e,{headers:r})}userInfoString(){return this.infoString(new ie(null,null))}userRoleInfoString(){return this.infoString(new we(null))}infoString(e){let a="";const s=Object.keys(e);for(const t of s)t.startsWith("__mj_")?a+=t.replace("__mj_","_mj__")+`
197
209
  `:t.startsWith("_")||(a+=t+`
198
- `);return a}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new $),this._localStorageProvider}get Metadata(){return this}PushStatusUpdates(e=null){e||(e=this.sessionId),this._wsClient||(this._wsClient=Ee({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}}));const a=this._pushStatusRequests.find(r=>r.sessionId===e);if(a)return a.observable;const s=p`subscription StatusUpdates($sessionId: String!) {
210
+ `);return a}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new $),this._localStorageProvider}get Metadata(){return this}PushStatusUpdates(e=null){e||(e=this.sessionId),this._wsClient||(this._wsClient=Ee({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}}));const a=this._pushStatusRequests.find(r=>r.sessionId===e);if(a)return a.observable;const s=m`subscription StatusUpdates($sessionId: String!) {
199
211
  statusUpdates(sessionId: $sessionId) {
200
212
  date
201
213
  message
202
214
  sessionId
203
215
  }
204
216
  }
205
- `,t=new ge(r=>(this._wsClient.subscribe({query:s,variables:{sessionId:e}},{next:o=>r.next(o.data.statusUpdates),error:o=>r.error(o),complete:()=>r.complete()}),()=>{console.log("would unsub here")}));return this._pushStatusRequests.push({sessionId:e,observable:t}),t}};h(w,"GraphQLDataProvider");let V=w;const b=class b{constructor(){this._localStorage={}}async getItem(e){return new Promise(a=>{this._localStorage.hasOwnProperty(e)?a(this._localStorage[e]):a(null)})}async setItem(e,a){return new Promise(s=>{this._localStorage[e]=a,s()})}async remove(e){return new Promise(a=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],a()})}};h(b,"BrowserStorageProviderBase");let G=b;const Ve="MJ_Metadata",E="Metadata_KVPairs",J=class J extends G{constructor(){super(),this.dbPromise=Re(Ve,1,{upgrade(e){e.objectStoreNames.contains(E)||e.createObjectStore(E)}})}async setItem(e,a){const t=(await this.dbPromise).transaction(E,"readwrite");await t.objectStore(E).put(a,e),await t.done}async getItem(e){return await(await this.dbPromise).transaction(E).objectStore(E).get(e)}async remove(e){const s=(await this.dbPromise).transaction(E,"readwrite");await s.objectStore(E).delete(e),await s.done}};h(J,"BrowserIndexedDBStorageProvider");let $=J;async function Fe(R){const e=new V;return we(e),await e.Config(R),Ie.Instance.RaiseEvent({event:Ce.LoggedIn,eventCode:null,component:this,args:null}),e}h(Fe,"setupGraphQLClient");const j=class j{};h(j,"SyncRolesAndUsersResult");let T=j;const W=class W{};h(W,"RoleInput");let v=W;const z=class z{};h(z,"UserInput");let L=z;const H=class H{};h(H,"RolesAndUsersInput");let _=H;var de=(R=>(R.Create="Create",R.Update="Update",R.CreateOrUpdate="CreateOrUpdate",R.Delete="Delete",R.DeleteWithFilter="DeleteWithFilter",R))(de||{});const X=class X{};h(X,"ActionItemInput");let P=X;const Z=class Z{constructor(){this.Results=[]}};h(Z,"SyncDataResult");let x=Z;const Y=class Y{};h(Y,"ActionItemOutput");let M=Y;const ee=class ee{get Client(){return this._client}constructor(e,a,s,t){const r={"x-session-id":s};a&&(r.authorization="Bearer "+a),t&&(r["x-mj-api-key"]=t),this._client=new ie(e,{headers:r})}async GetData(e,a){try{const t=await this.Client.request(`query GetData($input: GetDataInputType!) {
217
+ `,t=new ge(r=>(this._wsClient.subscribe({query:s,variables:{sessionId:e}},{next:o=>r.next(o.data.statusUpdates),error:o=>r.error(o),complete:()=>r.complete()}),()=>{console.log("would unsub here")}));return this._pushStatusRequests.push({sessionId:e,observable:t}),t}};p(N,"GraphQLDataProvider");let V=N;const b=class b{constructor(){this._localStorage={}}async getItem(e){return new Promise(a=>{this._localStorage.hasOwnProperty(e)?a(this._localStorage[e]):a(null)})}async setItem(e,a){return new Promise(s=>{this._localStorage[e]=a,s()})}async remove(e){return new Promise(a=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],a()})}};p(b,"BrowserStorageProviderBase");let F=b;const Ve="MJ_Metadata",E="Metadata_KVPairs",J=class J extends F{constructor(){super(),this.dbPromise=Re(Ve,1,{upgrade(e){e.objectStoreNames.contains(E)||e.createObjectStore(E)}})}async setItem(e,a){const t=(await this.dbPromise).transaction(E,"readwrite");await t.objectStore(E).put(a,e),await t.done}async getItem(e){return await(await this.dbPromise).transaction(E).objectStore(E).get(e)}async remove(e){const s=(await this.dbPromise).transaction(E,"readwrite");await s.objectStore(E).delete(e),await s.done}};p(J,"BrowserIndexedDBStorageProvider");let $=J;async function Ge(R){const e=new V;return Ne(e),await e.Config(R),Ie.Instance.RaiseEvent({event:Ce.LoggedIn,eventCode:null,component:this,args:null}),e}p(Ge,"setupGraphQLClient");const j=class j{};p(j,"SyncRolesAndUsersResult");let T=j;const W=class W{};p(W,"RoleInput");let x=W;const z=class z{};p(z,"UserInput");let L=z;const H=class H{};p(H,"RolesAndUsersInput");let v=H;var ye=(R=>(R.Create="Create",R.Update="Update",R.CreateOrUpdate="CreateOrUpdate",R.Delete="Delete",R.DeleteWithFilter="DeleteWithFilter",R))(ye||{});const X=class X{};p(X,"ActionItemInput");let _=X;const Z=class Z{constructor(){this.Results=[]}};p(Z,"SyncDataResult");let M=Z;const Y=class Y{};p(Y,"ActionItemOutput");let P=Y;const ee=class ee{get Client(){return this._client}constructor(e,a,s,t){const r={"x-session-id":s};a&&(r.authorization="Bearer "+a),t&&(r["x-mj-api-key"]=t),this._client=new ne(e,{headers:r})}async GetData(e,a){try{const t=await this.Client.request(`query GetData($input: GetDataInputType!) {
206
218
  GetData(input: $input) {
207
219
  Success
208
220
  ErrorMessages
209
221
  Queries
210
222
  Results
211
223
  }
212
- }`,{input:{Queries:e,Token:"nope"}});return t&&t.GetData?{Success:t.GetData.Success,Results:t.GetData.Results.map(r=>r?ce(r):null),ErrorMessages:t.GetData.ErrorMessages,Queries:t.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:t.GetData?.ErrorMessages??["Unknown error"],Queries:t.GetData?.Queries??e}}catch(s){const t=`GraphQLSystemUserClient::GetData - Error getting geta - ${s}`;return N(t),{Success:!1,Results:[],ErrorMessages:[t],Queries:e}}}async GetAllRemoteEntities(){try{const a=await this.Client.request(`query GetAllEntities {
224
+ }`,{input:{Queries:e,Token:"nope"}});return t&&t.GetData?{Success:t.GetData.Success,Results:t.GetData.Results.map(r=>r?ce(r):null),ErrorMessages:t.GetData.ErrorMessages,Queries:t.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:t.GetData?.ErrorMessages??["Unknown error"],Queries:t.GetData?.Queries??e}}catch(s){const t=`GraphQLSystemUserClient::GetData - Error getting geta - ${s}`;return h(t),{Success:!1,Results:[],ErrorMessages:[t],Queries:e}}}async GetAllRemoteEntities(){try{const a=await this.Client.request(`query GetAllEntities {
213
225
  GetAllEntities {
214
226
  Success
215
227
  ErrorMessage
@@ -232,7 +244,7 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
232
244
  }
233
245
  }
234
246
  }
235
- }`);return a&&a.GetAllEntities?a.GetAllEntities:{Success:!1,Results:[],ErrorMessage:a.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return N(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const s=await this.Client.request(`mutation SyncData($items: [ActionItemInputType!]!) {
247
+ }`);return a&&a.GetAllEntities?a.GetAllEntities:{Success:!1,Results:[],ErrorMessage:a.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return h(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const s=await this.Client.request(`mutation SyncData($items: [ActionItemInputType!]!) {
236
248
  SyncData(items: $items) {
237
249
  Success
238
250
  Results {
@@ -256,9 +268,9 @@ var ye=Object.defineProperty;var h=(R,e)=>ye(R,"name",{value:e,configurable:!0})
256
268
  RecordJSON
257
269
  }
258
270
  }
259
- }`,{items:e});return s&&s.SyncData?s.SyncData:{Success:!1,Results:[]}}catch(a){return N(`GraphQLSystemUserClient::SyncData - Error syncing data - ${a}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const s=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
271
+ }`,{items:e});return s&&s.SyncData?s.SyncData:{Success:!1,Results:[]}}catch(a){return h(`GraphQLSystemUserClient::SyncData - Error syncing data - ${a}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const s=await this.Client.request(`mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {
260
272
  SyncRolesAndUsers(data: $data) {
261
273
  Success
262
274
  }
263
- }`,{data:e});return s&&s.SyncRolesAndUsers?s.SyncRolesAndUsers:{Success:!1}}catch(a){return N(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${a}`),{Success:!1}}}};h(ee,"GraphQLSystemUserClient");let U=ee;const te=class te{};h(te,"GetDataOutput");let Q=te;const se=class se{};h(se,"SimpleRemoteEntityOutput");let B=se;const ae=class ae{};h(ae,"SimpleRemoteEntity");let A=ae;const re=class re{};h(re,"SimpleRemoteEntityField");let K=re;export{P as ActionItemInput,M as ActionItemOutput,I as FieldMapper,Q as GetDataOutput,V as GraphQLDataProvider,F as GraphQLProviderConfigData,U as GraphQLSystemUserClient,C as GraphQLTransactionGroup,v as RoleInput,_ as RolesAndUsersInput,A as SimpleRemoteEntity,K as SimpleRemoteEntityField,B as SimpleRemoteEntityOutput,de as SyncDataAction,x as SyncDataResult,T as SyncRolesAndUsersResult,L as UserInput,Be as gql,Fe as setupGraphQLClient};
275
+ }`,{data:e});return s&&s.SyncRolesAndUsers?s.SyncRolesAndUsers:{Success:!1}}catch(a){return h(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${a}`),{Success:!1}}}};p(ee,"GraphQLSystemUserClient");let Q=ee;const te=class te{};p(te,"GetDataOutput");let U=te;const se=class se{};p(se,"SimpleRemoteEntityOutput");let B=se;const ae=class ae{};p(ae,"SimpleRemoteEntity");let A=ae;const re=class re{};p(re,"SimpleRemoteEntityField");let K=re;export{_ as ActionItemInput,P as ActionItemOutput,I as FieldMapper,U as GetDataOutput,V as GraphQLDataProvider,G as GraphQLProviderConfigData,Q as GraphQLSystemUserClient,C as GraphQLTransactionGroup,x as RoleInput,v as RolesAndUsersInput,A as SimpleRemoteEntity,K as SimpleRemoteEntityField,B as SimpleRemoteEntityOutput,ye as SyncDataAction,M as SyncDataResult,T as SyncRolesAndUsersResult,L as UserInput,Be as gql,Ge as setupGraphQLClient};
264
276
  //# sourceMappingURL=index.mjs.map