@contractspec/example.integration-hub 3.8.22 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +6 -1
  2. package/dist/docs/index.js +5 -2
  3. package/dist/docs/integration-hub.docblock.js +5 -2
  4. package/dist/handlers/index.js +5 -5
  5. package/dist/handlers/integration.handlers.js +5 -5
  6. package/dist/handlers/integration.handlers.preview.test.d.ts +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +8 -8
  9. package/dist/node/docs/index.js +5 -2
  10. package/dist/node/docs/integration-hub.docblock.js +5 -2
  11. package/dist/node/handlers/index.js +5 -5
  12. package/dist/node/handlers/integration.handlers.js +5 -5
  13. package/dist/node/index.js +8 -8
  14. package/dist/node/setup/credential-setup.js +1 -0
  15. package/dist/node/setup/index.js +1 -0
  16. package/dist/node/ui/IntegrationDashboard.js +1 -1
  17. package/dist/node/ui/IntegrationHubCredentialSetupPreview.js +1 -0
  18. package/dist/node/ui/IntegrationHubCredentialSetupPreview.model.js +1 -0
  19. package/dist/node/ui/hooks/index.js +1 -1
  20. package/dist/node/ui/hooks/useIntegrationData.js +1 -1
  21. package/dist/node/ui/index.js +4 -4
  22. package/dist/setup/credential-setup.d.ts +158 -0
  23. package/dist/setup/credential-setup.js +2 -0
  24. package/dist/setup/index.d.ts +1 -0
  25. package/dist/setup/index.js +2 -0
  26. package/dist/ui/IntegrationDashboard.js +1 -1
  27. package/dist/ui/IntegrationDashboard.preview-runtime.test.d.ts +1 -0
  28. package/dist/ui/IntegrationHubCredentialSetupPreview.d.ts +6 -0
  29. package/dist/ui/IntegrationHubCredentialSetupPreview.js +2 -0
  30. package/dist/ui/IntegrationHubCredentialSetupPreview.model.d.ts +22 -0
  31. package/dist/ui/IntegrationHubCredentialSetupPreview.model.js +2 -0
  32. package/dist/ui/IntegrationHubCredentialSetupPreview.test.d.ts +1 -0
  33. package/dist/ui/hooks/index.js +1 -1
  34. package/dist/ui/hooks/useIntegrationData.d.ts +1 -1
  35. package/dist/ui/hooks/useIntegrationData.js +1 -1
  36. package/dist/ui/index.d.ts +1 -0
  37. package/dist/ui/index.js +4 -4
  38. package/package.json +59 -10
@@ -1 +1 @@
1
- import{useTemplateRuntime as Kq}from"@contractspec/lib.example-shared-ui";import{useCallback as Qq,useEffect as Xq,useState as R}from"react";function x(K="local-project"){let{handlers:W}=Kq(),q=W.integration,[J,Y]=R([]),[X,U]=R([]),[P,O]=R([]),[$,Q]=R(!0),[k,z]=R(null),A=Qq(async()=>{try{Q(!0),z(null);let[w,t,qq]=await Promise.all([q.listIntegrations({projectId:K,limit:100}),q.listConnections({limit:100}),q.listSyncConfigs({limit:100})]);Y(w.integrations),U(t.connections),O(qq.configs)}catch(w){z(w instanceof Error?w:Error("Failed to load integrations"))}finally{Q(!1)}},[q,K]);Xq(()=>{A()},[A]);let B={totalIntegrations:J.length,activeIntegrations:J.filter((w)=>w.status==="ACTIVE").length,totalConnections:X.length,connectedCount:X.filter((w)=>w.status==="CONNECTED").length,totalSyncs:P.length,activeSyncs:P.filter((w)=>w.status==="ACTIVE").length};return{integrations:J,connections:X,syncConfigs:P,loading:$,error:k,stats:B,refetch:A}}import{defineVisualization as h,VisualizationRegistry as Zq}from"@contractspec/lib.contracts-spec/visualizations";var $q={key:"integration.list",version:"1.0.0"},Wq={key:"integration.connection.list",version:"1.0.0"},g={key:"integration.syncConfig.list",version:"1.0.0"},V={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},d=h({meta:{...V,key:"integration-hub.visualization.integration-types",title:"Integration Types",description:"Distribution of configured integration categories.",goal:"Show where integration coverage is concentrated.",context:"Integration overview."},source:{primary:$q,resultPath:"data"},visualization:{kind:"pie",nameDimension:"type",valueMeasure:"count",dimensions:[{key:"type",label:"Type",dataPath:"type",type:"category"}],measures:[{key:"count",label:"Count",dataPath:"count",format:"number"}],table:{caption:"Integration counts by type."}}}),p=h({meta:{...V,key:"integration-hub.visualization.connection-status",title:"Connection Status",description:"Status distribution across configured connections.",goal:"Highlight connection health and instability.",context:"Connection monitoring."},source:{primary:Wq,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"status",yMeasures:["count"],dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"count",label:"Connections",dataPath:"count",format:"number",color:"#1d4ed8"}],table:{caption:"Connection counts by status."}}}),C=h({meta:{...V,key:"integration-hub.visualization.sync-healthy",title:"Healthy Syncs",description:"Sync configurations currently healthy or recently successful.",goal:"Summarize healthy synchronization capacity.",context:"Sync-state comparison."},source:{primary:g,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),S=h({meta:{...V,key:"integration-hub.visualization.sync-attention",title:"Attention Needed",description:"Sync configurations paused, failing, or otherwise needing review.",goal:"Summarize syncs needing action.",context:"Sync-state comparison."},source:{primary:g,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),u=[d,p,C,S],Iq=new Zq([...u]),dq=u.map((K)=>({key:K.meta.key,version:K.meta.version}));function Jq(K){return K==="ACTIVE"||K==="SUCCESS"}function l(K,W,q){let J=new Map,Y=new Map,X=0,U=0;for(let $ of K)J.set($.type,(J.get($.type)??0)+1);for(let $ of W)Y.set($.status,(Y.get($.status)??0)+1);for(let $ of q)if(Jq($.status))X+=1;else U+=1;return{primaryItems:[{key:"integration-types",spec:d,data:{data:Array.from(J.entries()).map(([$,Q])=>({type:$,count:Q}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:p,data:{data:Array.from(Y.entries()).map(([$,Q])=>({status:$,count:Q}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:C,data:{data:[{value:X}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:S,data:{data:[{value:U}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}import{ComparisonView as Yq,VisualizationCard as Pq,VisualizationGrid as Hq}from"@contractspec/lib.design-system";import{jsx as _,jsxs as r}from"react/jsx-runtime";function c({integrations:K,connections:W,syncConfigs:q}){let{primaryItems:J,comparisonItems:Y}=l(K,W,q);return r("section",{className:"space-y-4",children:[r("div",{children:[_("h3",{className:"font-semibold text-lg",children:"Integration Visualizations"}),_("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts for integration coverage and sync health."})]}),_(Hq,{children:J.map((X)=>_(Pq,{data:X.data,description:X.description,height:X.height,spec:X.spec,title:X.title},X.key))}),_(Yq,{description:"Comparison surface for healthy versus attention-needed syncs.",items:Y,title:"Sync-State Comparison"})]})}import{ChatWithSidebar as Uq}from"@contractspec/module.ai-chat";import{jsx as o}from"react/jsx-runtime";var wq=["List my integrations","Show sync status","Add a connection"],Gq="You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.";function a({proxyUrl:K="/api/chat",mcpServers:W,thinkingLevel:q="thinking",suggestions:J=wq,systemPrompt:Y=Gq,className:X}){return o("div",{className:X??"flex h-[500px] flex-col",children:o(Uq,{className:"flex-1",systemPrompt:Y,proxyUrl:K,mcpServers:W,thinkingLevel:q,suggestions:J,showSuggestionsWhenEmpty:!0})})}import{Button as v}from"@contractspec/lib.design-system";import{Badge as i}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as Bq}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as M,jsxs as Oq}from"react/jsx-runtime";var Fq={ACTIVE:"default",CONNECTED:"default",SUCCESS:"default",PENDING:"secondary",PAUSED:"secondary",ERROR:"destructive",DISCONNECTED:"outline"};function N(K){return K?K.toLocaleString():"Never"}function b(K){return K?JSON.stringify(K,null,2):"No configuration"}function f({status:K}){return M(i,{variant:Fq[K]??"outline",children:K})}function I({controller:K,label:W,toggleColumnId:q,toggleVisibleLabel:J,toggleHiddenLabel:Y,pinColumnId:X,pinLabel:U,resizeColumnId:P,resizeLabel:O}){let $=K.rows[0],Q=K.columns.find((B)=>B.id===q),k=K.columns.find((B)=>B.id===X),z=K.columns.find((B)=>B.id===P),A=k?.pinState==="left"?!1:"left";return Oq(Bq,{gap:"sm",className:"flex-wrap",children:[M(i,{variant:"outline",children:W}),M(v,{variant:"outline",size:"sm",onPress:()=>$?.toggleExpanded?.(!$?.isExpanded),children:"Expand First Row"}),M(v,{variant:"outline",size:"sm",onPress:()=>Q?.toggleVisibility?.(!Q?.visible),children:Q?.visible?J:Y}),M(v,{variant:"outline",size:"sm",onPress:()=>k?.pin?.(A),children:k?.pinState==="left"?`Unpin ${U}`:`Pin ${U}`}),M(v,{variant:"outline",size:"sm",onPress:()=>z?.resizeBy?.(40),children:O})]})}import{DataTable as Mq}from"@contractspec/lib.design-system";import{useContractTable as Dq}from"@contractspec/lib.presentation-runtime-react";import{VStack as s}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as E}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as G,jsxs as T}from"react/jsx-runtime";function y({connections:K}){let W=Dq({data:K,columns:[{id:"connection",header:"Connection",label:"Connection",accessor:(q)=>q.name,cell:({item:q})=>T(s,{gap:"xs",children:[G(E,{className:"font-medium text-sm",children:q.name}),T(E,{className:"text-muted-foreground text-xs",children:["Created ",q.createdAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>G(f,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"lastSyncAt",header:"Last Sync",label:"Last Sync",accessor:(q)=>q.lastSyncAt?.getTime()??0,cell:({item:q})=>N(q.lastSyncAt),size:200,canSort:!0,canHide:!0,canResize:!0},{id:"errorMessage",header:"Errors",label:"Errors",accessor:(q)=>q.errorMessage??"",cell:({value:q})=>String(q||"No errors"),size:240,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{errorMessage:!1},columnPinning:{left:["connection"],right:[]}},renderExpandedContent:(q)=>T(s,{gap:"sm",className:"py-2",children:[G(E,{className:"font-medium text-sm",children:"Credentials"}),G("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:b(q.credentials)}),G(E,{className:"font-medium text-sm",children:"Config"}),G("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:b(q.config)}),G(E,{className:"text-muted-foreground text-sm",children:q.errorMessage??"No sync errors recorded."})]}),getCanExpand:()=>!0});return G(Mq,{controller:W,title:"Connections",description:"Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",toolbar:G(I,{controller:W,label:`${K.length} total connections`,toggleColumnId:"errorMessage",toggleVisibleLabel:"Hide Error Column",toggleHiddenLabel:"Show Error Column",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"connection",resizeLabel:"Widen Connection"}),emptyState:G("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No connections found"})})}import{DataTable as kq}from"@contractspec/lib.design-system";import{useContractTable as Aq}from"@contractspec/lib.presentation-runtime-react";import{VStack as e}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as D}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as L,jsxs as F}from"react/jsx-runtime";function m({syncConfigs:K}){let W=Aq({data:K,columns:[{id:"sync",header:"Sync Config",label:"Sync Config",accessor:(q)=>q.name,cell:({item:q})=>F(e,{gap:"xs",children:[L(D,{className:"font-medium text-sm",children:q.name}),F(D,{className:"text-muted-foreground text-xs",children:[q.sourceEntity," → ",q.targetEntity]})]}),size:260,minSize:200,canSort:!0,canPin:!0,canResize:!0},{id:"frequency",header:"Frequency",label:"Frequency",accessorKey:"frequency",size:160,canSort:!0,canHide:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>L(f,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"recordsSynced",header:"Records",label:"Records",accessorKey:"recordsSynced",align:"right",size:140,canSort:!0,canResize:!0},{id:"lastRunAt",header:"Last Run",label:"Last Run",accessor:(q)=>q.lastRunAt?.getTime()??0,cell:({item:q})=>N(q.lastRunAt),size:200,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{lastRunAt:!1},columnPinning:{left:["sync"],right:[]}},renderExpandedContent:(q)=>F(e,{gap:"sm",className:"py-2",children:[F(D,{className:"text-muted-foreground text-sm",children:["Connection ",q.connectionId]}),F(D,{className:"text-muted-foreground text-sm",children:["Last run: ",N(q.lastRunAt)]}),F(D,{className:"text-muted-foreground text-sm",children:["Last status: ",q.lastRunStatus??"No runs recorded"]}),F(D,{className:"text-muted-foreground text-sm",children:["Updated ",q.updatedAt.toLocaleString()]})]}),getCanExpand:()=>!0});return L(kq,{controller:W,title:"Sync Configs",description:"Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",toolbar:L(I,{controller:W,label:`${K.length} syncs`,toggleColumnId:"lastRunAt",toggleVisibleLabel:"Hide Last Run",toggleHiddenLabel:"Show Last Run",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"sync",resizeLabel:"Widen Sync"}),emptyState:L("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No sync configurations found"})})}import{Button as n,ErrorState as Rq,LoaderBlock as _q,StatCard as j,StatCardGroup as Nq}from"@contractspec/lib.design-system";import{useState as Eq}from"react";import{jsx as Z,jsxs as H}from"react/jsx-runtime";var Lq={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",INACTIVE:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",CONNECTED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DISCONNECTED:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",PENDING:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ERROR:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},zq={CRM:"\uD83D\uDCCA",MARKETING:"\uD83D\uDCE3",PAYMENT:"\uD83D\uDCB3",COMMUNICATION:"\uD83D\uDCAC",DATA:"\uD83D\uDDC4️",CUSTOM:"⚙️"};function AK(){let[K,W]=Eq("integrations"),{integrations:q,connections:J,syncConfigs:Y,loading:X,error:U,stats:P,refetch:O}=x(),$=[{id:"integrations",label:"Integrations",icon:"\uD83D\uDD0C"},{id:"connections",label:"Connections",icon:"\uD83D\uDD17"},{id:"syncs",label:"Sync Configs",icon:"\uD83D\uDD04"},{id:"chat",label:"Chat",icon:"\uD83D\uDCAC"}];if(X)return Z(_q,{label:"Loading Integrations..."});if(U)return Z(Rq,{title:"Failed to load Integrations",description:U.message,onRetry:O,retryLabel:"Retry"});return H("div",{className:"space-y-6",children:[H("div",{className:"flex items-center justify-between",children:[Z("h2",{className:"font-bold text-2xl",children:"Integration Hub"}),H(n,{onClick:()=>alert("Add integration modal"),children:[Z("span",{className:"mr-2",children:"+"})," Add Integration"]})]}),H(Nq,{children:[Z(j,{label:"Integrations",value:P.totalIntegrations,hint:`${P.activeIntegrations} active`}),Z(j,{label:"Connections",value:P.totalConnections,hint:`${P.connectedCount} connected`}),Z(j,{label:"Syncs",value:P.totalSyncs,hint:`${P.activeSyncs} active`})]}),Z(c,{connections:J,integrations:q,syncConfigs:Y}),Z("nav",{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:$.map((Q)=>H(n,{type:"button",role:"tab","aria-selected":K===Q.id,onClick:()=>W(Q.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${K===Q.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[Z("span",{children:Q.icon}),Q.label]},Q.id))}),H("div",{className:"min-h-[400px]",role:"tabpanel",children:[K==="integrations"&&H("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[q.map((Q)=>H("div",{className:"cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",children:[H("div",{className:"mb-3 flex items-center gap-3",children:[Z("span",{className:"text-2xl",children:zq[Q.type]??"⚙️"}),H("div",{children:[Z("h3",{className:"font-medium",children:Q.name}),Z("p",{className:"text-muted-foreground text-sm",children:Q.type})]})]}),H("div",{className:"flex items-center justify-between",children:[Z("span",{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${Lq[Q.status]??""}`,children:Q.status}),Z("span",{className:"text-muted-foreground text-xs",children:Q.createdAt.toLocaleDateString()})]})]},Q.id)),q.length===0&&Z("div",{className:"col-span-full flex h-64 items-center justify-center text-muted-foreground",children:"No integrations configured"})]}),K==="connections"&&Z(y,{connections:J}),K==="chat"&&Z(a,{proxyUrl:"/api/chat",thinkingLevel:"thinking",suggestions:["List my integrations","Show sync status","Add a connection"],className:"min-h-[400px]"}),K==="syncs"&&Z(m,{syncConfigs:Y})]})]})}export{AK as IntegrationDashboard};
1
+ var t={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},rr={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},M={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};import{useTemplateRuntime as Ur}from"@contractspec/lib.example-shared-ui";import{useCallback as Jr,useEffect as Qr,useState as Z}from"react";function pr(r){let{handlers:O,projectId:p}=Ur(),P=O.integration,K=r??p,[k,R]=Z([]),[W,E]=Z([]),[w,q]=Z([]),[y,v]=Z(!0),[m,Y]=Z(null),g=Jr(async()=>{try{v(!0),Y(null);let[B,Xr,hr]=await Promise.all([P.listIntegrations({projectId:K,limit:100}),P.listConnections({limit:100}),P.listSyncConfigs({limit:100})]);R(B.integrations),E(Xr.connections),q(hr.configs)}catch(B){Y(B instanceof Error?B:Error("Failed to load integrations"))}finally{v(!1)}},[K,P]);Qr(()=>{g()},[g]);let yr={totalIntegrations:k.length,activeIntegrations:k.filter((B)=>B.status==="ACTIVE").length,totalConnections:W.length,connectedCount:W.filter((B)=>B.status==="CONNECTED").length,totalSyncs:w.length,activeSyncs:w.filter((B)=>B.status==="ACTIVE").length};return{integrations:k,connections:W,syncConfigs:w,loading:y,error:m,stats:yr,refetch:g}}import{defineVisualization as e,VisualizationRegistry as Zr}from"@contractspec/lib.contracts-spec/visualizations";var $r={key:"integration.list",version:"1.0.0"},Fr={key:"integration.connection.list",version:"1.0.0"},kr={key:"integration.syncConfig.list",version:"1.0.0"},V={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},u=e({meta:{...V,key:"integration-hub.visualization.integration-types",title:"Integration Types",description:"Distribution of configured integration categories.",goal:"Show where integration coverage is concentrated.",context:"Integration overview."},source:{primary:$r,resultPath:"data"},visualization:{kind:"pie",nameDimension:"type",valueMeasure:"count",dimensions:[{key:"type",label:"Type",dataPath:"type",type:"category"}],measures:[{key:"count",label:"Count",dataPath:"count",format:"number"}],table:{caption:"Integration counts by type."}}}),o=e({meta:{...V,key:"integration-hub.visualization.connection-status",title:"Connection Status",description:"Status distribution across configured connections.",goal:"Highlight connection health and instability.",context:"Connection monitoring."},source:{primary:Fr,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"status",yMeasures:["count"],dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"count",label:"Connections",dataPath:"count",format:"number",color:"#1d4ed8"}],table:{caption:"Connection counts by status."}}}),c=e({meta:{...V,key:"integration-hub.visualization.sync-healthy",title:"Healthy Syncs",description:"Sync configurations currently healthy or recently successful.",goal:"Summarize healthy synchronization capacity.",context:"Sync-state comparison."},source:{primary:kr,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),l=e({meta:{...V,key:"integration-hub.visualization.sync-attention",title:"Attention Needed",description:"Sync configurations paused, failing, or otherwise needing review.",goal:"Summarize syncs needing action.",context:"Sync-state comparison."},source:{primary:kr,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),wr=[u,o,c,l],pp=new Zr([...wr]),kp=wr.map((r)=>({key:r.meta.key,version:r.meta.version}));function br(r){return r==="ACTIVE"||r==="SUCCESS"}function _r(r,O,p){let P=new Map,K=new Map,k=0,R=0;for(let w of r)P.set(w.type,(P.get(w.type)??0)+1);for(let w of O)K.set(w.status,(K.get(w.status)??0)+1);for(let w of p)if(br(w.status))k+=1;else R+=1;return{primaryItems:[{key:"integration-types",spec:u,data:{data:Array.from(P.entries()).map(([w,q])=>({type:w,count:q}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:o,data:{data:Array.from(K.entries()).map(([w,q])=>({status:w,count:q}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:c,data:{data:[{value:k}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:l,data:{data:[{value:R}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}import{ComparisonView as Dr,VisualizationCard as dr,VisualizationGrid as Lr}from"@contractspec/lib.design-system";import{jsx as $,jsxs as Or}from"react/jsx-runtime";function Pr({integrations:r,connections:O,syncConfigs:p}){let{primaryItems:P,comparisonItems:K}=_r(r,O,p);return Or("section",{className:"space-y-4",children:[Or("div",{children:[$("h3",{className:"font-semibold text-lg",children:"Integration Visualizations"}),$("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts for integration coverage and sync health."})]}),$(Lr,{children:P.map((k)=>$(dr,{data:k.data,description:k.description,height:k.height,spec:k.spec,title:k.title},k.key))}),$(Dr,{description:"Comparison surface for healthy versus attention-needed syncs.",items:K,title:"Sync-State Comparison"})]})}import{ChatWithSidebar as Mr}from"@contractspec/module.ai-chat";import{jsx as Kr}from"react/jsx-runtime";var er=["List my integrations","Show sync status","Add a connection"],Vr="You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.";function Er({proxyUrl:r="/api/chat",mcpServers:O,thinkingLevel:p="thinking",suggestions:P=er,systemPrompt:K=Vr,className:k}){return Kr("div",{className:k??"flex h-[500px] flex-col",children:Kr(Mr,{className:"flex-1",systemPrompt:K,proxyUrl:r,mcpServers:O,thinkingLevel:p,suggestions:P,showSuggestionsWhenEmpty:!0})})}function Ar(r){let O=t,p=rr,P=M,K=O.modes?.[r],k=[...(K?.configFields??[]).map((E)=>({...E,kind:"config",configured:vr(P.configValues[E.key]),secretRef:void 0})),...(K?.secretFields??[]).map((E)=>({...E,kind:"secret",configured:vr(P.secretRefs[E.key]),secretRef:P.secretRefs[E.key]}))],R=Object.values(p.variables??{}).flatMap((E)=>(E.aliases??[]).map((w)=>({...w,targetLabel:p.targets?.[w.targetId??""]?.packageName??w.targetId}))).filter((E)=>P.targetIds.includes(E.targetId??"")),W=k.filter((E)=>E.kind==="secret"&&E.required&&!E.configured);return{fields:k,aliases:R,missingSecrets:W}}function vr(r){return r!==void 0&&r!==null&&r!==""}import{Box as h,Button as zr,HStack as Rr,Muted as x,Small as U,Text as z,VStack as F}from"@contractspec/lib.design-system";import{jsx as A,jsxs as H}from"react/jsx-runtime";function Gr({mode:r=M.selectedMode,onModeChange:O}){let{fields:p,aliases:P,missingSecrets:K}=Ar(r);return A(h,{className:"rounded-2xl border border-border bg-card p-4",children:H(F,{gap:"lg",align:"stretch",children:[H(F,{gap:"xs",align:"stretch",children:[A(U,{className:"font-semibold uppercase tracking-wide",children:"BYOK and monorepo env setup"}),A(z,{className:"text-muted-foreground text-sm",children:"The Integration Hub sample now publishes credential manifests, server-only secret references, and Next/Expo public aliases for multi-app workspaces."})]}),A(Rr,{className:"flex-wrap gap-2",children:["managed","byok"].map((k)=>A(zr,{type:"button",variant:r===k?"default":"outline",onClick:()=>O?.(k),children:k==="byok"?"BYOK":"Managed"},k))}),H(F,{gap:"sm",align:"stretch",children:[A(U,{children:"Required setup fields"}),A(h,{className:"grid gap-2 md:grid-cols-2",children:p.map((k)=>A(h,{className:"rounded-xl border border-border bg-background p-3",children:H(Rr,{className:"items-start justify-between gap-3",children:[H(F,{gap:"xs",align:"stretch",children:[A(z,{className:"font-medium text-sm",children:qr(k.key)}),A(x,{className:"text-xs",children:k.description}),k.secretRef?A(U,{className:"font-mono",children:k.secretRef}):null]}),A(U,{className:"rounded-full bg-muted px-2 py-0.5",children:k.configured?"configured":"missing"})]})},`${k.kind}:${k.key}`))})]}),H(F,{gap:"sm",align:"stretch",children:[A(U,{children:"App aliases"}),A(h,{className:"grid gap-2 md:grid-cols-2",children:P.map((k)=>H(h,{className:"rounded-xl border border-border bg-background p-3",children:[A(z,{className:"font-mono text-sm",children:k.name}),H(x,{className:"text-xs",children:[k.targetLabel," · ",k.framework," ·"," ",k.exposure??"server"]}),Cr(k.name)?A(U,{className:"text-amber-600",children:"Public client alias"}):null]},`${k.targetId}:${k.name}`))})]}),K.length?H(h,{className:"rounded-xl border border-amber-300 bg-amber-50 p-3 text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100",children:[H(z,{className:"font-medium text-sm",children:["Missing BYOK secret refs:"," ",K.map((k)=>qr(k.key)).join(", "),"."]}),A(x,{className:"text-xs",children:"Secret fields stay server-only and are not materialized as NEXT_PUBLIC_* or EXPO_PUBLIC_* aliases."})]}):null]})})}function Cr(r){return r.startsWith("NEXT_PUBLIC_")||r.startsWith("EXPO_PUBLIC_")}function qr(r){return r.replace(/[_-]+/g," ").replace(/\b\w/g,(O)=>O.toUpperCase())}import{Button as C}from"@contractspec/lib.design-system";import{Badge as Nr}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as fr}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as J,jsxs as Tr}from"react/jsx-runtime";var Sr={ACTIVE:"default",CONNECTED:"default",SUCCESS:"default",PENDING:"secondary",PAUSED:"secondary",ERROR:"destructive",DISCONNECTED:"outline"};function b(r){return r?r.toLocaleString():"Never"}function j(r){return r?JSON.stringify(r,null,2):"No configuration"}function f({status:r}){return J(Nr,{variant:Sr[r]??"outline",children:r})}function S({controller:r,label:O,toggleColumnId:p,toggleVisibleLabel:P,toggleHiddenLabel:K,pinColumnId:k,pinLabel:R,resizeColumnId:W,resizeLabel:E}){let w=r.rows[0],q=r.columns.find((Y)=>Y.id===p),y=r.columns.find((Y)=>Y.id===k),v=r.columns.find((Y)=>Y.id===W),m=y?.pinState==="left"?!1:"left";return Tr(fr,{gap:"sm",className:"flex-wrap",children:[J(Nr,{variant:"outline",children:O}),J(C,{variant:"outline",size:"sm",onPress:()=>w?.toggleExpanded?.(!w?.isExpanded),children:"Expand First Row"}),J(C,{variant:"outline",size:"sm",onPress:()=>q?.toggleVisibility?.(!q?.visible),children:q?.visible?P:K}),J(C,{variant:"outline",size:"sm",onPress:()=>y?.pin?.(m),children:y?.pinState==="left"?`Unpin ${R}`:`Pin ${R}`}),J(C,{variant:"outline",size:"sm",onPress:()=>v?.resizeBy?.(40),children:E})]})}import{DataTable as mr}from"@contractspec/lib.design-system";import{useContractTable as gr}from"@contractspec/lib.presentation-runtime-react";import{VStack as Wr}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as D}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as I,jsxs as a}from"react/jsx-runtime";function i({connections:r}){let O=gr({data:r,columns:[{id:"connection",header:"Connection",label:"Connection",accessor:(p)=>p.name,cell:({item:p})=>a(Wr,{gap:"xs",children:[I(D,{className:"font-medium text-sm",children:p.name}),a(D,{className:"text-muted-foreground text-xs",children:["Created ",p.createdAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:p})=>I(f,{status:String(p)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"lastSyncAt",header:"Last Sync",label:"Last Sync",accessor:(p)=>p.lastSyncAt?.getTime()??0,cell:({item:p})=>b(p.lastSyncAt),size:200,canSort:!0,canHide:!0,canResize:!0},{id:"errorMessage",header:"Errors",label:"Errors",accessor:(p)=>p.errorMessage??"",cell:({value:p})=>String(p||"No errors"),size:240,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{errorMessage:!1},columnPinning:{left:["connection"],right:[]}},renderExpandedContent:(p)=>a(Wr,{gap:"sm",className:"py-2",children:[I(D,{className:"font-medium text-sm",children:"Credentials"}),I("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:j(p.credentials)}),I(D,{className:"font-medium text-sm",children:"Config"}),I("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:j(p.config)}),I(D,{className:"text-muted-foreground text-sm",children:p.errorMessage??"No sync errors recorded."})]}),getCanExpand:()=>!0});return I(mr,{controller:O,title:"Connections",description:"Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",toolbar:I(S,{controller:O,label:`${r.length} total connections`,toggleColumnId:"errorMessage",toggleVisibleLabel:"Hide Error Column",toggleHiddenLabel:"Show Error Column",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"connection",resizeLabel:"Widen Connection"}),emptyState:I("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No connections found"})})}import{DataTable as ur}from"@contractspec/lib.design-system";import{useContractTable as or}from"@contractspec/lib.presentation-runtime-react";import{VStack as Br}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as Q}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as d,jsxs as X}from"react/jsx-runtime";function n({syncConfigs:r}){let O=or({data:r,columns:[{id:"sync",header:"Sync Config",label:"Sync Config",accessor:(p)=>p.name,cell:({item:p})=>X(Br,{gap:"xs",children:[d(Q,{className:"font-medium text-sm",children:p.name}),X(Q,{className:"text-muted-foreground text-xs",children:[p.sourceEntity," → ",p.targetEntity]})]}),size:260,minSize:200,canSort:!0,canPin:!0,canResize:!0},{id:"frequency",header:"Frequency",label:"Frequency",accessorKey:"frequency",size:160,canSort:!0,canHide:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:p})=>d(f,{status:String(p)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"recordsSynced",header:"Records",label:"Records",accessorKey:"recordsSynced",align:"right",size:140,canSort:!0,canResize:!0},{id:"lastRunAt",header:"Last Run",label:"Last Run",accessor:(p)=>p.lastRunAt?.getTime()??0,cell:({item:p})=>b(p.lastRunAt),size:200,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{lastRunAt:!1},columnPinning:{left:["sync"],right:[]}},renderExpandedContent:(p)=>X(Br,{gap:"sm",className:"py-2",children:[X(Q,{className:"text-muted-foreground text-sm",children:["Connection ",p.connectionId]}),X(Q,{className:"text-muted-foreground text-sm",children:["Last run: ",b(p.lastRunAt)]}),X(Q,{className:"text-muted-foreground text-sm",children:["Last status: ",p.lastRunStatus??"No runs recorded"]}),X(Q,{className:"text-muted-foreground text-sm",children:["Updated ",p.updatedAt.toLocaleString()]})]}),getCanExpand:()=>!0});return d(ur,{controller:O,title:"Sync Configs",description:"Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",toolbar:d(S,{controller:O,label:`${r.length} syncs`,toggleColumnId:"lastRunAt",toggleVisibleLabel:"Hide Last Run",toggleHiddenLabel:"Show Last Run",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"sync",resizeLabel:"Widen Sync"}),emptyState:d("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No sync configurations found"})})}import{Box as L,Button as Hr,ErrorState as cr,HStack as T,LoaderBlock as lr,StatCard as s,StatCardGroup as xr,Text as G,VStack as Ir}from"@contractspec/lib.design-system";import{useState as Yr}from"react";import{jsx as _,jsxs as N}from"react/jsx-runtime";var jr={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",INACTIVE:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",CONNECTED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DISCONNECTED:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",PENDING:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ERROR:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},ar={CRM:"\uD83D\uDCCA",MARKETING:"\uD83D\uDCE3",PAYMENT:"\uD83D\uDCB3",COMMUNICATION:"\uD83D\uDCAC",DATA:"\uD83D\uDDC4️",CUSTOM:"⚙️"};function sp(){let[r,O]=Yr("integrations"),[p,P]=Yr("byok"),{integrations:K,connections:k,syncConfigs:R,loading:W,error:E,stats:w,refetch:q}=pr(),y=[{id:"integrations",label:"Integrations",icon:"\uD83D\uDD0C"},{id:"credentials",label:"BYOK/env",icon:"\uD83D\uDD10"},{id:"connections",label:"Connections",icon:"\uD83D\uDD17"},{id:"syncs",label:"Sync Configs",icon:"\uD83D\uDD04"},{id:"chat",label:"Chat",icon:"\uD83D\uDCAC"}];if(W)return _(lr,{label:"Loading Integrations..."});if(E)return _(cr,{title:"Failed to load Integrations",description:E.message,onRetry:q,retryLabel:"Retry"});return N(Ir,{gap:"lg",align:"stretch",children:[N(T,{className:"items-center justify-between",children:[_(G,{className:"font-bold text-2xl",children:"Integration Hub"}),_(Hr,{onClick:()=>alert("Add integration modal"),children:N(T,{className:"items-center gap-2",children:[_(G,{"aria-hidden":"true",children:"+"}),_(G,{children:"Add Integration"})]})})]}),N(xr,{children:[_(s,{label:"Integrations",value:w.totalIntegrations,hint:`${w.activeIntegrations} active`}),_(s,{label:"Connections",value:w.totalConnections,hint:`${w.connectedCount} connected`}),_(s,{label:"Syncs",value:w.totalSyncs,hint:`${w.activeSyncs} active`})]}),_(Pr,{connections:k,integrations:K,syncConfigs:R}),_(L,{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:y.map((v)=>N(Hr,{type:"button",role:"tab","aria-selected":r===v.id,onClick:()=>O(v.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${r===v.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[_(G,{"aria-hidden":"true",children:v.icon}),_(G,{children:v.label})]},v.id))}),N(L,{className:"min-h-[400px]",role:"tabpanel",children:[r==="integrations"&&N(L,{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[K.map((v)=>N(L,{className:"cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",children:[N(T,{className:"mb-3 items-center gap-3",children:[_(G,{className:"text-2xl",children:ar[v.type]??"⚙️"}),N(Ir,{gap:"xs",align:"stretch",children:[_(G,{className:"font-medium",children:v.name}),_(G,{className:"text-muted-foreground text-sm",children:v.type})]})]}),N(T,{className:"items-center justify-between",children:[_(G,{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${jr[v.status]??""}`,children:v.status}),_(G,{className:"text-muted-foreground text-xs",children:v.createdAt.toLocaleDateString()})]})]},v.id)),K.length===0&&_(L,{className:"col-span-full flex h-64 items-center justify-center",children:_(G,{className:"text-muted-foreground",children:"No integrations configured"})})]}),r==="credentials"&&_(Gr,{mode:p,onModeChange:P}),r==="connections"&&_(i,{connections:k}),r==="chat"&&_(Er,{proxyUrl:"/api/chat",thinkingLevel:"thinking",suggestions:["List my integrations","Show sync status","Add a connection"],className:"min-h-[400px]"}),r==="syncs"&&_(n,{syncConfigs:R})]})]})}export{sp as IntegrationDashboard};
@@ -0,0 +1 @@
1
+ var _={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},w={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},u={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};function l(n){let p=_,k=w,c=u,s=p.modes?.[n],e=[...(s?.configFields??[]).map((o)=>({...o,kind:"config",configured:O(c.configValues[o.key]),secretRef:void 0})),...(s?.secretFields??[]).map((o)=>({...o,kind:"secret",configured:O(c.secretRefs[o.key]),secretRef:c.secretRefs[o.key]}))],d=Object.values(k.variables??{}).flatMap((o)=>(o.aliases??[]).map((b)=>({...b,targetLabel:k.targets?.[b.targetId??""]?.packageName??b.targetId}))).filter((o)=>c.targetIds.includes(o.targetId??"")),P=e.filter((o)=>o.kind==="secret"&&o.required&&!o.configured);return{fields:e,aliases:d,missingSecrets:P}}function O(n){return n!==void 0&&n!==null&&n!==""}import{Box as i,Button as m,HStack as E,Muted as g,Small as a,Text as v,VStack as y}from"@contractspec/lib.design-system";import{jsx as r,jsxs as t}from"react/jsx-runtime";function R({mode:n=u.selectedMode,onModeChange:p}){let{fields:k,aliases:c,missingSecrets:s}=l(n);return r(i,{className:"rounded-2xl border border-border bg-card p-4",children:t(y,{gap:"lg",align:"stretch",children:[t(y,{gap:"xs",align:"stretch",children:[r(a,{className:"font-semibold uppercase tracking-wide",children:"BYOK and monorepo env setup"}),r(v,{className:"text-muted-foreground text-sm",children:"The Integration Hub sample now publishes credential manifests, server-only secret references, and Next/Expo public aliases for multi-app workspaces."})]}),r(E,{className:"flex-wrap gap-2",children:["managed","byok"].map((e)=>r(m,{type:"button",variant:n===e?"default":"outline",onClick:()=>p?.(e),children:e==="byok"?"BYOK":"Managed"},e))}),t(y,{gap:"sm",align:"stretch",children:[r(a,{children:"Required setup fields"}),r(i,{className:"grid gap-2 md:grid-cols-2",children:k.map((e)=>r(i,{className:"rounded-xl border border-border bg-background p-3",children:t(E,{className:"items-start justify-between gap-3",children:[t(y,{gap:"xs",align:"stretch",children:[r(v,{className:"font-medium text-sm",children:I(e.key)}),r(g,{className:"text-xs",children:e.description}),e.secretRef?r(a,{className:"font-mono",children:e.secretRef}):null]}),r(a,{className:"rounded-full bg-muted px-2 py-0.5",children:e.configured?"configured":"missing"})]})},`${e.kind}:${e.key}`))})]}),t(y,{gap:"sm",align:"stretch",children:[r(a,{children:"App aliases"}),r(i,{className:"grid gap-2 md:grid-cols-2",children:c.map((e)=>t(i,{className:"rounded-xl border border-border bg-background p-3",children:[r(v,{className:"font-mono text-sm",children:e.name}),t(g,{className:"text-xs",children:[e.targetLabel," · ",e.framework," ·"," ",e.exposure??"server"]}),S(e.name)?r(a,{className:"text-amber-600",children:"Public client alias"}):null]},`${e.targetId}:${e.name}`))})]}),s.length?t(i,{className:"rounded-xl border border-amber-300 bg-amber-50 p-3 text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100",children:[t(v,{className:"font-medium text-sm",children:["Missing BYOK secret refs:"," ",s.map((e)=>I(e.key)).join(", "),"."]}),r(g,{className:"text-xs",children:"Secret fields stay server-only and are not materialized as NEXT_PUBLIC_* or EXPO_PUBLIC_* aliases."})]}):null]})})}function S(n){return n.startsWith("NEXT_PUBLIC_")||n.startsWith("EXPO_PUBLIC_")}function I(n){return n.replace(/[_-]+/g," ").replace(/\b\w/g,(p)=>p.toUpperCase())}export{R as IntegrationHubCredentialSetupPreview};
@@ -0,0 +1 @@
1
+ var c={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},s={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},p={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};function g(r){let d=c,t=s,o=p,i=d.modes?.[r],a=[...(i?.configFields??[]).map((e)=>({...e,kind:"config",configured:l(o.configValues[e.key]),secretRef:void 0})),...(i?.secretFields??[]).map((e)=>({...e,kind:"secret",configured:l(o.secretRefs[e.key]),secretRef:o.secretRefs[e.key]}))],k=Object.values(t.variables??{}).flatMap((e)=>(e.aliases??[]).map((n)=>({...n,targetLabel:t.targets?.[n.targetId??""]?.packageName??n.targetId}))).filter((e)=>o.targetIds.includes(e.targetId??"")),y=a.filter((e)=>e.kind==="secret"&&e.required&&!e.configured);return{fields:a,aliases:k,missingSecrets:y}}function l(r){return r!==void 0&&r!==null&&r!==""}export{g as buildIntegrationHubCredentialSetupPreviewModel};
@@ -1 +1 @@
1
- import{useTemplateRuntime as W}from"@contractspec/lib.example-shared-ui";import{useCallback as X,useEffect as Y,useState as v}from"react";function Z(F="local-project"){let{handlers:J}=W(),w=J.integration,[x,K]=v([]),[z,M]=v([]),[A,N]=v([]),[O,G]=v(!0),[P,H]=v(null),B=X(async()=>{try{G(!0),H(null);let[q,U,V]=await Promise.all([w.listIntegrations({projectId:F,limit:100}),w.listConnections({limit:100}),w.listSyncConfigs({limit:100})]);K(q.integrations),M(U.connections),N(V.configs)}catch(q){H(q instanceof Error?q:Error("Failed to load integrations"))}finally{G(!1)}},[w,F]);Y(()=>{B()},[B]);let Q={totalIntegrations:x.length,activeIntegrations:x.filter((q)=>q.status==="ACTIVE").length,totalConnections:z.length,connectedCount:z.filter((q)=>q.status==="CONNECTED").length,totalSyncs:A.length,activeSyncs:A.filter((q)=>q.status==="ACTIVE").length};return{integrations:x,connections:z,syncConfigs:A,loading:O,error:P,stats:Q,refetch:B}}export{Z as useIntegrationData};
1
+ import{useTemplateRuntime as $}from"@contractspec/lib.example-shared-ui";import{useCallback as k,useEffect as T,useState as w}from"react";function b(K){let{handlers:M,projectId:N}=$(),x=M.integration,G=K??N,[z,Q]=w([]),[A,U]=w([]),[B,V]=w([]),[W,H]=w(!0),[X,J]=w(null),F=k(async()=>{try{H(!0),J(null);let[q,Z,_]=await Promise.all([x.listIntegrations({projectId:G,limit:100}),x.listConnections({limit:100}),x.listSyncConfigs({limit:100})]);Q(q.integrations),U(Z.connections),V(_.configs)}catch(q){J(q instanceof Error?q:Error("Failed to load integrations"))}finally{H(!1)}},[G,x]);T(()=>{F()},[F]);let Y={totalIntegrations:z.length,activeIntegrations:z.filter((q)=>q.status==="ACTIVE").length,totalConnections:A.length,connectedCount:A.filter((q)=>q.status==="CONNECTED").length,totalSyncs:B.length,activeSyncs:B.filter((q)=>q.status==="ACTIVE").length};return{integrations:z,connections:A,syncConfigs:B,loading:W,error:X,stats:Y,refetch:F}}export{b as useIntegrationData};
@@ -1 +1 @@
1
- import{useTemplateRuntime as X}from"@contractspec/lib.example-shared-ui";import{useCallback as Y,useEffect as Z,useState as v}from"react";function k(G="local-project"){let{handlers:K}=X(),w=K.integration,[z,M]=v([]),[A,N]=v([]),[B,O]=v([]),[P,H]=v(!0),[Q,J]=v(null),F=Y(async()=>{try{H(!0),J(null);let[q,V,W]=await Promise.all([w.listIntegrations({projectId:G,limit:100}),w.listConnections({limit:100}),w.listSyncConfigs({limit:100})]);M(q.integrations),N(V.connections),O(W.configs)}catch(q){J(q instanceof Error?q:Error("Failed to load integrations"))}finally{H(!1)}},[w,G]);Z(()=>{F()},[F]);let U={totalIntegrations:z.length,activeIntegrations:z.filter((q)=>q.status==="ACTIVE").length,totalConnections:A.length,connectedCount:A.filter((q)=>q.status==="CONNECTED").length,totalSyncs:B.length,activeSyncs:B.filter((q)=>q.status==="ACTIVE").length};return{integrations:z,connections:A,syncConfigs:B,loading:P,error:Q,stats:U,refetch:F}}export{k as useIntegrationData};
1
+ import{useTemplateRuntime as k}from"@contractspec/lib.example-shared-ui";import{useCallback as x,useEffect as T,useState as w}from"react";function O(M){let{handlers:N,projectId:Q}=k(),z=N.integration,H=M??Q,[A,U]=w([]),[B,V]=w([]),[F,W]=w([]),[X,J]=w(!0),[Y,K]=w(null),G=x(async()=>{try{J(!0),K(null);let[q,_,$]=await Promise.all([z.listIntegrations({projectId:H,limit:100}),z.listConnections({limit:100}),z.listSyncConfigs({limit:100})]);U(q.integrations),V(_.connections),W($.configs)}catch(q){K(q instanceof Error?q:Error("Failed to load integrations"))}finally{J(!1)}},[H,z]);T(()=>{G()},[G]);let Z={totalIntegrations:A.length,activeIntegrations:A.filter((q)=>q.status==="ACTIVE").length,totalConnections:B.length,connectedCount:B.filter((q)=>q.status==="CONNECTED").length,totalSyncs:F.length,activeSyncs:F.filter((q)=>q.status==="ACTIVE").length};return{integrations:A,connections:B,syncConfigs:F,loading:X,error:Y,stats:Z,refetch:G}}export{O as useIntegrationData};
@@ -1,4 +1,4 @@
1
- import{useTemplateRuntime as Zq}from"@contractspec/lib.example-shared-ui";import{useCallback as $q,useEffect as Wq,useState as N}from"react";function d(K="local-project"){let{handlers:W}=Zq(),q=W.integration,[Q,$]=N([]),[J,H]=N([]),[w,D]=N([]),[Y,X]=N(!0),[Z,U]=N(null),F=$q(async()=>{try{X(!0),U(null);let[M,Qq,Xq]=await Promise.all([q.listIntegrations({projectId:K,limit:100}),q.listConnections({limit:100}),q.listSyncConfigs({limit:100})]);$(M.integrations),H(Qq.connections),D(Xq.configs)}catch(M){U(M instanceof Error?M:Error("Failed to load integrations"))}finally{X(!1)}},[q,K]);Wq(()=>{F()},[F]);let O={totalIntegrations:Q.length,activeIntegrations:Q.filter((M)=>M.status==="ACTIVE").length,totalConnections:J.length,connectedCount:J.filter((M)=>M.status==="CONNECTED").length,totalSyncs:w.length,activeSyncs:w.filter((M)=>M.status==="ACTIVE").length};return{integrations:Q,connections:J,syncConfigs:w,loading:Y,error:Z,stats:O,refetch:F}}import{defineVisualization as z,VisualizationRegistry as Jq}from"@contractspec/lib.contracts-spec/visualizations";var Hq={key:"integration.list",version:"1.0.0"},wq={key:"integration.connection.list",version:"1.0.0"},l={key:"integration.syncConfig.list",version:"1.0.0"},V={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},b=z({meta:{...V,key:"integration-hub.visualization.integration-types",title:"Integration Types",description:"Distribution of configured integration categories.",goal:"Show where integration coverage is concentrated.",context:"Integration overview."},source:{primary:Hq,resultPath:"data"},visualization:{kind:"pie",nameDimension:"type",valueMeasure:"count",dimensions:[{key:"type",label:"Type",dataPath:"type",type:"category"}],measures:[{key:"count",label:"Count",dataPath:"count",format:"number"}],table:{caption:"Integration counts by type."}}}),T=z({meta:{...V,key:"integration-hub.visualization.connection-status",title:"Connection Status",description:"Status distribution across configured connections.",goal:"Highlight connection health and instability.",context:"Connection monitoring."},source:{primary:wq,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"status",yMeasures:["count"],dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"count",label:"Connections",dataPath:"count",format:"number",color:"#1d4ed8"}],table:{caption:"Connection counts by status."}}}),C=z({meta:{...V,key:"integration-hub.visualization.sync-healthy",title:"Healthy Syncs",description:"Sync configurations currently healthy or recently successful.",goal:"Summarize healthy synchronization capacity.",context:"Sync-state comparison."},source:{primary:l,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),S=z({meta:{...V,key:"integration-hub.visualization.sync-attention",title:"Attention Needed",description:"Sync configurations paused, failing, or otherwise needing review.",goal:"Summarize syncs needing action.",context:"Sync-state comparison."},source:{primary:l,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),a=[b,T,C,S],jq=new Jq([...a]),xq=a.map((K)=>({key:K.meta.key,version:K.meta.version}));function Yq(K){return K==="ACTIVE"||K==="SUCCESS"}function f(K,W,q){let Q=new Map,$=new Map,J=0,H=0;for(let Y of K)Q.set(Y.type,(Q.get(Y.type)??0)+1);for(let Y of W)$.set(Y.status,($.get(Y.status)??0)+1);for(let Y of q)if(Yq(Y.status))J+=1;else H+=1;return{primaryItems:[{key:"integration-types",spec:b,data:{data:Array.from(Q.entries()).map(([Y,X])=>({type:Y,count:X}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:T,data:{data:Array.from($.entries()).map(([Y,X])=>({status:Y,count:X}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:C,data:{data:[{value:J}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:S,data:{data:[{value:H}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}import{ComparisonView as Pq,VisualizationCard as Uq,VisualizationGrid as Gq}from"@contractspec/lib.design-system";import{jsx as k,jsxs as c}from"react/jsx-runtime";function o({integrations:K,connections:W,syncConfigs:q}){let{primaryItems:Q,comparisonItems:$}=f(K,W,q);return c("section",{className:"space-y-4",children:[c("div",{children:[k("h3",{className:"font-semibold text-lg",children:"Integration Visualizations"}),k("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts for integration coverage and sync health."})]}),k(Gq,{children:Q.map((J)=>k(Uq,{data:J.data,description:J.description,height:J.height,spec:J.spec,title:J.title},J.key))}),k(Pq,{description:"Comparison surface for healthy versus attention-needed syncs.",items:$,title:"Sync-State Comparison"})]})}import{ChatWithSidebar as Mq}from"@contractspec/module.ai-chat";import{jsx as i}from"react/jsx-runtime";var Bq=["List my integrations","Show sync status","Add a connection"],Dq="You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.";function y({proxyUrl:K="/api/chat",mcpServers:W,thinkingLevel:q="thinking",suggestions:Q=Bq,systemPrompt:$=Dq,className:J}){return i("div",{className:J??"flex h-[500px] flex-col",children:i(Mq,{className:"flex-1",systemPrompt:$,proxyUrl:K,mcpServers:W,thinkingLevel:q,suggestions:Q,showSuggestionsWhenEmpty:!0})})}import{Button as v}from"@contractspec/lib.design-system";import{Badge as e}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as Fq}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as A,jsxs as Rq}from"react/jsx-runtime";var Oq={ACTIVE:"default",CONNECTED:"default",SUCCESS:"default",PENDING:"secondary",PAUSED:"secondary",ERROR:"destructive",DISCONNECTED:"outline"};function L(K){return K?K.toLocaleString():"Never"}function m(K){return K?JSON.stringify(K,null,2):"No configuration"}function I({status:K}){return A(e,{variant:Oq[K]??"outline",children:K})}function p({controller:K,label:W,toggleColumnId:q,toggleVisibleLabel:Q,toggleHiddenLabel:$,pinColumnId:J,pinLabel:H,resizeColumnId:w,resizeLabel:D}){let Y=K.rows[0],X=K.columns.find((O)=>O.id===q),Z=K.columns.find((O)=>O.id===J),U=K.columns.find((O)=>O.id===w),F=Z?.pinState==="left"?!1:"left";return Rq(Fq,{gap:"sm",className:"flex-wrap",children:[A(e,{variant:"outline",children:W}),A(v,{variant:"outline",size:"sm",onPress:()=>Y?.toggleExpanded?.(!Y?.isExpanded),children:"Expand First Row"}),A(v,{variant:"outline",size:"sm",onPress:()=>X?.toggleVisibility?.(!X?.visible),children:X?.visible?Q:$}),A(v,{variant:"outline",size:"sm",onPress:()=>Z?.pin?.(F),children:Z?.pinState==="left"?`Unpin ${H}`:`Pin ${H}`}),A(v,{variant:"outline",size:"sm",onPress:()=>U?.resizeBy?.(40),children:D})]})}import{DataTable as Aq}from"@contractspec/lib.design-system";import{useContractTable as _q}from"@contractspec/lib.presentation-runtime-react";import{VStack as s}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as h}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as B,jsxs as j}from"react/jsx-runtime";function x({connections:K}){let W=_q({data:K,columns:[{id:"connection",header:"Connection",label:"Connection",accessor:(q)=>q.name,cell:({item:q})=>j(s,{gap:"xs",children:[B(h,{className:"font-medium text-sm",children:q.name}),j(h,{className:"text-muted-foreground text-xs",children:["Created ",q.createdAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>B(I,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"lastSyncAt",header:"Last Sync",label:"Last Sync",accessor:(q)=>q.lastSyncAt?.getTime()??0,cell:({item:q})=>L(q.lastSyncAt),size:200,canSort:!0,canHide:!0,canResize:!0},{id:"errorMessage",header:"Errors",label:"Errors",accessor:(q)=>q.errorMessage??"",cell:({value:q})=>String(q||"No errors"),size:240,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{errorMessage:!1},columnPinning:{left:["connection"],right:[]}},renderExpandedContent:(q)=>j(s,{gap:"sm",className:"py-2",children:[B(h,{className:"font-medium text-sm",children:"Credentials"}),B("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:m(q.credentials)}),B(h,{className:"font-medium text-sm",children:"Config"}),B("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:m(q.config)}),B(h,{className:"text-muted-foreground text-sm",children:q.errorMessage??"No sync errors recorded."})]}),getCanExpand:()=>!0});return B(Aq,{controller:W,title:"Connections",description:"Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",toolbar:B(p,{controller:W,label:`${K.length} total connections`,toggleColumnId:"errorMessage",toggleVisibleLabel:"Hide Error Column",toggleHiddenLabel:"Show Error Column",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"connection",resizeLabel:"Widen Connection"}),emptyState:B("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No connections found"})})}import{DataTable as Nq}from"@contractspec/lib.design-system";import{useContractTable as kq}from"@contractspec/lib.presentation-runtime-react";import{VStack as t}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as _}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as E,jsxs as R}from"react/jsx-runtime";function g({syncConfigs:K}){let W=kq({data:K,columns:[{id:"sync",header:"Sync Config",label:"Sync Config",accessor:(q)=>q.name,cell:({item:q})=>R(t,{gap:"xs",children:[E(_,{className:"font-medium text-sm",children:q.name}),R(_,{className:"text-muted-foreground text-xs",children:[q.sourceEntity," → ",q.targetEntity]})]}),size:260,minSize:200,canSort:!0,canPin:!0,canResize:!0},{id:"frequency",header:"Frequency",label:"Frequency",accessorKey:"frequency",size:160,canSort:!0,canHide:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>E(I,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"recordsSynced",header:"Records",label:"Records",accessorKey:"recordsSynced",align:"right",size:140,canSort:!0,canResize:!0},{id:"lastRunAt",header:"Last Run",label:"Last Run",accessor:(q)=>q.lastRunAt?.getTime()??0,cell:({item:q})=>L(q.lastRunAt),size:200,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{lastRunAt:!1},columnPinning:{left:["sync"],right:[]}},renderExpandedContent:(q)=>R(t,{gap:"sm",className:"py-2",children:[R(_,{className:"text-muted-foreground text-sm",children:["Connection ",q.connectionId]}),R(_,{className:"text-muted-foreground text-sm",children:["Last run: ",L(q.lastRunAt)]}),R(_,{className:"text-muted-foreground text-sm",children:["Last status: ",q.lastRunStatus??"No runs recorded"]}),R(_,{className:"text-muted-foreground text-sm",children:["Updated ",q.updatedAt.toLocaleString()]})]}),getCanExpand:()=>!0});return E(Nq,{controller:W,title:"Sync Configs",description:"Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",toolbar:E(p,{controller:W,label:`${K.length} syncs`,toggleColumnId:"lastRunAt",toggleVisibleLabel:"Hide Last Run",toggleHiddenLabel:"Show Last Run",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"sync",resizeLabel:"Widen Sync"}),emptyState:E("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No sync configurations found"})})}import{Button as n,ErrorState as Lq,LoaderBlock as hq,StatCard as u,StatCardGroup as Eq}from"@contractspec/lib.design-system";import{useState as zq}from"react";import{jsx as P,jsxs as G}from"react/jsx-runtime";var Vq={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",INACTIVE:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",CONNECTED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DISCONNECTED:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",PENDING:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ERROR:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},fq={CRM:"\uD83D\uDCCA",MARKETING:"\uD83D\uDCE3",PAYMENT:"\uD83D\uDCB3",COMMUNICATION:"\uD83D\uDCAC",DATA:"\uD83D\uDDC4️",CUSTOM:"⚙️"};function vq(){let[K,W]=zq("integrations"),{integrations:q,connections:Q,syncConfigs:$,loading:J,error:H,stats:w,refetch:D}=d(),Y=[{id:"integrations",label:"Integrations",icon:"\uD83D\uDD0C"},{id:"connections",label:"Connections",icon:"\uD83D\uDD17"},{id:"syncs",label:"Sync Configs",icon:"\uD83D\uDD04"},{id:"chat",label:"Chat",icon:"\uD83D\uDCAC"}];if(J)return P(hq,{label:"Loading Integrations..."});if(H)return P(Lq,{title:"Failed to load Integrations",description:H.message,onRetry:D,retryLabel:"Retry"});return G("div",{className:"space-y-6",children:[G("div",{className:"flex items-center justify-between",children:[P("h2",{className:"font-bold text-2xl",children:"Integration Hub"}),G(n,{onClick:()=>alert("Add integration modal"),children:[P("span",{className:"mr-2",children:"+"})," Add Integration"]})]}),G(Eq,{children:[P(u,{label:"Integrations",value:w.totalIntegrations,hint:`${w.activeIntegrations} active`}),P(u,{label:"Connections",value:w.totalConnections,hint:`${w.connectedCount} connected`}),P(u,{label:"Syncs",value:w.totalSyncs,hint:`${w.activeSyncs} active`})]}),P(o,{connections:Q,integrations:q,syncConfigs:$}),P("nav",{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:Y.map((X)=>G(n,{type:"button",role:"tab","aria-selected":K===X.id,onClick:()=>W(X.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${K===X.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[P("span",{children:X.icon}),X.label]},X.id))}),G("div",{className:"min-h-[400px]",role:"tabpanel",children:[K==="integrations"&&G("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[q.map((X)=>G("div",{className:"cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",children:[G("div",{className:"mb-3 flex items-center gap-3",children:[P("span",{className:"text-2xl",children:fq[X.type]??"⚙️"}),G("div",{children:[P("h3",{className:"font-medium",children:X.name}),P("p",{className:"text-muted-foreground text-sm",children:X.type})]})]}),G("div",{className:"flex items-center justify-between",children:[P("span",{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${Vq[X.status]??""}`,children:X.status}),P("span",{className:"text-muted-foreground text-xs",children:X.createdAt.toLocaleDateString()})]})]},X.id)),q.length===0&&P("div",{className:"col-span-full flex h-64 items-center justify-center text-muted-foreground",children:"No integrations configured"})]}),K==="connections"&&P(x,{connections:Q}),K==="chat"&&P(y,{proxyUrl:"/api/chat",thinkingLevel:"thinking",suggestions:["List my integrations","Show sync status","Add a connection"],className:"min-h-[400px]"}),K==="syncs"&&P(g,{syncConfigs:$})]})]})}var qq=[{id:"int-1",name:"Salesforce",type:"CRM",status:"ACTIVE",connectionCount:3},{id:"int-2",name:"HubSpot",type:"MARKETING",status:"ACTIVE",connectionCount:2},{id:"int-3",name:"Stripe",type:"PAYMENT",status:"ACTIVE",connectionCount:1},{id:"int-4",name:"Slack",type:"COMMUNICATION",status:"INACTIVE",connectionCount:0},{id:"int-5",name:"Google Sheets",type:"DATA",status:"ACTIVE",connectionCount:5},{id:"int-6",name:"PostHog",type:"ANALYTICS",status:"ACTIVE",connectionCount:1}],r=[{id:"conn-1",integrationId:"int-1",name:"Production Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-16T10:00:00Z"},{id:"conn-2",integrationId:"int-1",name:"Sandbox Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-15T14:00:00Z"},{id:"conn-3",integrationId:"int-2",name:"Marketing HubSpot",status:"CONNECTED",lastSyncAt:"2024-01-16T08:00:00Z"},{id:"conn-4",integrationId:"int-3",name:"Stripe Live",status:"CONNECTED",lastSyncAt:"2024-01-16T12:00:00Z"},{id:"conn-5",integrationId:"int-5",name:"Analytics Sheet",status:"ERROR",lastSyncAt:"2024-01-14T09:00:00Z",error:"Authentication expired"},{id:"conn-6",integrationId:"int-6",name:"PostHog Workspace",status:"CONNECTED",lastSyncAt:"2024-01-16T11:45:00Z"}],Kq=[{id:"sync-1",connectionId:"conn-1",name:"Contacts Sync",frequency:"HOURLY",lastRunAt:"2024-01-16T10:00:00Z",status:"SUCCESS",recordsSynced:1250},{id:"sync-2",connectionId:"conn-1",name:"Opportunities Sync",frequency:"DAILY",lastRunAt:"2024-01-16T00:00:00Z",status:"SUCCESS",recordsSynced:340},{id:"sync-3",connectionId:"conn-3",name:"Orders Sync",frequency:"REALTIME",lastRunAt:"2024-01-16T12:30:00Z",status:"SUCCESS",recordsSynced:89},{id:"sync-4",connectionId:"conn-5",name:"Metrics Export",frequency:"DAILY",lastRunAt:"2024-01-14T09:00:00Z",status:"FAILED",recordsSynced:0}],Iq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="IntegrationDashboard")throw Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");let W=qq,q=r,Q=Kq,$=f(W,q,Q),J=W.filter((Z)=>Z.status==="ACTIVE"),H=q.filter((Z)=>Z.status==="CONNECTED"),w=q.filter((Z)=>Z.status==="ERROR"),Y=Q.filter((Z)=>Z.status==="SUCCESS").reduce((Z,U)=>Z+U.recordsSynced,0),X=["# Integration Hub","","> Connect and sync data with external services","","## Overview","","| Metric | Value |","|--------|-------|",`| Active Integrations | ${J.length} |`,`| Connected Services | ${H.length} |`,`| Error Connections | ${w.length} |`,`| Sync Configs | ${Q.length} |`,`| Records Synced (24h) | ${Y.toLocaleString()} |`,""];X.push("## Visualization Overview"),X.push("");for(let Z of[...$.primaryItems,...$.comparisonItems])X.push(`- **${Z.title}** via \`${Z.spec.meta.key}\``);X.push(""),X.push("## Integrations"),X.push(""),X.push("| Name | Type | Connections | Status |"),X.push("|------|------|-------------|--------|");for(let Z of W){let U=Z.status==="ACTIVE"?"\uD83D\uDFE2":"⚫";X.push(`| ${Z.name} | ${Z.type} | ${Z.connectionCount} | ${U} ${Z.status} |`)}X.push(""),X.push("## Recent Sync Activity"),X.push(""),X.push("| Sync | Frequency | Last Run | Records | Status |"),X.push("|------|-----------|----------|---------|--------|");for(let Z of Q){let U=new Date(Z.lastRunAt).toLocaleString(),F=Z.status==="SUCCESS"?"✅":"❌";X.push(`| ${Z.name} | ${Z.frequency} | ${U} | ${Z.recordsSynced} | ${F} ${Z.status} |`)}if(w.length>0){X.push(""),X.push("## ⚠️ Connections with Errors"),X.push("");for(let Z of w){let U=W.find((F)=>F.id===Z.integrationId);X.push(`- **${Z.name}** (${U?.name??"Unknown"}): ${Z.error??"Unknown error"}`)}}return{mimeType:"text/markdown",body:X.join(`
2
- `)}}},pq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="ConnectionList")throw Error("connectionListMarkdownRenderer: not ConnectionList");let W=r,q=qq,Q=["# Connections","","> Manage connections to external services",""];for(let $ of q){let J=W.filter((H)=>H.integrationId===$.id);if(J.length===0)continue;Q.push(`## ${$.name}`),Q.push(""),Q.push("| Connection | Status | Last Sync |"),Q.push("|------------|--------|-----------|");for(let H of J){let w=new Date(H.lastSyncAt).toLocaleString(),D=H.status==="CONNECTED"?"\uD83D\uDFE2":H.status==="ERROR"?"\uD83D\uDD34":"⚫";Q.push(`| ${H.name} | ${D} ${H.status} | ${w} |`)}Q.push("")}return{mimeType:"text/markdown",body:Q.join(`
3
- `)}}},dq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="SyncConfigEditor")throw Error("syncConfigMarkdownRenderer: not SyncConfigEditor");let W=Kq,q=r,Q=["# Sync Configurations","","> Configure automated data synchronization",""];for(let $ of W){let J=q.find((w)=>w.id===$.connectionId),H=$.status==="SUCCESS"?"✅":"❌";Q.push(`## ${$.name}`),Q.push(""),Q.push(`**Connection:** ${J?.name??"Unknown"}`),Q.push(`**Frequency:** ${$.frequency}`),Q.push(`**Status:** ${H} ${$.status}`),Q.push(`**Last Run:** ${new Date($.lastRunAt).toLocaleString()}`),Q.push(`**Records Synced:** ${$.recordsSynced.toLocaleString()}`),Q.push("")}return Q.push("## Frequency Options"),Q.push(""),Q.push("- **REALTIME**: Sync on every change"),Q.push("- **HOURLY**: Sync every hour"),Q.push("- **DAILY**: Sync once per day"),Q.push("- **WEEKLY**: Sync once per week"),Q.push("- **MANUAL**: Sync only when triggered"),{mimeType:"text/markdown",body:Q.join(`
4
- `)}}};export{d as useIntegrationData,dq as syncConfigMarkdownRenderer,Iq as integrationDashboardMarkdownRenderer,pq as connectionListMarkdownRenderer,y as IntegrationHubChat,vq as IntegrationDashboard};
1
+ var _r={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},Or={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},d={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};import{useTemplateRuntime as Ir}from"@contractspec/lib.example-shared-ui";import{useCallback as br,useEffect as Fr,useState as b}from"react";function e(r){let{handlers:P,projectId:p}=Ir(),w=P.integration,O=r??p,[k,R]=b([]),[G,v]=b([]),[E,K]=b([]),[_,A]=b(!0),[U,X]=b(null),x=br(async()=>{try{A(!0),X(null);let[H,Zr,$r]=await Promise.all([w.listIntegrations({projectId:O,limit:100}),w.listConnections({limit:100}),w.listSyncConfigs({limit:100})]);R(H.integrations),v(Zr.connections),K($r.configs)}catch(H){X(H instanceof Error?H:Error("Failed to load integrations"))}finally{A(!1)}},[O,w]);Fr(()=>{x()},[x]);let Qr={totalIntegrations:k.length,activeIntegrations:k.filter((H)=>H.status==="ACTIVE").length,totalConnections:G.length,connectedCount:G.filter((H)=>H.status==="CONNECTED").length,totalSyncs:E.length,activeSyncs:E.filter((H)=>H.status==="ACTIVE").length};return{integrations:k,connections:G,syncConfigs:E,loading:_,error:U,stats:Qr,refetch:x}}import{defineVisualization as z,VisualizationRegistry as Dr}from"@contractspec/lib.contracts-spec/visualizations";var Mr={key:"integration.list",version:"1.0.0"},Lr={key:"integration.connection.list",version:"1.0.0"},Pr={key:"integration.syncConfig.list",version:"1.0.0"},f={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},j=z({meta:{...f,key:"integration-hub.visualization.integration-types",title:"Integration Types",description:"Distribution of configured integration categories.",goal:"Show where integration coverage is concentrated.",context:"Integration overview."},source:{primary:Mr,resultPath:"data"},visualization:{kind:"pie",nameDimension:"type",valueMeasure:"count",dimensions:[{key:"type",label:"Type",dataPath:"type",type:"category"}],measures:[{key:"count",label:"Count",dataPath:"count",format:"number"}],table:{caption:"Integration counts by type."}}}),o=z({meta:{...f,key:"integration-hub.visualization.connection-status",title:"Connection Status",description:"Status distribution across configured connections.",goal:"Highlight connection health and instability.",context:"Connection monitoring."},source:{primary:Lr,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"status",yMeasures:["count"],dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"count",label:"Connections",dataPath:"count",format:"number",color:"#1d4ed8"}],table:{caption:"Connection counts by status."}}}),c=z({meta:{...f,key:"integration-hub.visualization.sync-healthy",title:"Healthy Syncs",description:"Sync configurations currently healthy or recently successful.",goal:"Summarize healthy synchronization capacity.",context:"Sync-state comparison."},source:{primary:Pr,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),l=z({meta:{...f,key:"integration-hub.visualization.sync-attention",title:"Attention Needed",description:"Sync configurations paused, failing, or otherwise needing review.",goal:"Summarize syncs needing action.",context:"Sync-state comparison."},source:{primary:Pr,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),Kr=[j,o,c,l],vp=new Dr([...Kr]),Rp=Kr.map((r)=>({key:r.meta.key,version:r.meta.version}));function yr(r){return r==="ACTIVE"||r==="SUCCESS"}function T(r,P,p){let w=new Map,O=new Map,k=0,R=0;for(let E of r)w.set(E.type,(w.get(E.type)??0)+1);for(let E of P)O.set(E.status,(O.get(E.status)??0)+1);for(let E of p)if(yr(E.status))k+=1;else R+=1;return{primaryItems:[{key:"integration-types",spec:j,data:{data:Array.from(w.entries()).map(([E,K])=>({type:E,count:K}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:o,data:{data:Array.from(O.entries()).map(([E,K])=>({status:E,count:K}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:c,data:{data:[{value:k}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:l,data:{data:[{value:R}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}import{ComparisonView as Vr,VisualizationCard as dr,VisualizationGrid as zr}from"@contractspec/lib.design-system";import{jsx as F,jsxs as Er}from"react/jsx-runtime";function Ar({integrations:r,connections:P,syncConfigs:p}){let{primaryItems:w,comparisonItems:O}=T(r,P,p);return Er("section",{className:"space-y-4",children:[Er("div",{children:[F("h3",{className:"font-semibold text-lg",children:"Integration Visualizations"}),F("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts for integration coverage and sync health."})]}),F(zr,{children:w.map((k)=>F(dr,{data:k.data,description:k.description,height:k.height,spec:k.spec,title:k.title},k.key))}),F(Vr,{description:"Comparison surface for healthy versus attention-needed syncs.",items:O,title:"Sync-State Comparison"})]})}import{ChatWithSidebar as fr}from"@contractspec/module.ai-chat";import{jsx as vr}from"react/jsx-runtime";var Tr=["List my integrations","Show sync status","Add a connection"],Cr="You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.";function a({proxyUrl:r="/api/chat",mcpServers:P,thinkingLevel:p="thinking",suggestions:w=Tr,systemPrompt:O=Cr,className:k}){return vr("div",{className:k??"flex h-[500px] flex-col",children:vr(fr,{className:"flex-1",systemPrompt:O,proxyUrl:r,mcpServers:P,thinkingLevel:p,suggestions:w,showSuggestionsWhenEmpty:!0})})}function qr(r){let P=_r,p=Or,w=d,O=P.modes?.[r],k=[...(O?.configFields??[]).map((v)=>({...v,kind:"config",configured:Rr(w.configValues[v.key]),secretRef:void 0})),...(O?.secretFields??[]).map((v)=>({...v,kind:"secret",configured:Rr(w.secretRefs[v.key]),secretRef:w.secretRefs[v.key]}))],R=Object.values(p.variables??{}).flatMap((v)=>(v.aliases??[]).map((E)=>({...E,targetLabel:p.targets?.[E.targetId??""]?.packageName??E.targetId}))).filter((v)=>w.targetIds.includes(v.targetId??"")),G=k.filter((v)=>v.kind==="secret"&&v.required&&!v.configured);return{fields:k,aliases:R,missingSecrets:G}}function Rr(r){return r!==void 0&&r!==null&&r!==""}import{Box as Q,Button as Sr,HStack as Gr,Muted as i,Small as Z,Text as C,VStack as D}from"@contractspec/lib.design-system";import{jsx as N,jsxs as Y}from"react/jsx-runtime";function t({mode:r=d.selectedMode,onModeChange:P}){let{fields:p,aliases:w,missingSecrets:O}=qr(r);return N(Q,{className:"rounded-2xl border border-border bg-card p-4",children:Y(D,{gap:"lg",align:"stretch",children:[Y(D,{gap:"xs",align:"stretch",children:[N(Z,{className:"font-semibold uppercase tracking-wide",children:"BYOK and monorepo env setup"}),N(C,{className:"text-muted-foreground text-sm",children:"The Integration Hub sample now publishes credential manifests, server-only secret references, and Next/Expo public aliases for multi-app workspaces."})]}),N(Gr,{className:"flex-wrap gap-2",children:["managed","byok"].map((k)=>N(Sr,{type:"button",variant:r===k?"default":"outline",onClick:()=>P?.(k),children:k==="byok"?"BYOK":"Managed"},k))}),Y(D,{gap:"sm",align:"stretch",children:[N(Z,{children:"Required setup fields"}),N(Q,{className:"grid gap-2 md:grid-cols-2",children:p.map((k)=>N(Q,{className:"rounded-xl border border-border bg-background p-3",children:Y(Gr,{className:"items-start justify-between gap-3",children:[Y(D,{gap:"xs",align:"stretch",children:[N(C,{className:"font-medium text-sm",children:Nr(k.key)}),N(i,{className:"text-xs",children:k.description}),k.secretRef?N(Z,{className:"font-mono",children:k.secretRef}):null]}),N(Z,{className:"rounded-full bg-muted px-2 py-0.5",children:k.configured?"configured":"missing"})]})},`${k.kind}:${k.key}`))})]}),Y(D,{gap:"sm",align:"stretch",children:[N(Z,{children:"App aliases"}),N(Q,{className:"grid gap-2 md:grid-cols-2",children:w.map((k)=>Y(Q,{className:"rounded-xl border border-border bg-background p-3",children:[N(C,{className:"font-mono text-sm",children:k.name}),Y(i,{className:"text-xs",children:[k.targetLabel," · ",k.framework," ·"," ",k.exposure??"server"]}),mr(k.name)?N(Z,{className:"text-amber-600",children:"Public client alias"}):null]},`${k.targetId}:${k.name}`))})]}),O.length?Y(Q,{className:"rounded-xl border border-amber-300 bg-amber-50 p-3 text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100",children:[Y(C,{className:"font-medium text-sm",children:["Missing BYOK secret refs:"," ",O.map((k)=>Nr(k.key)).join(", "),"."]}),N(i,{className:"text-xs",children:"Secret fields stay server-only and are not materialized as NEXT_PUBLIC_* or EXPO_PUBLIC_* aliases."})]}):null]})})}function mr(r){return r.startsWith("NEXT_PUBLIC_")||r.startsWith("EXPO_PUBLIC_")}function Nr(r){return r.replace(/[_-]+/g," ").replace(/\b\w/g,(P)=>P.toUpperCase())}import{Button as S}from"@contractspec/lib.design-system";import{Badge as Wr}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as ur}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as $,jsxs as xr}from"react/jsx-runtime";var gr={ACTIVE:"default",CONNECTED:"default",SUCCESS:"default",PENDING:"secondary",PAUSED:"secondary",ERROR:"destructive",DISCONNECTED:"outline"};function M(r){return r?r.toLocaleString():"Never"}function n(r){return r?JSON.stringify(r,null,2):"No configuration"}function m({status:r}){return $(Wr,{variant:gr[r]??"outline",children:r})}function u({controller:r,label:P,toggleColumnId:p,toggleVisibleLabel:w,toggleHiddenLabel:O,pinColumnId:k,pinLabel:R,resizeColumnId:G,resizeLabel:v}){let E=r.rows[0],K=r.columns.find((X)=>X.id===p),_=r.columns.find((X)=>X.id===k),A=r.columns.find((X)=>X.id===G),U=_?.pinState==="left"?!1:"left";return xr(ur,{gap:"sm",className:"flex-wrap",children:[$(Wr,{variant:"outline",children:P}),$(S,{variant:"outline",size:"sm",onPress:()=>E?.toggleExpanded?.(!E?.isExpanded),children:"Expand First Row"}),$(S,{variant:"outline",size:"sm",onPress:()=>K?.toggleVisibility?.(!K?.visible),children:K?.visible?w:O}),$(S,{variant:"outline",size:"sm",onPress:()=>_?.pin?.(U),children:_?.pinState==="left"?`Unpin ${R}`:`Pin ${R}`}),$(S,{variant:"outline",size:"sm",onPress:()=>A?.resizeBy?.(40),children:v})]})}import{DataTable as er}from"@contractspec/lib.design-system";import{useContractTable as jr}from"@contractspec/lib.presentation-runtime-react";import{VStack as Br}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as L}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as h,jsxs as s}from"react/jsx-runtime";function rr({connections:r}){let P=jr({data:r,columns:[{id:"connection",header:"Connection",label:"Connection",accessor:(p)=>p.name,cell:({item:p})=>s(Br,{gap:"xs",children:[h(L,{className:"font-medium text-sm",children:p.name}),s(L,{className:"text-muted-foreground text-xs",children:["Created ",p.createdAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:p})=>h(m,{status:String(p)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"lastSyncAt",header:"Last Sync",label:"Last Sync",accessor:(p)=>p.lastSyncAt?.getTime()??0,cell:({item:p})=>M(p.lastSyncAt),size:200,canSort:!0,canHide:!0,canResize:!0},{id:"errorMessage",header:"Errors",label:"Errors",accessor:(p)=>p.errorMessage??"",cell:({value:p})=>String(p||"No errors"),size:240,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{errorMessage:!1},columnPinning:{left:["connection"],right:[]}},renderExpandedContent:(p)=>s(Br,{gap:"sm",className:"py-2",children:[h(L,{className:"font-medium text-sm",children:"Credentials"}),h("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:n(p.credentials)}),h(L,{className:"font-medium text-sm",children:"Config"}),h("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:n(p.config)}),h(L,{className:"text-muted-foreground text-sm",children:p.errorMessage??"No sync errors recorded."})]}),getCanExpand:()=>!0});return h(er,{controller:P,title:"Connections",description:"Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",toolbar:h(u,{controller:P,label:`${r.length} total connections`,toggleColumnId:"errorMessage",toggleVisibleLabel:"Hide Error Column",toggleHiddenLabel:"Show Error Column",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"connection",resizeLabel:"Widen Connection"}),emptyState:h("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No connections found"})})}import{DataTable as or}from"@contractspec/lib.design-system";import{useContractTable as cr}from"@contractspec/lib.presentation-runtime-react";import{VStack as Hr}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as I}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as y,jsxs as J}from"react/jsx-runtime";function pr({syncConfigs:r}){let P=cr({data:r,columns:[{id:"sync",header:"Sync Config",label:"Sync Config",accessor:(p)=>p.name,cell:({item:p})=>J(Hr,{gap:"xs",children:[y(I,{className:"font-medium text-sm",children:p.name}),J(I,{className:"text-muted-foreground text-xs",children:[p.sourceEntity," → ",p.targetEntity]})]}),size:260,minSize:200,canSort:!0,canPin:!0,canResize:!0},{id:"frequency",header:"Frequency",label:"Frequency",accessorKey:"frequency",size:160,canSort:!0,canHide:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:p})=>y(m,{status:String(p)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"recordsSynced",header:"Records",label:"Records",accessorKey:"recordsSynced",align:"right",size:140,canSort:!0,canResize:!0},{id:"lastRunAt",header:"Last Run",label:"Last Run",accessor:(p)=>p.lastRunAt?.getTime()??0,cell:({item:p})=>M(p.lastRunAt),size:200,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{lastRunAt:!1},columnPinning:{left:["sync"],right:[]}},renderExpandedContent:(p)=>J(Hr,{gap:"sm",className:"py-2",children:[J(I,{className:"text-muted-foreground text-sm",children:["Connection ",p.connectionId]}),J(I,{className:"text-muted-foreground text-sm",children:["Last run: ",M(p.lastRunAt)]}),J(I,{className:"text-muted-foreground text-sm",children:["Last status: ",p.lastRunStatus??"No runs recorded"]}),J(I,{className:"text-muted-foreground text-sm",children:["Updated ",p.updatedAt.toLocaleString()]})]}),getCanExpand:()=>!0});return y(or,{controller:P,title:"Sync Configs",description:"Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",toolbar:y(u,{controller:P,label:`${r.length} syncs`,toggleColumnId:"lastRunAt",toggleVisibleLabel:"Hide Last Run",toggleHiddenLabel:"Show Last Run",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"sync",resizeLabel:"Widen Sync"}),emptyState:y("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No sync configurations found"})})}import{Box as V,Button as Yr,ErrorState as lr,HStack as g,LoaderBlock as ar,StatCard as wr,StatCardGroup as ir,Text as W,VStack as hr}from"@contractspec/lib.design-system";import{useState as Xr}from"react";import{jsx as q,jsxs as B}from"react/jsx-runtime";var tr={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",INACTIVE:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",CONNECTED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DISCONNECTED:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",PENDING:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ERROR:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},nr={CRM:"\uD83D\uDCCA",MARKETING:"\uD83D\uDCE3",PAYMENT:"\uD83D\uDCB3",COMMUNICATION:"\uD83D\uDCAC",DATA:"\uD83D\uDDC4️",CUSTOM:"⚙️"};function sr(){let[r,P]=Xr("integrations"),[p,w]=Xr("byok"),{integrations:O,connections:k,syncConfigs:R,loading:G,error:v,stats:E,refetch:K}=e(),_=[{id:"integrations",label:"Integrations",icon:"\uD83D\uDD0C"},{id:"credentials",label:"BYOK/env",icon:"\uD83D\uDD10"},{id:"connections",label:"Connections",icon:"\uD83D\uDD17"},{id:"syncs",label:"Sync Configs",icon:"\uD83D\uDD04"},{id:"chat",label:"Chat",icon:"\uD83D\uDCAC"}];if(G)return q(ar,{label:"Loading Integrations..."});if(v)return q(lr,{title:"Failed to load Integrations",description:v.message,onRetry:K,retryLabel:"Retry"});return B(hr,{gap:"lg",align:"stretch",children:[B(g,{className:"items-center justify-between",children:[q(W,{className:"font-bold text-2xl",children:"Integration Hub"}),q(Yr,{onClick:()=>alert("Add integration modal"),children:B(g,{className:"items-center gap-2",children:[q(W,{"aria-hidden":"true",children:"+"}),q(W,{children:"Add Integration"})]})})]}),B(ir,{children:[q(wr,{label:"Integrations",value:E.totalIntegrations,hint:`${E.activeIntegrations} active`}),q(wr,{label:"Connections",value:E.totalConnections,hint:`${E.connectedCount} connected`}),q(wr,{label:"Syncs",value:E.totalSyncs,hint:`${E.activeSyncs} active`})]}),q(Ar,{connections:k,integrations:O,syncConfigs:R}),q(V,{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:_.map((A)=>B(Yr,{type:"button",role:"tab","aria-selected":r===A.id,onClick:()=>P(A.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${r===A.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[q(W,{"aria-hidden":"true",children:A.icon}),q(W,{children:A.label})]},A.id))}),B(V,{className:"min-h-[400px]",role:"tabpanel",children:[r==="integrations"&&B(V,{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[O.map((A)=>B(V,{className:"cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",children:[B(g,{className:"mb-3 items-center gap-3",children:[q(W,{className:"text-2xl",children:nr[A.type]??"⚙️"}),B(hr,{gap:"xs",align:"stretch",children:[q(W,{className:"font-medium",children:A.name}),q(W,{className:"text-muted-foreground text-sm",children:A.type})]})]}),B(g,{className:"items-center justify-between",children:[q(W,{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${tr[A.status]??""}`,children:A.status}),q(W,{className:"text-muted-foreground text-xs",children:A.createdAt.toLocaleDateString()})]})]},A.id)),O.length===0&&q(V,{className:"col-span-full flex h-64 items-center justify-center",children:q(W,{className:"text-muted-foreground",children:"No integrations configured"})})]}),r==="credentials"&&q(t,{mode:p,onModeChange:w}),r==="connections"&&q(rr,{connections:k}),r==="chat"&&q(a,{proxyUrl:"/api/chat",thinkingLevel:"thinking",suggestions:["List my integrations","Show sync status","Add a connection"],className:"min-h-[400px]"}),r==="syncs"&&q(pr,{syncConfigs:R})]})]})}var Ur=[{id:"int-1",name:"Salesforce",type:"CRM",status:"ACTIVE",connectionCount:3},{id:"int-2",name:"HubSpot",type:"MARKETING",status:"ACTIVE",connectionCount:2},{id:"int-3",name:"Stripe",type:"PAYMENT",status:"ACTIVE",connectionCount:1},{id:"int-4",name:"Slack",type:"COMMUNICATION",status:"INACTIVE",connectionCount:0},{id:"int-5",name:"Google Sheets",type:"DATA",status:"ACTIVE",connectionCount:5},{id:"int-6",name:"PostHog",type:"ANALYTICS",status:"ACTIVE",connectionCount:1}],kr=[{id:"conn-1",integrationId:"int-1",name:"Production Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-16T10:00:00Z"},{id:"conn-2",integrationId:"int-1",name:"Sandbox Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-15T14:00:00Z"},{id:"conn-3",integrationId:"int-2",name:"Marketing HubSpot",status:"CONNECTED",lastSyncAt:"2024-01-16T08:00:00Z"},{id:"conn-4",integrationId:"int-3",name:"Stripe Live",status:"CONNECTED",lastSyncAt:"2024-01-16T12:00:00Z"},{id:"conn-5",integrationId:"int-5",name:"Analytics Sheet",status:"ERROR",lastSyncAt:"2024-01-14T09:00:00Z",error:"Authentication expired"},{id:"conn-6",integrationId:"int-6",name:"PostHog Workspace",status:"CONNECTED",lastSyncAt:"2024-01-16T11:45:00Z"}],Jr=[{id:"sync-1",connectionId:"conn-1",name:"Contacts Sync",frequency:"HOURLY",lastRunAt:"2024-01-16T10:00:00Z",status:"SUCCESS",recordsSynced:1250},{id:"sync-2",connectionId:"conn-1",name:"Opportunities Sync",frequency:"DAILY",lastRunAt:"2024-01-16T00:00:00Z",status:"SUCCESS",recordsSynced:340},{id:"sync-3",connectionId:"conn-3",name:"Orders Sync",frequency:"REALTIME",lastRunAt:"2024-01-16T12:30:00Z",status:"SUCCESS",recordsSynced:89},{id:"sync-4",connectionId:"conn-5",name:"Metrics Export",frequency:"DAILY",lastRunAt:"2024-01-14T09:00:00Z",status:"FAILED",recordsSynced:0}],rp={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="IntegrationDashboard")throw Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");let P=Ur,p=kr,w=Jr,O=T(P,p,w),k=P.filter((_)=>_.status==="ACTIVE"),R=p.filter((_)=>_.status==="CONNECTED"),G=p.filter((_)=>_.status==="ERROR"),E=w.filter((_)=>_.status==="SUCCESS").reduce((_,A)=>_+A.recordsSynced,0),K=["# Integration Hub","","> Connect and sync data with external services","","## Overview","","| Metric | Value |","|--------|-------|",`| Active Integrations | ${k.length} |`,`| Connected Services | ${R.length} |`,`| Error Connections | ${G.length} |`,`| Sync Configs | ${w.length} |`,`| Records Synced (24h) | ${E.toLocaleString()} |`,""];K.push("## Visualization Overview"),K.push("");for(let _ of[...O.primaryItems,...O.comparisonItems])K.push(`- **${_.title}** via \`${_.spec.meta.key}\``);K.push(""),K.push("## Integrations"),K.push(""),K.push("| Name | Type | Connections | Status |"),K.push("|------|------|-------------|--------|");for(let _ of P){let A=_.status==="ACTIVE"?"\uD83D\uDFE2":"⚫";K.push(`| ${_.name} | ${_.type} | ${_.connectionCount} | ${A} ${_.status} |`)}K.push(""),K.push("## Recent Sync Activity"),K.push(""),K.push("| Sync | Frequency | Last Run | Records | Status |"),K.push("|------|-----------|----------|---------|--------|");for(let _ of w){let A=new Date(_.lastRunAt).toLocaleString(),U=_.status==="SUCCESS"?"✅":"❌";K.push(`| ${_.name} | ${_.frequency} | ${A} | ${_.recordsSynced} | ${U} ${_.status} |`)}if(G.length>0){K.push(""),K.push("## ⚠️ Connections with Errors"),K.push("");for(let _ of G){let A=P.find((U)=>U.id===_.integrationId);K.push(`- **${_.name}** (${A?.name??"Unknown"}): ${_.error??"Unknown error"}`)}}return{mimeType:"text/markdown",body:K.join(`
2
+ `)}}},pp={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="ConnectionList")throw Error("connectionListMarkdownRenderer: not ConnectionList");let P=kr,p=Ur,w=["# Connections","","> Manage connections to external services",""];for(let O of p){let k=P.filter((R)=>R.integrationId===O.id);if(k.length===0)continue;w.push(`## ${O.name}`),w.push(""),w.push("| Connection | Status | Last Sync |"),w.push("|------------|--------|-----------|");for(let R of k){let G=new Date(R.lastSyncAt).toLocaleString(),v=R.status==="CONNECTED"?"\uD83D\uDFE2":R.status==="ERROR"?"\uD83D\uDD34":"⚫";w.push(`| ${R.name} | ${v} ${R.status} | ${G} |`)}w.push("")}return{mimeType:"text/markdown",body:w.join(`
3
+ `)}}},wp={target:"markdown",render:async(r)=>{if(r.source.type!=="component"||r.source.componentKey!=="SyncConfigEditor")throw Error("syncConfigMarkdownRenderer: not SyncConfigEditor");let P=Jr,p=kr,w=["# Sync Configurations","","> Configure automated data synchronization",""];for(let O of P){let k=p.find((G)=>G.id===O.connectionId),R=O.status==="SUCCESS"?"✅":"❌";w.push(`## ${O.name}`),w.push(""),w.push(`**Connection:** ${k?.name??"Unknown"}`),w.push(`**Frequency:** ${O.frequency}`),w.push(`**Status:** ${R} ${O.status}`),w.push(`**Last Run:** ${new Date(O.lastRunAt).toLocaleString()}`),w.push(`**Records Synced:** ${O.recordsSynced.toLocaleString()}`),w.push("")}return w.push("## Frequency Options"),w.push(""),w.push("- **REALTIME**: Sync on every change"),w.push("- **HOURLY**: Sync every hour"),w.push("- **DAILY**: Sync once per day"),w.push("- **WEEKLY**: Sync once per week"),w.push("- **MANUAL**: Sync only when triggered"),{mimeType:"text/markdown",body:w.join(`
4
+ `)}}};export{e as useIntegrationData,wp as syncConfigMarkdownRenderer,rp as integrationDashboardMarkdownRenderer,pp as connectionListMarkdownRenderer,t as IntegrationHubCredentialSetupPreview,a as IntegrationHubChat,sr as IntegrationDashboard};
@@ -0,0 +1,158 @@
1
+ export declare const integrationHubCredentialManifest: {
2
+ modes: {
3
+ managed: {
4
+ mode: "managed";
5
+ configFields: {
6
+ key: string;
7
+ required: true;
8
+ description: string;
9
+ }[];
10
+ validationStrategy: "provider-health";
11
+ setupSteps: string[];
12
+ };
13
+ byok: {
14
+ mode: "byok";
15
+ configFields: {
16
+ key: string;
17
+ required: true;
18
+ envVar: string;
19
+ description: string;
20
+ }[];
21
+ secretFields: {
22
+ key: string;
23
+ required: true;
24
+ envVar: string;
25
+ description: string;
26
+ }[];
27
+ validationStrategy: "byok-lifecycle";
28
+ rotation: {
29
+ supported: true;
30
+ recommendedIntervalDays: number;
31
+ };
32
+ allowedSecretProviders: string[];
33
+ setupSteps: string[];
34
+ };
35
+ };
36
+ };
37
+ export declare const integrationHubEnvironmentConfig: {
38
+ targets: {
39
+ webConsole: {
40
+ id: string;
41
+ packageName: string;
42
+ packagePath: string;
43
+ framework: "next";
44
+ surfaces: ("server" | "public-client")[];
45
+ envFiles: string[];
46
+ };
47
+ mobileConsole: {
48
+ id: string;
49
+ packageName: string;
50
+ packagePath: string;
51
+ framework: "expo";
52
+ surfaces: "native-client"[];
53
+ envFiles: string[];
54
+ };
55
+ syncWorker: {
56
+ id: string;
57
+ packageName: string;
58
+ packagePath: string;
59
+ framework: "node";
60
+ surfaces: ("worker" | "server")[];
61
+ envFiles: string[];
62
+ };
63
+ };
64
+ variables: {
65
+ publicOrigin: {
66
+ key: string;
67
+ description: string;
68
+ sensitivity: "public";
69
+ allowedSurfaces: ("public-client" | "native-client")[];
70
+ aliases: ({
71
+ targetId: string;
72
+ framework: "next";
73
+ name: string;
74
+ exposure: "public-client";
75
+ } | {
76
+ targetId: string;
77
+ framework: "expo";
78
+ name: string;
79
+ exposure: "native-client";
80
+ })[];
81
+ };
82
+ projectApiKey: {
83
+ key: string;
84
+ description: string;
85
+ sensitivity: "public";
86
+ allowedSurfaces: ("public-client" | "native-client")[];
87
+ valueSource: {
88
+ type: "byok-connection";
89
+ connectionId: string;
90
+ };
91
+ aliases: ({
92
+ targetId: string;
93
+ framework: "next";
94
+ name: string;
95
+ exposure: "public-client";
96
+ } | {
97
+ targetId: string;
98
+ framework: "expo";
99
+ name: string;
100
+ exposure: "native-client";
101
+ })[];
102
+ };
103
+ personalApiKey: {
104
+ key: string;
105
+ description: string;
106
+ sensitivity: "secret";
107
+ allowedSurfaces: ("worker" | "server")[];
108
+ valueSource: {
109
+ type: "secret";
110
+ secretRef: string;
111
+ };
112
+ aliases: {
113
+ targetId: string;
114
+ framework: "node";
115
+ name: string;
116
+ exposure: "server";
117
+ }[];
118
+ };
119
+ webhookSecret: {
120
+ key: string;
121
+ description: string;
122
+ sensitivity: "secret";
123
+ allowedSurfaces: ("worker" | "server")[];
124
+ aliases: {
125
+ targetId: string;
126
+ framework: "node";
127
+ name: string;
128
+ exposure: "server";
129
+ }[];
130
+ };
131
+ };
132
+ secretRequirements: {
133
+ personalApiKey: {
134
+ key: string;
135
+ required: true;
136
+ envVar: string;
137
+ provider: string;
138
+ rotationDays: number;
139
+ };
140
+ webhookSecret: {
141
+ key: string;
142
+ required: true;
143
+ envVar: string;
144
+ provider: string;
145
+ rotationDays: number;
146
+ };
147
+ };
148
+ };
149
+ export declare const integrationHubCredentialSetupState: {
150
+ readonly selectedMode: "byok";
151
+ readonly targetIds: readonly ["webConsole", "mobileConsole", "syncWorker"];
152
+ readonly configValues: {
153
+ readonly projectApiKey: "public-project-key-ref";
154
+ };
155
+ readonly secretRefs: {
156
+ readonly personalApiKey: "env://POSTHOG_PERSONAL_API_KEY";
157
+ };
158
+ };
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ var e={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},r={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},o={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};export{r as integrationHubEnvironmentConfig,o as integrationHubCredentialSetupState,e as integrationHubCredentialManifest};
@@ -0,0 +1 @@
1
+ export * from './credential-setup';
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ var e={modes:{managed:{mode:"managed",configFields:[{key:"workspaceId",required:!0,description:"Managed ContractSpec workspace that owns the provider connection."},{key:"region",required:!0,description:"Provider region used by the managed connector runtime."}],validationStrategy:"provider-health",setupSteps:["Select the workspace-owned managed connector.","Run the provider health check before enabling sync jobs."]},byok:{mode:"byok",configFields:[{key:"projectApiKey",required:!0,envVar:"POSTHOG_PROJECT_API_KEY",description:"Public analytics project key exposed through app-specific aliases."}],secretFields:[{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",description:"Server-only BYOK secret used for provider administration calls."},{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",description:"Server-only signing secret for incoming integration webhooks."}],validationStrategy:"byok-lifecycle",rotation:{supported:!0,recommendedIntervalDays:90},allowedSecretProviders:["env","vault","vercel","doppler"],setupSteps:["Create a restricted provider key with read/write access for sync metadata.","Store the key through a secret reference, never as a raw value in app config.","Materialize only public config aliases into browser or native app bundles."]}}},r={targets:{webConsole:{id:"webConsole",packageName:"@acme/integration-web",packagePath:"apps/web",framework:"next",surfaces:["server","public-client"],envFiles:["apps/web/.env.local"]},mobileConsole:{id:"mobileConsole",packageName:"@acme/integration-mobile",packagePath:"apps/mobile",framework:"expo",surfaces:["native-client"],envFiles:["apps/mobile/.env"]},syncWorker:{id:"syncWorker",packageName:"@acme/integration-worker",packagePath:"apps/worker",framework:"node",surfaces:["server","worker"],envFiles:["apps/worker/.env"]}},variables:{publicOrigin:{key:"publicOrigin",description:"Origin shared by web and mobile clients for integration callbacks.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_INTEGRATION_HUB_ORIGIN",exposure:"native-client"}]},projectApiKey:{key:"projectApiKey",description:"Public analytics key scoped to product usage capture.",sensitivity:"public",allowedSurfaces:["public-client","native-client"],valueSource:{type:"byok-connection",connectionId:"conn_posthog"},aliases:[{targetId:"webConsole",framework:"next",name:"NEXT_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"public-client"},{targetId:"mobileConsole",framework:"expo",name:"EXPO_PUBLIC_POSTHOG_PROJECT_API_KEY",exposure:"native-client"}]},personalApiKey:{key:"personalApiKey",description:"Server-only provider administration token.",sensitivity:"secret",allowedSurfaces:["server","worker"],valueSource:{type:"secret",secretRef:"env://POSTHOG_PERSONAL_API_KEY"},aliases:[{targetId:"syncWorker",framework:"node",name:"POSTHOG_PERSONAL_API_KEY",exposure:"server"}]},webhookSecret:{key:"webhookSecret",description:"Server-only secret for validating provider webhooks.",sensitivity:"secret",allowedSurfaces:["server","worker"],aliases:[{targetId:"syncWorker",framework:"node",name:"INTEGRATION_HUB_WEBHOOK_SECRET",exposure:"server"}]}},secretRequirements:{personalApiKey:{key:"personalApiKey",required:!0,envVar:"POSTHOG_PERSONAL_API_KEY",provider:"env",rotationDays:90},webhookSecret:{key:"webhookSecret",required:!0,envVar:"INTEGRATION_HUB_WEBHOOK_SECRET",provider:"env",rotationDays:90}}},o={selectedMode:"byok",targetIds:["webConsole","mobileConsole","syncWorker"],configValues:{projectApiKey:"public-project-key-ref"},secretRefs:{personalApiKey:"env://POSTHOG_PERSONAL_API_KEY"}};export{r as integrationHubEnvironmentConfig,o as integrationHubCredentialSetupState,e as integrationHubCredentialManifest};