@memberjunction/graphql-dataprovider 3.0.0 → 3.1.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 Ie=Object.defineProperty;var f=(E,e)=>Ie(E,"name",{value:e,configurable:!0});var m=require("graphql-request"),c=require("@memberjunction/core"),pe=require("@memberjunction/core-entities"),v=require("rxjs"),Re=require("graphql-ws"),Ee=require("uuid"),w=require("@memberjunction/global"),De=require("@tempfix/idb");const W=class W{constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const t in e)t in this._fieldMap&&(e[this._fieldMap[t]]=e[t],delete e[t]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([t,r])=>r===e)?.[0]??e}ReverseMapFields(e){const t=Object.fromEntries(Object.entries(this._fieldMap).map(([r,s])=>[s,r]));for(const r in e)r in t&&(e[t[r]]=e[r],delete e[r]);return e}};f(W,"FieldMapper");let P=W;const z=class z extends c.TransactionGroupBase{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=m.gql`
1
+ "use strict";var Ie=Object.defineProperty;var f=(E,e)=>Ie(E,"name",{value:e,configurable:!0});var m=require("graphql-request"),c=require("@memberjunction/core"),pe=require("@memberjunction/core-entities"),P=require("rxjs"),Re=require("graphql-ws"),Ee=require("uuid"),w=require("@memberjunction/global"),De=require("@tempfix/idb");const W=class W{constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const t in e)t in this._fieldMap&&(e[this._fieldMap[t]]=e[t],delete e[t]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([t,r])=>r===e)?.[0]??e}ReverseMapFields(e){const t=Object.fromEntries(Object.entries(this._fieldMap).map(([r,s])=>[s,r]));for(const r in e)r in t&&(e[t[r]]=e[r],delete e[r]);return e}};f(W,"FieldMapper");let $=W;const z=class z extends c.TransactionGroupBase{constructor(e){super(),this._provider=e}async HandleSubmit(){const e=m.gql`
2
2
  mutation ExecuteTransactionGroup($group: TransactionInputType!) {
3
3
  ExecuteTransactionGroup(group: $group) {
4
4
  Success
@@ -179,7 +179,7 @@
179
179
  error
180
180
  }
181
181
  }
182
- `,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,s);if(!a?.EmbedText)throw new Error("Invalid response from server");const o=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?o.embeddings:o.embeddings[0],modelName:o.modelName,vectorDimensions:o.vectorDimensions,error:o.error}}catch(t){const r=t;return c.LogError(`Error generating embeddings: ${r}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}};f(H,"GraphQLAIClient");let N=H;const $="default",X=class X{constructor(){this._storage=new Map}getCategoryMap(e){const t=e||$;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){return this.getCategoryMap(t||$).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||$).set(e,t)}async Remove(e,t){this.getCategoryMap(t||$).delete(e)}async ClearCategory(e){const t=e||$;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||$);return t?Array.from(t.keys()):[]}};f(X,"BrowserStorageProviderBase");let b=X;const we="MJ_Metadata",$e=3,he=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],fe="Metadata_KVPairs",Y=class Y extends b{constructor(){super(),this._dbReady=!1,this.dbPromise=De.openDB(we,$e,{upgrade(e){try{e.objectStoreNames.contains(fe)&&e.deleteObjectStore(fe);for(const t of he)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(t){c.LogErrorEx({error:t,message:t?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{c.LogErrorEx({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return he.includes(t)}getStoreName(e){const t=e||$;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||$;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,a=this.getStoreName(r),o=this.getStoreKey(e,r),i=s.transaction(a,"readwrite");await i.objectStore(a).put(t,o),await i.done}catch(s){c.LogErrorEx({error:s,message:s?.message}),await super.SetItem(e,t,r)}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(a)??null}catch(r){return c.LogErrorEx({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t),o=r.transaction(s,"readwrite");await o.objectStore(s).delete(a),await o.done}catch(r){c.LogErrorEx({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||$,s=this.getStoreName(e);if(this.isKnownCategory(r)){const a=t.transaction(s,"readwrite");await a.objectStore(s).clear(),await a.done}else{const a=`[${r}]:`,o=t.transaction("mj:default","readwrite"),i=o.objectStore("mj:default"),n=await i.getAllKeys();for(const u of n)typeof u=="string"&&u.startsWith(a)&&await i.delete(u);await o.done}}catch(t){c.LogErrorEx({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||$,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(u=>String(u));const n=`[${r}]:`;return i.map(u=>String(u)).filter(u=>u.startsWith(n)).map(u=>u.slice(n.length))}catch(t){return c.LogErrorEx({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}};f(Y,"BrowserIndexedDBStorageProvider");let x=Y;const Z=class Z 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)}};f(Z,"GraphQLProviderConfigData");let T=Z;const h=class h extends c.ProviderBase{constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {
182
+ `,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,s);if(!a?.EmbedText)throw new Error("Invalid response from server");const o=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?o.embeddings:o.embeddings[0],modelName:o.modelName,vectorDimensions:o.vectorDimensions,error:o.error}}catch(t){const r=t;return c.LogError(`Error generating embeddings: ${r}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}};f(H,"GraphQLAIClient");let N=H;const v="default",X=class X{constructor(){this._storage=new Map}getCategoryMap(e){const t=e||v;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){return this.getCategoryMap(t||v).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||v).set(e,t)}async Remove(e,t){this.getCategoryMap(t||v).delete(e)}async ClearCategory(e){const t=e||v;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||v);return t?Array.from(t.keys()):[]}};f(X,"BrowserStorageProviderBase");let b=X;const we="MJ_Metadata",ve=3,he=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],fe="Metadata_KVPairs",Y=class Y extends b{constructor(){super(),this._dbReady=!1,this.dbPromise=De.openDB(we,ve,{upgrade(e){try{e.objectStoreNames.contains(fe)&&e.deleteObjectStore(fe);for(const t of he)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(t){c.LogErrorEx({error:t,message:t?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{c.LogErrorEx({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return he.includes(t)}getStoreName(e){const t=e||v;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||v;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,a=this.getStoreName(r),o=this.getStoreKey(e,r),i=s.transaction(a,"readwrite");await i.objectStore(a).put(t,o),await i.done}catch(s){c.LogErrorEx({error:s,message:s?.message}),await super.SetItem(e,t,r)}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(a)??null}catch(r){return c.LogErrorEx({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t),o=r.transaction(s,"readwrite");await o.objectStore(s).delete(a),await o.done}catch(r){c.LogErrorEx({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||v,s=this.getStoreName(e);if(this.isKnownCategory(r)){const a=t.transaction(s,"readwrite");await a.objectStore(s).clear(),await a.done}else{const a=`[${r}]:`,o=t.transaction("mj:default","readwrite"),i=o.objectStore("mj:default"),n=await i.getAllKeys();for(const u of n)typeof u=="string"&&u.startsWith(a)&&await i.delete(u);await o.done}}catch(t){c.LogErrorEx({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||v,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(u=>String(u));const n=`[${r}]:`;return i.map(u=>String(u)).filter(u=>u.startsWith(n)).map(u=>u.slice(n.length))}catch(t){return c.LogErrorEx({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}};f(Y,"BrowserIndexedDBStorageProvider");let x=Y;const Z=class Z 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)}};f(Z,"GraphQLProviderConfigData");let T=Z;const h=class h extends c.ProviderBase{constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {
183
183
  ${this.userInfoString()}
184
184
  UserRoles_UserIDArray {
185
185
  ${this.userRoleInfoString()}
@@ -239,11 +239,11 @@
239
239
  }
240
240
  }
241
241
  }
242
- `,o=(await this.ExecuteGQL(s,{input:r}))?.RunQueriesWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map(n=>{if((n.status==="stale"||n.status==="no_validation")&&n.Results){const u=JSON.parse(n.Results);return{queryIndex:n.queryIndex,queryId:n.queryId,status:n.status,results:u,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}}return{queryIndex:n.queryIndex,queryId:n.queryId,status:n.status,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c.LogError(`Error in RunQueriesWithCacheCheck: ${r}`),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async InternalRunView(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:l,v:d}=await this.getEntityNameAndUserView(e,t);i=d,o=l}const n=this.Entities.find(l=>l.Name===o);if(!n)throw new Error(`Entity ${o} not found in metadata`);let u=!1;const p=c.getGraphQLTypeNameBase(n);e.ViewID?(r=`Run${p}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(r=`Run${p}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(u=!0,r=`Run${p}DynamicView`,s="RunDynamicViewInput",a.EntityName=e.EntityName),a.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",a.OrderBy=e.OrderBy?e.OrderBy:"",a.UserSearchString=e.UserSearchString?e.UserSearchString:"",a.Fields=e.Fields,a.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,e.MaxRows!==void 0&&(a.MaxRows=e.MaxRows),e.StartRow!==void 0&&(a.StartRow=e.StartRow),a.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,a.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(a.AuditLogDescription=e.AuditLogDescription),u||(a.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",a.ExcludeDataFromAllPriorViewRuns=e.ExcludeDataFromAllPriorViewRuns?e.ExcludeDataFromAllPriorViewRuns:!1,a.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",a.SaveViewResults=e.SaveViewResults?e.SaveViewResults:!1);const g=this.getViewRunTimeFieldList(n,i,e,u),I=m.gql`
242
+ `,o=(await this.ExecuteGQL(s,{input:r}))?.RunQueriesWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map(n=>{if((n.status==="stale"||n.status==="no_validation")&&n.Results){const u=JSON.parse(n.Results);return{queryIndex:n.queryIndex,queryId:n.queryId,status:n.status,results:u,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}}return{queryIndex:n.queryIndex,queryId:n.queryId,status:n.status,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c.LogError(`Error in RunQueriesWithCacheCheck: ${r}`),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async InternalRunView(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:l,v:g}=await this.getEntityNameAndUserView(e,t);i=g,o=l}const n=this.Entities.find(l=>l.Name===o);if(!n)throw new Error(`Entity ${o} not found in metadata`);let u=!1;const p=c.getGraphQLTypeNameBase(n);e.ViewID?(r=`Run${p}ViewByID`,s="RunViewByIDInput",a.ViewID=e.ViewID):e.ViewName?(r=`Run${p}ViewByName`,s="RunViewByNameInput",a.ViewName=e.ViewName):(u=!0,r=`Run${p}DynamicView`,s="RunDynamicViewInput",a.EntityName=e.EntityName),a.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",a.OrderBy=e.OrderBy?e.OrderBy:"",a.UserSearchString=e.UserSearchString?e.UserSearchString:"",a.Fields=e.Fields,a.IgnoreMaxRows=e.IgnoreMaxRows?e.IgnoreMaxRows:!1,e.MaxRows!==void 0&&(a.MaxRows=e.MaxRows),e.StartRow!==void 0&&(a.StartRow=e.StartRow),a.ForceAuditLog=e.ForceAuditLog?e.ForceAuditLog:!1,a.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(a.AuditLogDescription=e.AuditLogDescription),u||(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 y=this.getViewRunTimeFieldList(n,i,e,u),S=m.gql`
243
243
  query RunViewQuery ($input: ${s}!) {
244
244
  ${r}(input: $input) {
245
245
  Results {
246
- ${g.join(`
246
+ ${y.join(`
247
247
  `)}
248
248
  }
249
249
  UserViewRunID
@@ -253,7 +253,7 @@
253
253
  Success
254
254
  ErrorMessage
255
255
  }
256
- }`,y=await this.ExecuteGQL(I,{input:a});if(y&&y[r]){const l=y[r].Results;if(l&&l.length>0){const R=n.Fields.filter(S=>S.CodeName!==S.Name&&S.CodeName!==void 0);l.forEach(S=>{this.ConvertBackToMJFields(S),R.forEach(D=>{S[D.Name]=S[D.CodeName]})})}return y[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw c.LogError(r),r}}async InternalRunViews(e,t){try{let r=[],s=[],a=[];for(const n of e){let u="",p="";const g={};let I=null,y=null;if(n.ViewEntity)y=n.ViewEntity,I=y.Get("Entity");else{const{entityName:S,v:D}=await this.getEntityNameAndUserView(n,t);y=D,I=S}const l=this.Entities.find(S=>S.Name===I);if(!l)throw new Error(`Entity ${I} not found in metadata`);s.push(l);let d=!1;const R=c.getGraphQLTypeNameBase(l);n.ViewID?(u=`Run${R}ViewByID`,p="RunViewByIDInput",g.ViewID=n.ViewID):n.ViewName?(u=`Run${R}ViewByName`,p="RunViewByNameInput",g.ViewName=n.ViewName):(d=!0,u=`Run${R}DynamicView`,p="RunDynamicViewInput",g.EntityName=n.EntityName),g.ExtraFilter=n.ExtraFilter||"",g.OrderBy=n.OrderBy||"",g.UserSearchString=n.UserSearchString||"",g.Fields=n.Fields,g.IgnoreMaxRows=n.IgnoreMaxRows||!1,n.MaxRows!==void 0&&(g.MaxRows=n.MaxRows),n.StartRow!==void 0&&(g.StartRow=n.StartRow),g.ForceAuditLog=n.ForceAuditLog||!1,g.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(g.AuditLogDescription=n.AuditLogDescription),d||(g.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",g.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,g.OverrideExcludeFilter=n.OverrideExcludeFilter||"",g.SaveViewResults=n.SaveViewResults||!1),r.push(g),a.push(...this.getViewRunTimeFieldList(l,y,n,d))}const o=m.gql`
256
+ }`,d=await this.ExecuteGQL(S,{input:a});if(d&&d[r]){const l=d[r].Results;if(l&&l.length>0){const R=n.Fields.filter(I=>I.CodeName!==I.Name&&I.CodeName!==void 0);l.forEach(I=>{this.ConvertBackToMJFields(I),R.forEach(D=>{I[D.Name]=I[D.CodeName]})})}return d[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw c.LogError(r),r}}async InternalRunViews(e,t){try{let r=[],s=[],a=[];for(const n of e){let u="",p="";const y={};let S=null,d=null;if(n.ViewEntity)d=n.ViewEntity,S=d.Get("Entity");else{const{entityName:I,v:D}=await this.getEntityNameAndUserView(n,t);d=D,S=I}const l=this.Entities.find(I=>I.Name===S);if(!l)throw new Error(`Entity ${S} not found in metadata`);s.push(l);let g=!1;const R=c.getGraphQLTypeNameBase(l);n.ViewID?(u=`Run${R}ViewByID`,p="RunViewByIDInput",y.ViewID=n.ViewID):n.ViewName?(u=`Run${R}ViewByName`,p="RunViewByNameInput",y.ViewName=n.ViewName):(g=!0,u=`Run${R}DynamicView`,p="RunDynamicViewInput",y.EntityName=n.EntityName),y.ExtraFilter=n.ExtraFilter||"",y.OrderBy=n.OrderBy||"",y.UserSearchString=n.UserSearchString||"",y.Fields=n.Fields,y.IgnoreMaxRows=n.IgnoreMaxRows||!1,n.MaxRows!==void 0&&(y.MaxRows=n.MaxRows),n.StartRow!==void 0&&(y.StartRow=n.StartRow),y.ForceAuditLog=n.ForceAuditLog||!1,y.ResultType=n.ResultType||"simple",n.AuditLogDescription&&n.AuditLogDescription.length>0&&(y.AuditLogDescription=n.AuditLogDescription),g||(y.ExcludeUserViewRunID=n.ExcludeUserViewRunID||"",y.ExcludeDataFromAllPriorViewRuns=n.ExcludeDataFromAllPriorViewRuns||!1,y.OverrideExcludeFilter=n.OverrideExcludeFilter||"",y.SaveViewResults=n.SaveViewResults||!1),r.push(y),a.push(...this.getViewRunTimeFieldList(l,d,n,g))}const o=m.gql`
257
257
  query RunViewsQuery ($input: [RunViewGenericInput!]!) {
258
258
  RunViews(input: $input) {
259
259
  Results {
@@ -271,7 +271,7 @@
271
271
  Success
272
272
  ErrorMessage
273
273
  }
274
- }`,i=await this.ExecuteGQL(o,{input:r});if(i&&i.RunViews){const n=i.RunViews;for(const[u,p]of n.entries())p.Results=p.Results.map(g=>{let I=JSON.parse(g.Data);return this.ConvertBackToMJFields(I),I});return n}return null}catch(r){throw c.LogError(r),r}}async RunViewsWithCacheCheck(e,t){try{const r=e.map(n=>({params:{EntityName:n.params.EntityName||"",ExtraFilter:n.params.ExtraFilter||"",OrderBy:n.params.OrderBy||"",Fields:n.params.Fields,UserSearchString:n.params.UserSearchString||"",IgnoreMaxRows:n.params.IgnoreMaxRows||!1,MaxRows:n.params.MaxRows,StartRow:n.params.StartRow,ForceAuditLog:n.params.ForceAuditLog||!1,AuditLogDescription:n.params.AuditLogDescription||"",ResultType:n.params.ResultType||"simple"},cacheStatus:n.cacheStatus?{maxUpdatedAt:n.cacheStatus.maxUpdatedAt,rowCount:n.cacheStatus.rowCount}:null})),s=m.gql`
274
+ }`,i=await this.ExecuteGQL(o,{input:r});if(i&&i.RunViews){const n=i.RunViews;for(const[u,p]of n.entries())p.Results=p.Results.map(y=>{let S=JSON.parse(y.Data);return this.ConvertBackToMJFields(S),S});return n}return null}catch(r){throw c.LogError(r),r}}async RunViewsWithCacheCheck(e,t){try{const r=e.map(n=>({params:{EntityName:n.params.EntityName||"",ExtraFilter:n.params.ExtraFilter||"",OrderBy:n.params.OrderBy||"",Fields:n.params.Fields,UserSearchString:n.params.UserSearchString||"",IgnoreMaxRows:n.params.IgnoreMaxRows||!1,MaxRows:n.params.MaxRows,StartRow:n.params.StartRow,ForceAuditLog:n.params.ForceAuditLog||!1,AuditLogDescription:n.params.AuditLogDescription||"",ResultType:n.params.ResultType||"simple"},cacheStatus:n.cacheStatus?{maxUpdatedAt:n.cacheStatus.maxUpdatedAt,rowCount:n.cacheStatus.rowCount}:null})),s=m.gql`
275
275
  query RunViewsWithCacheCheckQuery($input: [RunViewWithCacheCheckInput!]!) {
276
276
  RunViewsWithCacheCheck(input: $input) {
277
277
  success
@@ -290,10 +290,21 @@
290
290
  EntityID
291
291
  Data
292
292
  }
293
+ differentialData {
294
+ updatedRows {
295
+ PrimaryKey {
296
+ FieldName
297
+ Value
298
+ }
299
+ EntityID
300
+ Data
301
+ }
302
+ deletedRecordIDs
303
+ }
293
304
  }
294
305
  }
295
306
  }
296
- `,o=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map((n,u)=>{const p=e[u];if(n.status==="stale"&&n.Results){const g=p.params.EntityName,I=this.Entities.find(l=>l.Name===g),y=n.Results.map(l=>{const d=JSON.parse(l.Data);return this.ConvertBackToMJFields(d),d});return{viewIndex:n.viewIndex,status:n.status,results:y,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}}return{viewIndex:n.viewIndex,status:n.status,results:void 0,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c.LogError(r),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await pe.ViewInfo.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await pe.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 P;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=m.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
307
+ `,o=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!o)return{success:!1,results:[],errorMessage:"No response from server"};const i=o.results.map((n,u)=>{const p=e[u];if(n.status==="differential"&&n.differentialData){const y=n.differentialData.updatedRows.map(S=>{const d=JSON.parse(S.Data);return this.ConvertBackToMJFields(d),d});return{viewIndex:n.viewIndex,status:n.status,results:void 0,differentialData:{updatedRows:y,deletedRecordIDs:n.differentialData.deletedRecordIDs},maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}}if(n.status==="stale"&&n.Results){const y=n.Results.map(S=>{const d=JSON.parse(S.Data);return this.ConvertBackToMJFields(d),d});return{viewIndex:n.viewIndex,status:n.status,results:y,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}}return{viewIndex:n.viewIndex,status:n.status,results:void 0,maxUpdatedAt:n.maxUpdatedAt,rowCount:n.rowCount,errorMessage:n.errorMessage}});return{success:o.success,results:i,errorMessage:o.errorMessage}}catch(r){return c.LogError(r),{success:!1,results:[],errorMessage:r instanceof Error?r.message:String(r)}}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await pe.ViewInfo.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await pe.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 $;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=m.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
297
308
  GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
298
309
  EntityName
299
310
  RelatedEntityName
@@ -344,32 +355,32 @@
344
355
  Message
345
356
  }
346
357
  }
347
- }`,o={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(n=>({FieldName:n.FieldName,Value:n.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(n=>n.Copy())};return(await this.ExecuteGQL(a,{request:o}))?.MergeRecords}catch(a){return c.LogError(a),{Success:!1,OverallStatus:a&&a.message?a.message:a,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=c.getGraphQLTypeNameBase(e.EntityInfo),n=`${o}${i}`,u=e.Fields.filter(y=>!y.ReadOnly||y.IsPrimaryKey&&e.IsSaved),p=new P,g=` ${n}(input: $input) {
348
- ${e.Fields.map(y=>p.MapFieldName(y.CodeName)).join(`
358
+ }`,o={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(n=>({FieldName:n.FieldName,Value:n.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(n=>n.Copy())};return(await this.ExecuteGQL(a,{request:o}))?.MergeRecords}catch(a){return c.LogError(a),{Success:!1,OverallStatus:a&&a.message?a.message:a,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(d=>({FieldName:d.CodeName,Value:d.Value})),e.ResultHistory.push(s);const i=c.getGraphQLTypeNameBase(e.EntityInfo),n=`${o}${i}`,u=e.Fields.filter(d=>!d.ReadOnly||d.IsPrimaryKey&&e.IsSaved),p=new $,y=` ${n}(input: $input) {
359
+ ${e.Fields.map(d=>p.MapFieldName(d.CodeName)).join(`
349
360
  `)}
350
- }`,I=m.gql`mutation ${o}${i} ($input: ${n}Input!) {
351
- ${g}
361
+ }`,S=m.gql`mutation ${o}${i} ($input: ${n}Input!) {
362
+ ${y}
352
363
  }
353
- `;for(let y=0;y<u.length;y++){const l=u[y];let d=l.Value;if(d)switch(l.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:d=d.getTime();break;case c.EntityFieldTSType.Boolean:typeof d!="boolean"&&(d=parseInt(d)!==0);break;case c.EntityFieldTSType.Number:if(typeof d!="number"){const R=Number(d);isNaN(R)||(d=R)}break}d===null&&l.EntityFieldInfo.AllowsNull===!1&&(l.EntityFieldInfo.DefaultValue!==null?d=l.EntityFieldInfo.DefaultValue:l.FieldType===c.EntityFieldTSType.Number||l.FieldType===c.EntityFieldTSType.Boolean?d=0:d=""),a.input[l.CodeName]=d}if(o.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const y=[];e.Fields.forEach(l=>{let d=null;l.OldValue!==null&&l.OldValue!==void 0&&(l.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?d=l.OldValue.getTime().toString():l.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?d=l.OldValue===!0?"1":"0":typeof l.OldValue!="string"?d=l.OldValue.toString():d=l.OldValue),y.push({Key:l.CodeName,Value:d})}),a.input.OldValues___=y}if(e.TransactionGroup){const y=[{varName:"input",inputType:n+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",g,a,{mutationName:n,mutationInputTypes:y},(l,d)=>{s.EndedAt=new Date,d&&l?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(l)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const y=await this.ExecuteGQL(I,a);if(y&&y[n])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(y[n]),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 l=e.Fields.find(S=>S.Name.trim().toLowerCase()===t.KeyValuePairs[y].FieldName.trim().toLowerCase()).EntityFieldInfo,d=t.GetValueByIndex(y),R=l.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${l.CodeName}: ${R}!`,o.length>0&&(o+=", "),o+=`${l.CodeName}: $${l.CodeName}`,l.TSType===c.EntityFieldTSType.Number){if(isNaN(t.GetValueByIndex(y)))throw new Error(`Primary Key value ${d} (${l.Name}) is not a valid number`);a[l.CodeName]=parseInt(d)}else a[l.CodeName]=d}const n=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",u=c.getGraphQLTypeNameBase(e.EntityInfo),p=new P,g=m.gql`query Single${u}${n.length>0?"Full":""} (${i}) {
364
+ `;for(let d=0;d<u.length;d++){const l=u[d];let g=l.Value;if(g)switch(l.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:g=g.getTime();break;case c.EntityFieldTSType.Boolean:typeof g!="boolean"&&(g=parseInt(g)!==0);break;case c.EntityFieldTSType.Number:if(typeof g!="number"){const R=Number(g);isNaN(R)||(g=R)}break}g===null&&l.EntityFieldInfo.AllowsNull===!1&&(l.EntityFieldInfo.DefaultValue!==null?g=l.EntityFieldInfo.DefaultValue:l.FieldType===c.EntityFieldTSType.Number||l.FieldType===c.EntityFieldTSType.Boolean?g=0:g=""),a.input[l.CodeName]=g}if(o.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const d=[];e.Fields.forEach(l=>{let g=null;l.OldValue!==null&&l.OldValue!==void 0&&(l.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?g=l.OldValue.getTime().toString():l.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?g=l.OldValue===!0?"1":"0":typeof l.OldValue!="string"?g=l.OldValue.toString():g=l.OldValue),d.push({Key:l.CodeName,Value:g})}),a.input.OldValues___=d}if(e.TransactionGroup){const d=[{varName:"input",inputType:n+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",y,a,{mutationName:n,mutationInputTypes:d},(l,g)=>{s.EndedAt=new Date,g&&l?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(l)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const d=await this.ExecuteGQL(S,a);if(d&&d[n])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(d[n]),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 d=0;d<t.KeyValuePairs.length;d++){const l=e.Fields.find(I=>I.Name.trim().toLowerCase()===t.KeyValuePairs[d].FieldName.trim().toLowerCase()).EntityFieldInfo,g=t.GetValueByIndex(d),R=l.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${l.CodeName}: ${R}!`,o.length>0&&(o+=", "),o+=`${l.CodeName}: $${l.CodeName}`,l.TSType===c.EntityFieldTSType.Number){if(isNaN(t.GetValueByIndex(d)))throw new Error(`Primary Key value ${g} (${l.Name}) is not a valid number`);a[l.CodeName]=parseInt(g)}else a[l.CodeName]=g}const n=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",u=c.getGraphQLTypeNameBase(e.EntityInfo),p=new $,y=m.gql`query Single${u}${n.length>0?"Full":""} (${i}) {
354
365
  ${u}(${o}) {
355
- ${e.Fields.filter(y=>!y.EntityFieldInfo.IsBinaryFieldType).map(y=>y.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?y.CodeName.replace("__mj_","_mj__"):y.CodeName).join(`
366
+ ${e.Fields.filter(d=>!d.EntityFieldInfo.IsBinaryFieldType).map(d=>d.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?d.CodeName.replace("__mj_","_mj__"):d.CodeName).join(`
356
367
  `)}
357
368
  ${n}
358
369
  }
359
370
  }
360
- `,I=await this.ExecuteGQL(g,a);return I&&I[u]?this.ConvertBackToMJFields(I[u]):null}catch(a){return c.LogError(a),null}}ConvertBackToMJFields(e){return new P().ReverseMapFields(e),e}getRelatedEntityString(e,t){let r="";for(let s=0;s<e.RelatedEntities.length;s++)if(t.indexOf(e.RelatedEntities[s].RelatedEntity)>=0){const a=e.RelatedEntities[s],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+=`
371
+ `,S=await this.ExecuteGQL(y,a);return S&&S[u]?this.ConvertBackToMJFields(S[u]):null}catch(a){return c.LogError(a),null}}ConvertBackToMJFields(e){return new $().ReverseMapFields(e),e}getRelatedEntityString(e,t){let r="";for(let s=0;s<e.RelatedEntities.length;s++)if(t.indexOf(e.RelatedEntities[s].RelatedEntity)>=0){const a=e.RelatedEntities[s],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+=`
361
372
  ${i} {
362
373
  ${o.Fields.map(n=>n.CodeName).join(`
363
374
  `)}
364
375
  }
365
- `}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(l=>({FieldName:l.CodeName,Value:l.Value})),e.ResultHistory.push(s);const a={},o=[];let i="",n="",u="";for(let l of e.PrimaryKey.KeyValuePairs){const d=e.Fields.find(R=>R.Name.trim().toLowerCase()===l.FieldName.trim().toLowerCase());a[d.CodeName]=d.Value,o.push({varName:d.CodeName,inputType:d.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${d.CodeName}: $${d.CodeName}`,n.length>0&&(n+=", "),n+=`$${d.CodeName}: ${d.EntityFieldInfo.GraphQLType}!`,u.length>0&&(u+=`
366
- `),u+=`${d.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const g="Delete"+c.getGraphQLTypeNameBase(e.EntityInfo),I=m.gql`${g}(${i}, options___: $options___) {
376
+ `}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(l=>({FieldName:l.CodeName,Value:l.Value})),e.ResultHistory.push(s);const a={},o=[];let i="",n="",u="";for(let l of e.PrimaryKey.KeyValuePairs){const g=e.Fields.find(R=>R.Name.trim().toLowerCase()===l.FieldName.trim().toLowerCase());a[g.CodeName]=g.Value,o.push({varName:g.CodeName,inputType:g.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${g.CodeName}: $${g.CodeName}`,n.length>0&&(n+=", "),n+=`$${g.CodeName}: ${g.EntityFieldInfo.GraphQLType}!`,u.length>0&&(u+=`
377
+ `),u+=`${g.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),a.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const y="Delete"+c.getGraphQLTypeNameBase(e.EntityInfo),S=m.gql`${y}(${i}, options___: $options___) {
367
378
  ${u}
368
379
  }
369
- `,y=m.gql`mutation ${g} (${n}, $options___: DeleteOptionsInput!) {
370
- ${I}
380
+ `,d=m.gql`mutation ${y} (${n}, $options___: DeleteOptionsInput!) {
381
+ ${S}
371
382
  }
372
- `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,"Delete",I,a,{mutationName:g,mutationInputTypes:o},(l,d)=>{if(s.EndedAt=new Date,d&&l){let R=!0;for(const S of e.PrimaryKey.KeyValuePairs)S.Value!==l[S.FieldName]&&(R=!1);R?s.Success=!0:(s.Success=!1,s.Message="Transaction failed to commit")}else s.Success=!1,s.Message="Transaction failed to commit"})),!0;{const l=await this.ExecuteGQL(y,a);if(l&&l[g]){const d=l[g];for(let R of e.PrimaryKey.KeyValuePairs){let S=d[R.FieldName],D=R.Value;if(typeof D=="number"&&(D=D.toString()),typeof S=="number"&&(S=S.toString()),D!==S)throw new Error(`Primary key value mismatch in server Delete response. Field: ${R.FieldName}, Original: ${D}, Returned: ${S}`)}return s.Success=!0,s.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(a){return s.EndedAt=new Date,s.Success=!1,s.Message=a.response?.errors?.length>0?a.response.errors[0].message:a.message,c.LogError(a),!1}}async GetDatasetByName(e,t){const r=m.gql`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
383
+ `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,"Delete",S,a,{mutationName:y,mutationInputTypes:o},(l,g)=>{if(s.EndedAt=new Date,g&&l){let R=!0;for(const I of e.PrimaryKey.KeyValuePairs)I.Value!==l[I.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 l=await this.ExecuteGQL(d,a);if(l&&l[y]){const g=l[y];for(let R of e.PrimaryKey.KeyValuePairs){let I=g[R.FieldName],D=R.Value;if(typeof D=="number"&&(D=D.toString()),typeof I=="number"&&(I=I.toString()),D!==I)throw new Error(`Primary key value mismatch in server Delete response. Field: ${R.FieldName}, Original: ${D}, Returned: ${I}`)}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=m.gql`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
373
384
  GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
374
385
  DatasetID
375
386
  DatasetName
@@ -429,14 +440,14 @@
429
440
  }
430
441
  }`,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 h.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(console.error("[GraphQL] ExecuteGQL error caught:",{hasResponse:!!s?.response,hasErrors:!!s?.response?.errors,errorCount:s?.response?.errors?.length,firstError:s?.response?.errors?.[0],errorCode:s?.response?.errors?.[0]?.extensions?.code,errorMessage:s?.response?.errors?.[0]?.message,fullError:s}),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(){const e=h.Instance&&h.Instance._configData===this._configData;if(e&&h.Instance._refreshPromise)return h.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(h.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&h.Instance&&(h.Instance._refreshPromise=null)}}async performTokenRefresh(){if(this._configData.Data.RefreshTokenFunction){const e=await this._configData.Data.RefreshTokenFunction();if(e){this._configData.Token=e;const t=this.CreateNewGraphQLClient(this._configData.URL,this._configData.Token,this._sessionId,this._configData.MJAPIKey);this._client=t,h.Instance&&h.Instance._configData===this._configData&&(h.Instance._client=t)}else throw new Error("Refresh token function returned null or undefined token")}else throw new Error("No refresh token function provided")}static async RefreshToken(){return h.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,s){const a={"x-session-id":r};return t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),new m.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__")+`
431
442
  `:s.startsWith("_")||(t+=s+`
432
- `);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new x),this._localStorageProvider}get Metadata(){return this}getOrCreateWSClient(){const e=Date.now();return this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&this._activeSubscriptionCount===0&&this.disposeWSClient(),this._wsClient||(this._wsClient=Re.createClient({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:()=>!0}),this._wsClientCreatedAt=e,this._subscriptionCleanupTimer||(this._subscriptionCleanupTimer=setInterval(()=>{this.cleanupStaleSubscriptions()},this.SUBSCRIPTION_CLEANUP_INTERVAL_MS))),this._wsClient}disposeWSClient(){if(this._wsClient){try{this._wsClient.dispose()}catch(e){console.error("[GraphQLDataProvider] Error disposing WebSocket client:",e)}this._wsClient=null,this._wsClientCreatedAt=null}}completeAllSubjects(){this._pushStatusSubjects.forEach((e,t)=>{try{e.subject.complete(),e.subscription.unsubscribe()}catch(r){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,r)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=this._pushStatusSubjects.size,r=Array.from(this._pushStatusSubjects.entries()),s=[];r.forEach(([a,o])=>{const i=e-o.lastRequestedAt,n=e-o.lastEmissionAt;o.activeSubscribers===0&&i>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&n>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${a} for cleanup: activeSubscribers=${o.activeSubscribers}, timeSinceRequested=${Math.round(i/1e3)}s, timeSinceEmission=${Math.round(n/1e3)}s`),s.push(a))}),s.forEach(a=>{const o=this._pushStatusSubjects.get(a);if(o)try{o.subject.complete(),o.subscription.unsubscribe(),this._pushStatusSubjects.delete(a),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${a}`)}catch(i){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${a}:`,i)}}),s.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${s.length} stale subscription(s)`),this._pushStatusSubjects.size===0&&this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&(console.log("[GraphQLDataProvider] Disposing of idle WebSocket client"),this.disposeWSClient())}finally{this._isCleaningUp=!1}}}subscribe(e,t){return new v.Observable(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const a=s.subscribe({query:e,variables:t},{next:o=>{r.next(o.data)},error:async o=>{const i=o;if(i?.extensions?.code==="JWT_EXPIRED"||i?.message?.includes("token has expired")||i?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(u){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",u),r.error(u)}}else r.error(o)},complete:()=>{r.complete()}});return()=>{this._activeSubscriptionCount--,a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new v.Observable(n=>{r.activeSubscribers++;const u=r.subject.subscribe(n);return()=>{const p=this._pushStatusSubjects.get(e);p&&p.activeSubscribers>0&&p.activeSubscribers--,u.unsubscribe()}});const s=m.gql`subscription StatusUpdates($sessionId: String!) {
443
+ `);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new x),this._localStorageProvider}get Metadata(){return this}getOrCreateWSClient(){const e=Date.now();return this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&this._activeSubscriptionCount===0&&this.disposeWSClient(),this._wsClient||(this._wsClient=Re.createClient({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:()=>!0}),this._wsClientCreatedAt=e,this._subscriptionCleanupTimer||(this._subscriptionCleanupTimer=setInterval(()=>{this.cleanupStaleSubscriptions()},this.SUBSCRIPTION_CLEANUP_INTERVAL_MS))),this._wsClient}disposeWSClient(){if(this._wsClient){try{this._wsClient.dispose()}catch(e){console.error("[GraphQLDataProvider] Error disposing WebSocket client:",e)}this._wsClient=null,this._wsClientCreatedAt=null}}completeAllSubjects(){this._pushStatusSubjects.forEach((e,t)=>{try{e.subject.complete(),e.subscription.unsubscribe()}catch(r){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,r)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=this._pushStatusSubjects.size,r=Array.from(this._pushStatusSubjects.entries()),s=[];r.forEach(([a,o])=>{const i=e-o.lastRequestedAt,n=e-o.lastEmissionAt;o.activeSubscribers===0&&i>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&n>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${a} for cleanup: activeSubscribers=${o.activeSubscribers}, timeSinceRequested=${Math.round(i/1e3)}s, timeSinceEmission=${Math.round(n/1e3)}s`),s.push(a))}),s.forEach(a=>{const o=this._pushStatusSubjects.get(a);if(o)try{o.subject.complete(),o.subscription.unsubscribe(),this._pushStatusSubjects.delete(a),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${a}`)}catch(i){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${a}:`,i)}}),s.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${s.length} stale subscription(s)`),this._pushStatusSubjects.size===0&&this._wsClient&&this._wsClientCreatedAt&&e-this._wsClientCreatedAt>this.WS_CLIENT_MAX_AGE_MS&&(console.log("[GraphQLDataProvider] Disposing of idle WebSocket client"),this.disposeWSClient())}finally{this._isCleaningUp=!1}}}subscribe(e,t){return new P.Observable(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const a=s.subscribe({query:e,variables:t},{next:o=>{r.next(o.data)},error:async o=>{const i=o;if(i?.extensions?.code==="JWT_EXPIRED"||i?.message?.includes("token has expired")||i?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(u){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",u),r.error(u)}}else r.error(o)},complete:()=>{r.complete()}});return()=>{this._activeSubscriptionCount--,a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new P.Observable(n=>{r.activeSubscribers++;const u=r.subject.subscribe(n);return()=>{const p=this._pushStatusSubjects.get(e);p&&p.activeSubscribers>0&&p.activeSubscribers--,u.unsubscribe()}});const s=m.gql`subscription StatusUpdates($sessionId: String!) {
433
444
  statusUpdates(sessionId: $sessionId) {
434
445
  date
435
446
  message
436
447
  sessionId
437
448
  }
438
449
  }
439
- `,a=new v.Subject,o=this.getOrCreateWSClient(),i=new v.Subscription;return i.add(new v.Observable(n=>{const u=o.subscribe({query:s,variables:{sessionId:e}},{next:p=>{const g=this._pushStatusSubjects.get(e);g&&(g.lastEmissionAt=Date.now()),n.next(p.data.statusUpdates.message)},error:async p=>{const g=p;if(g?.extensions?.code==="JWT_EXPIRED"||g?.message?.includes("token has expired")||g?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),n.complete()}catch(y){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",y),n.error(y)}}else n.error(p)},complete:()=>{n.complete()}});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,u()}}).subscribe({next:n=>a.next(n),error:n=>{a.error(n),this._pushStatusSubjects.delete(e)},complete:()=>{a.complete(),this._pushStatusSubjects.delete(e)}})),this._pushStatusSubjects.set(e,{subject:a,subscription:i,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new v.Observable(n=>{const u=this._pushStatusSubjects.get(e);u&&u.activeSubscribers++;const p=a.subscribe(n);return()=>{const g=this._pushStatusSubjects.get(e);g&&g.activeSubscribers>0&&g.activeSubscribers--,p.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}};f(h,"GraphQLDataProvider");let L=h;async function Pe(E){const e=new L;return c.SetProvider(e),await e.Config(E),await c.StartupManager.Instance.Startup(),w.MJGlobal.Instance.RaiseEvent({event:w.MJEventType.LoggedIn,eventCode:null,component:this,args:null}),e}f(Pe,"setupGraphQLClient");const ee=class ee{};f(ee,"SyncRolesAndUsersResult");let A=ee;const te=class te{};f(te,"RoleInput");let M=te;const re=class re{};f(re,"UserInput");let V=re;const se=class se{};f(se,"RolesAndUsersInput");let Q=se;var Se=(E=>(E.Create="Create",E.Update="Update",E.CreateOrUpdate="CreateOrUpdate",E.Delete="Delete",E.DeleteWithFilter="DeleteWithFilter",E))(Se||{});const ae=class ae{};f(ae,"ActionItemInput");let G=ae;const ne=class ne{constructor(){this.Results=[]}};f(ne,"SyncDataResult");let F=ne;const oe=class oe{};f(oe,"ActionItemOutput");let U=oe;const ie=class ie{get Client(){return this._client}constructor(e,t,r,s){const a={"x-session-id":r};this._sessionId=r,t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),this._client=new m.GraphQLClient(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
450
+ `,a=new P.Subject,o=this.getOrCreateWSClient(),i=new P.Subscription;return i.add(new P.Observable(n=>{const u=o.subscribe({query:s,variables:{sessionId:e}},{next:p=>{const y=this._pushStatusSubjects.get(e);y&&(y.lastEmissionAt=Date.now()),n.next(p.data.statusUpdates.message)},error:async p=>{const y=p;if(y?.extensions?.code==="JWT_EXPIRED"||y?.message?.includes("token has expired")||y?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),n.complete()}catch(d){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",d),n.error(d)}}else n.error(p)},complete:()=>{n.complete()}});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,u()}}).subscribe({next:n=>a.next(n),error:n=>{a.error(n),this._pushStatusSubjects.delete(e)},complete:()=>{a.complete(),this._pushStatusSubjects.delete(e)}})),this._pushStatusSubjects.set(e,{subject:a,subscription:i,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new P.Observable(n=>{const u=this._pushStatusSubjects.get(e);u&&u.activeSubscribers++;const p=a.subscribe(n);return()=>{const y=this._pushStatusSubjects.get(e);y&&y.activeSubscribers>0&&y.activeSubscribers--,p.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}};f(h,"GraphQLDataProvider");let L=h;async function $e(E){const e=new L;return c.SetProvider(e),await e.Config(E),await c.StartupManager.Instance.Startup(),w.MJGlobal.Instance.RaiseEvent({event:w.MJEventType.LoggedIn,eventCode:null,component:this,args:null}),e}f($e,"setupGraphQLClient");const ee=class ee{};f(ee,"SyncRolesAndUsersResult");let A=ee;const te=class te{};f(te,"RoleInput");let M=te;const re=class re{};f(re,"UserInput");let V=re;const se=class se{};f(se,"RolesAndUsersInput");let Q=se;var Se=(E=>(E.Create="Create",E.Update="Update",E.CreateOrUpdate="CreateOrUpdate",E.Delete="Delete",E.DeleteWithFilter="DeleteWithFilter",E))(Se||{});const ae=class ae{};f(ae,"ActionItemInput");let F=ae;const ne=class ne{constructor(){this.Results=[]}};f(ne,"SyncDataResult");let G=ne;const oe=class oe{};f(oe,"ActionItemOutput");let U=oe;const ie=class ie{get Client(){return this._client}constructor(e,t,r,s){const a={"x-session-id":r};this._sessionId=r,t&&(a.authorization="Bearer "+t),s&&(a["x-mj-api-key"]=s),this._client=new m.GraphQLClient(e,{headers:a})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
440
451
  GetData(input: $input) {
441
452
  Success
442
453
  ErrorMessages
@@ -844,18 +855,20 @@
844
855
  ResultData
845
856
  }
846
857
  }
847
- `;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}}};f(ye,"GraphQLActionClient");let K=ye;const me=class me{constructor(e){this._dataProvider=e}async RunTest(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(i=>{try{const n=JSON.parse(i);n.resolver==="RunTestResolver"&&n.type==="TestExecutionProgress"&&n.status==="ok"&&n.data?.progress&&e.onProgress(n.data.progress)}catch(n){console.error("[GraphQLTestingClient] Failed to parse progress message:",n)}}));const r=m.gql`
858
+ `;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}}};f(ye,"GraphQLActionClient");let K=ye;const me=class me{constructor(e){this._dataProvider=e}async RunTest(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(n=>{try{const u=JSON.parse(n);u.resolver==="RunTestResolver"&&u.type==="TestExecutionProgress"&&u.status==="ok"&&u.data?.progress&&e.onProgress(u.data.progress)}catch(u){console.error("[GraphQLTestingClient] Failed to parse progress message:",u)}}));const r=m.gql`
848
859
  mutation RunTest(
849
860
  $testId: String!,
850
861
  $verbose: Boolean,
851
862
  $environment: String,
852
- $tags: String
863
+ $tags: String,
864
+ $variables: String
853
865
  ) {
854
866
  RunTest(
855
867
  testId: $testId,
856
868
  verbose: $verbose,
857
869
  environment: $environment,
858
- tags: $tags
870
+ tags: $tags,
871
+ variables: $variables
859
872
  ) {
860
873
  success
861
874
  errorMessage
@@ -863,13 +876,14 @@
863
876
  result
864
877
  }
865
878
  }
866
- `,s=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,a={testId:e.testId,verbose:e.verbose,environment:e.environment,tags:s},o=await this._dataProvider.ExecuteGQL(r,a);return this.processTestResult(o.RunTest)}catch(r){return this.handleError(r,"RunTest")}finally{t&&t.unsubscribe()}}async RunTestSuite(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(n=>{try{const u=JSON.parse(n);u.resolver==="RunTestResolver"&&u.type==="TestExecutionProgress"&&u.status==="ok"&&u.data?.progress&&e.onProgress(u.data.progress)}catch(u){console.error("[GraphQLTestingClient] Failed to parse progress message:",u)}}));const r=m.gql`
879
+ `,s=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,a=e.variables?JSON.stringify(e.variables):void 0,o={testId:e.testId,verbose:e.verbose,environment:e.environment,tags:s,variables:a},i=await this._dataProvider.ExecuteGQL(r,o);return this.processTestResult(i.RunTest)}catch(r){return this.handleError(r,"RunTest")}finally{t&&t.unsubscribe()}}async RunTestSuite(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(u=>{try{const p=JSON.parse(u);p.resolver==="RunTestResolver"&&p.type==="TestExecutionProgress"&&p.status==="ok"&&p.data?.progress&&e.onProgress(p.data.progress)}catch(p){console.error("[GraphQLTestingClient] Failed to parse progress message:",p)}}));const r=m.gql`
867
880
  mutation RunTestSuite(
868
881
  $suiteId: String!,
869
882
  $verbose: Boolean,
870
883
  $environment: String,
871
884
  $parallel: Boolean,
872
885
  $tags: String,
886
+ $variables: String,
873
887
  $selectedTestIds: String,
874
888
  $sequenceStart: Int,
875
889
  $sequenceEnd: Int
@@ -880,6 +894,7 @@
880
894
  environment: $environment,
881
895
  parallel: $parallel,
882
896
  tags: $tags,
897
+ variables: $variables,
883
898
  selectedTestIds: $selectedTestIds,
884
899
  sequenceStart: $sequenceStart,
885
900
  sequenceEnd: $sequenceEnd
@@ -890,7 +905,7 @@
890
905
  result
891
906
  }
892
907
  }
893
- `,s=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,a=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0,o={suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:s,selectedTestIds:a,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd},i=await this._dataProvider.ExecuteGQL(r,o);return this.processSuiteResult(i.RunTestSuite)}catch(r){return this.handleError(r,"RunTestSuite")}finally{t&&t.unsubscribe()}}async IsTestRunning(e){try{const t=m.gql`
908
+ `,s=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,a=e.variables?JSON.stringify(e.variables):void 0,o=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0,i={suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:s,variables:a,selectedTestIds:o,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd},n=await this._dataProvider.ExecuteGQL(r,i);return this.processSuiteResult(n.RunTestSuite)}catch(r){return this.handleError(r,"RunTestSuite")}finally{t&&t.unsubscribe()}}async IsTestRunning(e){try{const t=m.gql`
894
909
  query IsTestRunning($testId: String!) {
895
910
  IsTestRunning(testId: $testId)
896
911
  }
@@ -978,5 +993,5 @@
978
993
  error
979
994
  }
980
995
  }
981
- `,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return c.LogError(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}};f(ge,"GraphQLComponentRegistryClient");let j=ge;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return m.gql}}),exports.ActionItemInput=G,exports.ActionItemOutput=U,exports.BrowserIndexedDBStorageProvider=x,exports.BrowserStorageProviderBase=b,exports.FieldMapper=P,exports.GetDataOutput=_,exports.GraphQLAIClient=N,exports.GraphQLActionClient=K,exports.GraphQLComponentRegistryClient=j,exports.GraphQLDataProvider=L,exports.GraphQLProviderConfigData=T,exports.GraphQLSystemUserClient=q,exports.GraphQLTestingClient=J,exports.GraphQLTransactionGroup=C,exports.RoleInput=M,exports.RolesAndUsersInput=Q,exports.SimpleRemoteEntity=k,exports.SimpleRemoteEntityField=B,exports.SimpleRemoteEntityOutput=O,exports.SyncDataAction=Se,exports.SyncDataResult=F,exports.SyncRolesAndUsersResult=A,exports.UserInput=V,exports.setupGraphQLClient=Pe;
996
+ `,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return c.LogError(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}};f(ge,"GraphQLComponentRegistryClient");let j=ge;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return m.gql}}),exports.ActionItemInput=F,exports.ActionItemOutput=U,exports.BrowserIndexedDBStorageProvider=x,exports.BrowserStorageProviderBase=b,exports.FieldMapper=$,exports.GetDataOutput=_,exports.GraphQLAIClient=N,exports.GraphQLActionClient=K,exports.GraphQLComponentRegistryClient=j,exports.GraphQLDataProvider=L,exports.GraphQLProviderConfigData=T,exports.GraphQLSystemUserClient=q,exports.GraphQLTestingClient=J,exports.GraphQLTransactionGroup=C,exports.RoleInput=M,exports.RolesAndUsersInput=Q,exports.SimpleRemoteEntity=k,exports.SimpleRemoteEntityField=B,exports.SimpleRemoteEntityOutput=O,exports.SyncDataAction=Se,exports.SyncDataResult=G,exports.SyncRolesAndUsersResult=A,exports.UserInput=V,exports.setupGraphQLClient=$e;
982
997
  //# sourceMappingURL=index.cjs.map