@capxul/sdk-react 1.0.0-alpha.9 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/internal/capxul-bootstrap-context.tsx","../src/internal/capxul-client-context.tsx","../src/provider.tsx","../../errors/src/errors.ts","../../errors/src/convex-error-decoding.ts","../src/internal/require-bootstrapped-client.ts","../src/internal/reactivity-keys.ts","../src/internal/unwrap-capxul-result.ts","../src/hooks/use-capxul-session.ts","../src/hooks/use-capxul-profile.ts","../src/internal/is-vitest-runtime.ts","../src/internal/invalidate-auth-boundary.ts","../src/hooks/use-capxul-account-lifecycle.ts","../src/hooks/use-capxul-account-balance.ts","../src/hooks/use-capxul-account-fund.ts","../src/hooks/use-capxul-sign-in.ts","../src/hooks/use-capxul-verify-otp.ts","../src/hooks/use-capxul-sign-out.ts","../src/hooks/use-capxul-sub-accounts.ts","../src/hooks/use-capxul-orgs.ts","../src/hooks/use-capxul-org.ts","../src/hooks/use-capxul-org-members.ts","../src/hooks/use-capxul-org-roles.ts","../src/hooks/use-capxul-org-deploy-roles.ts","../src/hooks/use-capxul-org-treasury.ts","../src/hooks/use-capxul-create-org.ts","../src/hooks/use-capxul-complete-personal-onboarding.ts","../src/hooks/use-capxul-complete-organization-onboarding.ts","../src/hooks/use-capxul-invite-member.ts","../src/hooks/use-capxul-remove-member.ts","../src/hooks/use-capxul-assign-role.ts","../src/hooks/use-capxul-switch-acting-entity.ts"],"sourcesContent":["\"use client\";\n\n// Bootstrap-state context (SDK publish readiness · sdk-provider-owned-bootstrap).\n//\n// `<CapxulProvider>` runs the async client bootstrap and publishes its status\n// here. Consumers read it via `useCapxul()` for an opt-in splash / error / retry\n// surface. Data hooks do NOT need it — they sit in `isPending` until the client\n// resolves (see `useCapxulClientOrNull`).\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { CapxulError } from \"@capxul/errors\";\n\nexport type CapxulBootstrapStatus = \"bootstrapping\" | \"ready\" | \"error\";\n\nexport interface CapxulBootstrapState {\n readonly status: CapxulBootstrapStatus;\n readonly error: CapxulError | null;\n readonly retry: () => void;\n}\n\nconst CapxulBootstrapContext = createContext<CapxulBootstrapState | null>(null);\n\nexport interface CapxulBootstrapProviderProps {\n readonly value: CapxulBootstrapState;\n readonly children: ReactNode;\n}\n\nexport function CapxulBootstrapProvider({ value, children }: CapxulBootstrapProviderProps) {\n return (\n <CapxulBootstrapContext.Provider value={value}>{children}</CapxulBootstrapContext.Provider>\n );\n}\n\nexport function useCapxul(): CapxulBootstrapState {\n const state = useContext(CapxulBootstrapContext);\n if (state === null) {\n throw new Error(\"useCapxul must be used within <CapxulProvider>\");\n }\n return state;\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { CapxulClient } from \"@capxul/sdk\";\n\nconst MISSING_CAPXUL_CLIENT_PROVIDER = Symbol(\"MISSING_CAPXUL_CLIENT_PROVIDER\");\n\nconst CapxulClientContext = createContext<\n CapxulClient | null | typeof MISSING_CAPXUL_CLIENT_PROVIDER\n>(MISSING_CAPXUL_CLIENT_PROVIDER);\n\nexport interface CapxulClientProviderProps {\n readonly client: CapxulClient | null;\n readonly children: ReactNode;\n}\n\nexport function CapxulClientProvider({ client, children }: CapxulClientProviderProps) {\n return <CapxulClientContext.Provider value={client}>{children}</CapxulClientContext.Provider>;\n}\n\nexport function useCapxulClient(): CapxulClient {\n const client = useCapxulClientOrNull();\n if (client === null) {\n throw new Error(\"useCapxulClient called before <CapxulProvider> bootstrap resolved\");\n }\n return client;\n}\n\n/**\n * Returns the client, or `null` while `<CapxulProvider>` is still bootstrapping.\n * Data hooks use this so they can sit in `isPending` (disabled query) until the\n * client resolves, rather than throwing during bootstrap.\n */\nexport function useCapxulClientOrNull(): CapxulClient | null {\n const client = useContext(CapxulClientContext);\n if (client === MISSING_CAPXUL_CLIENT_PROVIDER) {\n throw new Error(\"useCapxulClient must be used within <CapxulProvider>\");\n }\n return client;\n}\n","\"use client\";\n\n// CapxulProvider — owns the client lifecycle (sdk-provider-owned-bootstrap.md).\n//\n// Two modes:\n// - `publishableKey` (browser/app): the provider runs the async bootstrap via\n// `createCapxulClient`, owns the TanStack QueryClient, exposes status via\n// `useCapxul()`, and closes the client on unmount / re-bootstrap.\n// - `client` (Node/server consumers that bootstrap before React, plus test\n// harnesses): a pre-built client is supplied; the provider is `ready`\n// immediately and leaves that client's lifecycle to the caller.\n//\n// `signer` threads into the deploy lane via `createCapxulClient` when supplied.\n// Browser apps with `requirement: \"deployed\"` omit it — the SDK auto-wires Openfort.\n\nimport * as React from \"react\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { AccountRequirement, CapxulClient, CapxulSigner } from \"@capxul/sdk\";\nimport { createCapxulClient } from \"@capxul/sdk\";\n\nimport {\n CapxulBootstrapProvider,\n type CapxulBootstrapState,\n} from \"./internal/capxul-bootstrap-context\";\nimport { CapxulClientProvider } from \"./internal/capxul-client-context\";\n\nvoid React;\n\ntype CapxulProviderSharedProps = {\n /** Bring your own QueryClient; otherwise the provider creates one. */\n readonly queryClient?: QueryClient;\n readonly children: ReactNode;\n};\n\n/** Browser / app path — the provider bootstraps the client from a publishable key. */\ntype CapxulProviderPublishableKeyProps = CapxulProviderSharedProps & {\n readonly publishableKey: string;\n readonly client?: never;\n /** Init-time account readiness target. Default `\"none\"`. */\n readonly requirement?: AccountRequirement;\n /**\n * Optional consumer-held signer for the deploy lane. Omitted in browser apps\n * with `requirement: \"deployed\"` — the SDK wires Openfort from bootstrap.\n */\n readonly signer?: CapxulSigner;\n};\n\n/**\n * Node / server / test path — a pre-built client is supplied; lifecycle stays\n * with the caller. Mutually exclusive with `publishableKey`.\n */\ntype CapxulProviderInjectedClientProps = CapxulProviderSharedProps & {\n readonly client: CapxulClient;\n readonly publishableKey?: never;\n readonly requirement?: never;\n readonly signer?: never;\n};\n\nexport type CapxulProviderProps =\n | CapxulProviderPublishableKeyProps\n | CapxulProviderInjectedClientProps;\n\nfunction makeDefaultQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: { retry: 2, staleTime: 30_000 },\n mutations: { retry: 0 },\n },\n });\n}\n\nfunction isCapxulQueryKey(queryKey: readonly unknown[]): boolean {\n return queryKey[0] === \"capxul\";\n}\n\nfunction clearClientScopedQueries(queryClient: QueryClient, ownsQueryClient: boolean): void {\n if (ownsQueryClient) {\n queryClient.clear();\n return;\n }\n queryClient.removeQueries({ predicate: (query) => isCapxulQueryKey(query.queryKey) });\n}\n\nexport function CapxulProvider(props: CapxulProviderProps) {\n const {\n publishableKey,\n client: injectedClient,\n requirement,\n signer,\n queryClient,\n children,\n } = props;\n\n // The QueryClient is pinned at mount: a later `queryClient` prop swap is\n // ignored (consumers should not swap it mid-tree) — pass your own once, or\n // let the provider create one.\n const [resolvedQueryClient] = useState(() => queryClient ?? makeDefaultQueryClient());\n const [ownsQueryClient] = useState(() => queryClient === undefined);\n\n const [client, setClient] = useState<CapxulClient | null>(injectedClient ?? null);\n const previousClientRef = useRef<CapxulClient | null>(injectedClient ?? null);\n const [status, setStatus] = useState<CapxulBootstrapState[\"status\"]>(\n injectedClient === undefined ? \"bootstrapping\" : \"ready\",\n );\n const [error, setError] = useState<CapxulError | null>(null);\n const [attempt, setAttempt] = useState(0);\n\n const retry = useCallback(() => {\n setAttempt((n) => n + 1);\n }, []);\n\n // Bootstrap path: the provider owns the client it creates and closes it on\n // unmount / re-bootstrap. The `cancelled` guard closes a client that resolves\n // after the effect tears down (StrictMode double-invoke, retry, unmount).\n useEffect(() => {\n if (publishableKey === undefined) return;\n let cancelled = false;\n let created: CapxulClient | null = null;\n setStatus(\"bootstrapping\");\n setError(null);\n setClient(null);\n void (async () => {\n const result = await createCapxulClient({\n publishableKey,\n ...(requirement === undefined ? {} : { requirement }),\n ...(signer === undefined ? {} : { signer }),\n });\n if (cancelled) {\n if (result.ok) await result.value._internal.close?.();\n return;\n }\n if (result.ok) {\n created = result.value;\n setClient(result.value);\n setStatus(\"ready\");\n } else {\n setError(result.error);\n setStatus(\"error\");\n }\n })();\n return () => {\n cancelled = true;\n void created?._internal.close?.();\n };\n }, [publishableKey, requirement, signer, attempt]);\n\n // Injected-client path: track prop identity; lifecycle stays with the caller.\n useEffect(() => {\n if (injectedClient === undefined) return;\n setClient(injectedClient);\n setStatus(\"ready\");\n setError(null);\n }, [injectedClient]);\n\n useEffect(() => {\n const previous = previousClientRef.current;\n if (previous !== null && previous !== client) {\n clearClientScopedQueries(resolvedQueryClient, ownsQueryClient);\n }\n previousClientRef.current = client;\n }, [client, ownsQueryClient, resolvedQueryClient]);\n\n const bootstrapState = useMemo<CapxulBootstrapState>(\n () => ({ status, error, retry }),\n [status, error, retry],\n );\n\n // Validate AFTER the hooks so a publishableKey↔client prop transition never\n // changes the hook count (rules of hooks); the throw aborts render cleanly.\n if ((publishableKey === undefined) === (injectedClient === undefined)) {\n throw new Error(\"CapxulProvider requires exactly one of `publishableKey` or `client`\");\n }\n\n return (\n <QueryClientProvider client={resolvedQueryClient}>\n <CapxulBootstrapProvider value={bootstrapState}>\n <CapxulClientProvider client={client}>{children}</CapxulClientProvider>\n </CapxulBootstrapProvider>\n </QueryClientProvider>\n );\n}\n","// The canonical error-code catalog as a runtime constant. `CapxulErrorCode`\n// is derived from it so the type and any runtime check that needs to\n// enumerate codes (e.g. the convex-error codec's `KNOWN_CODES`) share a\n// single source of truth — a TypeScript union alone can't be introspected\n// at runtime, which previously forced a hand-maintained duplicate.\nexport const CAPXUL_ERROR_CODES = [\n \"NOT_AUTHENTICATED\",\n \"EMAIL_DELIVERY_FAILED\",\n \"PROFILE_NOT_FOUND\",\n \"SMART_ACCOUNT_MISSING\",\n \"PLAYER_NOT_FOUND\",\n \"ACCOUNT_NOT_FOUND\",\n \"PROVIDER_ERROR\",\n \"INVALID_INPUT\",\n \"ENV_MISSING\",\n \"NOT_IMPLEMENTED\",\n \"VERIFICATION_REQUIRED\",\n \"INSUFFICIENT_BALANCE\",\n \"INVALID_RECIPIENT\",\n \"ROLE_PERMISSION_DENIED\",\n \"TRANSACTION_FAILED\",\n \"RATE_LIMITED\",\n \"NETWORK_ERROR\",\n \"UNKNOWN\",\n \"OTP_EXPIRED\",\n \"SIGNER_REJECTED\",\n \"CANCELLED\",\n \"WRONG_STATE\",\n] as const;\n\nexport type CapxulErrorCode = (typeof CAPXUL_ERROR_CODES)[number];\n\n/**\n * Why an auth/provider call failed — a flat CAUSE enum. The *where* (which\n * OpenFort operation) stays in the separate `operation` detail field; this\n * names the root cause so a single `$exception` can be triaged without\n * parsing the message. Five members, no free strings:\n *\n * - `auth-origin-mismatch`: OTP cookies live on `localhost:PORT` but OpenFort\n * hits the Convex host → no session reaches the provider.\n * - `stale-openfort-cache`: an old `userId` in scoped storage makes the SDK\n * skip re-auth → 401 on `v2/accounts`.\n * - `app-env-allowlist`: missing `VITE_CAPXUL_CONVEX_SITE_URL` / the origin is\n * not allowlisted → 401.\n * - `no-secure-context`: sandboxed/headless browser with no Web Crypto, so\n * `getAddress`/`configure` can never produce an address. Previously vanished\n * into `unknown`; the signer's secure-context probe now names it.\n * - `unknown`: catch-all when no cause could be determined.\n */\nexport type FailureMode =\n | \"auth-origin-mismatch\"\n | \"stale-openfort-cache\"\n | \"app-env-allowlist\"\n | \"no-secure-context\"\n | \"unknown\";\n\nexport type CapxulErrorDetails = Record<string, unknown>;\n\nexport type SignerSource = \"openfort-embedded\" | \"injected-eip1193\" | \"local-private-key\";\n\nexport type VerificationRequiredDetails =\n | { readonly requiredTier: number }\n | { readonly rail: string; readonly currentKind: string };\n\nexport type SerializedCapxulError = {\n readonly code: CapxulErrorCode;\n readonly message: string;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n};\n\nexport type CapxulErrorOptions = {\n readonly cause?: unknown;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n};\n\nexport class CapxulError extends Error {\n readonly code: CapxulErrorCode;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n\n constructor(code: CapxulErrorCode, message: string, options: CapxulErrorOptions = {}) {\n super(message, \"cause\" in options ? { cause: options.cause } : undefined);\n this.name = \"CapxulError\";\n this.code = code;\n if (options.details !== undefined) {\n this.details = options.details;\n }\n if (options.correlationId !== undefined) {\n this.correlationId = options.correlationId;\n }\n if (options.layer !== undefined) {\n this.layer = options.layer;\n }\n }\n}\n\nexport function isCapxulError(value: unknown): value is CapxulError {\n return value instanceof CapxulError;\n}\n\nexport function serializeCapxulError(error: CapxulError): SerializedCapxulError {\n return compactSerialized({\n code: error.code,\n message: error.message,\n details: error.details,\n correlationId: error.correlationId,\n layer: error.layer,\n });\n}\n\nexport function deserializeCapxulError(serialized: SerializedCapxulError): CapxulError {\n return new CapxulError(\n serialized.code,\n serialized.message,\n compactErrorOptions({\n details: serialized.details,\n correlationId: serialized.correlationId,\n layer: serialized.layer,\n }),\n );\n}\n\nfunction compactSerialized(serialized: {\n readonly code: CapxulErrorCode;\n readonly message: string;\n readonly details: CapxulErrorDetails | undefined;\n readonly correlationId: string | undefined;\n readonly layer: string | undefined;\n}): SerializedCapxulError {\n const result: {\n code: CapxulErrorCode;\n message: string;\n details?: CapxulErrorDetails;\n correlationId?: string;\n layer?: string;\n } = {\n code: serialized.code,\n message: serialized.message,\n };\n\n if (serialized.details !== undefined) {\n result.details = serialized.details;\n }\n if (serialized.correlationId !== undefined) {\n result.correlationId = serialized.correlationId;\n }\n if (serialized.layer !== undefined) {\n result.layer = serialized.layer;\n }\n\n return result;\n}\n\nfunction compactErrorOptions(options: {\n readonly cause?: unknown;\n readonly details: CapxulErrorDetails | undefined;\n readonly correlationId: string | undefined;\n readonly layer: string | undefined;\n}): CapxulErrorOptions {\n const result: {\n cause?: unknown;\n details?: CapxulErrorDetails;\n correlationId?: string;\n layer?: string;\n } = {};\n\n if (\"cause\" in options) {\n result.cause = options.cause;\n }\n if (options.details !== undefined) {\n result.details = options.details;\n }\n if (options.correlationId !== undefined) {\n result.correlationId = options.correlationId;\n }\n if (options.layer !== undefined) {\n result.layer = options.layer;\n }\n\n return result;\n}\n\nexport const Errors = {\n notAuthenticated: (message?: string, opts?: { readonly failure_mode?: FailureMode }) =>\n new CapxulError(\n \"NOT_AUTHENTICATED\",\n message ?? \"Not authenticated\",\n opts?.failure_mode ? { details: { failure_mode: opts.failure_mode } } : undefined,\n ),\n emailDeliveryFailed: (detail: string) =>\n new CapxulError(\"EMAIL_DELIVERY_FAILED\", \"Failed to send email\", {\n details: { detail },\n }),\n\n profileNotFound: (authUserId: string) =>\n new CapxulError(\"PROFILE_NOT_FOUND\", `Profile not found for user ${authUserId}`, {\n details: { authUserId },\n }),\n\n smartAccountMissing: (authUserId: string) =>\n new CapxulError(\"SMART_ACCOUNT_MISSING\", \"Smart account not provisioned\", {\n details: { authUserId },\n }),\n\n playerNotFound: (playerId?: string) =>\n new CapxulError(\n \"PLAYER_NOT_FOUND\",\n playerId ? `Openfort player ${playerId} not found` : \"Openfort player not found\",\n playerId === undefined ? undefined : { details: { playerId } },\n ),\n\n accountNotFound: (accountId?: string) =>\n new CapxulError(\n \"ACCOUNT_NOT_FOUND\",\n accountId ? `Openfort account ${accountId} not found` : \"Openfort account not found\",\n accountId === undefined ? undefined : { details: { accountId } },\n ),\n\n providerError: (\n provider: string,\n operation: string,\n cause: unknown,\n opts?: { readonly failure_mode?: FailureMode },\n ) => {\n const details: Record<string, unknown> = { provider, operation };\n if (opts?.failure_mode) {\n details.failure_mode = opts.failure_mode;\n }\n return new CapxulError(\"PROVIDER_ERROR\", `Provider error: ${provider} ${operation}`, {\n cause,\n details,\n });\n },\n\n invalidInput: (field: string, reason: string) =>\n new CapxulError(\"INVALID_INPUT\", `Invalid ${field}: ${reason}`, {\n details: { field, reason },\n }),\n\n envMissing: (name: string) =>\n new CapxulError(\"ENV_MISSING\", `Environment variable ${name} not configured`, {\n details: { name },\n }),\n\n notImplemented: (domain: string, method: string) =>\n new CapxulError(\n \"NOT_IMPLEMENTED\",\n `${domain}.${method} is not yet implemented. This feature is planned for a future release.`,\n { details: { domain, method } },\n ),\n\n /**\n * Sibling factory to {@link Errors.providerError} for the per-state timeout\n * path in flows (initially ProvisioningFlow's mint_openfort / deploy_safe /\n * register_indexer `after:` timers). Same `PROVIDER_ERROR` code as\n * `providerError`, plus a `details.reason: \"timeout\"` discriminator so\n * downstream observers can distinguish failure modes without parsing the\n * message string. The redacted message names the timeout budget; the\n * native `cause` carries the same information for `reportError` fidelity.\n */\n providerTimeout: (provider: string, operation: string, timeoutMs: number) =>\n new CapxulError(\n \"PROVIDER_ERROR\",\n `Provider error: ${provider} ${operation} (timeout exceeded ${timeoutMs}ms)`,\n {\n details: { provider, operation, reason: \"timeout\" },\n cause: new Error(`timeout: ${operation} exceeded ${timeoutMs}ms`),\n },\n ),\n\n verificationRequired: (details: VerificationRequiredDetails) => {\n const message =\n \"rail\" in details\n ? `Verification is required before ${details.rail} can use ${details.currentKind}.`\n : `Verification tier ${details.requiredTier} is required.`;\n\n return new CapxulError(\"VERIFICATION_REQUIRED\", message, {\n details,\n });\n },\n\n insufficientBalance: (asset: string, available: string, required: string) =>\n new CapxulError(\"INSUFFICIENT_BALANCE\", `Insufficient ${asset} balance`, {\n details: { asset, available, required },\n }),\n\n invalidRecipient: (reason: string) =>\n new CapxulError(\"INVALID_RECIPIENT\", `Invalid recipient: ${reason}`, {\n details: { reason },\n }),\n\n /**\n * The org Zodiac Roles modifier REFUSED the spend on-chain (G4 · #547): the\n * member's role condition (per-tx cap, per-day allowance, allowed recipient,\n * or membership) was violated, so `execTransactionWithRole` reverted. This is\n * a PERMISSION denial — explicitly NOT an `INSUFFICIENT_BALANCE` (the treasury\n * held the funds; the role's authority is what bound). `reason` discriminates\n * the violated condition (`over_cap` / `daily_cap` / `not_member` /\n * `disallowed_recipient` / `condition_violation`); leak-safe — no on-chain\n * identifiers ever enter the details.\n */\n rolePermissionDenied: (details: {\n readonly reason:\n | \"over_cap\"\n | \"daily_cap\"\n | \"not_member\"\n | \"disallowed_recipient\"\n | \"condition_violation\";\n readonly operation?: string;\n }) =>\n new CapxulError(\n \"ROLE_PERMISSION_DENIED\",\n `Org role denied this spend on-chain (${details.reason}).`,\n {\n details:\n details.operation === undefined\n ? { reason: details.reason }\n : { reason: details.reason, operation: details.operation },\n },\n ),\n\n /**\n * A transaction (or sponsored UserOp) failed. `details.reason` discriminates\n * the failure mode for callers that must distinguish a CONFIRMED on-chain\n * revert (`\"onchain_revert\"` — the op executed and reverted, e.g. a Zodiac\n * Roles condition violation) from an inconclusive infra failure. A confirmed\n * revert is the ONLY mode the org spend port may map to a roles denial.\n */\n transactionFailed: (operation: string, cause?: unknown, extra?: { readonly reason?: string }) =>\n new CapxulError(\"TRANSACTION_FAILED\", `Transaction failed: ${operation}`, {\n cause,\n details: extra?.reason === undefined ? { operation } : { operation, reason: extra.reason },\n }),\n\n rateLimited: (details?: { readonly retryAfterMs?: number; readonly resource?: string }) =>\n new CapxulError(\n \"RATE_LIMITED\",\n \"Rate limit exceeded\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n networkError: (operation: string, cause?: unknown) =>\n new CapxulError(\"NETWORK_ERROR\", `Network error during ${operation}`, {\n cause,\n details: { operation },\n }),\n\n unknown: (cause?: unknown) => new CapxulError(\"UNKNOWN\", \"Unknown error\", { cause }),\n\n otpExpired: (details?: { readonly email?: string; readonly expiredAt?: number }) =>\n new CapxulError(\n \"OTP_EXPIRED\",\n \"Verification code has expired. Request a new one.\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n signerRejected: (details: {\n readonly source: SignerSource;\n readonly reason?: string;\n readonly cause?: unknown;\n }) =>\n new CapxulError(\"SIGNER_REJECTED\", \"Signer rejected the request.\", {\n cause: details.cause,\n details:\n details.reason === undefined\n ? { source: details.source }\n : { source: details.source, reason: details.reason },\n }),\n\n cancelled: (details?: { readonly operation?: string; readonly reason?: string }) =>\n new CapxulError(\n \"CANCELLED\",\n \"Operation was cancelled.\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n /**\n * Method called from a flow state where its precondition fails (TA16). The\n * SDK's method API short-circuits with this error before driving the\n * internal state machine. `currentState` is the Effect-machine snapshot\n * tag (stringified — substrate is `@effect/experimental/Machine` per\n * `docs/canon/decisions/state-machine-substrate.md`); `validStates`\n * enumerates the states the method accepts.\n */\n wrongState: (details: {\n readonly method: string;\n readonly currentState: string;\n readonly validStates: readonly string[];\n }) =>\n new CapxulError(\n \"WRONG_STATE\",\n `${details.method} called from state '${details.currentState}'; valid states: ${details.validStates.join(\", \")}`,\n { details: { ...details, validStates: [...details.validStates] } },\n ),\n} as const;\n","// Shared `decodeConvexError` helper (TA5) — used by both the SDK's\n// `ConvexCallAdapter.mapToCapxulError` AND the backend `credentials/http.ts`\n// `bootstrapClient` handler. Single source of truth for cross-Convex-boundary\n// error decoding rules.\n//\n// Recognizes the `ConvexError(SerializedCapxulError)` object-shape produced by\n// `withErrorBoundary` (Probe B finding, 2026-05-19):\n//\n// { name: \"ConvexError\", data: { code, message, details?, correlationId?, layer? } }\n//\n// AND the defensive string-shape branch for older Convex versions where\n// `data` is a JSON-serialized string. Pass-through for raw `CapxulError`\n// instances (which arrive directly when the throw happened in the same\n// V8 isolate as the catch). Returns null when the value is not a\n// recognizable shape — the caller falls back to NETWORK_ERROR + reportError.\n\nimport {\n CAPXUL_ERROR_CODES,\n CapxulError,\n type CapxulErrorCode,\n type SerializedCapxulError,\n deserializeCapxulError,\n} from \"./errors.ts\";\n\n// Derived from the canonical catalog in errors.ts — single source of truth,\n// so a new code added to `CAPXUL_ERROR_CODES` is recognized here automatically.\nconst KNOWN_CODES: ReadonlySet<CapxulErrorCode> = new Set(CAPXUL_ERROR_CODES);\n\nfunction isCapxulCode(value: unknown): value is CapxulErrorCode {\n return typeof value === \"string\" && KNOWN_CODES.has(value as CapxulErrorCode);\n}\n\nfunction reconstruct(serialized: Record<string, unknown>): CapxulError | null {\n if (!isCapxulCode(serialized.code)) return null;\n const payload: SerializedCapxulError = {\n code: serialized.code,\n message: typeof serialized.message === \"string\" ? serialized.message : String(serialized.code),\n ...(typeof serialized.details === \"object\" &&\n serialized.details !== null &&\n !Array.isArray(serialized.details)\n ? { details: serialized.details as Record<string, unknown> }\n : {}),\n ...(typeof serialized.correlationId === \"string\"\n ? { correlationId: serialized.correlationId }\n : {}),\n ...(typeof serialized.layer === \"string\" ? { layer: serialized.layer } : {}),\n };\n return deserializeCapxulError(payload);\n}\n\nexport function decodeConvexError(err: unknown): CapxulError | null {\n if (err === null || err === undefined) return null;\n\n // Pass-through: same isolate, real CapxulError instance.\n if (err instanceof CapxulError) return err;\n\n if (typeof err !== \"object\") return null;\n\n // The canonical shape produced by `withErrorBoundary` then crossed by\n // Convex's `ctx.runQuery` / `ConvexHttpClient`: a `ConvexError` whose\n // `data` is the `SerializedCapxulError` object literal.\n const record = err as Record<string, unknown>;\n if (!(\"data\" in record)) return null;\n const data = record.data;\n\n if (typeof data === \"object\" && data !== null) {\n return reconstruct(data as Record<string, unknown>);\n }\n\n // Defensive depth — some Convex versions JSON-stringify the data at\n // the runtime boundary. Probe B confirmed @convex-dev/better-auth 0.10.13\n // + convex 1.39.x do NOT do this, but the cheap parse keeps forward\n // compatibility.\n if (typeof data === \"string\") {\n try {\n const parsed = JSON.parse(data) as unknown;\n if (typeof parsed === \"object\" && parsed !== null) {\n return reconstruct(parsed as Record<string, unknown>);\n }\n } catch {\n // Fall through.\n }\n }\n\n return null;\n}\n","import { Errors } from \"@capxul/errors\";\nimport type { CapxulClient } from \"@capxul/sdk\";\n\n/**\n * Narrow the bootstrap-nullable client to a ready client inside a query /\n * mutation function (sdk-provider-owned-bootstrap.md). Data hooks gate their\n * queries on `enabled: client !== null`, so this only ever throws for a mutation\n * triggered while `<CapxulProvider>` is still bootstrapping.\n */\nexport function requireBootstrappedClient(\n client: CapxulClient | null,\n method: string,\n): CapxulClient {\n if (client === null) {\n throw Errors.wrongState({ method, currentState: \"bootstrapping\", validStates: [\"ready\"] });\n }\n return client;\n}\n","// Typed query-key catalog (epic #258 · TanStack reactive surface).\n//\n// Auth-boundary mutations (`verifyOtp`, `signOut`) invalidate all three\n// keys on success. `signIn` does not — OTP sent leaves session null.\n\nimport type { AccountId, OrgId } from \"@capxul/types\";\n\nexport const capxulKeys = {\n session: [\"capxul\", \"session\"] as const,\n profile: [\"capxul\", \"profile\"] as const,\n account: [\"capxul\", \"account\"] as const,\n accountLifecycle: [\"capxul\", \"accountLifecycle\"] as const,\n provisioning: [\"capxul\", \"provisioning\"] as const,\n binding: [\"capxul\", \"binding\"] as const,\n accountBalance: [\"capxul\", \"accountBalance\"] as const,\n subAccounts: (accountId: AccountId | undefined) =>\n [\"capxul\", \"subAccounts\", accountId ?? \"pending\"] as const,\n // Organization domain (canon §C3, D13 — entity-scoped, keyed by OrgId).\n orgs: [\"capxul\", \"orgs\"] as const,\n org: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\"] as const,\n orgMembers: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"members\"] as const,\n orgRoles: (orgId: OrgId | undefined) => [\"capxul\", \"org\", orgId ?? \"pending\", \"roles\"] as const,\n orgTreasury: (orgId: OrgId | undefined) =>\n [\"capxul\", \"org\", orgId ?? \"pending\", \"treasury\"] as const,\n} satisfies Record<string, readonly unknown[] | ((...args: never[]) => readonly unknown[])>;\n","import { captureExceptionSync } from \"@capxul/sdk\";\nimport type { TelemetryPort } from \"@capxul/sdk\";\nimport type { CapxulResult } from \"@capxul/sdk\";\n\n/**\n * Unwrap a `CapxulResult` for TanStack query/mutation functions —\n * throws into error paths, optionally reporting the error to telemetry first.\n *\n * When `telemetry` is provided and the result is `{ ok: false }`,\n * `captureExceptionSync` is called (fire-and-forget) before the throw. `operation`\n * tags the telemetry event so query reads and mutation writes stay\n * distinguishable in error tracking (defaults to `\"query\"`).\n */\nexport function unwrapCapxulResult<T>(\n result: CapxulResult<T>,\n telemetry?: TelemetryPort,\n operation: \"query\" | \"mutation\" = \"query\",\n): T {\n if (result.ok) {\n return result.value;\n }\n if (telemetry) {\n try {\n captureExceptionSync(telemetry, result.error, {\n layer: \"react-query\",\n operation,\n });\n } catch {\n // Telemetry failure never prevents the throw\n }\n }\n throw result.error;\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { Session } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulSessionReturn = UseQueryResult<Session | null, CapxulError>;\n\nexport function useCapxulSession(): UseCapxulSessionReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.session,\n queryFn: async () =>\n unwrapCapxulResult(\n await requireBootstrappedClient(client, \"auth.getSession\").auth.getSession(),\n client!._internal.telemetry,\n ),\n enabled: client !== null,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { Profile } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulProfileReturn = UseQueryResult<Profile | null, CapxulError>;\n\nexport function useCapxulProfile(): UseCapxulProfileReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.profile,\n queryFn: async () =>\n unwrapCapxulResult(\n await requireBootstrappedClient(client, \"identity.loadCurrent\").identity.loadCurrent(),\n client!._internal.telemetry,\n ),\n enabled: client !== null,\n });\n}\n","/** True under Vitest — disables hook polling intervals that fight fake timers. */\nexport function isVitestRuntime(): boolean {\n return typeof process !== \"undefined\" && process.env[\"VITEST\"] === \"true\";\n}\n","import type { QueryClient } from \"@tanstack/react-query\";\n\nimport { capxulKeys } from \"./reactivity-keys\";\n\n/** Background refetch after verifyOtp — avoids hard reset cancel errors in UI. */\nexport async function invalidateAuthBoundary(queryClient: QueryClient): Promise<void> {\n await Promise.all([\n queryClient.invalidateQueries({ queryKey: capxulKeys.session }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.profile }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.accountLifecycle }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance }),\n ]);\n}\n\n/** Hard reset after signOut — drop cached authenticated rows immediately. */\nexport async function resetAuthBoundary(queryClient: QueryClient): Promise<void> {\n await queryClient.cancelQueries({ queryKey: capxulKeys.accountBalance });\n await Promise.all([\n queryClient.resetQueries({ queryKey: capxulKeys.session }),\n queryClient.resetQueries({ queryKey: capxulKeys.profile }),\n queryClient.resetQueries({ queryKey: capxulKeys.accountLifecycle }),\n queryClient.resetQueries({ queryKey: capxulKeys.accountBalance }),\n ]);\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n} from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport { isSettingUpLifecycle, type AccountLifecycle } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { isVitestRuntime } from \"../internal/is-vitest-runtime\";\nimport { invalidateAuthBoundary } from \"../internal/invalidate-auth-boundary\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nconst LOADING_LIFECYCLE: AccountLifecycle = { status: \"loading\" };\n\nexport interface UseCapxulAccountLifecycleReturn {\n readonly lifecycle: AccountLifecycle;\n readonly isSettingUp: boolean;\n readonly error: CapxulError | null;\n readonly isLoading: boolean;\n readonly isFetching: boolean;\n readonly isError: boolean;\n readonly retry: UseMutationResult<AccountLifecycle, CapxulError, void>[\"mutateAsync\"];\n readonly isRetrying: boolean;\n}\n\nexport function useCapxulAccountLifecycle(): UseCapxulAccountLifecycleReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n\n const query = useQuery<AccountLifecycle, CapxulError>({\n queryKey: capxulKeys.accountLifecycle,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"account.getLifecycle\");\n return unwrapCapxulResult(\n await bootstrappedClient.account.getLifecycle(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null,\n refetchInterval: (q) => {\n if (isVitestRuntime()) return false;\n const data = q.state.data;\n if (data === undefined) return false;\n // Keep polling through `loading` — the first fetch can race verifyOtp/session\n // hydration; without this the hook sticks on loading forever.\n if (data.status === \"loading\" || isSettingUpLifecycle(data)) return 2_000;\n return false;\n },\n });\n\n const retryMutation = useMutation<AccountLifecycle, CapxulError, void>({\n mutationFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"account.retrySetup\");\n return unwrapCapxulResult(\n await bootstrappedClient.account.retrySetup(),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n await invalidateAuthBoundary(queryClient);\n },\n });\n\n const lifecycle = query.data ?? LOADING_LIFECYCLE;\n const failedError = lifecycle.status === \"failed\" ? lifecycle.error : null;\n const queryError = query.isError ? query.error : null;\n\n return {\n lifecycle:\n queryError !== null && lifecycle.status === \"loading\"\n ? {\n status: \"failed\",\n at: \"connecting\",\n error: queryError,\n }\n : lifecycle,\n isSettingUp: isSettingUpLifecycle(lifecycle),\n error: failedError ?? queryError,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n isError: query.isError,\n retry: retryMutation.mutateAsync,\n isRetrying: retryMutation.isPending,\n };\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { Account } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulAccountBalanceReturn = UseQueryResult<Account, CapxulError>;\n\nexport type UseCapxulAccountBalanceOptions = {\n /** When false, skips the Convex readBalance action until the account ladder is ready. */\n readonly enabled?: boolean;\n};\n\nexport function useCapxulAccountBalance(\n options?: UseCapxulAccountBalanceOptions,\n): UseCapxulAccountBalanceReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.accountBalance,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"accounts.read\");\n return unwrapCapxulResult(\n await bootstrappedClient.accounts.read(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { Money } from \"@capxul/types\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulAccountFundReturn = UseMutationResult<\n { readonly txHash: string },\n CapxulError,\n Money\n>;\n\nexport function useCapxulAccountFund(): UseCapxulAccountFundReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (amount: Money) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"_internal.accounts.fund\");\n return unwrapCapxulResult(\n await bootstrappedClient._internal.accounts.fund(amount),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport interface SignInInput {\n readonly email: string;\n}\n\nexport interface SignInSuccess {\n readonly sessionId: string;\n readonly expiresAt: number;\n}\n\nexport type UseCapxulSignInReturn = UseMutationResult<SignInSuccess, CapxulError, SignInInput>;\n\nexport function useCapxulSignIn(): UseCapxulSignInReturn {\n const client = useCapxulClientOrNull();\n return useMutation({\n mutationFn: async (input: SignInInput) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"auth.signIn\");\n return unwrapCapxulResult(\n await bootstrappedClient.auth.signIn(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { Session } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { invalidateAuthBoundary } from \"../internal/invalidate-auth-boundary\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport interface VerifyOtpInput {\n readonly email: string;\n readonly code: string;\n}\n\nexport type UseCapxulVerifyOtpReturn = UseMutationResult<Session, CapxulError, VerifyOtpInput>;\n\nexport function useCapxulVerifyOtp(): UseCapxulVerifyOtpReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: VerifyOtpInput) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"auth.verifyOtp\");\n return unwrapCapxulResult(\n await bootstrappedClient.auth.verifyOtp(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n await invalidateAuthBoundary(queryClient);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { resetAuthBoundary } from \"../internal/invalidate-auth-boundary\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulSignOutReturn = UseMutationResult<void, CapxulError, void>;\n\nexport function useCapxulSignOut(): UseCapxulSignOutReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n onMutate: async () => {\n await queryClient.cancelQueries({ queryKey: capxulKeys.accountBalance });\n },\n mutationFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"auth.signOut\");\n return unwrapCapxulResult(\n await bootstrappedClient.auth.signOut(),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: () => resetAuthBoundary(queryClient),\n });\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { AccountId, SubAccount, SubAccountId } from \"@capxul/types\";\nimport type { TransferInput, TransferResult } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulSubAccountsListOptions = {\n readonly enabled?: boolean;\n};\n\nexport type UseCapxulSubAccountsListReturn = UseQueryResult<readonly SubAccount[], CapxulError>;\n\nexport function useCapxulSubAccountsList(\n accountId: AccountId | undefined,\n options?: UseCapxulSubAccountsListOptions,\n): UseCapxulSubAccountsListReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.subAccounts(accountId),\n queryFn: async () => {\n if (accountId === undefined) {\n throw Errors.invalidInput(\"accountId\", \"required for subAccounts.list\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.list\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.list(accountId),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true) && accountId !== undefined,\n });\n}\n\nexport type UseCapxulSubAccountCreateReturn = UseMutationResult<\n SubAccount,\n CapxulError,\n { readonly accountId: AccountId; readonly name: string }\n>;\n\nexport function useCapxulSubAccountCreate(): UseCapxulSubAccountCreateReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.create\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.create(input.accountId, { name: input.name }),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\nexport type UseCapxulSubAccountRenameReturn = UseMutationResult<\n SubAccount,\n CapxulError,\n { readonly accountId: AccountId; readonly subAccountId: SubAccountId; readonly name: string }\n>;\n\nexport function useCapxulSubAccountRename(): UseCapxulSubAccountRenameReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.rename\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.rename(input.subAccountId, input.name),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\nexport type UseCapxulSubAccountDeleteReturn = UseMutationResult<\n void,\n CapxulError,\n { readonly accountId: AccountId; readonly subAccountId: SubAccountId }\n>;\n\nexport function useCapxulSubAccountDelete(): UseCapxulSubAccountDeleteReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.delete\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.delete(input.subAccountId),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\n/**\n * Move money between two of the SAME Account's balances (canon §5/§12). The\n * consumer-facing labels are \"Add money\" (main → sub) and \"Move money out\"\n * (sub → main), both calling `transfer`. `accountId` is carried only to\n * invalidate the right cache keys; the SDK input itself is `{ from, to, amount }`.\n */\nexport type UseCapxulTransferReturn = UseMutationResult<\n TransferResult,\n CapxulError,\n { readonly accountId: AccountId } & TransferInput\n>;\n\nexport function useCapxulTransfer(): UseCapxulTransferReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async ({ from, to, amount }) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.transfer\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.transfer({ from, to, amount }),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { OrgView } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * List the Orgs you belong to (canon §C1 \"Org list\" / §C3). Binds directly to\n * the locked `capxul.orgs()` SDK method.\n */\nexport type UseCapxulOrgsReturn = UseQueryResult<readonly OrgView[], CapxulError>;\n\nexport type UseCapxulOrgsOptions = {\n /**\n * Gate the query on auth readiness. `client.orgs()` is a session-scoped\n * authenticated read; firing it before the session token settles surfaces a\n * spurious `NOT_AUTHENTICATED`. Consumers pass `enabled: <auth-ready>` (e.g.\n * \"the Organization surface is active\") — mirrors `useCapxulSubAccountsList`.\n * Defaults to `true` to preserve the bare `useCapxulOrgs()` call shape.\n */\n readonly enabled?: boolean;\n};\n\nexport function useCapxulOrgs(options?: UseCapxulOrgsOptions): UseCapxulOrgsReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.orgs,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"orgs\");\n return unwrapCapxulResult(\n await bootstrappedClient.orgs(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { OrgId, OrgView } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * A single Org you belong to, resolved from `capxul.orgs()` and narrowed to the\n * requested `orgId` (canon §C3). Returns `null` when the Org is not in your list.\n * Gated by `orgId !== undefined`. RED until S1.\n */\nexport type UseCapxulOrgReturn = UseQueryResult<OrgView | null, CapxulError>;\n\nexport function useCapxulOrg(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgOptions,\n): UseCapxulOrgReturn {\n const client = useCapxulClient();\n return useQuery({\n queryKey: capxulKeys.org(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrg\");\n }\n const orgs = unwrapCapxulResult(await client.orgs(), client!._internal.telemetry);\n return orgs.find((org) => org.id === orgId) ?? null;\n },\n enabled: (options?.enabled ?? true) && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgMembersOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The members of an Org (canon §C1 \"Members\" / §C3, D8/D9). Binds directly to\n * the entity-scoped `capxul.org(orgId).members()` (D13). Gated by\n * `orgId !== undefined`. RED until S3.\n */\nexport type UseCapxulOrgMembersReturn = UseQueryResult<readonly MemberView[], CapxulError>;\n\nexport function useCapxulOrgMembers(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgMembersOptions,\n): UseCapxulOrgMembersReturn {\n const client = useCapxulClient();\n return useQuery({\n queryKey: capxulKeys.orgMembers(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgMembers\");\n }\n return unwrapCapxulResult(await client.org(orgId).members(), client!._internal.telemetry);\n },\n enabled: (options?.enabled ?? true) && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { OrgId, RoleView } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgRolesOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The roles seeded on an Org (canon §C1 \"Roles\" / §C3, D4/D6). Binds directly\n * to the entity-scoped `capxul.org(orgId).roles()` (D13). Gated by\n * `orgId !== undefined`. RED until S2.\n */\nexport type UseCapxulOrgRolesReturn = UseQueryResult<readonly RoleView[], CapxulError>;\n\nexport function useCapxulOrgRoles(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgRolesOptions,\n): UseCapxulOrgRolesReturn {\n const client = useCapxulClient();\n return useQuery({\n queryKey: capxulKeys.orgRoles(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgRoles\");\n }\n return unwrapCapxulResult(await client.org(orgId).roles(), client!._internal.telemetry);\n },\n enabled: (options?.enabled ?? true) && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { OrgId, RoleView } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgDeployRolesReturn = UseMutationResult<\n readonly RoleView[],\n CapxulError,\n OrgId\n>;\n\nexport function useCapxulOrgDeployRoles(): UseCapxulOrgDeployRolesReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (orgId: OrgId) => {\n return unwrapCapxulResult(\n await client.org(orgId).deployRoles(),\n client._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_roles, orgId) => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgRoles(orgId) });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.org(orgId) });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgs });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { OrgId } from \"@capxul/sdk\";\nimport type { Account } from \"@capxul/types\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgTreasuryOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The Org treasury — the real M2 `Account` over the Org Safe (canon §C3, D3).\n * NEVER `AccountStatus` (the deploy-readiness ladder, no balance). Binds\n * directly to the entity-scoped `capxul.org(orgId).treasury()` (D13). Gated by\n * `orgId !== undefined`. RED until S1.\n */\nexport type UseCapxulOrgTreasuryReturn = UseQueryResult<Account, CapxulError>;\n\nexport function useCapxulOrgTreasury(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgTreasuryOptions,\n): UseCapxulOrgTreasuryReturn {\n const client = useCapxulClient();\n return useQuery({\n queryKey: capxulKeys.orgTreasury(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgTreasury\");\n }\n return unwrapCapxulResult(await client.org(orgId).treasury(), client!._internal.telemetry);\n },\n enabled: (options?.enabled ?? true) && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type { CreateOrgInput, OrgView } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Create an Org (canon §C2 J1 / §C3, S1). Binds directly to the locked\n * `capxul.createOrg(input)` SDK method. On success, invalidates the org list.\n * RED until S1 — `mutate` rejects with `Errors.notImplemented(\"org\",\"createOrg\")`.\n */\nexport type UseCapxulCreateOrgReturn = UseMutationResult<OrgView, CapxulError, CreateOrgInput>;\n\nexport function useCapxulCreateOrg(): UseCapxulCreateOrgReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CreateOrgInput) =>\n unwrapCapxulResult(await client.createOrg(input), client._internal.telemetry, \"mutation\"),\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgs });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type {\n CompletePersonalOnboardingInput,\n CompletePersonalOnboardingResult,\n} from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Complete personal onboarding (D-ONBOARD · #669). Binds to\n * `capxul.onboarding.completePersonal(input)`: persist the user's first identity\n * profile + trigger provisioning, then return the leak-safe `{ lifecycle }`. A\n * mutation, NOT an effect — call `mutateAsync` from a submit handler and route\n * on `lifecycle.status` (see `docs/onboarding.md`). On success it invalidates the\n * identity + account-lifecycle queries so the dashboard/provisioning screen\n * reactively reflects the new state. No effect hooks — a handler + a query.\n */\nexport type UseCapxulCompletePersonalOnboardingReturn = UseMutationResult<\n CompletePersonalOnboardingResult,\n CapxulError,\n CompletePersonalOnboardingInput\n>;\n\nexport function useCapxulCompletePersonalOnboarding(): UseCapxulCompletePersonalOnboardingReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CompletePersonalOnboardingInput) =>\n unwrapCapxulResult(\n await client.onboarding.completePersonal(input),\n client._internal.telemetry,\n \"mutation\",\n ),\n onSuccess: async () => {\n await Promise.all([\n queryClient.invalidateQueries({ queryKey: capxulKeys.profile }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.accountLifecycle }),\n ]);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/errors\";\nimport type {\n CompleteOrganizationOnboardingInput,\n CompleteOrganizationOnboardingResult,\n} from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Complete organization onboarding (D-ONBOARD · #669). Binds to\n * `capxul.onboarding.completeOrganization(input)`: persist the founder's identity\n * profile, create the Org (reusing `createOrg`), trigger provisioning, and return\n * `{ org, lifecycle }`. Scope every later org call via `capxul.org(org.id).*`. A\n * mutation, NOT an effect. On success it invalidates the identity, account-\n * lifecycle, and org-list queries. No effect hooks — a handler + a query.\n */\nexport type UseCapxulCompleteOrganizationOnboardingReturn = UseMutationResult<\n CompleteOrganizationOnboardingResult,\n CapxulError,\n CompleteOrganizationOnboardingInput\n>;\n\nexport function useCapxulCompleteOrganizationOnboarding(): UseCapxulCompleteOrganizationOnboardingReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CompleteOrganizationOnboardingInput) =>\n unwrapCapxulResult(\n await client.onboarding.completeOrganization(input),\n client._internal.telemetry,\n \"mutation\",\n ),\n onSuccess: async () => {\n await Promise.all([\n queryClient.invalidateQueries({ queryKey: capxulKeys.profile }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.accountLifecycle }),\n queryClient.invalidateQueries({ queryKey: capxulKeys.orgs }),\n ]);\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { InviteMemberInput, MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Invite a member to an Org by email (canon §C2 J2 virality loop / §C3, S3, D8).\n * Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).invite(input)`. On success, invalidates the member list.\n * RED until S3 — `mutate` rejects with `Errors.notImplemented(\"org\",\"invite\")`.\n */\nexport type UseCapxulInviteMemberReturn = UseMutationResult<\n MemberView,\n CapxulError,\n InviteMemberInput\n>;\n\nexport function useCapxulInviteMember(orgId: OrgId | undefined): UseCapxulInviteMemberReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: InviteMemberInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulInviteMember\");\n }\n return unwrapCapxulResult(\n await client.org(orgId).invite(input),\n client._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { OrgId, RemoveMemberInput } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Remove a member from an Org (canon §C2 J2 / §C3, S3, D7/D8) — drives the\n * on-chain REVOKE + Convex mirror. Keyed on the member's personal Safe address\n * (D7). Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).removeMember(input)`. On success, invalidates the member\n * list. RED until S3 — `mutate` rejects with\n * `Errors.notImplemented(\"org\",\"removeMember\")`.\n */\nexport type UseCapxulRemoveMemberReturn = UseMutationResult<void, CapxulError, RemoveMemberInput>;\n\nexport function useCapxulRemoveMember(orgId: OrgId | undefined): UseCapxulRemoveMemberReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: RemoveMemberInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulRemoveMember\");\n }\n return unwrapCapxulResult(\n await client.org(orgId).removeMember(input),\n client._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/errors\";\nimport type { AssignRoleInput, MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClient } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Assign a role to a member (canon §C2 J2 / §C3, S3, D7/D9) — drives the\n * on-chain GRANT + Convex mirror. Keyed on the member's personal Safe address\n * (D7); the `role` label maps deterministically to the on-chain `roleKey` (D9).\n * Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).assignRole(input)`. On success, invalidates the member\n * list. RED until S3 — `mutate` rejects with\n * `Errors.notImplemented(\"org\",\"assignRole\")`.\n */\nexport type UseCapxulAssignRoleReturn = UseMutationResult<MemberView, CapxulError, AssignRoleInput>;\n\nexport function useCapxulAssignRole(orgId: OrgId | undefined): UseCapxulAssignRoleReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: AssignRoleInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulAssignRole\");\n }\n return unwrapCapxulResult(\n await client.org(orgId).assignRole(input),\n client._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { OrgId } from \"@capxul/sdk\";\n\nexport type SwitchActingEntityInput = {\n readonly orgId?: OrgId;\n};\n\n/**\n * Switch the acting entity (personal Account ↔ Organization).\n *\n * Per canon D13 the acting entity is NOT shared mutable SDK state — scoping is\n * explicit per `capxul.org(orgId)` call — so this mutation carries no SDK side\n * effect. It exists as the stable mutation seam the headless\n * `CapxulEntitySwitcher` drives; the actual context switch is the consumer's\n * own local state, applied through the component's `onSwitchPersonal` /\n * `onSwitchOrg` callbacks.\n *\n * The legacy `org_entity_switched` telemetry emission was removed when master's\n * unified telemetry pipeline (#402) dropped that event from the Layer 0 spine.\n */\nexport type UseCapxulSwitchActingEntityReturn = UseMutationResult<\n void,\n Error,\n SwitchActingEntityInput | undefined\n>;\n\nexport function useCapxulSwitchActingEntity(): UseCapxulSwitchActingEntityReturn {\n return useMutation({\n mutationFn: async (_input?: SwitchActingEntityInput) => undefined,\n });\n}\n"],"mappings":";;;;;;AAsBA,MAAM,yBAAyB,cAA2C,IAAI;AAO9E,SAAgB,wBAAwB,EAAE,OAAO,YAA0C;CACzF,OACE,oBAAC,uBAAuB,UAAxB;EAAwC;EAAQ;CAA0C,C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W,YAAY;GACrB,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,YAAY,kBAAkB,EAAE,UAAU,WAAW,WAAW,KAAK,EAAE,CAAC;EAChF;CACF,CAAC;AACH;;;AClBA,SAAgB,oBAAoB,OAAqD;CACvF,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CACnC,OAAO,YAAY;EACjB,YAAY,OAAO,UAA2B;GAC5C,IAAI,UAAU,KAAA,GACZ,MAAM,OAAO,aAAa,SAAS,kCAAkC;GAEvE,OAAO,mBACL,MAAM,OAAO,IAAI,KAAK,EAAE,WAAW,KAAK,GACxC,OAAO,UAAU,WACjB,UACF;EACF;EACA,WAAW,YAAY;GACrB,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,YAAY,kBAAkB,EAAE,UAAU,WAAW,WAAW,KAAK,EAAE,CAAC;EAChF;CACF,CAAC;AACH;;;ACZA,SAAgB,8BAAiE;CAC/E,OAAO,YAAY,EACjB,YAAY,OAAO,WAAqC,KAAA,EAC1D,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../errors/src/errors.ts","../../errors/src/convex-error-decoding.ts","../src/internal/require-bootstrapped-client.ts","../src/internal/unwrap-capxul-result.ts","../src/hooks/use-capxul-profile.ts","../src/hooks/use-capxul-account-balance.ts","../src/hooks/use-capxul-account-fund.ts","../src/hooks/use-capxul-sub-accounts.ts","../src/internal/invalidate-money-state.ts","../src/internal/reject-unresolved-actor.ts","../src/hooks/use-capxul-money.ts","../src/hooks/use-capxul-orgs.ts","../src/hooks/use-capxul-org-members.ts","../src/hooks/use-capxul-org-roles.ts","../src/hooks/use-capxul-org-deploy-roles.ts","../src/hooks/use-capxul-org-treasury.ts","../src/hooks/use-capxul-create-org.ts","../src/hooks/use-capxul-invite-member.ts","../src/hooks/use-capxul-remove-member.ts","../src/hooks/use-capxul-assign-role.ts","../src/headless/journey/journey-state.ts","../src/internal/use-debounced-value.ts","../src/headless/onboarding/use-capxul-username-availability.ts","../src/headless/media/use-capxul-image-upload.ts"],"sourcesContent":["// The canonical error-code catalog as a runtime constant. `CapxulErrorCode`\n// is derived from it so the type and any runtime check that needs to\n// enumerate codes (e.g. the convex-error codec's `KNOWN_CODES`) share a\n// single source of truth — a TypeScript union alone can't be introspected\n// at runtime, which previously forced a hand-maintained duplicate.\nexport const CAPXUL_ERROR_CODES = [\n \"NOT_AUTHENTICATED\",\n \"EMAIL_DELIVERY_FAILED\",\n \"PROFILE_NOT_FOUND\",\n \"SMART_ACCOUNT_MISSING\",\n \"PLAYER_NOT_FOUND\",\n \"ACCOUNT_NOT_FOUND\",\n \"PROVIDER_ERROR\",\n \"INVALID_INPUT\",\n \"ENV_MISSING\",\n \"NOT_IMPLEMENTED\",\n \"VERIFICATION_REQUIRED\",\n \"INSUFFICIENT_BALANCE\",\n \"INVALID_RECIPIENT\",\n \"ROLE_PERMISSION_DENIED\",\n \"TRANSACTION_FAILED\",\n \"RATE_LIMITED\",\n \"NETWORK_ERROR\",\n \"UNKNOWN\",\n \"OTP_EXPIRED\",\n \"SIGNER_REJECTED\",\n \"CANCELLED\",\n \"WRONG_STATE\",\n \"STALE_EPOCH\",\n \"SUPERSEDED\",\n \"WORK_DIED\",\n \"ACTOR_STOPPED\",\n] as const;\n\nexport type CapxulErrorCode = (typeof CAPXUL_ERROR_CODES)[number];\n\n/**\n * The error codes that represent an expected product outcome rather than a\n * defect. The SDK and backend observation boundaries both classify failures\n * against this set to route expected outcomes to their own PostHog event\n * stream; keeping the single copy here (adjacent to `CAPXUL_ERROR_CODES`, so a\n * code rename forces this set to move with it) stops the two sides of the wire\n * from drifting and silently splitting one outcome across two streams.\n */\nexport const EXPECTED_OPERATION_OUTCOMES: ReadonlySet<CapxulErrorCode> = new Set([\n \"INVALID_INPUT\",\n \"NOT_AUTHENTICATED\",\n // A user with no Safe yet — the normal post-OTP / pre-provision state. Reading\n // the account, current user, or balance in that window is an expected outcome,\n // not a defect, so both observation boundaries route it to their\n // `*_expected_outcome` stream instead of an unexpected `$exception` (#1031).\n \"SMART_ACCOUNT_MISSING\",\n \"CANCELLED\",\n \"SIGNER_REJECTED\",\n \"VERIFICATION_REQUIRED\",\n \"INSUFFICIENT_BALANCE\",\n \"INVALID_RECIPIENT\",\n \"ROLE_PERMISSION_DENIED\",\n \"RATE_LIMITED\",\n \"OTP_EXPIRED\",\n \"WRONG_STATE\",\n \"STALE_EPOCH\",\n \"SUPERSEDED\",\n \"ACTOR_STOPPED\",\n]);\n\n/**\n * Why an auth/provider call failed — a flat CAUSE enum. The *where* (which\n * OpenFort operation) stays in the separate `operation` detail field; this\n * names the root cause so a single `$exception` can be triaged without\n * parsing the message. Five members, no free strings:\n *\n * - `auth-origin-mismatch`: OTP cookies live on `localhost:PORT` but OpenFort\n * hits the Convex host → no session reaches the provider.\n * - `stale-openfort-cache`: an old `userId` in scoped storage makes the SDK\n * skip re-auth → 401 on `v2/accounts`.\n * - `app-env-allowlist`: the selected app/deployment origin is not allowlisted\n * → 401.\n * - `no-secure-context`: sandboxed/headless browser with no Web Crypto, so\n * `getAddress`/`configure` can never produce an address. Previously vanished\n * into `unknown`; the signer's secure-context probe now names it.\n * - `unknown`: catch-all when no cause could be determined.\n */\nexport type FailureMode =\n | \"auth-origin-mismatch\"\n | \"stale-openfort-cache\"\n | \"app-env-allowlist\"\n | \"no-secure-context\"\n | \"unknown\";\n\n/**\n * The one failure representation carried by domain state, actor work, and\n * public error projection. Keeping it beside the canonical error catalog\n * prevents a machine or shell from inventing a second code vocabulary.\n */\nexport interface Failure {\n readonly code: CapxulErrorCode;\n readonly message: string;\n readonly mode?: FailureMode;\n}\n\nexport type CapxulErrorDetails = Record<string, unknown>;\n\nexport type SignerSource = \"openfort-embedded\" | \"injected-eip1193\" | \"local-private-key\";\n\nexport type VerificationRequiredDetails =\n | { readonly requiredTier: number }\n | { readonly rail: string; readonly currentKind: string };\n\nexport type SerializedCapxulError = {\n readonly code: CapxulErrorCode;\n readonly message: string;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n};\n\nexport type CapxulErrorOptions = {\n readonly cause?: unknown;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n};\n\nexport class CapxulError extends Error {\n readonly code: CapxulErrorCode;\n readonly details?: CapxulErrorDetails;\n readonly correlationId?: string;\n readonly layer?: string;\n\n constructor(code: CapxulErrorCode, message: string, options: CapxulErrorOptions = {}) {\n super(message, \"cause\" in options ? { cause: options.cause } : undefined);\n this.name = \"CapxulError\";\n this.code = code;\n if (options.details !== undefined) {\n this.details = options.details;\n }\n if (options.correlationId !== undefined) {\n this.correlationId = options.correlationId;\n }\n if (options.layer !== undefined) {\n this.layer = options.layer;\n }\n }\n}\n\nexport function isCapxulError(value: unknown): value is CapxulError {\n return value instanceof CapxulError;\n}\n\nexport function serializeCapxulError(error: CapxulError): SerializedCapxulError {\n return compactSerialized({\n code: error.code,\n message: error.message,\n details: error.details,\n correlationId: error.correlationId,\n layer: error.layer,\n });\n}\n\nexport function deserializeCapxulError(serialized: SerializedCapxulError): CapxulError {\n return new CapxulError(\n serialized.code,\n serialized.message,\n compactErrorOptions({\n details: serialized.details,\n correlationId: serialized.correlationId,\n layer: serialized.layer,\n }),\n );\n}\n\nfunction compactSerialized(serialized: {\n readonly code: CapxulErrorCode;\n readonly message: string;\n readonly details: CapxulErrorDetails | undefined;\n readonly correlationId: string | undefined;\n readonly layer: string | undefined;\n}): SerializedCapxulError {\n const result: {\n code: CapxulErrorCode;\n message: string;\n details?: CapxulErrorDetails;\n correlationId?: string;\n layer?: string;\n } = {\n code: serialized.code,\n message: serialized.message,\n };\n\n if (serialized.details !== undefined) {\n result.details = serialized.details;\n }\n if (serialized.correlationId !== undefined) {\n result.correlationId = serialized.correlationId;\n }\n if (serialized.layer !== undefined) {\n result.layer = serialized.layer;\n }\n\n return result;\n}\n\nfunction compactErrorOptions(options: {\n readonly cause?: unknown;\n readonly details: CapxulErrorDetails | undefined;\n readonly correlationId: string | undefined;\n readonly layer: string | undefined;\n}): CapxulErrorOptions {\n const result: {\n cause?: unknown;\n details?: CapxulErrorDetails;\n correlationId?: string;\n layer?: string;\n } = {};\n\n if (\"cause\" in options) {\n result.cause = options.cause;\n }\n if (options.details !== undefined) {\n result.details = options.details;\n }\n if (options.correlationId !== undefined) {\n result.correlationId = options.correlationId;\n }\n if (options.layer !== undefined) {\n result.layer = options.layer;\n }\n\n return result;\n}\n\nexport const Errors = {\n notAuthenticated: (message?: string, opts?: { readonly failure_mode?: FailureMode }) =>\n new CapxulError(\n \"NOT_AUTHENTICATED\",\n message ?? \"Not authenticated\",\n opts?.failure_mode ? { details: { failure_mode: opts.failure_mode } } : undefined,\n ),\n emailDeliveryFailed: (detail: string) =>\n new CapxulError(\"EMAIL_DELIVERY_FAILED\", \"Failed to send email\", {\n details: { detail },\n }),\n\n profileNotFound: (authUserId: string) =>\n new CapxulError(\"PROFILE_NOT_FOUND\", `Profile not found for user ${authUserId}`, {\n details: { authUserId },\n }),\n\n smartAccountMissing: (authUserId: string) =>\n new CapxulError(\"SMART_ACCOUNT_MISSING\", \"Smart account not provisioned\", {\n details: { authUserId },\n }),\n\n playerNotFound: (playerId?: string) =>\n new CapxulError(\n \"PLAYER_NOT_FOUND\",\n playerId ? `Openfort player ${playerId} not found` : \"Openfort player not found\",\n playerId === undefined ? undefined : { details: { playerId } },\n ),\n\n accountNotFound: (accountId?: string) =>\n new CapxulError(\n \"ACCOUNT_NOT_FOUND\",\n accountId ? `Openfort account ${accountId} not found` : \"Openfort account not found\",\n accountId === undefined ? undefined : { details: { accountId } },\n ),\n\n providerError: (\n provider: string,\n operation: string,\n cause: unknown,\n opts?: { readonly failure_mode?: FailureMode },\n ) => {\n const details: Record<string, unknown> = { provider, operation };\n if (opts?.failure_mode) {\n details.failure_mode = opts.failure_mode;\n }\n return new CapxulError(\"PROVIDER_ERROR\", `Provider error: ${provider} ${operation}`, {\n cause,\n details,\n });\n },\n\n invalidInput: (field: string, reason: string) =>\n new CapxulError(\"INVALID_INPUT\", `Invalid ${field}: ${reason}`, {\n details: { field, reason },\n }),\n\n envMissing: (name: string) =>\n new CapxulError(\"ENV_MISSING\", `Environment variable ${name} not configured`, {\n details: { name },\n }),\n\n notImplemented: (domain: string, method: string) =>\n new CapxulError(\n \"NOT_IMPLEMENTED\",\n `${domain}.${method} is not yet implemented. This feature is planned for a future release.`,\n { details: { domain, method } },\n ),\n\n /**\n * Sibling factory to {@link Errors.providerError} for the per-state timeout\n * path in flows. Same `PROVIDER_ERROR` code as\n * `providerError`, plus a `details.reason: \"timeout\"` discriminator so\n * downstream observers can distinguish failure modes without parsing the\n * message string. The redacted message names the timeout budget; the\n * native `cause` carries the same information for `reportError` fidelity.\n */\n providerTimeout: (provider: string, operation: string, timeoutMs: number) =>\n new CapxulError(\n \"PROVIDER_ERROR\",\n `Provider error: ${provider} ${operation} (timeout exceeded ${timeoutMs}ms)`,\n {\n details: { provider, operation, reason: \"timeout\" },\n cause: new Error(`timeout: ${operation} exceeded ${timeoutMs}ms`),\n },\n ),\n\n verificationRequired: (details: VerificationRequiredDetails) => {\n const message =\n \"rail\" in details\n ? `Verification is required before ${details.rail} can use ${details.currentKind}.`\n : `Verification tier ${details.requiredTier} is required.`;\n\n return new CapxulError(\"VERIFICATION_REQUIRED\", message, {\n details,\n });\n },\n\n insufficientBalance: (asset: string, available: string, required: string) =>\n new CapxulError(\"INSUFFICIENT_BALANCE\", `Insufficient ${asset} balance`, {\n details: { asset, available, required },\n }),\n\n invalidRecipient: (reason: string) =>\n new CapxulError(\"INVALID_RECIPIENT\", `Invalid recipient: ${reason}`, {\n details: { reason },\n }),\n\n /**\n * The org Zodiac Roles modifier REFUSED the spend on-chain (G4 · #547): the\n * member's role condition (per-tx cap, per-day allowance, allowed recipient,\n * or membership) was violated, so `execTransactionWithRole` reverted. This is\n * a PERMISSION denial — explicitly NOT an `INSUFFICIENT_BALANCE` (the treasury\n * held the funds; the role's authority is what bound). `reason` discriminates\n * the violated condition (`over_cap` / `daily_cap` / `not_member` /\n * `disallowed_recipient` / `condition_violation`); leak-safe — no on-chain\n * identifiers ever enter the details.\n */\n rolePermissionDenied: (details: {\n readonly reason:\n | \"over_cap\"\n | \"daily_cap\"\n | \"not_member\"\n | \"disallowed_recipient\"\n | \"condition_violation\";\n readonly operation?: string;\n }) =>\n new CapxulError(\n \"ROLE_PERMISSION_DENIED\",\n `Org role denied this spend on-chain (${details.reason}).`,\n {\n details:\n details.operation === undefined\n ? { reason: details.reason }\n : { reason: details.reason, operation: details.operation },\n },\n ),\n\n /**\n * A transaction (or sponsored UserOp) failed. `details.reason` discriminates\n * the failure mode for callers that must distinguish a CONFIRMED on-chain\n * revert (`\"onchain_revert\"` — the op executed and reverted, e.g. a Zodiac\n * Roles condition violation) from an inconclusive infra failure. A confirmed\n * revert is the ONLY mode the org spend port may map to a roles denial.\n */\n transactionFailed: (operation: string, cause?: unknown, extra?: { readonly reason?: string }) =>\n new CapxulError(\"TRANSACTION_FAILED\", `Transaction failed: ${operation}`, {\n cause,\n details: extra?.reason === undefined ? { operation } : { operation, reason: extra.reason },\n }),\n\n rateLimited: (details?: { readonly retryAfterMs?: number; readonly resource?: string }) =>\n new CapxulError(\n \"RATE_LIMITED\",\n \"Rate limit exceeded\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n networkError: (operation: string, cause?: unknown) =>\n new CapxulError(\"NETWORK_ERROR\", `Network error during ${operation}`, {\n cause,\n details: { operation },\n }),\n\n unknown: (cause?: unknown) => new CapxulError(\"UNKNOWN\", \"Unknown error\", { cause }),\n\n otpExpired: (details?: { readonly email?: string; readonly expiredAt?: number }) =>\n new CapxulError(\n \"OTP_EXPIRED\",\n \"Verification code has expired. Request a new one.\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n signerRejected: (details: {\n readonly source: SignerSource;\n readonly reason?: string;\n readonly cause?: unknown;\n }) =>\n new CapxulError(\"SIGNER_REJECTED\", \"Signer rejected the request.\", {\n cause: details.cause,\n details:\n details.reason === undefined\n ? { source: details.source }\n : { source: details.source, reason: details.reason },\n }),\n\n cancelled: (details?: { readonly operation?: string; readonly reason?: string }) =>\n new CapxulError(\n \"CANCELLED\",\n \"Operation was cancelled.\",\n details === undefined ? undefined : { details: { ...details } },\n ),\n\n /**\n * Method called from a flow state where its precondition fails (TA16). The\n * SDK's method API short-circuits with this error before driving the\n * internal state machine. `currentState` is the Effect-machine snapshot\n * tag (stringified from the SDK's actor-shell snapshot; see\n * `packages/errors/CONTEXT.md`); `validStates`\n * enumerates the states the method accepts.\n */\n wrongState: (details: {\n readonly method: string;\n readonly currentState: string;\n readonly validStates: readonly string[];\n }) =>\n new CapxulError(\n \"WRONG_STATE\",\n `${details.method} called from state '${details.currentState}'; valid states: ${details.validStates.join(\", \")}`,\n { details: { ...details, validStates: [...details.validStates] } },\n ),\n} as const;\n","// Shared `decodeConvexError` helper (TA5) — used by both the SDK's\n// `ConvexCallAdapter.mapToCapxulError` AND the backend `credentials/http.ts`\n// `bootstrapClient` handler. Single source of truth for cross-Convex-boundary\n// error decoding rules.\n//\n// Recognizes the `ConvexError(SerializedCapxulError)` object-shape produced by\n// `withErrorBoundary` (Probe B finding, 2026-05-19):\n//\n// { name: \"ConvexError\", data: { code, message, details?, correlationId?, layer? } }\n//\n// AND the defensive string-shape branch for older Convex versions where\n// `data` is a JSON-serialized string. Pass-through for raw `CapxulError`\n// instances (which arrive directly when the throw happened in the same\n// V8 isolate as the catch). Returns null when the value is not a\n// recognizable shape — the caller falls back to NETWORK_ERROR + reportError.\n\nimport {\n CAPXUL_ERROR_CODES,\n CapxulError,\n type CapxulErrorCode,\n type SerializedCapxulError,\n deserializeCapxulError,\n} from \"./errors.ts\";\n\n// Derived from the canonical catalog in errors.ts — single source of truth,\n// so a new code added to `CAPXUL_ERROR_CODES` is recognized here automatically.\nconst KNOWN_CODES: ReadonlySet<CapxulErrorCode> = new Set(CAPXUL_ERROR_CODES);\n\nfunction isCapxulCode(value: unknown): value is CapxulErrorCode {\n return typeof value === \"string\" && KNOWN_CODES.has(value as CapxulErrorCode);\n}\n\nfunction reconstruct(serialized: Record<string, unknown>): CapxulError | null {\n if (!isCapxulCode(serialized.code)) return null;\n const payload: SerializedCapxulError = {\n code: serialized.code,\n message: typeof serialized.message === \"string\" ? serialized.message : String(serialized.code),\n ...(typeof serialized.details === \"object\" &&\n serialized.details !== null &&\n !Array.isArray(serialized.details)\n ? { details: serialized.details as Record<string, unknown> }\n : {}),\n ...(typeof serialized.correlationId === \"string\"\n ? { correlationId: serialized.correlationId }\n : {}),\n ...(typeof serialized.layer === \"string\" ? { layer: serialized.layer } : {}),\n };\n return deserializeCapxulError(payload);\n}\n\nexport function decodeConvexError(err: unknown): CapxulError | null {\n if (err === null || err === undefined) return null;\n\n // Pass-through: same isolate, real CapxulError instance.\n if (err instanceof CapxulError) return err;\n\n if (typeof err !== \"object\") return null;\n\n // The canonical shape produced by `withErrorBoundary` then crossed by\n // Convex's `ctx.runQuery` / `ConvexHttpClient`: a `ConvexError` whose\n // `data` is the `SerializedCapxulError` object literal.\n const record = err as Record<string, unknown>;\n if (!(\"data\" in record)) return null;\n const data = record.data;\n\n if (typeof data === \"object\" && data !== null) {\n return reconstruct(data as Record<string, unknown>);\n }\n\n // Defensive depth — some Convex versions JSON-stringify the data at\n // the runtime boundary. Probe B confirmed @convex-dev/better-auth 0.10.13\n // + convex 1.39.x do NOT do this, but the cheap parse keeps forward\n // compatibility.\n if (typeof data === \"string\") {\n try {\n const parsed = JSON.parse(data) as unknown;\n if (typeof parsed === \"object\" && parsed !== null) {\n return reconstruct(parsed as Record<string, unknown>);\n }\n } catch {\n // Fall through.\n }\n }\n\n return null;\n}\n","import { Errors } from \"@capxul/errors\";\nimport type { CapxulClient } from \"@capxul/sdk\";\n\n/**\n * Narrow the bootstrap-nullable client to a ready client inside a query /\n * mutation function (sdk-provider-owned-bootstrap.md). Data hooks gate their\n * queries on `enabled: client !== null`, so this only ever throws for a mutation\n * triggered while `<CapxulProvider>` is still bootstrapping.\n */\nexport function requireBootstrappedClient(\n client: CapxulClient | null,\n method: string,\n): CapxulClient {\n if (client === null) {\n throw Errors.wrongState({ method, currentState: \"bootstrapping\", validStates: [\"ready\"] });\n }\n return client;\n}\n","import type { TelemetryPort } from \"@capxul/sdk\";\nimport type { CapxulResult } from \"@capxul/sdk\";\n\n/**\n * Unwrap a `CapxulResult` for TanStack query/mutation functions and throw into\n * React Query's error path.\n *\n * Failure observation belongs to the core SDK method boundary. The legacy\n * telemetry/operation arguments remain temporarily source-compatible with the\n * existing hook call sites, but are deliberately ignored so React cannot\n * report the same logical failure a second time.\n */\nexport function unwrapCapxulResult<T>(\n result: CapxulResult<T>,\n _legacyTelemetry?: TelemetryPort,\n _legacyOperation: \"query\" | \"mutation\" = \"query\",\n): T {\n if (result.ok) {\n return result.value;\n }\n throw result.error;\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError, Profile } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\nimport { useCapxulIdentityOrNull } from \"../identity\";\n\nexport type UseCapxulProfileReturn = UseQueryResult<Profile | null, CapxulError>;\n\nexport function useCapxulProfile(): UseCapxulProfileReturn {\n const client = useCapxulClientOrNull();\n const identity = useCapxulIdentityOrNull();\n return useQuery({\n queryKey: capxulKeys.profile,\n queryFn: async () =>\n unwrapCapxulResult(\n await requireBootstrappedClient(client, \"identity.loadCurrent\").identity.loadCurrent(),\n client!._internal.telemetry,\n ),\n // loadCurrent answers null while the auth session snapshot is still\n // restoring — indistinguishable from \"no profile\". Fetching before the\n // session is restored caches that null for the whole page lifetime.\n enabled: client !== null && identity?.phase === \"authenticated\",\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { Account, CapxulError } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulAccountBalanceReturn = UseQueryResult<Account, CapxulError>;\n\nexport type UseCapxulAccountBalanceOptions = {\n /** When false, skips the Convex readBalance action until the account ladder is ready. */\n readonly enabled?: boolean;\n};\n\nexport function useCapxulAccountBalance(\n options?: UseCapxulAccountBalanceOptions,\n): UseCapxulAccountBalanceReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.accountBalance,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"accounts.read\");\n return unwrapCapxulResult(\n await bootstrappedClient.accounts.read(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\nimport type { CapxulError, Money } from \"@capxul/sdk\";\n\nexport type UseCapxulAccountFundReturn = UseMutationResult<\n { readonly txHash: string },\n CapxulError,\n Money\n>;\n\nexport function useCapxulAccountFund(): UseCapxulAccountFundReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (amount: Money) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"_internal.accounts.fund\");\n return unwrapCapxulResult(\n await bootstrappedClient._internal.accounts.fund(amount),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type {\n AccountId,\n CapxulError,\n SubAccount,\n SubAccountId,\n TransferInput,\n TransferResult,\n} from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulSubAccountsListOptions = {\n readonly enabled?: boolean;\n};\n\nexport type UseCapxulSubAccountsListReturn = UseQueryResult<readonly SubAccount[], CapxulError>;\n\nexport function useCapxulSubAccountsList(\n accountId: AccountId | undefined,\n options?: UseCapxulSubAccountsListOptions,\n): UseCapxulSubAccountsListReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.subAccounts(accountId),\n queryFn: async () => {\n if (accountId === undefined) {\n throw Errors.invalidInput(\"accountId\", \"required for subAccounts.list\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.list\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.list(accountId),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true) && accountId !== undefined,\n });\n}\n\nexport type UseCapxulSubAccountCreateReturn = UseMutationResult<\n SubAccount,\n CapxulError,\n { readonly accountId: AccountId; readonly name: string }\n>;\n\nexport function useCapxulSubAccountCreate(): UseCapxulSubAccountCreateReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.create\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.create(input.accountId, { name: input.name }),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\nexport type UseCapxulSubAccountRenameReturn = UseMutationResult<\n SubAccount,\n CapxulError,\n { readonly accountId: AccountId; readonly subAccountId: SubAccountId; readonly name: string }\n>;\n\nexport function useCapxulSubAccountRename(): UseCapxulSubAccountRenameReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.rename\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.rename(input.subAccountId, input.name),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\nexport type UseCapxulSubAccountDeleteReturn = UseMutationResult<\n void,\n CapxulError,\n { readonly accountId: AccountId; readonly subAccountId: SubAccountId }\n>;\n\nexport function useCapxulSubAccountDelete(): UseCapxulSubAccountDeleteReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.delete\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.delete(input.subAccountId),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n\n/**\n * Move money between two of the SAME Account's balances (canon §5/§12). The\n * consumer-facing labels are \"Add money\" (main → sub) and \"Move money out\"\n * (sub → main), both calling `transfer`. `accountId` is carried only to\n * invalidate the right cache keys; the SDK input itself is `{ from, to, amount }`.\n */\nexport type UseCapxulTransferReturn = UseMutationResult<\n TransferResult,\n CapxulError,\n { readonly accountId: AccountId } & TransferInput\n>;\n\nexport function useCapxulTransfer(): UseCapxulTransferReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async ({ from, to, amount }) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"subAccounts.transfer\");\n return unwrapCapxulResult(\n await bootstrappedClient.subAccounts.transfer({ from, to, amount }),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_value, variables) => {\n await queryClient.invalidateQueries({\n queryKey: capxulKeys.subAccounts(variables.accountId),\n });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance });\n },\n });\n}\n","import type { QueryClient } from \"@tanstack/react-query\";\n\nimport type { ActorReference, OrgId, Payment } from \"@capxul/sdk\";\n\nimport { capxulKeys } from \"./reactivity-keys\";\n\n/**\n * Actor scope a money mutation settled under.\n *\n * #1145 (DEMOLITION §D5): the insights, address-book and org-`account`\n * invalidations this used to fan out to named queries that no hook creates any\n * more — the actor-scope family and `useCapxulOrganizationAccount` are deleted.\n * Invalidating a key nothing reads is a no-op that reads as coverage.\n */\ntype MoneyActorScope =\n | { readonly kind: \"account\" }\n | { readonly kind: \"org\"; readonly orgId: string }\n | ActorReference;\n\nexport function isPayment(value: unknown): value is Payment {\n if (typeof value !== \"object\" || value === null) return false;\n const record = value as Record<string, unknown>;\n return (\n typeof record.id === \"string\" &&\n typeof record.status === \"string\" &&\n typeof record.paymentType === \"string\" &&\n typeof record.amount === \"object\" &&\n record.amount !== null\n );\n}\n\nexport function paymentsFromValue(value: unknown): readonly Payment[] {\n if (Array.isArray(value)) return value.filter(isPayment);\n if (isPayment(value)) return [value];\n if (typeof value !== \"object\" || value === null) return [];\n const payments = (value as Record<string, unknown>).payments;\n return Array.isArray(payments) ? payments.filter(isPayment) : [];\n}\n\nexport async function invalidateMoneyState(\n queryClient: QueryClient,\n input: {\n readonly actor: MoneyActorScope;\n readonly payment?: Payment;\n },\n): Promise<void> {\n const invalidations = [queryClient.invalidateQueries({ queryKey: capxulKeys.payments })];\n\n if (input.payment !== undefined) {\n invalidations.push(\n queryClient.invalidateQueries({ queryKey: capxulKeys.payment(input.payment.id) }),\n );\n }\n\n if (input.actor.kind === \"account\" || input.actor.kind === \"personal\") {\n invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance }));\n } else {\n const orgId = (\n input.actor.kind === \"org\" ? input.actor.orgId : input.actor.organizationId\n ) as OrgId;\n invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.orgTreasury(orgId) }));\n }\n\n await Promise.all(invalidations);\n}\n","import { Errors } from \"@capxul/errors\";\n\n/**\n * Guard for mutation hooks whose variables carry an optional `actor` field\n * (`useCapxulPay`, `useCapxulPayout`, `useCapxulAddDestination`,\n * `useCapxulRemoveDestination`). Mirrors `requireActorScope` on the query path:\n * an EXPLICITLY-passed `actor: undefined` (the `capxulOrgScope(notYetLoadedOrgId)`\n * footgun) must fail loudly rather than silently fall back to the personal\n * scope. Omitting the `actor` key entirely keeps the personal-scope default.\n *\n * Throws `CapxulError` code `INVALID_INPUT` with `details.field === \"actor\"`;\n * called inside an async mutationFn it surfaces as `mutation.error: CapxulError`.\n */\nexport function rejectUnresolvedActor(variables: object, operation: string): void {\n if (\n Object.hasOwn(variables, \"actor\") &&\n (variables as { readonly actor?: unknown }).actor === undefined\n ) {\n throw Errors.invalidInput(\n \"actor\",\n `explicitly provided but undefined for ${operation} — actor scope not yet resolved; omit actor for the personal scope`,\n );\n }\n}\n","\"use client\";\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationResult,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type {\n Payment,\n PaymentsPayInput,\n PaymentsPayoutInput,\n PaymentsWithdrawInput,\n} from \"@capxul/sdk\";\nimport type { CapxulError } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { invalidateMoneyState } from \"../internal/invalidate-money-state\";\nimport { rejectUnresolvedActor } from \"../internal/reject-unresolved-actor\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulPayReturn = UseMutationResult<Payment, CapxulError, PaymentsPayInput>;\nexport function useCapxulPay(): UseCapxulPayReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n rejectUnresolvedActor(input, \"payments.pay\");\n const bootstrappedClient = requireBootstrappedClient(client, \"payments.pay\");\n return unwrapCapxulResult(\n await bootstrappedClient.payments.pay(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (payment) => {\n await invalidateMoneyState(queryClient, { actor: { kind: \"personal\" }, payment });\n },\n });\n}\n\nexport type UseCapxulPayoutReturn = UseMutationResult<Payment, CapxulError, PaymentsPayoutInput>;\nexport function useCapxulPayout(): UseCapxulPayoutReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n rejectUnresolvedActor(input, \"payments.payout\");\n const bootstrappedClient = requireBootstrappedClient(client, \"payments.payout\");\n return unwrapCapxulResult(\n await bootstrappedClient.payments.payout(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (payment, variables) => {\n const actor = variables.actor ?? { kind: \"personal\" as const };\n await invalidateMoneyState(queryClient, { actor, payment });\n },\n });\n}\n\nexport type UseCapxulWithdrawReturn = UseMutationResult<\n Payment,\n CapxulError,\n PaymentsWithdrawInput\n>;\nexport function useCapxulWithdraw(): UseCapxulWithdrawReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"payments.withdraw\");\n return unwrapCapxulResult(\n await bootstrappedClient.payments.withdraw(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (payment) => {\n await invalidateMoneyState(queryClient, { actor: { kind: \"personal\" }, payment });\n },\n });\n}\n\nexport type UseCapxulPaymentsReturn = UseQueryResult<readonly Payment[], CapxulError>;\nexport function useCapxulPayments(options?: {\n readonly enabled?: boolean;\n}): UseCapxulPaymentsReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.payments,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"payments.list\");\n return unwrapCapxulResult(\n await bootstrappedClient.payments.list(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true),\n });\n}\n\nexport type UseCapxulPaymentReturn = UseQueryResult<Payment | null, CapxulError>;\nexport function useCapxulPayment(\n paymentId: string | undefined,\n options?: { readonly enabled?: boolean },\n): UseCapxulPaymentReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.payment(paymentId),\n queryFn: async () => {\n if (paymentId === undefined)\n throw Errors.invalidInput(\"paymentId\", \"required for payments.get\");\n const bootstrappedClient = requireBootstrappedClient(client, \"payments.get\");\n return unwrapCapxulResult(\n await bootstrappedClient.payments.get(paymentId),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && paymentId !== undefined && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError, OrgView } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * List the Orgs you belong to (canon §C1 \"Org list\" / §C3). Binds directly to\n * the locked `capxul.orgs()` SDK method.\n */\nexport type UseCapxulOrgsReturn = UseQueryResult<readonly OrgView[], CapxulError>;\n\nexport type UseCapxulOrgsOptions = {\n /**\n * Gate the query on auth readiness. `client.orgs()` is a session-scoped\n * authenticated read; firing it before the session token settles surfaces a\n * spurious `NOT_AUTHENTICATED`. Consumers pass `enabled: <auth-ready>` (e.g.\n * \"the Organization surface is active\") — mirrors `useCapxulSubAccountsList`.\n * Defaults to `true` to preserve the bare `useCapxulOrgs()` call shape.\n */\n readonly enabled?: boolean;\n};\n\nexport function useCapxulOrgs(options?: UseCapxulOrgsOptions): UseCapxulOrgsReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.orgs,\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"orgs\");\n return unwrapCapxulResult(\n await bootstrappedClient.orgs(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { CapxulError, MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgMembersOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The members of an Org (canon §C1 \"Members\" / §C3, D8/D9). Binds directly to\n * the entity-scoped `capxul.org(orgId).members()` (D13). Gated by\n * `orgId !== undefined`; callers may additionally gate on canonical identity\n * readiness through `options.enabled`.\n */\nexport type UseCapxulOrgMembersReturn = UseQueryResult<readonly MemberView[], CapxulError>;\n\nexport function useCapxulOrgMembers(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgMembersOptions,\n): UseCapxulOrgMembersReturn {\n const client = useCapxulClientOrNull();\n const enabled = options?.enabled ?? true;\n return useQuery({\n queryKey: capxulKeys.orgMembers(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgMembers\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.members\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).members(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && enabled && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { CapxulError, OrgId, RoleView } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgRolesOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The roles seeded on an Org (canon §C1 \"Roles\" / §C3, D4/D6). Binds directly\n * to the entity-scoped `capxul.org(orgId).roles()` (D13). Gated by\n * `orgId !== undefined`. RED until S2.\n */\nexport type UseCapxulOrgRolesReturn = UseQueryResult<readonly RoleView[], CapxulError>;\n\nexport function useCapxulOrgRoles(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgRolesOptions,\n): UseCapxulOrgRolesReturn {\n const client = useCapxulClientOrNull();\n const enabled = options?.enabled ?? true;\n return useQuery({\n queryKey: capxulKeys.orgRoles(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgRoles\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.roles\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).roles(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && enabled && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError, OrgId, RoleView } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgDeployRolesReturn = UseMutationResult<\n readonly RoleView[],\n CapxulError,\n OrgId\n>;\n\nexport function useCapxulOrgDeployRoles(): UseCapxulOrgDeployRolesReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (orgId: OrgId) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"org.deployRoles\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).deployRoles(),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async (_roles, orgId) => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgRoles(orgId) });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.org(orgId) });\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgs });\n },\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { Account, CapxulError, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\nexport type UseCapxulOrgTreasuryOptions = {\n readonly enabled?: boolean;\n};\n\n/**\n * The Org treasury — the real M2 `Account` over the Org Safe (canon §C3, D3).\n * NEVER `AccountStatus` (the deploy-readiness ladder, no balance). Binds\n * directly to the entity-scoped `capxul.org(orgId).treasury()` (D13). Gated by\n * `orgId !== undefined`. RED until S1.\n */\nexport type UseCapxulOrgTreasuryReturn = UseQueryResult<Account, CapxulError>;\n\nexport function useCapxulOrgTreasury(\n orgId: OrgId | undefined,\n options?: UseCapxulOrgTreasuryOptions,\n): UseCapxulOrgTreasuryReturn {\n const client = useCapxulClientOrNull();\n const enabled = options?.enabled ?? true;\n return useQuery({\n queryKey: capxulKeys.orgTreasury(orgId),\n queryFn: async () => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulOrgTreasury\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.treasury\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).treasury(),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && enabled && orgId !== undefined,\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError, CreateOrgInput, OrgView } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Create an Org (canon §C2 J1 / §C3, S1). Binds directly to the locked\n * `capxul.createOrg(input)` SDK method. On success, invalidates the org list.\n * RED until S1 — `mutate` rejects with `Errors.notImplemented(\"org\",\"createOrg\")`.\n */\nexport type UseCapxulCreateOrgReturn = UseMutationResult<OrgView, CapxulError, CreateOrgInput>;\n\nexport function useCapxulCreateOrg(): UseCapxulCreateOrgReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CreateOrgInput) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"createOrg\");\n return unwrapCapxulResult(\n await bootstrappedClient.createOrg(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgs });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { CapxulError, InviteMemberInput, MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Invite a member to an Org by email (canon §C2 J2 virality loop / §C3, S3, D8).\n * Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).invite(input)`. On success, invalidates the member list.\n * RED until S3 — `mutate` rejects with `Errors.notImplemented(\"org\",\"invite\")`.\n */\nexport type UseCapxulInviteMemberReturn = UseMutationResult<\n MemberView,\n CapxulError,\n InviteMemberInput\n>;\n\nexport function useCapxulInviteMember(orgId: OrgId | undefined): UseCapxulInviteMemberReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: InviteMemberInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulInviteMember\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.invite\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).invite(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { CapxulError, OrgId, RemoveMemberInput } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Remove a member from an Org (canon §C2 J2 / §C3, S3, D7/D8) — drives the\n * on-chain REVOKE + Convex mirror. Keyed on the member's personal Safe address\n * (D7). Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).removeMember(input)`. On success, invalidates the member\n * list. RED until S3 — `mutate` rejects with\n * `Errors.notImplemented(\"org\",\"removeMember\")`.\n */\nexport type UseCapxulRemoveMemberReturn = UseMutationResult<void, CapxulError, RemoveMemberInput>;\n\nexport function useCapxulRemoveMember(orgId: OrgId | undefined): UseCapxulRemoveMemberReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: RemoveMemberInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulRemoveMember\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.removeMember\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).removeMember(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport { Errors } from \"@capxul/errors\";\nimport type { AssignRoleInput, CapxulError, MemberView, OrgId } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../internal/capxul-client-context\";\nimport { capxulKeys } from \"../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../internal/unwrap-capxul-result\";\n\n/**\n * Assign a role to a member (canon §C2 J2 / §C3, S3, D7/D9) — drives the\n * on-chain GRANT + Convex mirror. Keyed on the member's personal Safe address\n * (D7); the `role` label maps deterministically to the on-chain `roleKey` (D9).\n * Entity-scoped via the closed-over `orgId` (D13). Binds directly to\n * `capxul.org(orgId).assignRole(input)`. On success, invalidates the member\n * list. RED until S3 — `mutate` rejects with\n * `Errors.notImplemented(\"org\",\"assignRole\")`.\n */\nexport type UseCapxulAssignRoleReturn = UseMutationResult<MemberView, CapxulError, AssignRoleInput>;\n\nexport function useCapxulAssignRole(orgId: OrgId | undefined): UseCapxulAssignRoleReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: AssignRoleInput) => {\n if (orgId === undefined) {\n throw Errors.invalidInput(\"orgId\", \"required for useCapxulAssignRole\");\n }\n const bootstrappedClient = requireBootstrappedClient(client, \"org.assignRole\");\n return unwrapCapxulResult(\n await bootstrappedClient.org(orgId).assignRole(input),\n bootstrappedClient._internal.telemetry,\n \"mutation\",\n );\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgMembers(orgId) });\n },\n });\n}\n","// #1066: the durable onboarding journey record — the proven #844 Reference\n// implementation promoted into the SDK headless layer. Behavior map §3:\n// versioned, sessionStorage-backed, owner-scoped; reload resumes, sign-out\n// clears. This module owns journey DATA and transitions only — mapping a step\n// to a route is the consuming app's projection (apps disagree on paths, never\n// on steps).\nexport type OnboardingIntent = \"personal\" | \"organization\";\nexport type OnboardingStep = \"profile\" | \"organization\" | \"provisioning\";\n\nexport type PayoutDraftChain = \"evm\" | \"solana\" | \"starknet\";\n\nexport type PayoutDraftEntry = {\n readonly chain: PayoutDraftChain;\n readonly address: string;\n};\n\nexport type ProfileDraft = {\n readonly displayName: string;\n readonly country: string;\n readonly withdrawalAddress: string;\n // #1062 / #1063: collected at the profile step, persisted at submit.\n readonly username?: string;\n readonly payoutAddresses?: readonly PayoutDraftEntry[];\n};\n\nexport type OrganizationDraft = {\n readonly name: string;\n readonly handle: string;\n readonly country: string;\n // #1064\n readonly bio?: string;\n readonly size?: string;\n};\n\nexport type OnboardingOrigin =\n | { readonly kind: \"personal\" }\n | { readonly kind: \"organization\"; readonly organizationId: string }\n | { readonly kind: \"proof\"; readonly organizationId?: string };\n\nexport type OnboardingJourney = {\n readonly version: 1;\n readonly ownerId: string;\n readonly journeyId: string;\n readonly intent: OnboardingIntent;\n readonly entryPoint: \"signup\" | \"dashboard\";\n readonly origin?: OnboardingOrigin;\n readonly step: OnboardingStep;\n readonly profile?: ProfileDraft;\n readonly organization?: OrganizationDraft;\n readonly stableHandle?: string;\n readonly organizationId?: string;\n};\n\n/**\n * The app-facing projection input: where a resumed journey stands. Consumers\n * map this to their own routes.\n */\nexport type OnboardingJourneyPosition = {\n readonly intent: OnboardingIntent;\n readonly step: OnboardingStep;\n readonly organizationId?: string;\n readonly proof: boolean;\n};\n\nconst JOURNEY_KEY = \"capxul.onboarding.journey.v1\";\nconst VALIDATED_OWNER_KEY = \"capxul.onboarding.validated-owner.v1\";\nconst JOURNEY_VERSION = 1;\nconst MAX_DRAFT_TEXT_LENGTH = 200;\nconst MAX_ID_LENGTH = 160;\nconst MAX_STORED_JOURNEY_LENGTH = 8_192;\nconst MAX_PAYOUT_DRAFT_ENTRIES = 10;\n\n/**\n * The owner whose stored journey may currently be attributed to observations.\n * Persisted in sessionStorage rather than module memory so `currentOnboarding-\n * JourneyId` is a pure function of durable state — attribution is the same\n * regardless of the order of renders, reloads, or telemetry emits. Established\n * only when an authenticated owner is (journey start, or an owner-matched load)\n * and cleared at every auth boundary or on discard.\n */\nfunction markOnboardingOwnerValidated(ownerId: string): void {\n try {\n sessionStorage.setItem(VALIDATED_OWNER_KEY, ownerId);\n } catch {\n // Browser recovery context is useful but never authoritative domain state.\n }\n}\n\nfunction clearValidatedOnboardingOwner(): void {\n try {\n sessionStorage.removeItem(VALIDATED_OWNER_KEY);\n } catch {\n // Domain completion remains durable even if browser cleanup is unavailable.\n }\n}\n\nfunction validatedOnboardingOwner(): string | null {\n try {\n return sessionStorage.getItem(VALIDATED_OWNER_KEY);\n } catch {\n return null;\n }\n}\n\nexport function startOnboardingJourney(input: {\n readonly intent: OnboardingIntent;\n readonly ownerId: string;\n readonly entryPoint: \"signup\" | \"dashboard\";\n readonly origin?: OnboardingOrigin;\n readonly step?: OnboardingStep;\n}): OnboardingJourney {\n const journey: OnboardingJourney = {\n version: JOURNEY_VERSION,\n ownerId: input.ownerId,\n journeyId: `journey_${createRandomId()}`,\n intent: input.intent,\n entryPoint: input.entryPoint,\n step: input.step ?? \"profile\",\n ...(input.origin === undefined ? {} : { origin: input.origin }),\n };\n markOnboardingOwnerValidated(journey.ownerId);\n saveOnboardingJourney(journey);\n return journey;\n}\n\nexport function loadOnboardingJourney(expectedOwnerId?: string): OnboardingJourney | null {\n try {\n const raw = sessionStorage.getItem(JOURNEY_KEY);\n if (raw === null) return null;\n if (raw.length > MAX_STORED_JOURNEY_LENGTH) return discardInvalidJourney();\n const value: unknown = JSON.parse(raw);\n if (!isValidJourney(value)) return discardInvalidJourney();\n if (expectedOwnerId !== undefined && value.ownerId !== expectedOwnerId) {\n return discardInvalidJourney();\n }\n if (expectedOwnerId !== undefined) markOnboardingOwnerValidated(expectedOwnerId);\n return value;\n } catch {\n return discardInvalidJourney();\n }\n}\n\nexport function saveOnboardingJourney(journey: OnboardingJourney): void {\n if (!isValidJourney(journey)) {\n discardInvalidJourney();\n return;\n }\n try {\n sessionStorage.setItem(JOURNEY_KEY, JSON.stringify(journey));\n } catch {\n // Browser recovery context is useful but never authoritative domain state.\n }\n}\n\nexport function currentOnboardingJourneyId(): string | undefined {\n const journey = loadOnboardingJourney();\n const owner = validatedOnboardingOwner();\n return journey !== null && owner !== null && journey.ownerId === owner\n ? journey.journeyId\n : undefined;\n}\n\n/** Stop observation attribution while no authenticated owner is established. */\nexport function invalidateOnboardingJourneyObservation(): void {\n clearValidatedOnboardingOwner();\n}\n\n/** Where the journey stands — the pure position apps map to their routes. */\nexport function onboardingJourneyPosition(journey: OnboardingJourney): OnboardingJourneyPosition {\n const proof = journey.origin?.kind === \"proof\";\n if (journey.organizationId !== undefined) {\n return {\n intent: journey.intent,\n step: \"provisioning\",\n organizationId: journey.organizationId,\n proof,\n };\n }\n return { intent: journey.intent, step: journey.step, proof };\n}\n\n/**\n * The interruption-recovery decision (behavior map §4): a journey that does\n * not match the ready destination the app just rendered must resume; a\n * matching one needs no recovery. Returns the journey to resume, or null.\n */\nexport function activeOnboardingRecovery(\n ownerId: string,\n renderedReadyDestination?:\n | { readonly kind: \"personal\" }\n | { readonly kind: \"organization\"; readonly organizationId: string },\n): OnboardingJourney | null {\n const journey = loadOnboardingJourney(ownerId);\n if (journey === null) return null;\n const isMatchingDestination =\n renderedReadyDestination?.kind === \"personal\"\n ? journey.intent === \"personal\" &&\n journey.step === \"provisioning\" &&\n journey.organizationId === undefined\n : renderedReadyDestination?.kind === \"organization\" &&\n journey.intent === \"organization\" &&\n journey.step === \"provisioning\" &&\n journey.organizationId === renderedReadyDestination.organizationId;\n return isMatchingDestination ? null : journey;\n}\n\nexport function acknowledgeOnboardingDestination(\n destination:\n | { readonly kind: \"personal\" }\n | { readonly kind: \"organization\"; readonly organizationId: string },\n ownerId: string,\n): boolean {\n const journey = loadOnboardingJourney(ownerId);\n if (journey === null) return false;\n const matches =\n destination.kind === \"personal\"\n ? journey.intent === \"personal\" && journey.step === \"provisioning\"\n : journey.intent === \"organization\" &&\n journey.step === \"provisioning\" &&\n journey.organizationId === destination.organizationId;\n if (!matches) return false;\n clearOnboardingJourney();\n return true;\n}\n\nexport function clearOnboardingJourney(): void {\n clearValidatedOnboardingOwner();\n try {\n sessionStorage.removeItem(JOURNEY_KEY);\n } catch {\n // Domain completion remains durable even if browser cleanup is unavailable.\n }\n}\n\nfunction isValidJourney(value: unknown): value is OnboardingJourney {\n if (!isRecord(value) || value.version !== JOURNEY_VERSION) return false;\n if (\n !hasOnlyKeys(value, [\n \"version\",\n \"ownerId\",\n \"journeyId\",\n \"intent\",\n \"entryPoint\",\n \"origin\",\n \"step\",\n \"profile\",\n \"organization\",\n \"stableHandle\",\n \"organizationId\",\n ])\n ) {\n return false;\n }\n if (!isBoundedId(value.ownerId)) return false;\n if (!isBoundedId(value.journeyId) || !value.journeyId.startsWith(\"journey_\")) return false;\n if (value.intent !== \"personal\" && value.intent !== \"organization\") return false;\n if (value.entryPoint !== \"signup\" && value.entryPoint !== \"dashboard\") return false;\n if (value.step !== \"profile\" && value.step !== \"organization\" && value.step !== \"provisioning\") {\n return false;\n }\n if (value.origin !== undefined && !isOrigin(value.origin)) return false;\n if (value.profile !== undefined && !isProfileDraft(value.profile)) return false;\n if (value.organization !== undefined && !isOrganizationDraft(value.organization)) return false;\n if (value.stableHandle !== undefined && !isDraftText(value.stableHandle)) return false;\n if (value.organizationId !== undefined && !isBoundedId(value.organizationId)) return false;\n if (value.organization !== undefined && value.stableHandle !== value.organization.handle) {\n return false;\n }\n if (value.stableHandle !== undefined && value.organization === undefined) return false;\n if (\n value.intent === \"personal\" &&\n (value.step === \"organization\" ||\n value.organization !== undefined ||\n value.stableHandle !== undefined)\n ) {\n return false;\n }\n if (value.step === \"organization\" && value.intent !== \"organization\") return false;\n if (value.organizationId !== undefined && value.intent !== \"organization\") return false;\n if (value.organizationId !== undefined && value.step !== \"provisioning\") return false;\n return true;\n}\n\nfunction isOrigin(value: unknown): value is OnboardingOrigin {\n if (!isRecord(value)) return false;\n if (value.kind === \"personal\") return hasOnlyKeys(value, [\"kind\"]);\n if (value.kind === \"organization\") {\n return hasOnlyKeys(value, [\"kind\", \"organizationId\"]) && isBoundedId(value.organizationId);\n }\n return (\n value.kind === \"proof\" &&\n hasOnlyKeys(value, [\"kind\", \"organizationId\"]) &&\n (value.organizationId === undefined || isBoundedId(value.organizationId))\n );\n}\n\nfunction isProfileDraft(value: unknown): value is ProfileDraft {\n if (\n !isRecord(value) ||\n !hasOnlyKeys(value, [\n \"displayName\",\n \"country\",\n \"withdrawalAddress\",\n \"username\",\n \"payoutAddresses\",\n ]) ||\n !isDraftText(value.displayName) ||\n !isDraftText(value.country) ||\n !isDraftText(value.withdrawalAddress)\n ) {\n return false;\n }\n if (value.username !== undefined && !isDraftText(value.username)) return false;\n if (value.payoutAddresses !== undefined && !isPayoutDraftList(value.payoutAddresses)) {\n return false;\n }\n return true;\n}\n\nfunction isPayoutDraftList(value: unknown): value is readonly PayoutDraftEntry[] {\n return (\n Array.isArray(value) &&\n value.length <= MAX_PAYOUT_DRAFT_ENTRIES &&\n value.every(\n (entry: unknown) =>\n isRecord(entry) &&\n hasOnlyKeys(entry, [\"chain\", \"address\"]) &&\n (entry.chain === \"evm\" || entry.chain === \"solana\" || entry.chain === \"starknet\") &&\n isDraftText(entry.address),\n )\n );\n}\n\nfunction isOrganizationDraft(value: unknown): value is OrganizationDraft {\n if (\n !isRecord(value) ||\n !hasOnlyKeys(value, [\"name\", \"handle\", \"country\", \"bio\", \"size\"]) ||\n !isDraftText(value.name) ||\n !isDraftText(value.handle) ||\n !isDraftText(value.country)\n ) {\n return false;\n }\n if (value.bio !== undefined && !isDraftText(value.bio)) return false;\n if (value.size !== undefined && !isDraftText(value.size)) return false;\n return true;\n}\n\nfunction isDraftText(value: unknown): value is string {\n return typeof value === \"string\" && value.length <= MAX_DRAFT_TEXT_LENGTH;\n}\n\nfunction isBoundedId(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0 && value.length <= MAX_ID_LENGTH;\n}\n\nfunction discardInvalidJourney(): null {\n clearValidatedOnboardingOwner();\n try {\n sessionStorage.removeItem(JOURNEY_KEY);\n } catch {\n // Invalid browser context remains non-authoritative when storage is unavailable.\n }\n return null;\n}\n\nfunction createRandomId(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") return globalThis.crypto.randomUUID();\n return Math.random().toString(36).slice(2);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasOnlyKeys(value: Record<string, unknown>, allowed: readonly string[]): boolean {\n return Object.keys(value).every((key) => allowed.includes(key));\n}\n","\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/** The value as of `delayMs` after its last change (initial value immediate). */\nexport function useDebouncedValue<T>(value: T, delayMs: number): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delayMs);\n return () => clearTimeout(timer);\n }, [value, delayMs]);\n return debounced;\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../../internal/capxul-client-context\";\nimport { capxulKeys } from \"../../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../../internal/unwrap-capxul-result\";\nimport { useDebouncedValue } from \"../../internal/use-debounced-value\";\n\nexport type UsernameAvailability = {\n readonly available: boolean;\n readonly normalized: string;\n};\n\nexport type UseCapxulUsernameAvailabilityReturn = UseQueryResult<UsernameAvailability, CapxulError>;\n\n/**\n * #1062: debounced availability probe for the username the user is typing.\n * Disabled until the candidate reaches the 3-character floor; a malformed or\n * reserved candidate surfaces as the query's error (INVALID_INPUT with the\n * boundary's message), not as `available: false` — only a username someone\n * else owns is \"taken\".\n */\nexport function useCapxulUsernameAvailability(\n username: string,\n options?: { readonly enabled?: boolean; readonly debounceMs?: number },\n): UseCapxulUsernameAvailabilityReturn {\n const client = useCapxulClientOrNull();\n const candidate = useDebouncedValue(username.trim(), options?.debounceMs ?? 300);\n return useQuery({\n queryKey: capxulKeys.usernameAvailability(candidate),\n queryFn: async () => {\n const bootstrappedClient = requireBootstrappedClient(client, \"identity.usernameAvailable\");\n return unwrapCapxulResult(\n await bootstrappedClient.identity.usernameAvailable(candidate),\n bootstrappedClient._internal.telemetry,\n );\n },\n enabled: client !== null && candidate.length >= 3 && (options?.enabled ?? true),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/sdk\";\n\nimport { useCapxulClientOrNull } from \"../../internal/capxul-client-context\";\nimport { capxulKeys } from \"../../internal/reactivity-keys\";\nimport { requireBootstrappedClient } from \"../../internal/require-bootstrapped-client\";\nimport { unwrapCapxulResult } from \"../../internal/unwrap-capxul-result\";\n\nexport type ImageUploadTarget =\n | { readonly kind: \"profile\" }\n | { readonly kind: \"orgLogo\"; readonly orgId: string };\n\nexport type ImageUploadInput = {\n readonly blob: Blob;\n readonly target: ImageUploadTarget;\n};\n\nexport type UseCapxulImageUploadReturn = UseMutationResult<\n { readonly url: string | null },\n CapxulError,\n ImageUploadInput\n>;\n\n/**\n * #1061 / ADR-0014: the whole upload→record sequence as one mutation —\n * upload the blob, then bind the returned storage id to the profile image or\n * the org logo. The url is the resolved serving URL (re-read from queries,\n * never persisted by consumers).\n */\nexport function useCapxulImageUpload(): UseCapxulImageUploadReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async ({ blob, target }) => {\n const bootstrappedClient = requireBootstrappedClient(client, \"media.uploadImage\");\n const media = bootstrappedClient.media;\n const telemetry = bootstrappedClient._internal.telemetry;\n const uploaded = unwrapCapxulResult(await media.uploadImage(blob), telemetry);\n if (target.kind === \"profile\") {\n const set = unwrapCapxulResult(\n await media.setProfileImage({ storageId: uploaded.storageId }),\n telemetry,\n );\n return { url: set.imageUrl };\n }\n const set = unwrapCapxulResult(\n await media.setOrgLogo({ orgId: target.orgId, storageId: uploaded.storageId }),\n telemetry,\n );\n return { url: set.logoUrl };\n },\n onSuccess: async (_value, input) => {\n await queryClient.invalidateQueries({\n queryKey: input.target.kind === \"profile\" ? capxulKeys.profile : capxulKeys.orgs,\n });\n },\n });\n}\n"],"mappings":";;;;;AAKA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AA4FA,IAAa,cAAb,cAAiC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S,WAAW;CAC5E,CAAC;AACH;;;;;;;;;ACXA,SAAgB,uBAAmD;CACjE,MAAM,SAAS,sBAAsB;CACrC,MAAM,cAAc,eAAe;CACnC,OAAO,YAAY;EACjB,YAAY,OAAO,EAAE,MAAM,aAAa;GACtC,MAAM,qBAAqB,0BAA0B,QAAQ,mBAAmB;GAChF,MAAM,QAAQ,mBAAmB;GACjC,MAAM,YAAY,mBAAmB,UAAU;GAC/C,MAAM,WAAW,mBAAmB,MAAM,MAAM,YAAY,IAAI,GAAG,SAAS;GAC5E,IAAI,OAAO,SAAS,WAKlB,OAAO,EAAE,KAJG,mBACV,MAAM,MAAM,gBAAgB,EAAE,WAAW,SAAS,UAAU,CAAC,GAC7D,SAEc,EAAE,SAAS;GAM7B,OAAO,EAAE,KAJG,mBACV,MAAM,MAAM,WAAW;IAAE,OAAO,OAAO;IAAO,WAAW,SAAS;GAAU,CAAC,GAC7E,SAEc,EAAE,QAAQ;EAC5B;EACA,WAAW,OAAO,QAAQ,UAAU;GAClC,MAAM,YAAY,kBAAkB,EAClC,UAAU,MAAM,OAAO,SAAS,YAAY,WAAW,UAAU,WAAW,KAC9E,CAAC;EACH;CACF,CAAC;AACH"}
@@ -0,0 +1,21 @@
1
+ import { a as AuthenticationSlots, d as OnboardingControllerProps } from "../controllers-DuHYSiw1.mjs";
2
+ import * as React from "react";
3
+ import { ReactNode } from "react";
4
+ import { CapxulTestClient, CapxulTestClock, CapxulTestObservation, CreateCapxulTestClientOptions, SeedTestIdentityInput, createCapxulTestClient } from "@capxul/sdk/testing";
5
+
6
+ //#region src/testing/index.d.ts
7
+ interface CreateCapxulReactTestHarnessOptions extends CreateCapxulTestClientOptions {
8
+ readonly testing?: CapxulTestClient;
9
+ }
10
+ interface CapxulReactTestHarness {
11
+ readonly testing: CapxulTestClient;
12
+ readonly client: CapxulTestClient["client"];
13
+ readonly provider: (children: ReactNode) => React.JSX.Element;
14
+ readonly authentication: (slots: AuthenticationSlots) => React.JSX.Element;
15
+ readonly onboarding: (props: OnboardingControllerProps) => React.JSX.Element;
16
+ }
17
+ /** Build renderer-neutral React test elements over the real SDK testing client. */
18
+ declare function createCapxulReactTestHarness(options?: CreateCapxulReactTestHarnessOptions): CapxulReactTestHarness;
19
+ //#endregion
20
+ export { CapxulReactTestHarness, type CapxulTestClient, type CapxulTestClock, type CapxulTestObservation, CreateCapxulReactTestHarnessOptions, type CreateCapxulTestClientOptions, type SeedTestIdentityInput, createCapxulReactTestHarness, createCapxulTestClient };
21
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/testing/index.tsx"],"mappings":";;;;;;UA6BiB,mCAAA,SAA4C,6BAA6B;EAAA,SAC/E,OAAA,GAAU,gBAAA;AAAA;AAAA,UAGJ,sBAAA;EAAA,SACN,OAAA,EAAS,gBAAA;EAAA,SACT,MAAA,EAAQ,gBAAA;EAAA,SACR,QAAA,GAAW,QAAA,EAAU,SAAA,KAAc,KAAA,CAAM,GAAA,CAAI,OAAA;EAAA,SAC7C,cAAA,GAAiB,KAAA,EAAO,mBAAA,KAAwB,KAAA,CAAM,GAAA,CAAI,OAAA;EAAA,SAC1D,UAAA,GAAa,KAAA,EAAO,yBAAA,KAA8B,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA;;iBAIvD,4BAAA,CACd,OAAA,GAAS,mCAAA,GACR,sBAAsB"}
@@ -0,0 +1,24 @@
1
+ import { n as CapxulOnboardingController, r as CapxulProvider, t as CapxulAuthenticationController } from "../controllers-BU11km12.mjs";
2
+ import "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createCapxulTestClient } from "@capxul/sdk/testing";
5
+ //#region src/testing/index.tsx
6
+ /** Build renderer-neutral React test elements over the real SDK testing client. */
7
+ function createCapxulReactTestHarness(options = {}) {
8
+ const { testing: suppliedTesting, ...clientOptions } = options;
9
+ const testing = suppliedTesting ?? createCapxulTestClient(clientOptions);
10
+ return {
11
+ testing,
12
+ client: testing.client,
13
+ provider: (children) => /* @__PURE__ */ jsx(CapxulProvider, {
14
+ client: testing.client,
15
+ children
16
+ }),
17
+ authentication: (slots) => /* @__PURE__ */ jsx(CapxulAuthenticationController, { slots }),
18
+ onboarding: (props) => /* @__PURE__ */ jsx(CapxulOnboardingController, { ...props })
19
+ };
20
+ }
21
+ //#endregion
22
+ export { createCapxulReactTestHarness, createCapxulTestClient };
23
+
24
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/testing/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport {\n createCapxulTestClient,\n type CapxulTestClient,\n type CapxulTestClock,\n type CapxulTestObservation,\n type CreateCapxulTestClientOptions,\n type SeedTestIdentityInput,\n} from \"@capxul/sdk/testing\";\n\nimport {\n CapxulAuthenticationController,\n CapxulOnboardingController,\n type AuthenticationSlots,\n type OnboardingControllerProps,\n} from \"../controllers\";\nimport { CapxulProvider } from \"../provider\";\n\nexport { createCapxulTestClient };\nexport type {\n CapxulTestClient,\n CapxulTestClock,\n CapxulTestObservation,\n CreateCapxulTestClientOptions,\n SeedTestIdentityInput,\n};\n\nexport interface CreateCapxulReactTestHarnessOptions extends CreateCapxulTestClientOptions {\n readonly testing?: CapxulTestClient;\n}\n\nexport interface CapxulReactTestHarness {\n readonly testing: CapxulTestClient;\n readonly client: CapxulTestClient[\"client\"];\n readonly provider: (children: ReactNode) => React.JSX.Element;\n readonly authentication: (slots: AuthenticationSlots) => React.JSX.Element;\n readonly onboarding: (props: OnboardingControllerProps) => React.JSX.Element;\n}\n\n/** Build renderer-neutral React test elements over the real SDK testing client. */\nexport function createCapxulReactTestHarness(\n options: CreateCapxulReactTestHarnessOptions = {},\n): CapxulReactTestHarness {\n const { testing: suppliedTesting, ...clientOptions } = options;\n const testing = suppliedTesting ?? createCapxulTestClient(clientOptions);\n return {\n testing,\n client: testing.client,\n provider: (children) => <CapxulProvider client={testing.client}>{children}</CapxulProvider>,\n authentication: (slots) => <CapxulAuthenticationController slots={slots} />,\n onboarding: (props) => <CapxulOnboardingController {...props} />,\n };\n}\n"],"mappings":";;;;;;AA0CA,SAAgB,6BACd,UAA+C,CAAC,GACxB;CACxB,MAAM,EAAE,SAAS,iBAAiB,GAAG,kBAAkB;CACvD,MAAM,UAAU,mBAAmB,uBAAuB,aAAa;CACvE,OAAO;EACL;EACA,QAAQ,QAAQ;EAChB,WAAW,aAAa,oBAAC,gBAAD;GAAgB,QAAQ,QAAQ;GAAS;EAAyB,CAAA;EAC1F,iBAAiB,UAAU,oBAAC,gCAAD,EAAuC,MAAQ,CAAA;EAC1E,aAAa,UAAU,oBAAC,4BAAD,EAA4B,GAAI,MAAQ,CAAA;CACjE;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk-react",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.2.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "package.json",
@@ -11,32 +11,32 @@
11
11
  ".": {
12
12
  "types": "./dist/index.d.mts",
13
13
  "import": "./dist/index.mjs"
14
+ },
15
+ "./testing": {
16
+ "types": "./dist/testing/index.d.mts",
17
+ "import": "./dist/testing/index.mjs"
14
18
  }
15
19
  },
16
20
  "publishConfig": {
17
- "access": "public",
18
- "tag": "alpha"
21
+ "access": "public"
19
22
  },
20
23
  "dependencies": {
21
- "@capxul/sdk": "1.0.0-alpha.9"
24
+ "@capxul/sdk": "1.2.0"
22
25
  },
23
26
  "devDependencies": {
24
27
  "@tanstack/react-query": "^5.66.9",
25
- "@testing-library/jest-dom": "^6.9.1",
26
28
  "@testing-library/react": "^16.3.2",
27
29
  "@types/jsdom": "^28.0.3",
28
30
  "@types/react": "^19.2.15",
29
- "@types/react-test-renderer": "^19.1.0",
30
31
  "@vitest/coverage-v8": "4.1.7",
31
32
  "ink": "^7.0.3",
32
33
  "ink-testing-library": "^4.0.0",
33
34
  "jsdom": "^29.1.1",
34
35
  "react": "^19.2.6",
35
36
  "react-dom": "^19.2.6",
36
- "react-test-renderer": "^19.2.6",
37
37
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23",
38
- "@capxul/errors": "0.0.0",
39
- "@capxul/types": "0.1.0-alpha.0"
38
+ "@capxul/types": "0.1.0",
39
+ "@capxul/errors": "0.0.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tanstack/react-query": "^5.66.9",
@@ -49,7 +49,6 @@
49
49
  "check-types": "tsc -p tsconfig.json --noEmit",
50
50
  "lint": "oxlint -c ../../.oxlintrc.json . --deny-warnings",
51
51
  "build": "NODE_OPTIONS=--max-old-space-size=24576 vp pack",
52
- "_vp-tasks-allowed": "vp-allowed: `test` + `test:coverage` are vp tasks in vite.config.ts so vitest self-writes don't bust cache (#205).",
53
- "test:e2e": "vp test run --config vitest.e2e.config.ts"
52
+ "_vp-tasks-allowed": "vp-allowed: `test` + `test:coverage` are vp tasks in vite.config.ts so vitest self-writes don't bust cache (#205)."
54
53
  }
55
54
  }