@memberjunction/graphql-dataprovider 5.22.0 → 5.23.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 +51 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +56 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +63 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});import{gql as c,GraphQLClient as L}from"graphql-request";import{gql as
|
|
1
|
+
var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});import{gql as c,GraphQLClient as L}from"graphql-request";import{gql as Xe}from"graphql-request";import{TransactionGroupBase as H,TransactionResult as X,LogError as l,LogStatus as T,LogErrorEx as A,ProviderBase as Y,UserInfo as F,getGraphQLTypeNameBase as N,ProviderType as Z,BaseEntityResult as Q,EntityFieldTSType as b,TransactionItem as U,CompositeKey as ee,UserRoleInfo as te,InMemoryLocalStorageProvider as se,BaseEntity as re,ProviderConfigDataBase as ne,SetProvider as ae,StartupManager as oe,IsPlatformSQL as ie,IsVerboseLoggingEnabled as ce}from"@memberjunction/core";import{SafeJSONParse as C,CleanAndParseJSON as ue,GetGlobalObjectStore as G,UUIDsEqual as le,MJGlobal as V,MJEventType as _}from"@memberjunction/global";import{ViewInfo as q}from"@memberjunction/core-entities";import{Observable as x,Subject as de,Subscription as ye}from"rxjs";import{createClient as me}from"graphql-ws";import{v4 as ge}from"uuid";import{openDB as pe}from"@tempfix/idb";class w{static{g(this,"FieldMapper")}static{this.DB_PREFIX="__mj_"}static{this.GQL_PREFIX="_mj__"}constructor(){}MapFields(e){if(e)for(const t in e){const s=this.MapFieldName(t);s!==t&&(e[s]=e[t],delete e[t])}return e}MapFieldName(e){return e.startsWith(w.DB_PREFIX)?w.GQL_PREFIX+e.substring(w.DB_PREFIX.length):e}ReverseMapFieldName(e){return e.startsWith(w.GQL_PREFIX)?w.DB_PREFIX+e.substring(w.GQL_PREFIX.length):e}ReverseMapFields(e){for(const t in e){const s=this.ReverseMapFieldName(t);s!==t&&(e[s]=e[t],delete e[t])}return e}}class O extends H{static{g(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=c`
|
|
2
2
|
mutation ExecuteTransactionGroup($group: TransactionInputType!) {
|
|
3
3
|
ExecuteTransactionGroup(group: $group) {
|
|
4
4
|
Success
|
|
@@ -6,7 +6,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
6
6
|
ResultsJSON
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,t=[];for(const n of this.PendingTransactions)t.push({EntityName:n.BaseEntity.EntityInfo.Name,EntityObjectJSON:await n.BaseEntity.GetDataObjectJSON(),OperationType:n.OperationType});const s={group:{Items:t,Variables:this.Variables.map(n=>({Name:n.Name,ItemIndex:this.MapVariableEntityObjectToPosition(n),FieldName:n.FieldName,Type:n.Type}))}},r=await this._provider.ExecuteGQL(e,s);if(r&&r.ExecuteTransactionGroup){const n=r.ExecuteTransactionGroup,a=[];for(let i=0;i<this.PendingTransactions.length;i++){const o=n.ResultsJSON[i],u=C(o),d=this.PendingTransactions[i];a.push(new X(d,u,u!==null))}return a}else throw new Error("Failed to execute transaction group")}}const
|
|
9
|
+
`,t=[];for(const n of this.PendingTransactions)t.push({EntityName:n.BaseEntity.EntityInfo.Name,EntityObjectJSON:await n.BaseEntity.GetDataObjectJSON(),OperationType:n.OperationType});const s={group:{Items:t,Variables:this.Variables.map(n=>({Name:n.Name,ItemIndex:this.MapVariableEntityObjectToPosition(n),FieldName:n.FieldName,Type:n.Type}))}},r=await this._provider.ExecuteGQL(e,s);if(r&&r.ExecuteTransactionGroup){const n=r.ExecuteTransactionGroup,a=[];for(let i=0;i<this.PendingTransactions.length;i++){const o=n.ResultsJSON[i],u=C(o),d=this.PendingTransactions[i];a.push(new X(d,u,u!==null))}return a}else throw new Error("Failed to execute transaction group")}}const Se=900*1e3;class P{static{g(this,"FireAndForgetHelper")}static async Execute(e){const t=e.operationLabel??e.mutationFieldName;let s,r;try{const{promise:n,resolve:a,reject:i}=P.createCompletionPromise();r=P.setupTimeout(i,e.timeoutMs,e.timeoutErrorMessage),s=P.subscribeToPubSub(e,a,r);const o=await P.executeMutation(e);if(!e.validateAck(o)){r&&clearTimeout(r);const u=o?.errorMessage??"Server rejected the request";return l(`[FireAndForget:${t}] Server rejected: ${u}`),e.createErrorResult(u)}return T(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await n}catch(n){throw r&&clearTimeout(r),l(`[FireAndForget:${t}] Error: ${n.message}`),n}finally{r&&clearTimeout(r),s&&s.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((r,n)=>{e=r,t=n}),resolve:e,reject:t}}static setupTimeout(e,t,s){const r=t??Se,n=s??"The operation may still be running on the server but the client timed out after 15 minutes. Please refresh the page to check the latest status.";return setTimeout(()=>{e(new Error(n))},r)}static subscribeToPubSub(e,t,s){const r=e.dataProvider.sessionId,n=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(r).subscribe(a=>{try{const i=JSON.parse(a);e.onMessage&&e.onMessage(i),e.isCompletionEvent(i)&&(clearTimeout(s),T(`[FireAndForget:${n}] Completion event received`),t(e.extractResult(i)))}catch(i){console.error(`[FireAndForget:${n}] Failed to parse PubSub message:`,i)}})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}}class k{static{g(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=c`
|
|
10
10
|
mutation RunAIPrompt(
|
|
11
11
|
$promptId: String!,
|
|
12
12
|
$data: String,
|
|
@@ -65,7 +65,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
65
65
|
chatResult
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,s=this.preparePromptVariables(e),r=await this._dataProvider.ExecuteGQL(t,s);return this.processPromptResult(r)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let s,r,n;try{t.parsedResult&&(s=
|
|
68
|
+
`,s=this.preparePromptVariables(e),r=await this._dataProvider.ExecuteGQL(t,s);return this.processPromptResult(r)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let s,r,n;try{t.parsedResult&&(s=ue(t.parsedResult))}catch{s=t.parsedResult}try{t.validationResult&&(r=JSON.parse(t.validationResult))}catch{r=t.validationResult}try{t.chatResult&&(n=JSON.parse(t.chatResult))}catch{n=t.chatResult}return{success:t.success,output:t.output,parsedResult:s,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:r,chatResult:n}}handlePromptError(e){const t=e;return l(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,s){try{const r=this.buildRunAIAgentMutation(),n=this.prepareAgentVariables(e,t,s);return n.fireAndForget=!0,await P.Execute({dataProvider:this._dataProvider,mutation:r,variables:n,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:g(a=>a?.success===!0,"validateAck"),isCompletionEvent:g(a=>this.isAgentCompletionEvent(a),"isCompletionEvent"),extractResult:g(a=>this.extractAgentResult(a),"extractResult"),onMessage:e.onProgress?a=>this.forwardAgentProgress(a,e.onProgress):void 0,createErrorResult:g(a=>this.createAgentErrorResult(a),"createErrorResult")})}catch(r){return this.handleAgentError(r)}}buildRunAIAgentMutation(){return c`
|
|
69
69
|
mutation RunAIAgent(
|
|
70
70
|
$agentId: String!,
|
|
71
71
|
$messages: String!,
|
|
@@ -183,7 +183,16 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
183
183
|
error
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
`,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this._dataProvider.ExecuteGQL(t,r);if(!n?.EmbedText)throw new Error("Invalid response from server");const a=n.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?a.embeddings:a.embeddings[0],modelName:a.modelName,vectorDimensions:a.vectorDimensions,error:a.error}}catch(t){const s=t;return l(`Error generating embeddings: ${s}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:s.message||"Unknown error occurred"}}}async
|
|
186
|
+
`,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this._dataProvider.ExecuteGQL(t,r);if(!n?.EmbedText)throw new Error("Invalid response from server");const a=n.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?a.embeddings:a.embeddings[0],modelName:a.modelName,vectorDimensions:a.vectorDimensions,error:a.error}}catch(t){const s=t;return l(`Error generating embeddings: ${s}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:s.message||"Unknown error occurred"}}}async RunAutotagPipeline(){try{const e=c`
|
|
187
|
+
mutation RunAutotagPipeline {
|
|
188
|
+
RunAutotagPipeline {
|
|
189
|
+
Success
|
|
190
|
+
Status
|
|
191
|
+
ErrorMessage
|
|
192
|
+
PipelineRunID
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
`,t=await this._dataProvider.ExecuteGQL(e,{});if(!t?.RunAutotagPipeline)throw new Error("Invalid response from server");return t.RunAutotagPipeline}catch(e){const t=e;return l("GraphQLAIClient.RunAutotagPipeline failed",void 0,t),{Success:!1,Status:"Error",ErrorMessage:t.message||"Unknown error"}}}async VectorizeEntity(e){try{const t=c`
|
|
187
196
|
mutation VectorizeEntity(
|
|
188
197
|
$entityDocumentID: String!,
|
|
189
198
|
$entityID: String!,
|
|
@@ -200,7 +209,29 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
200
209
|
PipelineRunID
|
|
201
210
|
}
|
|
202
211
|
}
|
|
203
|
-
`,s={entityDocumentID:e.entityDocumentID,entityID:e.entityID};e.batchSize!==void 0&&(s.batchSize=e.batchSize);const r=await this._dataProvider.ExecuteGQL(t,s);if(!r?.VectorizeEntity)throw new Error("Invalid response from server");return r.VectorizeEntity}catch(t){const s=t;return l("GraphQLAIClient.VectorizeEntity failed",void 0,s),{Success:!1,Status:"Error",ErrorMessage:s.message||"Unknown error"}}}
|
|
212
|
+
`,s={entityDocumentID:e.entityDocumentID,entityID:e.entityID};e.batchSize!==void 0&&(s.batchSize=e.batchSize);const r=await this._dataProvider.ExecuteGQL(t,s);if(!r?.VectorizeEntity)throw new Error("Invalid response from server");return r.VectorizeEntity}catch(t){const s=t;return l("GraphQLAIClient.VectorizeEntity failed",void 0,s),{Success:!1,Status:"Error",ErrorMessage:s.message||"Unknown error"}}}async FetchEntityVectors(e){try{const t=c`
|
|
213
|
+
query FetchEntityVectors(
|
|
214
|
+
$entityDocumentID: String!,
|
|
215
|
+
$maxRecords: Int,
|
|
216
|
+
$filter: String
|
|
217
|
+
) {
|
|
218
|
+
FetchEntityVectors(
|
|
219
|
+
entityDocumentID: $entityDocumentID,
|
|
220
|
+
maxRecords: $maxRecords,
|
|
221
|
+
filter: $filter
|
|
222
|
+
) {
|
|
223
|
+
Success
|
|
224
|
+
TotalCount
|
|
225
|
+
ElapsedMs
|
|
226
|
+
ErrorMessage
|
|
227
|
+
Results {
|
|
228
|
+
ID
|
|
229
|
+
Values
|
|
230
|
+
Metadata
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
`,s={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(s.maxRecords=e.maxRecords),e.filter!==void 0&&(s.filter=e.filter);const r=await this._dataProvider.ExecuteGQL(t,s);if(!r?.FetchEntityVectors)throw new Error("Invalid response from server");return r.FetchEntityVectors}catch(t){const s=t;return l("GraphQLAIClient.FetchEntityVectors failed",void 0,s),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:s.message||"Unknown error"}}}}const $="default";class B{static{g(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||$;let s=this._storage.get(t);return s||(s=new Map,this._storage.set(t,s)),s}async GetItem(e,t){return this.getCategoryMap(t||$).get(e)??null}async SetItem(e,t,s){this.getCategoryMap(s||$).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()):[]}}const he="MJ_Metadata",Ie=3,K=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],j="Metadata_KVPairs";class J extends B{static{g(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=pe(he,Ie,{upgrade(e){try{e.objectStoreNames.contains(j)&&e.deleteObjectStore(j);for(const t of K)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(t){A({error:t,message:t?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{A({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return K.includes(t)}getStoreName(e){const t=e||$;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const s=t||$;return this.isKnownCategory(s)?e:`[${s}]:${e}`}async SetItem(e,t,s){try{const r=await this.dbPromise,n=this.getStoreName(s),a=this.getStoreKey(e,s),i=r.transaction(n,"readwrite");await i.objectStore(n).put(t,a),await i.done}catch(r){A({error:r,message:r?.message}),await super.SetItem(e,t,s)}}async GetItem(e,t){try{const s=await this.dbPromise,r=this.getStoreName(t),n=this.getStoreKey(e,t);return await s.transaction(r).objectStore(r).get(n)??null}catch(s){return A({error:s,message:s?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const s=await this.dbPromise,r=this.getStoreName(t),n=this.getStoreKey(e,t),a=s.transaction(r,"readwrite");await a.objectStore(r).delete(n),await a.done}catch(s){A({error:s,message:s?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,s=e||$,r=this.getStoreName(e);if(this.isKnownCategory(s)){const n=t.transaction(r,"readwrite");await n.objectStore(r).clear(),await n.done}else{const n=`[${s}]:`,a=t.transaction("mj:default","readwrite"),i=a.objectStore("mj:default"),o=await i.getAllKeys();for(const u of o)typeof u=="string"&&u.startsWith(n)&&await i.delete(u);await a.done}}catch(t){A({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,s=e||$,r=this.getStoreName(e),i=await t.transaction(r,"readonly").objectStore(r).getAllKeys();if(this.isKnownCategory(s))return i.map(u=>String(u));const o=`[${s}]:`;return i.map(u=>String(u)).filter(u=>u.startsWith(o)).map(u=>u.slice(o.length))}catch(t){return A({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}}class fe extends ne{static{g(this,"GraphQLProviderConfigData")}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 UserAPIKey(){return this.Data.UserAPIKey}set UserAPIKey(e){this.Data.UserAPIKey=e}get URL(){return this.Data.URL}get WSURL(){return this.Data.WSURL}get RefreshTokenFunction(){return this.Data.RefreshFunction}get OnAuthenticationError(){return this.Data.OnAuthenticationError}set OnAuthenticationError(e){this.Data.OnAuthenticationError=e}constructor(e,t,s,r,n,a,i,o,u,d){super({Token:e,URL:t,WSURL:s,MJAPIKey:o,UserAPIKey:u,RefreshTokenFunction:r,OnAuthenticationError:d},n,a,i)}}class S extends Y{static{g(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._dynamicHeaders=new Map,this._innerCurrentUserQueryString=`CurrentUser {
|
|
204
235
|
${this.userInfoString()}
|
|
205
236
|
MJUserRoles_UserIDArray {
|
|
206
237
|
${this.userRoleInfoString()}
|
|
@@ -209,7 +240,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
209
240
|
`,this._currentUserQuery=c`query CurrentUserAndRoles {
|
|
210
241
|
${this._innerCurrentUserQueryString}
|
|
211
242
|
CurrentUserTenantContext
|
|
212
|
-
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=1800*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=300*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=600*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,this._cacheInvalidationSubscription=null;const e=G();if(e&&e[S._globalStoreKey])return e[S._globalStoreKey];e&&(e[S._globalStoreKey]=this)}static{this._globalStoreKey="___SINGLETON__GraphQLDataProvider"}static get Instance(){const e=G();return e?e[S._globalStoreKey]:void 0}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new k(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}async InternalExecuteQueryFromSpec(e,t){throw new Error("ExecuteQueryFromSpec is not supported by this provider.")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return
|
|
243
|
+
}`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=1800*1e3,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=300*1e3,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=600*1e3,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,this._cacheInvalidationSubscription=null;const e=G();if(e&&e[S._globalStoreKey])return e[S._globalStoreKey];e&&(e[S._globalStoreKey]=this)}static{this._globalStoreKey="___SINGLETON__GraphQLDataProvider"}static get Instance(){const e=G();return e?e[S._globalStoreKey]:void 0}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new k(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}async InternalExecuteQueryFromSpec(e,t){throw new Error("ExecuteQueryFromSpec is not supported by this provider.")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return ge()}get LocalStoragePrefix(){if(this._configData===void 0||this._configData.URL===void 0)throw new Error("GraphQLDataProvider: ConfigData is not set. Please call Config() first.");return this._configData.URL.replace(/[^a-zA-Z0-9]/g,"_")+"."}async GetStoredSessionID(){try{const e=this.LocalStorageProvider;if(e){const t=this.LocalStoragePrefix+"sessionId";return await e.GetItem(t)}return null}catch(e){return console.error("Error retrieving session ID from local storage:",e),null}}async SaveStoredSessionID(e){try{const t=this.LocalStorageProvider;if(t){const s=this.LocalStoragePrefix+"sessionId";await t.SetItem(s,e)}}catch{}}async GetPreferredUUID(e){const t=await this.GetStoredSessionID();return e||!t?this.GenerateUUID():t}async Config(e,t,s,r){try{return this._configData=e,s?(this._sessionId=await this.GetPreferredUUID(r),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey,e.UserAPIKey),await this.SaveStoredSessionID(this._sessionId)):(S.Instance._configData=e,S.Instance._sessionId===void 0&&(S.Instance._sessionId=await this.GetPreferredUUID(r)),S.Instance._client||(S.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,S.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await S.Instance.SaveStoredSessionID(S.Instance._sessionId),this._sessionId=S.Instance._sessionId,this._client=S.Instance._client),super.Config(e)}catch(n){throw l(n),n}}get sessionId(){return this._sessionId}get AllowRefresh(){return!0}SetDynamicHeader(e,t){this._dynamicHeaders.set(e,t),this._client&&this._client.setHeader(e,t),S.Instance&&S.Instance!==this&&S.Instance._configData===this._configData&&(S.Instance._dynamicHeaders.set(e,t),S.Instance._client&&S.Instance._client.setHeader(e,t))}RemoveDynamicHeader(e){this._dynamicHeaders.delete(e),this._client&&this._client.setHeader(e,""),S.Instance&&S.Instance!==this&&S.Instance._configData===this._configData&&(S.Instance._dynamicHeaders.delete(e),S.Instance._client&&S.Instance._client.setHeader(e,""))}GetDynamicHeaders(){return this._dynamicHeaders}async GetCurrentUser(){const e=await this.ExecuteGQL(this._currentUserQuery,null);if(e){const t=this.ConvertBackToMJFields(e.CurrentUser),s=t.MJUserRoles_UserIDArray.map(n=>this.ConvertBackToMJFields(n));t.MJUserRoles_UserIDArray=s;const r=new F(this,{...t,UserRoles:s});return e.CurrentUserTenantContext&&typeof e.CurrentUserTenantContext=="object"&&(r.TenantContext=e.CurrentUserTenantContext),r}}async RunReport(e,t){const s=c`
|
|
213
244
|
query GetReportDataQuery ($ReportID: String!) {
|
|
214
245
|
GetReportData(ReportID: $ReportID) {
|
|
215
246
|
Success
|
|
@@ -346,7 +377,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
346
377
|
}
|
|
347
378
|
}
|
|
348
379
|
}
|
|
349
|
-
`,a=(await this.ExecuteGQL(r,{input:s}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,u)=>{const d=e[u];if(o.status==="differential"&&o.differentialData){const I=o.differentialData.updatedRows.map(D=>{const y=JSON.parse(D.Data);return this.ConvertBackToMJFields(y),y});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:I,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const I=o.Results.map(D=>{const y=JSON.parse(D.Data);return this.ConvertBackToMJFields(y),y});return{viewIndex:o.viewIndex,status:o.status,results:I,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}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(s){return l(s),{success:!1,results:[],errorMessage:s instanceof Error?s.message:String(s)}}}async getEntityNameAndUserView(e,t){let s,r;if(e.EntityName)s=e.EntityName;else if(e.ViewID)r=await
|
|
380
|
+
`,a=(await this.ExecuteGQL(r,{input:s}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const i=a.results.map((o,u)=>{const d=e[u];if(o.status==="differential"&&o.differentialData){const I=o.differentialData.updatedRows.map(D=>{const y=JSON.parse(D.Data);return this.ConvertBackToMJFields(y),y});return{viewIndex:o.viewIndex,status:o.status,results:void 0,differentialData:{updatedRows:I,deletedRecordIDs:o.differentialData.deletedRecordIDs},maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}if(o.status==="stale"&&o.Results){const I=o.Results.map(D=>{const y=JSON.parse(D.Data);return this.ConvertBackToMJFields(y),y});return{viewIndex:o.viewIndex,status:o.status,results:I,maxUpdatedAt:o.maxUpdatedAt,rowCount:o.rowCount,errorMessage:o.errorMessage}}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(s){return l(s),{success:!1,results:[],errorMessage:s instanceof Error?s.message:String(s)}}}async getEntityNameAndUserView(e,t){let s,r;if(e.EntityName)s=e.EntityName;else if(e.ViewID)r=await q.GetViewEntity(e.ViewID,t),s=r.Entity;else if(e.ViewName)r=await q.GetViewEntityByName(e.ViewName,t),s=r.Entity;else throw new Error("No EntityName, ViewID or ViewName passed to RunView");return{entityName:s,v:r}}getViewRunTimeFieldList(e,t,s,r){const n=[],a=new w;if(s.Fields){for(const i of e.PrimaryKeys)s.Fields.find(o=>o.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&n.push(i.Name);s.Fields.forEach(i=>{n.push(a.MapFieldName(i))})}else if(r)e.Fields.forEach(i=>{i.IsBinaryFieldType||n.push(a.MapFieldName(i.CodeName))});else{for(const i of e.PrimaryKeys)n.find(o=>o.trim().toLowerCase()===i.Name.toLowerCase())===void 0&&n.push(i.Name);t.Columns.forEach(i=>{i.hidden===!1&&!n.find(o=>o.trim().toLowerCase()===i.EntityField?.Name.trim().toLowerCase())&&i.EntityField&&n.push(a.MapFieldName(i.EntityField.CodeName))})}return n}get ProviderType(){return Z.Network}async GetRecordChanges(e,t){try{const s={EntityName:"MJ: Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},r=await this.RunView(s);return r?r.Results.sort((n,a)=>n.ChangedAt>a.ChangedAt?-1:1):null}catch(s){throw l(s),s}}async GetRecordDependencies(e,t){try{const s=c`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
|
|
350
381
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
351
382
|
EntityName
|
|
352
383
|
RelatedEntityName
|
|
@@ -410,7 +441,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
410
441
|
${o}
|
|
411
442
|
}
|
|
412
443
|
}
|
|
413
|
-
`,D=await this.ExecuteGQL(I,n);return D&&D[u]?this.ConvertBackToMJFields(D[u]):null}catch(n){return l(n),null}}ConvertBackToMJFields(e){return new w().ReverseMapFields(e),e}getRelatedEntityString(e,t){let s="";for(let r=0;r<e.RelatedEntities.length;r++)if(t.indexOf(e.RelatedEntities[r].RelatedEntity)>=0){const n=e.RelatedEntities[r],a=this.Entities.find(o=>
|
|
444
|
+
`,D=await this.ExecuteGQL(I,n);return D&&D[u]?this.ConvertBackToMJFields(D[u]):null}catch(n){return l(n),null}}ConvertBackToMJFields(e){return new w().ReverseMapFields(e),e}getRelatedEntityString(e,t){let s="";for(let r=0;r<e.RelatedEntities.length;r++)if(t.indexOf(e.RelatedEntities[r].RelatedEntity)>=0){const n=e.RelatedEntities[r],a=this.Entities.find(o=>le(o.ID,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,"")}`,s+=`
|
|
414
445
|
${i} {
|
|
415
446
|
${a.Fields.map(o=>o.CodeName).join(`
|
|
416
447
|
`)}
|
|
@@ -449,7 +480,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
449
480
|
LatestUpdateDate
|
|
450
481
|
EntityUpdateDates
|
|
451
482
|
}
|
|
452
|
-
}`,r=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:t});return r&&r.GetDatasetStatusByName&&r.GetDatasetStatusByName.Success?{DatasetID:r.GetDatasetStatusByName.DatasetID,DatasetName:r.GetDatasetStatusByName.DatasetName,Success:r.GetDatasetStatusByName.Success,Status:r.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(r.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(r.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new
|
|
483
|
+
}`,r=await this.ExecuteGQL(s,{DatasetName:e,ItemFilters:t});return r&&r.GetDatasetStatusByName&&r.GetDatasetStatusByName.Success?{DatasetID:r.GetDatasetStatusByName.DatasetID,DatasetName:r.GetDatasetStatusByName.DatasetName,Success:r.GetDatasetStatusByName.Success,Status:r.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(r.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(r.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new O(this)}async GetRecordFavoriteStatus(e,t,s){if(!s.Validate().IsValid)return!1;const n=this.Entities.find(o=>o.Name===t);if(!n)throw new Error(`Entity ${t} not found in metadata`);const a=c`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
|
|
453
484
|
GetRecordFavoriteStatus(params: $params) {
|
|
454
485
|
Success
|
|
455
486
|
IsFavorite
|
|
@@ -491,14 +522,26 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
491
522
|
}
|
|
492
523
|
}`,s=await this.ExecuteGQL(t,{DataContextItemID:e});if(s&&s.GetDataContextItemData){if(s.GetDataContextItemData.Success)return JSON.parse(s.GetDataContextItemData.Result);throw new Error(s.GetDataContextItemData.ErrorMessage)}else throw new Error("GraphQL query failed")}catch(t){throw l(t),t}}static async ExecuteGQL(e,t,s=!0){return S.Instance.ExecuteGQL(e,t,s)}async ExecuteGQL(e,t,s=!0){try{return await this._client.request(e,t)}catch(r){if(console.error("[GraphQL] ExecuteGQL error caught:",{hasResponse:!!r?.response,hasErrors:!!r?.response?.errors,errorCount:r?.response?.errors?.length,firstError:r?.response?.errors?.[0],errorCode:r?.response?.errors?.[0]?.extensions?.code,errorMessage:r?.response?.errors?.[0]?.message,fullError:r}),r&&r.response&&r.response.errors?.length>0)if(r.response.errors[0]?.extensions?.code?.toUpperCase().trim()==="JWT_EXPIRED"){if(s)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw l("JWT_EXPIRED and refreshTokenIfNeeded is false"),r}else throw r;else throw l(r),r}}async RefreshToken(){const e=S.Instance&&S.Instance._configData===this._configData;if(e&&S.Instance._refreshPromise)return S.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(S.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&S.Instance&&(S.Instance._refreshPromise=null)}}async performTokenRefresh(){if(this._configData.Data.RefreshTokenFunction)try{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._configData.UserAPIKey);this._client=t,S.Instance&&S.Instance._configData===this._configData&&(S.Instance._client=t)}else{const t=new Error("Refresh token function returned null or undefined token");throw this.notifyAuthenticationError(t),t}}catch(e){const t=e instanceof Error?e:new Error(String(e));throw this.notifyAuthenticationError(t),e}else{const e=new Error("No refresh token function provided");throw this.notifyAuthenticationError(e),e}}notifyAuthenticationError(e){try{const t=this._configData?.OnAuthenticationError;t&&t(e)}catch(t){console.error("[GraphQLDataProvider] Error in OnAuthenticationError callback:",t)}}static async RefreshToken(){return S.Instance.RefreshToken()}static async clearClientCache(e=new Set){const t=[];for(let s=0;s<localStorage.length;s++){const r=localStorage.key(s);r&&!e.has(r)&&t.push(r)}t.forEach(s=>localStorage.removeItem(s)),await new Promise(s=>{const r=indexedDB.deleteDatabase("MJ_Metadata");r.onsuccess=()=>s(),r.onerror=()=>s(),r.onblocked=()=>s()})}CreateNewGraphQLClient(e,t,s,r,n){const a={"x-session-id":s};t&&(a.authorization="Bearer "+t),r&&(a["x-mj-api-key"]=r),n&&(a["x-api-key"]=n);const i=new L(e,{headers:a});for(const[o,u]of this._dynamicHeaders)i.setHeader(o,u);return i}userInfoString(){return this.infoString(new F(null,null))}userRoleInfoString(){return this.infoString(new te(null))}infoString(e){let t="";const s=Object.keys(e);for(const r of s)r.startsWith("__mj_")?t+=r.replace("__mj_","_mj__")+`
|
|
493
524
|
`:r.startsWith("_")||(t+=r+`
|
|
494
|
-
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new J:this._localStorageProvider=new se),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=
|
|
525
|
+
`);return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new J:this._localStorageProvider=new se),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=me({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:g(()=>!0,"shouldRetry")}),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(s){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,s)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=this._pushStatusSubjects.size,s=Array.from(this._pushStatusSubjects.entries()),r=[];s.forEach(([n,a])=>{const i=e-a.lastRequestedAt,o=e-a.lastEmissionAt;a.activeSubscribers===0&&i>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&o>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${n} for cleanup: activeSubscribers=${a.activeSubscribers}, timeSinceRequested=${Math.round(i/1e3)}s, timeSinceEmission=${Math.round(o/1e3)}s`),r.push(n))}),r.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(i){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${n}:`,i)}}),r.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${r.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 x(s=>{const r=this.getOrCreateWSClient();this._activeSubscriptionCount++;const n=r.subscribe({query:e,variables:t},{next:g(a=>{s.next(a.data)},"next"),error:g(async a=>{const i=a;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(),s.complete()}catch(u){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",u),s.error(u)}}else s.error(a)},"error"),complete:g(()=>{s.complete()},"complete")});return()=>{this._activeSubscriptionCount--,n()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),s=this._pushStatusSubjects.get(e);if(s)return s.lastRequestedAt=t,new x(o=>{s.activeSubscribers++;const u=s.subject.subscribe(o);return()=>{const d=this._pushStatusSubjects.get(e);d&&d.activeSubscribers>0&&d.activeSubscribers--,u.unsubscribe()}});const r=c`subscription StatusUpdates($sessionId: String!) {
|
|
495
526
|
statusUpdates(sessionId: $sessionId) {
|
|
496
527
|
date
|
|
497
528
|
message
|
|
498
529
|
sessionId
|
|
499
530
|
}
|
|
500
531
|
}
|
|
501
|
-
`,n=new
|
|
532
|
+
`,n=new de,a=this.getOrCreateWSClient(),i=new ye;return i.add(new x(o=>{const u=a.subscribe({query:r,variables:{sessionId:e}},{next:g(d=>{const I=this._pushStatusSubjects.get(e);I&&(I.lastEmissionAt=Date.now()),o.next(d.data.statusUpdates.message)},"next"),error:g(async d=>{const I=d;if(I?.extensions?.code==="JWT_EXPIRED"||I?.message?.includes("token has expired")||I?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),o.complete()}catch(y){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",y),o.error(y)}}else o.error(d)},"error"),complete:g(()=>{o.complete()},"complete")});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,u()}}).subscribe({next:g(o=>n.next(o),"next"),error:g(o=>{n.error(o),this._pushStatusSubjects.delete(e)},"error"),complete:g(()=>{n.complete(),this._pushStatusSubjects.delete(e)},"complete")})),this._pushStatusSubjects.set(e,{subject:n,subscription:i,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new x(o=>{const u=this._pushStatusSubjects.get(e);u&&u.activeSubscribers++;const d=n.subscribe(o);return()=>{const I=this._pushStatusSubjects.get(e);I&&I.activeSubscribers>0&&I.activeSubscribers--,d.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.UnsubscribeFromCacheInvalidation(),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}ClientToolRequests(e){return this.subscribe(`
|
|
533
|
+
subscription ClientToolRequest($sessionID: String!) {
|
|
534
|
+
ClientToolRequest(sessionID: $sessionID) {
|
|
535
|
+
AgentRunID
|
|
536
|
+
SessionID
|
|
537
|
+
RequestID
|
|
538
|
+
ToolName
|
|
539
|
+
Params
|
|
540
|
+
TimeoutMs
|
|
541
|
+
Description
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
`,{sessionID:e})}SubscribeToCacheInvalidation(){if(this._cacheInvalidationSubscription||!this.ConfigData?.WSURL)return;const e=c`subscription CacheInvalidation {
|
|
502
545
|
cacheInvalidation {
|
|
503
546
|
EntityName
|
|
504
547
|
PrimaryKeyValues
|
|
@@ -520,7 +563,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
520
563
|
ChildEntityNames
|
|
521
564
|
ErrorMessage
|
|
522
565
|
}
|
|
523
|
-
}`;try{const n=await this.ExecuteGQL(r,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(a=>({ChildEntityName:a})):[]}catch(n){return l(`FindISAChildEntities failed for ${e.Name}: ${n}`),[]}}}async function
|
|
566
|
+
}`;try{const n=await this.ExecuteGQL(r,{EntityName:e.Name,RecordID:t});return n?.FindISAChildEntities?.Success&&n.FindISAChildEntities.ChildEntityNames?n.FindISAChildEntities.ChildEntityNames.map(a=>({ChildEntityName:a})):[]}catch(n){return l(`FindISAChildEntities failed for ${e.Name}: ${n}`),[]}}}async function De(h){const e=new S;return ae(e),await e.Config(h),V.Instance.RaiseEvent({event:_.LoggedIn,eventCode:null,component:this,args:null}),await oe.Instance.Startup(),e}g(De,"setupGraphQLClient");class Re{static{g(this,"SyncRolesAndUsersResult")}}class Ee{static{g(this,"RoleInput")}}class we{static{g(this,"UserInput")}}class ve{static{g(this,"RolesAndUsersInput")}}var W=(h=>(h.Create="Create",h.Update="Update",h.CreateOrUpdate="CreateOrUpdate",h.Delete="Delete",h.DeleteWithFilter="DeleteWithFilter",h))(W||{});class Ce{static{g(this,"ActionItemInput")}}class $e{static{g(this,"SyncDataResult")}constructor(){this.Results=[]}}class Pe{static{g(this,"ActionItemOutput")}}class be{static{g(this,"GraphQLSystemUserClient")}get Client(){return this._client}constructor(e,t,s,r){const n={"x-session-id":s};this._sessionId=s,t&&(n.authorization="Bearer "+t),r&&(n["x-mj-api-key"]=r),this._client=new L(e,{headers:n})}resolvePlatformSQL(e){if(e!=null)return ie(e)?e.default:e}async GetData(e,t){try{const r=await this.Client.request(`query GetData($input: GetDataInputType!) {
|
|
524
567
|
GetData(input: $input) {
|
|
525
568
|
Success
|
|
526
569
|
ErrorMessages
|
|
@@ -928,7 +971,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
928
971
|
error
|
|
929
972
|
}
|
|
930
973
|
}
|
|
931
|
-
`,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,r);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 l(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class
|
|
974
|
+
`,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},n=await this.Client.request(t,r);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 l(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:Array.isArray(e.textToEmbed)?[]:[],modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class Ae{static{g(this,"GetDataOutput")}}class Ne{static{g(this,"SimpleRemoteEntityOutput")}}class Me{static{g(this,"SimpleRemoteEntity")}}class xe{static{g(this,"SimpleRemoteEntityField")}}class Te{static{g(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,s=!1){try{const r=this.serializeActionParameters(t),n=this.createActionVariables(e,r,s),a=await this.executeActionMutation(n);return this.processActionResult(a,t)}catch(r){return this.handleActionError(r,t)}}serializeActionParameters(e){if(e)return e.map(t=>{let s=t.Value;return s!=null&&typeof s=="object"&&(s=JSON.stringify(s)),{...t,Value:s}})}createActionVariables(e,t,s=!1){return{input:{ActionID:e,Params:t,SkipActionLog:s}}}async executeActionMutation(e){const t=c`
|
|
932
975
|
mutation RunAction($input: RunActionInput!) {
|
|
933
976
|
RunAction(input: $input) {
|
|
934
977
|
Success
|
|
@@ -945,7 +988,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
945
988
|
ResultData
|
|
946
989
|
}
|
|
947
990
|
}
|
|
948
|
-
`;return await this._dataProvider.ExecuteGQL(t,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let t={};try{e.RunEntityAction.ResultData&&(t=JSON.parse(e.RunEntityAction.ResultData))}catch(s){l(`Failed to parse entity action result data: ${s}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return l(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class
|
|
991
|
+
`;return await this._dataProvider.ExecuteGQL(t,{input:e})}processEntityActionResult(e){if(!e?.RunEntityAction)throw new Error("Invalid response from server");let t={};try{e.RunEntityAction.ResultData&&(t=JSON.parse(e.RunEntityAction.ResultData))}catch(s){l(`Failed to parse entity action result data: ${s}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return l(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class Qe{static{g(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),s=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(s)}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=c`
|
|
949
992
|
mutation CreateAPIKey($input: CreateAPIKeyInput!) {
|
|
950
993
|
CreateAPIKey(input: $input) {
|
|
951
994
|
Success
|
|
@@ -961,7 +1004,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
961
1004
|
Error
|
|
962
1005
|
}
|
|
963
1006
|
}
|
|
964
|
-
`,r=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return r?.RevokeAPIKey?{Success:r.RevokeAPIKey.Success,Error:r.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(t){const s=t;return l(`Error revoking API key: ${s.message}`),{Success:!1,Error:`Error: ${s.message}`}}}}class
|
|
1007
|
+
`,r=await this._dataProvider.ExecuteGQL(t,{apiKeyId:e});return r?.RevokeAPIKey?{Success:r.RevokeAPIKey.Success,Error:r.RevokeAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}catch(t){const s=t;return l(`Error revoking API key: ${s.message}`),{Success:!1,Error:`Error: ${s.message}`}}}}class Le{static{g(this,"GraphQLTestingClient")}constructor(e){this._dataProvider=e}async RunTest(e){try{const t=this.buildRunTestMutation(),s=this.buildRunTestVariables(e);return await P.Execute({dataProvider:this._dataProvider,mutation:t,variables:s,mutationFieldName:"RunTest",operationLabel:"RunTest",validateAck:g(r=>r?.success===!0,"validateAck"),isCompletionEvent:g(r=>this.isTestCompletionEvent(r,e.testId),"isCompletionEvent"),extractResult:g(r=>this.extractTestResult(r),"extractResult"),onMessage:e.onProgress?r=>this.forwardTestProgress(r,e.onProgress):void 0,createErrorResult:g(r=>({success:!1,errorMessage:r,result:null}),"createErrorResult")})}catch(t){return this.handleError(t,"RunTest")}}async RunTestSuite(e){try{const t=this.buildRunTestSuiteMutation(),s=this.buildRunTestSuiteVariables(e);return await P.Execute({dataProvider:this._dataProvider,mutation:t,variables:s,mutationFieldName:"RunTestSuite",operationLabel:"RunTestSuite",validateAck:g(r=>r?.success===!0,"validateAck"),isCompletionEvent:g(r=>this.isSuiteCompletionEvent(r,e.suiteId),"isCompletionEvent"),extractResult:g(r=>this.extractSuiteResult(r),"extractResult"),onMessage:e.onProgress?r=>this.forwardTestProgress(r,e.onProgress):void 0,createErrorResult:g(r=>({success:!1,errorMessage:r,result:null}),"createErrorResult")})}catch(t){return this.handleError(t,"RunTestSuite")}}async IsTestRunning(e){try{const t=c`
|
|
965
1008
|
query IsTestRunning($testId: String!) {
|
|
966
1009
|
IsTestRunning(testId: $testId)
|
|
967
1010
|
}
|
|
@@ -1019,7 +1062,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
1019
1062
|
result
|
|
1020
1063
|
}
|
|
1021
1064
|
}
|
|
1022
|
-
`}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,s=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:s,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,s=e.variables?JSON.stringify(e.variables):void 0,r=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:s,selectedTestIds:r,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const s=e.data;return e.resolver==="RunTestResolver"&&e.type==="FireAndForgetComplete"&&s?.type==="complete"&&s?.testId===t}isSuiteCompletionEvent(e,t){const s=e.data;return e.resolver==="RunTestResolver"&&e.type==="FireAndForgetSuiteComplete"&&s?.type==="complete"&&s?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?C(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?C(t.result):null}}forwardTestProgress(e,t){if(e.resolver==="RunTestResolver"&&e.type==="TestExecutionProgress"&&e.status==="ok"){const r=e.data?.progress;r&&t(r)}}handleError(e,t){const s=e.message;return l(`${t} failed: ${s}`),{success:!1,errorMessage:s.includes("Failed to fetch")||s.includes("NetworkError")?"Lost connection to the server. The test may still be running. Please refresh to check the latest status.":s,result:null}}}class
|
|
1065
|
+
`}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,s=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:s,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,s=e.variables?JSON.stringify(e.variables):void 0,r=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:s,selectedTestIds:r,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const s=e.data;return e.resolver==="RunTestResolver"&&e.type==="FireAndForgetComplete"&&s?.type==="complete"&&s?.testId===t}isSuiteCompletionEvent(e,t){const s=e.data;return e.resolver==="RunTestResolver"&&e.type==="FireAndForgetSuiteComplete"&&s?.type==="complete"&&s?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?C(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?C(t.result):null}}forwardTestProgress(e,t){if(e.resolver==="RunTestResolver"&&e.type==="TestExecutionProgress"&&e.status==="ok"){const r=e.data?.progress;r&&t(r)}}handleError(e,t){const s=e.message;return l(`${t} failed: ${s}`),{success:!1,errorMessage:s.includes("Failed to fetch")||s.includes("NetworkError")?"Lost connection to the server. The test may still be running. Please refresh to check the latest status.":s,result:null}}}class Fe{static{g(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=c`
|
|
1023
1066
|
query GetRegistryComponent(
|
|
1024
1067
|
$registryName: String!,
|
|
1025
1068
|
$namespace: String!,
|
|
@@ -1103,7 +1146,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
1103
1146
|
error
|
|
1104
1147
|
}
|
|
1105
1148
|
}
|
|
1106
|
-
`,s=await this._dataProvider.ExecuteGQL(t,{feedback:e});return s&&s.SendComponentFeedback?s.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return l(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}}class
|
|
1149
|
+
`,s=await this._dataProvider.ExecuteGQL(t,{feedback:e});return s&&s.SendComponentFeedback?s.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(t){return l(t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}}class Ue{static{g(this,"GraphQLVersionHistoryClient")}constructor(e){this._dataProvider=e}async CreateLabel(e){let t;try{e.OnProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(a=>{try{const i=JSON.parse(a);i.resolver==="VersionHistoryResolver"&&i.type==="CreateLabelProgress"&&i.status==="ok"&&i.data&&e.OnProgress(i.data)}catch{}}));const s=c`
|
|
1107
1150
|
mutation CreateVersionLabel($input: CreateVersionLabelInput!, $sessionId: String) {
|
|
1108
1151
|
CreateVersionLabel(input: $input, sessionId: $sessionId) {
|
|
1109
1152
|
Success
|
|
@@ -1119,7 +1162,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
1119
1162
|
}
|
|
1120
1163
|
}
|
|
1121
1164
|
}
|
|
1122
|
-
`,r={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(s,r);return this.processResult(n)}catch(s){const r=s instanceof Error?s.message:String(s);return l(`GraphQLVersionHistoryClient.CreateLabel error: ${r}`),{Success:!1,Error:r}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return e.Description!=null&&(t.Description=e.Description),e.Scope!=null&&(t.Scope=e.Scope),e.EntityName!=null&&(t.EntityName=e.EntityName),e.ParentID!=null&&(t.ParentID=e.ParentID),e.ExternalSystemID!=null&&(t.ExternalSystemID=e.ExternalSystemID),e.IncludeDependencies!=null&&(t.IncludeDependencies=e.IncludeDependencies),e.MaxDepth!=null&&(t.MaxDepth=e.MaxDepth),e.ExcludeEntities!=null&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(s=>({Key:s.Key,Value:s.Value}))),t}processResult(e){const t=e?.CreateVersionLabel;if(!t)return{Success:!1,Error:"Invalid response from server."};const s=Array.isArray(t.CaptureErrors)?t.CaptureErrors.map(r=>({EntityName:r.EntityName??"",RecordID:r.RecordID??"",ErrorMessage:r.ErrorMessage??""})):void 0;return{Success:t.Success,LabelID:t.LabelID,LabelName:t.LabelName,ItemsCaptured:t.ItemsCaptured,SyntheticSnapshotsCreated:t.SyntheticSnapshotsCreated,Error:t.Error,CaptureErrors:s}}}class
|
|
1165
|
+
`,r={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(s,r);return this.processResult(n)}catch(s){const r=s instanceof Error?s.message:String(s);return l(`GraphQLVersionHistoryClient.CreateLabel error: ${r}`),{Success:!1,Error:r}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return e.Description!=null&&(t.Description=e.Description),e.Scope!=null&&(t.Scope=e.Scope),e.EntityName!=null&&(t.EntityName=e.EntityName),e.ParentID!=null&&(t.ParentID=e.ParentID),e.ExternalSystemID!=null&&(t.ExternalSystemID=e.ExternalSystemID),e.IncludeDependencies!=null&&(t.IncludeDependencies=e.IncludeDependencies),e.MaxDepth!=null&&(t.MaxDepth=e.MaxDepth),e.ExcludeEntities!=null&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(s=>({Key:s.Key,Value:s.Value}))),t}processResult(e){const t=e?.CreateVersionLabel;if(!t)return{Success:!1,Error:"Invalid response from server."};const s=Array.isArray(t.CaptureErrors)?t.CaptureErrors.map(r=>({EntityName:r.EntityName??"",RecordID:r.RecordID??"",ErrorMessage:r.ErrorMessage??""})):void 0;return{Success:t.Success,LabelID:t.LabelID,LabelName:t.LabelName,ItemsCaptured:t.ItemsCaptured,SyntheticSnapshotsCreated:t.SyntheticSnapshotsCreated,Error:t.Error,CaptureErrors:s}}}class Ge{static{g(this,"GraphQLFileStorageClient")}constructor(e){this._dataProvider=e}async ListObjects(e,t="",s){try{const r=c`
|
|
1123
1166
|
query ListStorageObjects($input: ListStorageObjectsInput!) {
|
|
1124
1167
|
ListStorageObjects(input: $input) {
|
|
1125
1168
|
objects {
|
|
@@ -1203,7 +1246,7 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
1203
1246
|
failedAccounts
|
|
1204
1247
|
}
|
|
1205
1248
|
}
|
|
1206
|
-
`,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:s?.maxResultsPerAccount,FileTypes:s?.fileTypes,SearchContent:s?.searchContent}},a=await this._dataProvider.ExecuteGQL(r,n);if(!a?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=a.SearchAcrossAccounts;return{accountResults:i.accountResults.map(o=>({accountId:o.accountID,accountName:o.accountName,success:o.success,errorMessage:o.errorMessage,results:o.results.map(u=>({path:u.path,name:u.name,size:u.size,contentType:u.contentType,lastModified:new Date(u.lastModified),relevance:u.relevance,excerpt:u.excerpt,matchInFilename:u.matchInFilename,objectId:u.objectId})),totalMatches:o.totalMatches,hasMore:o.hasMore,nextPageToken:o.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(r){return l(`Error searching across accounts: ${r}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}class
|
|
1249
|
+
`,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:s?.maxResultsPerAccount,FileTypes:s?.fileTypes,SearchContent:s?.searchContent}},a=await this._dataProvider.ExecuteGQL(r,n);if(!a?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=a.SearchAcrossAccounts;return{accountResults:i.accountResults.map(o=>({accountId:o.accountID,accountName:o.accountName,success:o.success,errorMessage:o.errorMessage,results:o.results.map(u=>({path:u.path,name:u.name,size:u.size,contentType:u.contentType,lastModified:new Date(u.lastModified),relevance:u.relevance,excerpt:u.excerpt,matchInFilename:u.matchInFilename,objectId:u.objectId})),totalMatches:o.totalMatches,hasMore:o.hasMore,nextPageToken:o.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(r){return l(`Error searching across accounts: ${r}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}class Ve{static{g(this,"GraphQLIntegrationClient")}constructor(e){this._dataProvider=e}async DiscoverObjects(e){try{const t=c`
|
|
1207
1250
|
query IntegrationDiscoverObjects($companyIntegrationID: String!) {
|
|
1208
1251
|
IntegrationDiscoverObjects(companyIntegrationID: $companyIntegrationID) {
|
|
1209
1252
|
Success
|
|
@@ -1362,5 +1405,5 @@ var z=Object.defineProperty;var g=(h,e)=>z(h,"name",{value:e,configurable:!0});i
|
|
|
1362
1405
|
IntegrationGetConnectorCapabilities(companyIntegrationID: $companyIntegrationID) {
|
|
1363
1406
|
Success Message SupportsGet SupportsCreate SupportsUpdate SupportsDelete SupportsSearch
|
|
1364
1407
|
}
|
|
1365
|
-
}`;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 s=e;return l(`Error in integration discovery: ${s}`),{Success:!1,Message:`Error: ${s.message}`,Data:t}}}export{
|
|
1408
|
+
}`;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 s=e;return l(`Error in integration discovery: ${s}`),{Success:!1,Message:`Error: ${s.message}`,Data:t}}}export{Ce as ActionItemInput,Pe as ActionItemOutput,J as BrowserIndexedDBStorageProvider,B as BrowserStorageProviderBase,w as FieldMapper,P as FireAndForgetHelper,Ae as GetDataOutput,k as GraphQLAIClient,Te as GraphQLActionClient,Fe as GraphQLComponentRegistryClient,S as GraphQLDataProvider,Qe as GraphQLEncryptionClient,Ge as GraphQLFileStorageClient,Ve as GraphQLIntegrationClient,fe as GraphQLProviderConfigData,be as GraphQLSystemUserClient,Le as GraphQLTestingClient,O as GraphQLTransactionGroup,Ue as GraphQLVersionHistoryClient,Ee as RoleInput,ve as RolesAndUsersInput,Me as SimpleRemoteEntity,xe as SimpleRemoteEntityField,Ne as SimpleRemoteEntityOutput,W as SyncDataAction,$e as SyncDataResult,Re as SyncRolesAndUsersResult,we as UserInput,Xe as gql,De as setupGraphQLClient};
|
|
1366
1409
|
//# sourceMappingURL=index.mjs.map
|