@memberjunction/graphql-dataprovider 2.50.0 → 2.52.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 +41 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -232,6 +232,13 @@ declare class GraphQLDataProvider extends ProviderBase implements IEntityDataPro
|
|
|
232
232
|
protected get Metadata(): IMetadataProvider;
|
|
233
233
|
private _wsClient;
|
|
234
234
|
private _pushStatusRequests;
|
|
235
|
+
/**
|
|
236
|
+
* Generic subscription method for GraphQL subscriptions
|
|
237
|
+
* @param subscription The GraphQL subscription query
|
|
238
|
+
* @param variables Variables to pass to the subscription
|
|
239
|
+
* @returns Observable that emits subscription data
|
|
240
|
+
*/
|
|
241
|
+
subscribe(subscription: string, variables?: any): Observable<any>;
|
|
235
242
|
PushStatusUpdates(sessionId?: string): Observable<string>;
|
|
236
243
|
}
|
|
237
244
|
|
package/dist/index.d.mts
CHANGED
|
@@ -232,6 +232,13 @@ declare class GraphQLDataProvider extends ProviderBase implements IEntityDataPro
|
|
|
232
232
|
protected get Metadata(): IMetadataProvider;
|
|
233
233
|
private _wsClient;
|
|
234
234
|
private _pushStatusRequests;
|
|
235
|
+
/**
|
|
236
|
+
* Generic subscription method for GraphQL subscriptions
|
|
237
|
+
* @param subscription The GraphQL subscription query
|
|
238
|
+
* @param variables Variables to pass to the subscription
|
|
239
|
+
* @returns Observable that emits subscription data
|
|
240
|
+
*/
|
|
241
|
+
subscribe(subscription: string, variables?: any): Observable<any>;
|
|
235
242
|
PushStatusUpdates(sessionId?: string): Observable<string>;
|
|
236
243
|
}
|
|
237
244
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var he=Object.defineProperty;var p=(w,e)=>he(w,"name",{value:e,configurable:!0});import{gql as m,GraphQLClient as oe}from"graphql-request";import{gql as Be}from"graphql-request";import{TransactionGroupBase as pe,TransactionResult as Ee,ProviderConfigDataBase as Re,ProviderBase as we,LogError as D,UserInfo as ue,ProviderType as ge,BaseEntityResult as le,EntityFieldTSType as g,TransactionItem as ce,UserRoleInfo as Ne,SetProvider as Se}from"@memberjunction/core";import{ViewInfo as ye}from"@memberjunction/core-entities";import{openDB as Ie}from"@tempfix/idb";import{Observable as de}from"rxjs";import{createClient as me}from"graphql-ws";import{v4 as Ce}from"uuid";import{SafeJSONParse as De,MJGlobal as Ve,MJEventType as Ge}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 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,s])=>s===e)?.[0]??e}ReverseMapFields(e){const t=Object.fromEntries(Object.entries(this._fieldMap).map(([s,a])=>[a,s]));for(const s in e)s in t&&(e[t[s]]=e[s],delete e[s]);return e}};p(q,"FieldMapper");let I=q;const b=class b extends pe{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=m`
|
|
2
2
|
mutation ExecuteTransactionGroup($group: TransactionInputType!) {
|
|
3
3
|
ExecuteTransactionGroup(group: $group) {
|
|
4
4
|
Success
|
|
@@ -6,7 +6,7 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
6
6
|
ResultsJSON
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,t=[];for(const r of this.PendingTransactions)t.push({EntityName:r.BaseEntity.EntityInfo.Name,EntityObjectJSON:await r.BaseEntity.GetDataObjectJSON(),OperationType:r.OperationType});const s={group:{Items:t,Variables:this.Variables.map(r=>({Name:r.Name,ItemIndex:this.MapVariableEntityObjectToPosition(r),FieldName:r.FieldName,Type:r.Type}))}},a=await this._provider.ExecuteGQL(e,s);if(a&&a.ExecuteTransactionGroup){const r=a.ExecuteTransactionGroup,o=[];for(let n=0;n<this.PendingTransactions.length;n++){const i=r.ResultsJSON[n],f=
|
|
9
|
+
`,t=[];for(const r of this.PendingTransactions)t.push({EntityName:r.BaseEntity.EntityInfo.Name,EntityObjectJSON:await r.BaseEntity.GetDataObjectJSON(),OperationType:r.OperationType});const s={group:{Items:t,Variables:this.Variables.map(r=>({Name:r.Name,ItemIndex:this.MapVariableEntityObjectToPosition(r),FieldName:r.FieldName,Type:r.Type}))}},a=await this._provider.ExecuteGQL(e,s);if(a&&a.ExecuteTransactionGroup){const r=a.ExecuteTransactionGroup,o=[];for(let n=0;n<this.PendingTransactions.length;n++){const i=r.ResultsJSON[n],f=De(i),h=this.PendingTransactions[n];o.push(new Ee(h,f,f!==null))}return o}else throw new Error("Failed to execute transaction group")}};p(b,"GraphQLTransactionGroup");let C=b;const k=class k extends Re{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,s,a,r,o,n,i){super({Token:e,URL:t,WSURL:s,MJAPIKey:i,RefreshTokenFunction:a},r,o,n)}};p(k,"GraphQLProviderConfigData");let G=k;const R=class R extends we{constructor(){super(),this._innerCurrentUserQueryString=`CurrentUser {
|
|
10
10
|
${this.userInfoString()}
|
|
11
11
|
UserRoles_UserIDArray {
|
|
12
12
|
${this.userRoleInfoString()}
|
|
@@ -14,7 +14,7 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
14
14
|
}
|
|
15
15
|
`,this._currentUserQuery=m`query CurrentUserAndRoles {
|
|
16
16
|
${this._innerCurrentUserQueryString}
|
|
17
|
-
}`,this._wsClient=null,this._pushStatusRequests=[],R._instance||(R._instance=this)}static get Instance(){return R._instance}get ConfigData(){return this._configData}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return Ce()}get LocalStoragePrefix(){if(this._configData===void 0||this._configData.URL===void 0)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.
|
|
17
|
+
}`,this._wsClient=null,this._pushStatusRequests=[],R._instance||(R._instance=this)}static get Instance(){return R._instance}get ConfigData(){return this._configData}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return Ce()}get LocalStoragePrefix(){if(this._configData===void 0||this._configData.URL===void 0)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.GetItem(t)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const t=this.LocalStorageProvider;if(t){const s=this.LocalStoragePrefix+"sessionId";await t.SetItem(s,e)}}catch{}}async GetPreferredUUID(e){const t=await this.GetStoredSessionID();return e||!t?this.GenerateUUID():t}async Config(e,t,s){try{return t?(this._configData=e,this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey),await this.SaveStoredSessionID(this._sessionId)):(R.Instance._configData=e,R.Instance._sessionId===void 0&&(R.Instance._sessionId=await this.GetPreferredUUID(s)),R.Instance._client||(R.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,R.Instance._sessionId,e.MJAPIKey)),await R.Instance.SaveStoredSessionID(R.Instance._sessionId)),super.Config(e)}catch(a){throw D(a),a}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const t=this.ConvertBackToMJFields(e.CurrentUser),s=t.UserRoles_UserIDArray.map(a=>this.ConvertBackToMJFields(a));return t.UserRoles_UserIDArray=s,new ue(this,{...t,UserRoles:s})}}async RunReport(e,t){const s=m`
|
|
18
18
|
query GetReportDataQuery ($ReportID: String!) {
|
|
19
19
|
GetReportData(ReportID: $ReportID) {
|
|
20
20
|
Success
|
|
@@ -71,7 +71,7 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
71
71
|
Success
|
|
72
72
|
ErrorMessage
|
|
73
73
|
}
|
|
74
|
-
}`,n=await this.ExecuteGQL(o,{input:s});if(n&&n.RunViews){const i=n.RunViews;for(const[f,h]of i.entries())h.Results=h.Results.map(y=>{let c=JSON.parse(y.Data);return this.ConvertBackToMJFields(c),c});return i}return null}catch(s){throw D(s),s}}async getEntityNameAndUserView(e,t){let s,a;if(e.EntityName)s=e.EntityName;else if(e.ViewID)a=await ye.GetViewEntity(e.ViewID,t),s=a.Entity;else if(e.ViewName)a=await ye.GetViewEntityByName(e.ViewName,t),s=a.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:s,v:a}}getViewRunTimeFieldList(e,t,s,a){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(a)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);t.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
|
|
74
|
+
}`,n=await this.ExecuteGQL(o,{input:s});if(n&&n.RunViews){const i=n.RunViews;for(const[f,h]of i.entries())h.Results=h.Results.map(y=>{let c=JSON.parse(y.Data);return this.ConvertBackToMJFields(c),c});return i}return null}catch(s){throw D(s),s}}async getEntityNameAndUserView(e,t){let s,a;if(e.EntityName)s=e.EntityName;else if(e.ViewID)a=await ye.GetViewEntity(e.ViewID,t),s=a.Entity;else if(e.ViewName)a=await ye.GetViewEntityByName(e.ViewName,t),s=a.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:s,v:a}}getViewRunTimeFieldList(e,t,s,a){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(a)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);t.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 ge.Network}async GetRecordChanges(e,t){try{const s={EntityName:"Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},a=await this.RunView(s);return a?a.Results.sort((r,o)=>r.ChangedAt>o.ChangedAt?-1:1):null}catch(s){throw D(s),s}}async GetRecordDependencies(e,t){try{const s=m`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
75
75
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
76
76
|
EntityName
|
|
77
77
|
RelatedEntityName
|
|
@@ -205,23 +205,23 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
205
205
|
ErrorMessage
|
|
206
206
|
Result
|
|
207
207
|
}
|
|
208
|
-
}`,s=await this.ExecuteGQL(t,{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(t){throw D(t),t}}static async ExecuteGQL(e,t,s=!0){return R.Instance.ExecuteGQL(e,t,s)}async ExecuteGQL(e,t,s=!0){try{return await this._client.request(e,t)}catch(a){if(a&&a.response&&a.response.errors?.length>0)if(a.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(s)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw D("JWT_EXPIRED and refreshTokenIfNeeded is false"),a}else throw a;else throw D(a),a}}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 R.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,s,a){const r={"x-session-id":s};return t&&(r.authorization="Bearer "+t),a&&(r["x-mj-api-key"]=a),new oe(e,{headers:r})}userInfoString(){return this.infoString(new ue(null,null))}userRoleInfoString(){return this.infoString(new
|
|
208
|
+
}`,s=await this.ExecuteGQL(t,{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(t){throw D(t),t}}static async ExecuteGQL(e,t,s=!0){return R.Instance.ExecuteGQL(e,t,s)}async ExecuteGQL(e,t,s=!0){try{return await this._client.request(e,t)}catch(a){if(a&&a.response&&a.response.errors?.length>0)if(a.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(s)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw D("JWT_EXPIRED and refreshTokenIfNeeded is false"),a}else throw a;else throw D(a),a}}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 R.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,s,a){const r={"x-session-id":s};return t&&(r.authorization="Bearer "+t),a&&(r["x-mj-api-key"]=a),new oe(e,{headers:r})}userInfoString(){return this.infoString(new ue(null,null))}userRoleInfoString(){return this.infoString(new Ne(null))}infoString(e){let t="";const s=Object.keys(e);for(const a of s)a.startsWith("__mj_")?t+=a.replace("__mj_","_mj__")+`
|
|
209
209
|
`:a.startsWith("_")||(t+=a+`
|
|
210
|
-
`);return t}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=
|
|
210
|
+
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new $),this._localStorageProvider}get Metadata(){return this}subscribe(e,t){return this._wsClient||(this._wsClient=me({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}})),new de(s=>{const a=this._wsClient.subscribe({query:e,variables:t},{next:r=>{s.next(r.data)},error:r=>{s.error(r)},complete:()=>{s.complete()}});return()=>{a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId),this._wsClient||(this._wsClient=me({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token}}));const t=this._pushStatusRequests.find(r=>r.sessionId===e);if(t)return t.observable;const s=m`subscription StatusUpdates($sessionId: String!) {
|
|
211
211
|
statusUpdates(sessionId: $sessionId) {
|
|
212
212
|
date
|
|
213
213
|
message
|
|
214
214
|
sessionId
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
`,a=new
|
|
217
|
+
`,a=new de(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:a}),a}};p(R,"GraphQLDataProvider");let V=R;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(s=>{this._localStorage[e]=t,s()})}async Remove(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],t()})}};p(J,"BrowserStorageProviderBase");let F=J;const Fe="MJ_Metadata",N="Metadata_KVPairs",j=class j extends F{constructor(){super(),this.dbPromise=Ie(Fe,1,{upgrade(e){e.objectStoreNames.contains(N)||e.createObjectStore(N)}})}async setItem(e,t){const a=(await this.dbPromise).transaction(N,"readwrite");await a.objectStore(N).put(t,e),await a.done}async getItem(e){return await(await this.dbPromise).transaction(N).objectStore(N).get(e)}async remove(e){const s=(await this.dbPromise).transaction(N,"readwrite");await s.objectStore(N).delete(e),await s.done}};p(j,"BrowserIndexedDBStorageProvider");let $=j;async function $e(w){const e=new V;return Se(e),await e.Config(w),Ve.Instance.RaiseEvent({event:Ge.LoggedIn,eventCode:null,component:this,args:null}),e}p($e,"setupGraphQLClient");const W=class W{};p(W,"SyncRolesAndUsersResult");let T=W;const z=class z{};p(z,"RoleInput");let P=z;const H=class H{};p(H,"UserInput");let v=H;const X=class X{};p(X,"RolesAndUsersInput");let x=X;var fe=(w=>(w.Create="Create",w.Update="Update",w.CreateOrUpdate="CreateOrUpdate",w.Delete="Delete",w.DeleteWithFilter="DeleteWithFilter",w))(fe||{});const Z=class Z{};p(Z,"ActionItemInput");let L=Z;const Y=class Y{constructor(){this.Results=[]}};p(Y,"SyncDataResult");let A=Y;const ee=class ee{};p(ee,"ActionItemOutput");let M=ee;const te=class te{get Client(){return this._client}constructor(e,t,s,a){const r={"x-session-id":s};t&&(r.authorization="Bearer "+t),a&&(r["x-mj-api-key"]=a),this._client=new oe(e,{headers:r})}async GetData(e,t){try{const a=await this.Client.request(`query GetData($input: GetDataInputType!) {
|
|
218
218
|
GetData(input: $input) {
|
|
219
219
|
Success
|
|
220
220
|
ErrorMessages
|
|
221
221
|
Queries
|
|
222
222
|
Results
|
|
223
223
|
}
|
|
224
|
-
}`,{input:{Queries:e,Token:"nope"}});return a&&a.GetData?{Success:a.GetData.Success,Results:a.GetData.Results.map(r=>r?
|
|
224
|
+
}`,{input:{Queries:e,Token:"nope"}});return a&&a.GetData?{Success:a.GetData.Success,Results:a.GetData.Results.map(r=>r?De(r):null),ErrorMessages:a.GetData.ErrorMessages,Queries:a.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:a.GetData?.ErrorMessages??["Unknown error"],Queries:a.GetData?.Queries??e}}catch(s){const a=`GraphQLSystemUserClient::GetData - Error getting geta - ${s}`;return D(a),{Success:!1,Results:[],ErrorMessages:[a],Queries:e}}}async GetAllRemoteEntities(){try{const t=await this.Client.request(`query GetAllEntities {
|
|
225
225
|
GetAllEntities {
|
|
226
226
|
Success
|
|
227
227
|
ErrorMessage
|
|
@@ -272,7 +272,7 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
272
272
|
SyncRolesAndUsers(data: $data) {
|
|
273
273
|
Success
|
|
274
274
|
}
|
|
275
|
-
}`,{data:e});return s&&s.SyncRolesAndUsers?s.SyncRolesAndUsers:{Success:!1}}catch(t){return D(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}};p(te,"GraphQLSystemUserClient");let
|
|
275
|
+
}`,{data:e});return s&&s.SyncRolesAndUsers?s.SyncRolesAndUsers:{Success:!1}}catch(t){return D(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${t}`),{Success:!1}}}};p(te,"GraphQLSystemUserClient");let _=te;const se=class se{};p(se,"GetDataOutput");let U=se;const ae=class ae{};p(ae,"SimpleRemoteEntityOutput");let Q=ae;const re=class re{};p(re,"SimpleRemoteEntity");let K=re;const ne=class ne{};p(ne,"SimpleRemoteEntityField");let B=ne;const ie=class ie{constructor(e){this._dataProvider=e}async RunAction(e,t,s=!1){try{const a=this.serializeActionParameters(t),r=this.createActionVariables(e,a,s),o=await this.executeActionMutation(r);return this.processActionResult(o,t)}catch(a){return this.handleActionError(a,t)}}serializeActionParameters(e){if(e)return e.map(t=>{let s=t.Value;return s!=null&&typeof s=="object"&&(s=JSON.stringify(s)),{...t,Value:s}})}createActionVariables(e,t,s=!1){return{input:{ActionID:e,Params:t,SkipActionLog:s}}}async executeActionMutation(e){const t=m`
|
|
276
276
|
mutation RunAction($input: RunActionInput!) {
|
|
277
277
|
RunAction(input: $input) {
|
|
278
278
|
Success
|
|
@@ -289,5 +289,5 @@ var De=Object.defineProperty;var p=(w,e)=>De(w,"name",{value:e,configurable:!0})
|
|
|
289
289
|
ResultData
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
`;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(s){D(`Failed to parse entity action result data: ${s}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return D(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};p(ie,"GraphQLActionClient");let O=ie;export{L as ActionItemInput,
|
|
292
|
+
`;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(s){D(`Failed to parse entity action result data: ${s}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return D(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}};p(ie,"GraphQLActionClient");let O=ie;export{L as ActionItemInput,M as ActionItemOutput,I as FieldMapper,U as GetDataOutput,O as GraphQLActionClient,V as GraphQLDataProvider,G as GraphQLProviderConfigData,_ as GraphQLSystemUserClient,C as GraphQLTransactionGroup,P as RoleInput,x as RolesAndUsersInput,K as SimpleRemoteEntity,B as SimpleRemoteEntityField,Q as SimpleRemoteEntityOutput,fe as SyncDataAction,A as SyncDataResult,T as SyncRolesAndUsersResult,v as UserInput,Be as gql,$e as setupGraphQLClient};
|
|
293
293
|
//# sourceMappingURL=index.mjs.map
|