@w6w/embed 0.2.30 → 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{CreateFunctionModal-CCYi9deY.js → CreateFunctionModal-glk2zg1r.js} +28 -27
  2. package/dist/{CreateFunctionModal-CCYi9deY.js.map → CreateFunctionModal-glk2zg1r.js.map} +1 -1
  3. package/dist/{DocumentFormModal-B3VudaLb.js → DocumentFormModal-Cw85R4wk.js} +2 -2
  4. package/dist/{DocumentFormModal-B3VudaLb.js.map → DocumentFormModal-Cw85R4wk.js.map} +1 -1
  5. package/dist/{ImportSpecModal-C-B8Jwxk.js → ImportSpecModal-fU5RsVTa.js} +2 -2
  6. package/dist/{ImportSpecModal-C-B8Jwxk.js.map → ImportSpecModal-fU5RsVTa.js.map} +1 -1
  7. package/dist/WorkflowEditor-C7oudiIb.js +1169 -0
  8. package/dist/WorkflowEditor-C7oudiIb.js.map +1 -0
  9. package/dist/callable-record-Bhxim8C1.js +14 -0
  10. package/dist/callable-record-Bhxim8C1.js.map +1 -0
  11. package/dist/callables-B49tS2vv.js +297 -0
  12. package/dist/callables-B49tS2vv.js.map +1 -0
  13. package/dist/{document-sources-DNmBojx6.js → document-sources-Khcw2zB5.js} +16 -16
  14. package/dist/document-sources-Khcw2zB5.js.map +1 -0
  15. package/dist/draft.mjs +1 -1
  16. package/dist/editor/WorkflowEditor.d.ts +2 -1
  17. package/dist/editor/WorkflowInputsModal.d.ts +12 -0
  18. package/dist/editor/WorkflowVariablesEditor.d.ts +1 -1
  19. package/dist/{editor-tools-BIAW-wzt.js → editor-tools-Dn7TgCP4.js} +566 -486
  20. package/dist/editor-tools-Dn7TgCP4.js.map +1 -0
  21. package/dist/editor.mjs +1 -1
  22. package/dist/editors.mjs +81 -80
  23. package/dist/editors.mjs.map +1 -1
  24. package/dist/endpoints-zOuwci2U.js +136 -0
  25. package/dist/endpoints-zOuwci2U.js.map +1 -0
  26. package/dist/fields-CXHRR5eK.js +28 -0
  27. package/dist/fields-CXHRR5eK.js.map +1 -0
  28. package/dist/forms.mjs +1 -1
  29. package/dist/index.mjs +91 -91
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/lib/callable-duplicate.d.ts +26 -0
  32. package/dist/lib/settings-rail.d.ts +12 -0
  33. package/dist/lib/variable-preview.d.ts +6 -0
  34. package/dist/lib.mjs +41 -40
  35. package/dist/lib.mjs.map +1 -1
  36. package/dist/lists/CallableKindList.d.ts +4 -1
  37. package/dist/lists/CallableRowParts.d.ts +5 -0
  38. package/dist/lists/CredentialDetail.d.ts +2 -0
  39. package/dist/lists/CredentialFields.d.ts +1 -1
  40. package/dist/lists/EndpointList.d.ts +2 -1
  41. package/dist/lists/WorkflowList.d.ts +2 -1
  42. package/dist/lists.mjs +1509 -1421
  43. package/dist/lists.mjs.map +1 -1
  44. package/dist/rail.mjs +1 -1
  45. package/dist/repos/callables.d.ts +23 -0
  46. package/dist/repos/fields.d.ts +4 -1
  47. package/dist/repos.mjs +242 -239
  48. package/dist/settings-rail-gUU2ZbSw.js +36 -0
  49. package/dist/settings-rail-gUU2ZbSw.js.map +1 -0
  50. package/dist/{spec-import-FygyV8sy.js → spec-import-CGPqUUjN.js} +2 -2
  51. package/dist/{spec-import-FygyV8sy.js.map → spec-import-CGPqUUjN.js.map} +1 -1
  52. package/dist/{use-callable-draft-DCauHt5o.js → use-callable-draft-w4tDTYcb.js} +8 -7
  53. package/dist/{use-callable-draft-DCauHt5o.js.map → use-callable-draft-w4tDTYcb.js.map} +1 -1
  54. package/package.json +3 -3
  55. package/src/styles.css +174 -40
  56. package/dist/WorkflowEditor-8NAcpjO_.js +0 -1140
  57. package/dist/WorkflowEditor-8NAcpjO_.js.map +0 -1
  58. package/dist/callables-tOlflvbl.js +0 -151
  59. package/dist/callables-tOlflvbl.js.map +0 -1
  60. package/dist/document-sources-DNmBojx6.js.map +0 -1
  61. package/dist/editor-tools-BIAW-wzt.js.map +0 -1
  62. package/dist/endpoints-DArAqoLT.js +0 -233
  63. package/dist/endpoints-DArAqoLT.js.map +0 -1
  64. package/dist/fields-DvS8XZFc.js +0 -21
  65. package/dist/fields-DvS8XZFc.js.map +0 -1
  66. package/dist/settings-rail--GdRMusb.js +0 -33
  67. package/dist/settings-rail--GdRMusb.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/embed-status.ts","../src/repos/webhook-listen.ts","../src/W6WEmbedProvider.tsx"],"sourcesContent":["/**\n * The embed's public session status, as a pure total function over the `@w6w/react` session\n * store's status plus whether a terminal partner-token 401 has been seen. No React here, so\n * `node:test` covers it exhaustively.\n */\nimport type { W6WSessionStatus } from \"@w6w/react\";\n\nexport type EmbedStatusValue = \"connecting\" | \"ready\" | \"error\";\n\nexport interface EmbedStatus {\n status: EmbedStatusValue;\n /** `EmbedAuthError` for a terminal 401, else the session store's own error; `null` otherwise. */\n error: unknown;\n}\n\n/**\n * The terminal partner-token 401: the host's `getSession` minted a token the API refused, and a\n * renewal did not fix it. `cause` is the SDK `ApiError`.\n */\nexport class EmbedAuthError extends Error {\n constructor(cause: unknown) {\n super(\"The w6w API rejected the embed session token (401).\", { cause });\n this.name = \"EmbedAuthError\";\n }\n}\n\n/**\n * `loading -> connecting`, `ready|renewing -> ready`, `expired -> connecting` (the provider\n * re-acquires), `error -> error`. A seen 401 wins over everything: it is `error` with the\n * `EmbedAuthError`, whatever the store currently says.\n */\nexport function deriveEmbedStatus(\n sessionStatus: W6WSessionStatus,\n sessionError: unknown,\n authError: EmbedAuthError | null,\n): EmbedStatus {\n if (authError) return { status: \"error\", error: authError };\n switch (sessionStatus) {\n case \"ready\":\n case \"renewing\":\n return { status: \"ready\", error: null };\n case \"error\":\n return { status: \"error\", error: sessionError };\n case \"loading\":\n case \"expired\":\n return { status: \"connecting\", error: null };\n }\n}\n","import type { W6WClient } from \"@w6w/sdk\";\nimport { path } from \"@w6w/sdk\";\n/**\n * \"Listen for test event\" on a `@w6w/webhook` subscription — `/subscriptions/:id/listen` over\n * `client.request()`. Not in the SDK's stable contract (Studio reaches it the same way, its\n * `repos/subscriptions.ts`), and `createW6WUiAdapter` carries none of it, so without these the\n * embedded editor's webhook Test tab fell back to the paste-a-payload form.\n */\n\n/**\n * Structural mirror of ui's `WebhookListenSession` (this barrel may not import `@w6w/ui`); the\n * UiBridge assignment typechecks against W6WApi structurally.\n */\nexport interface WebhookListenSession {\n id: string;\n subscriptionId: string;\n nodeId: string | null;\n expiresAt: string;\n status: \"waiting\" | \"captured\" | \"expired\";\n request?: {\n method: string;\n path: string;\n query: Record<string, string>;\n headers: Record<string, string>;\n body: unknown;\n };\n receivedAt?: string;\n}\n\nexport async function startWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n): Promise<{ session: WebhookListenSession; webhookUrl: string }> {\n const res = await client.request<{ session: WebhookListenSession; webhookUrl: string }>({\n method: \"POST\",\n path: path`/subscriptions/${subscriptionId}/listen`,\n body: {},\n });\n return res.body;\n}\n\nexport async function pollWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n sessionId: string,\n opts?: { waitSeconds?: number; signal?: AbortSignal },\n): Promise<WebhookListenSession> {\n const res = await client.request<{ session: WebhookListenSession }>({\n method: \"GET\",\n path: path`/subscriptions/${subscriptionId}/listen/${sessionId}`,\n query: { wait: String(opts?.waitSeconds ?? 0) },\n signal: opts?.signal,\n });\n return res.body.session;\n}\n\nexport async function stopWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n sessionId: string,\n): Promise<void> {\n await client.request<unknown>({\n method: \"DELETE\",\n path: path`/subscriptions/${subscriptionId}/listen/${sessionId}`,\n });\n}\n","import { QueryClient, QueryClientProvider, useQuery } from \"@tanstack/react-query\";\n/**\n * `<W6WEmbedProvider>` — everything an embedded w6w surface needs from a host, behind one\n * element: an identity-scoped `QueryClient`, a `@w6w/react` `<W6WProvider>` (client, session\n * renewal, per-request token) and `@w6w/ui`'s `<W6WUIProvider>` fed by `createW6WUiAdapter`.\n * It composes the three public pieces exactly as `@w6w/react`'s README bridge does: it never\n * spreads or patches the adapter, never reaches into `client.console`, and keeps no session\n * store of its own (`getSession` goes straight to `<W6WProvider>`).\n *\n * **Identity cache.** The `QueryClient` is owned here, not borrowed from the host, and it is a\n * NEW instance whenever `identityKey` changes — so a query cached while signed in as account A\n * is unreachable once the host switches to B. A new client alone is NOT enough: a mounted\n * `useQuery` keeps the `QueryObserver` it was born with, and that observer is bound to the client\n * it was created against, so a child that survives the swap would keep rendering A's cache. The\n * subtree is therefore also re-mounted (`key`), which drops every observer and every piece of\n * child state from the previous identity. The client, the `key` and the tuple handed to\n * `<W6WProvider>` all change in ONE state update: there is no render in which B's tree reads A's\n * cache. The old client is cleared once it is no longer mounted.\n *\n * **Identity switch (flush first).** A draft with a pending save must be written into the account\n * that produced the edit. When `identityKey` changes this provider therefore HOLDS the applied\n * tuple — `identityKey`, `apiOrigin`, `project`, `getSession`, the client — and keeps handing the\n * OLD one to `<W6WProvider>`, awaits `registry.flushAll()` (bounded, never rejects), and only then\n * applies the new tuple in a single update. `<W6WProvider>` swaps its client synchronously on a\n * new `identityKey` and detaches the old session store, so the flush must finish first; and the\n * new `getSession` is NOT forwarded early: `<W6WProvider>` reaches it through the stable wrapper\n * below, whose target is swapped in the same update as the tuple (forwarded early, the new\n * account's token would be minted on the old client). A flush that fails or times out still lets\n * the switch proceed (Q6) and is never retried with the new identity. A token rotation under an\n * unchanged `identityKey` is not a switch: it is forwarded at once, no hold.\n *\n * **No identity.** `identityKey={null}` mounts nothing but `fallback`: no `<W6WProvider>`, no\n * `QueryClientProvider`, no children — so no `getSession` call and no request. `null -> \"A\"`\n * applies at once (nothing can be pending); `\"A\" -> null` takes the SAME flush-first path as any\n * other switch before the fallback renders.\n *\n * **Default project.** `project={{ use: \"default\" }}` resolves ONCE per applied identity, through\n * one `client.projects.list()` query inside the identity-scoped `QueryClient`, to the row with\n * `isDefault === true` — never `list[0]`, never a fallback. `<W6WProvider>` gets no project until\n * it resolves; the client rebuild that follows reuses the cached answer (the query is keyed\n * without the client and lives in a component that stays mounted, so it is not re-issued).\n *\n * **Status.** `useEmbedStatus()` is `deriveEmbedStatus` over the `@w6w/react` session store plus a\n * terminal 401 seen through the forwarded `onUnauthorized`.\n */\nimport {\n W6WProvider,\n type W6WSession,\n createW6WUiAdapter,\n useW6WClient,\n useW6WSession,\n} from \"@w6w/react\";\nimport type { ApiError, FetchLike } from \"@w6w/sdk\";\nimport { type ThemeMode, type W6WApi, W6WUIProvider } from \"@w6w/ui\";\nimport {\n type ReactNode,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DraftRegistryProvider, EmbedClientProvider, createDraftRegistry } from \"./draft/index.ts\";\nimport { EmbedAuthError, type EmbedStatus, deriveEmbedStatus } from \"./embed-status.ts\";\nimport {\n EmbedProjectContext,\n type EmbedProjectState,\n useProvidedProject,\n} from \"./project-context.ts\";\nimport { updateConnection } from \"./repos/connections.ts\";\nimport { withCredentialMethods } from \"./repos/credentials.ts\";\nimport { listDataStoreEntries, listDataStores } from \"./repos/data-stores.ts\";\nimport { resolveActionFields } from \"./repos/fields.ts\";\nimport { listModelRoutes } from \"./repos/models.ts\";\nimport {\n pollWebhookListen,\n startWebhookListen,\n stopWebhookListen,\n} from \"./repos/webhook-listen.ts\";\nimport { listNodeSamples, listTestInputs, saveTestInput } from \"./repos/workflows.ts\";\nimport { EmbedThemeContext } from \"./theme-context.ts\";\n\nexport interface W6WEmbedProviderProps {\n /** The w6w API origin, e.g. `\"https://api.w6w.io\"`. */\n apiOrigin: string;\n /**\n * Mints a session for the CURRENT host user (`{token, expiresAt, expiresIn?}`). Always the\n * latest callback; the provider caches and renews the result.\n */\n getSession: () => Promise<W6WSession>;\n /**\n * Which signed-in identity this provider speaks for (e.g. `${userId}:${accountId}`). Changing it\n * rebuilds the API client AND replaces the `QueryClient`, so nothing cached for the previous\n * identity is ever shown under the new one.\n */\n identityKey: string | null;\n /**\n * Rendered instead of the embed while `identityKey` is `null` (no signed-in user). Nothing of\n * the embed mounts then: no `getSession` call, no request. Default `null`.\n */\n fallback?: ReactNode;\n /**\n * Start acquiring a session on mount. Without it the session is acquired lazily, by the first\n * request a mounted surface makes, and `useEmbedStatus()` stays `\"connecting\"` until then.\n */\n eager?: boolean;\n /** Force the `@w6w/ui` theme to follow the host's. Omit to resolve it the library's default way. */\n theme?: ThemeMode;\n /** Gates every read hook while `false` (default `true`) — e.g. until the host has a user. */\n ready?: boolean;\n /**\n * Default project for project-scoped operations: a project id, or `{ use: \"default\" }` to use\n * the account's default project (resolved once per identity; see `useEmbedProject()`).\n */\n project?: string | { use: \"default\" };\n /** Transport override (tests, request recording). Defaults to `globalThis.fetch`. */\n fetch?: FetchLike;\n children: ReactNode;\n}\n\nfunction makeQueryClient(): QueryClient {\n // Same defaults as Studio's own client (`studio/src/main.tsx`).\n return new QueryClient({\n defaultOptions: { queries: { retry: false, refetchOnWindowFocus: false } },\n });\n}\n\n/** The part of the tuple that changes only when a switch has been APPLIED (after the flush). */\ninterface Applied {\n identityKey: string | null;\n queryClient: QueryClient;\n}\n\n/** What `<W6WProvider>` is fed while no switch is in progress; frozen at the last such render. */\ninterface Forwarded {\n apiOrigin: string;\n project: string | { use: \"default\" } | undefined;\n getSession: () => Promise<W6WSession>;\n}\n\n/** Hands the SDK client of the nearest `<W6WProvider>` to `useWorkflowDraft`. */\nfunction ClientBridge({ children }: { children: ReactNode }) {\n return <EmbedClientProvider client={useW6WClient()}>{children}</EmbedClientProvider>;\n}\n\n/** The README bridge: `useW6WClient` -> `createW6WUiAdapter` -> `<W6WUIProvider>`. */\nfunction UiBridge({ theme, children }: { theme?: ThemeMode; children: ReactNode }) {\n const client = useW6WClient();\n const provided = useProvidedProject();\n // `createW6WUiAdapter` has no `updateConnection` or `listModelRoutes`; keep them if it ever\n // gains them, else supply the embed repo's own so the ui Edit modal can save and the\n // `@w6w/model` node's Route field offers the project's routes (not free text) in any host.\n const api = useMemo(() => {\n const adapter: W6WApi = createW6WUiAdapter(client);\n if (typeof adapter.updateConnection !== \"function\") {\n adapter.updateConnection = (id, body) => updateConnection(client, id, body);\n }\n withCredentialMethods(adapter, client);\n if (typeof adapter.listModelRoutes !== \"function\") {\n adapter.listModelRoutes = async (editorProject) => {\n const project = editorProject || provided;\n if (!project) return [];\n const routes = await listModelRoutes(client, project);\n return routes.map((r) => ({ name: r.name, model: r.modelId, status: r.status }));\n };\n }\n // Same for the `@w6w/store` node's store picker: the project's store names, not free text.\n if (typeof adapter.listDataStores !== \"function\") {\n adapter.listDataStores = async (editorProject) => {\n const project = editorProject || provided;\n if (!project) return [];\n return listDataStores(client, project);\n };\n }\n // ...and its key picker: one page of the named store's entries, searched by key prefix.\n if (typeof adapter.listDataStoreEntries !== \"function\") {\n adapter.listDataStoreEntries = async (store, opts) => {\n const project = opts.project || provided;\n if (!project) return { items: [] };\n return listDataStoreEntries(client, project, store, opts);\n };\n }\n // Persisted node samples, so the editor's picker keeps upstream keys across a reload.\n if (typeof adapter.loadNodeSamples !== \"function\") {\n adapter.loadNodeSamples = (workflowId) => listNodeSamples(client, workflowId);\n }\n // Remembered test inputs, so every test form reopens prefilled with the last values used.\n if (typeof adapter.loadTestInputs !== \"function\") {\n adapter.loadTestInputs = (workflowId) => listTestInputs(client, workflowId);\n }\n if (typeof adapter.saveTestInput !== \"function\") {\n adapter.saveTestInput = (workflowId, nodeId, input) =>\n saveTestInput(client, workflowId, nodeId, input);\n }\n if (typeof adapter.resolveActionFields !== \"function\") {\n adapter.resolveActionFields = (appId, actionKey, body, opts) =>\n resolveActionFields(client, appId, actionKey, body, opts);\n }\n // The webhook node's Test tab listens for a real request only when all three exist; without\n // them it falls back to the paste-a-payload form.\n if (typeof adapter.startWebhookListen !== \"function\") {\n adapter.startWebhookListen = (subscriptionId) => startWebhookListen(client, subscriptionId);\n adapter.pollWebhookListen = (subscriptionId, sessionId, opts) =>\n pollWebhookListen(client, subscriptionId, sessionId, opts);\n adapter.stopWebhookListen = (subscriptionId, sessionId) =>\n stopWebhookListen(client, subscriptionId, sessionId);\n }\n return adapter;\n }, [client, provided]);\n return (\n <W6WUIProvider api={api} theme={theme}>\n <EmbedThemeContext.Provider value={theme}>{children}</EmbedThemeContext.Provider>\n </W6WUIProvider>\n );\n}\n\nconst EmbedStatusContext = createContext<EmbedStatus>({ status: \"connecting\", error: null });\n\n/** The session status of the nearest `<W6WEmbedProvider>`. See `deriveEmbedStatus`. */\nexport function useEmbedStatus(): EmbedStatus {\n return useContext(EmbedStatusContext);\n}\n\n/** Publishes `useEmbedStatus()`, and starts the session on mount when `eager`. */\nfunction StatusBridge({\n eager,\n authError,\n onAcquire,\n children,\n}: {\n eager: boolean;\n authError: EmbedAuthError | null;\n onAcquire: () => void;\n children: ReactNode;\n}) {\n const { status, error, refresh } = useW6WSession();\n // `refresh` is per session store, so a rebuilt client (project resolved) is started again.\n useEffect(() => {\n if (eager) void refresh();\n }, [eager, refresh]);\n useEffect(() => {\n if (status === \"loading\" || status === \"renewing\") onAcquire();\n }, [status, onAcquire]);\n const value = useMemo(\n () => deriveEmbedStatus(status, error, authError),\n [status, error, authError],\n );\n return <EmbedStatusContext.Provider value={value}>{children}</EmbedStatusContext.Provider>;\n}\n\n/**\n * Resolves `{use:\"default\"}`. Lives INSIDE `<W6WProvider>` (it needs the client) but at a fixed\n * slot, so it survives the client rebuild that follows resolution; the query key carries no\n * client, so nothing refetches.\n */\nfunction DefaultProjectResolver({\n identityKey,\n enabled,\n onState,\n}: {\n identityKey: string;\n enabled: boolean;\n onState: (key: string, state: EmbedProjectState) => void;\n}) {\n const client = useW6WClient();\n const q = useQuery({\n queryKey: [\"w6w-embed\", \"default-project\"],\n enabled,\n queryFn: async () => {\n const rows = await client.projects.list();\n const home = rows.find((p) => p.isDefault === true);\n if (!home) throw new Error(\"The account has no default project.\");\n return home.id;\n },\n });\n const { isError, error, data } = q;\n const state = useMemo<EmbedProjectState>(\n () =>\n isError\n ? { project: null, status: \"error\", error }\n : data !== undefined\n ? { project: data, status: \"ready\" }\n : { project: null, status: \"resolving\" },\n [isError, error, data],\n );\n useEffect(() => {\n onState(identityKey, state);\n }, [identityKey, state, onState]);\n return null;\n}\n\nexport function W6WEmbedProvider({\n apiOrigin,\n getSession,\n identityKey,\n fallback = null,\n eager = false,\n theme,\n ready,\n project,\n fetch,\n children,\n}: W6WEmbedProviderProps): ReactNode {\n const [registry] = useState(createDraftRegistry);\n const [applied, setApplied] = useState<Applied>(() => ({\n identityKey,\n queryClient: makeQueryClient(),\n }));\n\n // While `identityKey` differs from the applied one a switch is pending: everything below keeps\n // using the values frozen at the last render that was not pending. Otherwise props flow straight\n // through (project / origin changes, token rotation). Idempotent latest-value writes, the same\n // pattern `<W6WProvider>` uses for its own refs.\n const switching = identityKey !== applied.identityKey;\n const forwardedRef = useRef<Forwarded>({ apiOrigin, project, getSession });\n if (!switching) forwardedRef.current = { apiOrigin, project, getSession };\n const forwarded = forwardedRef.current;\n\n // The stable `getSession` handed to `<W6WProvider>`: reads whatever is applied RIGHT NOW. Its\n // target changes in the same render that applies the new tuple, never before the flush settles.\n const sessionRef = useRef(forwarded.getSession);\n sessionRef.current = forwarded.getSession;\n const [stableGetSession] = useState(() => () => sessionRef.current());\n\n useEffect(() => {\n if (identityKey === applied.identityKey) return;\n let cancelled = false;\n const apply = () => {\n if (cancelled) return;\n setApplied({ identityKey, queryClient: makeQueryClient() });\n };\n // Nothing is mounted under a null identity, so nothing can be pending: apply at once.\n if (applied.identityKey === null) {\n apply();\n return () => {\n cancelled = true;\n };\n }\n // `flushAll` never rejects and is bounded; the switch proceeds either way (Q6).\n registry.flushAll().then(apply, apply);\n return () => {\n cancelled = true;\n };\n }, [identityKey, applied.identityKey, registry]);\n\n // The replaced client is dropped once nothing mounted reads it.\n const queryClient = applied.queryClient;\n useEffect(() => () => queryClient.clear(), [queryClient]);\n\n // Default-project resolution, tagged with the identity it was resolved for: a result for A is\n // never read once B is applied.\n const [resolved, setResolved] = useState<{ key: string; state: EmbedProjectState } | null>(null);\n const onResolved = useCallback((key: string, state: EmbedProjectState) => {\n setResolved((prev) =>\n prev &&\n prev.key === key &&\n prev.state.project === state.project &&\n prev.state.status === state.status &&\n prev.state.error === state.error\n ? prev\n : { key, state },\n );\n }, []);\n\n // The terminal partner-token 401, tagged with its identity; cleared when the next acquisition\n // starts (StatusBridge) or the identity changes (the tag no longer matches).\n const [authFailure, setAuthFailure] = useState<{\n key: QueryClient;\n error: EmbedAuthError;\n } | null>(null);\n // The handler is bound to the per-mount client it was created for: a late 401 from a previous\n // `<W6WProvider>` is tagged with ITS client, never the one applied by the time it fires — even\n // when the identity key came back (A -> B -> A mints a new client for the same key).\n const onUnauthorized = useMemo(() => {\n const key = applied.queryClient;\n return (error: ApiError) => {\n setAuthFailure({ key, error: new EmbedAuthError(error) });\n };\n }, [applied.queryClient]);\n const clearAuthFailure = useCallback(() => setAuthFailure(null), []);\n\n const appliedKey = applied.identityKey;\n const spec = forwarded.project;\n // Only exactly `{ use: \"default\" }` asks for the account default; null, `{}`, `[]` or any other\n // object (JS hosts, casts) is \"no project\" and makes no lookup.\n const wantsDefault =\n typeof spec === \"object\" && spec !== null && !Array.isArray(spec) && spec.use === \"default\";\n const projectState: EmbedProjectState = useMemo(() => {\n if (typeof spec === \"string\") return { project: spec, status: \"ready\" };\n if (!wantsDefault) return { project: null, status: \"ready\" };\n return resolved && resolved.key === appliedKey\n ? resolved.state\n : { project: null, status: \"resolving\" };\n }, [spec, wantsDefault, resolved, appliedKey]);\n\n if (appliedKey === null) return fallback;\n\n return (\n <DraftRegistryProvider registry={registry}>\n <QueryClientProvider key={appliedKey} client={queryClient}>\n <W6WProvider\n baseUrl={forwarded.apiOrigin}\n getSession={stableGetSession}\n identityKey={appliedKey}\n ready={ready}\n project={projectState.project ?? undefined}\n fetch={fetch}\n onUnauthorized={onUnauthorized}\n >\n {wantsDefault ? (\n <DefaultProjectResolver\n identityKey={appliedKey}\n enabled={ready !== false}\n onState={onResolved}\n />\n ) : null}\n <EmbedProjectContext.Provider value={projectState}>\n <StatusBridge\n eager={eager}\n authError={authFailure && authFailure.key === queryClient ? authFailure.error : null}\n onAcquire={clearAuthFailure}\n >\n <ClientBridge>\n <UiBridge theme={theme}>{children}</UiBridge>\n </ClientBridge>\n </StatusBridge>\n </EmbedProjectContext.Provider>\n </W6WProvider>\n </QueryClientProvider>\n </DraftRegistryProvider>\n );\n}\n"],"names":["EmbedAuthError","cause","deriveEmbedStatus","sessionStatus","sessionError","authError","startWebhookListen","client","subscriptionId","path","pollWebhookListen","sessionId","opts","stopWebhookListen","makeQueryClient","QueryClient","ClientBridge","children","jsx","EmbedClientProvider","useW6WClient","UiBridge","theme","provided","useProvidedProject","api","useMemo","adapter","createW6WUiAdapter","id","body","updateConnection","withCredentialMethods","editorProject","project","listModelRoutes","r","listDataStores","store","listDataStoreEntries","workflowId","listNodeSamples","listTestInputs","nodeId","input","saveTestInput","appId","actionKey","resolveActionFields","W6WUIProvider","EmbedThemeContext","EmbedStatusContext","createContext","useEmbedStatus","useContext","StatusBridge","eager","onAcquire","status","error","refresh","useW6WSession","useEffect","value","DefaultProjectResolver","identityKey","enabled","onState","q","useQuery","home","p","isError","data","state","W6WEmbedProvider","apiOrigin","getSession","fallback","ready","fetch","registry","useState","createDraftRegistry","applied","setApplied","switching","forwardedRef","useRef","forwarded","sessionRef","stableGetSession","cancelled","apply","queryClient","resolved","setResolved","onResolved","useCallback","key","prev","authFailure","setAuthFailure","onUnauthorized","clearAuthFailure","appliedKey","spec","wantsDefault","projectState","DraftRegistryProvider","QueryClientProvider","jsxs","W6WProvider","EmbedProjectContext"],"mappings":";;;;;;;;;;;;;;;;;;AAmBO,MAAMA,WAAuB,MAAM;AAAA,EACxC,YAAYC,GAAgB;AAC1B,UAAM,uDAAuD,EAAE,OAAAA,GAAO,GACtE,KAAK,OAAO;AAAA,EACd;AACF;AAOO,SAASC,GACdC,GACAC,GACAC,GACa;AACb,MAAIA,EAAW,QAAO,EAAE,QAA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A1F;AAAA,UAACqC;AAAA,UAAA;AAAA,YACC,OAAAC;AAAA,YACA,WAAW6C,KAAeA,EAAY,QAAQP,IAAcO,EAAY,QAAQ;AAAA,YAChF,WAAWG;AAAA,YAEX,4BAACxF,IAAA,EACC,UAAA,gBAAAE,EAACG,IAAA,EAAS,OAAAC,GAAe,UAAAL,GAAS,EAAA,CACpC;AAAA,UAAA;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,EACF,GA5BwBwF,CA6B1B,GACF;AAEJ;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/embed-status.ts","../src/repos/webhook-listen.ts","../src/W6WEmbedProvider.tsx"],"sourcesContent":["/**\n * The embed's public session status, as a pure total function over the `@w6w/react` session\n * store's status plus whether a terminal partner-token 401 has been seen. No React here, so\n * `node:test` covers it exhaustively.\n */\nimport type { W6WSessionStatus } from \"@w6w/react\";\n\nexport type EmbedStatusValue = \"connecting\" | \"ready\" | \"error\";\n\nexport interface EmbedStatus {\n status: EmbedStatusValue;\n /** `EmbedAuthError` for a terminal 401, else the session store's own error; `null` otherwise. */\n error: unknown;\n}\n\n/**\n * The terminal partner-token 401: the host's `getSession` minted a token the API refused, and a\n * renewal did not fix it. `cause` is the SDK `ApiError`.\n */\nexport class EmbedAuthError extends Error {\n constructor(cause: unknown) {\n super(\"The w6w API rejected the embed session token (401).\", { cause });\n this.name = \"EmbedAuthError\";\n }\n}\n\n/**\n * `loading -> connecting`, `ready|renewing -> ready`, `expired -> connecting` (the provider\n * re-acquires), `error -> error`. A seen 401 wins over everything: it is `error` with the\n * `EmbedAuthError`, whatever the store currently says.\n */\nexport function deriveEmbedStatus(\n sessionStatus: W6WSessionStatus,\n sessionError: unknown,\n authError: EmbedAuthError | null,\n): EmbedStatus {\n if (authError) return { status: \"error\", error: authError };\n switch (sessionStatus) {\n case \"ready\":\n case \"renewing\":\n return { status: \"ready\", error: null };\n case \"error\":\n return { status: \"error\", error: sessionError };\n case \"loading\":\n case \"expired\":\n return { status: \"connecting\", error: null };\n }\n}\n","import type { W6WClient } from \"@w6w/sdk\";\nimport { path } from \"@w6w/sdk\";\n/**\n * \"Listen for test event\" on a `@w6w/webhook` subscription — `/subscriptions/:id/listen` over\n * `client.request()`. Not in the SDK's stable contract (Studio reaches it the same way, its\n * `repos/subscriptions.ts`), and `createW6WUiAdapter` carries none of it, so without these the\n * embedded editor's webhook Test tab fell back to the paste-a-payload form.\n */\n\n/**\n * Structural mirror of ui's `WebhookListenSession` (this barrel may not import `@w6w/ui`); the\n * UiBridge assignment typechecks against W6WApi structurally.\n */\nexport interface WebhookListenSession {\n id: string;\n subscriptionId: string;\n nodeId: string | null;\n expiresAt: string;\n status: \"waiting\" | \"captured\" | \"expired\";\n request?: {\n method: string;\n path: string;\n query: Record<string, string>;\n headers: Record<string, string>;\n body: unknown;\n };\n receivedAt?: string;\n}\n\nexport async function startWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n): Promise<{ session: WebhookListenSession; webhookUrl: string }> {\n const res = await client.request<{ session: WebhookListenSession; webhookUrl: string }>({\n method: \"POST\",\n path: path`/subscriptions/${subscriptionId}/listen`,\n body: {},\n });\n return res.body;\n}\n\nexport async function pollWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n sessionId: string,\n opts?: { waitSeconds?: number; signal?: AbortSignal },\n): Promise<WebhookListenSession> {\n const res = await client.request<{ session: WebhookListenSession }>({\n method: \"GET\",\n path: path`/subscriptions/${subscriptionId}/listen/${sessionId}`,\n query: { wait: String(opts?.waitSeconds ?? 0) },\n signal: opts?.signal,\n });\n return res.body.session;\n}\n\nexport async function stopWebhookListen(\n client: W6WClient,\n subscriptionId: string,\n sessionId: string,\n): Promise<void> {\n await client.request<unknown>({\n method: \"DELETE\",\n path: path`/subscriptions/${subscriptionId}/listen/${sessionId}`,\n });\n}\n","import { QueryClient, QueryClientProvider, useQuery } from \"@tanstack/react-query\";\n/**\n * `<W6WEmbedProvider>` — everything an embedded w6w surface needs from a host, behind one\n * element: an identity-scoped `QueryClient`, a `@w6w/react` `<W6WProvider>` (client, session\n * renewal, per-request token) and `@w6w/ui`'s `<W6WUIProvider>` fed by `createW6WUiAdapter`.\n * It composes the three public pieces exactly as `@w6w/react`'s README bridge does: it never\n * spreads or patches the adapter, never reaches into `client.console`, and keeps no session\n * store of its own (`getSession` goes straight to `<W6WProvider>`).\n *\n * **Identity cache.** The `QueryClient` is owned here, not borrowed from the host, and it is a\n * NEW instance whenever `identityKey` changes — so a query cached while signed in as account A\n * is unreachable once the host switches to B. A new client alone is NOT enough: a mounted\n * `useQuery` keeps the `QueryObserver` it was born with, and that observer is bound to the client\n * it was created against, so a child that survives the swap would keep rendering A's cache. The\n * subtree is therefore also re-mounted (`key`), which drops every observer and every piece of\n * child state from the previous identity. The client, the `key` and the tuple handed to\n * `<W6WProvider>` all change in ONE state update: there is no render in which B's tree reads A's\n * cache. The old client is cleared once it is no longer mounted.\n *\n * **Identity switch (flush first).** A draft with a pending save must be written into the account\n * that produced the edit. When `identityKey` changes this provider therefore HOLDS the applied\n * tuple — `identityKey`, `apiOrigin`, `project`, `getSession`, the client — and keeps handing the\n * OLD one to `<W6WProvider>`, awaits `registry.flushAll()` (bounded, never rejects), and only then\n * applies the new tuple in a single update. `<W6WProvider>` swaps its client synchronously on a\n * new `identityKey` and detaches the old session store, so the flush must finish first; and the\n * new `getSession` is NOT forwarded early: `<W6WProvider>` reaches it through the stable wrapper\n * below, whose target is swapped in the same update as the tuple (forwarded early, the new\n * account's token would be minted on the old client). A flush that fails or times out still lets\n * the switch proceed (Q6) and is never retried with the new identity. A token rotation under an\n * unchanged `identityKey` is not a switch: it is forwarded at once, no hold.\n *\n * **No identity.** `identityKey={null}` mounts nothing but `fallback`: no `<W6WProvider>`, no\n * `QueryClientProvider`, no children — so no `getSession` call and no request. `null -> \"A\"`\n * applies at once (nothing can be pending); `\"A\" -> null` takes the SAME flush-first path as any\n * other switch before the fallback renders.\n *\n * **Default project.** `project={{ use: \"default\" }}` resolves ONCE per applied identity, through\n * one `client.projects.list()` query inside the identity-scoped `QueryClient`, to the row with\n * `isDefault === true` — never `list[0]`, never a fallback. `<W6WProvider>` gets no project until\n * it resolves; the client rebuild that follows reuses the cached answer (the query is keyed\n * without the client and lives in a component that stays mounted, so it is not re-issued).\n *\n * **Status.** `useEmbedStatus()` is `deriveEmbedStatus` over the `@w6w/react` session store plus a\n * terminal 401 seen through the forwarded `onUnauthorized`.\n */\nimport {\n W6WProvider,\n type W6WSession,\n createW6WUiAdapter,\n useW6WClient,\n useW6WSession,\n} from \"@w6w/react\";\nimport type { ApiError, FetchLike } from \"@w6w/sdk\";\nimport { type ThemeMode, type W6WApi, W6WUIProvider } from \"@w6w/ui\";\nimport {\n type ReactNode,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DraftRegistryProvider, EmbedClientProvider, createDraftRegistry } from \"./draft/index.ts\";\nimport { EmbedAuthError, type EmbedStatus, deriveEmbedStatus } from \"./embed-status.ts\";\nimport {\n EmbedProjectContext,\n type EmbedProjectState,\n useProvidedProject,\n} from \"./project-context.ts\";\nimport { updateConnection } from \"./repos/connections.ts\";\nimport { withCredentialMethods } from \"./repos/credentials.ts\";\nimport { listDataStoreEntries, listDataStores } from \"./repos/data-stores.ts\";\nimport { resolveActionFields, resolveTriggerFields } from \"./repos/fields.ts\";\nimport { listModelRoutes } from \"./repos/models.ts\";\nimport {\n pollWebhookListen,\n startWebhookListen,\n stopWebhookListen,\n} from \"./repos/webhook-listen.ts\";\nimport { listNodeSamples, listTestInputs, saveTestInput } from \"./repos/workflows.ts\";\nimport { EmbedThemeContext } from \"./theme-context.ts\";\n\nexport interface W6WEmbedProviderProps {\n /** The w6w API origin, e.g. `\"https://api.w6w.io\"`. */\n apiOrigin: string;\n /**\n * Mints a session for the CURRENT host user (`{token, expiresAt, expiresIn?}`). Always the\n * latest callback; the provider caches and renews the result.\n */\n getSession: () => Promise<W6WSession>;\n /**\n * Which signed-in identity this provider speaks for (e.g. `${userId}:${accountId}`). Changing it\n * rebuilds the API client AND replaces the `QueryClient`, so nothing cached for the previous\n * identity is ever shown under the new one.\n */\n identityKey: string | null;\n /**\n * Rendered instead of the embed while `identityKey` is `null` (no signed-in user). Nothing of\n * the embed mounts then: no `getSession` call, no request. Default `null`.\n */\n fallback?: ReactNode;\n /**\n * Start acquiring a session on mount. Without it the session is acquired lazily, by the first\n * request a mounted surface makes, and `useEmbedStatus()` stays `\"connecting\"` until then.\n */\n eager?: boolean;\n /** Force the `@w6w/ui` theme to follow the host's. Omit to resolve it the library's default way. */\n theme?: ThemeMode;\n /** Gates every read hook while `false` (default `true`) — e.g. until the host has a user. */\n ready?: boolean;\n /**\n * Default project for project-scoped operations: a project id, or `{ use: \"default\" }` to use\n * the account's default project (resolved once per identity; see `useEmbedProject()`).\n */\n project?: string | { use: \"default\" };\n /** Transport override (tests, request recording). Defaults to `globalThis.fetch`. */\n fetch?: FetchLike;\n children: ReactNode;\n}\n\nfunction makeQueryClient(): QueryClient {\n // Same defaults as Studio's own client (`studio/src/main.tsx`).\n return new QueryClient({\n defaultOptions: { queries: { retry: false, refetchOnWindowFocus: false } },\n });\n}\n\n/** The part of the tuple that changes only when a switch has been APPLIED (after the flush). */\ninterface Applied {\n identityKey: string | null;\n queryClient: QueryClient;\n}\n\n/** What `<W6WProvider>` is fed while no switch is in progress; frozen at the last such render. */\ninterface Forwarded {\n apiOrigin: string;\n project: string | { use: \"default\" } | undefined;\n getSession: () => Promise<W6WSession>;\n}\n\n/** Hands the SDK client of the nearest `<W6WProvider>` to `useWorkflowDraft`. */\nfunction ClientBridge({ children }: { children: ReactNode }) {\n return <EmbedClientProvider client={useW6WClient()}>{children}</EmbedClientProvider>;\n}\n\n/** The README bridge: `useW6WClient` -> `createW6WUiAdapter` -> `<W6WUIProvider>`. */\nfunction UiBridge({ theme, children }: { theme?: ThemeMode; children: ReactNode }) {\n const client = useW6WClient();\n const provided = useProvidedProject();\n // `createW6WUiAdapter` has no `updateConnection` or `listModelRoutes`; keep them if it ever\n // gains them, else supply the embed repo's own so the ui Edit modal can save and the\n // `@w6w/model` node's Route field offers the project's routes (not free text) in any host.\n const api = useMemo(() => {\n const adapter: W6WApi = createW6WUiAdapter(client);\n if (typeof adapter.updateConnection !== \"function\") {\n adapter.updateConnection = (id, body) => updateConnection(client, id, body);\n }\n withCredentialMethods(adapter, client);\n if (typeof adapter.listModelRoutes !== \"function\") {\n adapter.listModelRoutes = async (editorProject) => {\n const project = editorProject || provided;\n if (!project) return [];\n const routes = await listModelRoutes(client, project);\n return routes.map((r) => ({ name: r.name, model: r.modelId, status: r.status }));\n };\n }\n // Same for the `@w6w/store` node's store picker: the project's store names, not free text.\n if (typeof adapter.listDataStores !== \"function\") {\n adapter.listDataStores = async (editorProject) => {\n const project = editorProject || provided;\n if (!project) return [];\n return listDataStores(client, project);\n };\n }\n // ...and its key picker: one page of the named store's entries, searched by key prefix.\n if (typeof adapter.listDataStoreEntries !== \"function\") {\n adapter.listDataStoreEntries = async (store, opts) => {\n const project = opts.project || provided;\n if (!project) return { items: [] };\n return listDataStoreEntries(client, project, store, opts);\n };\n }\n // Persisted node samples, so the editor's picker keeps upstream keys across a reload.\n if (typeof adapter.loadNodeSamples !== \"function\") {\n adapter.loadNodeSamples = (workflowId) => listNodeSamples(client, workflowId);\n }\n // Remembered test inputs, so every test form reopens prefilled with the last values used.\n if (typeof adapter.loadTestInputs !== \"function\") {\n adapter.loadTestInputs = (workflowId) => listTestInputs(client, workflowId);\n }\n if (typeof adapter.saveTestInput !== \"function\") {\n adapter.saveTestInput = (workflowId, nodeId, input) =>\n saveTestInput(client, workflowId, nodeId, input);\n }\n if (typeof adapter.resolveActionFields !== \"function\") {\n adapter.resolveActionFields = (appId, actionKey, body, opts) =>\n resolveActionFields(client, appId, actionKey, body, opts);\n }\n if (typeof adapter.resolveTriggerFields !== \"function\") {\n adapter.resolveTriggerFields = (appId, triggerKey, body, opts) =>\n resolveTriggerFields(client, appId, triggerKey, body, opts);\n }\n // The webhook node's Test tab listens for a real request only when all three exist; without\n // them it falls back to the paste-a-payload form.\n if (typeof adapter.startWebhookListen !== \"function\") {\n adapter.startWebhookListen = (subscriptionId) => startWebhookListen(client, subscriptionId);\n adapter.pollWebhookListen = (subscriptionId, sessionId, opts) =>\n pollWebhookListen(client, subscriptionId, sessionId, opts);\n adapter.stopWebhookListen = (subscriptionId, sessionId) =>\n stopWebhookListen(client, subscriptionId, sessionId);\n }\n return adapter;\n }, [client, provided]);\n return (\n <W6WUIProvider api={api} theme={theme}>\n <EmbedThemeContext.Provider value={theme}>{children}</EmbedThemeContext.Provider>\n </W6WUIProvider>\n );\n}\n\nconst EmbedStatusContext = createContext<EmbedStatus>({ status: \"connecting\", error: null });\n\n/** The session status of the nearest `<W6WEmbedProvider>`. See `deriveEmbedStatus`. */\nexport function useEmbedStatus(): EmbedStatus {\n return useContext(EmbedStatusContext);\n}\n\n/** Publishes `useEmbedStatus()`, and starts the session on mount when `eager`. */\nfunction StatusBridge({\n eager,\n authError,\n onAcquire,\n children,\n}: {\n eager: boolean;\n authError: EmbedAuthError | null;\n onAcquire: () => void;\n children: ReactNode;\n}) {\n const { status, error, refresh } = useW6WSession();\n // `refresh` is per session store, so a rebuilt client (project resolved) is started again.\n useEffect(() => {\n if (eager) void refresh();\n }, [eager, refresh]);\n useEffect(() => {\n if (status === \"loading\" || status === \"renewing\") onAcquire();\n }, [status, onAcquire]);\n const value = useMemo(\n () => deriveEmbedStatus(status, error, authError),\n [status, error, authError],\n );\n return <EmbedStatusContext.Provider value={value}>{children}</EmbedStatusContext.Provider>;\n}\n\n/**\n * Resolves `{use:\"default\"}`. Lives INSIDE `<W6WProvider>` (it needs the client) but at a fixed\n * slot, so it survives the client rebuild that follows resolution; the query key carries no\n * client, so nothing refetches.\n */\nfunction DefaultProjectResolver({\n identityKey,\n enabled,\n onState,\n}: {\n identityKey: string;\n enabled: boolean;\n onState: (key: string, state: EmbedProjectState) => void;\n}) {\n const client = useW6WClient();\n const q = useQuery({\n queryKey: [\"w6w-embed\", \"default-project\"],\n enabled,\n queryFn: async () => {\n const rows = await client.projects.list();\n const home = rows.find((p) => p.isDefault === true);\n if (!home) throw new Error(\"The account has no default project.\");\n return home.id;\n },\n });\n const { isError, error, data } = q;\n const state = useMemo<EmbedProjectState>(\n () =>\n isError\n ? { project: null, status: \"error\", error }\n : data !== undefined\n ? { project: data, status: \"ready\" }\n : { project: null, status: \"resolving\" },\n [isError, error, data],\n );\n useEffect(() => {\n onState(identityKey, state);\n }, [identityKey, state, onState]);\n return null;\n}\n\nexport function W6WEmbedProvider({\n apiOrigin,\n getSession,\n identityKey,\n fallback = null,\n eager = false,\n theme,\n ready,\n project,\n fetch,\n children,\n}: W6WEmbedProviderProps): ReactNode {\n const [registry] = useState(createDraftRegistry);\n const [applied, setApplied] = useState<Applied>(() => ({\n identityKey,\n queryClient: makeQueryClient(),\n }));\n\n // While `identityKey` differs from the applied one a switch is pending: everything below keeps\n // using the values frozen at the last render that was not pending. Otherwise props flow straight\n // through (project / origin changes, token rotation). Idempotent latest-value writes, the same\n // pattern `<W6WProvider>` uses for its own refs.\n const switching = identityKey !== applied.identityKey;\n const forwardedRef = useRef<Forwarded>({ apiOrigin, project, getSession });\n if (!switching) forwardedRef.current = { apiOrigin, project, getSession };\n const forwarded = forwardedRef.current;\n\n // The stable `getSession` handed to `<W6WProvider>`: reads whatever is applied RIGHT NOW. Its\n // target changes in the same render that applies the new tuple, never before the flush settles.\n const sessionRef = useRef(forwarded.getSession);\n sessionRef.current = forwarded.getSession;\n const [stableGetSession] = useState(() => () => sessionRef.current());\n\n useEffect(() => {\n if (identityKey === applied.identityKey) return;\n let cancelled = false;\n const apply = () => {\n if (cancelled) return;\n setApplied({ identityKey, queryClient: makeQueryClient() });\n };\n // Nothing is mounted under a null identity, so nothing can be pending: apply at once.\n if (applied.identityKey === null) {\n apply();\n return () => {\n cancelled = true;\n };\n }\n // `flushAll` never rejects and is bounded; the switch proceeds either way (Q6).\n registry.flushAll().then(apply, apply);\n return () => {\n cancelled = true;\n };\n }, [identityKey, applied.identityKey, registry]);\n\n // The replaced client is dropped once nothing mounted reads it.\n const queryClient = applied.queryClient;\n useEffect(() => () => queryClient.clear(), [queryClient]);\n\n // Default-project resolution, tagged with the identity it was resolved for: a result for A is\n // never read once B is applied.\n const [resolved, setResolved] = useState<{ key: string; state: EmbedProjectState } | null>(null);\n const onResolved = useCallback((key: string, state: EmbedProjectState) => {\n setResolved((prev) =>\n prev &&\n prev.key === key &&\n prev.state.project === state.project &&\n prev.state.status === state.status &&\n prev.state.error === state.error\n ? prev\n : { key, state },\n );\n }, []);\n\n // The terminal partner-token 401, tagged with its identity; cleared when the next acquisition\n // starts (StatusBridge) or the identity changes (the tag no longer matches).\n const [authFailure, setAuthFailure] = useState<{\n key: QueryClient;\n error: EmbedAuthError;\n } | null>(null);\n // The handler is bound to the per-mount client it was created for: a late 401 from a previous\n // `<W6WProvider>` is tagged with ITS client, never the one applied by the time it fires — even\n // when the identity key came back (A -> B -> A mints a new client for the same key).\n const onUnauthorized = useMemo(() => {\n const key = applied.queryClient;\n return (error: ApiError) => {\n setAuthFailure({ key, error: new EmbedAuthError(error) });\n };\n }, [applied.queryClient]);\n const clearAuthFailure = useCallback(() => setAuthFailure(null), []);\n\n const appliedKey = applied.identityKey;\n const spec = forwarded.project;\n // Only exactly `{ use: \"default\" }` asks for the account default; null, `{}`, `[]` or any other\n // object (JS hosts, casts) is \"no project\" and makes no lookup.\n const wantsDefault =\n typeof spec === \"object\" && spec !== null && !Array.isArray(spec) && spec.use === \"default\";\n const projectState: EmbedProjectState = useMemo(() => {\n if (typeof spec === \"string\") return { project: spec, status: \"ready\" };\n if (!wantsDefault) return { project: null, status: \"ready\" };\n return resolved && resolved.key === appliedKey\n ? resolved.state\n : { project: null, status: \"resolving\" };\n }, [spec, wantsDefault, resolved, appliedKey]);\n\n if (appliedKey === null) return fallback;\n\n return (\n <DraftRegistryProvider registry={registry}>\n <QueryClientProvider key={appliedKey} client={queryClient}>\n <W6WProvider\n baseUrl={forwarded.apiOrigin}\n getSession={stableGetSession}\n identityKey={appliedKey}\n ready={ready}\n project={projectState.project ?? undefined}\n fetch={fetch}\n onUnauthorized={onUnauthorized}\n >\n {wantsDefault ? (\n <DefaultProjectResolver\n identityKey={appliedKey}\n enabled={ready !== false}\n onState={onResolved}\n />\n ) : null}\n <EmbedProjectContext.Provider value={projectState}>\n <StatusBridge\n eager={eager}\n authError={authFailure && authFailure.key === queryClient ? authFailure.error : null}\n onAcquire={clearAuthFailure}\n >\n <ClientBridge>\n <UiBridge theme={theme}>{children}</UiBridge>\n </ClientBridge>\n </StatusBridge>\n </EmbedProjectContext.Provider>\n </W6WProvider>\n </QueryClientProvider>\n </DraftRegistryProvider>\n );\n}\n"],"names":["EmbedAuthError","cause","deriveEmbedStatus","sessionStatus","sessionError","authError","startWebhookListen","client","subscriptionId","path","pollWebhookListen","sessionId","opts","stopWebhookListen","makeQueryClient","QueryClient","ClientBridge","children","jsx","EmbedClientProvider","useW6WClient","UiBridge","theme","provided","useProvidedProject","api","useMemo","adapter","createW6WUiAdapter","id","body","updateConnection","withCredentialMethods","editorProject","project","listModelRoutes","r","listDataStores","store","listDataStoreEntries","workflowId","listNodeSamples","listTestInputs","nodeId","input","saveTestInput","appId","actionKey","resolveActionFields","triggerKey","resolveTriggerFields","W6WUIProvider","EmbedThemeContext","EmbedStatusContext","createContext","useEmbedStatus","useContext","StatusBridge","eager","onAcquire","status","error","refresh","useW6WSession","useEffect","value","DefaultProjectResolver","identityKey","enabled","onState","q","useQuery","home","p","isError","data","state","W6WEmbedProvider","apiOrigin","getSession","fallback","ready","fetch","registry","useState","createDraftRegistry","applied","setApplied","switching","forwardedRef","useRef","forwarded","sessionRef","stableGetSession","cancelled","apply","queryClient","resolved","setResolved","onResolved","useCallback","key","prev","authFailure","setAuthFailure","onUnauthorized","clearAuthFailure","appliedKey","spec","wantsDefault","projectState","DraftRegistryProvider","Q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AA,IAAA;AAAA,MACC,SAASvB,EAAU;AAAA,MACnB,YAAYE;AAAA,MACZ,aAAac;AAAA,MACb,OAAA1B;AAAA,MACA,SAAS6B,EAAa,WAAW;AAAA,MACjC,OAAA5B;AAAA,MACA,gBAAAuB;AAAA,MAEC,UAAA;AAAA,QAAAI,IACC,gBAAA3F;AAAA,UAACgD;AAAA,UAAA;AAAA,YACC,aAAayC;AAAA,YACb,SAAS1B,MAAU;AAAA,YACnB,SAASkB;AAAA,UAAA;AAAA,QAAA,IAET;AAAA,QACJ,gBAAAjF,EAACiG,GAAoB,UAApB,EAA6B,OAAOL,GACnC,UAAA,gBAAA5F;AAAA,UAACuC;AAAA,UAAA;AAAA,YACC,OAAAC;AAAA,YACA,WAAW6C,KAAeA,EAAY,QAAQP,IAAcO,EAAY,QAAQ;AAAA,YAChF,WAAWG;AAAA,YAEX,4BAAC1F,IAAA,EACC,UAAA,gBAAAE,EAACG,IAAA,EAAS,OAAAC,GAAe,UAAAL,GAAS,EAAA,CACpC;AAAA,UAAA;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,EACF,GA5BwB0F,CA6B1B,GACF;AAEJ;"}
@@ -0,0 +1,26 @@
1
+ import { CallableKind } from './callable-kind.ts';
2
+ /** `name (copy)`, `name (copy 2)`, … — the first one no row in `taken` already shows. */
3
+ export declare function copyDisplayName(name: string, taken: Iterable<string | null | undefined>): string;
4
+ /**
5
+ * `key-copy`, `key-copy-2`, … — the first one not in `taken`, cut so it stays within the key
6
+ * grammar's 39 characters (the cut drops the base's tail, never the suffix, and never leaves a
7
+ * trailing or doubled `-`).
8
+ */
9
+ export declare function copyKey(key: string, taken: Iterable<string | null | undefined>): string;
10
+ /** The siblings a copy must not collide with: their keys and their display names. */
11
+ export interface DuplicateSiblings {
12
+ keys: Iterable<string | null | undefined>;
13
+ names: Iterable<string | null | undefined>;
14
+ }
15
+ /**
16
+ * The definition to POST for a copy of `source` under `newId`. `source` is the kind's editable
17
+ * definition (`callableRecord(...).definition` for a Function/Endpoint, the `workflow` body of a
18
+ * Workflow's `get`) and is never mutated.
19
+ *
20
+ * - `key` — a fresh sibling-free key when the source has one; a Workflow without a key stays
21
+ * without one (its key is optional).
22
+ * - `displayName` — `"<name> (copy)"`, falling back to the key when the source has no name.
23
+ * - Workflow `name` — a blank Workflow's `name` IS its id (`blankDefinition`), so a `name` equal
24
+ * to the old id follows the id; any other `name` is kept.
25
+ */
26
+ export declare function duplicateDefinition(kind: CallableKind, source: Record<string, unknown>, newId: string, siblings: DuplicateSiblings): Record<string, unknown>;
@@ -14,6 +14,18 @@ export interface CallablePolicy {
14
14
  retry?: RetryPolicy;
15
15
  onError?: CallableOnError;
16
16
  reroute?: ErrorReroute;
17
+ /**
18
+ * How long the Function's app call waits before it fails, in ms. Lives on
19
+ * the definition as `impl.timeoutMs` (the action arm only), absent = the
20
+ * server default (the action's own limit, else 120 s).
21
+ */
22
+ timeoutMs?: number;
23
+ /**
24
+ * READ-ONLY: true when the definition's `impl` is an app action, i.e. when a
25
+ * timeout means anything. Set by {@link policyFromDefinition}; never written
26
+ * back by {@link definitionWithPolicy}.
27
+ */
28
+ timeoutApplicable?: boolean;
17
29
  }
18
30
  /** A definition carrying (at least) the three fields above, plus whatever
19
31
  * else `Fn`/`Endpoint` declares — `definitionWithPolicy` preserves every
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A one-line preview of a workflow variable's default for the Data rail's read-only list: a
3
+ * literal as itself, an expression with each reference as `{{…}}`, a secret masked. `null` when
4
+ * there is no default.
5
+ */
6
+ export declare function variableDefaultPreview(value: unknown): string | null;
package/dist/lib.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  "use client";
2
2
  import { d as l, f as d, a as c, i as p, p as u, b as m, r as f, c as g, s as S, t as b, e as w, w as R, g as v } from "./setup-incomplete-BHs3Lpfy.js";
3
- import { d as h, a as y, e as I, i as x, b as D, p as C, r as P, c as U, f as A, s as E, g as K, t as T, v as k, h as L } from "./document-sources-DNmBojx6.js";
3
+ import { d as h, a as x, e as y, i as I, b as D, p as C, r as P, c as U, f as A, s as E, g as K, t as T, v as k, h as L } from "./document-sources-Khcw2zB5.js";
4
4
  import { a as W, b as N, e as _, h as B, c as O, d as j, i as H, m as q, p as G, r as M, f as Y, g as $, s as z, j as J, k as Q, l as X, t as Z, v as aa, w as ea, n as sa } from "./import-bindings-EUtxZ9Ti.js";
5
- import { c as ra, d as ia, i as oa, p as na } from "./settings-rail--GdRMusb.js";
6
- import { A as da, b as ca, f as pa, i as ua, a as ma, c as fa, s as ga, u as Sa } from "./slug-BVdgiP_L.js";
7
- import { i as wa, s as Ra } from "./spec-import-invalidation-D3retX4Q.js";
8
- import { U as Fa, b as ha, n as ya } from "./workflow-blank-BJFLdGyE.js";
9
- import { I as xa, c as Da, f as Ca, i as Pa, a as Ua, m as Aa, p as Ea, s as Ka, t as Ta, b as ka, d as La, u as Va, e as Wa, g as Na } from "./coerce-input-DFJ4n_wc.js";
5
+ import { d as ra, i as ia, p as oa } from "./settings-rail-gUU2ZbSw.js";
6
+ import { A as la, b as da, f as ca, i as pa, a as ua, c as ma, s as fa, u as ga } from "./slug-BVdgiP_L.js";
7
+ import { i as ba, s as wa } from "./spec-import-invalidation-D3retX4Q.js";
8
+ import { U as va, b as Fa, n as ha } from "./workflow-blank-BJFLdGyE.js";
9
+ import { I as ya, c as Ia, f as Da, i as Ca, a as Pa, m as Ua, p as Aa, s as Ea, t as Ka, b as Ta, d as ka, u as La, e as Va, g as Wa } from "./coerce-input-DFJ4n_wc.js";
10
+ import { c as _a } from "./callable-record-Bhxim8C1.js";
10
11
  function r(s) {
11
12
  const e = new URLSearchParams(s), a = e.get("edit");
12
13
  if (a === null || a === "") return null;
@@ -19,46 +20,46 @@ function i(s) {
19
20
  return a != null && a.startsWith("run_") ? a : null;
20
21
  }
21
22
  export {
22
- da as ACCOUNT_SLUG_RE,
23
- xa as INPUT_TYPES,
24
- Fa as UNTITLED_WORKFLOW,
23
+ la as ACCOUNT_SLUG_RE,
24
+ ya as INPUT_TYPES,
25
+ va as UNTITLED_WORKFLOW,
25
26
  W as allowedModes,
26
- ha as blankDefinition,
27
+ Fa as blankDefinition,
27
28
  N as buildRows,
28
- ca as buildSnippet,
29
- ra as callableRecord,
30
- Da as coerceInput,
31
- ia as definitionWithPolicy,
29
+ da as buildSnippet,
30
+ _a as callableRecord,
31
+ Ia as coerceInput,
32
+ ra as definitionWithPolicy,
32
33
  l as disabledBannerState,
33
34
  h as documentSampleValues,
34
- y as duplicateKeyIndexes,
35
- I as errorHandlerSelfDecision,
35
+ x as duplicateKeyIndexes,
36
+ y as errorHandlerSelfDecision,
36
37
  _ as evaluateEdit,
37
- Ca as fieldsFromWorkflow,
38
- pa as filterKeyInput,
38
+ Da as fieldsFromWorkflow,
39
+ ca as filterKeyInput,
39
40
  d as findBindingProblems,
40
41
  c as findSetupIncomplete,
41
42
  B as hasDefinitionActions,
42
43
  O as hasDelete,
43
44
  j as hasVersionHistory,
44
- Pa as implToTarget,
45
- Ua as inputsForSave,
45
+ Ca as implToTarget,
46
+ Pa as inputsForSave,
46
47
  p as invalidReason,
47
- wa as invalidateImportedCallable,
48
- x as isCodeRailAvailable,
49
- ua as isEndpointKey,
48
+ ba as invalidateImportedCallable,
49
+ I as isCodeRailAvailable,
50
+ pa as isEndpointKey,
50
51
  D as isExprDefault,
51
52
  H as isRowArchived,
52
- oa as isSettingsRailAvailable,
53
- ma as isUrnAddressable,
54
- fa as isValidAccountSlug,
53
+ ia as isSettingsRailAvailable,
54
+ ua as isUrnAddressable,
55
+ ma as isValidAccountSlug,
55
56
  r as legacyEditRedirect,
56
- Aa as mergeSeed,
57
+ Ua as mergeSeed,
57
58
  q as metadataFieldsForKind,
58
- ya as nextUntitledName,
59
- Ea as paramsToFields,
59
+ ha as nextUntitledName,
60
+ Aa as paramsToFields,
60
61
  G as parseImportPaste,
61
- na as policyFromDefinition,
62
+ oa as policyFromDefinition,
62
63
  C as projectDocumentSources,
63
64
  u as publishDisabledReason,
64
65
  m as publishProblems,
@@ -74,24 +75,24 @@ export {
74
75
  z as setBind,
75
76
  J as setCreateName,
76
77
  Q as setUnconfigured,
77
- Ka as shouldSeed,
78
- ga as slugify,
78
+ Ea as shouldSeed,
79
+ fa as slugify,
79
80
  X as specCollectionForKind,
80
- Ra as specImportListKey,
81
+ wa as specImportListKey,
81
82
  E as startingDataCollisions,
82
83
  K as startingDataForSave,
83
84
  S as stepValid,
84
- Ta as targetIsBound,
85
- ka as targetRef,
86
- La as targetToImpl,
85
+ Ka as targetIsBound,
86
+ Ta as targetRef,
87
+ ka as targetToImpl,
87
88
  Z as toSelections,
88
89
  T as toSnippetCallable,
89
90
  b as triggerInputSeed,
90
91
  w as triggerPreviews,
91
- Sa as unavailableReason,
92
- Va as uncoveredForEndpoint,
93
- Wa as uncoveredForFunction,
94
- Na as uncoveredRequiredKeys,
92
+ ga as unavailableReason,
93
+ La as uncoveredForEndpoint,
94
+ Va as uncoveredForFunction,
95
+ Wa as uncoveredRequiredKeys,
95
96
  k as variablesForSave,
96
97
  L as varsRailFor,
97
98
  aa as visibleRows,
package/dist/lib.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.mjs","sources":["../src/lib/workflow-route.ts"],"sourcesContent":["// T4.1.1 (R-3): `/<account>/<project>/workflows/:id` is the workflow visual\n// editor's canonical URL; the older `workflows?edit=<id>` form survives only as\n// an alias. Parsing that alias is a pure URL question with no React and no\n// router in it, so it lives here — `.ts`, zero imports — rather than inline in\n// `WorkflowsPage.tsx`, which `node --test` cannot load (JSX).\n\n/**\n * Read the legacy `edit` parameter off a location's search string.\n *\n * Returns `null` when there is nothing to redirect: no `edit` key at all, or\n * one that is empty (`?edit=` is not an id). Otherwise `id` is the `edit`\n * value and `search` is the rest of the query — `edit` removed, every other\n * parameter kept in its original order — as a leading-`?` search string, or\n * `\"\"` when nothing is left.\n *\n * legacyEditRedirect(\"?edit=wf_a\") // { id: \"wf_a\", search: \"\" }\n * legacyEditRedirect(\"?edit=wf_a&tab=steps\") // { id: \"wf_a\", search: \"?tab=steps\" }\n */\nexport function legacyEditRedirect(search: string): { id: string; search: string } | null {\n const params = new URLSearchParams(search);\n const id = params.get(\"edit\");\n if (id === null || id === \"\") return null;\n params.delete(\"edit\");\n const rest = params.toString();\n return { id, search: rest === \"\" ? \"\" : `?${rest}` };\n}\n\n// T2.4.2 — the History page's \"open in visual view\" link lands on\n// `workflows/:id?run=<runId>`; `WorkflowsPage` reads the `run` param on mount\n// and seeds `activeRunId` from it (EXTEND, not rebuild — the live-run\n// overlay machinery already handles a terminal run identically to a live\n// one). Guarded to `run_`-prefixed values only, so an unrelated/garbled\n// param (or this file's OWN `edit` alias from a stale link) never gets\n// treated as a run id.\n\n/**\n * Read the `run` query param off a location's search string, honouring it\n * only when it looks like a real run id.\n *\n * runParamFromSearch(\"?run=run_1&x=1\") // \"run_1\"\n * runParamFromSearch(\"?run=\") // null\n * runParamFromSearch(\"?run=wf_1\") // null — not a run id\n * runParamFromSearch(\"\") // null\n */\nexport function runParamFromSearch(search: string): string | null {\n const params = new URLSearchParams(search);\n const run = params.get(\"run\");\n return run?.startsWith(\"run_\") ? run : null;\n}\n"],"names":["legacyEditRedirect","search","params","id","rest","runParamFromSearch","run"],"mappings":";;;;;;;;;AAkBO,SAASA,EAAmBC,GAAuD;AACxF,QAAMC,IAAS,IAAI,gBAAgBD,CAAM,GACnCE,IAAKD,EAAO,IAAI,MAAM;AAC5B,MAAIC,MAAO,QAAQA,MAAO,GAAI,QAAO;AACrC,EAAAD,EAAO,OAAO,MAAM;AACpB,QAAME,IAAOF,EAAO,SAAA;AACpB,SAAO,EAAE,IAAAC,GAAI,QAAQC,MAAS,KAAK,KAAK,IAAIA,CAAI,GAAA;AAClD;AAmBO,SAASC,EAAmBJ,GAA+B;AAEhE,QAAMK,IADS,IAAI,gBAAgBL,CAAM,EACtB,IAAI,KAAK;AAC5B,SAAOK,KAAA,QAAAA,EAAK,WAAW,UAAUA,IAAM;AACzC;"}
1
+ {"version":3,"file":"lib.mjs","sources":["../src/lib/workflow-route.ts"],"sourcesContent":["// T4.1.1 (R-3): `/<account>/<project>/workflows/:id` is the workflow visual\n// editor's canonical URL; the older `workflows?edit=<id>` form survives only as\n// an alias. Parsing that alias is a pure URL question with no React and no\n// router in it, so it lives here — `.ts`, zero imports — rather than inline in\n// `WorkflowsPage.tsx`, which `node --test` cannot load (JSX).\n\n/**\n * Read the legacy `edit` parameter off a location's search string.\n *\n * Returns `null` when there is nothing to redirect: no `edit` key at all, or\n * one that is empty (`?edit=` is not an id). Otherwise `id` is the `edit`\n * value and `search` is the rest of the query — `edit` removed, every other\n * parameter kept in its original order — as a leading-`?` search string, or\n * `\"\"` when nothing is left.\n *\n * legacyEditRedirect(\"?edit=wf_a\") // { id: \"wf_a\", search: \"\" }\n * legacyEditRedirect(\"?edit=wf_a&tab=steps\") // { id: \"wf_a\", search: \"?tab=steps\" }\n */\nexport function legacyEditRedirect(search: string): { id: string; search: string } | null {\n const params = new URLSearchParams(search);\n const id = params.get(\"edit\");\n if (id === null || id === \"\") return null;\n params.delete(\"edit\");\n const rest = params.toString();\n return { id, search: rest === \"\" ? \"\" : `?${rest}` };\n}\n\n// T2.4.2 — the History page's \"open in visual view\" link lands on\n// `workflows/:id?run=<runId>`; `WorkflowsPage` reads the `run` param on mount\n// and seeds `activeRunId` from it (EXTEND, not rebuild — the live-run\n// overlay machinery already handles a terminal run identically to a live\n// one). Guarded to `run_`-prefixed values only, so an unrelated/garbled\n// param (or this file's OWN `edit` alias from a stale link) never gets\n// treated as a run id.\n\n/**\n * Read the `run` query param off a location's search string, honouring it\n * only when it looks like a real run id.\n *\n * runParamFromSearch(\"?run=run_1&x=1\") // \"run_1\"\n * runParamFromSearch(\"?run=\") // null\n * runParamFromSearch(\"?run=wf_1\") // null — not a run id\n * runParamFromSearch(\"\") // null\n */\nexport function runParamFromSearch(search: string): string | null {\n const params = new URLSearchParams(search);\n const run = params.get(\"run\");\n return run?.startsWith(\"run_\") ? run : null;\n}\n"],"names":["legacyEditRedirect","search","params","id","rest","runParamFromSearch","run"],"mappings":";;;;;;;;;;AAkBO,SAASA,EAAmBC,GAAuD;AACxF,QAAMC,IAAS,IAAI,gBAAgBD,CAAM,GACnCE,IAAKD,EAAO,IAAI,MAAM;AAC5B,MAAIC,MAAO,QAAQA,MAAO,GAAI,QAAO;AACrC,EAAAD,EAAO,OAAO,MAAM;AACpB,QAAME,IAAOF,EAAO,SAAA;AACpB,SAAO,EAAE,IAAAC,GAAI,QAAQC,MAAS,KAAK,KAAK,IAAIA,CAAI,GAAA;AAClD;AAmBO,SAASC,EAAmBJ,GAA+B;AAEhE,QAAMK,IADS,IAAI,gBAAgBL,CAAM,EACtB,IAAI,KAAK;AAC5B,SAAOK,KAAA,QAAAA,EAAK,WAAW,UAAUA,IAAM;AACzC;"}
@@ -1,4 +1,4 @@
1
- import { CallableListProps, CallableListRow } from '@w6w/ui';
1
+ import { CallableListGroup, CallableListProps, CallableListRow } from '@w6w/ui';
2
2
  import { ReactNode } from 'react';
3
3
  import { CallableKind } from '../lib/callable-descriptors.ts';
4
4
  import { ArchivableRow } from '../lib/rail-settings.ts';
@@ -37,6 +37,9 @@ export declare function CallableKindList<Row extends {
37
37
  toRow: (row: Row) => Omit<CallableListRow, "id" | "archived" | "status" | "meta" | "menu">;
38
38
  /** The row's name, key, update time, state and copy items: status, meta line and menu. */
39
39
  facts: (row: Row) => CallableRowFacts;
40
+ /** Status tabs between All and Archived (e.g. Active, Draft), and which one a row sits in. */
41
+ groups?: readonly CallableListGroup[];
42
+ group?: (row: Row) => string | undefined;
40
43
  /** Only the Import flow reads it (the workflow list key); `null` means no project. */
41
44
  project: string | null;
42
45
  onOpen?: (id: string, event?: React.MouseEvent<Element>) => void;
@@ -1,5 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { CallableKind } from '../lib/callable-descriptors.ts';
3
+ import { DuplicateSiblings } from '../lib/callable-duplicate.ts';
3
4
  /** "3m ago", "5h ago", "2d ago", else the date. */
4
5
  export declare function updatedAgo(iso: string | null | undefined, now?: number): string | null;
5
6
  /** The state beside a row's title: "disabled" wins over the kind's own state (`base`). */
@@ -30,4 +31,8 @@ export declare function CallableRowMenu(props: {
30
31
  name: string;
31
32
  archived: boolean;
32
33
  copy?: readonly CopyItem[];
34
+ /** The list's keys and names, so Duplicate picks ones no sibling holds. Read at click time. */
35
+ siblings?: () => DuplicateSiblings;
36
+ /** Where Duplicate creates the copy — a Workflow is project-scoped, the others ignore it. */
37
+ project?: string | null;
33
38
  }): import("react").JSX.Element;
@@ -12,6 +12,8 @@ export interface CredentialDetailProps {
12
12
  empty?: ReactNode;
13
13
  };
14
14
  }
15
+ /** `client_email` → "Client email", `project_id` → "Project ID": a display key as a label. */
16
+ export declare function factLabel(key: string): string;
15
17
  /**
16
18
  * Keyed by `credentialId`, so switching credentials remounts the body: a value typed for one
17
19
  * credential is never carried to (and posted to) the next.
@@ -4,7 +4,7 @@ export type CredentialFieldValues = Record<string, string>;
4
4
  /**
5
5
  * One input per descriptor field, controlled by `values`. Secret fields are masked (CSS, never
6
6
  * `type="password"`, which would trigger the browser's save-password prompt), `multiline` ones are
7
- * textareas. Shared with `CredentialDetail`'s rotate box so both render a type the same way.
7
+ * textareas — except a multiline SECRET (a key file), which is pasted unmasked and then previewed. Shared with `CredentialDetail`'s rotate box so both render a type the same way.
8
8
  */
9
9
  export declare function CredentialFieldInputs({ fields, values, onChange, idPrefix, }: {
10
10
  fields: readonly CredentialTypeField[];
@@ -11,7 +11,8 @@ export interface EndpointListProps {
11
11
  slots?: CallableListProps["slots"];
12
12
  }
13
13
  /**
14
- * The account's Endpoints: rows from `GET /endpoints`, archived ones behind a Show-archived toggle,
14
+ * The account's Endpoints: rows from `GET /endpoints`, filtered by status tabs (All, Ready, Unfinished,
15
+ * Archived) and a search box,
15
16
  * an "Unfinished" tag on drafts (no target yet), a New button that creates an Endpoint
16
17
  * (create-first: the row is POSTed before any editor exists), and Import. Never navigates — the
17
18
  * host wires `onOpen` / `getHref` / `onCreated`.
@@ -11,7 +11,8 @@ export interface WorkflowListProps {
11
11
  slots?: CallableListProps["slots"];
12
12
  }
13
13
  /**
14
- * A project's Workflows: rows from `GET /workflows`, archived ones behind a Show-archived toggle,
14
+ * A project's Workflows: rows from `GET /workflows`, filtered by status tabs (All, Active, Draft,
15
+ * Archived) and a search box,
15
16
  * a New button that creates a blank Workflow (the row is POSTed before any editor exists), and
16
17
  * Import. With no project there is nothing to list and New refuses. Never navigates — the host
17
18
  * wires `onOpen` / `getHref` / `onCreated`.