@memberjunction/react-runtime 3.4.0 → 4.0.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.
Files changed (76) hide show
  1. package/.turbo/turbo-build.log +33 -25
  2. package/CHANGELOG.md +28 -0
  3. package/dist/324.runtime.umd.js +817 -0
  4. package/dist/490.runtime.umd.js +1 -0
  5. package/dist/compiler/babel-config.js +15 -21
  6. package/dist/compiler/babel-config.js.map +1 -1
  7. package/dist/compiler/component-compiler.js +13 -17
  8. package/dist/compiler/component-compiler.js.map +1 -1
  9. package/dist/compiler/index.js +2 -13
  10. package/dist/compiler/index.js.map +1 -1
  11. package/dist/component-manager/component-manager.js +7 -34
  12. package/dist/component-manager/component-manager.js.map +1 -1
  13. package/dist/component-manager/index.js +1 -5
  14. package/dist/component-manager/index.js.map +1 -1
  15. package/dist/component-manager/types.js +1 -2
  16. package/dist/index.js +31 -100
  17. package/dist/index.js.map +1 -1
  18. package/dist/registry/component-registry-service.js +8 -35
  19. package/dist/registry/component-registry-service.js.map +1 -1
  20. package/dist/registry/component-registry.js +5 -9
  21. package/dist/registry/component-registry.js.map +1 -1
  22. package/dist/registry/component-resolver.js +5 -9
  23. package/dist/registry/component-resolver.js.map +1 -1
  24. package/dist/registry/index.js +4 -11
  25. package/dist/registry/index.js.map +1 -1
  26. package/dist/registry/registry-provider.js +1 -2
  27. package/dist/runtime/component-hierarchy.js +24 -55
  28. package/dist/runtime/component-hierarchy.js.map +1 -1
  29. package/dist/runtime/component-wrapper.d.ts +18 -0
  30. package/dist/runtime/component-wrapper.d.ts.map +1 -0
  31. package/dist/runtime/component-wrapper.js +108 -0
  32. package/dist/runtime/error-boundary.js +4 -11
  33. package/dist/runtime/error-boundary.js.map +1 -1
  34. package/dist/runtime/index.js +4 -26
  35. package/dist/runtime/index.js.map +1 -1
  36. package/dist/runtime/prop-builder.js +17 -28
  37. package/dist/runtime/prop-builder.js.map +1 -1
  38. package/dist/runtime/react-root-manager.js +4 -8
  39. package/dist/runtime/react-root-manager.js.map +1 -1
  40. package/dist/runtime.umd.js +1 -801
  41. package/dist/types/dependency-types.js +1 -2
  42. package/dist/types/index.js +2 -18
  43. package/dist/types/index.js.map +1 -1
  44. package/dist/types/library-config.js +1 -2
  45. package/dist/utilities/cache-manager.js +1 -5
  46. package/dist/utilities/cache-manager.js.map +1 -1
  47. package/dist/utilities/component-error-analyzer.js +53 -57
  48. package/dist/utilities/component-error-analyzer.js.map +1 -1
  49. package/dist/utilities/component-styles.js +2 -6
  50. package/dist/utilities/component-styles.js.map +1 -1
  51. package/dist/utilities/component-unwrapper.d.ts.map +1 -1
  52. package/dist/utilities/component-unwrapper.js +6 -13
  53. package/dist/utilities/component-unwrapper.js.map +1 -1
  54. package/dist/utilities/core-libraries.js +2 -7
  55. package/dist/utilities/core-libraries.js.map +1 -1
  56. package/dist/utilities/index.js +9 -25
  57. package/dist/utilities/index.js.map +1 -1
  58. package/dist/utilities/library-dependency-resolver.js +1 -5
  59. package/dist/utilities/library-dependency-resolver.js.map +1 -1
  60. package/dist/utilities/library-loader.js +23 -27
  61. package/dist/utilities/library-loader.js.map +1 -1
  62. package/dist/utilities/library-registry.d.ts.map +1 -1
  63. package/dist/utilities/library-registry.js +3 -7
  64. package/dist/utilities/library-registry.js.map +1 -1
  65. package/dist/utilities/resource-manager.d.ts +0 -1
  66. package/dist/utilities/resource-manager.d.ts.map +1 -1
  67. package/dist/utilities/resource-manager.js +2 -6
  68. package/dist/utilities/resource-manager.js.map +1 -1
  69. package/dist/utilities/runtime-utilities.d.ts +10 -0
  70. package/dist/utilities/runtime-utilities.d.ts.map +1 -0
  71. package/dist/utilities/runtime-utilities.js +92 -0
  72. package/dist/utilities/standard-libraries.js +3 -8
  73. package/dist/utilities/standard-libraries.js.map +1 -1
  74. package/package.json +17 -17
  75. package/tsconfig.json +7 -22
  76. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,817 @@
1
+ "use strict";(this.webpackChunkMJReactRuntime=this.webpackChunkMJReactRuntime||[]).push([[324],{324(e,t,r){r.r(t),r.d(t,{ActionItemInput:()=>M,ActionItemOutput:()=>L,BrowserIndexedDBStorageProvider:()=>E,BrowserStorageProviderBase:()=>R,FieldMapper:()=>g,GetDataOutput:()=>T,GraphQLAIClient:()=>I,GraphQLActionClient:()=>F,GraphQLComponentRegistryClient:()=>j,GraphQLDataProvider:()=>f,GraphQLEncryptionClient:()=>O,GraphQLFileStorageClient:()=>k,GraphQLProviderConfigData:()=>P,GraphQLSystemUserClient:()=>Q,GraphQLTestingClient:()=>K,GraphQLTransactionGroup:()=>h,GraphQLVersionHistoryClient:()=>J,RoleInput:()=>v,RolesAndUsersInput:()=>N,SimpleRemoteEntity:()=>V,SimpleRemoteEntityField:()=>_,SimpleRemoteEntityOutput:()=>U,SyncDataAction:()=>x,SyncDataResult:()=>G,SyncRolesAndUsersResult:()=>$,UserInput:()=>A,gql:()=>s.J1,setupGraphQLClient:()=>C});var s=r(215),a=r(454),n=r(928),o=r(600),i=r(49),u=r(226),c=r(497),l=r(718),d=r(897),m=r(196),p=Object.defineProperty,y=(e,t)=>p(e,"name",{value:t,configurable:!0});class g{static{y(this,"FieldMapper")}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(([e,t])=>[t,e]));for(const r in e)r in t&&(e[t[r]]=e[r],delete e[r]);return e}}class h extends a.VH{static{y(this,"GraphQLTransactionGroup")}constructor(e){super(),this._provider=e}async HandleSubmit(){const e=s.J1`
2
+ mutation ExecuteTransactionGroup($group: TransactionInputType!) {
3
+ ExecuteTransactionGroup(group: $group) {
4
+ Success
5
+ ErrorMessages
6
+ ResultsJSON
7
+ }
8
+ }
9
+ `,t=[];for(const e of this.PendingTransactions)t.push({EntityName:e.BaseEntity.EntityInfo.Name,EntityObjectJSON:await e.BaseEntity.GetDataObjectJSON(),OperationType:e.OperationType});const r={group:{Items:t,Variables:this.Variables.map(e=>({Name:e.Name,ItemIndex:this.MapVariableEntityObjectToPosition(e),FieldName:e.FieldName,Type:e.Type}))}},n=await this._provider.ExecuteGQL(e,r);if(n&&n.ExecuteTransactionGroup){const e=n.ExecuteTransactionGroup,t=[];for(let r=0;r<this.PendingTransactions.length;r++){const s=e.ResultsJSON[r],n=(0,d.NG)(s),o=this.PendingTransactions[r];t.push(new a.qT(o,n,null!==n))}return t}throw new Error("Failed to execute transaction group")}}class I{static{y(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=s.J1`
10
+ mutation RunAIPrompt(
11
+ $promptId: String!,
12
+ $data: String,
13
+ $overrideModelId: String,
14
+ $overrideVendorId: String,
15
+ $configurationId: String,
16
+ $skipValidation: Boolean,
17
+ $templateData: String,
18
+ $responseFormat: String,
19
+ $temperature: Float,
20
+ $topP: Float,
21
+ $topK: Int,
22
+ $minP: Float,
23
+ $frequencyPenalty: Float,
24
+ $presencePenalty: Float,
25
+ $seed: Int,
26
+ $stopSequences: [String!],
27
+ $includeLogProbs: Boolean,
28
+ $topLogProbs: Int,
29
+ $messages: String,
30
+ $rerunFromPromptRunID: String,
31
+ $systemPromptOverride: String
32
+ ) {
33
+ RunAIPrompt(
34
+ promptId: $promptId,
35
+ data: $data,
36
+ overrideModelId: $overrideModelId,
37
+ overrideVendorId: $overrideVendorId,
38
+ configurationId: $configurationId,
39
+ skipValidation: $skipValidation,
40
+ templateData: $templateData,
41
+ responseFormat: $responseFormat,
42
+ temperature: $temperature,
43
+ topP: $topP,
44
+ topK: $topK,
45
+ minP: $minP,
46
+ frequencyPenalty: $frequencyPenalty,
47
+ presencePenalty: $presencePenalty,
48
+ seed: $seed,
49
+ stopSequences: $stopSequences,
50
+ includeLogProbs: $includeLogProbs,
51
+ topLogProbs: $topLogProbs,
52
+ messages: $messages,
53
+ rerunFromPromptRunID: $rerunFromPromptRunID,
54
+ systemPromptOverride: $systemPromptOverride
55
+ ) {
56
+ success
57
+ output
58
+ parsedResult
59
+ error
60
+ executionTimeMs
61
+ tokensUsed
62
+ promptRunId
63
+ rawResult
64
+ validationResult
65
+ chatResult
66
+ }
67
+ }
68
+ `,r=this.preparePromptVariables(e),a=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(a)}catch(e){return this.handlePromptError(e)}}preparePromptVariables(e){const t={promptId:e.promptId};return void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.templateData&&(t.templateData="object"==typeof e.templateData?JSON.stringify(e.templateData):e.templateData),void 0!==e.messages&&(t.messages=JSON.stringify(e.messages)),void 0!==e.overrideModelId&&(t.overrideModelId=e.overrideModelId),void 0!==e.overrideVendorId&&(t.overrideVendorId=e.overrideVendorId),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.skipValidation&&(t.skipValidation=e.skipValidation),void 0!==e.responseFormat&&(t.responseFormat=e.responseFormat),void 0!==e.temperature&&(t.temperature=e.temperature),void 0!==e.topP&&(t.topP=e.topP),void 0!==e.topK&&(t.topK=e.topK),void 0!==e.minP&&(t.minP=e.minP),void 0!==e.frequencyPenalty&&(t.frequencyPenalty=e.frequencyPenalty),void 0!==e.presencePenalty&&(t.presencePenalty=e.presencePenalty),void 0!==e.seed&&(t.seed=e.seed),void 0!==e.stopSequences&&(t.stopSequences=e.stopSequences),void 0!==e.includeLogProbs&&(t.includeLogProbs=e.includeLogProbs),void 0!==e.topLogProbs&&(t.topLogProbs=e.topLogProbs),void 0!==e.rerunFromPromptRunID&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),void 0!==e.systemPromptOverride&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,a;try{t.parsedResult&&(r=JSON.parse(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(a=JSON.parse(t.chatResult))}catch{a=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:a}}handlePromptError(e){const t=e;return(0,a.ZI)(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){let n;try{e.onProgress&&(n=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{(0,a.Mo)({message:"[GraphQLAIClient] Received statusUpdate message",verboseOnly:!0,additionalArgs:[t]});const r=JSON.parse(t);if((0,a.Mo)({message:"[GraphQLAIClient] Parsed message",verboseOnly:!0,additionalArgs:[r]}),"RunAIAgentResolver"===r.resolver&&"ExecutionProgress"===r.type&&"ok"===r.status&&r.data?.progress){(0,a.Mo)({message:"[GraphQLAIClient] Forwarding progress to callback",verboseOnly:!0,additionalArgs:[r.data.progress]});const t={...r.data.progress,metadata:{...r.data.progress.metadata||{},agentRunId:r.data.agentRunId}};e.onProgress(t)}else(0,a.Mo)({message:"[GraphQLAIClient] Message does not match filter criteria",verboseOnly:!0,additionalArgs:[{resolver:r.resolver,type:r.type,status:r.status,hasProgress:!!r.data?.progress}]})}catch(e){console.error("[GraphQLAIClient] Failed to parse progress message:",e,"Raw message:",t)}}));const o=s.J1`
69
+ mutation RunAIAgent(
70
+ $agentId: String!,
71
+ $messages: String!,
72
+ $sessionId: String!,
73
+ $data: String,
74
+ $payload: String,
75
+ $templateData: String,
76
+ $lastRunId: String,
77
+ $autoPopulateLastRunPayload: Boolean,
78
+ $configurationId: String,
79
+ $conversationDetailId: String,
80
+ $createArtifacts: Boolean,
81
+ $createNotification: Boolean,
82
+ $sourceArtifactId: String,
83
+ $sourceArtifactVersionId: String
84
+ ) {
85
+ RunAIAgent(
86
+ agentId: $agentId,
87
+ messages: $messages,
88
+ sessionId: $sessionId,
89
+ data: $data,
90
+ payload: $payload,
91
+ templateData: $templateData,
92
+ lastRunId: $lastRunId,
93
+ autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
94
+ configurationId: $configurationId,
95
+ conversationDetailId: $conversationDetailId,
96
+ createArtifacts: $createArtifacts,
97
+ createNotification: $createNotification,
98
+ sourceArtifactId: $sourceArtifactId,
99
+ sourceArtifactVersionId: $sourceArtifactVersionId
100
+ ) {
101
+ success
102
+ errorMessage
103
+ executionTimeMs
104
+ result
105
+ }
106
+ }
107
+ `,i=this.prepareAgentVariables(e,t,r),u=await this._dataProvider.ExecuteGQL(o,i);return this.processAgentResult(u.RunAIAgent?.result)}catch(e){return this.handleAgentError(e)}finally{n&&n.unsubscribe()}}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return void 0!==e.data&&(s.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(s.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(s.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(s.configurationId=e.configurationId),void 0!==e.conversationDetailId&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),void 0!==t&&(s.sourceArtifactId=t),void 0!==r&&(s.sourceArtifactVersionId=r),s}processAgentResult(e){return(0,d.NG)(e)}handleAgentError(e){return(0,a.ZI)(`Error running AI agent: ${e}`),{success:!1,agentRun:void 0}}async RunAIAgentFromConversationDetail(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);if("RunAIAgentResolver"===r.resolver&&"ExecutionProgress"===r.type&&"ok"===r.status&&r.data?.progress){const t={...r.data.progress,metadata:{...r.data.progress.metadata||{},agentRunId:r.data.agentRunId}};e.onProgress(t)}}catch(e){console.error("[GraphQLAIClient] Failed to parse progress message:",e)}}));const r=s.J1`
108
+ mutation RunAIAgentFromConversationDetail(
109
+ $conversationDetailId: String!,
110
+ $agentId: String!,
111
+ $sessionId: String!,
112
+ $maxHistoryMessages: Int,
113
+ $data: String,
114
+ $payload: String,
115
+ $lastRunId: String,
116
+ $autoPopulateLastRunPayload: Boolean,
117
+ $configurationId: String,
118
+ $createArtifacts: Boolean,
119
+ $createNotification: Boolean,
120
+ $sourceArtifactId: String,
121
+ $sourceArtifactVersionId: String
122
+ ) {
123
+ RunAIAgentFromConversationDetail(
124
+ conversationDetailId: $conversationDetailId,
125
+ agentId: $agentId,
126
+ sessionId: $sessionId,
127
+ maxHistoryMessages: $maxHistoryMessages,
128
+ data: $data,
129
+ payload: $payload,
130
+ lastRunId: $lastRunId,
131
+ autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
132
+ configurationId: $configurationId,
133
+ createArtifacts: $createArtifacts,
134
+ createNotification: $createNotification,
135
+ sourceArtifactId: $sourceArtifactId,
136
+ sourceArtifactVersionId: $sourceArtifactVersionId
137
+ ) {
138
+ success
139
+ errorMessage
140
+ executionTimeMs
141
+ result
142
+ }
143
+ }
144
+ `,a={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId};void 0!==e.maxHistoryMessages&&(a.maxHistoryMessages=e.maxHistoryMessages),void 0!==e.data&&(a.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(a.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(a.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(a.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(a.configurationId=e.configurationId),void 0!==e.createArtifacts&&(a.createArtifacts=e.createArtifacts),void 0!==e.createNotification&&(a.createNotification=e.createNotification),void 0!==e.sourceArtifactId&&(a.sourceArtifactId=e.sourceArtifactId),void 0!==e.sourceArtifactVersionId&&(a.sourceArtifactVersionId=e.sourceArtifactVersionId);const n=await this._dataProvider.ExecuteGQL(r,a);return this.processAgentResult(n.RunAIAgentFromConversationDetail?.result)}catch(e){return this.handleAgentError(e)}finally{t&&t.unsubscribe()}}async ExecuteSimplePrompt(e){try{const t=s.J1`
145
+ mutation ExecuteSimplePrompt(
146
+ $systemPrompt: String!,
147
+ $messages: String,
148
+ $preferredModels: [String!],
149
+ $modelPower: String,
150
+ $responseFormat: String
151
+ ) {
152
+ ExecuteSimplePrompt(
153
+ systemPrompt: $systemPrompt,
154
+ messages: $messages,
155
+ preferredModels: $preferredModels,
156
+ modelPower: $modelPower,
157
+ responseFormat: $responseFormat
158
+ ) {
159
+ success
160
+ result
161
+ resultObject
162
+ modelName
163
+ error
164
+ executionTimeMs
165
+ }
166
+ }
167
+ `,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const a=await this._dataProvider.ExecuteGQL(t,r);if(!a?.ExecuteSimplePrompt)throw new Error("Invalid response from server");const n=a.ExecuteSimplePrompt;let o;if(n.resultObject)try{o=JSON.parse(n.resultObject)}catch{o=n.resultObject}return{success:n.success,result:n.result,resultObject:o,modelName:n.modelName,error:n.error,executionTimeMs:n.executionTimeMs}}catch(e){const t=e;return(0,a.ZI)(`Error executing simple prompt: ${t}`),{success:!1,modelName:"Unknown",error:t.message||"Unknown error occurred"}}}async EmbedText(e){try{const t=s.J1`
168
+ mutation EmbedText(
169
+ $textToEmbed: [String!]!,
170
+ $modelSize: String!
171
+ ) {
172
+ EmbedText(
173
+ textToEmbed: $textToEmbed,
174
+ modelSize: $modelSize
175
+ ) {
176
+ embeddings
177
+ modelName
178
+ vectorDimensions
179
+ error
180
+ }
181
+ }
182
+ `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this._dataProvider.ExecuteGQL(t,r);if(!a?.EmbedText)throw new Error("Invalid response from server");const n=a.EmbedText;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){const r=t;return(0,a.ZI)(`Error generating embeddings: ${r}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:r.message||"Unknown error occurred"}}}}const S="default";class R{static{y(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||S;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){return this.getCategoryMap(t||S).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||S).set(e,t)}async Remove(e,t){this.getCategoryMap(t||S).delete(e)}async ClearCategory(e){const t=e||S;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||S);return t?Array.from(t.keys()):[]}}const D=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],w="Metadata_KVPairs";class E extends R{static{y(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=(0,m.P2)("MJ_Metadata",3,{upgrade(e){try{e.objectStoreNames.contains(w)&&e.deleteObjectStore(w);for(const t of D)e.objectStoreNames.contains(t)||e.createObjectStore(t)}catch(e){(0,a.Q1)({error:e,message:e?.message})}}}),this.dbPromise.then(()=>{this._dbReady=!0}).catch(e=>{(0,a.Q1)({error:e,message:"IndexedDB initialization failed: "+e?.message})})}isKnownCategory(e){const t=`mj:${e}`;return D.includes(t)}getStoreName(e){const t=e||S;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||S;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,a=this.getStoreName(r),n=this.getStoreKey(e,r),o=s.transaction(a,"readwrite");await o.objectStore(a).put(t,n),await o.done}catch(s){(0,a.Q1)({error:s,message:s?.message}),await super.SetItem(e,t,r)}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t);return await r.transaction(s).objectStore(s).get(a)??null}catch(r){return(0,a.Q1)({error:r,message:r?.message}),await super.GetItem(e,t)}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),a=this.getStoreKey(e,t),n=r.transaction(s,"readwrite");await n.objectStore(s).delete(a),await n.done}catch(r){(0,a.Q1)({error:r,message:r?.message}),await super.Remove(e,t)}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||S,s=this.getStoreName(e);if(this.isKnownCategory(r)){const e=t.transaction(s,"readwrite");await e.objectStore(s).clear(),await e.done}else{const e=`[${r}]:`,s=t.transaction("mj:default","readwrite"),a=s.objectStore("mj:default"),n=await a.getAllKeys();for(const t of n)"string"==typeof t&&t.startsWith(e)&&await a.delete(t);await s.done}}catch(t){(0,a.Q1)({error:t,message:t?.message}),await super.ClearCategory(e)}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||S,s=this.getStoreName(e),a=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return a.map(e=>String(e));const n=`[${r}]:`;return a.map(e=>String(e)).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))}catch(t){return(0,a.Q1)({error:t,message:t?.message}),await super.GetCategoryKeys(e)}}}class P extends a.dZ{static{y(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}constructor(e,t,r,s,a,n,o,i,u){super({Token:e,URL:t,WSURL:r,MJAPIKey:i,UserAPIKey:u,RefreshTokenFunction:s},a,n,o)}}class f extends a.Dn{static{y(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {\n ${this.userInfoString()}\n UserRoles_UserIDArray {\n ${this.userRoleInfoString()}\n }\n }\n `,this._currentUserQuery=s.J1`query CurrentUserAndRoles {
183
+ ${this._innerCurrentUserQueryString}
184
+ }`,this._wsClient=null,this._wsClientCreatedAt=null,this._pushStatusSubjects=new Map,this._activeSubscriptionCount=0,this.WS_CLIENT_MAX_AGE_MS=18e5,this.SUBSCRIPTION_CLEANUP_INTERVAL_MS=3e5,this.SUBSCRIPTION_IDLE_TIMEOUT_MS=6e5,this._subscriptionCleanupTimer=null,this._isCleaningUp=!1,f._instance||(f._instance=this)}static get Instance(){return f._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new I(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return(0,l.A)()}get LocalStoragePrefix(){if(void 0===this._configData||void 0===this._configData.URL)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 this._configData=e,r?(this._sessionId=await this.GetPreferredUUID(s),this._client=this.CreateNewGraphQLClient(e.URL,e.Token,this._sessionId,e.MJAPIKey,e.UserAPIKey),await this.SaveStoredSessionID(this._sessionId)):(f.Instance._configData=e,void 0===f.Instance._sessionId&&(f.Instance._sessionId=await this.GetPreferredUUID(s)),f.Instance._client||(f.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,f.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await f.Instance.SaveStoredSessionID(f.Instance._sessionId),this._sessionId=f.Instance._sessionId,this._client=f.Instance._client),super.Config(e)}catch(e){throw(0,a.ZI)(e),e}}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(e=>this.ConvertBackToMJFields(e));return t.UserRoles_UserIDArray=r,new a.oq(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=s.J1`
185
+ query GetReportDataQuery ($ReportID: String!) {
186
+ GetReportData(ReportID: $ReportID) {
187
+ Success
188
+ Results
189
+ RowCount
190
+ ExecutionTime
191
+ ErrorMessage
192
+ }
193
+ }`,a=await this.ExecuteGQL(r,{ReportID:e.ReportID});if(a&&a.GetReportData)return{ReportID:e.ReportID,Success:a.GetReportData.Success,Results:JSON.parse(a.GetReportData.Results),RowCount:a.GetReportData.RowCount,ExecutionTime:a.GetReportData.ExecutionTime,ErrorMessage:a.GetReportData.ErrorMessage}}async InternalRunQuery(e,t){if(e.QueryID)return this.RunQueryByID(e.QueryID,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);if(e.QueryName)return this.RunQueryByName(e.QueryName,e.CategoryID,e.CategoryPath,t,e.Parameters,e.MaxRows,e.StartRow);throw new Error("No QueryID or QueryName provided to RunQuery")}async InternalRunQueries(e,t){const r=s.J1`
194
+ query RunQueriesBatch($input: [RunQueryInput!]!) {
195
+ RunQueries(input: $input) {
196
+ ${this.QueryReturnFieldList}
197
+ }
198
+ }
199
+ `,a=e.map(e=>({QueryID:e.QueryID,QueryName:e.QueryName,CategoryID:e.CategoryID,CategoryPath:e.CategoryPath,Parameters:e.Parameters,MaxRows:e.MaxRows,StartRow:e.StartRow,ForceAuditLog:e.ForceAuditLog,AuditLogDescription:e.AuditLogDescription})),n=await this.ExecuteGQL(r,{input:a});return n&&n.RunQueries?n.RunQueries.map(e=>this.TransformQueryPayload(e)):[]}async RunQueryByID(e,t,r,a,n,o,i){const u=s.J1`
200
+ query GetQueryDataQuery($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
201
+ GetQueryData(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
202
+ ${this.QueryReturnFieldList}
203
+ }
204
+ }
205
+ `,c={QueryID:e};void 0!==t&&(c.CategoryID=t),void 0!==r&&(c.CategoryPath=r),void 0!==n&&(c.Parameters=n),void 0!==o&&(c.MaxRows=o),void 0!==i&&(c.StartRow=i);const l=await this.ExecuteGQL(u,c);if(l&&l.GetQueryData)return this.TransformQueryPayload(l.GetQueryData)}async RunQueryByName(e,t,r,a,n,o,i){const u=s.J1`
206
+ query GetQueryDataByNameQuery($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {
207
+ GetQueryDataByName(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {
208
+ ${this.QueryReturnFieldList}
209
+ }
210
+ }
211
+ `,c={QueryName:e};void 0!==t&&(c.CategoryID=t),void 0!==r&&(c.CategoryPath=r),void 0!==n&&(c.Parameters=n),void 0!==o&&(c.MaxRows=o),void 0!==i&&(c.StartRow=i);const l=await this.ExecuteGQL(u,c);if(l&&l.GetQueryDataByName)return this.TransformQueryPayload(l.GetQueryDataByName)}get QueryReturnFieldList(){return"\n Success\n QueryID\n QueryName\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters"}TransformQueryPayload(e){try{return{QueryID:e.QueryID,QueryName:e.QueryName,Success:e.Success,Results:JSON.parse(e.Results),RowCount:e.RowCount,TotalRowCount:e.TotalRowCount,ExecutionTime:e.ExecutionTime,ErrorMessage:e.ErrorMessage,AppliedParameters:e.AppliedParameters?JSON.parse(e.AppliedParameters):void 0}}catch(e){return(0,a.ZI)(`Error transforming query payload: ${e}`),null}}async RunQueriesWithCacheCheck(e,t){try{const t=e.map(e=>({params:{QueryID:e.params.QueryID||null,QueryName:e.params.QueryName||null,CategoryID:e.params.CategoryID||null,CategoryPath:e.params.CategoryPath||null,Parameters:e.params.Parameters||null,MaxRows:e.params.MaxRows??null,StartRow:e.params.StartRow??null,ForceAuditLog:e.params.ForceAuditLog||!1,AuditLogDescription:e.params.AuditLogDescription||null},cacheStatus:e.cacheStatus?{maxUpdatedAt:e.cacheStatus.maxUpdatedAt,rowCount:e.cacheStatus.rowCount}:null})),r=s.J1`
212
+ query RunQueriesWithCacheCheckQuery($input: [RunQueryWithCacheCheckInput!]!) {
213
+ RunQueriesWithCacheCheck(input: $input) {
214
+ success
215
+ errorMessage
216
+ results {
217
+ queryIndex
218
+ queryId
219
+ status
220
+ Results
221
+ maxUpdatedAt
222
+ rowCount
223
+ errorMessage
224
+ }
225
+ }
226
+ }
227
+ `,a=(await this.ExecuteGQL(r,{input:t}))?.RunQueriesWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const n=a.results.map(e=>{if(("stale"===e.status||"no_validation"===e.status)&&e.Results){const t=JSON.parse(e.Results);return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,results:t,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}}return{queryIndex:e.queryIndex,queryId:e.queryId,status:e.status,maxUpdatedAt:e.maxUpdatedAt,rowCount:e.rowCount,errorMessage:e.errorMessage}});return{success:a.success,results:n,errorMessage:a.errorMessage}}catch(e){return(0,a.ZI)(`Error in RunQueriesWithCacheCheck: ${e}`),{success:!1,results:[],errorMessage:e instanceof Error?e.message:String(e)}}}async InternalRunView(e,t){try{let r="",n="";if(!e)throw"No parameters passed to RunView";{const o={};let i,u;if(e.ViewEntity)u=e.ViewEntity,i=u.Entity;else{const{entityName:r,v:s}=await this.getEntityNameAndUserView(e,t);u=s,i=r}const c=this.Entities.find(e=>e.Name===i);if(!c)throw new Error(`Entity ${i} not found in metadata`);let l=!1;const d=(0,a.I)(c);e.ViewID?(r=`Run${d}ViewByID`,n="RunViewByIDInput",o.ViewID=e.ViewID):e.ViewName?(r=`Run${d}ViewByName`,n="RunViewByNameInput",o.ViewName=e.ViewName):(l=!0,r=`Run${d}DynamicView`,n="RunDynamicViewInput",o.EntityName=e.EntityName),o.ExtraFilter=e.ExtraFilter?e.ExtraFilter:"",o.OrderBy=e.OrderBy?e.OrderBy:"",o.UserSearchString=e.UserSearchString?e.UserSearchString:"",o.Fields=e.Fields,o.IgnoreMaxRows=!!e.IgnoreMaxRows&&e.IgnoreMaxRows,void 0!==e.MaxRows&&(o.MaxRows=e.MaxRows),void 0!==e.StartRow&&(o.StartRow=e.StartRow),o.ForceAuditLog=!!e.ForceAuditLog&&e.ForceAuditLog,o.ResultType=e.ResultType?e.ResultType:"simple",e.AuditLogDescription&&e.AuditLogDescription.length>0&&(o.AuditLogDescription=e.AuditLogDescription),l||(o.ExcludeUserViewRunID=e.ExcludeUserViewRunID?e.ExcludeUserViewRunID:"",o.ExcludeDataFromAllPriorViewRuns=!!e.ExcludeDataFromAllPriorViewRuns&&e.ExcludeDataFromAllPriorViewRuns,o.OverrideExcludeFilter=e.OverrideExcludeFilter?e.OverrideExcludeFilter:"",o.SaveViewResults=!!e.SaveViewResults&&e.SaveViewResults),e.Aggregates&&e.Aggregates.length>0&&(o.Aggregates=e.Aggregates.map(e=>({expression:e.expression,alias:e.alias})));const m=this.getViewRunTimeFieldList(c,u,e,l),p=e.Aggregates&&e.Aggregates.length>0?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",y=s.J1`
228
+ query RunViewQuery ($input: ${n}!) {
229
+ ${r}(input: $input) {
230
+ Results {
231
+ ${m.join("\n ")}
232
+ }
233
+ UserViewRunID
234
+ RowCount
235
+ TotalRowCount
236
+ ExecutionTime
237
+ Success
238
+ ErrorMessage${p}
239
+ }
240
+ }`;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:i,queryName:r,aggregateCount:o.Aggregates.length,aggregates:o.Aggregates});const g=await this.ExecuteGQL(y,{input:o});if(g&&g[r]){const e=g[r].AggregateResults;o.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:i,aggregateResultCount:e?.length||0,aggregateResults:e,aggregateExecutionTime:g[r].AggregateExecutionTime});const t=g[r].Results;if(t&&t.length>0){const e=c.Fields.filter(e=>e.CodeName!==e.Name&&void 0!==e.CodeName);t.forEach(t=>{this.ConvertBackToMJFields(t),e.forEach(e=>{t[e.Name]=t[e.CodeName]})})}return g[r]}}return null}catch(e){throw(0,a.ZI)(e),e}}async InternalRunViews(e,t){try{let r=[],n=[],o=[];for(const s of e){let e="",i="";const u={};let c=null,l=null;if(s.ViewEntity)l=s.ViewEntity,c=l.Get("Entity");else{const{entityName:e,v:r}=await this.getEntityNameAndUserView(s,t);l=r,c=e}const d=this.Entities.find(e=>e.Name===c);if(!d)throw new Error(`Entity ${c} not found in metadata`);n.push(d);let m=!1;const p=(0,a.I)(d);s.ViewID?(e=`Run${p}ViewByID`,i="RunViewByIDInput",u.ViewID=s.ViewID):s.ViewName?(e=`Run${p}ViewByName`,i="RunViewByNameInput",u.ViewName=s.ViewName):(m=!0,e=`Run${p}DynamicView`,i="RunDynamicViewInput",u.EntityName=s.EntityName),u.ExtraFilter=s.ExtraFilter||"",u.OrderBy=s.OrderBy||"",u.UserSearchString=s.UserSearchString||"",u.Fields=s.Fields,u.IgnoreMaxRows=s.IgnoreMaxRows||!1,void 0!==s.MaxRows&&(u.MaxRows=s.MaxRows),void 0!==s.StartRow&&(u.StartRow=s.StartRow),u.ForceAuditLog=s.ForceAuditLog||!1,u.ResultType=s.ResultType||"simple",s.AuditLogDescription&&s.AuditLogDescription.length>0&&(u.AuditLogDescription=s.AuditLogDescription),m||(u.ExcludeUserViewRunID=s.ExcludeUserViewRunID||"",u.ExcludeDataFromAllPriorViewRuns=s.ExcludeDataFromAllPriorViewRuns||!1,u.OverrideExcludeFilter=s.OverrideExcludeFilter||"",u.SaveViewResults=s.SaveViewResults||!1),s.Aggregates&&s.Aggregates.length>0&&(u.Aggregates=s.Aggregates.map(e=>({expression:e.expression,alias:e.alias}))),r.push(u),o.push(...this.getViewRunTimeFieldList(d,l,s,m))}const i=e.some(e=>e.Aggregates&&e.Aggregates.length>0)?"\n AggregateResults {\n alias\n expression\n value\n error\n }\n AggregateExecutionTime":"",u=s.J1`
241
+ query RunViewsQuery ($input: [RunViewGenericInput!]!) {
242
+ RunViews(input: $input) {
243
+ Results {
244
+ PrimaryKey {
245
+ FieldName
246
+ Value
247
+ }
248
+ EntityID
249
+ Data
250
+ }
251
+ UserViewRunID
252
+ RowCount
253
+ TotalRowCount
254
+ ExecutionTime
255
+ Success
256
+ ErrorMessage${i}
257
+ }
258
+ }`,c=await this.ExecuteGQL(u,{input:r});if(c&&c.RunViews){const e=c.RunViews;for(const[t,r]of e.entries())r.Results=r.Results.map(e=>{let t=JSON.parse(e.Data);return this.ConvertBackToMJFields(t),t});return e}return null}catch(e){throw(0,a.ZI)(e),e}}async RunViewsWithCacheCheck(e,t){try{const t=e.map(e=>({params:{EntityName:e.params.EntityName||"",ExtraFilter:e.params.ExtraFilter||"",OrderBy:e.params.OrderBy||"",Fields:e.params.Fields,UserSearchString:e.params.UserSearchString||"",IgnoreMaxRows:e.params.IgnoreMaxRows||!1,MaxRows:e.params.MaxRows,StartRow:e.params.StartRow,ForceAuditLog:e.params.ForceAuditLog||!1,AuditLogDescription:e.params.AuditLogDescription||"",ResultType:e.params.ResultType||"simple"},cacheStatus:e.cacheStatus?{maxUpdatedAt:e.cacheStatus.maxUpdatedAt,rowCount:e.cacheStatus.rowCount}:null})),r=s.J1`
259
+ query RunViewsWithCacheCheckQuery($input: [RunViewWithCacheCheckInput!]!) {
260
+ RunViewsWithCacheCheck(input: $input) {
261
+ success
262
+ errorMessage
263
+ results {
264
+ viewIndex
265
+ status
266
+ maxUpdatedAt
267
+ rowCount
268
+ errorMessage
269
+ Results {
270
+ PrimaryKey {
271
+ FieldName
272
+ Value
273
+ }
274
+ EntityID
275
+ Data
276
+ }
277
+ differentialData {
278
+ updatedRows {
279
+ PrimaryKey {
280
+ FieldName
281
+ Value
282
+ }
283
+ EntityID
284
+ Data
285
+ }
286
+ deletedRecordIDs
287
+ }
288
+ }
289
+ }
290
+ }
291
+ `,a=(await this.ExecuteGQL(r,{input:t}))?.RunViewsWithCacheCheck;if(!a)return{success:!1,results:[],errorMessage:"No response from server"};const n=a.results.map((t,r)=>{if(e[r],"differential"===t.status&&t.differentialData){const e=t.differentialData.updatedRows.map(e=>{const t=JSON.parse(e.Data);return this.ConvertBackToMJFields(t),t});return{viewIndex:t.viewIndex,status:t.status,results:void 0,differentialData:{updatedRows:e,deletedRecordIDs:t.differentialData.deletedRecordIDs},maxUpdatedAt:t.maxUpdatedAt,rowCount:t.rowCount,errorMessage:t.errorMessage}}if("stale"===t.status&&t.Results){const e=t.Results.map(e=>{const t=JSON.parse(e.Data);return this.ConvertBackToMJFields(t),t});return{viewIndex:t.viewIndex,status:t.status,results:e,maxUpdatedAt:t.maxUpdatedAt,rowCount:t.rowCount,errorMessage:t.errorMessage}}return{viewIndex:t.viewIndex,status:t.status,results:void 0,maxUpdatedAt:t.maxUpdatedAt,rowCount:t.rowCount,errorMessage:t.errorMessage}});return{success:a.success,results:n,errorMessage:a.errorMessage}}catch(e){return(0,a.ZI)(e),{success:!1,results:[],errorMessage:e instanceof Error?e.message:String(e)}}}async getEntityNameAndUserView(e,t){let r,s;if(e.EntityName)r=e.EntityName;else if(e.ViewID)s=await n.o1C.GetViewEntity(e.ViewID,t),r=s.Entity;else{if(!e.ViewName)throw new Error("No EntityName, ViewID or ViewName passed to RunView");s=await n.o1C.GetViewEntityByName(e.ViewName,t),r=s.Entity}return{entityName:r,v:s}}getViewRunTimeFieldList(e,t,r,s){const a=[],n=new g;if(r.Fields){for(const t of e.PrimaryKeys)void 0===r.Fields.find(e=>e.trim().toLowerCase()===t.Name.toLowerCase())&&a.push(t.Name);r.Fields.forEach(e=>{a.push(n.MapFieldName(e))})}else if(s)e.Fields.forEach(e=>{e.IsBinaryFieldType||a.push(n.MapFieldName(e.CodeName))});else{for(const t of e.PrimaryKeys)void 0===a.find(e=>e.trim().toLowerCase()===t.Name.toLowerCase())&&a.push(t.Name);t.Columns.forEach(e=>{!1===e.hidden&&!a.find(t=>t.trim().toLowerCase()===e.EntityField?.Name.trim().toLowerCase())&&e.EntityField&&a.push(n.MapFieldName(e.EntityField.CodeName))})}return a}get ProviderType(){return a.cp.Network}async GetRecordChanges(e,t){try{const r={EntityName:"Record Changes",ExtraFilter:`RecordID = '${t.Values()}' AND Entity = '${e}'`},s=await this.RunView(r);return s?s.Results.sort((e,t)=>e.ChangedAt>t.ChangedAt?-1:1):null}catch(e){throw(0,a.ZI)(e),e}}async GetRecordDependencies(e,t){try{const r=s.J1`query GetRecordDependenciesQuery ($entityName: String!, $CompositeKey: CompositeKeyInputType!) {
292
+ GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
293
+ EntityName
294
+ RelatedEntityName
295
+ FieldName
296
+ CompositeKey {
297
+ KeyValuePairs {
298
+ FieldName
299
+ Value
300
+ }
301
+ }
302
+ }
303
+ }`,a={entityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}};return(await this.ExecuteGQL(r,a))?.GetRecordDependencies}catch(e){throw(0,a.ZI)(e),e}}ensureKeyValuePairValueIsString(e){return e.map(e=>({FieldName:e.FieldName,Value:e.Value.toString()}))}async GetRecordDuplicates(e,t){if(!e)return null;const r=s.J1`query GetRecordDuplicatesQuery ($params: PotentialDuplicateRequestType!) {
304
+ GetRecordDuplicates(params: $params) {
305
+ Status
306
+ ErrorMessage
307
+ PotentialDuplicateResult {
308
+ EntityID
309
+ DuplicateRunDetailMatchRecordIDs
310
+ RecordPrimaryKeys {
311
+ KeyValuePairs {
312
+ FieldName
313
+ Value
314
+ }
315
+ }
316
+ Duplicates {
317
+ ProbabilityScore
318
+ KeyValuePairs {
319
+ FieldName
320
+ Value
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }`;let a={EntityID:e.EntityID,EntityDocumentID:e.EntityDocumentID,ListID:e.ListID,ProbabilityScore:e.ProbabilityScore,Options:e.Options,RecordIDs:e.RecordIDs.map(e=>e.Copy())};const n=await this.ExecuteGQL(r,{params:a});return n&&n.GetRecordDuplicates?n.GetRecordDuplicates:void 0}async MergeRecords(e,t,r){const n=this.Entities.find(t=>t.Name.trim().toLowerCase()===e.EntityName.trim().toLowerCase());if(!n||!n.AllowRecordMerge)throw new Error(`Entity ${e.EntityName} does not allow record merging, check the AllowRecordMerge property in the entity metadata`);try{const t=s.J1`mutation MergeRecordsMutation ($request: RecordMergeRequest!) {
326
+ MergeRecords(request: $request) {
327
+ Success
328
+ OverallStatus
329
+ RecordMergeLogID
330
+ RecordStatus {
331
+ CompositeKey {
332
+ KeyValuePairs {
333
+ FieldName
334
+ Value
335
+ }
336
+ }
337
+ Success
338
+ RecordMergeDeletionLogID
339
+ Message
340
+ }
341
+ }
342
+ }`,r={EntityName:e.EntityName,SurvivingRecordCompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.SurvivingRecordCompositeKey.KeyValuePairs)},FieldMap:e.FieldMap?.map(e=>({FieldName:e.FieldName,Value:e.Value.toString()})),RecordsToMerge:e.RecordsToMerge.map(e=>e.Copy())};return(await this.ExecuteGQL(t,{request:r}))?.MergeRecords}catch(t){return(0,a.ZI)(t),{Success:!1,OverallStatus:t&&t.message?t.message:t,RecordStatus:[],RecordMergeLogID:"",Request:e}}}async Save(e,t,r){const n=new a.KV;try{e.RegisterTransactionPreprocessing();const t={input:{}},o=e.IsSaved?"Update":"Create";n.StartedAt=new Date,n.Type=e.IsSaved?"update":"create",n.OriginalValues=e.Fields.map(e=>({FieldName:e.CodeName,Value:e.Value})),e.ResultHistory.push(n);const i=(0,a.I)(e.EntityInfo),u=`${o}${i}`,c=e.Fields.filter(t=>!t.ReadOnly||t.IsPrimaryKey&&e.IsSaved),l=new g,d=` ${u}(input: $input) {\n ${e.Fields.map(e=>l.MapFieldName(e.CodeName)).join("\n ")}\n }`,m=s.J1`mutation ${o}${i} ($input: ${u}Input!) {
343
+ ${d}
344
+ }
345
+ `;for(let e=0;e<c.length;e++){const r=c[e];let s=r.Value;if(s)switch(r.EntityFieldInfo.TSType){case a.$S.Date:s=s.getTime();break;case a.$S.Boolean:"boolean"!=typeof s&&(s=0!==parseInt(s));break;case a.$S.Number:if("number"!=typeof s){const e=Number(s);isNaN(e)||(s=e)}}null===s&&!1===r.EntityFieldInfo.AllowsNull&&(s=null!==r.EntityFieldInfo.DefaultValue?r.EntityFieldInfo.DefaultValue:r.FieldType===a.$S.Number||r.FieldType===a.$S.Boolean?0:""),t.input[r.CodeName]=s}if("update"===o.trim().toLowerCase()&&!1===r.SkipOldValuesCheck){const r=[];e.Fields.forEach(e=>{let t=null;null!==e.OldValue&&void 0!==e.OldValue&&(t=e.EntityFieldInfo.TSType===a.$S.Date?e.OldValue.getTime().toString():e.EntityFieldInfo.TSType===a.$S.Boolean?!0===e.OldValue?"1":"0":"string"!=typeof e.OldValue?e.OldValue.toString():e.OldValue),r.push({Key:e.CodeName,Value:t})}),t.input.OldValues___=r}if(e.TransactionGroup){const r=[{varName:"input",inputType:u+"Input!"}];return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new a.U1(e,"create"===n.Type?"Create":"Update",d,t,{mutationName:u,mutationInputTypes:r},(e,t)=>{n.EndedAt=new Date,t&&e?(n.Success=!0,n.NewValues=this.ConvertBackToMJFields(e)):(n.Success=!1,n.Message="Transaction failed")})),!0}{const r=await this.ExecuteGQL(m,t);if(r&&r[u])return n.Success=!0,n.EndedAt=new Date,n.NewValues=this.ConvertBackToMJFields(r[u]),n.NewValues;throw new Error(`Save failed for ${e.EntityInfo.ClassName}`)}}catch(e){return n.Success=!1,n.EndedAt=new Date,n.Message=e.response?.errors?.length>0?e.response.errors[0].message:e.message,(0,a.ZI)(e),null}}async Load(e,t,r=null,n){try{const n={};let o="",i="";for(let r=0;r<t.KeyValuePairs.length;r++){const s=e.Fields.find(e=>e.Name.trim().toLowerCase()===t.KeyValuePairs[r].FieldName.trim().toLowerCase()).EntityFieldInfo,u=t.GetValueByIndex(r),c=s.GraphQLType;if(i.length>0&&(i+=", "),i+=`$${s.CodeName}: ${c}!`,o.length>0&&(o+=", "),o+=`${s.CodeName}: $${s.CodeName}`,s.TSType===a.$S.Number){if(isNaN(t.GetValueByIndex(r)))throw new Error(`Primary Key value ${u} (${s.Name}) is not a valid number`);n[s.CodeName]=parseInt(u)}else n[s.CodeName]=u}const u=r&&r.length>0?this.getRelatedEntityString(e.EntityInfo,r):"",c=(0,a.I)(e.EntityInfo),l=(new g,s.J1`query Single${c}${u.length>0?"Full":""} (${i}) {
346
+ ${c}(${o}) {
347
+ ${e.Fields.filter(e=>!e.EntityFieldInfo.IsBinaryFieldType).map(e=>e.EntityFieldInfo.Name.trim().toLowerCase().startsWith("__mj_")?e.CodeName.replace("__mj_","_mj__"):e.CodeName).join("\n ")}
348
+ ${u}
349
+ }
350
+ }
351
+ `),d=await this.ExecuteGQL(l,n);return d&&d[c]?this.ConvertBackToMJFields(d[c]):null}catch(e){return(0,a.ZI)(e),null}}ConvertBackToMJFields(e){return(new g).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 t=e.RelatedEntities[s],a=this.Entities.find(e=>e.ID===t.RelatedEntityID);let n="";n="many to many"===t.Type.toLowerCase().trim()?`${t.RelatedEntityCodeName}_${t.JoinEntityJoinField.replace(/\s/g,"")}`:`${t.RelatedEntityCodeName}_${t.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`\n ${n} {\n ${a.Fields.map(e=>e.CodeName).join("\n ")}\n }\n `}return r}async Delete(e,t,r){const n=new a.KV;try{e.RegisterTransactionPreprocessing(),n.StartedAt=new Date,n.Type="delete",n.OriginalValues=e.Fields.map(e=>({FieldName:e.CodeName,Value:e.Value})),e.ResultHistory.push(n);const r={},o=[];let i="",u="",c="";for(let t of e.PrimaryKey.KeyValuePairs){const s=e.Fields.find(e=>e.Name.trim().toLowerCase()===t.FieldName.trim().toLowerCase());r[s.CodeName]=s.Value,o.push({varName:s.CodeName,inputType:s.EntityFieldInfo.GraphQLType+"!"}),i.length>0&&(i+=", "),i+=`${s.CodeName}: $${s.CodeName}`,u.length>0&&(u+=", "),u+=`$${s.CodeName}: ${s.EntityFieldInfo.GraphQLType}!`,c.length>0&&(c+="\n "),c+=`${s.CodeName}`}o.push({varName:"options___",inputType:"DeleteOptionsInput!"}),r.options___=t||{SkipEntityAIActions:!1,SkipEntityActions:!1};const l="Delete"+(0,a.I)(e.EntityInfo),d=s.J1`${l}(${i}, options___: $options___) {
352
+ ${c}
353
+ }
354
+ `,m=s.J1`mutation ${l} (${u}, $options___: DeleteOptionsInput!) {
355
+ ${d}
356
+ }
357
+ `;if(e.TransactionGroup)return e.RaiseReadyForTransaction(),e.TransactionGroup.AddTransaction(new a.U1(e,"Delete",d,r,{mutationName:l,mutationInputTypes:o},(t,r)=>{if(n.EndedAt=new Date,r&&t){let r=!0;for(const s of e.PrimaryKey.KeyValuePairs)s.Value!==t[s.FieldName]&&(r=!1);r?n.Success=!0:(n.Success=!1,n.Message="Transaction failed to commit")}else n.Success=!1,n.Message="Transaction failed to commit"})),!0;{const t=await this.ExecuteGQL(m,r);if(t&&t[l]){const r=t[l];for(let t of e.PrimaryKey.KeyValuePairs){let e=r[t.FieldName],s=t.Value;if("number"==typeof s&&(s=s.toString()),"number"==typeof e&&(e=e.toString()),s!==e)throw new Error(`Primary key value mismatch in server Delete response. Field: ${t.FieldName}, Original: ${s}, Returned: ${e}`)}return n.Success=!0,n.EndedAt=new Date,!0}throw new Error(`Delete failed for ${e.EntityInfo.Name}: ${e.PrimaryKey.ToString()} `)}}catch(e){return n.EndedAt=new Date,n.Success=!1,n.Message=e.response?.errors?.length>0?e.response.errors[0].message:e.message,(0,a.ZI)(e),!1}}async GetDatasetByName(e,t){const r=s.J1`query GetDatasetByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
358
+ GetDatasetByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
359
+ DatasetID
360
+ DatasetName
361
+ Success
362
+ Status
363
+ LatestUpdateDate
364
+ Results
365
+ }
366
+ }`,a=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return a&&a.GetDatasetByName&&a.GetDatasetByName.Success?{DatasetID:a.GetDatasetByName.DatasetID,DatasetName:a.GetDatasetByName.DatasetName,Success:a.GetDatasetByName.Success,Status:a.GetDatasetByName.Status,LatestUpdateDate:new Date(a.GetDatasetByName.LatestUpdateDate),Results:JSON.parse(a.GetDatasetByName.Results)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,Results:null}}async GetDatasetStatusByName(e,t){const r=s.J1`query GetDatasetStatusByName($DatasetName: String!, $ItemFilters: [DatasetItemFilterTypeGQL!]) {
367
+ GetDatasetStatusByName(DatasetName: $DatasetName, ItemFilters: $ItemFilters) {
368
+ DatasetID
369
+ DatasetName
370
+ Success
371
+ Status
372
+ LatestUpdateDate
373
+ EntityUpdateDates
374
+ }
375
+ }`,a=await this.ExecuteGQL(r,{DatasetName:e,ItemFilters:t});return a&&a.GetDatasetStatusByName&&a.GetDatasetStatusByName.Success?{DatasetID:a.GetDatasetStatusByName.DatasetID,DatasetName:a.GetDatasetStatusByName.DatasetName,Success:a.GetDatasetStatusByName.Success,Status:a.GetDatasetStatusByName.Status,LatestUpdateDate:new Date(a.GetDatasetStatusByName.LatestUpdateDate),EntityUpdateDates:JSON.parse(a.GetDatasetStatusByName.EntityUpdateDates)}:{DatasetID:"",DatasetName:e,Success:!1,Status:"Unknown",LatestUpdateDate:null,EntityUpdateDates:null}}async CreateTransactionGroup(){return new h(this)}async GetRecordFavoriteStatus(e,t,r){if(!r.Validate().IsValid)return!1;const a=this.Entities.find(e=>e.Name===t);if(!a)throw new Error(`Entity ${t} not found in metadata`);const n=s.J1`query GetRecordFavoriteStatus($params: UserFavoriteSearchParams!) {
376
+ GetRecordFavoriteStatus(params: $params) {
377
+ Success
378
+ IsFavorite
379
+ }
380
+ }`,o=await this.ExecuteGQL(n,{params:{UserID:e,EntityID:a.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)}}});return o&&o.GetRecordFavoriteStatus&&o.GetRecordFavoriteStatus.Success?o.GetRecordFavoriteStatus.IsFavorite:void 0}async SetRecordFavoriteStatus(e,t,r,a,n){const o=this.Entities.find(e=>e.Name===t);if(!o)throw new Error(`Entity ${t} not found in metadata`);const i=s.J1`mutation SetRecordFavoriteStatus($params: UserFavoriteSetParams!) {
381
+ SetRecordFavoriteStatus(params: $params){
382
+ Success
383
+ }
384
+ }`,u=await this.ExecuteGQL(i,{params:{UserID:e,EntityID:o.ID,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(r.KeyValuePairs)},IsFavorite:a}});if(u&&null!==u.SetRecordFavoriteStatus)return u.SetRecordFavoriteStatus.Success}async GetEntityRecordName(e,t){if(!e||!t||0===t.KeyValuePairs?.length)return null;const r=s.J1`query GetEntityRecordNameQuery ($EntityName: String!, $CompositeKey: CompositeKeyInputType!) {
385
+ GetEntityRecordName(EntityName: $EntityName, CompositeKey: $CompositeKey) {
386
+ Success
387
+ Status
388
+ RecordName
389
+ }
390
+ }`,a=await this.ExecuteGQL(r,{EntityName:e,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(t.KeyValuePairs)}});return a&&a.GetEntityRecordName&&a.GetEntityRecordName.Success?a.GetEntityRecordName.RecordName:void 0}async GetEntityRecordNames(e){if(!e)return null;const t=s.J1`query GetEntityRecordNamesQuery ($info: [EntityRecordNameInput!]!) {
391
+ GetEntityRecordNames(info: $info) {
392
+ Success
393
+ Status
394
+ CompositeKey {
395
+ KeyValuePairs {
396
+ FieldName
397
+ Value
398
+ }
399
+ }
400
+ EntityName
401
+ RecordName
402
+ }
403
+ }`,r=await this.ExecuteGQL(t,{info:e.map(e=>({EntityName:e.EntityName,CompositeKey:{KeyValuePairs:this.ensureKeyValuePairValueIsString(e.CompositeKey.KeyValuePairs)}}))});return r&&r.GetEntityRecordNames?r.GetEntityRecordNames:void 0}async GetDataContextData(e){try{const t=s.J1`query GetDataContextData ($DataContextID: String!) {
404
+ GetDataContextData(DataContextID: $DataContextID) {
405
+ Success
406
+ ErrorMessages
407
+ Results
408
+ }
409
+ }`,r=await this.ExecuteGQL(t,{DataContextID:e});if(r&&r.GetDataContextData){if(r.GetDataContextData.Success)return r.GetDataContextData.Results.map(e=>JSON.parse(e));throw new Error(r.GetDataContextData.ErrorMessages.join(", "))}throw new Error("GraphQL query failed")}catch(e){throw(0,a.ZI)(e),e}}async GetDataContextItemData(e){try{const t=s.J1`query GetDataContextItemData ($DataContextItemID: String!) {
410
+ GetDataContextItemData(DataContextItemID: $DataContextItemID) {
411
+ Success
412
+ ErrorMessage
413
+ Result
414
+ }
415
+ }`,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)}throw new Error("GraphQL query failed")}catch(e){throw(0,a.ZI)(e),e}}static async ExecuteGQL(e,t,r=!0){return f.Instance.ExecuteGQL(e,t,r)}async ExecuteGQL(e,t,r=!0){try{return await this._client.request(e,t)}catch(s){if(console.error("[GraphQL] ExecuteGQL error caught:",{hasResponse:!!s?.response,hasErrors:!!s?.response?.errors,errorCount:s?.response?.errors?.length,firstError:s?.response?.errors?.[0],errorCode:s?.response?.errors?.[0]?.extensions?.code,errorMessage:s?.response?.errors?.[0]?.message,fullError:s}),s&&s.response&&s.response.errors?.length>0){if("JWT_EXPIRED"===s.response.errors[0]?.extensions?.code?.toUpperCase().trim()){if(r)return await this.RefreshToken(),await this.ExecuteGQL(e,t,!1);throw(0,a.ZI)("JWT_EXPIRED and refreshTokenIfNeeded is false"),s}throw s}throw(0,a.ZI)(s),s}}async RefreshToken(){const e=f.Instance&&f.Instance._configData===this._configData;if(e&&f.Instance._refreshPromise)return f.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(f.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&f.Instance&&(f.Instance._refreshPromise=null)}}async performTokenRefresh(){if(!this._configData.Data.RefreshTokenFunction)throw new Error("No refresh token function provided");{const e=await this._configData.Data.RefreshTokenFunction();if(!e)throw new Error("Refresh token function returned null or undefined token");{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,f.Instance&&f.Instance._configData===this._configData&&(f.Instance._client=t)}}}static async RefreshToken(){return f.Instance.RefreshToken()}CreateNewGraphQLClient(e,t,r,a,n){const o={"x-session-id":r};return t&&(o.authorization="Bearer "+t),a&&(o["x-mj-api-key"]=a),n&&(o["x-api-key"]=n),new s.l4(e,{headers:o})}userInfoString(){return this.infoString(new a.oq(null,null))}userRoleInfoString(){return this.infoString(new a.St(null))}infoString(e){let t="";const r=Object.keys(e);for(const e of r)e.startsWith("__mj_")?t+=e.replace("__mj_","_mj__")+"\n ":e.startsWith("_")||(t+=e+"\n ");return t}get LocalStorageProvider(){return this._localStorageProvider||(typeof indexedDB<"u"?this._localStorageProvider=new E:this._localStorageProvider=new a.KW),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&&0===this._activeSubscriptionCount&&this.disposeWSClient(),this._wsClient||(this._wsClient=(0,c.UU)({url:this.ConfigData.WSURL,connectionParams:{Authorization:"Bearer "+this.ConfigData.Token},keepAlive:3e4,retryAttempts:3,shouldRetry:y(()=>!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(e){console.error(`[GraphQLDataProvider] Error cleaning up subject for ${t}:`,e)}}),this._pushStatusSubjects.clear()}cleanupStaleSubscriptions(){if(!this._isCleaningUp){this._isCleaningUp=!0;try{const e=Date.now(),t=(this._pushStatusSubjects.size,Array.from(this._pushStatusSubjects.entries())),r=[];t.forEach(([t,s])=>{const a=e-s.lastRequestedAt,n=e-s.lastEmissionAt;0===s.activeSubscribers&&a>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&n>=this.SUBSCRIPTION_IDLE_TIMEOUT_MS&&(console.log(`[GraphQLDataProvider] Marking session ${t} for cleanup: activeSubscribers=${s.activeSubscribers}, timeSinceRequested=${Math.round(a/1e3)}s, timeSinceEmission=${Math.round(n/1e3)}s`),r.push(t))}),r.forEach(e=>{const t=this._pushStatusSubjects.get(e);if(t)try{t.subject.complete(),t.subscription.unsubscribe(),this._pushStatusSubjects.delete(e),console.log(`[GraphQLDataProvider] Cleaned up stale subscription for session: ${e}`)}catch(t){console.error(`[GraphQLDataProvider] Error cleaning up subscription for ${e}:`,t)}}),r.length>0&&console.log(`[GraphQLDataProvider] Cleaned up ${r.length} stale subscription(s)`),0===this._pushStatusSubjects.size&&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 o.c(r=>{const s=this.getOrCreateWSClient();this._activeSubscriptionCount++;const a=s.subscribe({query:e,variables:t},{next:y(e=>{r.next(e.data)},"next"),error:y(async e=>{const t=e;if("JWT_EXPIRED"===t?.extensions?.code||t?.message?.includes("token has expired")||t?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] WebSocket JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),r.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for WebSocket:",e),r.error(e)}}else r.error(e)},"error"),complete:y(()=>{r.complete()},"complete")});return()=>{this._activeSubscriptionCount--,a()}})}PushStatusUpdates(e=null){e||(e=this.sessionId);const t=Date.now(),r=this._pushStatusSubjects.get(e);if(r)return r.lastRequestedAt=t,new o.c(t=>{r.activeSubscribers++;const s=r.subject.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}});const a=s.J1`subscription StatusUpdates($sessionId: String!) {
416
+ statusUpdates(sessionId: $sessionId) {
417
+ date
418
+ message
419
+ sessionId
420
+ }
421
+ }
422
+ `,n=new i.B,c=this.getOrCreateWSClient(),l=new u.yU;return l.add(new o.c(t=>{const r=c.subscribe({query:a,variables:{sessionId:e}},{next:y(r=>{const s=this._pushStatusSubjects.get(e);s&&(s.lastEmissionAt=Date.now()),t.next(r.data.statusUpdates.message)},"next"),error:y(async e=>{const r=e;if("JWT_EXPIRED"===r?.extensions?.code||r?.message?.includes("token has expired")||r?.message?.includes("JWT_EXPIRED")){console.log("[GraphQLDataProvider] PushStatusUpdates JWT token expired, refreshing and reconnecting...");try{await this.RefreshToken(),this.disposeWSClient(),t.complete()}catch(e){console.error("[GraphQLDataProvider] Failed to refresh token for PushStatusUpdates:",e),t.error(e)}}else t.error(e)},"error"),complete:y(()=>{t.complete()},"complete")});return this._activeSubscriptionCount++,()=>{this._activeSubscriptionCount--,r()}}).subscribe({next:y(e=>n.next(e),"next"),error:y(t=>{n.error(t),this._pushStatusSubjects.delete(e)},"error"),complete:y(()=>{n.complete(),this._pushStatusSubjects.delete(e)},"complete")})),this._pushStatusSubjects.set(e,{subject:n,subscription:l,createdAt:t,lastRequestedAt:t,lastEmissionAt:t,activeSubscribers:0}),new o.c(t=>{const r=this._pushStatusSubjects.get(e);r&&r.activeSubscribers++;const s=n.subscribe(t);return()=>{const t=this._pushStatusSubjects.get(e);t&&t.activeSubscribers>0&&t.activeSubscribers--,s.unsubscribe()}})}disposeWebSocketResources(){this._subscriptionCleanupTimer&&(clearInterval(this._subscriptionCleanupTimer),this._subscriptionCleanupTimer=null),this.completeAllSubjects(),this._activeSubscriptionCount=0,this.disposeWSClient()}}async function C(e){const t=new f;return(0,a.YE)(t),await t.Config(e),await a.jF.Instance.Startup(),d.rt.Instance.RaiseEvent({event:d.UK.LoggedIn,eventCode:null,component:this,args:null}),t}y(C,"setupGraphQLClient");class ${static{y(this,"SyncRolesAndUsersResult")}}class v{static{y(this,"RoleInput")}}class A{static{y(this,"UserInput")}}class N{static{y(this,"RolesAndUsersInput")}}var b,x=((b=x||{}).Create="Create",b.Update="Update",b.CreateOrUpdate="CreateOrUpdate",b.Delete="Delete",b.DeleteWithFilter="DeleteWithFilter",b);class M{static{y(this,"ActionItemInput")}}class G{static{y(this,"SyncDataResult")}constructor(){this.Results=[]}}class L{static{y(this,"ActionItemOutput")}}class Q{static{y(this,"GraphQLSystemUserClient")}get Client(){return this._client}constructor(e,t,r,a){const n={"x-session-id":r};this._sessionId=r,t&&(n.authorization="Bearer "+t),a&&(n["x-mj-api-key"]=a),this._client=new s.l4(e,{headers:n})}async GetData(e,t){try{const r=await this.Client.request("query GetData($input: GetDataInputType!) {\n GetData(input: $input) {\n Success\n ErrorMessages\n Queries\n Results\n }\n }",{input:{Queries:e,Token:t}});return r&&r.GetData?{Success:r.GetData.Success,Results:r.GetData.Results.map(e=>e?(0,d.NG)(e):null),ErrorMessages:r.GetData.ErrorMessages,Queries:r.GetData.Queries}:{Success:!1,Results:[],ErrorMessages:r.GetData?.ErrorMessages??["Unknown error"],Queries:r.GetData?.Queries??e}}catch(t){let r=t instanceof Error?t.message:String(t);const s=r.match(/Error: ([^:]+)\./);if(s&&(r=s[1]+"."),(0,a.l9)()){const e=`GraphQLSystemUserClient::GetData - Error getting data - ${t}`;(0,a.ZI)(e)}return{Success:!1,Results:[],ErrorMessages:[r],Queries:e}}}async GetAllRemoteEntities(){try{const e=await this.Client.request("query GetAllEntities {\n GetAllEntities {\n Success\n ErrorMessage\n Results {\n ID\n Name\n Description\n SchemaName\n BaseView\n BaseTable\n CodeName\n ClassName\n Fields {\n ID\n Name\n Description\n Type\n AllowsNull\n MaxLength\n }\n }\n }\n }");return e&&e.GetAllEntities?e.GetAllEntities:{Success:!1,Results:[],ErrorMessage:e.GetAllEntities?.ErrorMessage??"Unknown error"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::GetAllRemoteEntities - Error getting remote entities - ${e}`),{Success:!1,Results:[],ErrorMessage:e}}}async SyncData(e){try{const t=await this.Client.request("mutation SyncData($items: [ActionItemInputType!]!) {\n SyncData(items: $items) {\n Success\n Results {\n Success\n ErrorMessage\n EntityName\n Type\n PrimaryKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n AlternateKey {\n KeyValuePairs {\n FieldName\n Value \n }\n }\n DeleteFilter\n RecordJSON\n }\n }\n }",{items:e});return t&&t.SyncData?t.SyncData:{Success:!1,Results:[]}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncData - Error syncing data - ${e}`),{Success:!1,Results:[]}}}async SyncRolesAndUsers(e){try{const t=await this.Client.request("mutation SyncRolesAndUsers($data: RolesAndUsersInputType!) {\n SyncRolesAndUsers(data: $data) {\n Success\n }\n }",{data:e});return t&&t.SyncRolesAndUsers?t.SyncRolesAndUsers:{Success:!1}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::SyncRolesAndUsers - Error syncing roles and users - ${e}`),{Success:!1}}}async RunViewByName(e){try{const t=await this.Client.request("query RunViewByNameSystemUser($input: RunViewByNameInput!) {\n RunViewByNameSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",{input:e});return t&&t.RunViewByNameSystemUser?t.RunViewByNameSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by name"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByNameSystemUser - Error running view by name - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViewByID(e){try{const t=await this.Client.request("query RunViewByIDSystemUser($input: RunViewByIDInput!) {\n RunViewByIDSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",{input:e});return t&&t.RunViewByIDSystemUser?t.RunViewByIDSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute view by ID"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewByIDSystemUser - Error running view by ID - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunDynamicView(e){try{const t=await this.Client.request("query RunDynamicViewSystemUser($input: RunDynamicViewInput!) {\n RunDynamicViewSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",{input:e});return t&&t.RunDynamicViewSystemUser?t.RunDynamicViewSystemUser:{Results:[],Success:!1,ErrorMessage:"Failed to execute dynamic view"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunDynamicViewSystemUser - Error running dynamic view - ${e}`),{Results:[],Success:!1,ErrorMessage:e.toString()}}}async RunViews(e){try{const t=await this.Client.request("query RunViewsSystemUser($input: [RunViewGenericInput!]!) {\n RunViewsSystemUser(input: $input) {\n Results {\n PrimaryKey {\n FieldName\n Value\n }\n EntityID\n Data\n }\n UserViewRunID\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n Success\n }\n }",{input:e});return t&&t.RunViewsSystemUser?t.RunViewsSystemUser:[]}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunViewsSystemUser - Error running views - ${e}`),[]}}async GetQueryData(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataSystemUser($QueryID: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataSystemUser(QueryID: $QueryID, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryID:e.QueryID};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataSystemUser?{...s.GetQueryDataSystemUser,Results:s.GetQueryDataSystemUser.Results?(0,d.NG)(s.GetQueryDataSystemUser.Results):null}:{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataSystemUser - Error executing query - ${t}`),{QueryID:e.QueryID,QueryName:"",Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async GetQueryDataByName(e){try{if(void 0!==e.Parameters&&Array.isArray(e.Parameters))throw new Error("Parameters must be a JSON object, not an array. Use {} for empty parameters instead of [].");const t="query GetQueryDataByNameSystemUser($QueryName: String!, $CategoryID: String, $CategoryPath: String, $Parameters: JSONObject, $MaxRows: Int, $StartRow: Int) {\n GetQueryDataByNameSystemUser(QueryName: $QueryName, CategoryID: $CategoryID, CategoryPath: $CategoryPath, Parameters: $Parameters, MaxRows: $MaxRows, StartRow: $StartRow) {\n QueryID\n QueryName\n Success\n Results\n RowCount\n TotalRowCount\n ExecutionTime\n ErrorMessage\n AppliedParameters\n }\n }",r={QueryName:e.QueryName};void 0!==e.CategoryID&&(r.CategoryID=e.CategoryID),void 0!==e.CategoryPath&&(r.CategoryPath=e.CategoryPath),void 0!==e.Parameters&&(r.Parameters=e.Parameters),void 0!==e.MaxRows&&(r.MaxRows=e.MaxRows),void 0!==e.StartRow&&(r.StartRow=e.StartRow);const s=await this.Client.request(t,r);return s&&s.GetQueryDataByNameSystemUser?{...s.GetQueryDataByNameSystemUser,Results:s.GetQueryDataByNameSystemUser.Results?(0,d.NG)(s.GetQueryDataByNameSystemUser.Results):null}:{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:"Query execution failed"}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::GetQueryDataByNameSystemUser - Error executing query - ${t}`),{QueryID:"",QueryName:e.QueryName,Success:!1,Results:null,RowCount:0,TotalRowCount:0,ExecutionTime:0,ErrorMessage:t.toString()}}}async CreateQuery(e){try{const t=await this.Client.request("mutation CreateQuerySystemUser($input: CreateQuerySystemUserInput!) {\n CreateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.CreateQuerySystemUser?t.CreateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to create query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::CreateQuery - Error creating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async UpdateQuery(e){try{const t=await this.Client.request("mutation UpdateQuerySystemUser($input: UpdateQuerySystemUserInput!) {\n UpdateQuerySystemUser(input: $input) {\n Success\n ErrorMessage\n ID\n Name\n Description\n CategoryID\n Category\n SQL\n Status\n QualityRank\n EmbeddingVector\n EmbeddingModelID\n EmbeddingModelName\n Fields {\n ID\n QueryID\n Name\n Description\n Sequence\n SQLBaseType\n SQLFullType\n SourceEntityID\n SourceEntity\n SourceFieldName\n IsComputed\n ComputationDescription\n IsSummary\n SummaryDescription\n }\n Parameters {\n ID\n QueryID\n Name\n Description\n Type\n IsRequired\n DefaultValue\n SampleValue\n ValidationFilters\n }\n Entities {\n ID\n QueryID\n EntityID\n Entity\n }\n Permissions {\n ID\n QueryID\n RoleID\n Role\n }\n }\n }",{input:e});return t&&t.UpdateQuerySystemUser?t.UpdateQuerySystemUser:{Success:!1,ErrorMessage:"Failed to update query"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::UpdateQuery - Error updating query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async DeleteQuery(e,t){try{if(!e||""===e.trim())return(0,a.ZI)("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) {\n DeleteQuerySystemResolver(ID: $ID, options: $options) {\n Success\n ErrorMessage\n ID\n Name\n }\n }",s={ID:e};void 0!==t&&(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(e){return(0,a.ZI)(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${e}`),{Success:!1,ErrorMessage:e.toString()}}}async RunAIPrompt(e){try{const t=s.J1`
423
+ query RunAIPromptSystemUser(
424
+ $promptId: String!,
425
+ $data: String,
426
+ $overrideModelId: String,
427
+ $overrideVendorId: String,
428
+ $configurationId: String,
429
+ $skipValidation: Boolean,
430
+ $templateData: String,
431
+ $responseFormat: String,
432
+ $temperature: Float,
433
+ $topP: Float,
434
+ $topK: Int,
435
+ $minP: Float,
436
+ $frequencyPenalty: Float,
437
+ $presencePenalty: Float,
438
+ $seed: Int,
439
+ $stopSequences: [String!],
440
+ $includeLogProbs: Boolean,
441
+ $topLogProbs: Int,
442
+ $messages: String,
443
+ $rerunFromPromptRunID: String,
444
+ $systemPromptOverride: String
445
+ ) {
446
+ RunAIPromptSystemUser(
447
+ promptId: $promptId,
448
+ data: $data,
449
+ overrideModelId: $overrideModelId,
450
+ overrideVendorId: $overrideVendorId,
451
+ configurationId: $configurationId,
452
+ skipValidation: $skipValidation,
453
+ templateData: $templateData,
454
+ responseFormat: $responseFormat,
455
+ temperature: $temperature,
456
+ topP: $topP,
457
+ topK: $topK,
458
+ minP: $minP,
459
+ frequencyPenalty: $frequencyPenalty,
460
+ presencePenalty: $presencePenalty,
461
+ seed: $seed,
462
+ stopSequences: $stopSequences,
463
+ includeLogProbs: $includeLogProbs,
464
+ topLogProbs: $topLogProbs,
465
+ messages: $messages,
466
+ rerunFromPromptRunID: $rerunFromPromptRunID,
467
+ systemPromptOverride: $systemPromptOverride
468
+ ) {
469
+ success
470
+ output
471
+ parsedResult
472
+ error
473
+ executionTimeMs
474
+ tokensUsed
475
+ promptRunId
476
+ rawResult
477
+ validationResult
478
+ chatResult
479
+ }
480
+ }
481
+ `,r=this.preparePromptVariables(e),a=await this.Client.request(t,r);return a&&a.RunAIPromptSystemUser?this.processPromptResult(a.RunAIPromptSystemUser):{success:!1,error:"Failed to execute AI prompt as system user"}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunAIPrompt - Error running AI prompt - ${e}`),{success:!1,error:e.toString()}}}async RunAIAgent(e){try{const t=s.J1`
482
+ query RunAIAgentSystemUser(
483
+ $agentId: String!,
484
+ $messages: String!,
485
+ $sessionId: String!,
486
+ $data: String,
487
+ $templateData: String,
488
+ $lastRunId: String,
489
+ $autoPopulateLastRunPayload: Boolean,
490
+ $configurationId: String
491
+ ) {
492
+ RunAIAgentSystemUser(
493
+ agentId: $agentId,
494
+ messages: $messages,
495
+ sessionId: $sessionId,
496
+ data: $data,
497
+ templateData: $templateData,
498
+ lastRunId: $lastRunId,
499
+ autoPopulateLastRunPayload: $autoPopulateLastRunPayload,
500
+ configurationId: $configurationId
501
+ ) {
502
+ success
503
+ errorMessage
504
+ executionTimeMs
505
+ result
506
+ }
507
+ }
508
+ `,r=this.prepareAgentVariables(e),a=await this.Client.request(t,r);return a&&a.RunAIAgentSystemUser?this.processAgentResult(a.RunAIAgentSystemUser.result):{success:!1,agentRun:void 0}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::RunAIAgent - Error running AI agent - ${e}`),{success:!1,agentRun:void 0}}}preparePromptVariables(e){const t={promptId:e.promptId};return void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.templateData&&(t.templateData="object"==typeof e.templateData?JSON.stringify(e.templateData):e.templateData),void 0!==e.messages&&(t.messages=JSON.stringify(e.messages)),void 0!==e.overrideModelId&&(t.overrideModelId=e.overrideModelId),void 0!==e.overrideVendorId&&(t.overrideVendorId=e.overrideVendorId),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.skipValidation&&(t.skipValidation=e.skipValidation),void 0!==e.responseFormat&&(t.responseFormat=e.responseFormat),void 0!==e.temperature&&(t.temperature=e.temperature),void 0!==e.topP&&(t.topP=e.topP),void 0!==e.topK&&(t.topK=e.topK),void 0!==e.minP&&(t.minP=e.minP),void 0!==e.frequencyPenalty&&(t.frequencyPenalty=e.frequencyPenalty),void 0!==e.presencePenalty&&(t.presencePenalty=e.presencePenalty),void 0!==e.seed&&(t.seed=e.seed),void 0!==e.stopSequences&&(t.stopSequences=e.stopSequences),void 0!==e.includeLogProbs&&(t.includeLogProbs=e.includeLogProbs),void 0!==e.topLogProbs&&(t.topLogProbs=e.topLogProbs),void 0!==e.rerunFromPromptRunID&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),void 0!==e.systemPromptOverride&&(t.systemPromptOverride=e.systemPromptOverride),t}prepareAgentVariables(e){const t={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._sessionId};return void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.lastRunId&&(t.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(t.configurationId=e.configurationId),t}processPromptResult(e){let t,r,s;try{e.parsedResult&&(t=JSON.parse(e.parsedResult))}catch{t=e.parsedResult}try{e.validationResult&&(r=JSON.parse(e.validationResult))}catch{r=e.validationResult}try{e.chatResult&&(s=JSON.parse(e.chatResult))}catch{s=e.chatResult}return{success:e.success,output:e.output,parsedResult:t,error:e.error,executionTimeMs:e.executionTimeMs,tokensUsed:e.tokensUsed,promptRunId:e.promptRunId,rawResult:e.rawResult,validationResult:r,chatResult:s}}processAgentResult(e){return(0,d.NG)(e)}async ExecuteSimplePrompt(e){try{const t=s.J1`
509
+ query ExecuteSimplePromptSystemUser(
510
+ $systemPrompt: String!,
511
+ $messages: String,
512
+ $preferredModels: [String!],
513
+ $modelPower: String,
514
+ $responseFormat: String
515
+ ) {
516
+ ExecuteSimplePromptSystemUser(
517
+ systemPrompt: $systemPrompt,
518
+ messages: $messages,
519
+ preferredModels: $preferredModels,
520
+ modelPower: $modelPower,
521
+ responseFormat: $responseFormat
522
+ ) {
523
+ success
524
+ result
525
+ resultObject
526
+ modelName
527
+ error
528
+ executionTimeMs
529
+ }
530
+ }
531
+ `,r={systemPrompt:e.systemPrompt};e.messages&&e.messages.length>0&&(r.messages=JSON.stringify(e.messages)),e.preferredModels&&(r.preferredModels=e.preferredModels),e.modelPower&&(r.modelPower=e.modelPower),e.responseFormat&&(r.responseFormat=e.responseFormat);const a=await this.Client.request(t,r);if(!a?.ExecuteSimplePromptSystemUser)return{success:!1,modelName:"Unknown",error:"Failed to execute simple prompt as system user"};const n=a.ExecuteSimplePromptSystemUser;let o;if(n.resultObject)try{o=JSON.parse(n.resultObject)}catch{o=n.resultObject}return{success:n.success,result:n.result,resultObject:o,modelName:n.modelName,error:n.error,executionTimeMs:n.executionTimeMs}}catch(e){return(0,a.ZI)(`GraphQLSystemUserClient::ExecuteSimplePrompt - Error executing simple prompt - ${e}`),{success:!1,modelName:"Unknown",error:e.toString()}}}async EmbedText(e){try{const t=s.J1`
532
+ query EmbedTextSystemUser(
533
+ $textToEmbed: [String!]!,
534
+ $modelSize: String!
535
+ ) {
536
+ EmbedTextSystemUser(
537
+ textToEmbed: $textToEmbed,
538
+ modelSize: $modelSize
539
+ ) {
540
+ embeddings
541
+ modelName
542
+ vectorDimensions
543
+ error
544
+ }
545
+ }
546
+ `,r={textToEmbed:Array.isArray(e.textToEmbed)?e.textToEmbed:[e.textToEmbed],modelSize:e.modelSize},a=await this.Client.request(t,r);if(!a?.EmbedTextSystemUser)return{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:"Failed to generate embeddings as system user"};const n=a.EmbedTextSystemUser;return{embeddings:Array.isArray(e.textToEmbed)?n.embeddings:n.embeddings[0],modelName:n.modelName,vectorDimensions:n.vectorDimensions,error:n.error}}catch(t){return(0,a.ZI)(`GraphQLSystemUserClient::EmbedText - Error generating embeddings - ${t}`),{embeddings:(Array.isArray(e.textToEmbed),[]),modelName:"Unknown",vectorDimensions:0,error:t.toString()}}}}class T{static{y(this,"GetDataOutput")}}class U{static{y(this,"SimpleRemoteEntityOutput")}}class V{static{y(this,"SimpleRemoteEntity")}}class _{static{y(this,"SimpleRemoteEntityField")}}class F{static{y(this,"GraphQLActionClient")}constructor(e){this._dataProvider=e}async RunAction(e,t,r=!1){try{const s=this.serializeActionParameters(t),a=this.createActionVariables(e,s,r),n=await this.executeActionMutation(a);return this.processActionResult(n,t)}catch(e){return this.handleActionError(e,t)}}serializeActionParameters(e){if(e)return e.map(e=>{let t=e.Value;return null!=t&&"object"==typeof t&&(t=JSON.stringify(t)),{...e,Value:t}})}createActionVariables(e,t,r=!1){return{input:{ActionID:e,Params:t,SkipActionLog:r}}}async executeActionMutation(e){const t=s.J1`
547
+ mutation RunAction($input: RunActionInput!) {
548
+ RunAction(input: $input) {
549
+ Success
550
+ Message
551
+ ResultCode
552
+ ResultData
553
+ }
554
+ }
555
+ `;return await this._dataProvider.ExecuteGQL(t,e)}processActionResult(e,t){if(!e?.RunAction)throw new Error("Invalid response from server");let r;try{e.RunAction.ResultData&&(r=JSON.parse(e.RunAction.ResultData))}catch(e){(0,a.ZI)(`Failed to parse action result data: ${e}`)}return{Success:e.RunAction.Success,Message:e.RunAction.Message,Result:r,LogEntry:null,Params:t||[],RunParams:null}}handleActionError(e,t){const r=e;return(0,a.ZI)(`Error running action: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Result:null,LogEntry:null,Params:t||[],RunParams:null}}async RunEntityAction(e){try{const t=this.createEntityActionInput(e),r=await this.executeEntityActionMutation(t);return this.processEntityActionResult(r)}catch(e){return this.handleEntityActionError(e)}}createEntityActionInput(e){const t={EntityActionID:e.EntityAction.ID,InvocationType:e.InvocationType.Name,ListID:e.ListID,ViewID:e.ViewID};return e.Params&&(t.Params=this.convertActionParams(e.Params)),e.EntityObject&&this.addEntityInformation(t,e.EntityObject),t}convertActionParams(e){return e.map(e=>{let t=e.Value;return null!=t&&"object"==typeof t&&(t=JSON.stringify(t)),{Name:e.Name,Value:t,Type:e.Type}})}addEntityInformation(e,t){e.EntityName=t.EntityInfo?.Name,t.PrimaryKey&&(e.PrimaryKey=this.convertPrimaryKey(t.PrimaryKey))}convertPrimaryKey(e){return{KeyValuePairs:e.KeyValuePairs.map(e=>this.convertKeyValuePair(e))}}convertKeyValuePair(e){return{FieldName:e.FieldName,Value:null!==e.Value&&void 0!==e.Value?"object"==typeof e.Value?JSON.stringify(e.Value):e.Value.toString():null}}async executeEntityActionMutation(e){const t=s.J1`
556
+ mutation RunEntityAction($input: EntityActionInput!) {
557
+ RunEntityAction(input: $input) {
558
+ Success
559
+ Message
560
+ ResultData
561
+ }
562
+ }
563
+ `;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(e){(0,a.ZI)(`Failed to parse entity action result data: ${e}`)}return{Success:e.RunEntityAction.Success,Message:e.RunEntityAction.Message,RunParams:null,LogEntry:null,...t}}handleEntityActionError(e){const t=e;return(0,a.ZI)(`Error running entity action: ${t}`),{Success:!1,Message:`Error: ${t.message}`,RunParams:null,LogEntry:null}}}class O{static{y(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(e){return this.handleCreateAPIKeyError(e)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=s.J1`
564
+ mutation CreateAPIKey($input: CreateAPIKeyInput!) {
565
+ CreateAPIKey(input: $input) {
566
+ Success
567
+ RawKey
568
+ APIKeyID
569
+ Error
570
+ }
571
+ }
572
+ `;return await this._dataProvider.ExecuteGQL(t,e)}processCreateAPIKeyResult(e){const t=e;return t?.CreateAPIKey?{Success:t.CreateAPIKey.Success,RawKey:t.CreateAPIKey.RawKey,APIKeyID:t.CreateAPIKey.APIKeyID,Error:t.CreateAPIKey.Error}:{Success:!1,Error:"Invalid response from server"}}handleCreateAPIKeyError(e){const t=e;return(0,a.ZI)(`Error creating API key: ${t.message}`),{Success:!1,Error:`Error: ${t.message}`}}async RevokeAPIKey(e){try{const t=s.J1`
573
+ mutation RevokeAPIKey($apiKeyId: String!) {
574
+ RevokeAPIKey(apiKeyId: $apiKeyId) {
575
+ Success
576
+ Error
577
+ }
578
+ }
579
+ `,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(e){const t=e;return(0,a.ZI)(`Error revoking API key: ${t.message}`),{Success:!1,Error:`Error: ${t.message}`}}}}class K{static{y(this,"GraphQLTestingClient")}constructor(e){this._dataProvider=e}async RunTest(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);"RunTestResolver"===r.resolver&&"TestExecutionProgress"===r.type&&"ok"===r.status&&r.data?.progress&&e.onProgress(r.data.progress)}catch(e){console.error("[GraphQLTestingClient] Failed to parse progress message:",e)}}));const r=s.J1`
580
+ mutation RunTest(
581
+ $testId: String!,
582
+ $verbose: Boolean,
583
+ $environment: String,
584
+ $tags: String,
585
+ $variables: String
586
+ ) {
587
+ RunTest(
588
+ testId: $testId,
589
+ verbose: $verbose,
590
+ environment: $environment,
591
+ tags: $tags,
592
+ variables: $variables
593
+ ) {
594
+ success
595
+ errorMessage
596
+ executionTimeMs
597
+ result
598
+ }
599
+ }
600
+ `,a=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,n=e.variables?JSON.stringify(e.variables):void 0,o={testId:e.testId,verbose:e.verbose,environment:e.environment,tags:a,variables:n},i=await this._dataProvider.ExecuteGQL(r,o);return this.processTestResult(i.RunTest)}catch(e){return this.handleError(e,"RunTest")}finally{t&&t.unsubscribe()}}async RunTestSuite(e){let t;try{e.onProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);"RunTestResolver"===r.resolver&&"TestExecutionProgress"===r.type&&"ok"===r.status&&r.data?.progress&&e.onProgress(r.data.progress)}catch(e){console.error("[GraphQLTestingClient] Failed to parse progress message:",e)}}));const r=s.J1`
601
+ mutation RunTestSuite(
602
+ $suiteId: String!,
603
+ $verbose: Boolean,
604
+ $environment: String,
605
+ $parallel: Boolean,
606
+ $tags: String,
607
+ $variables: String,
608
+ $selectedTestIds: String,
609
+ $sequenceStart: Int,
610
+ $sequenceEnd: Int
611
+ ) {
612
+ RunTestSuite(
613
+ suiteId: $suiteId,
614
+ verbose: $verbose,
615
+ environment: $environment,
616
+ parallel: $parallel,
617
+ tags: $tags,
618
+ variables: $variables,
619
+ selectedTestIds: $selectedTestIds,
620
+ sequenceStart: $sequenceStart,
621
+ sequenceEnd: $sequenceEnd
622
+ ) {
623
+ success
624
+ errorMessage
625
+ executionTimeMs
626
+ result
627
+ }
628
+ }
629
+ `,a=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,n=e.variables?JSON.stringify(e.variables):void 0,o=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0,i={suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:a,variables:n,selectedTestIds:o,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd},u=await this._dataProvider.ExecuteGQL(r,i);return this.processSuiteResult(u.RunTestSuite)}catch(e){return this.handleError(e,"RunTestSuite")}finally{t&&t.unsubscribe()}}async IsTestRunning(e){try{const t=s.J1`
630
+ query IsTestRunning($testId: String!) {
631
+ IsTestRunning(testId: $testId)
632
+ }
633
+ `;return(await this._dataProvider.ExecuteGQL(t,{testId:e})).IsTestRunning}catch(e){return(0,a.ZI)(`Error checking test running status: ${e.message}`),!1}}processTestResult(e){if(!e)throw new Error("Invalid response from server");let t;try{t=(0,d.NG)(e.result)}catch{t=e.result}return{success:e.success,errorMessage:e.errorMessage,executionTimeMs:e.executionTimeMs,result:t}}processSuiteResult(e){if(!e)throw new Error("Invalid response from server");let t;try{t=(0,d.NG)(e.result)}catch{t=e.result}return{success:e.success,errorMessage:e.errorMessage,executionTimeMs:e.executionTimeMs,result:t}}handleError(e,t){const r=e.message;return(0,a.ZI)(`${t} failed: ${r}`),{success:!1,errorMessage:r,result:null}}}class j{static{y(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=s.J1`
634
+ query GetRegistryComponent(
635
+ $registryName: String!,
636
+ $namespace: String!,
637
+ $name: String!,
638
+ $version: String,
639
+ $hash: String
640
+ ) {
641
+ GetRegistryComponent(
642
+ registryName: $registryName,
643
+ namespace: $namespace,
644
+ name: $name,
645
+ version: $version,
646
+ hash: $hash
647
+ ) {
648
+ hash
649
+ notModified
650
+ message
651
+ specification
652
+ }
653
+ }
654
+ `,r={registryName:e.registryName,namespace:e.namespace,name:e.name};void 0!==e.version&&(r.version=e.version),void 0!==e.hash&&(r.hash=e.hash);const n=await this._dataProvider.ExecuteGQL(t,r);if(n&&n.GetRegistryComponent){const e=n.GetRegistryComponent;if(e.notModified&&!e.specification)return null;if(e.specification){if("object"==typeof e.specification)return e.specification;try{return JSON.parse(e.specification)}catch(e){return(0,a.ZI)(`Failed to parse component specification: ${e}`),null}}return null}return null}catch(e){throw(0,a.ZI)(e),new Error(`Failed to get registry component: ${e instanceof Error?e.message:"Unknown error"}`)}}async GetRegistryComponentWithHash(e){try{const t=s.J1`
655
+ query GetRegistryComponent(
656
+ $registryName: String!,
657
+ $namespace: String!,
658
+ $name: String!,
659
+ $version: String,
660
+ $hash: String
661
+ ) {
662
+ GetRegistryComponent(
663
+ registryName: $registryName,
664
+ namespace: $namespace,
665
+ name: $name,
666
+ version: $version,
667
+ hash: $hash
668
+ ) {
669
+ hash
670
+ notModified
671
+ message
672
+ specification
673
+ }
674
+ }
675
+ `,r={registryName:e.registryName,namespace:e.namespace,name:e.name};void 0!==e.version&&(r.version=e.version),void 0!==e.hash&&(r.hash=e.hash);const n=await this._dataProvider.ExecuteGQL(t,r);if(n&&n.GetRegistryComponent){const e=n.GetRegistryComponent;let t;if(e.specification)try{t=JSON.parse(e.specification)}catch(e){(0,a.ZI)(`Failed to parse component specification in GetRegistryComponentWithHash: ${e}`),t=void 0}return{specification:t,hash:e.hash,notModified:e.notModified,message:e.message}}return{specification:void 0,hash:"",notModified:!1,message:"Component not found"}}catch(e){throw(0,a.ZI)(e),new Error(`Failed to get registry component with hash: ${e instanceof Error?e.message:"Unknown error"}`)}}async SearchRegistryComponents(e){try{const t=s.J1`
676
+ query SearchRegistryComponents($params: SearchRegistryComponentsInput!) {
677
+ SearchRegistryComponents(params: $params) {
678
+ components
679
+ total
680
+ offset
681
+ limit
682
+ }
683
+ }
684
+ `,r=await this._dataProvider.ExecuteGQL(t,{params:e});if(r&&r.SearchRegistryComponents){const e=r.SearchRegistryComponents;return{components:e.components.map(e=>JSON.parse(e)),total:e.total,offset:e.offset,limit:e.limit}}return{components:[],total:0,offset:0,limit:e.limit||10}}catch(e){throw(0,a.ZI)(e),new Error(`Failed to search registry components: ${e instanceof Error?e.message:"Unknown error"}`)}}async ResolveComponentDependencies(e,t){try{const r=s.J1`
685
+ query ResolveComponentDependencies(
686
+ $registryId: String!,
687
+ $componentId: String!
688
+ ) {
689
+ ResolveComponentDependencies(
690
+ registryId: $registryId,
691
+ componentId: $componentId
692
+ ) {
693
+ componentId
694
+ name
695
+ namespace
696
+ version
697
+ circular
698
+ totalCount
699
+ dependencies {
700
+ componentId
701
+ name
702
+ namespace
703
+ version
704
+ circular
705
+ totalCount
706
+ }
707
+ }
708
+ }
709
+ `,a=await this._dataProvider.ExecuteGQL(r,{registryId:e,componentId:t});return a&&a.ResolveComponentDependencies?a.ResolveComponentDependencies:null}catch(e){throw(0,a.ZI)(e),new Error(`Failed to resolve component dependencies: ${e instanceof Error?e.message:"Unknown error"}`)}}async ComponentExists(e){try{return null!==await this.GetRegistryComponent(e)}catch{return!1}}async GetLatestVersion(e,t,r){try{return(await this.GetRegistryComponent({registryName:e,namespace:t,name:r,version:"latest"}))?.version||null}catch(e){return(0,a.ZI)(e),null}}async SendComponentFeedback(e){try{const t=s.J1`
710
+ mutation SendComponentFeedback($feedback: ComponentFeedbackInput!) {
711
+ SendComponentFeedback(feedback: $feedback) {
712
+ success
713
+ feedbackID
714
+ error
715
+ }
716
+ }
717
+ `,r=await this._dataProvider.ExecuteGQL(t,{feedback:e});return r&&r.SendComponentFeedback?r.SendComponentFeedback:{success:!1,error:"No response from server"}}catch(e){return(0,a.ZI)(e),{success:!1,error:e instanceof Error?e.message:"Unknown error"}}}}class J{static{y(this,"GraphQLVersionHistoryClient")}constructor(e){this._dataProvider=e}async CreateLabel(e){let t;try{e.OnProgress&&(t=this._dataProvider.PushStatusUpdates(this._dataProvider.sessionId).subscribe(t=>{try{const r=JSON.parse(t);"VersionHistoryResolver"===r.resolver&&"CreateLabelProgress"===r.type&&"ok"===r.status&&r.data&&e.OnProgress(r.data)}catch{}}));const r=s.J1`
718
+ mutation CreateVersionLabel($input: CreateVersionLabelInput!, $sessionId: String) {
719
+ CreateVersionLabel(input: $input, sessionId: $sessionId) {
720
+ Success
721
+ LabelID
722
+ LabelName
723
+ ItemsCaptured
724
+ SyntheticSnapshotsCreated
725
+ Error
726
+ CaptureErrors {
727
+ EntityName
728
+ RecordID
729
+ ErrorMessage
730
+ }
731
+ }
732
+ }
733
+ `,a={input:this.buildInput(e),sessionId:this._dataProvider.sessionId},n=await this._dataProvider.ExecuteGQL(r,a);return this.processResult(n)}catch(e){const t=e instanceof Error?e.message:String(e);return(0,a.ZI)(`GraphQLVersionHistoryClient.CreateLabel error: ${t}`),{Success:!1,Error:t}}finally{t&&t.unsubscribe()}}buildInput(e){const t={Name:e.Name};return null!=e.Description&&(t.Description=e.Description),null!=e.Scope&&(t.Scope=e.Scope),null!=e.EntityName&&(t.EntityName=e.EntityName),null!=e.ParentID&&(t.ParentID=e.ParentID),null!=e.ExternalSystemID&&(t.ExternalSystemID=e.ExternalSystemID),null!=e.IncludeDependencies&&(t.IncludeDependencies=e.IncludeDependencies),null!=e.MaxDepth&&(t.MaxDepth=e.MaxDepth),null!=e.ExcludeEntities&&(t.ExcludeEntities=e.ExcludeEntities),e.RecordKeys&&e.RecordKeys.length>0&&(t.RecordKeys=e.RecordKeys.map(e=>({Key:e.Key,Value:e.Value}))),t}processResult(e){const t=e?.CreateVersionLabel;if(!t)return{Success:!1,Error:"Invalid response from server."};const r=Array.isArray(t.CaptureErrors)?t.CaptureErrors.map(e=>({EntityName:e.EntityName??"",RecordID:e.RecordID??"",ErrorMessage:e.ErrorMessage??""})):void 0;return{Success:t.Success,LabelID:t.LabelID,LabelName:t.LabelName,ItemsCaptured:t.ItemsCaptured,SyntheticSnapshotsCreated:t.SyntheticSnapshotsCreated,Error:t.Error,CaptureErrors:r}}}class k{static{y(this,"GraphQLFileStorageClient")}constructor(e){this._dataProvider=e}async ListObjects(e,t="",r){try{const a=s.J1`
734
+ query ListStorageObjects($input: ListStorageObjectsInput!) {
735
+ ListStorageObjects(input: $input) {
736
+ objects {
737
+ name
738
+ path
739
+ fullPath
740
+ size
741
+ contentType
742
+ lastModified
743
+ isDirectory
744
+ etag
745
+ cacheControl
746
+ }
747
+ prefixes
748
+ }
749
+ }
750
+ `,n={input:{AccountID:e,Prefix:t,Delimiter:r||"/"}},o=await this._dataProvider.ExecuteGQL(a,n);if(!o?.ListStorageObjects)throw new Error("Invalid response from server");return{objects:o.ListStorageObjects.objects.map(e=>({...e,lastModified:new Date(e.lastModified)})),prefixes:o.ListStorageObjects.prefixes}}catch(e){const t=e;throw(0,a.ZI)(`Error listing storage objects: ${t}`),t}}async DirectoryExists(e,t){try{const r=await this.ListObjects(e,t.endsWith("/")?t:`${t}/`,"/");return r.objects.length>0||r.prefixes.length>0}catch(e){return(0,a.ZI)(`Error checking directory existence: ${e}`),!1}}async CreateDirectory(e,t){try{const r=s.J1`
751
+ mutation CreateDirectory($input: CreateDirectoryInput!) {
752
+ CreateDirectory(input: $input)
753
+ }
754
+ `,a={input:{AccountID:e,Path:t}};return(await this._dataProvider.ExecuteGQL(r,a))?.CreateDirectory??!1}catch(e){return(0,a.ZI)(`Error creating directory: ${e}`),!1}}async ObjectExists(e,t){try{const r=t.substring(0,t.lastIndexOf("/")+1),s=t.substring(t.lastIndexOf("/")+1);return(await this.ListObjects(e,r,"/")).objects.some(e=>e.name===s||e.fullPath===t)}catch(e){return(0,a.ZI)(`Error checking object existence: ${e}`),!1}}async CreatePreAuthUploadUrl(e,t,r){try{const a=s.J1`
755
+ mutation CreatePreAuthUploadUrl($input: CreatePreAuthUploadUrlInput!) {
756
+ CreatePreAuthUploadUrl(input: $input) {
757
+ UploadUrl
758
+ ProviderKey
759
+ }
760
+ }
761
+ `,n={input:{AccountID:e,ObjectName:t,ContentType:r}},o=await this._dataProvider.ExecuteGQL(a,n);if(!o?.CreatePreAuthUploadUrl)throw new Error("Invalid response from server");return{uploadUrl:o.CreatePreAuthUploadUrl.UploadUrl,providerKey:o.CreatePreAuthUploadUrl.ProviderKey}}catch(e){const t=e;throw(0,a.ZI)(`Error creating pre-auth upload URL: ${t}`),t}}async CreatePreAuthDownloadUrl(e,t){try{const r=s.J1`
762
+ query CreatePreAuthDownloadUrl($input: CreatePreAuthDownloadUrlInput!) {
763
+ CreatePreAuthDownloadUrl(input: $input)
764
+ }
765
+ `,a={input:{AccountID:e,ObjectName:t}},n=await this._dataProvider.ExecuteGQL(r,a);if(void 0===n?.CreatePreAuthDownloadUrl)throw new Error("Invalid response from server");return n.CreatePreAuthDownloadUrl}catch(e){const t=e;throw(0,a.ZI)(`Error creating pre-auth download URL: ${t}`),t}}async DeleteObject(e,t){try{const r=s.J1`
766
+ mutation DeleteStorageObject($input: DeleteStorageObjectInput!) {
767
+ DeleteStorageObject(input: $input)
768
+ }
769
+ `,a={input:{AccountID:e,ObjectName:t}};return(await this._dataProvider.ExecuteGQL(r,a))?.DeleteStorageObject??!1}catch(e){return(0,a.ZI)(`Error deleting storage object: ${e}`),!1}}async MoveObject(e,t,r){try{const a=s.J1`
770
+ mutation MoveStorageObject($input: MoveStorageObjectInput!) {
771
+ MoveStorageObject(input: $input)
772
+ }
773
+ `,n={input:{AccountID:e,OldName:t,NewName:r}};return(await this._dataProvider.ExecuteGQL(a,n))?.MoveStorageObject??!1}catch(e){return(0,a.ZI)(`Error moving storage object: ${e}`),!1}}async CopyObject(e,t,r){try{const a=s.J1`
774
+ mutation CopyStorageObject($input: CopyStorageObjectInput!) {
775
+ CopyStorageObject(input: $input)
776
+ }
777
+ `,n={input:{AccountID:e,SourceName:t,DestinationName:r}};return(await this._dataProvider.ExecuteGQL(a,n))?.CopyStorageObject??!1}catch(e){return(0,a.ZI)(`Error copying storage object: ${e}`),!1}}async CopyObjectBetweenAccounts(e,t,r,n){try{const a=s.J1`
778
+ mutation CopyObjectBetweenAccounts($input: CopyObjectBetweenAccountsInput!) {
779
+ CopyObjectBetweenAccounts(input: $input) {
780
+ success
781
+ message
782
+ bytesTransferred
783
+ sourceAccount
784
+ destinationAccount
785
+ sourcePath
786
+ destinationPath
787
+ }
788
+ }
789
+ `,o={input:{SourceAccountID:e,DestinationAccountID:t,SourcePath:r,DestinationPath:n}},i=await this._dataProvider.ExecuteGQL(a,o);if(!i?.CopyObjectBetweenAccounts)throw new Error("Invalid response from server");return{success:i.CopyObjectBetweenAccounts.success,message:i.CopyObjectBetweenAccounts.message,bytesTransferred:i.CopyObjectBetweenAccounts.bytesTransferred,sourceAccount:i.CopyObjectBetweenAccounts.sourceAccount,destinationAccount:i.CopyObjectBetweenAccounts.destinationAccount,sourcePath:i.CopyObjectBetweenAccounts.sourcePath,destinationPath:i.CopyObjectBetweenAccounts.destinationPath}}catch(e){const t=e;return(0,a.ZI)(`Error copying object between accounts: ${t}`),{success:!1,message:t.message,sourceAccount:"",destinationAccount:"",sourcePath:r,destinationPath:n}}}async SearchFiles(e,t,r){try{const a=s.J1`
790
+ query SearchAcrossAccounts($input: SearchAcrossAccountsInput!) {
791
+ SearchAcrossAccounts(input: $input) {
792
+ accountResults {
793
+ accountID
794
+ accountName
795
+ success
796
+ errorMessage
797
+ results {
798
+ path
799
+ name
800
+ size
801
+ contentType
802
+ lastModified
803
+ relevance
804
+ excerpt
805
+ matchInFilename
806
+ objectId
807
+ }
808
+ totalMatches
809
+ hasMore
810
+ nextPageToken
811
+ }
812
+ totalResultsReturned
813
+ successfulAccounts
814
+ failedAccounts
815
+ }
816
+ }
817
+ `,n={input:{AccountIDs:e,Query:t,MaxResultsPerAccount:r?.maxResultsPerAccount,FileTypes:r?.fileTypes,SearchContent:r?.searchContent}},o=await this._dataProvider.ExecuteGQL(a,n);if(!o?.SearchAcrossAccounts)throw new Error("Invalid response from server");const i=o.SearchAcrossAccounts;return{accountResults:i.accountResults.map(e=>({accountId:e.accountID,accountName:e.accountName,success:e.success,errorMessage:e.errorMessage,results:e.results.map(e=>({path:e.path,name:e.name,size:e.size,contentType:e.contentType,lastModified:new Date(e.lastModified),relevance:e.relevance,excerpt:e.excerpt,matchInFilename:e.matchInFilename,objectId:e.objectId})),totalMatches:e.totalMatches,hasMore:e.hasMore,nextPageToken:e.nextPageToken})),totalResultsReturned:i.totalResultsReturned,successfulAccounts:i.successfulAccounts,failedAccounts:i.failedAccounts}}catch(t){return(0,a.ZI)(`Error searching across accounts: ${t}`),{accountResults:[],totalResultsReturned:0,successfulAccounts:0,failedAccounts:e.length}}}}}}]);