@ekanos/sdk 0.20.0 → 0.22.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.
@@ -313,7 +313,7 @@ function WidgetFooter({ children }) {
313
313
  : 'opacity-100'), "aria-hidden": meta.isCollapsible && state.collapsed, children: children }));
314
314
  }
315
315
  function WidgetActions({ children }) {
316
- return (_jsx(CardFooter, { className: "bg-muted flex-shrink-0 justify-end border-t py-3", children: children }));
316
+ return (_jsx(CardFooter, { className: "flex-shrink-0 justify-end border-t py-3", children: children }));
317
317
  }
318
318
  function WidgetAskFooter({ context }) {
319
319
  var _a, _b;
@@ -1 +1 @@
1
- {"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/components/widgets/widget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EACL,SAAS,EAGT,GAAG,EACH,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B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,OAAO;QACd,MAAM,CAAC,IAAI;QACX,MAAM,CAAC,IAAI;QACX,aAAa;QACb,WAAW;QACX,WAAW;QACX,UAAU;QACV,SAAS;QACT,OAAO;KACR,CACF,CAAC;IACF,OAAO,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,CAAC;AACjE,CAAC;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,eAAe;IAC1B,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,WAAW;IAClB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE,eAAe;IAC1B,YAAY,EAAE,kBAAkB;CACjC,CAAC","sourcesContent":["'use client';\n\nimport {\n Component,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n} from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport {\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from '@ekanos/ui/dropdown-menu';\nimport { Icon } from '@ekanos/ui/icon';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@ekanos/ui/select';\nimport { StatusBadge } from '@ekanos/ui/status-badge';\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@ekanos/ui/tooltip';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport type { WidgetVerdict } from '../../types/widget-verdict';\nimport { useAnimatedHeight } from './use-animated-height';\nimport { useRelativeTime } from './use-relative-time';\nimport { WidgetAskBar } from './widget-ask-bar';\nimport { WidgetContext, type WidgetRenderState } from './widget-context';\nimport {\n WidgetDisabledState,\n WidgetEmptyState,\n type WidgetEmptyStateProps,\n WidgetErrorState,\n WidgetInactiveState,\n type WidgetInactiveStateProps,\n WidgetLoadingSkeleton,\n type WidgetSkeletonVariant,\n} from './widget-state-components';\n\n// ─── Error Boundary ─────────────────────────────────────────────────────────\n\nclass WidgetErrorBoundary extends Component<\n { widgetId: string; onRetry?: () => void; children: ReactNode },\n { hasError: boolean }\n> {\n state = { hasError: false };\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n console.error(`Widget \"${this.props.widgetId}\" crashed:`, error, info);\n }\n retry = () => {\n this.props.onRetry?.();\n this.setState({ hasError: false });\n };\n render() {\n if (this.state.hasError) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-1 flex-col items-center justify-center gap-3 px-5 py-8 text-center\"\n >\n <div className=\"bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"text-destructive h-5 w-5\"\n aria-hidden\n />\n </div>\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-label\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedTitle\"\n defaults=\"This widget ran into a problem\"\n />\n </p>\n <p className=\"text-muted-foreground text-meta max-w-xs\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedBody\"\n defaults=\"Try again. If it keeps happening, reload the page.\"\n />\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={this.retry}\n data-test=\"widget-crash-retry\"\n >\n <Icon name=\"fa-arrows-rotate\" className=\"h-4 w-4\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n </div>\n );\n }\n return this.props.children;\n }\n}\n\n// ─── Hook ───────────────────────────────────────────────────────────────────\n\nfunction useWidget() {\n const ctx = use(WidgetContext);\n if (!ctx) {\n throw new Error(\n 'Widget.* compound components must be rendered inside a widget provider. ' +\n 'On the Ekanos dashboard the host supplies one. Anywhere else — your own ' +\n 'app, a story, a component test — wrap the widget in ' +\n \"`WidgetPreviewProvider` from '@ekanos/sdk/components'.\",\n );\n }\n return ctx;\n}\n\n/**\n * The verdict the widget reported through `Widget.DataState`, for a body that\n * wants to echo it (an empty state, a summary row). `undefined` before the\n * widget has one.\n */\nexport function useWidgetVerdict(): WidgetVerdict | undefined {\n return useWidget().data?.verdict;\n}\n\n// ─── Card ───────────────────────────────────────────────────────────────────\n\nfunction WidgetCard({ children }: { children: ReactNode }) {\n const { meta } = useWidget();\n return (\n <Card\n // A verdict that needs the owner rings the card in its status mark, so\n // Home's \"needs you\" is found at a glance; the verdict is decided in\n // `Widget.DataState` below, so the card follows its header's pill.\n tone=\"verdict\"\n className={cn(\n // Neutralize the shadcn card's own py-6/gap-6 box model — widget\n // chrome owns all vertical spacing via its header/content/footer.\n 'shadow-ring @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0',\n meta.className,\n )}\n data-widget-id={meta.widgetId}\n >\n {children}\n <WidgetFreshness />\n </Card>\n );\n}\n\n// ─── Header ─────────────────────────────────────────────────────────────────\n\nfunction CollapseButton() {\n const { state, actions, meta } = useWidget();\n return (\n <Button\n variant=\"outline\"\n size=\"icon\"\n onClick={actions.toggleCollapsed}\n disabled={state.pendingCollapse}\n className=\"relative h-6 w-6 before:absolute before:top-1/2 before:left-1/2 before:h-11 before:w-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n aria-expanded={!state.collapsed}\n aria-controls={`widget-content-${meta.widgetId}`}\n aria-label={\n state.collapsed\n ? `Expand ${meta.title ?? 'widget'}`\n : `Collapse ${meta.title ?? 'widget'}`\n }\n >\n <Icon\n name=\"fa-chevron-right\"\n className={cn(\n 'ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none',\n !state.collapsed && 'rotate-90',\n )}\n />\n </Button>\n );\n}\n\n/**\n * The header's one trailing control (the design system's widget rules): a \"View all ›\"\n * link to where the data lives, or a period switch. Everything else goes in\n * the ⋯ menu.\n */\nexport type WidgetHeaderTrailing =\n | {\n kind: 'link';\n href: string;\n label: ReactNode;\n /** Open in a new tab. */\n external?: boolean;\n }\n | {\n kind: 'period';\n value: string;\n options: ReadonlyArray<{ value: string; label: string }>;\n onChange: (value: string) => void;\n /** Accessible name; defaults to \"Period\". */\n label?: string;\n };\n\nfunction HeaderTrailing({ trailing }: { trailing: WidgetHeaderTrailing }) {\n if (trailing.kind === 'link') {\n const link = trailing.external ? (\n <a href={trailing.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={trailing.href} />\n );\n\n return (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n render={link}\n nativeButton={false}\n data-test=\"widget-header-link\"\n >\n {trailing.label}\n <Icon name=\"fa-chevron-right\" className=\"h-3 w-3\" aria-hidden />\n </Button>\n );\n }\n\n return (\n <Select\n value={trailing.value}\n onValueChange={(value) => {\n if (typeof value === 'string') trailing.onChange(value);\n }}\n >\n <SelectTrigger\n size=\"sm\"\n aria-label={trailing.label ?? 'Period'}\n data-test=\"widget-header-period\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {trailing.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n\nconst VERDICT_BADGE_TONE = {\n attention: 'warning',\n critical: 'destructive',\n degraded: 'warning',\n unknown: 'neutral',\n} as const;\n\n/** Only the verdicts that ask something of the owner fill their pill. */\nconst VERDICT_BADGE_PROMINENT = {\n attention: true,\n critical: true,\n degraded: false,\n unknown: false,\n} as const;\n\n/**\n * The verdict under the title. Anything but `clear` is a status pill, the\n * words carrying the tone and the dot confirming it. `clear` is plain ink and\n * a check, no colour at all (plan 251 D24): calm is the absence of colour,\n * so colour on a dashboard always means \"look here\".\n */\nfunction VerdictLine({ verdict }: { verdict: WidgetVerdict }) {\n if (verdict.tone === 'clear') {\n return (\n <p\n className=\"text-foreground text-meta flex min-w-0 items-center gap-1.5\"\n data-test=\"widget-verdict\"\n data-verdict=\"clear\"\n >\n <Icon\n name=\"fa-circle-check\"\n className=\"h-3.5 w-3.5 shrink-0\"\n aria-hidden\n />\n <span className=\"truncate\">{verdict.sentence}</span>\n </p>\n );\n }\n\n return (\n <StatusBadge\n tone={VERDICT_BADGE_TONE[verdict.tone]}\n prominent={VERDICT_BADGE_PROMINENT[verdict.tone]}\n className=\"mt-0.5 max-w-full\"\n data-test=\"widget-verdict\"\n data-verdict={verdict.tone}\n >\n <span className=\"truncate\">{verdict.sentence}</span>\n </StatusBadge>\n );\n}\n\n/** Widgets already warned about `children` beside `trailing`, so each warns once. */\nconst warnedChildrenWithTrailing = new Set<string>();\n\nfunction WidgetHeader({\n title,\n subtitle,\n description,\n context,\n trailing,\n menu,\n children,\n}: {\n /** Override the provider's title — useful when the rendered name differs from the config name. */\n title?: string;\n /**\n * Override the provider's subtitle. It renders as the context line when\n * `context` is not set.\n */\n subtitle?: string;\n /** Override the provider's description — useful for widget-computed values. */\n description?: string;\n /**\n * One muted line under the title that frames the data: \"This month\",\n * \"As of today\", \"3 accounts\". A verdict that needs the owner replaces it;\n * a clear one joins it (\"This month · All caught up\").\n */\n context?: ReactNode;\n /** At most one control on the right: a \"View all ›\" link or a period switch. */\n trailing?: WidgetHeaderTrailing;\n /**\n * `Widget.MenuItem`s and `Widget.MenuChoice`s placed at the top of the\n * header's ⋯ menu: occasional actions (\"Open in QuickBooks\") and secondary\n * settings (a comparison basis) that don't earn the one trailing slot.\n */\n menu?: ReactNode;\n /**\n * @deprecated Free controls beside the ⋯ menu. Use `trailing` for the one\n * control a header carries and `menu` for the rest; `children` goes away\n * in a later major release.\n */\n children?: ReactNode;\n}) {\n const { meta, state, data } = useWidget();\n const effectiveTitle = title ?? meta.title;\n const effectiveDescription = description ?? meta.description;\n const contextLine = context ?? subtitle ?? meta.subtitle;\n // A verdict speaks for data on screen, so it shows only while active.\n const verdict = state.state === 'active' ? data?.verdict : undefined;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n children &&\n trailing &&\n !warnedChildrenWithTrailing.has(meta.widgetId)\n ) {\n warnedChildrenWithTrailing.add(meta.widgetId);\n console.warn(\n `Widget.Header (${meta.widgetId}): pass \\`trailing\\` or \\`children\\`, not both. \\`children\\` is deprecated; move other controls into \\`menu\\`.`,\n );\n }\n\n if (!effectiveTitle) return null;\n\n const titleNode = effectiveDescription ? (\n <>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={<CardTitle className=\"text-title cursor-help truncate\" />}\n >\n {effectiveTitle}\n </TooltipTrigger>\n <TooltipContent>\n <p>{effectiveDescription}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n <span className=\"sr-only\">{effectiveDescription}</span>\n </>\n ) : (\n <CardTitle className=\"text-title truncate\">{effectiveTitle}</CardTitle>\n );\n\n return (\n <CardHeader className=\"flex-shrink-0 px-5 pt-4 pb-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n {meta.isCollapsible ? <CollapseButton /> : null}\n <div className=\"min-w-0 space-y-0.5\">\n {titleNode}\n {verdict && verdict.tone !== 'clear' ? (\n <VerdictLine verdict={verdict} />\n ) : contextLine ? (\n <p\n className=\"text-muted-foreground text-meta truncate\"\n data-test=\"widget-header-context\"\n >\n {contextLine}\n {verdict ? (\n <>\n {' · '}\n <span data-test=\"widget-verdict\" data-verdict=\"clear\">\n {verdict.sentence}\n </span>\n </>\n ) : null}\n </p>\n ) : verdict ? (\n <VerdictLine verdict={verdict} />\n ) : null}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {trailing ? <HeaderTrailing trailing={trailing} /> : null}\n {children}\n <WidgetMenu items={menu} />\n </div>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The actions every widget shares, whatever it renders: open its full\n * surface, reload it, pin or unpin it. Each item needs something from the host\n * or the widget's data layer, so the menu shows only what applies — and\n * nothing at all when nothing does.\n */\nfunction WidgetMenu({ items }: { items?: ReactNode }) {\n const { state, actions, meta, data } = useWidget();\n const refresh = state.state === 'active' ? data?.refresh : undefined;\n const hasNavigation = !!items || !!meta.openHref || !!refresh;\n\n if (!hasNavigation && !meta.isPinnable) return null;\n\n const title = meta.title ?? 'widget';\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label={`Actions for ${title}`}\n data-test={`widget-menu-${meta.widgetId}`}\n />\n }\n >\n <Icon name=\"fa-ellipsis\" className=\"h-4 w-4\" aria-hidden />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-48\">\n {items}\n {meta.openHref ? (\n <DropdownMenuItem render={<Link href={meta.openHref} />}>\n <Icon name=\"fa-arrow-up-right-from-square\" aria-hidden />\n <Trans\n i18nKey=\"dashboard:widgetOpenInWorkspace\"\n defaults=\"Open in workspace\"\n />\n </DropdownMenuItem>\n ) : null}\n {refresh ? (\n <DropdownMenuItem onClick={refresh} disabled={data?.refreshing}>\n <Icon name=\"fa-arrows-rotate\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRefresh\" defaults=\"Refresh\" />\n </DropdownMenuItem>\n ) : null}\n {hasNavigation && meta.isPinnable ? <DropdownMenuSeparator /> : null}\n {meta.isPinnable ? (\n <DropdownMenuItem\n onClick={actions.togglePinned}\n disabled={state.pendingPin}\n data-test={`widget-menu-pin-${meta.widgetId}`}\n >\n <Icon\n name={state.pinned ? 'fa-thumbtack-slash' : 'fa-thumbtack'}\n aria-hidden\n />\n {state.pinned ? (\n <Trans\n i18nKey=\"dashboard:widgetUnpin\"\n defaults=\"Unpin from board\"\n />\n ) : (\n <Trans i18nKey=\"dashboard:widgetPin\" defaults=\"Pin to board\" />\n )}\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/**\n * One widget-specific entry in the header's ⋯ menu; pass it through\n * `Widget.Header`'s `menu` prop. With `href` it is a link, opened in a new tab\n * when `external`; otherwise it runs `onSelect`.\n */\nfunction WidgetMenuItem({\n icon,\n href,\n external = false,\n onSelect,\n disabled,\n children,\n}: {\n /** A Font Awesome class, e.g. `fa-envelope`. */\n icon?: string;\n href?: string;\n external?: boolean;\n onSelect?: () => void;\n disabled?: boolean;\n children: ReactNode;\n}) {\n const link = !href ? undefined : external ? (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={href} />\n );\n\n return (\n <DropdownMenuItem render={link} onClick={onSelect} disabled={disabled}>\n <Icon\n name={\n icon ??\n (external ? 'fa-arrow-up-right-from-square' : 'fa-arrow-right')\n }\n aria-hidden\n />\n {children}\n </DropdownMenuItem>\n );\n}\n\n/**\n * A setting that doesn't earn the header's one trailing slot (a comparison\n * basis, an as-of month), as a submenu of choices in the ⋯ menu. Pass it\n * through `Widget.Header`'s `menu` prop.\n */\nfunction WidgetMenuChoice<Value extends string>({\n icon,\n label,\n value,\n options,\n onChange,\n}: {\n /** A Font Awesome class, e.g. `fa-scale-balanced`. */\n icon?: string;\n label: ReactNode;\n value: Value;\n options: ReadonlyArray<{ value: Value; label: ReactNode }>;\n onChange: (value: Value) => void;\n}) {\n const current = options.find((option) => option.value === value);\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Icon name={icon ?? 'fa-sliders'} aria-hidden />\n <span className=\"flex-1\">{label}</span>\n {current ? (\n <span className=\"text-muted-foreground text-fine\">\n {current.label}\n </span>\n ) : null}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"min-w-44\">\n <DropdownMenuRadioGroup\n value={value}\n onValueChange={(next) => {\n const match = options.find((option) => option.value === next);\n if (match) onChange(match.value);\n }}\n >\n {options.map((option) => (\n <DropdownMenuRadioItem key={option.value} value={option.value}>\n {option.label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/**\n * \"Updated 3 minutes ago\" under an active widget whose data layer reports\n * when it last loaded (see `Widget.DataState`'s `updatedAt`).\n */\nfunction WidgetFreshness() {\n const { state, data } = useWidget();\n const updated = useRelativeTime(data?.updatedAt);\n\n if (state.state !== 'active' || state.collapsed || !updated) return null;\n\n return (\n <div\n className=\"text-muted-foreground border-border text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5\"\n aria-live=\"polite\"\n >\n {data?.refreshing ? (\n <>\n <Icon\n name=\"fa-arrows-rotate\"\n className=\"h-3 w-3 animate-spin\"\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRefreshing\" defaults=\"Refreshing…\" />\n </>\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetUpdated\"\n defaults=\"Updated {{time}}\"\n values={{ time: updated }}\n />\n )}\n </div>\n );\n}\n\n// ─── State-gated content ────────────────────────────────────────────────────\n\nfunction CollapsibleBody({\n collapsed,\n maxContentHeight,\n widgetId,\n children,\n}: {\n collapsed: boolean;\n maxContentHeight?: string;\n widgetId: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'ease-out-strong grid min-h-0 flex-1 transition-all duration-300 motion-reduce:transition-none',\n collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]',\n )}\n >\n <div className=\"min-h-0 overflow-hidden\">\n <CardContent\n id={`widget-content-${widgetId}`}\n className={cn(\n 'flex h-full min-h-0 flex-1 flex-col overflow-y-auto p-0',\n 'ease-out-strong transition-opacity duration-200 motion-reduce:transition-none',\n collapsed ? 'opacity-0' : 'opacity-100',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n maxContentHeight\n ? ({ '--widget-max-height': maxContentHeight } as CSSProperties)\n : undefined\n }\n >\n {children}\n </CardContent>\n </div>\n </div>\n );\n}\n\nfunction StaticBody({\n maxContentHeight,\n children,\n}: {\n maxContentHeight?: string;\n children: ReactNode;\n}) {\n const { innerRef, height } = useAnimatedHeight();\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n <div\n className={cn(\n 'h-(--body-height) overflow-hidden transition-all duration-250 ease-out motion-reduce:transition-none',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n {\n '--body-height': height === 'auto' ? 'auto' : `${height}px`,\n '--widget-max-height': maxContentHeight,\n } as CSSProperties\n }\n >\n <div ref={innerRef}>{children}</div>\n </div>\n </CardContent>\n );\n}\n\n/**\n * The standard padded body for content rendered inside `Widget.Active`.\n *\n * `Widget.Active`'s own `CardContent` renders `p-0` — deliberately, so a\n * full-bleed chart or table can run edge-to-edge inside the card. That means\n * ordinary content (text, rows, a KPI readout) is left flush against the\n * card's sides while `Widget.Header` stays inset (`px-5`) unless the body\n * supplies its own padding. `Widget.Body` is that padding: `px-5` matches\n * the header's horizontal inset so header and body align, `pt-4 pb-5`\n * balances the header's `pb-3`/card's bottom edge.\n *\n * Every widget wraps its content in it:\n *\n * ```tsx\n * <Widget.Active>\n * <Widget.Body>{/* text, a Stat, a form *\\/}</Widget.Body>\n * </Widget.Active>\n * ```\n *\n * Pass `flush` when the content runs to the card's edges: edge-to-edge rows\n * that pad themselves, a chart, a table with its own header row, an image.\n */\nfunction WidgetBody({\n flush = false,\n className,\n children,\n}: {\n /**\n * Drop the padding for content that runs to the card's edges: edge-to-edge\n * rows (which pad themselves, `px-5 py-3`), a full-bleed chart, an image.\n */\n flush?: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'flex flex-1 flex-col',\n flush ? 'pb-2' : 'gap-4 px-5 pt-4 pb-5',\n className,\n )}\n data-flush={flush || undefined}\n >\n {children}\n </div>\n );\n}\n\n/**\n * Renders `children` once the widget's state is `active`. Its `CardContent`\n * is flush (`p-0`); wrap content in `Widget.Body`, which pads it to line up\n * with the header, or `Widget.Body flush` for edge-to-edge rows and charts.\n * Never hand-roll a `px-*` wrapper.\n */\nfunction WidgetActive({ children }: { children: ReactNode }) {\n const { state, meta, data } = useWidget();\n if (state.state !== 'active') return null;\n const body = (\n <WidgetErrorBoundary widgetId={meta.widgetId} onRetry={data?.refresh}>\n {children}\n </WidgetErrorBoundary>\n );\n return meta.isCollapsible ? (\n <CollapsibleBody\n collapsed={state.collapsed}\n maxContentHeight={meta.maxContentHeight}\n widgetId={meta.widgetId}\n >\n {body}\n </CollapsibleBody>\n ) : (\n <StaticBody maxContentHeight={meta.maxContentHeight}>{body}</StaticBody>\n );\n}\n\n/**\n * Shows while the widget loads: a skeleton shaped like its body (`variant`,\n * `rows` by default), never a spinner.\n */\nfunction WidgetLoading({\n variant,\n children,\n}: {\n variant?: WidgetSkeletonVariant;\n children?: ReactNode;\n}) {\n const { state } = useWidget();\n if (state.state !== 'loading') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetLoadingSkeleton variant={variant} />}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget's data failed to load. Offers Try again whenever the\n * widget reports `onRefresh` through `Widget.DataState`. `title` and\n * `description` replace the default copy with something specific (\"Couldn't\n * load your inbox\").\n */\nfunction WidgetError({\n title,\n description,\n children,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n children?: ReactNode;\n}) {\n const { state, data } = useWidget();\n if (state.state !== 'error') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetErrorState\n title={title}\n description={description}\n onRetry={data?.refresh}\n retrying={data?.refreshing}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget can't reach its data. Give it a `reason`:\n * `not-connected` (one Connect button in `action`), `no-access` (a calm note\n * pointing to an admin) or `setup-needed`. `integrationName` defaults to the\n * host's source name.\n */\nfunction WidgetInactive({\n children,\n integrationName,\n ...props\n}: WidgetInactiveStateProps & { children?: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'inactive') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetInactiveState\n integrationName={integrationName ?? meta.source?.name}\n {...props}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * What an active widget shows when it has nothing to list. Render it inside\n * `Widget.Active`. Positive by default (\"You're all caught up\"), because an\n * empty queue is good news; `tone=\"neutral\"` for an empty search.\n */\nfunction WidgetEmpty(props: WidgetEmptyStateProps) {\n return <WidgetEmptyState {...props} />;\n}\n\nfunction WidgetDisabled({ children }: { children?: ReactNode }) {\n const { state } = useWidget();\n if (state.state !== 'disabled') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetDisabledState />}\n </CardContent>\n );\n}\n\n// ─── Footers ────────────────────────────────────────────────────────────────\n\nfunction WidgetFooter({ children }: { children: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'active') return null;\n return (\n <CardFooter\n className={cn(\n 'ease-out-strong flex-shrink-0 pb-6 transition-opacity duration-200 motion-reduce:transition-none',\n meta.isCollapsible && state.collapsed\n ? 'pointer-events-none opacity-0'\n : 'opacity-100',\n )}\n aria-hidden={meta.isCollapsible && state.collapsed}\n >\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetActions({ children }: { children: ReactNode }) {\n return (\n <CardFooter className=\"bg-muted flex-shrink-0 justify-end border-t py-3\">\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetAskFooter({ context }: { context?: WidgetAskContext }) {\n const { state, meta, data } = useWidget();\n const effectiveContext = context ?? meta.askContext;\n const shouldShow =\n (meta.aiFooterEnabled || !!effectiveContext) &&\n state.state === 'active' &&\n !state.collapsed;\n if (!shouldShow) return null;\n const base = effectiveContext ?? {\n widgetId: meta.widgetId,\n title: meta.title ?? meta.widgetId,\n snapshot: null,\n suggestedPrompt: `Tell me about ${meta.title ?? 'this widget'}.`,\n };\n return <WidgetAskBar context={withVerdict(base, data?.verdict)} />;\n}\n\n/**\n * Adds the widget's own conclusion to what the assistant sees, so an answer\n * starts from the verdict on the card instead of re-deriving it.\n */\nfunction withVerdict(\n context: WidgetAskContext,\n verdict: WidgetVerdict | undefined,\n): WidgetAskContext {\n if (!verdict) return context;\n return {\n ...context,\n snapshot: {\n ...context.snapshot,\n verdict: {\n tone: verdict.tone,\n sentence: verdict.sentence,\n ...(verdict.count !== undefined ? { count: verdict.count } : {}),\n },\n },\n };\n}\n\n/**\n * Renders a subtle \"data may be stale\" banner when the widget's integration is\n * `degraded` (but still active). Unhealthy integrations route to `disabled`\n * instead, so this only fires for the degraded middle ground.\n */\nfunction WidgetHealthFooter() {\n const { state, meta } = useWidget();\n const lastSuccessAt = toEpochMs(meta.health?.lastSuccessAt);\n const lastSynced = useRelativeTime(lastSuccessAt);\n const shouldShow =\n state.state === 'active' &&\n !state.collapsed &&\n meta.health?.status === 'degraded';\n if (!shouldShow) return null;\n return (\n <div className=\"text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"h-4 w-4 shrink-0\"\n aria-hidden\n />\n <span>\n {lastSynced ? (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNoticeSince\"\n defaults=\"Data may be out of date. Last synced {{time}}.\"\n values={{ time: lastSynced }}\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNotice\"\n defaults=\"This integration is degraded — data may be stale.\"\n />\n )}\n </span>\n </div>\n );\n}\n\nfunction toEpochMs(\n value: number | string | Date | null | undefined,\n): number | undefined {\n if (value === null || value === undefined) return undefined;\n const ms =\n value instanceof Date ? value.getTime() : new Date(value).getTime();\n return Number.isFinite(ms) && ms > 0 ? ms : undefined;\n}\n\n// ─── Data state override ────────────────────────────────────────────────────\n\n/**\n * Wraps children in a sub-provider that overrides the effective render state\n * with the widget's own data loading / error state. Only overrides when the\n * parent state is `active` — so the integration's `inactive` / `disabled` /\n * `loading` (initial) states still win.\n *\n * Read the parent integration state BEFORE wrapping in this component if you\n * need it to gate data fetching:\n *\n * ```tsx\n * const { state } = use(WidgetContext);\n * const integrationActive = state.state === 'active';\n * const { isLoading, isError } = useMyData(accountId, integrationActive);\n * return (\n * <Widget.DataState loading={isLoading} error={isError}>\n * <Widget.Card>…</Widget.Card>\n * </Widget.DataState>\n * );\n * ```\n *\n * Pass `onRefresh`, `refreshing` and `updatedAt` to give the widget the\n * shared Refresh menu item, a Try again button on its error view, and an\n * \"Updated 3 minutes ago\" footer. With TanStack Query:\n *\n * ```tsx\n * <Widget.DataState\n * loading={query.isLoading}\n * error={query.isError}\n * onRefresh={() => void query.refetch()}\n * refreshing={query.isFetching}\n * updatedAt={query.dataUpdatedAt}\n * >\n * ```\n */\nfunction WidgetDataState({\n loading,\n error,\n inactive,\n onRefresh,\n refreshing = false,\n updatedAt,\n verdict,\n children,\n}: {\n loading?: boolean;\n error?: boolean;\n /**\n * Force the `inactive` render state even though the integration itself is\n * active. Use for widget-level \"not connected\" states (e.g. the product is\n * activated but the upstream OAuth connection is missing). Takes priority\n * over `loading` / `error`.\n */\n inactive?: boolean;\n /** Reloads the widget's data. */\n onRefresh?: () => void;\n /** A reload is in flight. */\n refreshing?: boolean;\n /**\n * When the data on screen last loaded successfully: epoch milliseconds, an\n * ISO string or a `Date`. `0` means never, which TanStack Query's\n * `dataUpdatedAt` reports before the first success.\n */\n updatedAt?: number | string | Date | null;\n /**\n * The widget's verdict on its data (the design system's widget rules): `{ tone,\n * sentence, count? }`. Compute it with the same function the integration's\n * server `getAttention` uses, so the card and home's Needs you agree.\n */\n verdict?: WidgetVerdict;\n children: ReactNode;\n}) {\n const parent = useWidget();\n const overrideState: WidgetRenderState =\n parent.state.state !== 'active'\n ? parent.state.state\n : inactive\n ? 'inactive'\n : loading\n ? 'loading'\n : error\n ? 'error'\n : 'active';\n const updatedAtMs = toEpochMs(updatedAt);\n const reportsData =\n onRefresh !== undefined ||\n updatedAtMs !== undefined ||\n verdict !== undefined;\n const value = useMemo(\n () => ({\n state: { ...parent.state, state: overrideState },\n actions: parent.actions,\n meta: parent.meta,\n data: reportsData\n ? { updatedAt: updatedAtMs, refreshing, refresh: onRefresh, verdict }\n : parent.data,\n }),\n [\n parent.state,\n parent.actions,\n parent.meta,\n parent.data,\n overrideState,\n reportsData,\n updatedAtMs,\n refreshing,\n onRefresh,\n verdict,\n ],\n );\n return <WidgetContext value={value}>{children}</WidgetContext>;\n}\n\n// ─── Compound export ────────────────────────────────────────────────────────\n\nexport const Widget = {\n Card: WidgetCard,\n Header: WidgetHeader,\n MenuItem: WidgetMenuItem,\n MenuChoice: WidgetMenuChoice,\n DataState: WidgetDataState,\n Active: WidgetActive,\n Body: WidgetBody,\n Empty: WidgetEmpty,\n Loading: WidgetLoading,\n Error: WidgetError,\n Inactive: WidgetInactive,\n Disabled: WidgetDisabled,\n Footer: WidgetFooter,\n Actions: WidgetActions,\n AskFooter: WidgetAskFooter,\n HealthFooter: WidgetHealthFooter,\n};\n"]}
1
+ {"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/components/widgets/widget.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EACL,SAAS,EAGT,GAAG,EACH,OAAO,GACR,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL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S;QACzB,OAAO,KAAK,SAAS,CAAC;IACxB,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,KAAK,kCAAO,MAAM,CAAC,KAAK,KAAE,KAAK,EAAE,aAAa,GAAE;QAChD,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,WAAW;YACf,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE;YACrE,CAAC,CAAC,MAAM,CAAC,IAAI;KAChB,CAAC,EACF;QACE,MAAM,CAAC,KAAK;QACZ,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,IAAI;QACX,MAAM,CAAC,IAAI;QACX,aAAa;QACb,WAAW;QACX,WAAW;QACX,UAAU;QACV,SAAS;QACT,OAAO;KACR,CACF,CAAC;IACF,OAAO,KAAC,aAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,CAAC;AACjE,CAAC;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,cAAc;IACxB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,eAAe;IAC1B,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,WAAW;IAClB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,SAAS,EAAE,eAAe;IAC1B,YAAY,EAAE,kBAAkB;CACjC,CAAC","sourcesContent":["'use client';\n\nimport {\n Component,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n} from 'react';\n\nimport Link from 'next/link.js';\n\nimport { Button } from '@ekanos/ui/button';\nimport {\n Card,\n CardContent,\n CardFooter,\n CardHeader,\n CardTitle,\n} from '@ekanos/ui/card';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from '@ekanos/ui/dropdown-menu';\nimport { Icon } from '@ekanos/ui/icon';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@ekanos/ui/select';\nimport { StatusBadge } from '@ekanos/ui/status-badge';\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@ekanos/ui/tooltip';\nimport { Trans } from '@ekanos/ui/trans';\nimport { cn } from '@ekanos/ui/utils';\n\nimport type { WidgetAskContext } from '../../types/widget-ask-context';\nimport type { WidgetVerdict } from '../../types/widget-verdict';\nimport { useAnimatedHeight } from './use-animated-height';\nimport { useRelativeTime } from './use-relative-time';\nimport { WidgetAskBar } from './widget-ask-bar';\nimport { WidgetContext, type WidgetRenderState } from './widget-context';\nimport {\n WidgetDisabledState,\n WidgetEmptyState,\n type WidgetEmptyStateProps,\n WidgetErrorState,\n WidgetInactiveState,\n type WidgetInactiveStateProps,\n WidgetLoadingSkeleton,\n type WidgetSkeletonVariant,\n} from './widget-state-components';\n\n// ─── Error Boundary ─────────────────────────────────────────────────────────\n\nclass WidgetErrorBoundary extends Component<\n { widgetId: string; onRetry?: () => void; children: ReactNode },\n { hasError: boolean }\n> {\n state = { hasError: false };\n static getDerivedStateFromError() {\n return { hasError: true };\n }\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n console.error(`Widget \"${this.props.widgetId}\" crashed:`, error, info);\n }\n retry = () => {\n this.props.onRetry?.();\n this.setState({ hasError: false });\n };\n render() {\n if (this.state.hasError) {\n return (\n <div\n role=\"alert\"\n className=\"flex flex-1 flex-col items-center justify-center gap-3 px-5 py-8 text-center\"\n >\n <div className=\"bg-destructive/10 flex h-10 w-10 items-center justify-center rounded-full\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"text-destructive h-5 w-5\"\n aria-hidden\n />\n </div>\n <div className=\"space-y-1\">\n <p className=\"text-foreground text-label\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedTitle\"\n defaults=\"This widget ran into a problem\"\n />\n </p>\n <p className=\"text-muted-foreground text-meta max-w-xs\">\n <Trans\n i18nKey=\"dashboard:widgetCrashedBody\"\n defaults=\"Try again. If it keeps happening, reload the page.\"\n />\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={this.retry}\n data-test=\"widget-crash-retry\"\n >\n <Icon name=\"fa-arrows-rotate\" className=\"h-4 w-4\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRetry\" defaults=\"Try again\" />\n </Button>\n </div>\n );\n }\n return this.props.children;\n }\n}\n\n// ─── Hook ───────────────────────────────────────────────────────────────────\n\nfunction useWidget() {\n const ctx = use(WidgetContext);\n if (!ctx) {\n throw new Error(\n 'Widget.* compound components must be rendered inside a widget provider. ' +\n 'On the Ekanos dashboard the host supplies one. Anywhere else — your own ' +\n 'app, a story, a component test — wrap the widget in ' +\n \"`WidgetPreviewProvider` from '@ekanos/sdk/components'.\",\n );\n }\n return ctx;\n}\n\n/**\n * The verdict the widget reported through `Widget.DataState`, for a body that\n * wants to echo it (an empty state, a summary row). `undefined` before the\n * widget has one.\n */\nexport function useWidgetVerdict(): WidgetVerdict | undefined {\n return useWidget().data?.verdict;\n}\n\n// ─── Card ───────────────────────────────────────────────────────────────────\n\nfunction WidgetCard({ children }: { children: ReactNode }) {\n const { meta } = useWidget();\n return (\n <Card\n // A verdict that needs the owner rings the card in its status mark, so\n // Home's \"needs you\" is found at a glance; the verdict is decided in\n // `Widget.DataState` below, so the card follows its header's pill.\n tone=\"verdict\"\n className={cn(\n // Neutralize the shadcn card's own py-6/gap-6 box model — widget\n // chrome owns all vertical spacing via its header/content/footer.\n 'shadow-ring @container/widget relative flex h-full flex-col gap-0 overflow-hidden rounded-lg border-0 py-0',\n meta.className,\n )}\n data-widget-id={meta.widgetId}\n >\n {children}\n <WidgetFreshness />\n </Card>\n );\n}\n\n// ─── Header ─────────────────────────────────────────────────────────────────\n\nfunction CollapseButton() {\n const { state, actions, meta } = useWidget();\n return (\n <Button\n variant=\"outline\"\n size=\"icon\"\n onClick={actions.toggleCollapsed}\n disabled={state.pendingCollapse}\n className=\"relative h-6 w-6 before:absolute before:top-1/2 before:left-1/2 before:h-11 before:w-11 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n aria-expanded={!state.collapsed}\n aria-controls={`widget-content-${meta.widgetId}`}\n aria-label={\n state.collapsed\n ? `Expand ${meta.title ?? 'widget'}`\n : `Collapse ${meta.title ?? 'widget'}`\n }\n >\n <Icon\n name=\"fa-chevron-right\"\n className={cn(\n 'ease-out-strong h-4 w-4 transition-transform duration-200 motion-reduce:transition-none',\n !state.collapsed && 'rotate-90',\n )}\n />\n </Button>\n );\n}\n\n/**\n * The header's one trailing control (the design system's widget rules): a \"View all ›\"\n * link to where the data lives, or a period switch. Everything else goes in\n * the ⋯ menu.\n */\nexport type WidgetHeaderTrailing =\n | {\n kind: 'link';\n href: string;\n label: ReactNode;\n /** Open in a new tab. */\n external?: boolean;\n }\n | {\n kind: 'period';\n value: string;\n options: ReadonlyArray<{ value: string; label: string }>;\n onChange: (value: string) => void;\n /** Accessible name; defaults to \"Period\". */\n label?: string;\n };\n\nfunction HeaderTrailing({ trailing }: { trailing: WidgetHeaderTrailing }) {\n if (trailing.kind === 'link') {\n const link = trailing.external ? (\n <a href={trailing.href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={trailing.href} />\n );\n\n return (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n render={link}\n nativeButton={false}\n data-test=\"widget-header-link\"\n >\n {trailing.label}\n <Icon name=\"fa-chevron-right\" className=\"h-3 w-3\" aria-hidden />\n </Button>\n );\n }\n\n return (\n <Select\n value={trailing.value}\n onValueChange={(value) => {\n if (typeof value === 'string') trailing.onChange(value);\n }}\n >\n <SelectTrigger\n size=\"sm\"\n aria-label={trailing.label ?? 'Period'}\n data-test=\"widget-header-period\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {trailing.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n\nconst VERDICT_BADGE_TONE = {\n attention: 'warning',\n critical: 'destructive',\n degraded: 'warning',\n unknown: 'neutral',\n} as const;\n\n/** Only the verdicts that ask something of the owner fill their pill. */\nconst VERDICT_BADGE_PROMINENT = {\n attention: true,\n critical: true,\n degraded: false,\n unknown: false,\n} as const;\n\n/**\n * The verdict under the title. Anything but `clear` is a status pill, the\n * words carrying the tone and the dot confirming it. `clear` is plain ink and\n * a check, no colour at all (plan 251 D24): calm is the absence of colour,\n * so colour on a dashboard always means \"look here\".\n */\nfunction VerdictLine({ verdict }: { verdict: WidgetVerdict }) {\n if (verdict.tone === 'clear') {\n return (\n <p\n className=\"text-foreground text-meta flex min-w-0 items-center gap-1.5\"\n data-test=\"widget-verdict\"\n data-verdict=\"clear\"\n >\n <Icon\n name=\"fa-circle-check\"\n className=\"h-3.5 w-3.5 shrink-0\"\n aria-hidden\n />\n <span className=\"truncate\">{verdict.sentence}</span>\n </p>\n );\n }\n\n return (\n <StatusBadge\n tone={VERDICT_BADGE_TONE[verdict.tone]}\n prominent={VERDICT_BADGE_PROMINENT[verdict.tone]}\n className=\"mt-0.5 max-w-full\"\n data-test=\"widget-verdict\"\n data-verdict={verdict.tone}\n >\n <span className=\"truncate\">{verdict.sentence}</span>\n </StatusBadge>\n );\n}\n\n/** Widgets already warned about `children` beside `trailing`, so each warns once. */\nconst warnedChildrenWithTrailing = new Set<string>();\n\nfunction WidgetHeader({\n title,\n subtitle,\n description,\n context,\n trailing,\n menu,\n children,\n}: {\n /** Override the provider's title — useful when the rendered name differs from the config name. */\n title?: string;\n /**\n * Override the provider's subtitle. It renders as the context line when\n * `context` is not set.\n */\n subtitle?: string;\n /** Override the provider's description — useful for widget-computed values. */\n description?: string;\n /**\n * One muted line under the title that frames the data: \"This month\",\n * \"As of today\", \"3 accounts\". A verdict that needs the owner replaces it;\n * a clear one joins it (\"This month · All caught up\").\n */\n context?: ReactNode;\n /** At most one control on the right: a \"View all ›\" link or a period switch. */\n trailing?: WidgetHeaderTrailing;\n /**\n * `Widget.MenuItem`s and `Widget.MenuChoice`s placed at the top of the\n * header's ⋯ menu: occasional actions (\"Open in QuickBooks\") and secondary\n * settings (a comparison basis) that don't earn the one trailing slot.\n */\n menu?: ReactNode;\n /**\n * @deprecated Free controls beside the ⋯ menu. Use `trailing` for the one\n * control a header carries and `menu` for the rest; `children` goes away\n * in a later major release.\n */\n children?: ReactNode;\n}) {\n const { meta, state, data } = useWidget();\n const effectiveTitle = title ?? meta.title;\n const effectiveDescription = description ?? meta.description;\n const contextLine = context ?? subtitle ?? meta.subtitle;\n // A verdict speaks for data on screen, so it shows only while active.\n const verdict = state.state === 'active' ? data?.verdict : undefined;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n children &&\n trailing &&\n !warnedChildrenWithTrailing.has(meta.widgetId)\n ) {\n warnedChildrenWithTrailing.add(meta.widgetId);\n console.warn(\n `Widget.Header (${meta.widgetId}): pass \\`trailing\\` or \\`children\\`, not both. \\`children\\` is deprecated; move other controls into \\`menu\\`.`,\n );\n }\n\n if (!effectiveTitle) return null;\n\n const titleNode = effectiveDescription ? (\n <>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger\n render={<CardTitle className=\"text-title cursor-help truncate\" />}\n >\n {effectiveTitle}\n </TooltipTrigger>\n <TooltipContent>\n <p>{effectiveDescription}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n <span className=\"sr-only\">{effectiveDescription}</span>\n </>\n ) : (\n <CardTitle className=\"text-title truncate\">{effectiveTitle}</CardTitle>\n );\n\n return (\n <CardHeader className=\"flex-shrink-0 px-5 pt-4 pb-3\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-start gap-2.5\">\n {meta.isCollapsible ? <CollapseButton /> : null}\n <div className=\"min-w-0 space-y-0.5\">\n {titleNode}\n {verdict && verdict.tone !== 'clear' ? (\n <VerdictLine verdict={verdict} />\n ) : contextLine ? (\n <p\n className=\"text-muted-foreground text-meta truncate\"\n data-test=\"widget-header-context\"\n >\n {contextLine}\n {verdict ? (\n <>\n {' · '}\n <span data-test=\"widget-verdict\" data-verdict=\"clear\">\n {verdict.sentence}\n </span>\n </>\n ) : null}\n </p>\n ) : verdict ? (\n <VerdictLine verdict={verdict} />\n ) : null}\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {trailing ? <HeaderTrailing trailing={trailing} /> : null}\n {children}\n <WidgetMenu items={menu} />\n </div>\n </div>\n </CardHeader>\n );\n}\n\n/**\n * The actions every widget shares, whatever it renders: open its full\n * surface, reload it, pin or unpin it. Each item needs something from the host\n * or the widget's data layer, so the menu shows only what applies — and\n * nothing at all when nothing does.\n */\nfunction WidgetMenu({ items }: { items?: ReactNode }) {\n const { state, actions, meta, data } = useWidget();\n const refresh = state.state === 'active' ? data?.refresh : undefined;\n const hasNavigation = !!items || !!meta.openHref || !!refresh;\n\n if (!hasNavigation && !meta.isPinnable) return null;\n\n const title = meta.title ?? 'widget';\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"text-muted-foreground hover:text-foreground\"\n aria-label={`Actions for ${title}`}\n data-test={`widget-menu-${meta.widgetId}`}\n />\n }\n >\n <Icon name=\"fa-ellipsis\" className=\"h-4 w-4\" aria-hidden />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-48\">\n {items}\n {meta.openHref ? (\n <DropdownMenuItem render={<Link href={meta.openHref} />}>\n <Icon name=\"fa-arrow-up-right-from-square\" aria-hidden />\n <Trans\n i18nKey=\"dashboard:widgetOpenInWorkspace\"\n defaults=\"Open in workspace\"\n />\n </DropdownMenuItem>\n ) : null}\n {refresh ? (\n <DropdownMenuItem onClick={refresh} disabled={data?.refreshing}>\n <Icon name=\"fa-arrows-rotate\" aria-hidden />\n <Trans i18nKey=\"dashboard:widgetRefresh\" defaults=\"Refresh\" />\n </DropdownMenuItem>\n ) : null}\n {hasNavigation && meta.isPinnable ? <DropdownMenuSeparator /> : null}\n {meta.isPinnable ? (\n <DropdownMenuItem\n onClick={actions.togglePinned}\n disabled={state.pendingPin}\n data-test={`widget-menu-pin-${meta.widgetId}`}\n >\n <Icon\n name={state.pinned ? 'fa-thumbtack-slash' : 'fa-thumbtack'}\n aria-hidden\n />\n {state.pinned ? (\n <Trans\n i18nKey=\"dashboard:widgetUnpin\"\n defaults=\"Unpin from board\"\n />\n ) : (\n <Trans i18nKey=\"dashboard:widgetPin\" defaults=\"Pin to board\" />\n )}\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/**\n * One widget-specific entry in the header's ⋯ menu; pass it through\n * `Widget.Header`'s `menu` prop. With `href` it is a link, opened in a new tab\n * when `external`; otherwise it runs `onSelect`.\n */\nfunction WidgetMenuItem({\n icon,\n href,\n external = false,\n onSelect,\n disabled,\n children,\n}: {\n /** A Font Awesome class, e.g. `fa-envelope`. */\n icon?: string;\n href?: string;\n external?: boolean;\n onSelect?: () => void;\n disabled?: boolean;\n children: ReactNode;\n}) {\n const link = !href ? undefined : external ? (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" />\n ) : (\n <Link href={href} />\n );\n\n return (\n <DropdownMenuItem render={link} onClick={onSelect} disabled={disabled}>\n <Icon\n name={\n icon ??\n (external ? 'fa-arrow-up-right-from-square' : 'fa-arrow-right')\n }\n aria-hidden\n />\n {children}\n </DropdownMenuItem>\n );\n}\n\n/**\n * A setting that doesn't earn the header's one trailing slot (a comparison\n * basis, an as-of month), as a submenu of choices in the ⋯ menu. Pass it\n * through `Widget.Header`'s `menu` prop.\n */\nfunction WidgetMenuChoice<Value extends string>({\n icon,\n label,\n value,\n options,\n onChange,\n}: {\n /** A Font Awesome class, e.g. `fa-scale-balanced`. */\n icon?: string;\n label: ReactNode;\n value: Value;\n options: ReadonlyArray<{ value: Value; label: ReactNode }>;\n onChange: (value: Value) => void;\n}) {\n const current = options.find((option) => option.value === value);\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Icon name={icon ?? 'fa-sliders'} aria-hidden />\n <span className=\"flex-1\">{label}</span>\n {current ? (\n <span className=\"text-muted-foreground text-fine\">\n {current.label}\n </span>\n ) : null}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"min-w-44\">\n <DropdownMenuRadioGroup\n value={value}\n onValueChange={(next) => {\n const match = options.find((option) => option.value === next);\n if (match) onChange(match.value);\n }}\n >\n {options.map((option) => (\n <DropdownMenuRadioItem key={option.value} value={option.value}>\n {option.label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/**\n * \"Updated 3 minutes ago\" under an active widget whose data layer reports\n * when it last loaded (see `Widget.DataState`'s `updatedAt`).\n */\nfunction WidgetFreshness() {\n const { state, data } = useWidget();\n const updated = useRelativeTime(data?.updatedAt);\n\n if (state.state !== 'active' || state.collapsed || !updated) return null;\n\n return (\n <div\n className=\"text-muted-foreground border-border text-fine flex shrink-0 items-center gap-1.5 border-t px-5 py-2.5\"\n aria-live=\"polite\"\n >\n {data?.refreshing ? (\n <>\n <Icon\n name=\"fa-arrows-rotate\"\n className=\"h-3 w-3 animate-spin\"\n aria-hidden\n />\n <Trans i18nKey=\"dashboard:widgetRefreshing\" defaults=\"Refreshing…\" />\n </>\n ) : (\n <Trans\n i18nKey=\"dashboard:widgetUpdated\"\n defaults=\"Updated {{time}}\"\n values={{ time: updated }}\n />\n )}\n </div>\n );\n}\n\n// ─── State-gated content ────────────────────────────────────────────────────\n\nfunction CollapsibleBody({\n collapsed,\n maxContentHeight,\n widgetId,\n children,\n}: {\n collapsed: boolean;\n maxContentHeight?: string;\n widgetId: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'ease-out-strong grid min-h-0 flex-1 transition-all duration-300 motion-reduce:transition-none',\n collapsed ? 'grid-rows-[0fr]' : 'grid-rows-[1fr]',\n )}\n >\n <div className=\"min-h-0 overflow-hidden\">\n <CardContent\n id={`widget-content-${widgetId}`}\n className={cn(\n 'flex h-full min-h-0 flex-1 flex-col overflow-y-auto p-0',\n 'ease-out-strong transition-opacity duration-200 motion-reduce:transition-none',\n collapsed ? 'opacity-0' : 'opacity-100',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n maxContentHeight\n ? ({ '--widget-max-height': maxContentHeight } as CSSProperties)\n : undefined\n }\n >\n {children}\n </CardContent>\n </div>\n </div>\n );\n}\n\nfunction StaticBody({\n maxContentHeight,\n children,\n}: {\n maxContentHeight?: string;\n children: ReactNode;\n}) {\n const { innerRef, height } = useAnimatedHeight();\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n <div\n className={cn(\n 'h-(--body-height) overflow-hidden transition-all duration-250 ease-out motion-reduce:transition-none',\n maxContentHeight && 'max-h-(--widget-max-height)',\n )}\n style={\n {\n '--body-height': height === 'auto' ? 'auto' : `${height}px`,\n '--widget-max-height': maxContentHeight,\n } as CSSProperties\n }\n >\n <div ref={innerRef}>{children}</div>\n </div>\n </CardContent>\n );\n}\n\n/**\n * The standard padded body for content rendered inside `Widget.Active`.\n *\n * `Widget.Active`'s own `CardContent` renders `p-0` — deliberately, so a\n * full-bleed chart or table can run edge-to-edge inside the card. That means\n * ordinary content (text, rows, a KPI readout) is left flush against the\n * card's sides while `Widget.Header` stays inset (`px-5`) unless the body\n * supplies its own padding. `Widget.Body` is that padding: `px-5` matches\n * the header's horizontal inset so header and body align, `pt-4 pb-5`\n * balances the header's `pb-3`/card's bottom edge.\n *\n * Every widget wraps its content in it:\n *\n * ```tsx\n * <Widget.Active>\n * <Widget.Body>{/* text, a Stat, a form *\\/}</Widget.Body>\n * </Widget.Active>\n * ```\n *\n * Pass `flush` when the content runs to the card's edges: edge-to-edge rows\n * that pad themselves, a chart, a table with its own header row, an image.\n */\nfunction WidgetBody({\n flush = false,\n className,\n children,\n}: {\n /**\n * Drop the padding for content that runs to the card's edges: edge-to-edge\n * rows (which pad themselves, `px-5 py-3`), a full-bleed chart, an image.\n */\n flush?: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <div\n className={cn(\n 'flex flex-1 flex-col',\n flush ? 'pb-2' : 'gap-4 px-5 pt-4 pb-5',\n className,\n )}\n data-flush={flush || undefined}\n >\n {children}\n </div>\n );\n}\n\n/**\n * Renders `children` once the widget's state is `active`. Its `CardContent`\n * is flush (`p-0`); wrap content in `Widget.Body`, which pads it to line up\n * with the header, or `Widget.Body flush` for edge-to-edge rows and charts.\n * Never hand-roll a `px-*` wrapper.\n */\nfunction WidgetActive({ children }: { children: ReactNode }) {\n const { state, meta, data } = useWidget();\n if (state.state !== 'active') return null;\n const body = (\n <WidgetErrorBoundary widgetId={meta.widgetId} onRetry={data?.refresh}>\n {children}\n </WidgetErrorBoundary>\n );\n return meta.isCollapsible ? (\n <CollapsibleBody\n collapsed={state.collapsed}\n maxContentHeight={meta.maxContentHeight}\n widgetId={meta.widgetId}\n >\n {body}\n </CollapsibleBody>\n ) : (\n <StaticBody maxContentHeight={meta.maxContentHeight}>{body}</StaticBody>\n );\n}\n\n/**\n * Shows while the widget loads: a skeleton shaped like its body (`variant`,\n * `rows` by default), never a spinner.\n */\nfunction WidgetLoading({\n variant,\n children,\n}: {\n variant?: WidgetSkeletonVariant;\n children?: ReactNode;\n}) {\n const { state } = useWidget();\n if (state.state !== 'loading') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetLoadingSkeleton variant={variant} />}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget's data failed to load. Offers Try again whenever the\n * widget reports `onRefresh` through `Widget.DataState`. `title` and\n * `description` replace the default copy with something specific (\"Couldn't\n * load your inbox\").\n */\nfunction WidgetError({\n title,\n description,\n children,\n}: {\n title?: ReactNode;\n description?: ReactNode;\n children?: ReactNode;\n}) {\n const { state, data } = useWidget();\n if (state.state !== 'error') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetErrorState\n title={title}\n description={description}\n onRetry={data?.refresh}\n retrying={data?.refreshing}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * Shows when the widget can't reach its data. Give it a `reason`:\n * `not-connected` (one Connect button in `action`), `no-access` (a calm note\n * pointing to an admin) or `setup-needed`. `integrationName` defaults to the\n * host's source name.\n */\nfunction WidgetInactive({\n children,\n integrationName,\n ...props\n}: WidgetInactiveStateProps & { children?: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'inactive') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? (\n <WidgetInactiveState\n integrationName={integrationName ?? meta.source?.name}\n {...props}\n />\n )}\n </CardContent>\n );\n}\n\n/**\n * What an active widget shows when it has nothing to list. Render it inside\n * `Widget.Active`. Positive by default (\"You're all caught up\"), because an\n * empty queue is good news; `tone=\"neutral\"` for an empty search.\n */\nfunction WidgetEmpty(props: WidgetEmptyStateProps) {\n return <WidgetEmptyState {...props} />;\n}\n\nfunction WidgetDisabled({ children }: { children?: ReactNode }) {\n const { state } = useWidget();\n if (state.state !== 'disabled') return null;\n return (\n <CardContent className=\"flex min-h-0 flex-1 flex-col p-0\">\n {children ?? <WidgetDisabledState />}\n </CardContent>\n );\n}\n\n// ─── Footers ────────────────────────────────────────────────────────────────\n\nfunction WidgetFooter({ children }: { children: ReactNode }) {\n const { state, meta } = useWidget();\n if (state.state !== 'active') return null;\n return (\n <CardFooter\n className={cn(\n 'ease-out-strong flex-shrink-0 pb-6 transition-opacity duration-200 motion-reduce:transition-none',\n meta.isCollapsible && state.collapsed\n ? 'pointer-events-none opacity-0'\n : 'opacity-100',\n )}\n aria-hidden={meta.isCollapsible && state.collapsed}\n >\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetActions({ children }: { children: ReactNode }) {\n return (\n <CardFooter className=\"flex-shrink-0 justify-end border-t py-3\">\n {children}\n </CardFooter>\n );\n}\n\nfunction WidgetAskFooter({ context }: { context?: WidgetAskContext }) {\n const { state, meta, data } = useWidget();\n const effectiveContext = context ?? meta.askContext;\n const shouldShow =\n (meta.aiFooterEnabled || !!effectiveContext) &&\n state.state === 'active' &&\n !state.collapsed;\n if (!shouldShow) return null;\n const base = effectiveContext ?? {\n widgetId: meta.widgetId,\n title: meta.title ?? meta.widgetId,\n snapshot: null,\n suggestedPrompt: `Tell me about ${meta.title ?? 'this widget'}.`,\n };\n return <WidgetAskBar context={withVerdict(base, data?.verdict)} />;\n}\n\n/**\n * Adds the widget's own conclusion to what the assistant sees, so an answer\n * starts from the verdict on the card instead of re-deriving it.\n */\nfunction withVerdict(\n context: WidgetAskContext,\n verdict: WidgetVerdict | undefined,\n): WidgetAskContext {\n if (!verdict) return context;\n return {\n ...context,\n snapshot: {\n ...context.snapshot,\n verdict: {\n tone: verdict.tone,\n sentence: verdict.sentence,\n ...(verdict.count !== undefined ? { count: verdict.count } : {}),\n },\n },\n };\n}\n\n/**\n * Renders a subtle \"data may be stale\" banner when the widget's integration is\n * `degraded` (but still active). Unhealthy integrations route to `disabled`\n * instead, so this only fires for the degraded middle ground.\n */\nfunction WidgetHealthFooter() {\n const { state, meta } = useWidget();\n const lastSuccessAt = toEpochMs(meta.health?.lastSuccessAt);\n const lastSynced = useRelativeTime(lastSuccessAt);\n const shouldShow =\n state.state === 'active' &&\n !state.collapsed &&\n meta.health?.status === 'degraded';\n if (!shouldShow) return null;\n return (\n <div className=\"text-warning border-warning/30 bg-warning/5 text-fine flex items-center gap-2 border-t px-4 py-2\">\n <Icon\n name=\"fa-circle-exclamation\"\n className=\"h-4 w-4 shrink-0\"\n aria-hidden\n />\n <span>\n {lastSynced ? (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNoticeSince\"\n defaults=\"Data may be out of date. Last synced {{time}}.\"\n values={{ time: lastSynced }}\n />\n ) : (\n <Trans\n i18nKey=\"common:integrationHealth.degradedWidgetNotice\"\n defaults=\"This integration is degraded — data may be stale.\"\n />\n )}\n </span>\n </div>\n );\n}\n\nfunction toEpochMs(\n value: number | string | Date | null | undefined,\n): number | undefined {\n if (value === null || value === undefined) return undefined;\n const ms =\n value instanceof Date ? value.getTime() : new Date(value).getTime();\n return Number.isFinite(ms) && ms > 0 ? ms : undefined;\n}\n\n// ─── Data state override ────────────────────────────────────────────────────\n\n/**\n * Wraps children in a sub-provider that overrides the effective render state\n * with the widget's own data loading / error state. Only overrides when the\n * parent state is `active` — so the integration's `inactive` / `disabled` /\n * `loading` (initial) states still win.\n *\n * Read the parent integration state BEFORE wrapping in this component if you\n * need it to gate data fetching:\n *\n * ```tsx\n * const { state } = use(WidgetContext);\n * const integrationActive = state.state === 'active';\n * const { isLoading, isError } = useMyData(accountId, integrationActive);\n * return (\n * <Widget.DataState loading={isLoading} error={isError}>\n * <Widget.Card>…</Widget.Card>\n * </Widget.DataState>\n * );\n * ```\n *\n * Pass `onRefresh`, `refreshing` and `updatedAt` to give the widget the\n * shared Refresh menu item, a Try again button on its error view, and an\n * \"Updated 3 minutes ago\" footer. With TanStack Query:\n *\n * ```tsx\n * <Widget.DataState\n * loading={query.isLoading}\n * error={query.isError}\n * onRefresh={() => void query.refetch()}\n * refreshing={query.isFetching}\n * updatedAt={query.dataUpdatedAt}\n * >\n * ```\n */\nfunction WidgetDataState({\n loading,\n error,\n inactive,\n onRefresh,\n refreshing = false,\n updatedAt,\n verdict,\n children,\n}: {\n loading?: boolean;\n error?: boolean;\n /**\n * Force the `inactive` render state even though the integration itself is\n * active. Use for widget-level \"not connected\" states (e.g. the product is\n * activated but the upstream OAuth connection is missing). Takes priority\n * over `loading` / `error`.\n */\n inactive?: boolean;\n /** Reloads the widget's data. */\n onRefresh?: () => void;\n /** A reload is in flight. */\n refreshing?: boolean;\n /**\n * When the data on screen last loaded successfully: epoch milliseconds, an\n * ISO string or a `Date`. `0` means never, which TanStack Query's\n * `dataUpdatedAt` reports before the first success.\n */\n updatedAt?: number | string | Date | null;\n /**\n * The widget's verdict on its data (the design system's widget rules): `{ tone,\n * sentence, count? }`. Compute it with the same function the integration's\n * server `getAttention` uses, so the card and home's Needs you agree.\n */\n verdict?: WidgetVerdict;\n children: ReactNode;\n}) {\n const parent = useWidget();\n const overrideState: WidgetRenderState =\n parent.state.state !== 'active'\n ? parent.state.state\n : inactive\n ? 'inactive'\n : loading\n ? 'loading'\n : error\n ? 'error'\n : 'active';\n const updatedAtMs = toEpochMs(updatedAt);\n const reportsData =\n onRefresh !== undefined ||\n updatedAtMs !== undefined ||\n verdict !== undefined;\n const value = useMemo(\n () => ({\n state: { ...parent.state, state: overrideState },\n actions: parent.actions,\n meta: parent.meta,\n data: reportsData\n ? { updatedAt: updatedAtMs, refreshing, refresh: onRefresh, verdict }\n : parent.data,\n }),\n [\n parent.state,\n parent.actions,\n parent.meta,\n parent.data,\n overrideState,\n reportsData,\n updatedAtMs,\n refreshing,\n onRefresh,\n verdict,\n ],\n );\n return <WidgetContext value={value}>{children}</WidgetContext>;\n}\n\n// ─── Compound export ────────────────────────────────────────────────────────\n\nexport const Widget = {\n Card: WidgetCard,\n Header: WidgetHeader,\n MenuItem: WidgetMenuItem,\n MenuChoice: WidgetMenuChoice,\n DataState: WidgetDataState,\n Active: WidgetActive,\n Body: WidgetBody,\n Empty: WidgetEmpty,\n Loading: WidgetLoading,\n Error: WidgetError,\n Inactive: WidgetInactive,\n Disabled: WidgetDisabled,\n Footer: WidgetFooter,\n Actions: WidgetActions,\n AskFooter: WidgetAskFooter,\n HealthFooter: WidgetHealthFooter,\n};\n"]}
@@ -105,8 +105,8 @@ export type ExperiencePage = (Omit<ExperienceOverviewPageInput, 'integrations'>
105
105
  * A layout the experience suggests: workspaces (named groups of widgets and
106
106
  * pages) a Source admin can apply. Audiences are free-form NAMES, not roles or
107
107
  * permissions: a package cannot know a Source's audiences, so the host maps a
108
- * name to the Source audience of the same name and leaves an item with no
109
- * match for everyone.
108
+ * name to the Source's business type (level-1 audience) of the same name and
109
+ * leaves an item with no match for everyone.
110
110
  */
111
111
  export type ExperienceSuggestedLayout = SuggestedLayout;
112
112
  /** One reads-only section of the review queue; `read` must be a READ op of the integration. */
@@ -1 +1 @@
1
- {"version":3,"file":"define-experience.js","sourceRoot":"","sources":["../../src/experience/define-experience.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EAGrB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AA0BpC,MAAM,qBAAqB,GAAsB;IAC/C,OAAO;IACP,QAAQ;IACR,SAAS;IACT,UAAU;IACV,OAAO;IACP,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,WAAW;IACX,SAAS;CACV,CAAC;AAuJF,SAAS,aAAa,CAAC,IAAyB;;IAC9C,MAAM,IAAI,SAAuB,IAAI,CAAC,IAAI,mCAAI,QAAQ,CAAC;IACvD,MAAM,OAAO,GAAI,IAA2B,CAAC,IAAI,CAAC;IAClD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,CAAC,EAAE,+CAA+C,CACxG,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,EAA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,MAAM;gBAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type { ComponentType } from 'react';\n\nimport {\n EXPERIENCE_PAGE_KINDS,\n SuggestedLayoutSchema,\n type ExperiencePageKind,\n type SuggestedLayout,\n surfaceProblems,\n} from '@ekanos/integration-schema';\n\nimport type { ReadOperationKey, IntegrationName } from './types';\nimport type { WorkflowTemplate } from './workflow-template';\n\n/**\n * Keys that belong to an INTEGRATION and have no meaning on an experience.\n * Typed `never` so passing one is a compile error that names the key; the\n * runtime check in {@link defineExperience} catches the same keys from\n * untyped code.\n */\nexport interface IntegrationOnlyKeys {\n oauth?: never;\n egress?: never;\n storage?: never;\n webhooks?: never;\n tools?: never;\n actions?: never;\n connection?: never;\n activation?: never;\n events?: never;\n agentEvents?: never;\n schedules?: never;\n secrets?: never;\n}\n\nconst INTEGRATION_ONLY_KEYS: readonly string[] = [\n 'oauth',\n 'egress',\n 'storage',\n 'webhooks',\n 'tools',\n 'actions',\n 'connection',\n 'activation',\n 'events',\n 'agentEvents',\n 'schedules',\n 'secrets',\n];\n\nexport type ExperienceWidgetWidth = 'compact' | 'half' | 'full';\n\nexport interface ExperienceWidget {\n /** kebab-case, unique within the experience. */\n id: string;\n title: string;\n /** Integrations this widget calls. Checked against `ekanos.json` `integrations` by `ekanos check`. */\n integrations: readonly IntegrationName[];\n width?: ExperienceWidgetWidth;\n /**\n * A plain React component. It receives no integration props: it calls\n * `useOperation` / `useOperationMutation` and renders with `@ekanos/ui`,\n * exactly as an integration widget does today.\n */\n component: ComponentType;\n isCollapsible?: boolean;\n isPinnable?: boolean;\n aiFooterEnabled?: boolean;\n}\n\n/** What a custom page's component receives. */\nexport interface ExperiencePageProps {\n /**\n * The route below the page's own path, as segments: `[]` at the page itself,\n * `['archive']` at `<page path>/archive`. Only the sub-routes a page declares\n * in `routes` are served.\n */\n path: string[];\n}\n\nexport interface ExperiencePageRoute {\n /** kebab-case segments joined by `/`, relative to the page: `archive`, `drafts/new`. */\n path: string;\n title: string;\n}\n\ninterface ExperiencePageBase {\n /** kebab-case, unique within the experience. */\n id: string;\n title: string;\n}\n\n/**\n * The experience's root, shown when someone opens it. Give it a `component`\n * for a hand-built landing page, or none for the host's default overview.\n * An experience has at most one.\n */\nexport interface ExperienceOverviewPageInput extends ExperiencePageBase {\n kind: 'overview';\n path?: never;\n integrations?: readonly IntegrationName[];\n component?: ComponentType<ExperiencePageProps>;\n}\n\n/**\n * A widget dashboard of the experience's own widgets, laid out by the host.\n * No component: `widgets` lists widget ids declared in this experience.\n */\nexport interface ExperienceCanvasPageInput extends ExperiencePageBase {\n kind: 'canvas';\n /** Route segment under the experience, e.g. `review`. */\n path: string;\n widgets: readonly string[];\n integrations?: readonly IntegrationName[];\n component?: never;\n}\n\n/** A page you build yourself. `kind` may be left out: this is the default. */\nexport interface ExperienceCustomPageInput extends ExperiencePageBase {\n kind?: 'custom';\n /** Route segment under the experience, e.g. `review`. */\n path: string;\n /** Sub-routes the component handles; it reads the remainder from its `path` prop. */\n routes?: readonly ExperiencePageRoute[];\n integrations: readonly IntegrationName[];\n component: ComponentType<ExperiencePageProps>;\n}\n\nexport type ExperiencePageInput =\n | ExperienceOverviewPageInput\n | ExperienceCanvasPageInput\n | ExperienceCustomPageInput;\n\n/** A page as `defineExperience` returns it: `kind` and `integrations` always set. */\nexport type ExperiencePage =\n | (Omit<ExperienceOverviewPageInput, 'integrations'> & {\n integrations: readonly IntegrationName[];\n })\n | (Omit<ExperienceCanvasPageInput, 'integrations'> & {\n integrations: readonly IntegrationName[];\n })\n | (Omit<ExperienceCustomPageInput, 'kind'> & { kind: 'custom' });\n\n/**\n * A layout the experience suggests: workspaces (named groups of widgets and\n * pages) a Source admin can apply. Audiences are free-form NAMES, not roles or\n * permissions: a package cannot know a Source's audiences, so the host maps a\n * name to the Source audience of the same name and leaves an item with no\n * match for everyone.\n */\nexport type ExperienceSuggestedLayout = SuggestedLayout;\n\n/** One reads-only section of the review queue; `read` must be a READ op of the integration. */\nexport type ReviewQueueSection = {\n [S in IntegrationName]: {\n id: string;\n integration: S;\n read: ReadOperationKey<S>;\n };\n}[IntegrationName];\n\nexport interface ExperienceReviewQueue {\n readsOnly: true;\n sections: readonly ReviewQueueSection[];\n}\n\n/** A declaration only: the host decides how the sidebar draws it. */\nexport interface ExperienceSidebar {\n section: string;\n icon: string;\n label: string;\n}\n\nexport interface ExperienceInput extends IntegrationOnlyKeys {\n /** kebab-case; must equal `slug` in `ekanos.json`. */\n slug: string;\n name: string;\n description?: string;\n sidebar?: ExperienceSidebar;\n widgets?: readonly ExperienceWidget[];\n pages?: readonly ExperiencePageInput[];\n workflows?: readonly WorkflowTemplate[];\n reviewQueue?: ExperienceReviewQueue;\n suggestedLayout?: ExperienceSuggestedLayout;\n}\n\nexport interface ExperienceDefinition {\n readonly kind: 'experience';\n readonly slug: string;\n readonly name: string;\n readonly description?: string;\n readonly sidebar?: ExperienceSidebar;\n readonly widgets: readonly ExperienceWidget[];\n readonly pages: readonly ExperiencePage[];\n readonly workflows: readonly WorkflowTemplate[];\n readonly reviewQueue?: ExperienceReviewQueue;\n readonly suggestedLayout?: ExperienceSuggestedLayout;\n}\n\nfunction normalizePage(page: ExperiencePageInput): ExperiencePage {\n const kind: ExperiencePageKind = page.kind ?? 'custom';\n const rawPath = (page as { path?: unknown }).path;\n if (kind === 'overview') {\n if (rawPath !== undefined) {\n throw new Error(\n `Invalid experience definition: overview page \"${page.id}\" is the experience's root and takes no path.`,\n );\n }\n } else if (typeof rawPath !== 'string' || rawPath === '') {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" needs a path (a kebab-case string).`,\n );\n }\n\n return {\n ...page,\n kind,\n integrations: page.integrations ?? [],\n } as ExperiencePage;\n}\n\nconst KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\nfunction assertUnique(kind: string, ids: readonly string[]): void {\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n throw new Error(\n `Invalid experience definition: ${kind} id \"${id}\" is declared twice.`,\n );\n }\n seen.add(id);\n }\n}\n\n/**\n * Declare an experience: widgets, pages, workflow templates and a reads-only\n * review queue that reach integrations only through their pinned contracts.\n *\n * Integrations are NOT declared here. They live in `ekanos.json` `integrations` (readable\n * without running code) and `ekanos codegen` types them; naming an integration that is\n * not there is a compile error, and `ekanos check` re-verifies it.\n *\n * @example\n * export default defineExperience({\n * slug: 'content-engine',\n * name: 'Content engine',\n * widgets: [{ id: 'queue', title: 'Queue', integrations: ['cms'], component: Queue }],\n * });\n */\nexport function defineExperience(input: ExperienceInput): ExperienceDefinition {\n const raw = input as unknown as Record<string, unknown>;\n for (const key of INTEGRATION_ONLY_KEYS) {\n if (raw[key] !== undefined) {\n throw new Error(\n `Invalid experience definition: \"${key}\" belongs to an integration. An experience reaches integrations only through the integrations it declares (ekanos.json \"integrations\").`,\n );\n }\n }\n if (!KEBAB.test(input.slug)) {\n throw new Error(\n `Invalid experience definition: slug \"${input.slug}\" must be kebab-case.`,\n );\n }\n if (input.name.trim() === '') {\n throw new Error('Invalid experience definition: name is required.');\n }\n\n const widgets = input.widgets ?? [];\n const pages = input.pages ?? [];\n const workflows = input.workflows ?? [];\n\n for (const widget of widgets) {\n if (!KEBAB.test(widget.id)) {\n throw new Error(\n `Invalid experience definition: widget id \"${widget.id}\" must be kebab-case.`,\n );\n }\n if (\n typeof widget.component !== 'function' &&\n typeof widget.component !== 'object'\n ) {\n throw new Error(\n `Invalid experience definition: widget \"${widget.id}\" needs a component.`,\n );\n }\n }\n const normalizedPages = pages.map(normalizePage);\n for (const page of normalizedPages) {\n if (!(EXPERIENCE_PAGE_KINDS as readonly string[]).includes(page.kind)) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" has kind \"${String(page.kind)}\"; use overview, canvas or custom.`,\n );\n }\n if (\n !KEBAB.test(page.id) ||\n (page.kind !== 'overview' && !KEBAB.test(page.path))\n ) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" id and path must be kebab-case.`,\n );\n }\n const component = (page as { component?: unknown }).component;\n if (page.kind === 'canvas' && component !== undefined) {\n throw new Error(\n `Invalid experience definition: canvas page \"${page.id}\" takes \"widgets\", not a component.`,\n );\n }\n if (\n page.kind === 'custom' &&\n typeof component !== 'function' &&\n typeof component !== 'object'\n ) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" needs a component.`,\n );\n }\n }\n if (input.suggestedLayout !== undefined) {\n const parsed = SuggestedLayoutSchema.safeParse(input.suggestedLayout);\n if (!parsed.success) {\n throw new Error(\n `Invalid experience definition: suggestedLayout is malformed: ${parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('; ')}.`,\n );\n }\n }\n const problems = surfaceProblems({\n widgets,\n pages: normalizedPages.map((page) => ({\n id: page.id,\n kind: page.kind,\n ...(page.kind === 'overview' ? {} : { path: page.path }),\n ...(page.kind === 'canvas' ? { widgets: page.widgets } : {}),\n ...(page.kind === 'custom' && page.routes ? { routes: page.routes } : {}),\n })),\n ...(input.suggestedLayout\n ? { suggestedLayout: input.suggestedLayout }\n : {}),\n });\n if (problems[0] !== undefined) {\n throw new Error(`Invalid experience definition: ${problems[0]}.`);\n }\n assertUnique(\n 'workflow template',\n workflows.map((w) => w.id),\n );\n\n if (input.reviewQueue) {\n if (input.reviewQueue.readsOnly !== true) {\n throw new Error(\n 'Invalid experience definition: reviewQueue.readsOnly must be true.',\n );\n }\n assertUnique(\n 'review queue section',\n input.reviewQueue.sections.map((s) => s.id),\n );\n }\n\n return Object.freeze({\n kind: 'experience' as const,\n slug: input.slug,\n name: input.name,\n ...(input.description === undefined\n ? {}\n : { description: input.description }),\n ...(input.sidebar === undefined ? {} : { sidebar: input.sidebar }),\n widgets: Object.freeze([...widgets]),\n pages: Object.freeze(normalizedPages),\n workflows: Object.freeze([...workflows]),\n ...(input.reviewQueue === undefined\n ? {}\n : { reviewQueue: input.reviewQueue }),\n ...(input.suggestedLayout === undefined\n ? {}\n : { suggestedLayout: input.suggestedLayout }),\n });\n}\n\n/** Integrations an experience definition touches, deduplicated (for `check`/manifest). */\nexport function slotsUsedBy(definition: ExperienceDefinition): string[] {\n const used = new Set<string>();\n for (const widget of definition.widgets)\n for (const s of widget.integrations) used.add(s);\n for (const page of definition.pages)\n for (const s of page.integrations) used.add(s);\n for (const section of definition.reviewQueue?.sections ?? [])\n used.add(section.integration);\n for (const template of definition.workflows) {\n for (const s of template.build())\n if (s.type === 'tool') used.add(s.integration);\n }\n\n return [...used].sort();\n}\n"]}
1
+ {"version":3,"file":"define-experience.js","sourceRoot":"","sources":["../../src/experience/define-experience.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EAGrB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AA0BpC,MAAM,qBAAqB,GAAsB;IAC/C,OAAO;IACP,QAAQ;IACR,SAAS;IACT,UAAU;IACV,OAAO;IACP,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,WAAW;IACX,SAAS;CACV,CAAC;AAuJF,SAAS,aAAa,CAAC,IAAyB;;IAC9C,MAAM,IAAI,SAAuB,IAAI,CAAC,IAAI,mCAAI,QAAQ,CAAC;IACvD,MAAM,OAAO,GAAI,IAA2B,CAAC,IAAI,CAAC;IAClD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,CAAC,EAAE,+CAA+C,CACxG,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,wCAAwC,IAAI,CAAC,EAAE,uCAAuC,CACvF,CAAC;IACJ,CAAC;IA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,CAAC,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import type { ComponentType } from 'react';\n\nimport {\n EXPERIENCE_PAGE_KINDS,\n SuggestedLayoutSchema,\n type ExperiencePageKind,\n type SuggestedLayout,\n surfaceProblems,\n} from '@ekanos/integration-schema';\n\nimport type { ReadOperationKey, IntegrationName } from './types';\nimport type { WorkflowTemplate } from './workflow-template';\n\n/**\n * Keys that belong to an INTEGRATION and have no meaning on an experience.\n * Typed `never` so passing one is a compile error that names the key; the\n * runtime check in {@link defineExperience} catches the same keys from\n * untyped code.\n */\nexport interface IntegrationOnlyKeys {\n oauth?: never;\n egress?: never;\n storage?: never;\n webhooks?: never;\n tools?: never;\n actions?: never;\n connection?: never;\n activation?: never;\n events?: never;\n agentEvents?: never;\n schedules?: never;\n secrets?: never;\n}\n\nconst INTEGRATION_ONLY_KEYS: readonly string[] = [\n 'oauth',\n 'egress',\n 'storage',\n 'webhooks',\n 'tools',\n 'actions',\n 'connection',\n 'activation',\n 'events',\n 'agentEvents',\n 'schedules',\n 'secrets',\n];\n\nexport type ExperienceWidgetWidth = 'compact' | 'half' | 'full';\n\nexport interface ExperienceWidget {\n /** kebab-case, unique within the experience. */\n id: string;\n title: string;\n /** Integrations this widget calls. Checked against `ekanos.json` `integrations` by `ekanos check`. */\n integrations: readonly IntegrationName[];\n width?: ExperienceWidgetWidth;\n /**\n * A plain React component. It receives no integration props: it calls\n * `useOperation` / `useOperationMutation` and renders with `@ekanos/ui`,\n * exactly as an integration widget does today.\n */\n component: ComponentType;\n isCollapsible?: boolean;\n isPinnable?: boolean;\n aiFooterEnabled?: boolean;\n}\n\n/** What a custom page's component receives. */\nexport interface ExperiencePageProps {\n /**\n * The route below the page's own path, as segments: `[]` at the page itself,\n * `['archive']` at `<page path>/archive`. Only the sub-routes a page declares\n * in `routes` are served.\n */\n path: string[];\n}\n\nexport interface ExperiencePageRoute {\n /** kebab-case segments joined by `/`, relative to the page: `archive`, `drafts/new`. */\n path: string;\n title: string;\n}\n\ninterface ExperiencePageBase {\n /** kebab-case, unique within the experience. */\n id: string;\n title: string;\n}\n\n/**\n * The experience's root, shown when someone opens it. Give it a `component`\n * for a hand-built landing page, or none for the host's default overview.\n * An experience has at most one.\n */\nexport interface ExperienceOverviewPageInput extends ExperiencePageBase {\n kind: 'overview';\n path?: never;\n integrations?: readonly IntegrationName[];\n component?: ComponentType<ExperiencePageProps>;\n}\n\n/**\n * A widget dashboard of the experience's own widgets, laid out by the host.\n * No component: `widgets` lists widget ids declared in this experience.\n */\nexport interface ExperienceCanvasPageInput extends ExperiencePageBase {\n kind: 'canvas';\n /** Route segment under the experience, e.g. `review`. */\n path: string;\n widgets: readonly string[];\n integrations?: readonly IntegrationName[];\n component?: never;\n}\n\n/** A page you build yourself. `kind` may be left out: this is the default. */\nexport interface ExperienceCustomPageInput extends ExperiencePageBase {\n kind?: 'custom';\n /** Route segment under the experience, e.g. `review`. */\n path: string;\n /** Sub-routes the component handles; it reads the remainder from its `path` prop. */\n routes?: readonly ExperiencePageRoute[];\n integrations: readonly IntegrationName[];\n component: ComponentType<ExperiencePageProps>;\n}\n\nexport type ExperiencePageInput =\n | ExperienceOverviewPageInput\n | ExperienceCanvasPageInput\n | ExperienceCustomPageInput;\n\n/** A page as `defineExperience` returns it: `kind` and `integrations` always set. */\nexport type ExperiencePage =\n | (Omit<ExperienceOverviewPageInput, 'integrations'> & {\n integrations: readonly IntegrationName[];\n })\n | (Omit<ExperienceCanvasPageInput, 'integrations'> & {\n integrations: readonly IntegrationName[];\n })\n | (Omit<ExperienceCustomPageInput, 'kind'> & { kind: 'custom' });\n\n/**\n * A layout the experience suggests: workspaces (named groups of widgets and\n * pages) a Source admin can apply. Audiences are free-form NAMES, not roles or\n * permissions: a package cannot know a Source's audiences, so the host maps a\n * name to the Source's business type (level-1 audience) of the same name and\n * leaves an item with no match for everyone.\n */\nexport type ExperienceSuggestedLayout = SuggestedLayout;\n\n/** One reads-only section of the review queue; `read` must be a READ op of the integration. */\nexport type ReviewQueueSection = {\n [S in IntegrationName]: {\n id: string;\n integration: S;\n read: ReadOperationKey<S>;\n };\n}[IntegrationName];\n\nexport interface ExperienceReviewQueue {\n readsOnly: true;\n sections: readonly ReviewQueueSection[];\n}\n\n/** A declaration only: the host decides how the sidebar draws it. */\nexport interface ExperienceSidebar {\n section: string;\n icon: string;\n label: string;\n}\n\nexport interface ExperienceInput extends IntegrationOnlyKeys {\n /** kebab-case; must equal `slug` in `ekanos.json`. */\n slug: string;\n name: string;\n description?: string;\n sidebar?: ExperienceSidebar;\n widgets?: readonly ExperienceWidget[];\n pages?: readonly ExperiencePageInput[];\n workflows?: readonly WorkflowTemplate[];\n reviewQueue?: ExperienceReviewQueue;\n suggestedLayout?: ExperienceSuggestedLayout;\n}\n\nexport interface ExperienceDefinition {\n readonly kind: 'experience';\n readonly slug: string;\n readonly name: string;\n readonly description?: string;\n readonly sidebar?: ExperienceSidebar;\n readonly widgets: readonly ExperienceWidget[];\n readonly pages: readonly ExperiencePage[];\n readonly workflows: readonly WorkflowTemplate[];\n readonly reviewQueue?: ExperienceReviewQueue;\n readonly suggestedLayout?: ExperienceSuggestedLayout;\n}\n\nfunction normalizePage(page: ExperiencePageInput): ExperiencePage {\n const kind: ExperiencePageKind = page.kind ?? 'custom';\n const rawPath = (page as { path?: unknown }).path;\n if (kind === 'overview') {\n if (rawPath !== undefined) {\n throw new Error(\n `Invalid experience definition: overview page \"${page.id}\" is the experience's root and takes no path.`,\n );\n }\n } else if (typeof rawPath !== 'string' || rawPath === '') {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" needs a path (a kebab-case string).`,\n );\n }\n\n return {\n ...page,\n kind,\n integrations: page.integrations ?? [],\n } as ExperiencePage;\n}\n\nconst KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\nfunction assertUnique(kind: string, ids: readonly string[]): void {\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n throw new Error(\n `Invalid experience definition: ${kind} id \"${id}\" is declared twice.`,\n );\n }\n seen.add(id);\n }\n}\n\n/**\n * Declare an experience: widgets, pages, workflow templates and a reads-only\n * review queue that reach integrations only through their pinned contracts.\n *\n * Integrations are NOT declared here. They live in `ekanos.json` `integrations` (readable\n * without running code) and `ekanos codegen` types them; naming an integration that is\n * not there is a compile error, and `ekanos check` re-verifies it.\n *\n * @example\n * export default defineExperience({\n * slug: 'content-engine',\n * name: 'Content engine',\n * widgets: [{ id: 'queue', title: 'Queue', integrations: ['cms'], component: Queue }],\n * });\n */\nexport function defineExperience(input: ExperienceInput): ExperienceDefinition {\n const raw = input as unknown as Record<string, unknown>;\n for (const key of INTEGRATION_ONLY_KEYS) {\n if (raw[key] !== undefined) {\n throw new Error(\n `Invalid experience definition: \"${key}\" belongs to an integration. An experience reaches integrations only through the integrations it declares (ekanos.json \"integrations\").`,\n );\n }\n }\n if (!KEBAB.test(input.slug)) {\n throw new Error(\n `Invalid experience definition: slug \"${input.slug}\" must be kebab-case.`,\n );\n }\n if (input.name.trim() === '') {\n throw new Error('Invalid experience definition: name is required.');\n }\n\n const widgets = input.widgets ?? [];\n const pages = input.pages ?? [];\n const workflows = input.workflows ?? [];\n\n for (const widget of widgets) {\n if (!KEBAB.test(widget.id)) {\n throw new Error(\n `Invalid experience definition: widget id \"${widget.id}\" must be kebab-case.`,\n );\n }\n if (\n typeof widget.component !== 'function' &&\n typeof widget.component !== 'object'\n ) {\n throw new Error(\n `Invalid experience definition: widget \"${widget.id}\" needs a component.`,\n );\n }\n }\n const normalizedPages = pages.map(normalizePage);\n for (const page of normalizedPages) {\n if (!(EXPERIENCE_PAGE_KINDS as readonly string[]).includes(page.kind)) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" has kind \"${String(page.kind)}\"; use overview, canvas or custom.`,\n );\n }\n if (\n !KEBAB.test(page.id) ||\n (page.kind !== 'overview' && !KEBAB.test(page.path))\n ) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" id and path must be kebab-case.`,\n );\n }\n const component = (page as { component?: unknown }).component;\n if (page.kind === 'canvas' && component !== undefined) {\n throw new Error(\n `Invalid experience definition: canvas page \"${page.id}\" takes \"widgets\", not a component.`,\n );\n }\n if (\n page.kind === 'custom' &&\n typeof component !== 'function' &&\n typeof component !== 'object'\n ) {\n throw new Error(\n `Invalid experience definition: page \"${page.id}\" needs a component.`,\n );\n }\n }\n if (input.suggestedLayout !== undefined) {\n const parsed = SuggestedLayoutSchema.safeParse(input.suggestedLayout);\n if (!parsed.success) {\n throw new Error(\n `Invalid experience definition: suggestedLayout is malformed: ${parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('; ')}.`,\n );\n }\n }\n const problems = surfaceProblems({\n widgets,\n pages: normalizedPages.map((page) => ({\n id: page.id,\n kind: page.kind,\n ...(page.kind === 'overview' ? {} : { path: page.path }),\n ...(page.kind === 'canvas' ? { widgets: page.widgets } : {}),\n ...(page.kind === 'custom' && page.routes ? { routes: page.routes } : {}),\n })),\n ...(input.suggestedLayout\n ? { suggestedLayout: input.suggestedLayout }\n : {}),\n });\n if (problems[0] !== undefined) {\n throw new Error(`Invalid experience definition: ${problems[0]}.`);\n }\n assertUnique(\n 'workflow template',\n workflows.map((w) => w.id),\n );\n\n if (input.reviewQueue) {\n if (input.reviewQueue.readsOnly !== true) {\n throw new Error(\n 'Invalid experience definition: reviewQueue.readsOnly must be true.',\n );\n }\n assertUnique(\n 'review queue section',\n input.reviewQueue.sections.map((s) => s.id),\n );\n }\n\n return Object.freeze({\n kind: 'experience' as const,\n slug: input.slug,\n name: input.name,\n ...(input.description === undefined\n ? {}\n : { description: input.description }),\n ...(input.sidebar === undefined ? {} : { sidebar: input.sidebar }),\n widgets: Object.freeze([...widgets]),\n pages: Object.freeze(normalizedPages),\n workflows: Object.freeze([...workflows]),\n ...(input.reviewQueue === undefined\n ? {}\n : { reviewQueue: input.reviewQueue }),\n ...(input.suggestedLayout === undefined\n ? {}\n : { suggestedLayout: input.suggestedLayout }),\n });\n}\n\n/** Integrations an experience definition touches, deduplicated (for `check`/manifest). */\nexport function slotsUsedBy(definition: ExperienceDefinition): string[] {\n const used = new Set<string>();\n for (const widget of definition.widgets)\n for (const s of widget.integrations) used.add(s);\n for (const page of definition.pages)\n for (const s of page.integrations) used.add(s);\n for (const section of definition.reviewQueue?.sections ?? [])\n used.add(section.integration);\n for (const template of definition.workflows) {\n for (const s of template.build())\n if (s.type === 'tool') used.add(s.integration);\n }\n\n return [...used].sort();\n}\n"]}
@@ -5,8 +5,9 @@
5
5
  * An experience calls operations through an {@link ExperienceRuntime} and
6
6
  * through nothing else: no import of integration code, no `fetch` to an
7
7
  * integration route. The local harness implements it over its own
8
- * `/__ekanos/api/ops/run`; the host implements it over the installation's integration
9
- * route. Both answer with the same {@link OperationResult} and the same
8
+ * `/__ekanos/api/ops/run`; the host implements it over its experience route,
9
+ * `/api/experiences/<experience>/slots/…?account=<team>`, with the team's own
10
+ * connection to each integration (no install). Both answer with the same {@link OperationResult} and the same
10
11
  * refusal reasons, so an experience behaves identically in either.
11
12
  *
12
13
  * Isomorphic and dependency-free: types only (plus the re-exports below).
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/experience/runtime.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,yBAAyB,GAI1B,MAAM,SAAS,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/runtime` — the ONE seam between an experience and\n * an integration.\n *\n * An experience calls operations through an {@link ExperienceRuntime} and\n * through nothing else: no import of integration code, no `fetch` to an\n * integration route. The local harness implements it over its own\n * `/__ekanos/api/ops/run`; the host implements it over the installation's integration\n * route. Both answer with the same {@link OperationResult} and the same\n * refusal reasons, so an experience behaves identically in either.\n *\n * Isomorphic and dependency-free: types only (plus the re-exports below).\n */\nimport type { OperationResult } from '@ekanos/integration-schema';\n\nexport {\n OPERATION_REFUSAL_REASONS,\n type OperationError,\n type OperationRefusalReason,\n type OperationResult,\n} from './types';\n\n/** The channel a call arrives on; writes are judged by it (see `write_refused_on_channel`). */\nexport type OperationChannel = 'http' | 'rsc' | 'workflow';\n\n/**\n * Proof that a person approved one write. Opaque to the experience: the\n * runtime mints it (the harness approvals tray; the host approval gate) and\n * checks it. An experience may carry one back into `mutate(input, { approval })`.\n */\nexport interface ApprovalToken {\n readonly id: string;\n}\n\nexport interface OperationCallRequest {\n /** The integration name from `ekanos.json` `integrations` (its slug). */\n integration: string;\n /** `tool/<name>` or `action/<name>`. The version is the one `ekanos.json` pins. */\n op: string;\n input: unknown;\n channel: OperationChannel;\n approval?: ApprovalToken;\n}\n\nexport type IntegrationProvenance = 'registry' | 'local';\n\n/** What a runtime can say about an integration (for UI badges, never for widgets' logic). */\nexport interface IntegrationInfo {\n name: string;\n version: string;\n provenance: IntegrationProvenance;\n bindingMode?: string;\n runMode?: 'fixtures' | 'live';\n}\n\nexport interface ExperienceRuntime {\n /**\n * Run one operation. May take as long as a person takes to decide: a write\n * on an approval-gated channel resolves only once the approval tray has\n * answered (`write_not_approved` when it was rejected). Never throws for a\n * refusal: those are `{ ok: false, reason }`. A rejected promise means the\n * runtime itself is broken.\n */\n call(request: OperationCallRequest): Promise<OperationResult<unknown>>;\n integrations(): IntegrationInfo[];\n}\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/experience/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,yBAAyB,GAI1B,MAAM,SAAS,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/runtime` — the ONE seam between an experience and\n * an integration.\n *\n * An experience calls operations through an {@link ExperienceRuntime} and\n * through nothing else: no import of integration code, no `fetch` to an\n * integration route. The local harness implements it over its own\n * `/__ekanos/api/ops/run`; the host implements it over its experience route,\n * `/api/experiences/<experience>/slots/…?account=<team>`, with the team's own\n * connection to each integration (no install). Both answer with the same {@link OperationResult} and the same\n * refusal reasons, so an experience behaves identically in either.\n *\n * Isomorphic and dependency-free: types only (plus the re-exports below).\n */\nimport type { OperationResult } from '@ekanos/integration-schema';\n\nexport {\n OPERATION_REFUSAL_REASONS,\n type OperationError,\n type OperationRefusalReason,\n type OperationResult,\n} from './types';\n\n/** The channel a call arrives on; writes are judged by it (see `write_refused_on_channel`). */\nexport type OperationChannel = 'http' | 'rsc' | 'workflow';\n\n/**\n * Proof that a person approved one write. Opaque to the experience: the\n * runtime mints it (the harness approvals tray; the host approval gate) and\n * checks it. An experience may carry one back into `mutate(input, { approval })`.\n */\nexport interface ApprovalToken {\n readonly id: string;\n}\n\nexport interface OperationCallRequest {\n /** The integration name from `ekanos.json` `integrations` (its slug). */\n integration: string;\n /** `tool/<name>` or `action/<name>`. The version is the one `ekanos.json` pins. */\n op: string;\n input: unknown;\n channel: OperationChannel;\n approval?: ApprovalToken;\n}\n\nexport type IntegrationProvenance = 'registry' | 'local';\n\n/** What a runtime can say about an integration (for UI badges, never for widgets' logic). */\nexport interface IntegrationInfo {\n name: string;\n version: string;\n provenance: IntegrationProvenance;\n bindingMode?: string;\n runMode?: 'fixtures' | 'live';\n}\n\nexport interface ExperienceRuntime {\n /**\n * Run one operation. May take as long as a person takes to decide: a write\n * on an approval-gated channel resolves only once the approval tray has\n * answered (`write_not_approved` when it was rejected). Never throws for a\n * refusal: those are `{ ok: false, reason }`. A rejected promise means the\n * runtime itself is broken.\n */\n call(request: OperationCallRequest): Promise<OperationResult<unknown>>;\n integrations(): IntegrationInfo[];\n}\n"]}
@@ -93,6 +93,17 @@ export interface SerializeWorkflowOptions {
93
93
  * a template can never name an operation the contract lacks.
94
94
  */
95
95
  effectOf: (integration: string, op: string) => 'read' | 'write' | undefined;
96
+ /**
97
+ * The experience's slug, written on every tool step as `experience`. The
98
+ * host resolves the running team's connection from it at run time.
99
+ */
100
+ experience?: string;
101
+ /**
102
+ * @deprecated Pass `experience`. Written on every tool step as
103
+ * `installationId` when `experience` is absent; with neither, steps carry
104
+ * the deprecated `TEMPLATE_INSTALLATION_ID` placeholder so a caller built
105
+ * against 0.21 keeps producing a valid template.
106
+ */
96
107
  installationId?: string;
97
108
  }
98
109
  /**
@@ -60,7 +60,9 @@ export { TEMPLATE_INSTALLATION_ID };
60
60
  export function serializeWorkflowTemplate(template, options) {
61
61
  var _a;
62
62
  const steps = template.build();
63
- const installationId = (_a = options.installationId) !== null && _a !== void 0 ? _a : TEMPLATE_INSTALLATION_ID;
63
+ const target = options.experience !== undefined
64
+ ? { experience: options.experience }
65
+ : { installationId: (_a = options.installationId) !== null && _a !== void 0 ? _a : TEMPLATE_INSTALLATION_ID };
64
66
  const where = `workflow template "${template.id}"`;
65
67
  if (steps.length === 0)
66
68
  throw new Error(`${where}: build() returned no steps.`);
@@ -91,15 +93,7 @@ export function serializeWorkflowTemplate(template, options) {
91
93
  if (effect === undefined) {
92
94
  throw new Error(`${where}: step "${s.id}" calls ${s.integration} ${s.op}, which the pinned contract does not declare.`);
93
95
  }
94
- return {
95
- id: s.id,
96
- type: 'fusion_tool',
97
- tool: s.op,
98
- installationId,
99
- slot: s.integration,
100
- args: s.args,
101
- effect,
102
- };
96
+ return Object.assign(Object.assign({ id: s.id, type: 'fusion_tool', tool: s.op }, target), { slot: s.integration, args: s.args, effect });
103
97
  }
104
98
  case 'ai':
105
99
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-template.js","sourceRoot":"","sources":["../../src/experience/workflow-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AAYpC,MAAM,UAAU,GAAG,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAE1E,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC;AA8CD,MAAM,OAAO,GAAG,CAAC,OAAgC,EAAE,EAAE,CACnD,CAAA,OAAO,aAA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ACL,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EACL,QAAQ,CAAC,QAAQ,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;YACpB,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;QACnD,KAAK,EAAE,QAAQ;QACf,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import {\n TEMPLATE_INSTALLATION_ID,\n type WorkflowTemplate as EngineWorkflowTemplate,\n} from '@ekanos/integration-schema';\n\nimport type { OperationInput, OperationKey, IntegrationName } from './types';\n\n/**\n * A reference to an earlier step's output (`{ ref: 'draft.title' }`), the\n * workflow engine's operand shape. Build one with {@link ref}.\n */\nexport interface WorkflowRef {\n readonly ref: string;\n}\n\nexport function ref(path: string): WorkflowRef {\n if (path.trim() === '') throw new Error('ref(): path must not be empty.');\n\n return { ref: path };\n}\n\n/** Each input field may be literal or a reference to an earlier step's output. */\nexport type WithRefs<T> = T extends readonly unknown[]\n ? T | WorkflowRef\n : T extends object\n ? { [P in keyof T]: WithRefs<T[P]> | WorkflowRef }\n : T | WorkflowRef;\n\nexport interface StepOptions {\n /**\n * Step id(s) this step follows. Default: the previous step in `build()`\n * order (the first step follows nothing).\n */\n after?: string | readonly string[];\n}\n\nexport interface ToolStep {\n readonly type: 'tool';\n readonly id: string;\n readonly integration: string;\n /** `tool/<name>` or `action/<name>`; effect comes from the pinned contract. */\n readonly op: string;\n readonly args: Record<string, unknown>;\n readonly after?: readonly string[];\n}\n\nexport interface AiStep {\n readonly type: 'ai';\n readonly id: string;\n readonly kind: string;\n readonly instructions: string;\n readonly outputSchemaRef: string;\n readonly after?: readonly string[];\n}\n\nexport interface ApprovalStep {\n readonly type: 'approval';\n readonly id: string;\n readonly summary: string;\n readonly approverScope: 'account' | 'user';\n readonly after?: readonly string[];\n}\n\nexport type WorkflowStep = ToolStep | AiStep | ApprovalStep;\n\nconst afterOf = (options: StepOptions | undefined) =>\n options?.after === undefined\n ? {}\n : {\n after:\n typeof options.after === 'string'\n ? [options.after]\n : [...options.after],\n };\n\n/**\n * Step constructors for {@link defineWorkflowTemplate}.\n *\n * `step.tool` is typed from the generated registry: the integration, the operation\n * and its `args` are checked against the pinned contract. Whether a tool step\n * reads or writes is NOT authored; it is read from the contract at build, so a\n * template cannot call a write as if it were a read.\n */\nexport const step = {\n tool<S extends IntegrationName, K extends OperationKey<S>>(\n id: string,\n integration: S,\n op: K,\n args: WithRefs<OperationInput<S, K>>,\n options?: StepOptions,\n ): ToolStep {\n return {\n type: 'tool',\n id,\n integration,\n op,\n args: args as Record<string, unknown>,\n ...afterOf(options),\n };\n },\n ai(\n id: string,\n config: { instructions: string; outputSchemaRef: string; kind?: string },\n options?: StepOptions,\n ): AiStep {\n return {\n type: 'ai',\n id,\n kind: config.kind ?? 'draft',\n instructions: config.instructions,\n outputSchemaRef: config.outputSchemaRef,\n ...afterOf(options),\n };\n },\n approval(\n id: string,\n config: { summary: string; approverScope?: 'account' | 'user' },\n options?: StepOptions,\n ): ApprovalStep {\n return {\n type: 'approval',\n id,\n summary: config.summary,\n approverScope: config.approverScope ?? 'account',\n ...afterOf(options),\n };\n },\n};\n\nconst TEMPLATE_ID = /^[a-z][a-z0-9-]*$/;\nconst STEP_ID = /^[a-z][a-z0-9_]*$/;\nconst RESERVED_STEP_IDS = new Set(['trigger', 'item', 'loop', 'run']);\n\nexport interface WorkflowTemplateInput {\n /** kebab-case, unique within the experience. */\n id: string;\n name: string;\n /** A 5-field cron expression. Omit for a template that is started by hand. */\n schedule?: string;\n scope?: 'account' | 'user';\n /** Evaluated at `ekanos build`, never at runtime. */\n build: () => readonly WorkflowStep[];\n}\n\nexport interface WorkflowTemplate {\n readonly kind: 'workflow-template';\n readonly id: string;\n readonly name: string;\n readonly schedule?: string;\n readonly scope: 'account' | 'user';\n readonly build: () => readonly WorkflowStep[];\n}\n\nexport function defineWorkflowTemplate(\n input: WorkflowTemplateInput,\n): WorkflowTemplate {\n if (!TEMPLATE_ID.test(input.id)) {\n throw new Error(\n `defineWorkflowTemplate: id \"${input.id}\" must be kebab-case (e.g. \"morning-digest\").`,\n );\n }\n if (input.name.trim() === '') {\n throw new Error(`defineWorkflowTemplate(\"${input.id}\"): name is required.`);\n }\n if (\n input.schedule !== undefined &&\n input.schedule.trim().split(/\\s+/).length !== 5\n ) {\n throw new Error(\n `defineWorkflowTemplate(\"${input.id}\"): schedule must be a 5-field cron expression, got \"${input.schedule}\".`,\n );\n }\n\n return Object.freeze({\n kind: 'workflow-template' as const,\n id: input.id,\n name: input.name,\n ...(input.schedule === undefined ? {} : { schedule: input.schedule }),\n scope: input.scope ?? 'account',\n build: input.build,\n });\n}\n\n/** The serialized workflow the host's engine runs (validated by `WorkflowTemplateSchema`). */\nexport type WorkflowDsl = EngineWorkflowTemplate;\n\nexport { TEMPLATE_INSTALLATION_ID };\n\nexport interface SerializeWorkflowOptions {\n /**\n * Reads `read`/`write` for an integration operation from the pinned contract. Return\n * `undefined` when the operation is unknown: serialization then throws, so\n * a template can never name an operation the contract lacks.\n */\n effectOf: (integration: string, op: string) => 'read' | 'write' | undefined;\n installationId?: string;\n}\n\n/**\n * Turn a template into the engine's DSL. Pure and deterministic: the same\n * template and contracts always give the same JSON (it is hashed into the\n * manifest digest).\n */\nexport function serializeWorkflowTemplate(\n template: WorkflowTemplate,\n options: SerializeWorkflowOptions,\n): WorkflowDsl {\n const steps = template.build();\n const installationId = options.installationId ?? TEMPLATE_INSTALLATION_ID;\n const where = `workflow template \"${template.id}\"`;\n\n if (steps.length === 0)\n throw new Error(`${where}: build() returned no steps.`);\n\n const seen = new Set<string>();\n for (const s of steps) {\n if (!STEP_ID.test(s.id) || RESERVED_STEP_IDS.has(s.id)) {\n throw new Error(`${where}: step id \"${s.id}\" is invalid or reserved.`);\n }\n if (seen.has(s.id))\n throw new Error(`${where}: step id \"${s.id}\" is used twice.`);\n seen.add(s.id);\n }\n\n const edges: WorkflowDsl['edges'] = [];\n steps.forEach((s, index) => {\n const predecessors = s.after ?? (index === 0 ? [] : [steps[index - 1]!.id]);\n for (const from of predecessors) {\n if (!seen.has(from)) {\n throw new Error(\n `${where}: step \"${s.id}\" follows unknown step \"${from}\".`,\n );\n }\n edges.push({ from, to: s.id });\n }\n });\n\n const dslSteps = steps.map((s): WorkflowDsl['steps'][number] => {\n switch (s.type) {\n case 'tool': {\n const effect = options.effectOf(s.integration, s.op);\n if (effect === undefined) {\n throw new Error(\n `${where}: step \"${s.id}\" calls ${s.integration} ${s.op}, which the pinned contract does not declare.`,\n );\n }\n\n return {\n id: s.id,\n type: 'fusion_tool',\n tool: s.op,\n installationId,\n slot: s.integration,\n args: s.args as Extract<\n WorkflowDsl['steps'][number],\n { type: 'fusion_tool' }\n >['args'],\n effect,\n };\n }\n case 'ai':\n return {\n id: s.id,\n type: 'ai_step',\n kind: s.kind,\n instructions: s.instructions,\n outputSchemaRef: s.outputSchemaRef,\n };\n case 'approval':\n return {\n id: s.id,\n type: 'approval_gate',\n summaryTemplate: s.summary,\n approverScope: s.approverScope,\n };\n }\n });\n\n return {\n version: '1',\n name: template.name,\n scope: template.scope,\n trigger:\n template.schedule === undefined\n ? { type: 'manual' }\n : { type: 'schedule', cron: template.schedule },\n steps: dslSteps,\n edges,\n };\n}\n"]}
1
+ {"version":3,"file":"workflow-template.js","sourceRoot":"","sources":["../../src/experience/workflow-template.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AAYpC,MAAM,UAAU,GAAG,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAE1E,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACvB,CAAC;AA8CD,MAAM,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AAC,EAAE;oBACR,IAAI,EAAE,eAAe;oBACrB,eAAe,EAAE,CAAC,CAAC,OAAO;oBAC1B,aAAa,EAAE,CAAC,CAAC,aAAa;iBAC/B,CAAC;QACN,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EACL,QAAQ,CAAC,QAAQ,KAAK,SAAS;YAC7B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE;YACpB,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;QACnD,KAAK,EAAE,QAAQ;QACf,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import {\n TEMPLATE_INSTALLATION_ID,\n type WorkflowTemplate as EngineWorkflowTemplate,\n} from '@ekanos/integration-schema';\n\nimport type { OperationInput, OperationKey, IntegrationName } from './types';\n\n/**\n * A reference to an earlier step's output (`{ ref: 'draft.title' }`), the\n * workflow engine's operand shape. Build one with {@link ref}.\n */\nexport interface WorkflowRef {\n readonly ref: string;\n}\n\nexport function ref(path: string): WorkflowRef {\n if (path.trim() === '') throw new Error('ref(): path must not be empty.');\n\n return { ref: path };\n}\n\n/** Each input field may be literal or a reference to an earlier step's output. */\nexport type WithRefs<T> = T extends readonly unknown[]\n ? T | WorkflowRef\n : T extends object\n ? { [P in keyof T]: WithRefs<T[P]> | WorkflowRef }\n : T | WorkflowRef;\n\nexport interface StepOptions {\n /**\n * Step id(s) this step follows. Default: the previous step in `build()`\n * order (the first step follows nothing).\n */\n after?: string | readonly string[];\n}\n\nexport interface ToolStep {\n readonly type: 'tool';\n readonly id: string;\n readonly integration: string;\n /** `tool/<name>` or `action/<name>`; effect comes from the pinned contract. */\n readonly op: string;\n readonly args: Record<string, unknown>;\n readonly after?: readonly string[];\n}\n\nexport interface AiStep {\n readonly type: 'ai';\n readonly id: string;\n readonly kind: string;\n readonly instructions: string;\n readonly outputSchemaRef: string;\n readonly after?: readonly string[];\n}\n\nexport interface ApprovalStep {\n readonly type: 'approval';\n readonly id: string;\n readonly summary: string;\n readonly approverScope: 'account' | 'user';\n readonly after?: readonly string[];\n}\n\nexport type WorkflowStep = ToolStep | AiStep | ApprovalStep;\n\nconst afterOf = (options: StepOptions | undefined) =>\n options?.after === undefined\n ? {}\n : {\n after:\n typeof options.after === 'string'\n ? [options.after]\n : [...options.after],\n };\n\n/**\n * Step constructors for {@link defineWorkflowTemplate}.\n *\n * `step.tool` is typed from the generated registry: the integration, the operation\n * and its `args` are checked against the pinned contract. Whether a tool step\n * reads or writes is NOT authored; it is read from the contract at build, so a\n * template cannot call a write as if it were a read.\n */\nexport const step = {\n tool<S extends IntegrationName, K extends OperationKey<S>>(\n id: string,\n integration: S,\n op: K,\n args: WithRefs<OperationInput<S, K>>,\n options?: StepOptions,\n ): ToolStep {\n return {\n type: 'tool',\n id,\n integration,\n op,\n args: args as Record<string, unknown>,\n ...afterOf(options),\n };\n },\n ai(\n id: string,\n config: { instructions: string; outputSchemaRef: string; kind?: string },\n options?: StepOptions,\n ): AiStep {\n return {\n type: 'ai',\n id,\n kind: config.kind ?? 'draft',\n instructions: config.instructions,\n outputSchemaRef: config.outputSchemaRef,\n ...afterOf(options),\n };\n },\n approval(\n id: string,\n config: { summary: string; approverScope?: 'account' | 'user' },\n options?: StepOptions,\n ): ApprovalStep {\n return {\n type: 'approval',\n id,\n summary: config.summary,\n approverScope: config.approverScope ?? 'account',\n ...afterOf(options),\n };\n },\n};\n\nconst TEMPLATE_ID = /^[a-z][a-z0-9-]*$/;\nconst STEP_ID = /^[a-z][a-z0-9_]*$/;\nconst RESERVED_STEP_IDS = new Set(['trigger', 'item', 'loop', 'run']);\n\nexport interface WorkflowTemplateInput {\n /** kebab-case, unique within the experience. */\n id: string;\n name: string;\n /** A 5-field cron expression. Omit for a template that is started by hand. */\n schedule?: string;\n scope?: 'account' | 'user';\n /** Evaluated at `ekanos build`, never at runtime. */\n build: () => readonly WorkflowStep[];\n}\n\nexport interface WorkflowTemplate {\n readonly kind: 'workflow-template';\n readonly id: string;\n readonly name: string;\n readonly schedule?: string;\n readonly scope: 'account' | 'user';\n readonly build: () => readonly WorkflowStep[];\n}\n\nexport function defineWorkflowTemplate(\n input: WorkflowTemplateInput,\n): WorkflowTemplate {\n if (!TEMPLATE_ID.test(input.id)) {\n throw new Error(\n `defineWorkflowTemplate: id \"${input.id}\" must be kebab-case (e.g. \"morning-digest\").`,\n );\n }\n if (input.name.trim() === '') {\n throw new Error(`defineWorkflowTemplate(\"${input.id}\"): name is required.`);\n }\n if (\n input.schedule !== undefined &&\n input.schedule.trim().split(/\\s+/).length !== 5\n ) {\n throw new Error(\n `defineWorkflowTemplate(\"${input.id}\"): schedule must be a 5-field cron expression, got \"${input.schedule}\".`,\n );\n }\n\n return Object.freeze({\n kind: 'workflow-template' as const,\n id: input.id,\n name: input.name,\n ...(input.schedule === undefined ? {} : { schedule: input.schedule }),\n scope: input.scope ?? 'account',\n build: input.build,\n });\n}\n\n/** The serialized workflow the host's engine runs (validated by `WorkflowTemplateSchema`). */\nexport type WorkflowDsl = EngineWorkflowTemplate;\n\nexport { TEMPLATE_INSTALLATION_ID };\n\nexport interface SerializeWorkflowOptions {\n /**\n * Reads `read`/`write` for an integration operation from the pinned contract. Return\n * `undefined` when the operation is unknown: serialization then throws, so\n * a template can never name an operation the contract lacks.\n */\n effectOf: (integration: string, op: string) => 'read' | 'write' | undefined;\n /**\n * The experience's slug, written on every tool step as `experience`. The\n * host resolves the running team's connection from it at run time.\n */\n experience?: string;\n /**\n * @deprecated Pass `experience`. Written on every tool step as\n * `installationId` when `experience` is absent; with neither, steps carry\n * the deprecated `TEMPLATE_INSTALLATION_ID` placeholder so a caller built\n * against 0.21 keeps producing a valid template.\n */\n installationId?: string;\n}\n\n/**\n * Turn a template into the engine's DSL. Pure and deterministic: the same\n * template and contracts always give the same JSON (it is hashed into the\n * manifest digest).\n */\nexport function serializeWorkflowTemplate(\n template: WorkflowTemplate,\n options: SerializeWorkflowOptions,\n): WorkflowDsl {\n const steps = template.build();\n const target =\n options.experience !== undefined\n ? { experience: options.experience }\n : { installationId: options.installationId ?? TEMPLATE_INSTALLATION_ID };\n const where = `workflow template \"${template.id}\"`;\n\n if (steps.length === 0)\n throw new Error(`${where}: build() returned no steps.`);\n\n const seen = new Set<string>();\n for (const s of steps) {\n if (!STEP_ID.test(s.id) || RESERVED_STEP_IDS.has(s.id)) {\n throw new Error(`${where}: step id \"${s.id}\" is invalid or reserved.`);\n }\n if (seen.has(s.id))\n throw new Error(`${where}: step id \"${s.id}\" is used twice.`);\n seen.add(s.id);\n }\n\n const edges: WorkflowDsl['edges'] = [];\n steps.forEach((s, index) => {\n const predecessors = s.after ?? (index === 0 ? [] : [steps[index - 1]!.id]);\n for (const from of predecessors) {\n if (!seen.has(from)) {\n throw new Error(\n `${where}: step \"${s.id}\" follows unknown step \"${from}\".`,\n );\n }\n edges.push({ from, to: s.id });\n }\n });\n\n const dslSteps = steps.map((s): WorkflowDsl['steps'][number] => {\n switch (s.type) {\n case 'tool': {\n const effect = options.effectOf(s.integration, s.op);\n if (effect === undefined) {\n throw new Error(\n `${where}: step \"${s.id}\" calls ${s.integration} ${s.op}, which the pinned contract does not declare.`,\n );\n }\n\n return {\n id: s.id,\n type: 'fusion_tool',\n tool: s.op,\n ...target,\n slot: s.integration,\n args: s.args as Extract<\n WorkflowDsl['steps'][number],\n { type: 'fusion_tool' }\n >['args'],\n effect,\n };\n }\n case 'ai':\n return {\n id: s.id,\n type: 'ai_step',\n kind: s.kind,\n instructions: s.instructions,\n outputSchemaRef: s.outputSchemaRef,\n };\n case 'approval':\n return {\n id: s.id,\n type: 'approval_gate',\n summaryTemplate: s.summary,\n approverScope: s.approverScope,\n };\n }\n });\n\n return {\n version: '1',\n name: template.name,\n scope: template.scope,\n trigger:\n template.schedule === undefined\n ? { type: 'manual' }\n : { type: 'schedule', cron: template.schedule },\n steps: dslSteps,\n edges,\n };\n}\n"]}
@@ -16,9 +16,8 @@ export interface WorkspaceTargetDefinition {
16
16
  * alphanumeric with single hyphens between segments. */
17
17
  slug: string;
18
18
  name: string;
19
- /** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide
20
- * names are still translated at render time during the migration, but must
21
- * not be written. Validated by the host at gate time. */
19
+ /** A Font Awesome class string, e.g. `fa-inbox`. Validated by the host at
20
+ * gate time. */
22
21
  icon?: string;
23
22
  description?: string;
24
23
  /** Defaults to `'masonry'` when omitted. */
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-inbox`. Legacy Lucide\n * names are still translated at render time during the migration, but must\n * not be written. Validated by the host at gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
1
+ {"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Font Awesome class string, e.g. `fa-inbox`. Validated by the host at\n * gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekanos/sdk",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
5
  "description": "The official SDK for building Ekanos integrations.",
6
6
  "homepage": "https://sdk.ekanos.dev/sdk/overview",
@@ -114,8 +114,8 @@
114
114
  "access": "public"
115
115
  },
116
116
  "dependencies": {
117
- "@ekanos/integration-schema": "0.20.0",
118
- "@ekanos/ui": "0.20.0",
117
+ "@ekanos/integration-schema": "0.22.0",
118
+ "@ekanos/ui": "0.22.0",
119
119
  "@supabase/supabase-js": "2.118.0",
120
120
  "server-only": "^0.0.1",
121
121
  "zod-to-json-schema": "3.25.2"