@memberjunction/graphql-dataprovider 6.1.0-edge.5 → 6.1.0-edge.6

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 X=Object.defineProperty;var d=(g,e)=>X(g,"name",{value:e,configurable:!0});var u=require("graphql-request"),c=require("@memberjunction/core"),D=require("@memberjunction/global"),_=require("@memberjunction/core-entities"),$=require("rxjs"),Y=require("graphql-ws"),Z=require("uuid"),ee=require("@tempfix/idb");class b{static{d(this,"FieldMapper")}static{this.DB_PREFIX="__mj_"}static{this.GQL_PREFIX="_mj__"}constructor(){}MapFields(e){if(e)for(const t in e){const r=this.MapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}MapFieldName(e){return e.startsWith(b.DB_PREFIX)?b.GQL_PREFIX+e.substring(b.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(b.GQL_PREFIX)?b.DB_PREFIX+e.substring(b.GQL_PREFIX.length):e}ReverseMapFields(e){for(const t in e){const r=this.ReverseMapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}}class V extends c.TransactionGroupBase{static{d(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=u.gql`
1
+ "use strict";var X=Object.defineProperty;var d=(g,e)=>X(g,"name",{value:e,configurable:!0});var u=require("graphql-request"),c=require("@memberjunction/core"),D=require("@memberjunction/global"),_=require("@memberjunction/core-entities"),$=require("rxjs"),Y=require("graphql-ws"),Z=require("uuid"),ee=require("@tempfix/idb");class L{static{d(this,"FieldMapper")}static{this.DB_PREFIX="__mj_"}static{this.GQL_PREFIX="_mj__"}constructor(){}MapFields(e){if(e)for(const t in e){const r=this.MapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}MapFieldName(e){return e.startsWith(L.DB_PREFIX)?L.GQL_PREFIX+e.substring(L.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(L.GQL_PREFIX)?L.DB_PREFIX+e.substring(L.GQL_PREFIX.length):e}ReverseMapFields(e){for(const t in e){const r=this.ReverseMapFieldName(t);r!==t&&(e[r]=e[t],delete e[t])}return e}}class V extends c.TransactionGroupBase{static{d(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=u.gql`
2
2
  mutation ExecuteTransactionGroup($group: TransactionInputType!) {
3
3
  ExecuteTransactionGroup(group: $group) {
4
4
  Success
@@ -307,9 +307,9 @@
307
307
  }
308
308
  }
309
309
  }
310
- `,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return c.LogError("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const N="6.1.0-edge.5",P="default";class k{static{d(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}get SharesReferences(){return!0}getCategoryMap(e){const t=e||P;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){const s=this.getCategoryMap(t||P).get(e);return s===void 0?null:s}async GetItems(e,t){const r=new Map;if(e.length===0)return r;const s=this.getCategoryMap(t||P);for(const n of new Set(e)){const a=s.get(n);r.set(n,a===void 0?null:a)}return r}async SetItem(e,t,r){this.getCategoryMap(r||P).set(e,t)}async Remove(e,t){this.getCategoryMap(t||P).delete(e)}async ClearCategory(e){const t=e||P;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||P);return t?Array.from(t.keys()):[]}}const se="MJ_Metadata",ne=0;function ae(){try{const g=N.split("."),e=parseInt(g[0],10),t=parseInt(g[1],10);if(!Number.isFinite(e)||!Number.isFinite(t))throw new Error(`Could not parse major.minor from version "${N}"`);return e*1e3+t+ne}catch(g){return c.LogErrorEx({error:g,message:"Failed to derive IDB version from PACKAGE_VERSION; using fallback 99999"}),99999}}d(ae,"computeIdbVersion");const oe=ae(),K=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"];class B extends k{static{d(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=ee.openDB(se,oe,{upgrade:d((e,t,r)=>{try{c.LogStatus(`[IDBCache] Upgrading IndexedDB schema v${t} \u2192 v${r} (package ${N}). Dropping all stores; caches will repopulate on first use.`);for(const s of Array.from(e.objectStoreNames))e.deleteObjectStore(s);for(const s of K)e.objectStoreNames.contains(s)||e.createObjectStore(s)}catch(s){c.LogErrorEx({error:s,message:s?.message})}},"upgrade"),blocked:d((e,t)=>{c.LogStatus(`[IDBCache] Upgrade from v${e} to v${t} blocked by another tab. Close other tabs to allow the upgrade to proceed.`)},"blocked")}),this.dbPromise.then(e=>{this._dbReady=!0,e.onversionchange=()=>{c.LogStatus("[IDBCache] DB schema upgraded in another tab \u2014 closing local connection."),e.close(),this._dbReady=!1}}).catch(e=>{c.LogErrorEx({error:e,message:"IndexedDB initialization failed: "+e?.message})})}get SharesReferences(){return!1}get IsReady(){return this._dbReady}isKnownCategory(e){const t=`mj:${e}`;return K.includes(t)}getStoreName(e){const t=e||P;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||P;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,n=this.getStoreName(r),a=this.getStoreKey(e,r),i=s.transaction(n,"readwrite");await i.objectStore(n).put(t,a),await i.done}catch(s){c.LogErrorEx({error:s,message:s?.message})}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=await r.transaction(s).objectStore(s).get(n);return a===void 0?null:a}catch(r){return c.LogErrorEx({error:r,message:r?.message}),null}}async GetItems(e,t){const r=new Map;if(e.length===0)return r;try{const s=await this.dbPromise,n=this.getStoreName(t),a=Array.from(new Set(e)),i=a.map(h=>this.getStoreKey(h,t)),o=s.transaction(n,"readonly"),y=o.objectStore(n),l=i.map(h=>y.get(h)),S=await Promise.all(l);await o.done;for(let h=0;h<a.length;h++){const m=S[h];r.set(a[h],m===void 0?null:m)}return r}catch(s){c.LogErrorEx({error:s,message:s?.message});for(const n of new Set(e))r.set(n,null);return r}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=r.transaction(s,"readwrite");await a.objectStore(s).delete(n),await a.done}catch(r){c.LogErrorEx({error:r,message:r?.message})}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e);if(this.isKnownCategory(r)){const n=t.transaction(s,"readwrite");await n.objectStore(s).clear(),await n.done}else{const n=`[${r}]:`,a=t.transaction("mj:default","readwrite"),i=a.objectStore("mj:default"),o=await i.getAllKeys();for(const y of o)typeof y=="string"&&y.startsWith(n)&&await i.delete(y);await a.done}}catch(t){c.LogErrorEx({error:t,message:t?.message})}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(y=>String(y));const o=`[${r}]:`;return i.map(y=>String(y)).filter(y=>y.startsWith(o)).map(y=>y.slice(o.length))}catch(t){return c.LogErrorEx({error:t,message:t?.message}),[]}}}class x extends Error{static{d(this,"SafeGraphQLError")}constructor(e){super(e.message),this.name=e.name,this.response={status:e.status,errors:e.errors},this.request={query:e.query},this.Code=e.code,this.VariableShape=e.variableShape,this.stack=e.stackFrames?`${e.name}: ${e.message}
310
+ `,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return c.LogError("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const A="6.1.0-edge.6",P="default";class k{static{d(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}get SharesReferences(){return!0}getCategoryMap(e){const t=e||P;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){const s=this.getCategoryMap(t||P).get(e);return s===void 0?null:s}async GetItems(e,t){const r=new Map;if(e.length===0)return r;const s=this.getCategoryMap(t||P);for(const n of new Set(e)){const a=s.get(n);r.set(n,a===void 0?null:a)}return r}async SetItem(e,t,r){this.getCategoryMap(r||P).set(e,t)}async Remove(e,t){this.getCategoryMap(t||P).delete(e)}async ClearCategory(e){const t=e||P;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||P);return t?Array.from(t.keys()):[]}}const se="MJ_Metadata",ne=0;function ae(){try{const g=A.split("."),e=parseInt(g[0],10),t=parseInt(g[1],10);if(!Number.isFinite(e)||!Number.isFinite(t))throw new Error(`Could not parse major.minor from version "${A}"`);return e*1e3+t+ne}catch(g){return c.LogErrorEx({error:g,message:"Failed to derive IDB version from PACKAGE_VERSION; using fallback 99999"}),99999}}d(ae,"computeIdbVersion");const oe=ae(),K=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"];class B extends k{static{d(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=ee.openDB(se,oe,{upgrade:d((e,t,r)=>{try{c.LogStatus(`[IDBCache] Upgrading IndexedDB schema v${t} \u2192 v${r} (package ${A}). Dropping all stores; caches will repopulate on first use.`);for(const s of Array.from(e.objectStoreNames))e.deleteObjectStore(s);for(const s of K)e.objectStoreNames.contains(s)||e.createObjectStore(s)}catch(s){c.LogErrorEx({error:s,message:s?.message})}},"upgrade"),blocked:d((e,t)=>{c.LogStatus(`[IDBCache] Upgrade from v${e} to v${t} blocked by another tab. Close other tabs to allow the upgrade to proceed.`)},"blocked")}),this.dbPromise.then(e=>{this._dbReady=!0,e.onversionchange=()=>{c.LogStatus("[IDBCache] DB schema upgraded in another tab \u2014 closing local connection."),e.close(),this._dbReady=!1}}).catch(e=>{c.LogErrorEx({error:e,message:"IndexedDB initialization failed: "+e?.message})})}get SharesReferences(){return!1}get IsReady(){return this._dbReady}isKnownCategory(e){const t=`mj:${e}`;return K.includes(t)}getStoreName(e){const t=e||P;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||P;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,n=this.getStoreName(r),a=this.getStoreKey(e,r),i=s.transaction(n,"readwrite");await i.objectStore(n).put(t,a),await i.done}catch(s){c.LogErrorEx({error:s,message:s?.message})}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=await r.transaction(s).objectStore(s).get(n);return a===void 0?null:a}catch(r){return c.LogErrorEx({error:r,message:r?.message}),null}}async GetItems(e,t){const r=new Map;if(e.length===0)return r;try{const s=await this.dbPromise,n=this.getStoreName(t),a=Array.from(new Set(e)),i=a.map(h=>this.getStoreKey(h,t)),o=s.transaction(n,"readonly"),y=o.objectStore(n),l=i.map(h=>y.get(h)),S=await Promise.all(l);await o.done;for(let h=0;h<a.length;h++){const m=S[h];r.set(a[h],m===void 0?null:m)}return r}catch(s){c.LogErrorEx({error:s,message:s?.message});for(const n of new Set(e))r.set(n,null);return r}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=r.transaction(s,"readwrite");await a.objectStore(s).delete(n),await a.done}catch(r){c.LogErrorEx({error:r,message:r?.message})}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e);if(this.isKnownCategory(r)){const n=t.transaction(s,"readwrite");await n.objectStore(s).clear(),await n.done}else{const n=`[${r}]:`,a=t.transaction("mj:default","readwrite"),i=a.objectStore("mj:default"),o=await i.getAllKeys();for(const y of o)typeof y=="string"&&y.startsWith(n)&&await i.delete(y);await a.done}}catch(t){c.LogErrorEx({error:t,message:t?.message})}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(y=>String(y));const o=`[${r}]:`;return i.map(y=>String(y)).filter(y=>y.startsWith(o)).map(y=>y.slice(o.length))}catch(t){return c.LogErrorEx({error:t,message:t?.message}),[]}}}class x extends Error{static{d(this,"SafeGraphQLError")}constructor(e){super(e.message),this.name=e.name,this.response={status:e.status,errors:e.errors},this.request={query:e.query},this.Code=e.code,this.VariableShape=e.variableShape,this.stack=e.stackFrames?`${e.name}: ${e.message}
311
311
  ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}d(j,"ToSafeGraphQLError");const ie=3,ce=25;function F(g,e=0){if(g===null)return"null";if(g===void 0)return"undefined";if(Array.isArray(g))return g.length===0?"array(empty)":`array(${g.length} \xD7 ${ue(F(g[0],e+1))})`;if(typeof g=="object"){if(e>=ie)return"object(\u2026)";const t=Object.keys(g);if(t.length>ce)return`object(${t.length} keys)`;const r={};for(const s of t)r[s]=F(g[s],e+1);return r}return typeof g=="string"?g.length===0?"string(empty)":"string":typeof g}d(F,"describeShape");function ue(g){return typeof g=="string"?g:"object"}d(ue,"typeOf");function le(g){const e=g.indexOf(`
312
- at `);return e===-1?"":g.slice(e+1)}d(le,"stripStackHeader");function de(g,e){const t=g?.[0]?.message;return typeof t=="string"&&t.length>0?t:`GraphQL Error (Code: ${String(e??"unknown")})`}d(de,"deriveMessage");function ge(g){if(Array.isArray(g))return g.map(e=>{const t=e??{};return{message:typeof t.message=="string"?t.message:void 0,path:Array.isArray(t.path)?t.path:void 0,extensions:t.extensions&&typeof t.extensions=="object"?t.extensions:void 0}})}d(ge,"extractErrors");function G(g,e=!1){if(!g||typeof g!="object")return{name:typeof g,message:"Non-object value thrown; contents withheld",variables:"[REDACTED]"};const t=g,r=typeof t.response?.status=="number"?t.response.status:void 0,s=ge(t.response?.errors),n=s?.[0]?.extensions?.code;return{name:typeof t.name=="string"?t.name:"Error",message:de(s,r),status:r,errors:s,code:typeof n=="string"?n:void 0,query:typeof t.request?.query=="string"?t.request.query:void 0,stackFrames:typeof t.stack=="string"?le(t.stack):void 0,variables:e?t.request?.variables:"[REDACTED]",variableShape:t.request?.variables===void 0?void 0:F(t.request.variables)}}d(G,"SanitizeGraphQLError");const L=new b,ye=u.gql`subscription RemoteOperationProgress($channelId: ID!) {
312
+ at `);return e===-1?"":g.slice(e+1)}d(le,"stripStackHeader");function de(g,e){const t=g?.[0]?.message;return typeof t=="string"&&t.length>0?t:`GraphQL Error (Code: ${String(e??"unknown")})`}d(de,"deriveMessage");function ge(g){if(Array.isArray(g))return g.map(e=>{const t=e??{};return{message:typeof t.message=="string"?t.message:void 0,path:Array.isArray(t.path)?t.path:void 0,extensions:t.extensions&&typeof t.extensions=="object"?t.extensions:void 0}})}d(ge,"extractErrors");function G(g,e=!1){if(!g||typeof g!="object")return{name:typeof g,message:"Non-object value thrown; contents withheld",variables:"[REDACTED]"};const t=g,r=typeof t.response?.status=="number"?t.response.status:void 0,s=ge(t.response?.errors),n=s?.[0]?.extensions?.code;return{name:typeof t.name=="string"?t.name:"Error",message:de(s,r),status:r,errors:s,code:typeof n=="string"?n:void 0,query:typeof t.request?.query=="string"?t.request.query:void 0,stackFrames:typeof t.stack=="string"?le(t.stack):void 0,variables:e?t.request?.variables:"[REDACTED]",variableShape:t.request?.variables===void 0?void 0:F(t.request.variables)}}d(G,"SanitizeGraphQLError");const b=new L,ye=u.gql`subscription RemoteOperationProgress($channelId: ID!) {
313
313
  RemoteOperationProgress(channelId: $channelId) {
314
314
  ChannelId
315
315
  ProgressJSON
@@ -393,7 +393,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
393
393
  Success
394
394
  ErrorMessage${h}
395
395
  }
396
- }`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(m,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const R=p[r].Results;if(R&&R.length>0){const v=o.Fields.filter(C=>C.CodeName!==C.Name&&C.CodeName!==void 0);R.forEach(C=>{this.ConvertBackToMJFields(C),v.forEach(A=>{C[A.Name]=C[A.CodeName]})})}return p[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=[],n=[];for(const l of e){let S="",h="";const m={};let p=null,I=null;if(l.ViewEntity)I=l.ViewEntity,p=I.Get("Entity");else{const{entityName:C,v:A}=await this.getEntityNameAndUserView(l,t);I=A,p=C}const R=this.EntityByName(p);if(!R)throw new Error(`Entity ${p} not found in metadata`);s.push(R);let E=!1;const v=c.getGraphQLTypeNameBase(R);l.ViewID?(S=`Run${v}ViewByID`,h="RunViewByIDInput",m.ViewID=l.ViewID):l.ViewName?(S=`Run${v}ViewByName`,h="RunViewByNameInput",m.ViewName=l.ViewName):(E=!0,S=`Run${v}DynamicView`,h="RunDynamicViewInput",m.EntityName=l.EntityName),m.ExtraFilter=l.ExtraFilter||"",m.OrderBy=l.OrderBy||"",m.UserSearchString=l.UserSearchString||"",m.Fields=l.Fields,m.IgnoreMaxRows=l.IgnoreMaxRows||!1,l.MaxRows!==void 0&&(m.MaxRows=l.MaxRows),l.StartRow!==void 0&&(m.StartRow=l.StartRow),l.AfterKey&&(m.AfterKey={KeyValuePairs:l.AfterKey.KeyValuePairs}),m.ForceAuditLog=l.ForceAuditLog||!1,m.ResultType=l.ResultType||"simple",l.AuditLogDescription&&l.AuditLogDescription.length>0&&(m.AuditLogDescription=l.AuditLogDescription),l.BypassCache!==void 0&&(m.BypassCache=l.BypassCache),l.DataSource!==void 0&&(m.DataSource=l.DataSource),E||(m.ExcludeUserViewRunID=l.ExcludeUserViewRunID||"",m.ExcludeDataFromAllPriorViewRuns=l.ExcludeDataFromAllPriorViewRuns||!1,m.OverrideExcludeFilter=l.OverrideExcludeFilter||"",m.SaveViewResults=l.SaveViewResults||!1),l.Aggregates&&l.Aggregates.length>0&&(m.Aggregates=l.Aggregates.map(C=>({expression:C.expression,alias:C.alias}))),r.push(m),n.push(...this.getViewRunTimeFieldList(R,I,l,E))}const i=e.some(l=>l.Aggregates&&l.Aggregates.length>0)?`
396
+ }`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(m,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const R=p[r].Results;if(R&&R.length>0){const v=o.Fields.filter(C=>C.CodeName!==C.Name&&C.CodeName!==void 0);R.forEach(C=>{this.ConvertBackToMJFields(C),v.forEach(M=>{C[M.Name]=C[M.CodeName]})})}return p[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=[],n=[];for(const l of e){let S="",h="";const m={};let p=null,I=null;if(l.ViewEntity)I=l.ViewEntity,p=I.Get("Entity");else{const{entityName:C,v:M}=await this.getEntityNameAndUserView(l,t);I=M,p=C}const R=this.EntityByName(p);if(!R)throw new Error(`Entity ${p} not found in metadata`);s.push(R);let E=!1;const v=c.getGraphQLTypeNameBase(R);l.ViewID?(S=`Run${v}ViewByID`,h="RunViewByIDInput",m.ViewID=l.ViewID):l.ViewName?(S=`Run${v}ViewByName`,h="RunViewByNameInput",m.ViewName=l.ViewName):(E=!0,S=`Run${v}DynamicView`,h="RunDynamicViewInput",m.EntityName=l.EntityName),m.ExtraFilter=l.ExtraFilter||"",m.OrderBy=l.OrderBy||"",m.UserSearchString=l.UserSearchString||"",m.Fields=l.Fields,m.IgnoreMaxRows=l.IgnoreMaxRows||!1,l.MaxRows!==void 0&&(m.MaxRows=l.MaxRows),l.StartRow!==void 0&&(m.StartRow=l.StartRow),l.AfterKey&&(m.AfterKey={KeyValuePairs:l.AfterKey.KeyValuePairs}),m.ForceAuditLog=l.ForceAuditLog||!1,m.ResultType=l.ResultType||"simple",l.AuditLogDescription&&l.AuditLogDescription.length>0&&(m.AuditLogDescription=l.AuditLogDescription),l.BypassCache!==void 0&&(m.BypassCache=l.BypassCache),l.DataSource!==void 0&&(m.DataSource=l.DataSource),E||(m.ExcludeUserViewRunID=l.ExcludeUserViewRunID||"",m.ExcludeDataFromAllPriorViewRuns=l.ExcludeDataFromAllPriorViewRuns||!1,m.OverrideExcludeFilter=l.OverrideExcludeFilter||"",m.SaveViewResults=l.SaveViewResults||!1),l.Aggregates&&l.Aggregates.length>0&&(m.Aggregates=l.Aggregates.map(C=>({expression:C.expression,alias:C.alias}))),r.push(m),n.push(...this.getViewRunTimeFieldList(R,I,l,E))}const i=e.some(l=>l.Aggregates&&l.Aggregates.length>0)?`
397
397
  AggregateResults {
398
398
  alias
399
399
  expression
@@ -457,7 +457,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
457
457
  }
458
458
  }
459
459
  }
460
- `,a=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,y)=>{const l=e[y];if(o.status==="differential"&&o.differentialData){const S=o.differentialData.updatedRows.map(h=>{const m=JSON.parse(h.Data);return this.ConvertBackToMJFields(m),m});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:S,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const S=o.Results.map(m=>{const p=JSON.parse(m.Data);return this.ConvertBackToMJFields(p),p}),h=o.aggregateResults?.map(m=>({expression:m.expression,alias:m.alias,value:m.value!==void 0&&m.value!==null?JSON.parse(m.value):null,error:m.error}));return{viewIndex:o.viewIndex,status:o.status,results:S,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage,aggregateResults:h}}return{viewIndex:o.viewIndex,status:o.status,results:void 0,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.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 _.ViewInfo.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await _.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 n=[];if(r.Fields){for(const a of e.PrimaryKeys)r.Fields.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(L.MapFieldName(a.Name));r.Fields.forEach(a=>{n.push(L.MapFieldName(a))})}else if(s)e.Fields.forEach(a=>{a.IsBinaryFieldType||n.push(L.MapFieldName(a.CodeName))});else{for(const a of e.PrimaryKeys)n.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(L.MapFieldName(a.Name));t.Columns.forEach(a=>{a.hidden===!1&&!n.find(i=>i.trim().toLowerCase()===a.EntityField?.Name.trim().toLowerCase())&&a.EntityField&&n.push(L.MapFieldName(a.EntityField.CodeName))})}return n}get ProviderType(){return c.ProviderType.Network}async GetRecordChanges(e,t){try{const r={EntityName:"MJ: Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},s=await this.RunView(r);return s?s.Results.sort((n,a)=>n.ChangedAt>a.ChangedAt?-1:1):null}catch(r){throw c.LogError(r),r}}async GetRecordDependencies(e,t){try{const r=u.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
460
+ `,a=(await this.ExecuteGQL(s,{input:r}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,y)=>{const l=e[y];if(o.status==="differential"&&o.differentialData){const S=o.differentialData.updatedRows.map(h=>{const m=JSON.parse(h.Data);return this.ConvertBackToMJFields(m),m});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:S,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const S=o.Results.map(m=>{const p=JSON.parse(m.Data);return this.ConvertBackToMJFields(p),p}),h=o.aggregateResults?.map(m=>({expression:m.expression,alias:m.alias,value:m.value!==void 0&&m.value!==null?JSON.parse(m.value):null,error:m.error}));return{viewIndex:o.viewIndex,status:o.status,results:S,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage,aggregateResults:h}}return{viewIndex:o.viewIndex,status:o.status,results:void 0,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}});return{success:a.success,results:i,errorMessage:a.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 _.ViewInfo.GetViewEntity(e.ViewID,t),r=s.Entity;else if(e.ViewName)s=await _.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 n=[];if(r.Fields){for(const a of e.PrimaryKeys)r.Fields.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(b.MapFieldName(a.Name));r.Fields.forEach(a=>{n.push(b.MapFieldName(a))})}else if(s)e.Fields.forEach(a=>{a.IsBinaryFieldType||n.push(b.MapFieldName(a.CodeName))});else{for(const a of e.PrimaryKeys)n.find(i=>i.trim().toLowerCase()===a.Name.toLowerCase())===void 0&&n.push(b.MapFieldName(a.Name));t.Columns.forEach(a=>{a.hidden===!1&&!n.find(i=>i.trim().toLowerCase()===a.EntityField?.Name.trim().toLowerCase())&&a.EntityField&&n.push(b.MapFieldName(a.EntityField.CodeName))})}return n}get ProviderType(){return c.ProviderType.Network}async GetRecordChanges(e,t){try{const r={EntityName:"MJ: Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},s=await this.RunView(r);return s?s.Results.sort((n,a)=>n.ChangedAt>a.ChangedAt?-1:1):null}catch(r){throw c.LogError(r),r}}async GetRecordDependencies(e,t){try{const r=u.gql`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
461
461
  GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
462
462
  EntityName
463
463
  RelatedEntityName
@@ -533,19 +533,19 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
533
533
  }
534
534
  }
535
535
  }`,a={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(n,{request:a}))?.MergeRecords}catch(n){return c.LogError(n),{Success:!1,OverallStatus:n&&n.message?n.message:n,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){if(r?.IsParentEntitySave){const n=new c.BaseEntityResult;return n.StartedAt=new Date,n.EndedAt=new Date,n.Type=e.IsSaved?"update":"create",n.Success=!0,n.NewValues=e.GetAll(),e.RegisterResultHistoryEntry(n),n.NewValues}const s=new c.BaseEntityResult;try{e.RegisterTransactionPreprocessing();const n={input:{}},a=e.IsSaved?"Update":"Create";s.StartedAt=new Date,s.Type=e.IsSaved?"update":"create",s.OriginalValues=e.Fields.map(m=>({FieldName:m.CodeName,Value:m.Value})),e.RegisterResultHistoryEntry(s);const i=c.getGraphQLTypeNameBase(e.EntityInfo),o=`${a}${i}`,y=e.Fields.filter(m=>!m.ReadOnly||m.IsPrimaryKey&&e.IsSaved),l=` ${o}(input: $input) {
536
- ${e.Fields.map(m=>L.MapFieldName(m.CodeName)).join(`
536
+ ${e.Fields.map(m=>b.MapFieldName(m.CodeName)).join(`
537
537
  `)}
538
538
  }`,S=u.gql`mutation ${a}${i} ($input: ${o}Input!) {
539
539
  ${l}
540
540
  }
541
- `;for(let m=0;m<y.length;m++){const p=y[m];let I=e.Get(p.Name);if(I)switch(p.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:I=I.getTime();break;case c.EntityFieldTSType.Boolean:typeof I!="boolean"&&(I=parseInt(I)!==0);break;case c.EntityFieldTSType.Number:if(typeof I!="number"){const R=Number(I);isNaN(R)||(I=R)}break}I===null&&p.EntityFieldInfo.AllowsNull===!1&&(p.EntityFieldInfo.DefaultValue!==null?I=p.EntityFieldInfo.DefaultValue:p.FieldType===c.EntityFieldTSType.Number||p.FieldType===c.EntityFieldTSType.Boolean?I=0:I=""),n.input[L.MapFieldName(p.CodeName)]=I}const h=e.RestoreContext;if(h&&(n.input.RestoreContext___={SourceChangeID:h.SourceChangeID,Reason:h.Reason}),a.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const m=[];e.Fields.forEach(p=>{let I=null;p.OldValue!==null&&p.OldValue!==void 0&&(p.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?I=p.OldValue.getTime().toString():p.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?I=p.OldValue===!0?"1":"0":typeof p.OldValue!="string"?I=p.OldValue.toString():I=p.OldValue),m.push({Key:L.MapFieldName(p.CodeName),Value:I})}),n.input.OldValues___=m}if(e.TransactionGroup){const m=[{varName:"input",inputType:o+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",l,n,{mutationName:o,mutationInputTypes:m},(p,I)=>{s.EndedAt=new Date,I&&p?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(p)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const m=await this.ExecuteGQL(S,n);if(m&&m[o])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(m[o]),s.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(n){return s.Success=!1,s.EndedAt=new Date,s.Message=n.response?.errors?.length>0?n.response.errors[0].message:n.message,c.LogError(n),null}}async Load(e,t,r=null,s){try{const n={};let a="",i="";for(let h=0;h<t.KeyValuePairs.length;h++){const m=e.Fields.find(E=>E.Name.trim().toLowerCase()===t.KeyValuePairs[h].FieldName.trim().toLowerCase()).EntityFieldInfo,p=t.GetValueByIndex(h),I=m.GraphQLType;i.length>0&&(i+=", "),i+=`$${m.CodeName}: ${I}!`,a.length>0&&(a+=", ");const R=m.CodeName.startsWith("__mj_")?m.CodeName.replace("__mj_","_mj__"):m.CodeName;if(a+=`${R}: $${m.CodeName}`,m.TSType===c.EntityFieldTSType.Number){if(isNaN(t.GetValueByIndex(h)))throw new Error(`Primary Key value ${p} (${m.Name}) is not a valid number`);n[m.CodeName]=parseInt(p)}else n[m.CodeName]=p}const o=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",y=c.getGraphQLTypeNameBase(e.EntityInfo),l=u.gql`query Single${y}${o.length>0?"Full":""} (${i}) {
541
+ `;for(let m=0;m<y.length;m++){const p=y[m];let I=e.Get(p.Name);if(I)switch(p.EntityFieldInfo.TSType){case c.EntityFieldTSType.Date:I=I.getTime();break;case c.EntityFieldTSType.Boolean:typeof I!="boolean"&&(I=parseInt(I)!==0);break;case c.EntityFieldTSType.Number:if(typeof I!="number"){const R=Number(I);isNaN(R)||(I=R)}break}I===null&&p.EntityFieldInfo.AllowsNull===!1&&(p.EntityFieldInfo.DefaultValue!==null?I=p.EntityFieldInfo.DefaultValue:p.FieldType===c.EntityFieldTSType.Number||p.FieldType===c.EntityFieldTSType.Boolean?I=0:I=""),n.input[b.MapFieldName(p.CodeName)]=I}const h=e.RestoreContext;if(h&&(n.input.RestoreContext___={SourceChangeID:h.SourceChangeID,Reason:h.Reason}),a.trim().toLowerCase()==="update"&&r.SkipOldValuesCheck===!1){const m=[];e.Fields.forEach(p=>{let I=null;p.OldValue!==null&&p.OldValue!==void 0&&(p.EntityFieldInfo.TSType===c.EntityFieldTSType.Date?I=p.OldValue.getTime().toString():p.EntityFieldInfo.TSType===c.EntityFieldTSType.Boolean?I=p.OldValue===!0?"1":"0":typeof p.OldValue!="string"?I=p.OldValue.toString():I=p.OldValue),m.push({Key:b.MapFieldName(p.CodeName),Value:I})}),n.input.OldValues___=m}if(e.TransactionGroup){const m=[{varName:"input",inputType:o+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new c.TransactionItem(e,s.Type==="create"?"Create":"Update",l,n,{mutationName:o,mutationInputTypes:m},(p,I)=>{s.EndedAt=new Date,I&&p?(s.Success=!0,s.NewValues=this.ConvertBackToMJFields(p)):(s.Success=!1,s.Message="Transaction failed")})),!0}else{const m=await this.ExecuteGQL(S,n);if(m&&m[o])return s.Success=!0,s.EndedAt=new Date,s.NewValues=this.ConvertBackToMJFields(m[o]),s.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(n){return s.Success=!1,s.EndedAt=new Date,s.Message=n.response?.errors?.length>0?n.response.errors[0].message:n.message,c.LogError(n),null}}async Load(e,t,r=null,s){try{const n={};let a="",i="";for(let h=0;h<t.KeyValuePairs.length;h++){const m=e.Fields.find(E=>E.Name.trim().toLowerCase()===t.KeyValuePairs[h].FieldName.trim().toLowerCase()).EntityFieldInfo,p=t.GetValueByIndex(h),I=m.GraphQLType;i.length>0&&(i+=", "),i+=`$${m.CodeName}: ${I}!`,a.length>0&&(a+=", ");const R=m.CodeName.startsWith("__mj_")?m.CodeName.replace("__mj_","_mj__"):m.CodeName;if(a+=`${R}: $${m.CodeName}`,m.TSType===c.EntityFieldTSType.Number){if(isNaN(t.GetValueByIndex(h)))throw new Error(`Primary Key value ${p} (${m.Name}) is not a valid number`);n[m.CodeName]=parseInt(p)}else n[m.CodeName]=p}const o=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",y=c.getGraphQLTypeNameBase(e.EntityInfo),l=u.gql`query Single${y}${o.length>0?"Full":""} (${i}) {
542
542
  ${y}(${a}) {
543
543
  ${e.Fields.filter(h=>!h.EntityFieldInfo.IsBinaryFieldType).map(h=>h.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?h.CodeName.replace("__mj_","_mj__"):h.CodeName).join(`
544
544
  `)}
545
545
  ${o}
546
546
  }
547
547
  }
548
- `,S=await this.ExecuteGQL(l,n);return S&&S[y]?this.ConvertBackToMJFields(S[y]):null}catch(n){return c.LogError(n),null}}ConvertBackToMJFields(e){return L.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 n=e.RelatedEntities[s],a=this.EntityByID(n.RelatedEntityID);let i="";n.Type.toLowerCase().trim()==="many to many"?i=`${n.RelatedEntityCodeName}_${n.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${n.RelatedEntityCodeName}_${n.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
548
+ `,S=await this.ExecuteGQL(l,n);return S&&S[y]?this.ConvertBackToMJFields(S[y]):null}catch(n){return c.LogError(n),null}}ConvertBackToMJFields(e){return b.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 n=e.RelatedEntities[s],a=this.EntityByID(n.RelatedEntityID);let i="";n.Type.toLowerCase().trim()==="many to many"?i=`${n.RelatedEntityCodeName}_${n.JoinEntityJoinField.replace(/\s/g,"")}`:i=`${n.RelatedEntityCodeName}_${n.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`
549
549
  ${i} {
550
550
  ${a.Fields.map(o=>o.CodeName).join(`
551
551
  `)}
@@ -683,7 +683,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
683
683
  OriginSessionID
684
684
  RecordData
685
685
  }
686
- }`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:d(r=>{const s=r?.cacheInvalidation;if(!s)return;if(s.OriginSessionID&&s.OriginSessionID===this.sessionId){f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${s.EntityName}" (action: ${s.Action})`);return}f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Cache invalidation received: ${s.Action} for "${s.EntityName}" from server ${s.SourceServerID?.substring(0,8)||"unknown"}`);const n={type:"remote-invalidate",entityName:s.EntityName,baseEntity:null,provider:this,payload:{primaryKeyValues:s.PrimaryKeyValues,action:s.Action,sourceServerId:s.SourceServerID,timestamp:s.Timestamp,recordData:s.RecordData}};D.MJGlobal.Instance.RaiseEvent({event:D.MJEventType.ComponentEvent,eventCode:c.BaseEntity.BaseEventCode,args:n,component:this})},"next"),error:d(r=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",r),this._cacheInvalidationSubscription=null},"error"),complete:d(()=>{console.log("[GraphQLDataProvider] Cache invalidation subscription completed, will re-establish on next WebSocket creation"),this._cacheInvalidationSubscription=null},"complete")})}UnsubscribeFromCacheInvalidation(){this._cacheInvalidationSubscription&&(this._cacheInvalidationSubscription.unsubscribe(),this._cacheInvalidationSubscription=null)}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;const s=`query FindISAChildEntity($EntityName: String!, $RecordID: String!) {
686
+ }`,t=this.subscribe(e);this._cacheInvalidationSubscription=t.subscribe({next:d(r=>{const s=r?.cacheInvalidation;if(!s)return;if(s.OriginSessionID&&s.OriginSessionID===this.sessionId){f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Skipping self-originated cache invalidation for "${s.EntityName}" (action: ${s.Action})`);return}f.VerboseCacheInvalidationLogging&&console.debug(`[GraphQLDataProvider] Cache invalidation received: ${s.Action} for "${s.EntityName}" from server ${s.SourceServerID?.substring(0,8)||"unknown"}`);const n={type:"remote-invalidate",entityName:s.EntityName,baseEntity:null,provider:this,payload:{primaryKeyValues:s.PrimaryKeyValues,action:s.Action,sourceServerId:s.SourceServerID,timestamp:s.Timestamp,recordData:s.RecordData}};D.MJGlobal.Instance.RaiseEvent({event:D.MJEventType.ComponentEvent,eventCode:c.BaseEntity.BaseEventCode,args:n,component:this})},"next"),error:d(r=>{console.error("[GraphQLDataProvider] Cache invalidation subscription error:",r),this._cacheInvalidationSubscription=null},"error"),complete:d(()=>{console.log("[GraphQLDataProvider] Cache invalidation subscription completed, will re-establish on next WebSocket creation"),this._cacheInvalidationSubscription=null},"complete")})}static{this.ClientMemberRefreshWindowMinMs=15e3}static{this.ClientMemberRefreshWindowJitterMs=3e4}get MetadataMemberRefreshDelayMs(){return f.ClientMemberRefreshWindowMinMs+Math.random()*f.ClientMemberRefreshWindowJitterMs}get MetadataMemberRefreshRearmsOnNewEvents(){return!1}async RefreshAfterMetadataMemberChange(){return this.RefreshIfNeeded(void 0,!0)}UnsubscribeFromCacheInvalidation(){this.CancelPendingMetadataMemberRefresh(),this._cacheInvalidationSubscription&&(this._cacheInvalidationSubscription.unsubscribe(),this._cacheInvalidationSubscription=null)}async FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;const s=`query FindISAChildEntity($EntityName: String!, $RecordID: String!) {
687
687
  FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {
688
688
  Success
689
689
  ChildEntityName
@@ -1153,7 +1153,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1153
1153
  ErrorMessage
1154
1154
  }
1155
1155
  }
1156
- `,s={EntityNames:e,UserEmail:t},n=await this.Client.request(r,s);if(n?.CheckEntityPermissionsSystemUser){const a=n.CheckEntityPermissionsSystemUser;return{Success:a.Success,Results:(a.Results||[]).map(i=>({EntityName:i.EntityName,CanRead:i.CanRead})),ErrorMessage:a.ErrorMessage}}return{Success:!1,Results:[],ErrorMessage:"Invalid response from server"}}catch(r){return c.LogError(`GraphQLSystemUserClient::CheckEntityPermissionsSystemUser - Error checking entity permissions - ${r}`),{Success:!1,Results:[],ErrorMessage:r instanceof Error?r.message:String(r)}}}}class Ce{static{d(this,"GetDataOutput")}}class we{static{d(this,"SimpleRemoteEntityOutput")}}class $e{static{d(this,"SimpleRemoteEntity")}}class Pe{static{d(this,"SimpleRemoteEntityField")}}class Le{static{d(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),n=this.createActionVariables(e,s,r),a=await this.executeActionMutation(n);return this.processActionResult(a,t)}catch(s){return this.handleActionError(s,t)}}serializeActionParameters(e){if(e)return e.map(t=>{let r=t.Value;return r!=null&&typeof r=="object"&&(r=JSON.stringify(r)),{...t,Value:r}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=u.gql`
1156
+ `,s={EntityNames:e,UserEmail:t},n=await this.Client.request(r,s);if(n?.CheckEntityPermissionsSystemUser){const a=n.CheckEntityPermissionsSystemUser;return{Success:a.Success,Results:(a.Results||[]).map(i=>({EntityName:i.EntityName,CanRead:i.CanRead})),ErrorMessage:a.ErrorMessage}}return{Success:!1,Results:[],ErrorMessage:"Invalid response from server"}}catch(r){return c.LogError(`GraphQLSystemUserClient::CheckEntityPermissionsSystemUser - Error checking entity permissions - ${r}`),{Success:!1,Results:[],ErrorMessage:r instanceof Error?r.message:String(r)}}}}class Ce{static{d(this,"GetDataOutput")}}class we{static{d(this,"SimpleRemoteEntityOutput")}}class $e{static{d(this,"SimpleRemoteEntity")}}class Pe{static{d(this,"SimpleRemoteEntityField")}}class be{static{d(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),n=this.createActionVariables(e,s,r),a=await this.executeActionMutation(n);return this.processActionResult(a,t)}catch(s){return this.handleActionError(s,t)}}serializeActionParameters(e){if(e)return e.map(t=>{let r=t.Value;return r!=null&&typeof r=="object"&&(r=JSON.stringify(r)),{...t,Value:r}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=u.gql`
1157
1157
  mutation RunAction($input: RunActionInput!) {
1158
1158
  RunAction(input: $input) {
1159
1159
  Success
@@ -1170,7 +1170,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1170
1170
  ResultData
1171
1171
  }
1172
1172
  }
1173
- `;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}}}class be{static{d(this,"GraphQLListsClient")}constructor(e){this.dataProvider=e}async PreviewListDelta(e){const t=u.gql`
1173
+ `;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}}}class Le{static{d(this,"GraphQLListsClient")}constructor(e){this.dataProvider=e}async PreviewListDelta(e){const t=u.gql`
1174
1174
  query PreviewListDelta($input: ComputeDeltaInput!) {
1175
1175
  PreviewListDelta(input: $input) {
1176
1176
  ...ListDeltaFields
@@ -1183,28 +1183,28 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1183
1183
  ...ApplyResultFields
1184
1184
  }
1185
1185
  }
1186
- ${M}
1186
+ ${N}
1187
1187
  `,r=await this.dataProvider.ExecuteGQL(t,{input:{TargetListId:e.Delta.TargetListId,EntityName:e.Delta.EntityName,ToAdd:e.Delta.ToAdd,ToRemove:e.Delta.ToRemove,Unchanged:e.Delta.Unchanged,AddCount:e.Delta.Counts.Add,RemoveCount:e.Delta.Counts.Remove,UnchangedCount:e.Delta.Counts.Unchanged,SourceTotal:e.Delta.Counts.SourceTotal,TargetTotal:e.Delta.Counts.TargetTotal,DeltaToken:e.Delta.DeltaToken,ConfirmDrops:e.ConfirmDrops}});return T(r?.ApplyListDelta)}async MaterializeFromView(e,t){const r=u.gql`
1188
1188
  mutation MaterializeListFromView($viewId: String!, $options: MaterializeOptionsInput!) {
1189
1189
  MaterializeListFromView(viewId: $viewId, options: $options) {
1190
1190
  ...ApplyResultFields
1191
1191
  }
1192
1192
  }
1193
- ${M}
1193
+ ${N}
1194
1194
  `,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,options:{ListName:t.ListName,CategoryId:t.CategoryId,Description:t.Description,RememberLineage:t.RememberLineage,UseSnapshot:t.UseSnapshot,RefreshMode:t.RefreshMode}});return T(s?.MaterializeListFromView)}async AddViewResultsToList(e,t){const r=u.gql`
1195
1195
  mutation AddViewResultsToList($viewId: String!, $listId: String!) {
1196
1196
  AddViewResultsToList(viewId: $viewId, listId: $listId) {
1197
1197
  ...ApplyResultFields
1198
1198
  }
1199
1199
  }
1200
- ${M}
1200
+ ${N}
1201
1201
  `,s=await this.dataProvider.ExecuteGQL(r,{viewId:e,listId:t});return T(s?.AddViewResultsToList)}async RefreshFromSource(e){const t=u.gql`
1202
1202
  mutation RefreshListFromSource($listId: String!, $mode: String!, $confirmDrops: Boolean!) {
1203
1203
  RefreshListFromSource(listId: $listId, mode: $mode, confirmDrops: $confirmDrops) {
1204
1204
  ...ApplyResultFields
1205
1205
  }
1206
1206
  }
1207
- ${M}
1207
+ ${N}
1208
1208
  `,r=await this.dataProvider.ExecuteGQL(t,{listId:e.ListId,mode:e.Mode,confirmDrops:e.ConfirmDrops});return T(r?.RefreshListFromSource)}async ComposeLists(e){const t=u.gql`
1209
1209
  mutation ComposeLists($input: ComposeListsInput!) {
1210
1210
  ComposeLists(input: $input) {
@@ -1219,7 +1219,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1219
1219
  }
1220
1220
  }
1221
1221
  ${q}
1222
- `,r=await this.dataProvider.ExecuteGQL(t,{input:{ListID:e.ListID,Target:Ae(e.Target),PermissionLevel:e.PermissionLevel}});return Q(r?.ShareList)}async Unshare(e){const t=u.gql`
1222
+ `,r=await this.dataProvider.ExecuteGQL(t,{input:{ListID:e.ListID,Target:Me(e.Target),PermissionLevel:e.PermissionLevel}});return Q(r?.ShareList)}async Unshare(e){const t=u.gql`
1223
1223
  mutation UnshareList($permissionId: String!) {
1224
1224
  UnshareList(permissionId: $permissionId) {
1225
1225
  ...ShareResultFields
@@ -1270,7 +1270,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1270
1270
  CreatedAt
1271
1271
  }
1272
1272
  }
1273
- `;return((await this.dataProvider.ExecuteGQL(t,{listId:e}))?.ListSharesForList??[]).map(Ne)}async ListsSharedWithMe(){const e=u.gql`
1273
+ `;return((await this.dataProvider.ExecuteGQL(t,{listId:e}))?.ListSharesForList??[]).map(Ae)}async ListsSharedWithMe(){const e=u.gql`
1274
1274
  query ListsSharedWithMe {
1275
1275
  ListsSharedWithMe {
1276
1276
  ListID
@@ -1301,7 +1301,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1301
1301
  }
1302
1302
  DeltaToken
1303
1303
  }
1304
- `,M=u.gql`
1304
+ `,N=u.gql`
1305
1305
  fragment ApplyResultFields on ApplyListResultType {
1306
1306
  Success
1307
1307
  ResultCode
@@ -1320,7 +1320,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
1320
1320
  Message
1321
1321
  PermissionID
1322
1322
  }
1323
- `;function Ae(g){return g.kind==="user"?{Kind:"user",UserID:g.userId}:{Kind:"role",RoleID:g.roleId}}d(Ae,"serializeShareTarget");function Q(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ShareResult response");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,PermissionID:e.PermissionID??void 0}}d(Q,"parseShareResult");function Ne(g){const e=g,t=e.Target.Kind==="user"?{kind:"user",userId:e.Target.UserID}:{kind:"role",roleId:e.Target.RoleID};return{PermissionID:e.PermissionID,ListID:e.ListID,Target:t,PermissionLevel:e.PermissionLevel,Status:e.Status,SharedByUserID:e.SharedByUserID??null,CreatedAt:new Date(e.CreatedAt)}}d(Ne,"parseShareSummary");function U(g){switch(g.kind){case"list":return{Kind:"list",ListID:g.listId};case"view":return{Kind:"view",ViewID:g.viewId};case"adhoc":return{Kind:"adhoc",EntityName:g.entityName,ExtraFilter:g.extraFilter}}}d(U,"serializeListSource");function z(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ListDelta response from server");const e=g;return{TargetListId:e.TargetListId,EntityName:e.EntityName,ToAdd:e.ToAdd,ToRemove:e.ToRemove,Unchanged:e.Unchanged,Counts:e.Counts,Warnings:e.Warnings.map(Me),DeltaToken:e.DeltaToken}}d(z,"parseListDelta");function Me(g){let e;if(g.DetailsJSON)try{e=JSON.parse(g.DetailsJSON)}catch(t){c.LogError(`GraphQLListsClient: failed to parse warning details JSON: ${t}`)}return{Code:g.Code,Message:g.Message,Details:e}}d(Me,"parseWarning");function T(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ApplyResult response from server");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,CreatedListId:e.CreatedListId??void 0,TargetListId:e.TargetListId??void 0,Counts:e.AddedCount!=null||e.RemovedCount!=null||e.FailedCount!=null?{Added:e.AddedCount??0,Removed:e.RemovedCount??0,Failed:e.FailedCount??0}:void 0,Errors:e.Errors??void 0}}d(T,"parseApplyResult");class Te{static{d(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),r=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(r)}catch(t){return this.handleCreateAPIKeyError(t)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=u.gql`
1323
+ `;function Me(g){return g.kind==="user"?{Kind:"user",UserID:g.userId}:{Kind:"role",RoleID:g.roleId}}d(Me,"serializeShareTarget");function Q(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ShareResult response");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,PermissionID:e.PermissionID??void 0}}d(Q,"parseShareResult");function Ae(g){const e=g,t=e.Target.Kind==="user"?{kind:"user",userId:e.Target.UserID}:{kind:"role",roleId:e.Target.RoleID};return{PermissionID:e.PermissionID,ListID:e.ListID,Target:t,PermissionLevel:e.PermissionLevel,Status:e.Status,SharedByUserID:e.SharedByUserID??null,CreatedAt:new Date(e.CreatedAt)}}d(Ae,"parseShareSummary");function U(g){switch(g.kind){case"list":return{Kind:"list",ListID:g.listId};case"view":return{Kind:"view",ViewID:g.viewId};case"adhoc":return{Kind:"adhoc",EntityName:g.entityName,ExtraFilter:g.extraFilter}}}d(U,"serializeListSource");function z(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ListDelta response from server");const e=g;return{TargetListId:e.TargetListId,EntityName:e.EntityName,ToAdd:e.ToAdd,ToRemove:e.ToRemove,Unchanged:e.Unchanged,Counts:e.Counts,Warnings:e.Warnings.map(Ne),DeltaToken:e.DeltaToken}}d(z,"parseListDelta");function Ne(g){let e;if(g.DetailsJSON)try{e=JSON.parse(g.DetailsJSON)}catch(t){c.LogError(`GraphQLListsClient: failed to parse warning details JSON: ${t}`)}return{Code:g.Code,Message:g.Message,Details:e}}d(Ne,"parseWarning");function T(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ApplyResult response from server");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,CreatedListId:e.CreatedListId??void 0,TargetListId:e.TargetListId??void 0,Counts:e.AddedCount!=null||e.RemovedCount!=null||e.FailedCount!=null?{Added:e.AddedCount??0,Removed:e.RemovedCount??0,Failed:e.FailedCount??0}:void 0,Errors:e.Errors??void 0}}d(T,"parseApplyResult");class Te{static{d(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),r=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(r)}catch(t){return this.handleCreateAPIKeyError(t)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=u.gql`
1324
1324
  mutation CreateAPIKey($input: CreateAPIKeyInput!) {
1325
1325
  CreateAPIKey(input: $input) {
1326
1326
  Success
@@ -2018,5 +2018,5 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
2018
2018
  IntegrationGetConnectorCapabilities(companyIntegrationID: $companyIntegrationID) {
2019
2019
  Success Message SupportsGet SupportsCreate SupportsUpdate SupportsDelete SupportsSearch
2020
2020
  }
2021
- }`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return c.LogError(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}Object.defineProperty(exports,"gql",{enumerable:!0,get:d(function(){return u.gql},"get")}),exports.ActionItemInput=Ee,exports.ActionItemOutput=De,exports.BrowserIndexedDBStorageProvider=B,exports.BrowserStorageProviderBase=k,exports.FieldMapper=b,exports.FireAndForgetHelper=w,exports.GetDataOutput=Ce,exports.GraphQLAIClient=O,exports.GraphQLActionClient=Le,exports.GraphQLClassifyClient=Ge,exports.GraphQLClusterClient=xe,exports.GraphQLComponentRegistryClient=Qe,exports.GraphQLDataProvider=f,exports.GraphQLEncryptionClient=Te,exports.GraphQLFileStorageClient=_e,exports.GraphQLIntegrationClient=Oe,exports.GraphQLListsClient=be,exports.GraphQLLiveKitClient=Fe,exports.GraphQLProviderConfigData=me,exports.GraphQLSearchClient=Ve,exports.GraphQLSystemUserClient=ve,exports.GraphQLTestingClient=qe,exports.GraphQLTransactionGroup=V,exports.GraphQLVersionHistoryClient=Ue,exports.PACKAGE_VERSION=N,exports.RoleInput=he,exports.RolesAndUsersInput=fe,exports.SafeGraphQLError=x,exports.SanitizeGraphQLError=G,exports.SimpleRemoteEntity=$e,exports.SimpleRemoteEntityField=Pe,exports.SimpleRemoteEntityOutput=we,exports.SyncDataAction=J,exports.SyncDataResult=Re,exports.SyncRolesAndUsersResult=pe,exports.ToSafeGraphQLError=j,exports.UserInput=Ie,exports.setupGraphQLClient=Se;
2021
+ }`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return c.LogError(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}Object.defineProperty(exports,"gql",{enumerable:!0,get:d(function(){return u.gql},"get")}),exports.ActionItemInput=Ee,exports.ActionItemOutput=De,exports.BrowserIndexedDBStorageProvider=B,exports.BrowserStorageProviderBase=k,exports.FieldMapper=L,exports.FireAndForgetHelper=w,exports.GetDataOutput=Ce,exports.GraphQLAIClient=O,exports.GraphQLActionClient=be,exports.GraphQLClassifyClient=Ge,exports.GraphQLClusterClient=xe,exports.GraphQLComponentRegistryClient=Qe,exports.GraphQLDataProvider=f,exports.GraphQLEncryptionClient=Te,exports.GraphQLFileStorageClient=_e,exports.GraphQLIntegrationClient=Oe,exports.GraphQLListsClient=Le,exports.GraphQLLiveKitClient=Fe,exports.GraphQLProviderConfigData=me,exports.GraphQLSearchClient=Ve,exports.GraphQLSystemUserClient=ve,exports.GraphQLTestingClient=qe,exports.GraphQLTransactionGroup=V,exports.GraphQLVersionHistoryClient=Ue,exports.PACKAGE_VERSION=A,exports.RoleInput=he,exports.RolesAndUsersInput=fe,exports.SafeGraphQLError=x,exports.SanitizeGraphQLError=G,exports.SimpleRemoteEntity=$e,exports.SimpleRemoteEntityField=Pe,exports.SimpleRemoteEntityOutput=we,exports.SyncDataAction=J,exports.SyncDataResult=Re,exports.SyncRolesAndUsersResult=pe,exports.ToSafeGraphQLError=j,exports.UserInput=Ie,exports.setupGraphQLClient=Se;
2022
2022
  //# sourceMappingURL=index.cjs.map