@memberjunction/graphql-dataprovider 2.121.0 → 2.122.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 +56 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -16
- package/dist/index.d.mts +119 -16
- package/dist/index.mjs +53 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var fe=Object.defineProperty;var S=(
|
|
1
|
+
"use strict";var fe=Object.defineProperty;var S=(E,e)=>fe(E,"name",{value:e,configurable:!0});var R,m=require("graphql-request"),u=require("@memberjunction/core"),ge=require("@memberjunction/core-entities"),Re=require("@tempfix/idb"),$=require("rxjs"),Ie=require("graphql-ws"),Ee=require("uuid"),w=require("@memberjunction/global");const j=class j{constructor(){this._fieldMap={__mj_CreatedAt:"_mj__CreatedAt",__mj_UpdatedAt:"_mj__UpdatedAt",__mj_DeletedAt:"_mj__DeletedAt"}}MapFields(e){if(e)for(const t in e)t in this._fieldMap&&(e[this._fieldMap[t]]=e[t],delete e[t]);return e}MapFieldName(e){return this._fieldMap[e]??e}ReverseMapFieldName(e){return Object.entries(this._fieldMap).find(([t,r])=>r===e)?.[0]??e}ReverseMapFields(e){const t=Object.fromEntries(Object.entries(this._fieldMap).map(([r,s])=>[s,r]));for(const r in e)r in t&&(e[t[r]]=e[r],delete e[r]);return e}};S(j,"FieldMapper");let v=j;const W=class W extends u.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
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
}
|
|
151
151
|
`,this._currentUserQuery=m.gql`query CurrentUserAndRoles {
|
|
152
152
|
${this._innerCurrentUserQueryString}
|
|
153
|
-
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=30*60*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=5*60*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=10*60*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,R._instance||(R._instance=this)}static get Instance(){return R._instance}get ConfigData(){return this._configData}sanitizeGraphQLName(e){if(!e||e.length===0)return"";let t=e.replace(/[^A-Za-z0-9_]/g,"");return t.startsWith("__")&&(t=t.substring(2)),t=t.replace(/_/g,""),t.length===0||/^[0-9]/.test(t)?"_"+t:t}getGraphQLTypeNameBase(e){const t=e.SchemaName.trim().toLowerCase()===R.MJ_CORE_SCHEMA.trim().toLowerCase()?"MJ":this.sanitizeGraphQLName(e.SchemaName),r=this.sanitizeGraphQLName(e.BaseTable);return`${t}${r}`}get AI(){return this._aiClient||(this._aiClient=new C(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return
|
|
153
|
+
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=30*60*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=5*60*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=10*60*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,R._instance||(R._instance=this)}static get Instance(){return R._instance}get ConfigData(){return this._configData}sanitizeGraphQLName(e){if(!e||e.length===0)return"";let t=e.replace(/[^A-Za-z0-9_]/g,"");return t.startsWith("__")&&(t=t.substring(2)),t=t.replace(/_/g,""),t.length===0||/^[0-9]/.test(t)?"_"+t:t}getGraphQLTypeNameBase(e){const t=e.SchemaName.trim().toLowerCase()===R.MJ_CORE_SCHEMA.trim().toLowerCase()?"MJ":this.sanitizeGraphQLName(e.SchemaName),r=this.sanitizeGraphQLName(e.BaseTable);return`${t}${r}`}get AI(){return this._aiClient||(this._aiClient=new C(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return Ee.v4()}get LocalStoragePrefix(){if(this._configData===void 0||this._configData.URL===void 0)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.GetItem(t)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const t=this.LocalStorageProvider;if(t){const r=this.LocalStoragePrefix+"sessionId";await t.SetItem(r,e)}}catch{}}async GetPreferredUUID(e){const t=await this.GetStoredSessionID();return e||!t?this.GenerateUUID():t}async Config(e,t,r,s){try{return r?(this._configData=e,this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey),await this.SaveStoredSessionID(this._sessionId)):(R.Instance._configData=e,R.Instance._sessionId===void 0&&(R.Instance._sessionId=await this.GetPreferredUUID(s)),R.Instance._client||(R.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,R.Instance._sessionId,e.MJAPIKey)),await R.Instance.SaveStoredSessionID(R.Instance._sessionId)),super.Config(e)}catch(n){throw u.LogError(n),n}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const t=this.ConvertBackToMJFields(e.CurrentUser),r=t.UserRoles_UserIDArray.map(s=>this.ConvertBackToMJFields(s));return t.UserRoles_UserIDArray=r,new u.UserInfo(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=m.gql`
|
|
154
154
|
query GetReportDataQuery ($ReportID: String!) {
|
|
155
155
|
GetReportData(ReportID: $ReportID) {
|
|
156
156
|
Success
|
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
Success
|
|
195
195
|
ErrorMessage
|
|
196
196
|
}
|
|
197
|
-
}`,y=await this.ExecuteGQL(I,{input:n});if(y&&y[r]){const l=y[r].Results;if(l&&l.length>0){const f=i.Fields.filter(h=>h.CodeName!==h.Name&&h.CodeName!==void 0);l.forEach(h=>{this.ConvertBackToMJFields(h),f.forEach(
|
|
197
|
+
}`,y=await this.ExecuteGQL(I,{input:n});if(y&&y[r]){const l=y[r].Results;if(l&&l.length>0){const f=i.Fields.filter(h=>h.CodeName!==h.Name&&h.CodeName!==void 0);l.forEach(h=>{this.ConvertBackToMJFields(h),f.forEach(D=>{h[D.Name]=h[D.CodeName]})})}const d=y[r];return await this.PostProcessRunView(d,e,t),d}}else throw"No parameters passed to RunView";return null}catch(r){throw u.LogError(r),r}}async RunViews(e,t){await this.PreProcessRunViews(e,t);try{let r=[],s=[],n=[];for(const i of e){let c="",p="";const g={};let I=null,y=null;if(i.ViewEntity)y=i.ViewEntity,I=y.Get("Entity");else{const{entityName:h,v:D}=await this.getEntityNameAndUserView(i,t);y=D,I=h}const l=this.Entities.find(h=>h.Name===I);if(!l)throw new Error(`Entity ${I} not found in metadata`);s.push(l);let d=!1;const f=this.getGraphQLTypeNameBase(l);i.ViewID?(c=`Run${f}ViewByID`,p="RunViewByIDInput",g.ViewID=i.ViewID):i.ViewName?(c=`Run${f}ViewByName`,p="RunViewByNameInput",g.ViewName=i.ViewName):(d=!0,c=`Run${f}DynamicView`,p="RunDynamicViewInput",g.EntityName=i.EntityName),g.ExtraFilter=i.ExtraFilter||"",g.OrderBy=i.OrderBy||"",g.UserSearchString=i.UserSearchString||"",g.Fields=i.Fields,g.IgnoreMaxRows=i.IgnoreMaxRows||!1,i.MaxRows!==void 0&&(g.MaxRows=i.MaxRows),i.StartRow!==void 0&&(g.StartRow=i.StartRow),g.ForceAuditLog=i.ForceAuditLog||!1,g.ResultType=i.ResultType||"simple",i.AuditLogDescription&&i.AuditLogDescription.length>0&&(g.AuditLogDescription=i.AuditLogDescription),d||(g.ExcludeUserViewRunID=i.ExcludeUserViewRunID||"",g.ExcludeDataFromAllPriorViewRuns=i.ExcludeDataFromAllPriorViewRuns||!1,g.OverrideExcludeFilter=i.OverrideExcludeFilter||"",g.SaveViewResults=i.SaveViewResults||!1),r.push(g),n.push(...this.getViewRunTimeFieldList(l,y,i,d))}const a=m.gql`
|
|
198
198
|
query RunViewsQuery ($input: [RunViewGenericInput!]!) {
|
|
199
199
|
RunViews(input: $input) {
|
|
200
200
|
Results {
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
`,y=m.gql`mutation ${g} (${i}, $options___: DeleteOptionsInput!) {
|
|
289
289
|
${I}
|
|
290
290
|
}
|
|
291
|
-
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new u.TransactionItem(e,"Delete",I,n,{mutationName:g,mutationInputTypes:a},(l,d)=>{if(s.EndedAt=new Date,d&&l){let f=!0;for(const h of e.PrimaryKey.KeyValuePairs)h.Value!==l[h.FieldName]&&(f=!1);f?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,n);if(l&&l[g]){const d=l[g];for(let f of e.PrimaryKey.KeyValuePairs){let h=d[f.FieldName],
|
|
291
|
+
`;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new u.TransactionItem(e,"Delete",I,n,{mutationName:g,mutationInputTypes:a},(l,d)=>{if(s.EndedAt=new Date,d&&l){let f=!0;for(const h of e.PrimaryKey.KeyValuePairs)h.Value!==l[h.FieldName]&&(f=!1);f?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,n);if(l&&l[g]){const d=l[g];for(let f of e.PrimaryKey.KeyValuePairs){let h=d[f.FieldName],D=f.Value;if(typeof D=="number"&&(D=D.toString()),typeof h=="number"&&(h=h.toString()),D!==h)throw new Error(`Primary key value mismatch in server Delete response. Field: ${f.FieldName}, Original: ${D}, Returned: ${h}`)}return s.Success=!0,s.EndedAt=new Date,!0}else throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(n){return s.EndedAt=new Date,s.Success=!1,s.Message=n.response?.errors?.length>0?n.response.errors[0].message:n.message,u.LogError(n),!1}}async GetDatasetByName(e,t){const r=m.gql`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
|
|
292
292
|
GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
|
|
293
293
|
DatasetID
|
|
294
294
|
DatasetName
|
|
@@ -348,14 +348,14 @@
|
|
|
348
348
|
}
|
|
349
349
|
}`,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 u.LogError(t),t}}static async ExecuteGQL(e,t,r=!0){return R.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(s&&s.response&&s.response.errors?.length>0)if(s.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(r)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw u.LogError("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}else throw s;else throw u.LogError(s),s}}async RefreshToken(){if(this._configData.Data.RefreshTokenFunction){const e=await this._configData.Data.RefreshTokenFunction();if(e)this._configData.Token=e,this._client=this.CreateNewGraphQLClient(this._configData.URL,this._configData.Token,this._sessionId,this._configData.MJAPIKey);else throw new Error("Refresh token function returned null or undefined token")}else throw new Error("No refresh token function provided")}static async RefreshToken(){return R.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,s){const n={"x-session-id":r};return t&&(n.authorization="Bearer "+t),s&&(n["x-mj-api-key"]=s),new m.GraphQLClient(e,{headers:n})}userInfoString(){return this.infoString(new u.UserInfo(null,null))}userRoleInfoString(){return this.infoString(new u.UserRoleInfo(null))}infoString(e){let t="";const r=Object.keys(e);for(const s of r)s.startsWith("__mj_")?t+=s.replace("__mj_","_mj__")+`
|
|
350
350
|
`:s.startsWith("_")||(t+=s+`
|
|
351
|
-
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new
|
|
351
|
+
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(this._localStorageProvider=new T),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=Ie.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(([n,a])=>{const o=e-a.lastRequestedAt,i=e-a.lastEmissionAt;a.activeSubscribers===0&&o>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&i>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${n} for cleanup: activeSubscribers=${a.activeSubscribers}, timeSinceRequested=${Math.round(o/1e3)}s, timeSinceEmission=${Math.round(i/1e3)}s`),s.push(n))}),s.forEach(n=>{const a=this._pushStatusSubjects.get(n);if(a)try{a.subject.complete(),a.subscription.unsubscribe(),this._pushStatusSubjects.delete(n),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${n}`)}catch(o){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${n}:`,o)}}),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 $.Observable(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const n=s.subscribe({query:e,variables:t},{next:a=>{r.next(a.data)},error:a=>{r.error(a)},complete:()=>{r.complete()}});return()=>{this._activeSubscriptionCount--,n()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new $.Observable(i=>{r.activeSubscribers++;const c=r.subject.subscribe(i);return()=>{const p=this._pushStatusSubjects.get(e);p&&p.activeSubscribers>0&&p.activeSubscribers--,c.unsubscribe()}});const s=m.gql`subscription StatusUpdates($sessionId: String!) {
|
|
352
352
|
statusUpdates(sessionId: $sessionId) {
|
|
353
353
|
date
|
|
354
354
|
message
|
|
355
355
|
sessionId
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
`,n=new $.Subject,a=this.getOrCreateWSClient(),o=new $.Subscription;return o.add(new $.Observable(i=>{const c=a.subscribe({query:s,variables:{sessionId:e}},{next:p=>{const g=this._pushStatusSubjects.get(e);g&&(g.lastEmissionAt=Date.now()),i.next(p.data.statusUpdates.message)},error:p=>{i.error(p)},complete:()=>{i.complete()}});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,c()}}).subscribe({next:i=>n.next(i),error:i=>{n.error(i),this._pushStatusSubjects.delete(e)},complete:()=>{n.complete(),this._pushStatusSubjects.delete(e)}})),this._pushStatusSubjects.set(e,{subject:n,subscription:o,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new $.Observable(i=>{const c=this._pushStatusSubjects.get(e);c&&c.activeSubscribers++;const p=n.subscribe(i);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()}},S(R,"_GraphQLDataProvider"),R);pe.MJ_CORE_SCHEMA="__mj";let Se=pe;const X=class X{constructor(){this._localStorage={}}async GetItem(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)?t(this._localStorage[e]):t(null)})}async SetItem(e,t){return new Promise(r=>{this._localStorage[e]=t,r()})}async Remove(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],t()})}};S(X,"BrowserStorageProviderBase");let
|
|
358
|
+
`,n=new $.Subject,a=this.getOrCreateWSClient(),o=new $.Subscription;return o.add(new $.Observable(i=>{const c=a.subscribe({query:s,variables:{sessionId:e}},{next:p=>{const g=this._pushStatusSubjects.get(e);g&&(g.lastEmissionAt=Date.now()),i.next(p.data.statusUpdates.message)},error:p=>{i.error(p)},complete:()=>{i.complete()}});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,c()}}).subscribe({next:i=>n.next(i),error:i=>{n.error(i),this._pushStatusSubjects.delete(e)},complete:()=>{n.complete(),this._pushStatusSubjects.delete(e)}})),this._pushStatusSubjects.set(e,{subject:n,subscription:o,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new $.Observable(i=>{const c=this._pushStatusSubjects.get(e);c&&c.activeSubscribers++;const p=n.subscribe(i);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()}},S(R,"_GraphQLDataProvider"),R);pe.MJ_CORE_SCHEMA="__mj";let Se=pe;const X=class X{constructor(){this._localStorage={}}async GetItem(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)?t(this._localStorage[e]):t(null)})}async SetItem(e,t){return new Promise(r=>{this._localStorage[e]=t,r()})}async Remove(e){return new Promise(t=>{this._localStorage.hasOwnProperty(e)&&delete this._localStorage[e],t()})}};S(X,"BrowserStorageProviderBase");let L=X;const De="MJ_Metadata",P="Metadata_KVPairs",Z=class Z extends L{constructor(){super(),this.dbPromise=Re.openDB(De,1,{upgrade(e){e.objectStoreNames.contains(P)||e.createObjectStore(P)}})}async setItem(e,t){const s=(await this.dbPromise).transaction(P,"readwrite");await s.objectStore(P).put(t,e),await s.done}async getItem(e){return await(await this.dbPromise).transaction(P).objectStore(P).get(e)}async remove(e){const r=(await this.dbPromise).transaction(P,"readwrite");await r.objectStore(P).delete(e),await r.done}};S(Z,"BrowserIndexedDBStorageProvider");let T=Z;async function we(E){const e=new Se;return u.SetProvider(e),await e.Config(E),w.MJGlobal.Instance.RaiseEvent({event:w.MJEventType.LoggedIn,eventCode:null,component:this,args:null}),e}S(we,"setupGraphQLClient");const Y=class Y{};S(Y,"SyncRolesAndUsersResult");let V=Y;const ee=class ee{};S(ee,"RoleInput");let G=ee;const te=class te{};S(te,"UserInput");let x=te;const re=class re{};S(re,"RolesAndUsersInput");let M=re;var he=(E=>(E.Create="Create",E.Update="Update",E.CreateOrUpdate="CreateOrUpdate",E.Delete="Delete",E.DeleteWithFilter="DeleteWithFilter",E))(he||{});const se=class se{};S(se,"ActionItemInput");let A=se;const ne=class ne{constructor(){this.Results=[]}};S(ne,"SyncDataResult");let F=ne;const ae=class ae{};S(ae,"ActionItemOutput");let Q=ae;const ie=class ie{get Client(){return this._client}constructor(e,t,r,s){const n={"x-session-id":r};this._sessionId=r,t&&(n.authorization="Bearer "+t),s&&(n["x-mj-api-key"]=s),this._client=new m.GraphQLClient(e,{headers:n})}async GetData(e,t){try{const s=await this.Client.request(`query GetData($input: GetDataInputType!) {
|
|
359
359
|
GetData(input: $input) {
|
|
360
360
|
Success
|
|
361
361
|
ErrorMessages
|
|
@@ -509,86 +509,118 @@
|
|
|
509
509
|
CreateQuerySystemUser(input: $input) {
|
|
510
510
|
Success
|
|
511
511
|
ErrorMessage
|
|
512
|
-
|
|
512
|
+
ID
|
|
513
|
+
Name
|
|
514
|
+
Description
|
|
515
|
+
CategoryID
|
|
516
|
+
Category
|
|
517
|
+
SQL
|
|
518
|
+
Status
|
|
519
|
+
QualityRank
|
|
520
|
+
EmbeddingVector
|
|
521
|
+
EmbeddingModelID
|
|
522
|
+
EmbeddingModelName
|
|
513
523
|
Fields {
|
|
514
524
|
ID
|
|
515
525
|
QueryID
|
|
516
526
|
Name
|
|
517
527
|
Description
|
|
518
|
-
Type
|
|
519
528
|
Sequence
|
|
520
529
|
SQLBaseType
|
|
521
530
|
SQLFullType
|
|
531
|
+
SourceEntityID
|
|
532
|
+
SourceEntity
|
|
533
|
+
SourceFieldName
|
|
522
534
|
IsComputed
|
|
523
535
|
ComputationDescription
|
|
536
|
+
IsSummary
|
|
537
|
+
SummaryDescription
|
|
524
538
|
}
|
|
525
539
|
Parameters {
|
|
526
540
|
ID
|
|
527
541
|
QueryID
|
|
528
542
|
Name
|
|
543
|
+
Description
|
|
529
544
|
Type
|
|
530
|
-
DefaultValue
|
|
531
|
-
Comments
|
|
532
545
|
IsRequired
|
|
546
|
+
DefaultValue
|
|
547
|
+
SampleValue
|
|
548
|
+
ValidationFilters
|
|
533
549
|
}
|
|
534
550
|
Entities {
|
|
535
551
|
ID
|
|
536
552
|
QueryID
|
|
537
553
|
EntityID
|
|
538
|
-
|
|
554
|
+
Entity
|
|
539
555
|
}
|
|
540
556
|
Permissions {
|
|
541
557
|
ID
|
|
542
558
|
QueryID
|
|
543
559
|
RoleID
|
|
544
|
-
|
|
560
|
+
Role
|
|
545
561
|
}
|
|
546
562
|
}
|
|
547
|
-
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser
|
|
563
|
+
}`,{input:e});return r&&r.CreateQuerySystemUser?r.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(t){return u.LogError(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async UpdateQuery(e){try{const r=await this.Client.request(`mutation UpdateQuerySystemUser($input: UpdateQuerySystemUserInput!) {
|
|
548
564
|
UpdateQuerySystemUser(input: $input) {
|
|
549
565
|
Success
|
|
550
566
|
ErrorMessage
|
|
551
|
-
|
|
567
|
+
ID
|
|
568
|
+
Name
|
|
569
|
+
Description
|
|
570
|
+
CategoryID
|
|
571
|
+
Category
|
|
572
|
+
SQL
|
|
573
|
+
Status
|
|
574
|
+
QualityRank
|
|
575
|
+
EmbeddingVector
|
|
576
|
+
EmbeddingModelID
|
|
577
|
+
EmbeddingModelName
|
|
552
578
|
Fields {
|
|
553
579
|
ID
|
|
554
580
|
QueryID
|
|
555
581
|
Name
|
|
556
582
|
Description
|
|
557
|
-
Type
|
|
558
583
|
Sequence
|
|
559
584
|
SQLBaseType
|
|
560
585
|
SQLFullType
|
|
586
|
+
SourceEntityID
|
|
587
|
+
SourceEntity
|
|
588
|
+
SourceFieldName
|
|
561
589
|
IsComputed
|
|
562
590
|
ComputationDescription
|
|
591
|
+
IsSummary
|
|
592
|
+
SummaryDescription
|
|
563
593
|
}
|
|
564
594
|
Parameters {
|
|
565
595
|
ID
|
|
566
596
|
QueryID
|
|
567
597
|
Name
|
|
598
|
+
Description
|
|
568
599
|
Type
|
|
569
|
-
DefaultValue
|
|
570
|
-
Comments
|
|
571
600
|
IsRequired
|
|
601
|
+
DefaultValue
|
|
602
|
+
SampleValue
|
|
603
|
+
ValidationFilters
|
|
572
604
|
}
|
|
573
605
|
Entities {
|
|
574
606
|
ID
|
|
575
607
|
QueryID
|
|
576
608
|
EntityID
|
|
577
|
-
|
|
578
|
-
Sequence
|
|
609
|
+
Entity
|
|
579
610
|
}
|
|
580
611
|
Permissions {
|
|
581
612
|
ID
|
|
582
613
|
QueryID
|
|
583
614
|
RoleID
|
|
584
|
-
|
|
615
|
+
Role
|
|
585
616
|
}
|
|
586
617
|
}
|
|
587
|
-
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser
|
|
618
|
+
}`,{input:e});return r&&r.UpdateQuerySystemUser?r.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(t){return u.LogError(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${t}`),{Success:!1,ErrorMessage:t.toString()}}}async DeleteQuery(e,t){try{if(!e||e.trim()==="")return u.LogError("GraphQLSystemUserClient::DeleteQuery - Invalid query ID: ID cannot be null or empty"),{Success:!1,ErrorMessage:"Invalid query ID: ID cannot be null or empty"};const r=`mutation DeleteQuerySystemResolver($ID: String!, $options: DeleteOptionsInput) {
|
|
588
619
|
DeleteQuerySystemResolver(ID: $ID, options: $options) {
|
|
589
620
|
Success
|
|
590
621
|
ErrorMessage
|
|
591
|
-
|
|
622
|
+
ID
|
|
623
|
+
Name
|
|
592
624
|
}
|
|
593
625
|
}`,s={ID:e};t!==void 0&&(s.options=t);const n=await this.Client.request(r,s);return n&&n.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){return u.LogError(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${r}`),{Success:!1,ErrorMessage:r.toString()}}}async RunAIPrompt(e){try{const t=m.gql`
|
|
594
626
|
query RunAIPromptSystemUser(
|
|
@@ -714,7 +746,7 @@
|
|
|
714
746
|
error
|
|
715
747
|
}
|
|
716
748
|
}
|
|
717
|
-
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,s);if(!n?.EmbedTextSystemUser)return{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const a=n.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?a.embeddings:a.embeddings[0],modelName:a.modelName,vectorDimensions:a.vectorDimensions,error:a.error}}catch(t){return u.LogError(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}};S(ie,"GraphQLSystemUserClient");let
|
|
749
|
+
`,s={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,s);if(!n?.EmbedTextSystemUser)return{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const a=n.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?a.embeddings:a.embeddings[0],modelName:a.modelName,vectorDimensions:a.vectorDimensions,error:a.error}}catch(t){return u.LogError(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}};S(ie,"GraphQLSystemUserClient");let U=ie;const oe=class oe{};S(oe,"GetDataOutput");let q=oe;const ue=class ue{};S(ue,"SimpleRemoteEntityOutput");let _=ue;const ce=class ce{};S(ce,"SimpleRemoteEntity");let O=ce;const le=class le{};S(le,"SimpleRemoteEntityField");let B=le;const de=class de{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=m.gql`
|
|
718
750
|
mutation RunAction($input: RunActionInput!) {
|
|
719
751
|
RunAction(input: $input) {
|
|
720
752
|
Success
|
|
@@ -855,5 +887,5 @@
|
|
|
855
887
|
error
|
|
856
888
|
}
|
|
857
889
|
}
|
|
858
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return u.LogError(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}};S(me,"GraphQLComponentRegistryClient");let J=me;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return m.gql}}),exports.ActionItemInput=
|
|
890
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return u.LogError(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}};S(me,"GraphQLComponentRegistryClient");let J=me;Object.defineProperty(exports,"gql",{enumerable:!0,get:function(){return m.gql}}),exports.ActionItemInput=A,exports.ActionItemOutput=Q,exports.FieldMapper=v,exports.GetDataOutput=q,exports.GraphQLAIClient=C,exports.GraphQLActionClient=k,exports.GraphQLComponentRegistryClient=J,exports.GraphQLDataProvider=Se,exports.GraphQLProviderConfigData=b,exports.GraphQLSystemUserClient=U,exports.GraphQLTestingClient=K,exports.GraphQLTransactionGroup=N,exports.RoleInput=G,exports.RolesAndUsersInput=M,exports.SimpleRemoteEntity=O,exports.SimpleRemoteEntityField=B,exports.SimpleRemoteEntityOutput=_,exports.SyncDataAction=he,exports.SyncDataResult=F,exports.SyncRolesAndUsersResult=V,exports.UserInput=x,exports.setupGraphQLClient=we;
|
|
859
891
|
//# sourceMappingURL=index.cjs.map
|