@capxul/sdk-react 0.2.0-alpha.4 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +263 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +568 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +37 -75
- package/CHANGELOG.md +0 -304
- package/LICENSE +0 -44
- package/README.md +0 -187
- package/dist/index.cjs +0 -1289
- package/dist/index.d.cts +0 -673
- package/dist/index.d.ts +0 -673
- package/dist/index.js +0 -1230
- package/dist/proof/index.cjs +0 -12785
- package/dist/proof/index.d.cts +0 -753
- package/dist/proof/index.d.ts +0 -753
- package/dist/proof/index.js +0 -12758
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/internal/capxul-bootstrap-context.tsx","../src/internal/capxul-client-context.tsx","../src/provider.tsx","../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-invite-member.ts","../src/hooks/use-capxul-remove-member.ts","../src/hooks/use-capxul-assign-role.ts","../src/hooks/use-capxul-org-spend.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/config\";\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/config\";\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","import { Errors } from \"@capxul/config\";\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 type { CapxulResult } from \"@capxul/sdk\";\n\n/** Unwrap a `CapxulResult` for TanStack query/mutation functions — throws into error paths. */\nexport function unwrapCapxulResult<T>(result: CapxulResult<T>): 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 } from \"@capxul/config\";\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 ),\n enabled: client !== null,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\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 ),\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 { useMutation, useQuery, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"account.getLifecycle\").account.getLifecycle(),\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"account.retrySetup\").account.retrySetup(),\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\n return {\n lifecycle,\n isSettingUp: isSettingUpLifecycle(lifecycle),\n error: failedError ?? (query.isError ? query.error : null),\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/config\";\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 unwrapCapxulResult(await requireBootstrappedClient(client, \"accounts.read\").accounts.read()),\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/config\";\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"_internal.accounts.fund\")._internal.accounts.fund(\n amount,\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/config\";\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 unwrapCapxulResult(await requireBootstrappedClient(client, \"auth.signIn\").auth.signIn(input)),\n });\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"auth.verifyOtp\").auth.verifyOtp(input),\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/config\";\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 unwrapCapxulResult(await requireBootstrappedClient(client, \"auth.signOut\").auth.signOut()),\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/config\";\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 return unwrapCapxulResult(\n await requireBootstrappedClient(client, \"subAccounts.list\").subAccounts.list(accountId),\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"subAccounts.create\").subAccounts.create(\n input.accountId,\n { name: input.name },\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"subAccounts.rename\").subAccounts.rename(\n input.subAccountId,\n input.name,\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"subAccounts.delete\").subAccounts.delete(\n input.subAccountId,\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 unwrapCapxulResult(\n await requireBootstrappedClient(client, \"subAccounts.transfer\").subAccounts.transfer({\n from,\n to,\n amount,\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/config\";\nimport type { 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 * 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 = useCapxulClient();\n return useQuery({\n queryKey: capxulKeys.orgs,\n queryFn: async () => unwrapCapxulResult(await client.orgs()),\n enabled: options?.enabled ?? true,\n });\n}\n","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport { Errors, type CapxulError } from \"@capxul/config\";\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());\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/config\";\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());\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/config\";\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());\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/config\";\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(await client.org(orgId).deployRoles());\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/config\";\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());\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/config\";\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) => unwrapCapxulResult(await client.createOrg(input)),\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, type CapxulError } from \"@capxul/config\";\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(await client.org(orgId).invite(input));\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/config\";\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(await client.org(orgId).removeMember(input));\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/config\";\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(await client.org(orgId).assignRole(input));\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/config\";\nimport type { OrgId, OrgSpendInput, OrgSpendResult } 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 * Spend from an Org's scoped sub-account (canon §C2 J3+J4 capstone / §C3, S4,\n * D5) — two-level gated (Level 1 Zodiac cap + Level 2 envelope scope/balance)\n * one-UserOp spend via CapxulPayments. Entity-scoped via the closed-over\n * `orgId` (D13). Binds directly to `capxul.org(orgId).spend(input)`. On success,\n * invalidates the treasury (balance moved). RED until S4 — `mutate` rejects with\n * `Errors.notImplemented(\"org\",\"spend\")`.\n */\nexport type UseCapxulOrgSpendReturn = UseMutationResult<OrgSpendResult, CapxulError, OrgSpendInput>;\n\nexport function useCapxulOrgSpend(orgId: OrgId | undefined): UseCapxulOrgSpendReturn {\n const client = useCapxulClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: OrgSpendInput) => {\n if (orgId === undefined) throw Errors.invalidInput(\"orgId\", \"org is not selected\");\n return unwrapCapxulResult(await client.org(orgId).spend(input));\n },\n onSuccess: async () => {\n if (orgId === undefined) return;\n await queryClient.invalidateQueries({ queryKey: capxulKeys.orgTreasury(orgId) });\n },\n });\n}\n"],"mappings":";;;;;;;AAsBA,MAAM,yBAAyB,cAA2C,IAAI;AAO9E,SAAgB,wBAAwB,EAAE,OAAO,YAA0C;CACzF,OACE,oBAAC,uBAAuB,UAAxB;EAAwC;EAAQ;CAA0C,CAAA;AAE9F;AAEA,SAAgB,YAAkC;CAChD,MAAM,QAAQ,WAAW,sBAAsB;CAC/C,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,gDAAgD;CAElE,OAAO;AACT;;;AClCA,MAAM,iCAAiC,OAAO,gCAAgC;AAE9E,MAAM,sBAAsB,cAE1B,8BAA8B;AAOhC,SAAgB,qBAAqB,EAAE,QAAQ,YAAuC;CACpF,OAAO,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F;AAEA,SAAgB,kBAAgC;CAC9C,MAAM,SAAS,sBAAsB;CACrC,IAAI,WAAW,MACb,MAAM,IAAI,MAAM,mEAAmE;CAErF,OAAO;AACT;;;;;;AAOA,SAAgB,wBAA6C;CAC3D,MAAM,SAAS,WAAW,mBAAmB;CAC7C,IAAI,WAAW,gCACb,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO;AACT;;;ACyBA,SAAS,yBAAsC;CAC7C,OAAO,IAAI,YAAY,EACrB,gBAAgB;EACd,SAAS;GAAE,OAAO;GAAG,WAAW;EAAO;EACvC,WAAW,EAAE,OAAO,EAAE;CACxB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,SAAS,kCAAkC;GAEvE,OAAO,mBAAmB,MAAM,OAAO,IAAI,KAAK,EAAE,WAAW,KAAK,CAAC;EACrE;EACA,WAAW,YAAY;GACrB,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,YAAY,kBAAkB,EAAE,UAAU,WAAW,WAAW,KAAK,EAAE,CAAC;EAChF;CACF,CAAC;AACH;;;AChBA,SAAgB,kBAAkB,OAAmD;CACnF,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CACnC,OAAO,YAAY;EACjB,YAAY,OAAO,UAAyB;GAC1C,IAAI,UAAU,KAAA,GAAW,MAAM,OAAO,aAAa,SAAS,qBAAqB;GACjF,OAAO,mBAAmB,MAAM,OAAO,IAAI,KAAK,EAAE,MAAM,KAAK,CAAC;EAChE;EACA,WAAW,YAAY;GACrB,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,YAAY,kBAAkB,EAAE,UAAU,WAAW,YAAY,KAAK,EAAE,CAAC;EACjF;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,92 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"homepage": "https://capxul.com",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/Xelmar-tech/Capxul.git",
|
|
12
|
-
"directory": "packages/sdk-react"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/Xelmar-tech/Capxul/issues"
|
|
16
|
-
},
|
|
17
|
-
"author": "Capxul (Xelmar Tech Ltd.)",
|
|
18
|
-
"keywords": [
|
|
19
|
-
"capxul",
|
|
20
|
-
"sdk",
|
|
21
|
-
"react",
|
|
22
|
-
"hooks",
|
|
23
|
-
"stablecoin",
|
|
24
|
-
"payments",
|
|
25
|
-
"typescript"
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist",
|
|
6
|
+
"package.json",
|
|
7
|
+
"README.md"
|
|
26
8
|
],
|
|
9
|
+
"type": "module",
|
|
27
10
|
"exports": {
|
|
28
11
|
".": {
|
|
29
|
-
"types": "./dist/index.d.
|
|
30
|
-
"import": "./dist/index.
|
|
31
|
-
"require": "./dist/index.cjs"
|
|
32
|
-
},
|
|
33
|
-
"./proof": {
|
|
34
|
-
"types": "./dist/proof/index.d.ts",
|
|
35
|
-
"import": "./dist/proof/index.js",
|
|
36
|
-
"require": "./dist/proof/index.cjs"
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"import": "./dist/index.mjs"
|
|
37
14
|
}
|
|
38
15
|
},
|
|
39
|
-
"files": [
|
|
40
|
-
"dist",
|
|
41
|
-
"README.md",
|
|
42
|
-
"LICENSE",
|
|
43
|
-
"CHANGELOG.md"
|
|
44
|
-
],
|
|
45
16
|
"publishConfig": {
|
|
46
17
|
"access": "public"
|
|
47
18
|
},
|
|
48
19
|
"dependencies": {
|
|
49
|
-
"@capxul/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"@tanstack/react-query": "^5",
|
|
53
|
-
"@xstate/react": "^5",
|
|
54
|
-
"convex": ">=1.0.0",
|
|
55
|
-
"react": ">=18.2.0 <20",
|
|
56
|
-
"viem": ">=2.0.0"
|
|
20
|
+
"@capxul/config": "0.0.0",
|
|
21
|
+
"@capxul/sdk": "1.0.0-alpha.6",
|
|
22
|
+
"@capxul/types": "0.0.0"
|
|
57
23
|
},
|
|
58
24
|
"devDependencies": {
|
|
59
|
-
"@tanstack/react-query": "^5",
|
|
25
|
+
"@tanstack/react-query": "^5.66.9",
|
|
26
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
60
27
|
"@testing-library/react": "^16.3.2",
|
|
61
|
-
"@
|
|
62
|
-
"@types/
|
|
63
|
-
"@types/react": "19.
|
|
64
|
-
"@
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"vitest": "^4.1.2",
|
|
73
|
-
"@repo/config": "0.0.0",
|
|
74
|
-
"@repo/observability": "0.0.0",
|
|
75
|
-
"@repo/platform-kernel": "0.0.0",
|
|
76
|
-
"@repo/typescript-config": "0.0.0"
|
|
28
|
+
"@types/jsdom": "^28.0.3",
|
|
29
|
+
"@types/react": "^19.2.15",
|
|
30
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
31
|
+
"@vitest/coverage-v8": "4.1.7",
|
|
32
|
+
"ink": "^7.0.3",
|
|
33
|
+
"ink-testing-library": "^4.0.0",
|
|
34
|
+
"jsdom": "^29.1.1",
|
|
35
|
+
"react": "^19.2.6",
|
|
36
|
+
"react-dom": "^19.2.6",
|
|
37
|
+
"react-test-renderer": "^19.2.6",
|
|
38
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23"
|
|
77
39
|
},
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
"proof:plan": "tsx ops/proof/plan-cli.ts",
|
|
85
|
-
"proof:react-headless": "vitest run ops/proof/react-headless.test.tsx",
|
|
86
|
-
"test": "vitest run",
|
|
87
|
-
"test:types": "vitest run --typecheck"
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@tanstack/react-query": "^5.66.9",
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.12.0"
|
|
88
46
|
},
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
47
|
+
"scripts": {
|
|
48
|
+
"check-types": "tsc -p tsconfig.json --noEmit",
|
|
49
|
+
"lint": "oxlint -c ../../.oxlintrc.json . --deny-warnings",
|
|
50
|
+
"build": "vp pack",
|
|
51
|
+
"_vp-tasks-allowed": "vp-allowed: `test` + `test:coverage` are vp tasks in vite.config.ts so vitest self-writes don't bust cache (#205).",
|
|
52
|
+
"test:e2e": "vp test run --config vitest.e2e.config.ts"
|
|
53
|
+
}
|
|
92
54
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
# @capxul/sdk-react
|
|
2
|
-
|
|
3
|
-
## 0.2.0-alpha.4
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- b6c1f94: Complete the auth dogfooding epic around the canonical auth surface.
|
|
8
|
-
|
|
9
|
-
The SDK now carries the guarded OTP proof path, bootstrap continuation states,
|
|
10
|
-
canonical auth service behavior, and final funnel proof support needed for
|
|
11
|
-
first-run auth dogfooding. The React SDK aligns its auth hooks and provider
|
|
12
|
-
state with that canonical flow, including signout cleanup, bootstrap-required
|
|
13
|
-
continuations, and funnel telemetry integration.
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- 50d3c55: Bundle the internal Safe derivation package into the SDK artifact instead of
|
|
18
|
-
publishing it as a runtime dependency, and add a packaging guard that fails when
|
|
19
|
-
publishable packages leak private `@repo/*` runtime dependencies.
|
|
20
|
-
- Updated dependencies [b6c1f94]
|
|
21
|
-
- Updated dependencies [50d3c55]
|
|
22
|
-
- @capxul/sdk@0.2.0-alpha.4
|
|
23
|
-
|
|
24
|
-
## 0.2.0-alpha.3
|
|
25
|
-
|
|
26
|
-
### Patch Changes
|
|
27
|
-
|
|
28
|
-
- Updated dependencies [5b99a9b]
|
|
29
|
-
- @capxul/sdk@0.2.0-alpha.3
|
|
30
|
-
|
|
31
|
-
## 0.2.0-alpha.2
|
|
32
|
-
|
|
33
|
-
### Minor Changes
|
|
34
|
-
|
|
35
|
-
- 995383f: Epic 660: Unified auth surface
|
|
36
|
-
- Introduces AuthService promise-based auth API replacing the imperative capxul.auth.\* tuple interface
|
|
37
|
-
- Adds SignerProvisioner for deterministic Safe v1.4.1 address derivation from viem signers
|
|
38
|
-
- Adds useAuth() React hook with reactive state + promise-based methods
|
|
39
|
-
- Deprecates useAuthFlow and useAuthBootstrapFlow in favor of useAuth()
|
|
40
|
-
- Migrates reference CLI auth commands (send-otp, verify-otp, signout) to useAuth()
|
|
41
|
-
- Migrates test surfaces: walkthroughs, type tests, e2e harness signup, lazy-dx provider
|
|
42
|
-
- Adds @repo/safe-derive workspace package for Safe address derivation utilities
|
|
43
|
-
- Aligns CapxulConfig.data to \_data with internal SDK transport ownership (Epic 652)
|
|
44
|
-
- Pins esbuild to 0.25.12 to fix binary-version skew in fresh worktrees
|
|
45
|
-
|
|
46
|
-
- 2ef4ee3: Reshape the organizations members surface around a single Membership entity
|
|
47
|
-
with a status lifecycle (`pending | active | revoked | expired`).
|
|
48
|
-
- Replaces the prior invitation/membership split (which produced a phantom
|
|
49
|
-
`MemberInvitation` type that never compiled) with a single `Member` type
|
|
50
|
-
exposing `status`, `email`, `acceptedAt`, `expiresAt`, and `resentCount`.
|
|
51
|
-
- New methods on `organizations.members.*`: `accept(token)`, `revoke(memberId)`,
|
|
52
|
-
`resend(memberId)`. `invite()` now returns a `MemberInviteResponse`
|
|
53
|
-
containing the raw invite token (returned once).
|
|
54
|
-
- Auto-accepts pending invitations on first sign-in for the matching email
|
|
55
|
-
via a BetterAuth post-signup hook.
|
|
56
|
-
- Nightly Convex cron expires overdue pending invitations.
|
|
57
|
-
|
|
58
|
-
Public type changes:
|
|
59
|
-
- Removed: `MemberInvitation` (was never exported; type didn't compile).
|
|
60
|
-
- Added: `MembershipStatus`, `MemberInviteResponse`.
|
|
61
|
-
- Updated: `Member` shape — see SDK reference for the full delta.
|
|
62
|
-
|
|
63
|
-
React hooks:
|
|
64
|
-
- New: `useAcceptInvitation`, `useRevokeMember`, `useResendInvitation`.
|
|
65
|
-
- Updated: `useInviteMember` returns `MemberInviteResponse` (was returning a
|
|
66
|
-
type that didn't exist).
|
|
67
|
-
|
|
68
|
-
Reference CLI:
|
|
69
|
-
- New commands: `org members invite`, `org members list`, `org members retrieve`,
|
|
70
|
-
`org members accept`, `org members updateRole`, `org members revoke`,
|
|
71
|
-
`org members remove`, `org members resend`.
|
|
72
|
-
|
|
73
|
-
- c7146bf: **Transport ownership (#656):** The SDK now owns construction of the
|
|
74
|
-
authenticated `ConvexHttpClient`. Consumers no longer wire `data` manually
|
|
75
|
-
or provide `auth.createDataClient`. After `verifyOtp` exchanges a Convex
|
|
76
|
-
JWT, the SDK builds the default data client internally via
|
|
77
|
-
`createDefaultDataClient` and stores it on `config._data`.
|
|
78
|
-
- `CapxulConfig.data` renamed to `_data` (internal test seam).
|
|
79
|
-
- `CapxulAuthConfig.createDataClient` removed from public types.
|
|
80
|
-
- `convex` moved from `peerDependencies` to `dependencies`.
|
|
81
|
-
|
|
82
|
-
### Patch Changes
|
|
83
|
-
|
|
84
|
-
- d252aa7: Widen the published React peer dependency to `>=18.2.0 <20` so React 18 consumers, including the Ink reference proof app, can install the alpha SDK without peer conflicts.
|
|
85
|
-
- Updated dependencies [995383f]
|
|
86
|
-
- Updated dependencies [2ef4ee3]
|
|
87
|
-
- Updated dependencies [c7146bf]
|
|
88
|
-
- @capxul/sdk@0.2.0-alpha.2
|
|
89
|
-
|
|
90
|
-
## 0.2.0-alpha.1
|
|
91
|
-
|
|
92
|
-
### Minor Changes
|
|
93
|
-
|
|
94
|
-
- **Transport ownership (#656):** Remove the `auth.createDataClient`
|
|
95
|
-
callback from `CapxulProvider`. The React provider now passes its
|
|
96
|
-
singleton data client via `CapxulConfig._data` and lets the SDK own
|
|
97
|
-
runtime construction after OTP verification.
|
|
98
|
-
|
|
99
|
-
### Patch Changes
|
|
100
|
-
|
|
101
|
-
- Updated dependencies
|
|
102
|
-
- @capxul/sdk@0.2.0-alpha.1
|
|
103
|
-
|
|
104
|
-
## 0.1.0-alpha.12
|
|
105
|
-
|
|
106
|
-
### Minor Changes
|
|
107
|
-
|
|
108
|
-
- Publish the post-alpha.11 SDK and React SDK surface: funds v1 sub-account
|
|
109
|
-
runtime coverage, React hook wiring, payments list support, and the latest
|
|
110
|
-
generated Convex API snapshots used by current alpha consumers.
|
|
111
|
-
|
|
112
|
-
Note: alpha.10 and alpha.11 were intermediate runner artifacts from the
|
|
113
|
-
prior release pipeline (manual `package.json` bumps that were never folded
|
|
114
|
-
back into the repo). alpha.12 reconciles `package.json`, the changesets
|
|
115
|
-
state, and npm to a single consistent version.
|
|
116
|
-
|
|
117
|
-
### Patch Changes
|
|
118
|
-
|
|
119
|
-
- Updated dependencies
|
|
120
|
-
- @capxul/sdk@0.1.0-alpha.12
|
|
121
|
-
|
|
122
|
-
## 0.1.0-alpha.9
|
|
123
|
-
|
|
124
|
-
### Minor Changes
|
|
125
|
-
|
|
126
|
-
- Add the canonical auth bootstrap flow.
|
|
127
|
-
|
|
128
|
-
`verifyOtp()` now resolves a verified email session into either an
|
|
129
|
-
`existing_member` identity or a `bootstrap_required` continuation. New and
|
|
130
|
-
incomplete members continue through `completeBootstrap()`, which validates a
|
|
131
|
-
server-issued bootstrap token, claims the username, provisions the account/Safe
|
|
132
|
-
through the backend bootstrap path, and returns the authenticated product
|
|
133
|
-
identity. The React SDK adds `useAuthBootstrapFlow()` as the typed first-run
|
|
134
|
-
flow wrapper.
|
|
135
|
-
|
|
136
|
-
### Patch Changes
|
|
137
|
-
|
|
138
|
-
- Updated dependencies
|
|
139
|
-
- @capxul/sdk@0.1.0-alpha.9
|
|
140
|
-
|
|
141
|
-
## 0.1.0-alpha.8
|
|
142
|
-
|
|
143
|
-
### Minor Changes
|
|
144
|
-
|
|
145
|
-
- 3af04a9: Public `<CapxulProvider>` now wires authenticated Convex reads end-to-end (#487, closes #484).
|
|
146
|
-
|
|
147
|
-
The `build-time-urls` arm of `BrowserCapxulConfig` now causes the provider to internally instantiate a `ConvexReactClient`, wrap it as a `CapxulDataClient`, and feed it as `config.data` into `createCapxulClient`. The existing `auth.createDataClient` callback is wired to the same singleton so a `verifyOtp` call refreshes the data client's auth header without churning the WebSocket. The provider also wraps `client.auth.signOut` so the data client survives sign-out — post-signout reads return typed backend `NOT_AUTHENTICATED` instead of the SDK's `NOT_IMPLEMENTED` stub (closes the #474 friction as a side-effect).
|
|
148
|
-
|
|
149
|
-
New optional `sessionStore?: AuthSessionStore` prop lets browser apps opt into `localStorage`-backed persistence and Node consumers (CLIs, e2e harnesses) opt into file-backed persistence. Defaults to in-memory.
|
|
150
|
-
|
|
151
|
-
This closes the architectural gap that made the React hook surface (`useMe`, `useAccount`, `useSafe`, ...) impossible to exercise end-to-end through the public provider — previously `config.data` was never populated, so every authenticated read short-circuited to `NOT_IMPLEMENTED`. The Ink reference CLI (`apps/reference-cli/`) is rebuilt on top of the public provider as proof: 17/17 agent-driver assertions pass against live alpha-3 Convex, including a dev-OTP authenticated round-trip that mints a real session via `AUTH_DEV_OTP=00000` and exercises three distinct hook end-states (`NOT_AUTHENTICATED`, `PROFILE_NOT_FOUND`, post-signout `NOT_AUTHENTICATED`).
|
|
152
|
-
|
|
153
|
-
- 57203a4: Withdrawals v1 W2 (#465) — public surface tightening + org-scope create
|
|
154
|
-
- `WithdrawalsCreateInput.destination` no longer accepts `kind`. The
|
|
155
|
-
backend now resolves the `external_account` row by FK and infers
|
|
156
|
-
the kind + rail server-side. Anything that doesn't route to
|
|
157
|
-
`chain_wallet` (or is chain_wallet but non-EVM in slice 1) returns
|
|
158
|
-
`VERIFICATION_REQUIRED` with `details.rail` + `details.currentKind`.
|
|
159
|
-
- `organizations.withdrawals.create` is now a real mutation (no
|
|
160
|
-
longer a `NOT_IMPLEMENTED` stub). Returns the `processing` row
|
|
161
|
-
only — Safe + Zodiac submission orchestration ships in W3+.
|
|
162
|
-
- `Errors.verificationRequired({ rail, currentKind })` factory
|
|
163
|
-
added; the `VERIFICATION_REQUIRED` code now broadens to cover
|
|
164
|
-
both KYC tier gates and unsupported withdrawal rails.
|
|
165
|
-
|
|
166
|
-
**Migration:** Remove `destination.kind` from any
|
|
167
|
-
`capxul.withdrawals.create({ destination: { kind, externalAccountId } })`
|
|
168
|
-
call sites. Pass only `externalAccountId`.
|
|
169
|
-
|
|
170
|
-
### Patch Changes
|
|
171
|
-
|
|
172
|
-
- Updated dependencies [57203a4]
|
|
173
|
-
- @capxul/sdk@0.1.0-alpha.8
|
|
174
|
-
|
|
175
|
-
## 0.1.0-alpha.4
|
|
176
|
-
|
|
177
|
-
### Minor Changes
|
|
178
|
-
|
|
179
|
-
- Post-alpha hardening — WAVE 1 + WAVE 2 cumulative
|
|
180
|
-
|
|
181
|
-
**WAVE 1 (merged 2026-05-03 12:44Z):**
|
|
182
|
-
- S2 story 1: wire onboarding readback hooks (#469) — `me.update`, `accounts.retrieve`, `accounts.update`, `useAccount`, `useSafe`
|
|
183
|
-
- S3 phase 1: Ink reference CLI scaffold + `auth+me` end-to-end against live alpha-3 Convex (#470). Stickiness gate (D3) fired.
|
|
184
|
-
- S5: split `CapxulProvider` into public single-input `BrowserCapxulConfig` + test-only `CapxulTestProvider` from `@capxul/sdk-react/proof` (#473). Q1 lock honored. 7 type-level provider-shape guards including `@ts-expect-error` against test-provider leaking to public barrel.
|
|
185
|
-
|
|
186
|
-
**WAVE 2 (merged 2026-05-03 12:54-13:16Z):**
|
|
187
|
-
- S3 phase 2: per-domain CLI commands closing #458 (#476) — `account retrieve/update`, `safe retrieve`, `payment retrieve`, `withdrawal retrieve/list`. 12/12 agent-driver tests pass.
|
|
188
|
-
- S2 story 2: `capxul.tokenTransfers.*` non-canonical SDK namespace (#479) — Option A per #477 (canon-aligned `transfers.*` shape deferred to alpha.5+ pending backend canon work). New `useTokenTransfers` + `useTokenTransfer` hooks; new `getByTxLogIndex` backend query. Hook proof matrix length unchanged at 41 (non-canonical hooks deliberately excluded).
|
|
189
|
-
|
|
190
|
-
**S1 (#456) closed no-op** — alpha publish infrastructure (tsup, lazy-DX, transport state machine, npm metadata, READMEs, CHANGELOG, changesets, OIDC release workflow) physically merged into `api-first` via PRs #449-#452 earlier the same day; the slice merge produced 0 file changes per clean-room probe.
|
|
191
|
-
|
|
192
|
-
**Friction issues filed for alpha.4+ polish:**
|
|
193
|
-
- #474 — `me.get` returns `NOT_IMPLEMENTED` when `config.data` is undefined; should be `NOT_AUTHENTICATED`.
|
|
194
|
-
- #475 — `@capxul/sdk/headless` slim entry point excludes xstate flow machines + brand constructors (1.6 MB → much smaller).
|
|
195
|
-
- #477 / #478 — `transfers.*` / `balanceLedger.*` / `treasury` canon-shape alignment with indexer feed.
|
|
196
|
-
- #471 — Vercel-capxul-web preview-deploy systemic failure on api-first base (separate from epic).
|
|
197
|
-
|
|
198
|
-
### Patch Changes
|
|
199
|
-
|
|
200
|
-
- Updated dependencies
|
|
201
|
-
- @capxul/sdk@0.1.0-alpha.4
|
|
202
|
-
|
|
203
|
-
## 0.1.0-alpha.3
|
|
204
|
-
|
|
205
|
-
### Patch Changes
|
|
206
|
-
|
|
207
|
-
- Re-export `tryCatch` from `@capxul/sdk`.
|
|
208
|
-
|
|
209
|
-
`tryCatch` is referenced in `packages/sdk/README.md` (live on npm at
|
|
210
|
-
`0.1.0-alpha.2`) and in `.claude/rules/sdk.md` as the canonical
|
|
211
|
-
async-error helper for SDK operations:
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
import { tryCatch } from "@capxul/sdk";
|
|
215
|
-
|
|
216
|
-
const [err, payment] = await tryCatch(capxul.payments.create({ ... }));
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
The helper lives at `@repo/observability/try-catch.ts` and is bundled
|
|
220
|
-
into the SDK dist via tsup `noExternal`, but it was never re-exported
|
|
221
|
-
from `packages/sdk/src/index.ts`. Consumers following the README example
|
|
222
|
-
hit `Module '"@capxul/sdk"' has no exported member 'tryCatch'.` at
|
|
223
|
-
import time.
|
|
224
|
-
|
|
225
|
-
Caught during alpha.2 spike-install verification (REVIEW.html, "What's
|
|
226
|
-
not proven" row 6). One-line public-export addition; no runtime change.
|
|
227
|
-
|
|
228
|
-
- Updated dependencies
|
|
229
|
-
- @capxul/sdk@0.1.0-alpha.3
|
|
230
|
-
|
|
231
|
-
## 0.1.0-alpha.2
|
|
232
|
-
|
|
233
|
-
### Patch Changes
|
|
234
|
-
|
|
235
|
-
- Add `convex` as a peer dependency.
|
|
236
|
-
|
|
237
|
-
`@capxul/sdk`'s bundled `_generated/api` snapshot calls
|
|
238
|
-
`anyApi` / `componentsGeneric` from `convex/server` at runtime — they
|
|
239
|
-
are not just types — and tsup correctly externalizes `convex` /
|
|
240
|
-
`convex/server` / `convex/react` so the consumer's own Convex install
|
|
241
|
-
is reused. The peer was missing from the published manifest, so
|
|
242
|
-
`require('@capxul/sdk')` failed with `Cannot find module 'convex/server'`
|
|
243
|
-
in any spike that hadn't already installed `convex`.
|
|
244
|
-
|
|
245
|
-
`@capxul/sdk-react` mirrors the peer because its bundle re-exports
|
|
246
|
-
flow-machine constructors from `@capxul/sdk` and may transitively
|
|
247
|
-
pull in the same module.
|
|
248
|
-
|
|
249
|
-
Caught during alpha.1 spike-install verification.
|
|
250
|
-
|
|
251
|
-
- Updated dependencies
|
|
252
|
-
- @capxul/sdk@0.1.0-alpha.2
|
|
253
|
-
|
|
254
|
-
## 0.1.0-alpha.1
|
|
255
|
-
|
|
256
|
-
### Patch Changes
|
|
257
|
-
|
|
258
|
-
- Move workspace `@repo/*` packages from `dependencies` to
|
|
259
|
-
`devDependencies` so the published `package.json` doesn't list them
|
|
260
|
-
as runtime deps. The tsup pipeline bundles every `@repo/*` import
|
|
261
|
-
inline (`noExternal`), so the published code has zero references to
|
|
262
|
-
those packages — but until now the published `package.json` still
|
|
263
|
-
declared them, and `npm install @capxul/sdk@0.1.0-alpha.0` failed
|
|
264
|
-
trying to resolve `@repo/api-contract@0.0.0` etc. on the public
|
|
265
|
-
registry.
|
|
266
|
-
|
|
267
|
-
`@capxul/sdk-react` keeps `@capxul/sdk` as a runtime dep — that one
|
|
268
|
-
is published.
|
|
269
|
-
|
|
270
|
-
No public surface changes. Pure publish-metadata correction caught
|
|
271
|
-
during alpha.0 spike-install verification.
|
|
272
|
-
|
|
273
|
-
- Updated dependencies
|
|
274
|
-
- @capxul/sdk@0.1.0-alpha.1
|
|
275
|
-
|
|
276
|
-
Changelog managed by [changesets](https://github.com/changesets/changesets) —
|
|
277
|
-
see `.changeset/README.md` for the operator workflow.
|
|
278
|
-
|
|
279
|
-
## 0.1.0-alpha.0
|
|
280
|
-
|
|
281
|
-
### Minor Changes
|
|
282
|
-
|
|
283
|
-
- Initial alpha publish.
|
|
284
|
-
|
|
285
|
-
`@capxul/sdk` ships the headless TypeScript client for Capxul's
|
|
286
|
-
`/v1/*` HTTP contract — auth, me, accounts, payments, organizations,
|
|
287
|
-
withdrawals, documents, and three XState v5 flow machines. Errors
|
|
288
|
-
are typed `CapxulError` instances with narrowed `code` unions per
|
|
289
|
-
method; `tryCatch` returns the canonical `[error, data]` tuple.
|
|
290
|
-
|
|
291
|
-
`@capxul/sdk-react` ships the React provider and hooks. The lazy-DX
|
|
292
|
-
`<CapxulProvider publishableKey="cap_pk_…">` mounts synchronously
|
|
293
|
-
and bootstraps runtime URLs through `/v1/client/bootstrap` on the
|
|
294
|
-
first SDK call. `useCapxulStatus()` exposes the canonical 5-state
|
|
295
|
-
transport lifecycle through `useSyncExternalStore`. Read hooks
|
|
296
|
-
return the canonical `QueryResult<T>` three-state discriminated
|
|
297
|
-
union (loading / data / error) — never throws on "still loading".
|
|
298
|
-
|
|
299
|
-
See each package's `README.md` for the public surface.
|
|
300
|
-
|
|
301
|
-
### Patch Changes
|
|
302
|
-
|
|
303
|
-
- Updated dependencies
|
|
304
|
-
- @capxul/sdk@0.1.0-alpha.0
|
package/LICENSE
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2026 Xelmar Tech Ltd. ("Capxul"). All rights reserved.
|
|
2
|
-
|
|
3
|
-
This software ("@capxul/sdk-react", the "Software") is proprietary to
|
|
4
|
-
Capxul. The Software is licensed, not sold, and is made available
|
|
5
|
-
solely to registered Capxul customers under the Capxul Terms of
|
|
6
|
-
Service or a separate written commercial agreement between Capxul and
|
|
7
|
-
the licensee.
|
|
8
|
-
|
|
9
|
-
Two-layer trust
|
|
10
|
-
---------------
|
|
11
|
-
Capxul's value-bearing on-chain logic — Safe v1.4.1, ERC-4337 modules,
|
|
12
|
-
and any contract that custodies, transfers, or signs over user funds —
|
|
13
|
-
is open source under permissive licenses and is published in a
|
|
14
|
-
separate, auditable repository. See:
|
|
15
|
-
|
|
16
|
-
https://github.com/Xelmar-tech/Capxul
|
|
17
|
-
|
|
18
|
-
The orchestration layer in this package — React provider, hooks,
|
|
19
|
-
state-machine wiring, integration glue, and any code that translates
|
|
20
|
-
customer intent into transactions or routes data between subsystems —
|
|
21
|
-
is the proprietary product of Capxul and is governed by this license.
|
|
22
|
-
|
|
23
|
-
Customers of the Capxul platform may use this Software solely:
|
|
24
|
-
(a) to access Capxul's hosted services they have contracted for,
|
|
25
|
-
(b) within the scope of their active subscription or trial, and
|
|
26
|
-
(c) in accordance with the Capxul Terms of Service.
|
|
27
|
-
|
|
28
|
-
Without limiting the foregoing, you may NOT:
|
|
29
|
-
(i) redistribute, sublicense, sell, lease, or rent the Software,
|
|
30
|
-
(ii) reverse-engineer, decompile, or disassemble the Software,
|
|
31
|
-
except to the limited extent applicable mandatory law
|
|
32
|
-
permits, and
|
|
33
|
-
(iii) remove or alter copyright, trademark, or other proprietary
|
|
34
|
-
notices in the Software.
|
|
35
|
-
|
|
36
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
37
|
-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
|
|
38
|
-
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT
|
|
39
|
-
SHALL CAPXUL OR ITS AFFILIATES BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
40
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE,
|
|
41
|
-
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
42
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
43
|
-
|
|
44
|
-
Contact: legal@capxul.com
|