@memberjunction/graphql-dataprovider 6.1.0-edge.4 → 6.1.0-edge.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +14 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
chatResult
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,r=this.preparePromptVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(s)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,n;try{t.parsedResult&&(r=D.CleanAndParseJSON(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(n=JSON.parse(t.chatResult))}catch{n=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:n}}handlePromptError(e){const t=e;return c.LogError(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){try{const
|
|
68
|
+
`,r=this.preparePromptVariables(e),s=await this._dataProvider.ExecuteGQL(t,r);return this.processPromptResult(s)}catch(t){return this.handlePromptError(t)}}preparePromptVariables(e){const t={promptId:e.promptId};return e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.templateData!==void 0&&(t.templateData=typeof e.templateData=="object"?JSON.stringify(e.templateData):e.templateData),e.messages!==void 0&&(t.messages=JSON.stringify(e.messages)),e.overrideModelId!==void 0&&(t.overrideModelId=e.overrideModelId),e.overrideVendorId!==void 0&&(t.overrideVendorId=e.overrideVendorId),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.skipValidation!==void 0&&(t.skipValidation=e.skipValidation),e.responseFormat!==void 0&&(t.responseFormat=e.responseFormat),e.temperature!==void 0&&(t.temperature=e.temperature),e.topP!==void 0&&(t.topP=e.topP),e.topK!==void 0&&(t.topK=e.topK),e.minP!==void 0&&(t.minP=e.minP),e.frequencyPenalty!==void 0&&(t.frequencyPenalty=e.frequencyPenalty),e.presencePenalty!==void 0&&(t.presencePenalty=e.presencePenalty),e.seed!==void 0&&(t.seed=e.seed),e.stopSequences!==void 0&&(t.stopSequences=e.stopSequences),e.includeLogProbs!==void 0&&(t.includeLogProbs=e.includeLogProbs),e.topLogProbs!==void 0&&(t.topLogProbs=e.topLogProbs),e.rerunFromPromptRunID!==void 0&&(t.rerunFromPromptRunID=e.rerunFromPromptRunID),e.systemPromptOverride!==void 0&&(t.systemPromptOverride=e.systemPromptOverride),t}processPromptResult(e){if(!e?.RunAIPrompt)throw new Error("Invalid response from server");const t=e.RunAIPrompt;let r,s,n;try{t.parsedResult&&(r=D.CleanAndParseJSON(t.parsedResult))}catch{r=t.parsedResult}try{t.validationResult&&(s=JSON.parse(t.validationResult))}catch{s=t.validationResult}try{t.chatResult&&(n=JSON.parse(t.chatResult))}catch{n=t.chatResult}return{success:t.success,output:t.output,parsedResult:r,error:t.error,executionTimeMs:t.executionTimeMs,tokensUsed:t.tokensUsed,promptRunId:t.promptRunId,rawResult:t.rawResult,validationResult:s,chatResult:n}}handlePromptError(e){const t=e;return c.LogError(`Error running AI prompt: ${t}`),{success:!1,error:t.message||"Unknown error occurred"}}async RunAIAgent(e,t,r){let s=!1;try{const n=this.buildRunAIAgentMutation(),a=this.prepareAgentVariables(e,t,r);a.fireAndForget=!0;const i={};return await w.Execute({dataProvider:this._dataProvider,mutation:n,variables:a,mutationFieldName:"RunAIAgent",operationLabel:"RunAIAgent",validateAck:d(o=>{const y=o?.success===!0;return y&&(s=!0),y},"validateAck"),isCompletionEvent:d(o=>this.isAgentCompletionEvent(o),"isCompletionEvent"),extractResult:d(o=>this.extractAgentResult(o),"extractResult"),extractSyncResult:d(o=>this.extractAgentResultFromAck(o),"extractSyncResult"),onMessage:d(o=>{this.captureAgentRunId(o,i),e.onProgress&&this.forwardAgentProgress(o,e.onProgress)},"onMessage"),onStall:d(()=>this.reconcileAgentRun(i.id?`ID='${i.id}'`:void 0),"onStall"),createErrorResult:d(o=>this.createAgentErrorResult(o,s),"createErrorResult")})}catch(n){return this.handleAgentError(n,s)}}buildRunAIAgentMutation(){return u.gql`
|
|
69
69
|
mutation RunAIAgent(
|
|
70
70
|
$agentId: String!,
|
|
71
71
|
$messages: String!,
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
result
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
`}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return e.data!==void 0&&(s.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(s.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(s.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(s.configurationId=e.configurationId),e.conversationDetailId!==void 0&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),t!==void 0&&(s.sourceArtifactId=t),r!==void 0&&(s.sourceArtifactVersionId=r),e.planMode!==void 0&&(s.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(s.requestedSkillIDs=e.requestedSkillIDs),e.taskGraphDebug!==void 0&&(s.taskGraphDebug=JSON.stringify(e.taskGraphDebug)),s}processAgentResult(e){return D.SafeJSONParse(e)}handleAgentError(e){const
|
|
115
|
+
`}prepareAgentVariables(e,t,r){const s={agentId:e.agent.ID,messages:JSON.stringify(e.conversationMessages),sessionId:this._dataProvider.sessionId};return e.data!==void 0&&(s.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(s.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(s.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(s.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(s.configurationId=e.configurationId),e.conversationDetailId!==void 0&&(s.conversationDetailId=e.conversationDetailId,s.createArtifacts=!0,s.createNotification=!0),t!==void 0&&(s.sourceArtifactId=t),r!==void 0&&(s.sourceArtifactVersionId=r),e.planMode!==void 0&&(s.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(s.requestedSkillIDs=e.requestedSkillIDs),e.taskGraphDebug!==void 0&&(s.taskGraphDebug=JSON.stringify(e.taskGraphDebug)),s}processAgentResult(e){return D.SafeJSONParse(e)}handleAgentError(e,t=!1){const s=e?.message||String(e);c.LogError(`Error running AI agent: ${s}`);const n=s.includes("Failed to fetch")||s.includes("NetworkError"),a=s.includes("timed out")||s.includes("timeout");let i;return n&&t?i="Lost connection to the server. The agent may still be running. Please refresh to check the latest status.":n?i="Could not reach the server. The request may not have started. Please try again.":i=s,{success:!1,agentRun:void 0,errorMessage:i,requestAcknowledged:t}}async RunAIAgentFromConversationDetail(e){let t=!1;try{const r=this.buildConversationDetailMutation(),s=this.prepareConversationDetailVariables(e);return await w.Execute({dataProvider:this._dataProvider,mutation:r,variables:s,mutationFieldName:"RunAIAgentFromConversationDetail",operationLabel:"RunAIAgentFromConversationDetail",validateAck:d(n=>{const a=n?.success===!0;return a&&(t=!0),a},"validateAck"),isCompletionEvent:d(n=>this.isConversationDetailCompletionEvent(n,e.conversationDetailId),"isCompletionEvent"),extractResult:d(n=>this.extractAgentResult(n),"extractResult"),extractSyncResult:d(n=>this.extractAgentResultFromAck(n),"extractSyncResult"),onMessage:e.onProgress?n=>this.forwardConversationDetailProgress(n,e.onProgress):void 0,onStall:d(()=>this.reconcileAgentRun(`ConversationDetailID='${e.conversationDetailId}'`),"onStall"),createErrorResult:d(n=>this.createAgentErrorResult(n,t),"createErrorResult")})}catch(r){return this.handleAgentError(r,t)}}buildConversationDetailMutation(){return u.gql`
|
|
116
116
|
mutation RunAIAgentFromConversationDetail(
|
|
117
117
|
$conversationDetailId: String!,
|
|
118
118
|
$agentId: String!,
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
result
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return e.maxHistoryMessages!==void 0&&(t.maxHistoryMessages=e.maxHistoryMessages),e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(t.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.planMode!==void 0&&(t.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(t.requestedSkillIDs=e.requestedSkillIDs),e.createArtifacts!==void 0&&(t.createArtifacts=e.createArtifacts),e.createNotification!==void 0&&(t.createNotification=e.createNotification),e.sourceArtifactId!==void 0&&(t.sourceArtifactId=e.sourceArtifactId),e.sourceArtifactVersionId!==void 0&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&t?.type==="complete"}isConversationDetailCompletionEvent(e,t){const r=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&r?.type==="complete"&&r?.conversationDetailId===t}captureAgentRunId(e,t){const r=e.data,s=r?.agentRunId??r?.runId;s&&s!=="unknown"&&(t.id=s)}async reconcileAgentRun(e){if(!e)return"continue";const t=await this._dataProvider.RunView({EntityName:"MJ: AI Agent Runs",ExtraFilter:e,OrderBy:"__mj_CreatedAt DESC",ResultType:"entity_object",BypassCache:!0}),r=t.Success?t.Results?.[0]:void 0;return!r||r.Status==="Running"?"continue":{resolve:{success:r.Status==="Completed"||r.Status==="Paused"||r.Status==="AwaitingFeedback",agentRun:r,payload:r.Result?D.SafeJSONParse(r.Result)??void 0:void 0,errorMessage:r.ErrorMessage??void 0}}}extractAgentResult(e){const t=e.data,r=t.result;
|
|
158
|
+
`}prepareConversationDetailVariables(e){const t={conversationDetailId:e.conversationDetailId,agentId:e.agentId,sessionId:this._dataProvider.sessionId,fireAndForget:!0};return e.maxHistoryMessages!==void 0&&(t.maxHistoryMessages=e.maxHistoryMessages),e.data!==void 0&&(t.data=typeof e.data=="object"?JSON.stringify(e.data):e.data),e.payload!==void 0&&(t.payload=typeof e.payload=="object"?JSON.stringify(e.payload):e.payload),e.lastRunId!==void 0&&(t.lastRunId=e.lastRunId),e.autoPopulateLastRunPayload!==void 0&&(t.autoPopulateLastRunPayload=e.autoPopulateLastRunPayload),e.configurationId!==void 0&&(t.configurationId=e.configurationId),e.planMode!==void 0&&(t.planMode=e.planMode),e.requestedSkillIDs!==void 0&&(t.requestedSkillIDs=e.requestedSkillIDs),e.createArtifacts!==void 0&&(t.createArtifacts=e.createArtifacts),e.createNotification!==void 0&&(t.createNotification=e.createNotification),e.sourceArtifactId!==void 0&&(t.sourceArtifactId=e.sourceArtifactId),e.sourceArtifactVersionId!==void 0&&(t.sourceArtifactVersionId=e.sourceArtifactVersionId),t}isAgentCompletionEvent(e){const t=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&t?.type==="complete"}isConversationDetailCompletionEvent(e,t){const r=e.data;return e.resolver==="RunAIAgentResolver"&&e.type==="StreamingContent"&&r?.type==="complete"&&r?.conversationDetailId===t}captureAgentRunId(e,t){const r=e.data,s=r?.agentRunId??r?.runId;s&&s!=="unknown"&&(t.id=s)}async reconcileAgentRun(e){if(!e)return"continue";const t=await this._dataProvider.RunView({EntityName:"MJ: AI Agent Runs",ExtraFilter:e,OrderBy:"__mj_CreatedAt DESC",ResultType:"entity_object",BypassCache:!0}),r=t.Success?t.Results?.[0]:void 0;return!r||r.Status==="Running"?"continue":{resolve:{success:r.Status==="Completed"||r.Status==="Paused"||r.Status==="AwaitingFeedback",agentRun:r,payload:r.Result?D.SafeJSONParse(r.Result)??void 0:void 0,errorMessage:r.ErrorMessage??void 0}}}extractAgentResult(e){const t=e.data,r=t.result;if(r){const a=D.SafeJSONParse(r);if(a)return!a.errorMessage&&typeof t.errorMessage=="string"&&(a.errorMessage=t.errorMessage),a}const s=!!t.success,n=typeof t.errorMessage=="string"&&t.errorMessage?t.errorMessage:void 0;return{success:s,agentRun:void 0,errorMessage:n??(s?void 0:"Agent execution ended without a result payload")}}extractAgentResultFromAck(e){const t=e.result;if(t){const r=D.SafeJSONParse(t);if(r)return r}return{success:e.success,agentRun:void 0,errorMessage:e.errorMessage}}forwardAgentProgress(e,t){if(e.resolver!=="RunAIAgentResolver"||e.type!=="ExecutionProgress"||e.status!=="ok")return;const s=e.data?.progress;s&&t({step:s.currentStep,percentage:s.percentage,message:s.message,metadata:s})}forwardConversationDetailProgress(e,t){if(e.resolver!=="RunAIAgentResolver"||e.type!=="ExecutionProgress"||e.status!=="ok")return;const r=e.data,s=r?.progress;s&&t({currentStep:s.currentStep,percentage:s.percentage,message:s.message,metadata:{...s,agentRun:r?.agentRun,agentRunId:r?.agentRunId}})}createAgentErrorResult(e,t=!1){return{success:!1,agentRun:void 0,errorMessage:e,requestAcknowledged:t}}async ExecuteSimplePrompt(e){try{const t=u.gql`
|
|
159
159
|
mutation ExecuteSimplePrompt(
|
|
160
160
|
$systemPrompt: String!,
|
|
161
161
|
$messages: String,
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
`,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return c.LogError("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const
|
|
310
|
+
`,r={entityDocumentID:e.entityDocumentID};e.maxRecords!==void 0&&(r.maxRecords=e.maxRecords),e.filter!==void 0&&(r.filter=e.filter);const s=await this._dataProvider.ExecuteGQL(t,r);if(!s?.FetchEntityVectors)throw new Error("Invalid response from server");return s.FetchEntityVectors}catch(t){const r=t;return c.LogError("GraphQLAIClient.FetchEntityVectors failed",void 0,r),{Success:!1,Results:[],TotalCount:0,ElapsedMs:0,ErrorMessage:r.message||"Unknown error"}}}}const N="6.1.0-edge.5",P="default";class k{static{d(this,"BrowserStorageProviderBase")}constructor(){this._storage=new Map}get SharesReferences(){return!0}getCategoryMap(e){const t=e||P;let r=this._storage.get(t);return r||(r=new Map,this._storage.set(t,r)),r}async GetItem(e,t){const s=this.getCategoryMap(t||P).get(e);return s===void 0?null:s}async GetItems(e,t){const r=new Map;if(e.length===0)return r;const s=this.getCategoryMap(t||P);for(const n of new Set(e)){const a=s.get(n);r.set(n,a===void 0?null:a)}return r}async SetItem(e,t,r){this.getCategoryMap(r||P).set(e,t)}async Remove(e,t){this.getCategoryMap(t||P).delete(e)}async ClearCategory(e){const t=e||P;this._storage.delete(t)}async GetCategoryKeys(e){const t=this._storage.get(e||P);return t?Array.from(t.keys()):[]}}const se="MJ_Metadata",ne=0;function ae(){try{const g=N.split("."),e=parseInt(g[0],10),t=parseInt(g[1],10);if(!Number.isFinite(e)||!Number.isFinite(t))throw new Error(`Could not parse major.minor from version "${N}"`);return e*1e3+t+ne}catch(g){return c.LogErrorEx({error:g,message:"Failed to derive IDB version from PACKAGE_VERSION; using fallback 99999"}),99999}}d(ae,"computeIdbVersion");const oe=ae(),K=["mj:default","mj:Metadata","mj:RunViewCache","mj:RunQueryCache","mj:DatasetCache"];class B extends k{static{d(this,"BrowserIndexedDBStorageProvider")}constructor(){super(),this._dbReady=!1,this.dbPromise=ee.openDB(se,oe,{upgrade:d((e,t,r)=>{try{c.LogStatus(`[IDBCache] Upgrading IndexedDB schema v${t} \u2192 v${r} (package ${N}). Dropping all stores; caches will repopulate on first use.`);for(const s of Array.from(e.objectStoreNames))e.deleteObjectStore(s);for(const s of K)e.objectStoreNames.contains(s)||e.createObjectStore(s)}catch(s){c.LogErrorEx({error:s,message:s?.message})}},"upgrade"),blocked:d((e,t)=>{c.LogStatus(`[IDBCache] Upgrade from v${e} to v${t} blocked by another tab. Close other tabs to allow the upgrade to proceed.`)},"blocked")}),this.dbPromise.then(e=>{this._dbReady=!0,e.onversionchange=()=>{c.LogStatus("[IDBCache] DB schema upgraded in another tab \u2014 closing local connection."),e.close(),this._dbReady=!1}}).catch(e=>{c.LogErrorEx({error:e,message:"IndexedDB initialization failed: "+e?.message})})}get SharesReferences(){return!1}get IsReady(){return this._dbReady}isKnownCategory(e){const t=`mj:${e}`;return K.includes(t)}getStoreName(e){const t=e||P;return this.isKnownCategory(t)?`mj:${t}`:"mj:default"}getStoreKey(e,t){const r=t||P;return this.isKnownCategory(r)?e:`[${r}]:${e}`}async SetItem(e,t,r){try{const s=await this.dbPromise,n=this.getStoreName(r),a=this.getStoreKey(e,r),i=s.transaction(n,"readwrite");await i.objectStore(n).put(t,a),await i.done}catch(s){c.LogErrorEx({error:s,message:s?.message})}}async GetItem(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=await r.transaction(s).objectStore(s).get(n);return a===void 0?null:a}catch(r){return c.LogErrorEx({error:r,message:r?.message}),null}}async GetItems(e,t){const r=new Map;if(e.length===0)return r;try{const s=await this.dbPromise,n=this.getStoreName(t),a=Array.from(new Set(e)),i=a.map(h=>this.getStoreKey(h,t)),o=s.transaction(n,"readonly"),y=o.objectStore(n),l=i.map(h=>y.get(h)),S=await Promise.all(l);await o.done;for(let h=0;h<a.length;h++){const m=S[h];r.set(a[h],m===void 0?null:m)}return r}catch(s){c.LogErrorEx({error:s,message:s?.message});for(const n of new Set(e))r.set(n,null);return r}}async Remove(e,t){try{const r=await this.dbPromise,s=this.getStoreName(t),n=this.getStoreKey(e,t),a=r.transaction(s,"readwrite");await a.objectStore(s).delete(n),await a.done}catch(r){c.LogErrorEx({error:r,message:r?.message})}}async ClearCategory(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e);if(this.isKnownCategory(r)){const n=t.transaction(s,"readwrite");await n.objectStore(s).clear(),await n.done}else{const n=`[${r}]:`,a=t.transaction("mj:default","readwrite"),i=a.objectStore("mj:default"),o=await i.getAllKeys();for(const y of o)typeof y=="string"&&y.startsWith(n)&&await i.delete(y);await a.done}}catch(t){c.LogErrorEx({error:t,message:t?.message})}}async GetCategoryKeys(e){try{const t=await this.dbPromise,r=e||P,s=this.getStoreName(e),i=await t.transaction(s,"readonly").objectStore(s).getAllKeys();if(this.isKnownCategory(r))return i.map(y=>String(y));const o=`[${r}]:`;return i.map(y=>String(y)).filter(y=>y.startsWith(o)).map(y=>y.slice(o.length))}catch(t){return c.LogErrorEx({error:t,message:t?.message}),[]}}}class x extends Error{static{d(this,"SafeGraphQLError")}constructor(e){super(e.message),this.name=e.name,this.response={status:e.status,errors:e.errors},this.request={query:e.query},this.Code=e.code,this.VariableShape=e.variableShape,this.stack=e.stackFrames?`${e.name}: ${e.message}
|
|
311
311
|
${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}d(j,"ToSafeGraphQLError");const ie=3,ce=25;function F(g,e=0){if(g===null)return"null";if(g===void 0)return"undefined";if(Array.isArray(g))return g.length===0?"array(empty)":`array(${g.length} \xD7 ${ue(F(g[0],e+1))})`;if(typeof g=="object"){if(e>=ie)return"object(\u2026)";const t=Object.keys(g);if(t.length>ce)return`object(${t.length} keys)`;const r={};for(const s of t)r[s]=F(g[s],e+1);return r}return typeof g=="string"?g.length===0?"string(empty)":"string":typeof g}d(F,"describeShape");function ue(g){return typeof g=="string"?g:"object"}d(ue,"typeOf");function le(g){const e=g.indexOf(`
|
|
312
312
|
at `);return e===-1?"":g.slice(e+1)}d(le,"stripStackHeader");function de(g,e){const t=g?.[0]?.message;return typeof t=="string"&&t.length>0?t:`GraphQL Error (Code: ${String(e??"unknown")})`}d(de,"deriveMessage");function ge(g){if(Array.isArray(g))return g.map(e=>{const t=e??{};return{message:typeof t.message=="string"?t.message:void 0,path:Array.isArray(t.path)?t.path:void 0,extensions:t.extensions&&typeof t.extensions=="object"?t.extensions:void 0}})}d(ge,"extractErrors");function G(g,e=!1){if(!g||typeof g!="object")return{name:typeof g,message:"Non-object value thrown; contents withheld",variables:"[REDACTED]"};const t=g,r=typeof t.response?.status=="number"?t.response.status:void 0,s=ge(t.response?.errors),n=s?.[0]?.extensions?.code;return{name:typeof t.name=="string"?t.name:"Error",message:de(s,r),status:r,errors:s,code:typeof n=="string"?n:void 0,query:typeof t.request?.query=="string"?t.request.query:void 0,stackFrames:typeof t.stack=="string"?le(t.stack):void 0,variables:e?t.request?.variables:"[REDACTED]",variableShape:t.request?.variables===void 0?void 0:F(t.request.variables)}}d(G,"SanitizeGraphQLError");const L=new b,ye=u.gql`subscription RemoteOperationProgress($channelId: ID!) {
|
|
313
313
|
RemoteOperationProgress(channelId: $channelId) {
|
|
@@ -393,7 +393,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
393
393
|
Success
|
|
394
394
|
ErrorMessage${h}
|
|
395
395
|
}
|
|
396
|
-
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(m,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const R=p[r].Results;if(R&&R.length>0){const v=o.Fields.filter(C=>C.CodeName!==C.Name&&C.CodeName!==void 0);R.forEach(C=>{this.ConvertBackToMJFields(C),v.forEach(
|
|
396
|
+
}`;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Sending RunView with aggregates:",{entityName:a,queryName:r,aggregateCount:n.Aggregates.length,aggregates:n.Aggregates});const p=await this.ExecuteGQL(m,{input:n});if(p&&p[r]){const I=p[r].AggregateResults;n.Aggregates?.length>0&&console.log("[GraphQLDataProvider] Received aggregate results:",{entityName:a,aggregateResultCount:I?.length||0,aggregateResults:I,aggregateExecutionTime:p[r].AggregateExecutionTime});const R=p[r].Results;if(R&&R.length>0){const v=o.Fields.filter(C=>C.CodeName!==C.Name&&C.CodeName!==void 0);R.forEach(C=>{this.ConvertBackToMJFields(C),v.forEach(A=>{C[A.Name]=C[A.CodeName]})})}return p[r]}}else throw"No parameters passed to RunView";return null}catch(r){throw c.LogError(r),r}}async InternalRunViews(e,t){try{let r=[],s=[],n=[];for(const l of e){let S="",h="";const m={};let p=null,I=null;if(l.ViewEntity)I=l.ViewEntity,p=I.Get("Entity");else{const{entityName:C,v:A}=await this.getEntityNameAndUserView(l,t);I=A,p=C}const R=this.EntityByName(p);if(!R)throw new Error(`Entity ${p} not found in metadata`);s.push(R);let E=!1;const v=c.getGraphQLTypeNameBase(R);l.ViewID?(S=`Run${v}ViewByID`,h="RunViewByIDInput",m.ViewID=l.ViewID):l.ViewName?(S=`Run${v}ViewByName`,h="RunViewByNameInput",m.ViewName=l.ViewName):(E=!0,S=`Run${v}DynamicView`,h="RunDynamicViewInput",m.EntityName=l.EntityName),m.ExtraFilter=l.ExtraFilter||"",m.OrderBy=l.OrderBy||"",m.UserSearchString=l.UserSearchString||"",m.Fields=l.Fields,m.IgnoreMaxRows=l.IgnoreMaxRows||!1,l.MaxRows!==void 0&&(m.MaxRows=l.MaxRows),l.StartRow!==void 0&&(m.StartRow=l.StartRow),l.AfterKey&&(m.AfterKey={KeyValuePairs:l.AfterKey.KeyValuePairs}),m.ForceAuditLog=l.ForceAuditLog||!1,m.ResultType=l.ResultType||"simple",l.AuditLogDescription&&l.AuditLogDescription.length>0&&(m.AuditLogDescription=l.AuditLogDescription),l.BypassCache!==void 0&&(m.BypassCache=l.BypassCache),l.DataSource!==void 0&&(m.DataSource=l.DataSource),E||(m.ExcludeUserViewRunID=l.ExcludeUserViewRunID||"",m.ExcludeDataFromAllPriorViewRuns=l.ExcludeDataFromAllPriorViewRuns||!1,m.OverrideExcludeFilter=l.OverrideExcludeFilter||"",m.SaveViewResults=l.SaveViewResults||!1),l.Aggregates&&l.Aggregates.length>0&&(m.Aggregates=l.Aggregates.map(C=>({expression:C.expression,alias:C.alias}))),r.push(m),n.push(...this.getViewRunTimeFieldList(R,I,l,E))}const i=e.some(l=>l.Aggregates&&l.Aggregates.length>0)?`
|
|
397
397
|
AggregateResults {
|
|
398
398
|
alias
|
|
399
399
|
expression
|
|
@@ -551,7 +551,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
551
551
|
`)}
|
|
552
552
|
}
|
|
553
553
|
`}return r}async Delete(e,t,r){const s=new c.BaseEntityResult;try{e.RegisterTransactionPreprocessing(),s.StartedAt=new Date,s.Type="delete",s.OriginalValues=e.Fields.map(p=>({FieldName:p.CodeName,Value:p.Value})),e.RegisterResultHistoryEntry(s);const n={},a=[];let i="",o="",y="";for(let p of e.PrimaryKey.KeyValuePairs){const I=e.Fields.find(E=>E.Name.trim().toLowerCase()===p.FieldName.trim().toLowerCase());n[I.CodeName]=I.Value,a.push({varName:I.CodeName,inputType:I.EntityFieldInfo.GraphQLType+"!"});const R=I.CodeName.startsWith("__mj_")?I.CodeName.replace("__mj_","_mj__"):I.CodeName;i.length>0&&(i+=", "),i+=`${R}: $${I.CodeName}`,o.length>0&&(o+=", "),o+=`$${I.CodeName}: ${I.EntityFieldInfo.GraphQLType}!`,y.length>0&&(y+=`
|
|
554
|
-
`),y+=`${R}`}a.push({varName:"options___",inputType:"DeleteOptionsInput!"}),n.options___={SkipEntityAIActions:t?.SkipEntityAIActions??!1,SkipEntityActions:t?.SkipEntityActions??!1,ReplayOnly:t?.ReplayOnly??!1,IsParentEntityDelete:t?.IsParentEntityDelete??!1};const S="Delete"+c.getGraphQLTypeNameBase(e.EntityInfo),h=u.gql`${S}(${i}, options___: $options___) {
|
|
554
|
+
`),y+=`${R}`}a.push({varName:"options___",inputType:"DeleteOptionsInput!"}),n.options___={SkipEntityAIActions:t?.SkipEntityAIActions??!1,SkipEntityActions:t?.SkipEntityActions??!1,ReplayOnly:t?.ReplayOnly??!1,IsParentEntityDelete:t?.IsParentEntityDelete??!1,SkipRecordChanges:t?.SkipRecordChanges??!1};const S="Delete"+c.getGraphQLTypeNameBase(e.EntityInfo),h=u.gql`${S}(${i}, options___: $options___) {
|
|
555
555
|
${y}
|
|
556
556
|
}
|
|
557
557
|
`,m=u.gql`mutation ${S} (${o}, $options___: DeleteOptionsInput!) {
|
|
@@ -915,7 +915,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
915
915
|
ID
|
|
916
916
|
Name
|
|
917
917
|
}
|
|
918
|
-
}`,s={ID:e};t!==void 0&&(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.DeleteQueryExtended?n.DeleteQueryExtended:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){let s="";if(r instanceof Error){if(s=r.message,"cause"in r&&r.cause){const n=r.cause;s+=` | Cause: ${n.message||n}`,"code"in n&&(s+=` | Code: ${n.code}`)}if("response"in r){const n=r.response;n?.status&&(s+=` | HTTP Status: ${n.status}`),n?.errors&&(s+=` | GraphQL Errors: ${JSON.stringify(n.errors)}`)}r.stack&&console.error("DeleteQuery stack trace:",r.stack)}else s=String(r);return c.LogError(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${s}`),{Success:!1,ErrorMessage:s}}}async RunAIPrompt(e){try{const t=u.gql`
|
|
918
|
+
}`,s={ID:e};t!==void 0&&(s.options={SkipEntityAIActions:t.SkipEntityAIActions??!1,SkipEntityActions:t.SkipEntityActions??!1,ReplayOnly:t.ReplayOnly??!1,IsParentEntityDelete:t.IsParentEntityDelete??!1,SkipRecordChanges:t.SkipRecordChanges??!1});const n=await this.Client.request(r,s);return n&&n.DeleteQueryExtended?n.DeleteQueryExtended:{Success:!1,ErrorMessage:"Failed to delete query"}}catch(r){let s="";if(r instanceof Error){if(s=r.message,"cause"in r&&r.cause){const n=r.cause;s+=` | Cause: ${n.message||n}`,"code"in n&&(s+=` | Code: ${n.code}`)}if("response"in r){const n=r.response;n?.status&&(s+=` | HTTP Status: ${n.status}`),n?.errors&&(s+=` | GraphQL Errors: ${JSON.stringify(n.errors)}`)}r.stack&&console.error("DeleteQuery stack trace:",r.stack)}else s=String(r);return c.LogError(`GraphQLSystemUserClient::DeleteQuery - Error deleting query - ${s}`),{Success:!1,ErrorMessage:s}}}async RunAIPrompt(e){try{const t=u.gql`
|
|
919
919
|
query RunAIPromptSystemUser(
|
|
920
920
|
$promptId: String!,
|
|
921
921
|
$data: String,
|
|
@@ -1219,7 +1219,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
1221
1221
|
${q}
|
|
1222
|
-
`,r=await this.dataProvider.ExecuteGQL(t,{input:{ListID:e.ListID,Target:
|
|
1222
|
+
`,r=await this.dataProvider.ExecuteGQL(t,{input:{ListID:e.ListID,Target:Ae(e.Target),PermissionLevel:e.PermissionLevel}});return Q(r?.ShareList)}async Unshare(e){const t=u.gql`
|
|
1223
1223
|
mutation UnshareList($permissionId: String!) {
|
|
1224
1224
|
UnshareList(permissionId: $permissionId) {
|
|
1225
1225
|
...ShareResultFields
|
|
@@ -1270,7 +1270,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
1270
1270
|
CreatedAt
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
`;return((await this.dataProvider.ExecuteGQL(t,{listId:e}))?.ListSharesForList??[]).map(
|
|
1273
|
+
`;return((await this.dataProvider.ExecuteGQL(t,{listId:e}))?.ListSharesForList??[]).map(Ne)}async ListsSharedWithMe(){const e=u.gql`
|
|
1274
1274
|
query ListsSharedWithMe {
|
|
1275
1275
|
ListsSharedWithMe {
|
|
1276
1276
|
ListID
|
|
@@ -1320,7 +1320,7 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
1320
1320
|
Message
|
|
1321
1321
|
PermissionID
|
|
1322
1322
|
}
|
|
1323
|
-
`;function
|
|
1323
|
+
`;function Ae(g){return g.kind==="user"?{Kind:"user",UserID:g.userId}:{Kind:"role",RoleID:g.roleId}}d(Ae,"serializeShareTarget");function Q(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ShareResult response");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,PermissionID:e.PermissionID??void 0}}d(Q,"parseShareResult");function Ne(g){const e=g,t=e.Target.Kind==="user"?{kind:"user",userId:e.Target.UserID}:{kind:"role",roleId:e.Target.RoleID};return{PermissionID:e.PermissionID,ListID:e.ListID,Target:t,PermissionLevel:e.PermissionLevel,Status:e.Status,SharedByUserID:e.SharedByUserID??null,CreatedAt:new Date(e.CreatedAt)}}d(Ne,"parseShareSummary");function U(g){switch(g.kind){case"list":return{Kind:"list",ListID:g.listId};case"view":return{Kind:"view",ViewID:g.viewId};case"adhoc":return{Kind:"adhoc",EntityName:g.entityName,ExtraFilter:g.extraFilter}}}d(U,"serializeListSource");function z(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ListDelta response from server");const e=g;return{TargetListId:e.TargetListId,EntityName:e.EntityName,ToAdd:e.ToAdd,ToRemove:e.ToRemove,Unchanged:e.Unchanged,Counts:e.Counts,Warnings:e.Warnings.map(Me),DeltaToken:e.DeltaToken}}d(z,"parseListDelta");function Me(g){let e;if(g.DetailsJSON)try{e=JSON.parse(g.DetailsJSON)}catch(t){c.LogError(`GraphQLListsClient: failed to parse warning details JSON: ${t}`)}return{Code:g.Code,Message:g.Message,Details:e}}d(Me,"parseWarning");function T(g){if(!g||typeof g!="object")throw new Error("GraphQLListsClient: empty/invalid ApplyResult response from server");const e=g;return{Success:e.Success,ResultCode:e.ResultCode,Message:e.Message,CreatedListId:e.CreatedListId??void 0,TargetListId:e.TargetListId??void 0,Counts:e.AddedCount!=null||e.RemovedCount!=null||e.FailedCount!=null?{Added:e.AddedCount??0,Removed:e.RemovedCount??0,Failed:e.FailedCount??0}:void 0,Errors:e.Errors??void 0}}d(T,"parseApplyResult");class Te{static{d(this,"GraphQLEncryptionClient")}constructor(e){this._dataProvider=e}async CreateAPIKey(e){try{const t=this.createAPIKeyVariables(e),r=await this.executeCreateAPIKeyMutation(t);return this.processCreateAPIKeyResult(r)}catch(t){return this.handleCreateAPIKeyError(t)}}createAPIKeyVariables(e){return{input:{Label:e.Label,Description:e.Description,ExpiresAt:e.ExpiresAt?.toISOString(),ScopeIDs:e.ScopeIDs}}}async executeCreateAPIKeyMutation(e){const t=u.gql`
|
|
1324
1324
|
mutation CreateAPIKey($input: CreateAPIKeyInput!) {
|
|
1325
1325
|
CreateAPIKey(input: $input) {
|
|
1326
1326
|
Success
|
|
@@ -2018,5 +2018,5 @@ ${e.stackFrames}`:this.stack}}function j(g){return g instanceof x?g:new x(G(g))}
|
|
|
2018
2018
|
IntegrationGetConnectorCapabilities(companyIntegrationID: $companyIntegrationID) {
|
|
2019
2019
|
Success Message SupportsGet SupportsCreate SupportsUpdate SupportsDelete SupportsSearch
|
|
2020
2020
|
}
|
|
2021
|
-
}`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return c.LogError(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}Object.defineProperty(exports,"gql",{enumerable:!0,get:d(function(){return u.gql},"get")}),exports.ActionItemInput=Ee,exports.ActionItemOutput=De,exports.BrowserIndexedDBStorageProvider=B,exports.BrowserStorageProviderBase=k,exports.FieldMapper=b,exports.FireAndForgetHelper=w,exports.GetDataOutput=Ce,exports.GraphQLAIClient=O,exports.GraphQLActionClient=Le,exports.GraphQLClassifyClient=Ge,exports.GraphQLClusterClient=xe,exports.GraphQLComponentRegistryClient=Qe,exports.GraphQLDataProvider=f,exports.GraphQLEncryptionClient=Te,exports.GraphQLFileStorageClient=_e,exports.GraphQLIntegrationClient=Oe,exports.GraphQLListsClient=be,exports.GraphQLLiveKitClient=Fe,exports.GraphQLProviderConfigData=me,exports.GraphQLSearchClient=Ve,exports.GraphQLSystemUserClient=ve,exports.GraphQLTestingClient=qe,exports.GraphQLTransactionGroup=V,exports.GraphQLVersionHistoryClient=Ue,exports.PACKAGE_VERSION=
|
|
2021
|
+
}`;return(await this._dataProvider.ExecuteGQL(t,{companyIntegrationID:e}))?.IntegrationGetConnectorCapabilities??{Success:!1,Message:"No response"}}catch(t){return{Success:!1,Message:t.message}}}handleError(e,t){const r=e;return c.LogError(`Error in integration discovery: ${r}`),{Success:!1,Message:`Error: ${r.message}`,Data:t}}}Object.defineProperty(exports,"gql",{enumerable:!0,get:d(function(){return u.gql},"get")}),exports.ActionItemInput=Ee,exports.ActionItemOutput=De,exports.BrowserIndexedDBStorageProvider=B,exports.BrowserStorageProviderBase=k,exports.FieldMapper=b,exports.FireAndForgetHelper=w,exports.GetDataOutput=Ce,exports.GraphQLAIClient=O,exports.GraphQLActionClient=Le,exports.GraphQLClassifyClient=Ge,exports.GraphQLClusterClient=xe,exports.GraphQLComponentRegistryClient=Qe,exports.GraphQLDataProvider=f,exports.GraphQLEncryptionClient=Te,exports.GraphQLFileStorageClient=_e,exports.GraphQLIntegrationClient=Oe,exports.GraphQLListsClient=be,exports.GraphQLLiveKitClient=Fe,exports.GraphQLProviderConfigData=me,exports.GraphQLSearchClient=Ve,exports.GraphQLSystemUserClient=ve,exports.GraphQLTestingClient=qe,exports.GraphQLTransactionGroup=V,exports.GraphQLVersionHistoryClient=Ue,exports.PACKAGE_VERSION=N,exports.RoleInput=he,exports.RolesAndUsersInput=fe,exports.SafeGraphQLError=x,exports.SanitizeGraphQLError=G,exports.SimpleRemoteEntity=$e,exports.SimpleRemoteEntityField=Pe,exports.SimpleRemoteEntityOutput=we,exports.SyncDataAction=J,exports.SyncDataResult=Re,exports.SyncRolesAndUsersResult=pe,exports.ToSafeGraphQLError=j,exports.UserInput=Ie,exports.setupGraphQLClient=Se;
|
|
2022
2022
|
//# sourceMappingURL=index.cjs.map
|