@memberjunction/react-runtime 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +18 -19
- package/CHANGELOG.md +16 -0
- package/dist/324.runtime.umd.js +14 -14
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +0 -58
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +7 -6
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/runtime.umd.js +1 -1
- package/package.json +6 -6
- package/src/component-manager/component-manager.ts +5 -64
- package/src/registry/component-registry-service.ts +9 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
1
|
|
|
2
|
-
> @memberjunction/react-runtime@5.
|
|
2
|
+
> @memberjunction/react-runtime@5.5.0 build
|
|
3
3
|
> npm run build:node && npm run build:umd
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @memberjunction/react-runtime@5.
|
|
6
|
+
> @memberjunction/react-runtime@5.5.0 build:node
|
|
7
7
|
> tsc
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @memberjunction/react-runtime@5.
|
|
10
|
+
> @memberjunction/react-runtime@5.5.0 build:umd
|
|
11
11
|
> webpack --config webpack.umd.config.cjs
|
|
12
12
|
|
|
13
13
|
[BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/MJ/MJ/packages/MJCoreEntities/dist/generated/entity_subclasses.js as it exceeds the max of 500KB.
|
|
14
|
-
asset [1m[33mruntime.umd.js[39m[22m [1m[33m2.
|
|
15
|
-
asset [1m[32m324.runtime.umd.js[39m[22m
|
|
14
|
+
asset [1m[33mruntime.umd.js[39m[22m [1m[33m2.31 MiB[39m[22m [1m[32m[emitted][39m[22m [1m[32m[minimized][39m[22m [1m[33m[big][39m[22m (name: main) 1 related asset
|
|
15
|
+
asset [1m[32m324.runtime.umd.js[39m[22m 117 KiB [1m[32m[emitted][39m[22m [1m[32m[minimized][39m[22m
|
|
16
16
|
asset [1m[32m490.runtime.umd.js[39m[22m 61.7 KiB [1m[32m[emitted][39m[22m [1m[32m[minimized][39m[22m (id hint: vendors)
|
|
17
|
-
orphan modules 5.
|
|
17
|
+
orphan modules 5.64 MiB [1m[33m[orphan][39m[22m 490 modules
|
|
18
18
|
runtime modules 6.94 KiB 10 modules
|
|
19
|
-
built modules 5.
|
|
19
|
+
built modules 5.75 MiB [1m[33m[built][39m[22m
|
|
20
20
|
modules by path [1m../../../node_modules/[39m[22m 780 KiB 23 modules
|
|
21
|
-
modules by path [1m../../
|
|
22
|
-
[1m../../
|
|
23
|
-
[1m../../MJCoreEntities/dist/engines/UserViewEngine.js[39m[22m 18.7 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
24
|
-
modules by path [1m../../MJGlobal/dist/[39m[22m 193 KiB
|
|
25
|
-
[1m../../MJGlobal/dist/index.js + 16 modules[39m[22m 193 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
21
|
+
modules by path [1m../../MJGlobal/dist/[39m[22m 195 KiB
|
|
22
|
+
[1m../../MJGlobal/dist/index.js + 17 modules[39m[22m 194 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
26
23
|
[1m../../MJGlobal/dist/ lazy strict namespace object[39m[22m 160 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
modules by path [1m../../MJCoreEntities/dist/[39m[22m 3.19 MiB
|
|
25
|
+
[1m../../MJCoreEntities/dist/index.js + 23 modules[39m[22m 3.17 MiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
26
|
+
[1m../../MJCoreEntities/dist/engines/UserViewEngine.js[39m[22m 18.9 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
27
|
+
[1m./dist/index.js + 27 modules[39m[22m 423 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
28
|
+
[1m../../MJCore/dist/index.js + 73 modules[39m[22m 1.09 MiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
29
|
+
[1m../../GraphQLDataProvider/dist/index.mjs[39m[22m 117 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
30
30
|
|
|
31
31
|
[1m[33mWARNING[39m[22m in [1m../../MJGlobal/dist/DynamicPackageLoader.js[39m[22m [1m[32m80:21-44[39m[22m
|
|
32
32
|
[1mCritical dependency: the request of a dependency is an expression[39m[22m
|
|
33
|
-
@ ../../MJGlobal/dist/index.js
|
|
34
|
-
@
|
|
35
|
-
@ ./dist/registry/component-registry-service.js 75:21-67
|
|
33
|
+
@ ../../MJGlobal/dist/index.js 22:0-42 22:0-42
|
|
34
|
+
@ ./dist/registry/component-registry-service.js
|
|
36
35
|
@ ./dist/registry/index.js 3:0-72 3:0-72
|
|
37
36
|
@ ./dist/index.js 8:0-47 63:21-38 9:0-47 64:21-38 14:0-47 14:0-47 15:0-88 15:0-88 15:0-88 15:0-88
|
|
38
37
|
|
|
39
38
|
1 warning has detailed information that is not shown.
|
|
40
39
|
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
|
|
41
40
|
|
|
42
|
-
webpack 5.105.0 compiled with [1m[33m1 warning[39m[22m in
|
|
41
|
+
webpack 5.105.0 compiled with [1m[33m1 warning[39m[22m in 146677 ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @memberjunction/react-runtime
|
|
2
2
|
|
|
3
|
+
## 5.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2b1d842: Add Qwen 3.5 Plus AI model metadata and revert diagnostic logging for component registry loading
|
|
8
|
+
- df2457c: no migration, just small code changes
|
|
9
|
+
- Updated dependencies [2b1d842]
|
|
10
|
+
- Updated dependencies [a1648c5]
|
|
11
|
+
- Updated dependencies [ee9f788]
|
|
12
|
+
- Updated dependencies [df2457c]
|
|
13
|
+
- @memberjunction/core@5.5.0
|
|
14
|
+
- @memberjunction/graphql-dataprovider@5.5.0
|
|
15
|
+
- @memberjunction/core-entities@5.5.0
|
|
16
|
+
- @memberjunction/global@5.5.0
|
|
17
|
+
- @memberjunction/interactive-component-types@5.5.0
|
|
18
|
+
|
|
3
19
|
## 5.4.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/324.runtime.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkMJReactRuntime=this.webpackChunkMJReactRuntime||[]).push([[324],{324(e,t,r){r.r(t),r.d(t,{ActionItemInput:()=>
|
|
1
|
+
"use strict";(this.webpackChunkMJReactRuntime=this.webpackChunkMJReactRuntime||[]).push([[324],{324(e,t,r){r.r(t),r.d(t,{ActionItemInput:()=>T,ActionItemOutput:()=>Q,BrowserIndexedDBStorageProvider:()=>f,BrowserStorageProviderBase:()=>D,FieldMapper:()=>g,FireAndForgetHelper:()=>I,GetDataOutput:()=>G,GraphQLAIClient:()=>S,GraphQLActionClient:()=>O,GraphQLComponentRegistryClient:()=>j,GraphQLDataProvider:()=>P,GraphQLEncryptionClient:()=>k,GraphQLFileStorageClient:()=>B,GraphQLProviderConfigData:()=>C,GraphQLSystemUserClient:()=>L,GraphQLTestingClient:()=>K,GraphQLTransactionGroup:()=>h,GraphQLVersionHistoryClient:()=>J,RoleInput:()=>A,RolesAndUsersInput:()=>b,SimpleRemoteEntity:()=>U,SimpleRemoteEntityField:()=>_,SimpleRemoteEntityOutput:()=>V,SyncDataAction:()=>M,SyncDataResult:()=>F,SyncRolesAndUsersResult:()=>$,UserInput:()=>N,gql:()=>s.J1,setupGraphQLClient:()=>v});var s=r(215),a=r(358),n=r(865),o=r(429),i=r(600),u=r(49),c=r(226),l=r(497),d=r(718),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
2
|
mutation ExecuteTransactionGroup($group: TransactionInputType!) {
|
|
3
3
|
ExecuteTransactionGroup(group: $group) {
|
|
4
4
|
Success
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
ResultsJSON
|
|
7
7
|
}
|
|
8
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}))}},
|
|
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}))}},o=await this._provider.ExecuteGQL(e,r);if(o&&o.ExecuteTransactionGroup){const e=o.ExecuteTransactionGroup,t=[];for(let r=0;r<this.PendingTransactions.length;r++){const s=e.ResultsJSON[r],o=(0,n.NG)(s),i=this.PendingTransactions[r];t.push(new a.qT(i,o,null!==o))}return t}throw new Error("Failed to execute transaction group")}}class I{static{y(this,"FireAndForgetHelper")}static async Execute(e){const t=e.operationLabel??e.mutationFieldName;let r,s;try{const{promise:n,resolve:o,reject:i}=I.createCompletionPromise();s=I.setupTimeout(i,e.timeoutMs,e.timeoutErrorMessage),r=I.subscribeToPubSub(e,o,s);const u=await I.executeMutation(e);if(!e.validateAck(u)){s&&clearTimeout(s);const r=u?.errorMessage??"Server rejected the request";return(0,a.ZI)(`[FireAndForget:${t}] Server rejected: ${r}`),e.createErrorResult(r)}return(0,a.b0)(`[FireAndForget:${t}] Server accepted, waiting for completion via WebSocket`),await n}catch(e){throw s&&clearTimeout(s),(0,a.ZI)(`[FireAndForget:${t}] Error: ${e.message}`),e}finally{s&&clearTimeout(s),r&&r.unsubscribe()}}static createCompletionPromise(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}static setupTimeout(e,t,r){const s=r??"The operation may still be running on the server but the client timed out after 15 minutes. Please refresh the page to check the latest status.";return setTimeout(()=>{e(new Error(s))},t??9e5)}static subscribeToPubSub(e,t,r){const s=e.dataProvider.sessionId,n=e.operationLabel??e.mutationFieldName;return e.dataProvider.PushStatusUpdates(s).subscribe(s=>{try{const o=JSON.parse(s);e.onMessage&&e.onMessage(o),e.isCompletionEvent(o)&&(clearTimeout(r),(0,a.b0)(`[FireAndForget:${n}] Completion event received`),t(e.extractResult(o)))}catch(e){console.error(`[FireAndForget:${n}] Failed to parse PubSub message:`,e)}})}static async executeMutation(e){return(await e.dataProvider.ExecuteGQL(e.mutation,e.variables))[e.mutationFieldName]}}class S{static{y(this,"GraphQLAIClient")}constructor(e){this._dataProvider=e}async RunAIPrompt(e){try{const t=s.J1`
|
|
10
10
|
mutation RunAIPrompt(
|
|
11
11
|
$promptId: String!,
|
|
12
12
|
$data: String,
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
result
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
`}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,
|
|
109
|
+
`}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,n.NG)(e)}handleAgentError(e){const t=e?.message||String(e);(0,a.ZI)(`Error running AI agent: ${t}`);const r=t.includes("Failed to fetch")||t.includes("NetworkError");let s;return t.includes("timed out")||t.includes("timeout"),s=r?"Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":t,{success:!1,agentRun:void 0,errorMessage:s}}async RunAIAgentFromConversationDetail(e){try{const t=this.buildConversationDetailMutation(),r=this.prepareConversationDetailVariables(e);return await I.Execute({dataProvider:this._dataProvider,mutation:t,variables:r,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:y(e=>!0===e?.success,"validateAck"),isCompletionEvent:y(t=>this.isConversationDetailCompletionEvent(t,e.conversationDetailId),"isCompletionEvent"),extractResult:y(e=>this.extractAgentResult(e),"extractResult"),onMessage:e.onProgress?t=>this.forwardConversationDetailProgress(t,e.onProgress):void 0,createErrorResult:y(e=>this.createAgentErrorResult(e),"createErrorResult")})}catch(e){return this.handleAgentError(e)}}buildConversationDetailMutation(){return s.J1`
|
|
110
110
|
mutation RunAIAgentFromConversationDetail(
|
|
111
111
|
$conversationDetailId: String!,
|
|
112
112
|
$agentId: String!,
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
result
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return void 0!==e.maxHistoryMessages&&(t.maxHistoryMessages=e.maxHistoryMessages),void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(t.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(t.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.createArtifacts&&(t.createArtifacts=e.createArtifacts),void 0!==e.createNotification&&(t.createNotification=e.createNotification),void 0!==e.sourceArtifactId&&(t.sourceArtifactId=e.sourceArtifactId),void 0!==e.sourceArtifactVersionId&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return"RunAIAgentResolver"===e.resolver&&"StreamingContent"===e.type&&"complete"===t?.type}isConversationDetailCompletionEvent(e,t){const r=e.data;return"RunAIAgentResolver"===e.resolver&&"StreamingContent"===e.type&&"complete"===r?.type&&r?.conversationDetailId===t}extractAgentResult(e){const t=e.data,r=t.result;return r?(0,
|
|
148
|
+
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return void 0!==e.maxHistoryMessages&&(t.maxHistoryMessages=e.maxHistoryMessages),void 0!==e.data&&(t.data="object"==typeof e.data?JSON.stringify(e.data):e.data),void 0!==e.payload&&(t.payload="object"==typeof e.payload?JSON.stringify(e.payload):e.payload),void 0!==e.lastRunId&&(t.lastRunId=e.lastRunId),void 0!==e.autoPopulateLastRunPayload&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),void 0!==e.configurationId&&(t.configurationId=e.configurationId),void 0!==e.createArtifacts&&(t.createArtifacts=e.createArtifacts),void 0!==e.createNotification&&(t.createNotification=e.createNotification),void 0!==e.sourceArtifactId&&(t.sourceArtifactId=e.sourceArtifactId),void 0!==e.sourceArtifactVersionId&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return"RunAIAgentResolver"===e.resolver&&"StreamingContent"===e.type&&"complete"===t?.type}isConversationDetailCompletionEvent(e,t){const r=e.data;return"RunAIAgentResolver"===e.resolver&&"StreamingContent"===e.type&&"complete"===r?.type&&r?.conversationDetailId===t}extractAgentResult(e){const t=e.data,r=t.result;return r?(0,n.NG)(r):{success:t.success,agentRun:void 0}}forwardAgentProgress(e,t){if("RunAIAgentResolver"!==e.resolver||"ExecutionProgress"!==e.type||"ok"!==e.status)return;const r=e.data?.progress;r&&t({step:r.currentStep,percentage:r.percentage,message:r.message,metadata:r})}forwardConversationDetailProgress(e,t){if("RunAIAgentResolver"!==e.resolver||"ExecutionProgress"!==e.type||"ok"!==e.status)return;const r=e.data?.progress;r&&t({currentStep:r.currentStep,percentage:r.percentage,message:r.message,metadata:r})}createAgentErrorResult(e){return{success:!1,agentRun:void 0,errorMessage:e}}async ExecuteSimplePrompt(e){try{const t=s.J1`
|
|
149
149
|
mutation ExecuteSimplePrompt(
|
|
150
150
|
$systemPrompt: String!,
|
|
151
151
|
$messages: String,
|
|
@@ -183,9 +183,9 @@
|
|
|
183
183
|
error
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
`,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 R="default";class D{static{y(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||R;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||R).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||R).set(e,t)}async Remove(e,t){this.getCategoryMap(t||R).delete(e)}async ClearCategory(e){const t=e||R;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||R);return t?Array.from(t.keys()):[]}}const E=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],w="Metadata_KVPairs";class
|
|
186
|
+
`,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 R="default";class D{static{y(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}getCategoryMap(e){const t=e||R;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||R).get(e)??null}async SetItem(e,t,r){this.getCategoryMap(r||R).set(e,t)}async Remove(e,t){this.getCategoryMap(t||R).delete(e)}async ClearCategory(e){const t=e||R;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||R);return t?Array.from(t.keys()):[]}}const E=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"],w="Metadata_KVPairs";class f extends D{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 E)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 E.includes(t)}getStoreName(e){const t=e||R;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||R;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||R,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||R,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 C 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 P extends a.Dn{static{y(this,"GraphQLDataProvider")}constructor(){super(),this._refreshPromise=null,this._innerCurrentUserQueryString=`CurrentUser {\n ${this.userInfoString()}\n MJUserRoles_UserIDArray {\n ${this.userRoleInfoString()}\n }\n }\n `,this._currentUserQuery=s.J1`query CurrentUserAndRoles {
|
|
187
187
|
${this._innerCurrentUserQueryString}
|
|
188
|
-
}`,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,P._instance||(P._instance=this)}static get Instance(){return P._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new S(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return(0,
|
|
188
|
+
}`,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,P._instance||(P._instance=this)}static get Instance(){return P._instance}get ConfigData(){return this._configData}get AI(){return this._aiClient||(this._aiClient=new S(this)),this._aiClient}get DatabaseConnection(){throw new Error("DatabaseConnection not implemented for the GraphQLDataProvider")}get InstanceConnectionString(){return this._configData.URL}GenerateUUID(){return(0,d.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)):(P.Instance._configData=e,void 0===P.Instance._sessionId&&(P.Instance._sessionId=await this.GetPreferredUUID(s)),P.Instance._client||(P.Instance._client=this.CreateNewGraphQLClient(e.URL,e.Token,P.Instance._sessionId,e.MJAPIKey,e.UserAPIKey)),await P.Instance.SaveStoredSessionID(P.Instance._sessionId),this._sessionId=P.Instance._sessionId,this._client=P.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.MJUserRoles_UserIDArray.map(e=>this.ConvertBackToMJFields(e));return t.MJUserRoles_UserIDArray=r,new a.oq(this,{...t,UserRoles:r})}}async RunReport(e,t){const r=s.J1`
|
|
189
189
|
query GetReportDataQuery ($ReportID: String!) {
|
|
190
190
|
GetReportData(ReportID: $ReportID) {
|
|
191
191
|
Success
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
`,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
|
|
301
|
+
`,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 o.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 o.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:"MJ: 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!) {
|
|
302
302
|
GetRecordDependencies(entityName: $entityName, CompositeKey: $CompositeKey) {
|
|
303
303
|
EntityName
|
|
304
304
|
RelatedEntityName
|
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
${u}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
`),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
|
|
361
|
+
`),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=>(0,n.jd)(e.ID,t.RelatedEntityID));let o="";o="many to many"===t.Type.toLowerCase().trim()?`${t.RelatedEntityCodeName}_${t.JoinEntityJoinField.replace(/\s/g,"")}`:`${t.RelatedEntityCodeName}_${t.RelatedEntityJoinField.replace(/\s/g,"")}`,r+=`\n ${o} {\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___={SkipEntityAIActions:t?.SkipEntityAIActions??!1,SkipEntityActions:t?.SkipEntityActions??!1,ReplayOnly:t?.ReplayOnly??!1,IsParentEntityDelete:t?.IsParentEntityDelete??!1};const l="Delete"+(0,a.I)(e.EntityInfo),d=s.J1`${l}(${i}, options___: $options___) {
|
|
362
362
|
${c}
|
|
363
363
|
}
|
|
364
364
|
`,m=s.J1`mutation ${l} (${u}, $options___: DeleteOptionsInput!) {
|
|
@@ -422,14 +422,14 @@
|
|
|
422
422
|
ErrorMessage
|
|
423
423
|
Result
|
|
424
424
|
}
|
|
425
|
-
}`,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 P.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=P.Instance&&P.Instance._configData===this._configData;if(e&&P.Instance._refreshPromise)return P.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(P.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&P.Instance&&(P.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,P.Instance&&P.Instance._configData===this._configData&&(P.Instance._client=t)}}}static async RefreshToken(){return P.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
|
|
425
|
+
}`,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 P.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=P.Instance&&P.Instance._configData===this._configData;if(e&&P.Instance._refreshPromise)return P.Instance._refreshPromise;if(this._refreshPromise)return this._refreshPromise;console.log("[GraphQL] Starting token refresh..."),this._refreshPromise=this.performTokenRefresh(),e&&(P.Instance._refreshPromise=this._refreshPromise);try{await this._refreshPromise,console.log("[GraphQL] Token refresh completed successfully")}finally{this._refreshPromise=null,e&&P.Instance&&(P.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,P.Instance&&P.Instance._configData===this._configData&&(P.Instance._client=t)}}}static async RefreshToken(){return P.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 f: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,l.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 i.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 i.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!) {
|
|
426
426
|
statusUpdates(sessionId: $sessionId) {
|
|
427
427
|
date
|
|
428
428
|
message
|
|
429
429
|
sessionId
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
`,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 FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;try{const r=await this.ExecuteGQL("query FindISAChildEntity($EntityName: String!, $RecordID: String!) {\n FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityName\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntity?.Success&&r.FindISAChildEntity.ChildEntityName?{ChildEntityName:r.FindISAChildEntity.ChildEntityName}:null}catch(t){return(0,a.ZI)(`FindISAChildEntity failed for ${e.Name}: ${t}`),null}}async FindISAChildEntities(e,t,r){if(!e.IsParentType)return[];try{const r=await this.ExecuteGQL("query FindISAChildEntities($EntityName: String!, $RecordID: String!) {\n FindISAChildEntities(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityNames\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntities?.Success&&r.FindISAChildEntities.ChildEntityNames?r.FindISAChildEntities.ChildEntityNames.map(e=>({ChildEntityName:e})):[]}catch(t){return(0,a.ZI)(`FindISAChildEntities failed for ${e.Name}: ${t}`),[]}}}async function $(e){const t=Date.now();console.log(`[DIAG][${t}] setupGraphQLClient() ENTER`);const r=new P;console.log(`[DIAG][${t}] setupGraphQLClient() calling SetProvider() (Metadata.Provider will be set BEFORE Config completes)`),(0,a.YE)(r),console.log(`[DIAG][${t}] setupGraphQLClient() SetProvider() done. Metadata.Provider is now set. Starting async Config()...`);const s=Date.now();await r.Config(e),console.log(`[DIAG][${t}] setupGraphQLClient() provider.Config() completed in ${Date.now()-s}ms. Provider is now fully ready.`);const n=Date.now();return console.log(`[DIAG][${t}] setupGraphQLClient() calling StartupManager.Startup()...`),await a.jF.Instance.Startup(),console.log(`[DIAG][${t}] setupGraphQLClient() StartupManager.Startup() completed in ${Date.now()-n}ms`),d.rt.Instance.RaiseEvent({event:d.UK.LoggedIn,eventCode:null,component:this,args:null}),console.log(`[DIAG][${t}] setupGraphQLClient() EXIT - total time: ${Date.now()-t}ms`),r}y($,"setupGraphQLClient");class v{static{y(this,"SyncRolesAndUsersResult")}}class A{static{y(this,"RoleInput")}}class N{static{y(this,"UserInput")}}class b{static{y(this,"RolesAndUsersInput")}}var x,M=((x=M||{}).Create="Create",x.Update="Update",x.CreateOrUpdate="CreateOrUpdate",x.Delete="Delete",x.DeleteWithFilter="DeleteWithFilter",x);class G{static{y(this,"ActionItemInput")}}class T{static{y(this,"SyncDataResult")}constructor(){this.Results=[]}}class Q{static{y(this,"ActionItemOutput")}}class L{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={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(e){let t="";if(e instanceof Error){if(t=e.message,"cause"in e&&e.cause){const r=e.cause;t+=` | Cause: ${r.message||r}`,"code"in r&&(t+=` | Code: ${r.code}`)}if("response"in e){const r=e.response;r?.status&&(t+=` | HTTP Status: ${r.status}`),r?.errors&&(t+=` | GraphQL Errors: ${JSON.stringify(r.errors)}`)}e.stack&&console.error("DeleteQuery stack trace:",e.stack)}else t=String(e);return(0,a.ZI)(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${t}`),{Success:!1,ErrorMessage:t}}}async RunAIPrompt(e){try{const t=s.J1`
|
|
432
|
+
`,n=new u.B,o=this.getOrCreateWSClient(),l=new c.yU;return l.add(new i.c(t=>{const r=o.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 i.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 FindISAChildEntity(e,t,r){if(!e.IsParentType)return null;try{const r=await this.ExecuteGQL("query FindISAChildEntity($EntityName: String!, $RecordID: String!) {\n FindISAChildEntity(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityName\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntity?.Success&&r.FindISAChildEntity.ChildEntityName?{ChildEntityName:r.FindISAChildEntity.ChildEntityName}:null}catch(t){return(0,a.ZI)(`FindISAChildEntity failed for ${e.Name}: ${t}`),null}}async FindISAChildEntities(e,t,r){if(!e.IsParentType)return[];try{const r=await this.ExecuteGQL("query FindISAChildEntities($EntityName: String!, $RecordID: String!) {\n FindISAChildEntities(EntityName: $EntityName, RecordID: $RecordID) {\n Success\n ChildEntityNames\n ErrorMessage\n }\n }",{EntityName:e.Name,RecordID:t});return r?.FindISAChildEntities?.Success&&r.FindISAChildEntities.ChildEntityNames?r.FindISAChildEntities.ChildEntityNames.map(e=>({ChildEntityName:e})):[]}catch(t){return(0,a.ZI)(`FindISAChildEntities failed for ${e.Name}: ${t}`),[]}}}async function v(e){const t=new P;return(0,a.YE)(t),await t.Config(e),await a.jF.Instance.Startup(),n.rt.Instance.RaiseEvent({event:n.UK.LoggedIn,eventCode:null,component:this,args:null}),t}y(v,"setupGraphQLClient");class ${static{y(this,"SyncRolesAndUsersResult")}}class A{static{y(this,"RoleInput")}}class N{static{y(this,"UserInput")}}class b{static{y(this,"RolesAndUsersInput")}}var x,M=((x=M||{}).Create="Create",x.Update="Update",x.CreateOrUpdate="CreateOrUpdate",x.Delete="Delete",x.DeleteWithFilter="DeleteWithFilter",x);class T{static{y(this,"ActionItemInput")}}class F{static{y(this,"SyncDataResult")}constructor(){this.Results=[]}}class Q{static{y(this,"ActionItemOutput")}}class L{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,n.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,n.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,n.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={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQuerySystemResolver?n.DeleteQuerySystemResolver:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(e){let t="";if(e instanceof Error){if(t=e.message,"cause"in e&&e.cause){const r=e.cause;t+=` | Cause: ${r.message||r}`,"code"in r&&(t+=` | Code: ${r.code}`)}if("response"in e){const r=e.response;r?.status&&(t+=` | HTTP Status: ${r.status}`),r?.errors&&(t+=` | GraphQL Errors: ${JSON.stringify(r.errors)}`)}e.stack&&console.error("DeleteQuery stack trace:",e.stack)}else t=String(e);return(0,a.ZI)(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${t}`),{Success:!1,ErrorMessage:t}}}async RunAIPrompt(e){try{const t=s.J1`
|
|
433
433
|
query RunAIPromptSystemUser(
|
|
434
434
|
$promptId: String!,
|
|
435
435
|
$data: String,
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
result
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
`,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,
|
|
518
|
+
`,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,n.NG)(e)}async ExecuteSimplePrompt(e){try{const t=s.J1`
|
|
519
519
|
query ExecuteSimplePromptSystemUser(
|
|
520
520
|
$systemPrompt: String!,
|
|
521
521
|
$messages: String,
|
|
@@ -553,7 +553,7 @@
|
|
|
553
553
|
error
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
`,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
|
|
556
|
+
`,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 G{static{y(this,"GetDataOutput")}}class V{static{y(this,"SimpleRemoteEntityOutput")}}class U{static{y(this,"SimpleRemoteEntity")}}class _{static{y(this,"SimpleRemoteEntityField")}}class O{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`
|
|
557
557
|
mutation RunAction($input: RunActionInput!) {
|
|
558
558
|
RunAction(input: $input) {
|
|
559
559
|
Success
|
|
@@ -644,7 +644,7 @@
|
|
|
644
644
|
result
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
`}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:r,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0,s=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:r,selectedTestIds:s,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetComplete"===e.type&&"complete"===r?.type&&r?.testId===t}isSuiteCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetSuiteComplete"===e.type&&"complete"===r?.type&&r?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,
|
|
647
|
+
`}buildRunTestVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0;return{testId:e.testId,verbose:e.verbose,environment:e.environment,tags:t,variables:r,fireAndForget:!0}}buildRunTestSuiteVariables(e){const t=e.tags&&e.tags.length>0?JSON.stringify(e.tags):void 0,r=e.variables?JSON.stringify(e.variables):void 0,s=e.selectedTestIds&&e.selectedTestIds.length>0?JSON.stringify(e.selectedTestIds):void 0;return{suiteId:e.suiteId,verbose:e.verbose,environment:e.environment,parallel:e.parallel,tags:t,variables:r,selectedTestIds:s,sequenceStart:e.sequenceStart,sequenceEnd:e.sequenceEnd,fireAndForget:!0}}isTestCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetComplete"===e.type&&"complete"===r?.type&&r?.testId===t}isSuiteCompletionEvent(e,t){const r=e.data;return"RunTestResolver"===e.resolver&&"FireAndForgetSuiteComplete"===e.type&&"complete"===r?.type&&r?.suiteId===t}extractTestResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}extractSuiteResult(e){const t=e.data;return{success:t.success,errorMessage:t.errorMessage,executionTimeMs:t.executionTimeMs,result:t.result?(0,n.NG)(t.result):null}}forwardTestProgress(e,t){if("RunTestResolver"===e.resolver&&"TestExecutionProgress"===e.type&&"ok"===e.status){const r=e.data?.progress;r&&t(r)}}handleError(e,t){const r=e.message;return(0,a.ZI)(`${t} failed: ${r}`),{success:!1,errorMessage:r.includes("Failed to fetch")||r.includes("NetworkError")?"Lost connection to the server. The test may still be running. Please refresh to check the latest status.":r,result:null}}}class j{static{y(this,"GraphQLComponentRegistryClient")}constructor(e){this._dataProvider=e}async GetRegistryComponent(e){try{const t=s.J1`
|
|
648
648
|
query GetRegistryComponent(
|
|
649
649
|
$registryName: String!,
|
|
650
650
|
$namespace: String!,
|
|
@@ -665,7 +665,7 @@
|
|
|
665
665
|
specification
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
`,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=
|
|
668
|
+
`,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`
|
|
669
669
|
query GetRegistryComponent(
|
|
670
670
|
$registryName: String!,
|
|
671
671
|
$namespace: String!,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-manager.d.ts","sourceRoot":"","sources":["../../src/component-manager/component-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAA8B,MAAM,6CAA6C,CAAC;AAIxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,UAAU,EACV,eAAe,EACf,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAMjB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAyB;IAGvC,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,qBAAqB,CAA0B;IACvD,OAAO,CAAC,eAAe,CAA+C;IAGtE,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,aAAa,CAAa;gBAGhC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,EAC9B,MAAM,GAAE,sBAA2B;IAyB/B,aAAa,CACjB,IAAI,EAAE,aAAa,EACnB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;YAiCR,eAAe;IAuKvB,aAAa,CACjB,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"component-manager.d.ts","sourceRoot":"","sources":["../../src/component-manager/component-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAA8B,MAAM,6CAA6C,CAAC;AAIxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAmB,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,UAAU,EACV,eAAe,EACf,sBAAsB,EAGvB,MAAM,SAAS,CAAC;AAMjB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAyB;IAGvC,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,qBAAqB,CAA0B;IACvD,OAAO,CAAC,eAAe,CAA+C;IAGtE,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,aAAa,CAAa;gBAGhC,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,EAC9B,MAAM,GAAE,sBAA2B;IAyB/B,aAAa,CACjB,IAAI,EAAE,aAAa,EACnB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC;YAiCR,eAAe;IAuKvB,aAAa,CACjB,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,eAAe,CAAC;YAuFb,sBAAsB;YAkFtB,uBAAuB;IAoBrC,OAAO,CAAC,UAAU;YAeJ,kBAAkB;IA+FhC,OAAO,CAAC,mBAAmB;YA0Cb,gBAAgB;YAkDhB,2BAA2B;YAkC3B,uBAAuB;IAgBrC,OAAO,CAAC,YAAY;YAQN,aAAa;IAsB3B,OAAO,CAAC,eAAe;IAUvB,UAAU,IAAI,IAAI;IAUlB,aAAa,IAAI;QACf,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,YAAY,EAAE,MAAM,CAAC;KACtB;IAWD,OAAO,CAAC,GAAG;CAKZ"}
|
|
@@ -188,25 +188,9 @@ export class ComponentManager {
|
|
|
188
188
|
location: rootSpec.location,
|
|
189
189
|
registry: rootSpec.registry
|
|
190
190
|
});
|
|
191
|
-
const hierarchyDiagTime = Date.now();
|
|
192
|
-
console.log(`[DIAG][${hierarchyDiagTime}] loadHierarchy() ENTER for ${rootSpec.name}`, {
|
|
193
|
-
location: rootSpec.location,
|
|
194
|
-
registry: rootSpec.registry,
|
|
195
|
-
namespace: rootSpec.namespace,
|
|
196
|
-
version: rootSpec.version,
|
|
197
|
-
providerExists: !!Metadata?.Provider,
|
|
198
|
-
providerType: Metadata?.Provider ? Metadata.Provider.constructor?.name : 'N/A',
|
|
199
|
-
graphQLClientExists: !!this.graphQLClient
|
|
200
|
-
});
|
|
201
191
|
try {
|
|
202
192
|
if (this.componentEngine && typeof this.componentEngine.Config === 'function') {
|
|
203
|
-
const engineConfigStart = Date.now();
|
|
204
|
-
console.log(`[DIAG][${hierarchyDiagTime}] loadHierarchy() calling componentEngine.Config()...`);
|
|
205
193
|
await this.componentEngine.Config(false, options.contextUser);
|
|
206
|
-
console.log(`[DIAG][${hierarchyDiagTime}] loadHierarchy() componentEngine.Config() completed in ${Date.now() - engineConfigStart}ms`);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
console.log(`[DIAG][${hierarchyDiagTime}] loadHierarchy() SKIPPING componentEngine.Config() - engine: ${!!this.componentEngine}, hasConfig: ${this.componentEngine ? typeof this.componentEngine.Config === 'function' : 'N/A'}`);
|
|
210
194
|
}
|
|
211
195
|
const result = await this.loadComponentRecursive(rootSpec, options, loaded, errors, components, stats, new Set());
|
|
212
196
|
stats.totalTime = Date.now() - startTime;
|
|
@@ -337,43 +321,19 @@ export class ComponentManager {
|
|
|
337
321
|
});
|
|
338
322
|
return fullSpec;
|
|
339
323
|
}
|
|
340
|
-
const fetchDiagTime = Date.now();
|
|
341
|
-
console.log(`[DIAG][${fetchDiagTime}] fetchComponentSpec() EXTERNAL path for ${spec.registry}/${spec.name}`, {
|
|
342
|
-
graphQLClientExists: !!this.graphQLClient,
|
|
343
|
-
registryName: spec.registry,
|
|
344
|
-
namespace: spec.namespace,
|
|
345
|
-
name: spec.name,
|
|
346
|
-
version: spec.version
|
|
347
|
-
});
|
|
348
324
|
if (!this.graphQLClient) {
|
|
349
|
-
console.log(`[DIAG][${fetchDiagTime}] fetchComponentSpec() graphQLClient is null, calling initializeGraphQLClient()...`);
|
|
350
325
|
await this.initializeGraphQLClient();
|
|
351
|
-
console.log(`[DIAG][${fetchDiagTime}] fetchComponentSpec() after initializeGraphQLClient(): graphQLClient is ${this.graphQLClient ? 'SET' : 'STILL NULL'}`);
|
|
352
326
|
}
|
|
353
327
|
if (!this.graphQLClient) {
|
|
354
|
-
console.error(`[DIAG][${fetchDiagTime}] fetchComponentSpec() FATAL: GraphQL client not available after init attempt. Provider state:`, {
|
|
355
|
-
metadataExists: !!Metadata,
|
|
356
|
-
providerExists: !!Metadata?.Provider,
|
|
357
|
-
providerType: Metadata?.Provider ? Metadata.Provider.constructor?.name : 'N/A'
|
|
358
|
-
});
|
|
359
328
|
throw new Error('GraphQL client not available for registry fetching');
|
|
360
329
|
}
|
|
361
330
|
this.log(`Fetching from external registry: ${spec.registry}/${spec.name}`);
|
|
362
|
-
console.log(`[DIAG][${fetchDiagTime}] fetchComponentSpec() calling GetRegistryComponent()...`);
|
|
363
|
-
const gqlStart = Date.now();
|
|
364
331
|
const fullSpec = await this.graphQLClient.GetRegistryComponent({
|
|
365
332
|
registryName: spec.registry,
|
|
366
333
|
namespace: spec.namespace || 'Global',
|
|
367
334
|
name: spec.name,
|
|
368
335
|
version: spec.version || 'latest'
|
|
369
336
|
});
|
|
370
|
-
console.log(`[DIAG][${fetchDiagTime}] fetchComponentSpec() GetRegistryComponent() returned in ${Date.now() - gqlStart}ms:`, {
|
|
371
|
-
resultIsNull: fullSpec === null,
|
|
372
|
-
resultIsUndefined: fullSpec === undefined,
|
|
373
|
-
resultType: fullSpec ? typeof fullSpec : 'N/A',
|
|
374
|
-
hasName: fullSpec ? !!fullSpec.name : false,
|
|
375
|
-
hasCode: fullSpec ? !!fullSpec.code : false
|
|
376
|
-
});
|
|
377
337
|
if (!fullSpec) {
|
|
378
338
|
throw new Error(`Component not found in registry: ${spec.registry}/${spec.name}`);
|
|
379
339
|
}
|
|
@@ -457,35 +417,17 @@ export class ComponentManager {
|
|
|
457
417
|
}
|
|
458
418
|
}
|
|
459
419
|
async initializeGraphQLClient() {
|
|
460
|
-
const diagTime = Date.now();
|
|
461
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() ENTER`);
|
|
462
420
|
try {
|
|
463
421
|
const provider = Metadata?.Provider;
|
|
464
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() provider check:`, {
|
|
465
|
-
metadataExists: !!Metadata,
|
|
466
|
-
providerExists: !!provider,
|
|
467
|
-
providerType: provider ? provider.constructor?.name : 'N/A',
|
|
468
|
-
hasExecuteGQL: provider ? 'ExecuteGQL' in provider : false,
|
|
469
|
-
typeofExecuteGQL: provider && 'ExecuteGQL' in provider ? typeof provider.ExecuteGQL : 'N/A'
|
|
470
|
-
});
|
|
471
422
|
if (provider && provider.ExecuteGQL) {
|
|
472
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() provider check PASSED, importing GraphQLComponentRegistryClient...`);
|
|
473
|
-
const importStart = Date.now();
|
|
474
423
|
const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');
|
|
475
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() import took ${Date.now() - importStart}ms`);
|
|
476
424
|
this.graphQLClient = new GraphQLComponentRegistryClient(provider);
|
|
477
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() SUCCESS - graphQLClient created`);
|
|
478
425
|
this.log('GraphQL client initialized');
|
|
479
426
|
}
|
|
480
|
-
else {
|
|
481
|
-
console.warn(`[DIAG][${diagTime}] initializeGraphQLClient() provider check FAILED - graphQLClient will remain null`);
|
|
482
|
-
}
|
|
483
427
|
}
|
|
484
428
|
catch (error) {
|
|
485
|
-
console.error(`[DIAG][${diagTime}] initializeGraphQLClient() CAUGHT ERROR:`, error);
|
|
486
429
|
LogError(`Failed to initialize GraphQL client: ${error instanceof Error ? error.message : String(error)}`);
|
|
487
430
|
}
|
|
488
|
-
console.log(`[DIAG][${diagTime}] initializeGraphQLClient() EXIT - graphQLClient is ${this.graphQLClient ? 'SET' : 'NULL'} (took ${Date.now() - diagTime}ms)`);
|
|
489
431
|
}
|
|
490
432
|
isCacheValid(entry) {
|
|
491
433
|
const age = Date.now() - entry.fetchedAt.getTime();
|