@capxul/sdk-react 0.2.0-alpha.5 → 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 +36 -32
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +96 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { QueryClient, UseMutationResult, UseQueryResult } from "@tanstack/react-query";
|
|
3
|
-
import { Account,
|
|
3
|
+
import { Account, AccountLifecycle, AccountRequirement, AssignRoleInput, CapxulClient, CapxulSigner, CreateOrgInput, InviteMemberInput, MemberView, OrgId, OrgSpendInput, OrgSpendResult, OrgView, Profile, RemoveMemberInput, RoleView, Session, TransferInput, TransferResult } from "@capxul/sdk";
|
|
4
4
|
import { CapxulError } from "@capxul/config";
|
|
5
5
|
import { Account as Account$1, AccountId, Money, SubAccount, SubAccountId } from "@capxul/types";
|
|
6
6
|
|
|
7
7
|
//#region src/provider.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly client?:
|
|
16
|
-
/** Init-time account readiness target. Default `"none"`. */
|
|
8
|
+
type CapxulProviderSharedProps = {
|
|
9
|
+
/** Bring your own QueryClient; otherwise the provider creates one. */readonly queryClient?: QueryClient;
|
|
10
|
+
readonly children: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/** Browser / app path — the provider bootstraps the client from a publishable key. */
|
|
13
|
+
type CapxulProviderPublishableKeyProps = CapxulProviderSharedProps & {
|
|
14
|
+
readonly publishableKey: string;
|
|
15
|
+
readonly client?: never; /** Init-time account readiness target. Default `"none"`. */
|
|
17
16
|
readonly requirement?: AccountRequirement;
|
|
18
|
-
/** Optional app origin forwarded to the SDK bootstrap request. */
|
|
19
|
-
readonly origin?: ProductionAdapterInput["origin"];
|
|
20
|
-
/** Optional bootstrap host override for live/dev environments. */
|
|
21
|
-
readonly bootstrapBaseUrl?: ProductionAdapterInput["bootstrapBaseUrl"];
|
|
22
|
-
/** Optional auth persistence adapter; Node CLIs pass their filesystem cache. */
|
|
23
|
-
readonly authCache?: ProductionAdapterInput["authCache"];
|
|
24
|
-
/** Optional method invocation timeout in milliseconds. */
|
|
25
|
-
readonly invokeTimeoutMs?: ProductionAdapterInput["invokeTimeoutMs"];
|
|
26
17
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
18
|
+
* Optional consumer-held signer for the deploy lane. Omitted in browser apps
|
|
19
|
+
* with `requirement: "deployed"` — the SDK wires Openfort from bootstrap.
|
|
29
20
|
*/
|
|
30
21
|
readonly signer?: CapxulSigner;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Node / server / test path — a pre-built client is supplied; lifecycle stays
|
|
25
|
+
* with the caller. Mutually exclusive with `publishableKey`.
|
|
26
|
+
*/
|
|
27
|
+
type CapxulProviderInjectedClientProps = CapxulProviderSharedProps & {
|
|
28
|
+
readonly client: CapxulClient;
|
|
29
|
+
readonly publishableKey?: never;
|
|
30
|
+
readonly requirement?: never;
|
|
31
|
+
readonly signer?: never;
|
|
32
|
+
};
|
|
33
|
+
type CapxulProviderProps = CapxulProviderPublishableKeyProps | CapxulProviderInjectedClientProps;
|
|
35
34
|
declare function CapxulProvider(props: CapxulProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
36
35
|
//#endregion
|
|
37
36
|
//#region src/internal/capxul-bootstrap-context.d.ts
|
|
@@ -51,9 +50,18 @@ declare function useCapxulSession(): UseCapxulSessionReturn;
|
|
|
51
50
|
type UseCapxulProfileReturn = UseQueryResult<Profile | null, CapxulError>;
|
|
52
51
|
declare function useCapxulProfile(): UseCapxulProfileReturn;
|
|
53
52
|
//#endregion
|
|
54
|
-
//#region src/hooks/use-capxul-account.d.ts
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
//#region src/hooks/use-capxul-account-lifecycle.d.ts
|
|
54
|
+
interface UseCapxulAccountLifecycleReturn {
|
|
55
|
+
readonly lifecycle: AccountLifecycle;
|
|
56
|
+
readonly isSettingUp: boolean;
|
|
57
|
+
readonly error: CapxulError | null;
|
|
58
|
+
readonly isLoading: boolean;
|
|
59
|
+
readonly isFetching: boolean;
|
|
60
|
+
readonly isError: boolean;
|
|
61
|
+
readonly retry: UseMutationResult<AccountLifecycle, CapxulError, void>["mutateAsync"];
|
|
62
|
+
readonly isRetrying: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare function useCapxulAccountLifecycle(): UseCapxulAccountLifecycleReturn;
|
|
57
65
|
//#endregion
|
|
58
66
|
//#region src/hooks/use-capxul-account-balance.d.ts
|
|
59
67
|
type UseCapxulAccountBalanceReturn = UseQueryResult<Account, CapxulError>;
|
|
@@ -91,10 +99,6 @@ declare function useCapxulVerifyOtp(): UseCapxulVerifyOtpReturn;
|
|
|
91
99
|
type UseCapxulSignOutReturn = UseMutationResult<void, CapxulError, void>;
|
|
92
100
|
declare function useCapxulSignOut(): UseCapxulSignOutReturn;
|
|
93
101
|
//#endregion
|
|
94
|
-
//#region src/hooks/use-capxul-ensure-ready.d.ts
|
|
95
|
-
type UseCapxulEnsureReadyReturn = UseMutationResult<AccountStatus, CapxulError, void>;
|
|
96
|
-
declare function useCapxulEnsureReady(): UseCapxulEnsureReadyReturn;
|
|
97
|
-
//#endregion
|
|
98
102
|
//#region src/hooks/use-capxul-sub-accounts.d.ts
|
|
99
103
|
type UseCapxulSubAccountsListOptions = {
|
|
100
104
|
readonly enabled?: boolean;
|
|
@@ -255,5 +259,5 @@ declare function useCapxulAssignRole(orgId: OrgId | undefined): UseCapxulAssignR
|
|
|
255
259
|
type UseCapxulOrgSpendReturn = UseMutationResult<OrgSpendResult, CapxulError, OrgSpendInput>;
|
|
256
260
|
declare function useCapxulOrgSpend(orgId: OrgId | undefined): UseCapxulOrgSpendReturn;
|
|
257
261
|
//#endregion
|
|
258
|
-
export { type CapxulBootstrapState, type CapxulBootstrapStatus, CapxulProvider, type CapxulProviderProps, type SignInInput, type SignInSuccess, type UseCapxulAccountBalanceOptions, type UseCapxulAccountBalanceReturn, type UseCapxulAccountFundReturn, type
|
|
262
|
+
export { type CapxulBootstrapState, type CapxulBootstrapStatus, CapxulProvider, type CapxulProviderProps, type SignInInput, type SignInSuccess, type UseCapxulAccountBalanceOptions, type UseCapxulAccountBalanceReturn, type UseCapxulAccountFundReturn, type UseCapxulAccountLifecycleReturn, type UseCapxulAssignRoleReturn, type UseCapxulCreateOrgReturn, type UseCapxulInviteMemberReturn, type UseCapxulOrgDeployRolesReturn, type UseCapxulOrgMembersOptions, type UseCapxulOrgMembersReturn, type UseCapxulOrgOptions, type UseCapxulOrgReturn, type UseCapxulOrgRolesOptions, type UseCapxulOrgRolesReturn, type UseCapxulOrgSpendReturn, type UseCapxulOrgTreasuryOptions, type UseCapxulOrgTreasuryReturn, type UseCapxulOrgsReturn, type UseCapxulProfileReturn, type UseCapxulRemoveMemberReturn, type UseCapxulSessionReturn, type UseCapxulSignInReturn, type UseCapxulSignOutReturn, type UseCapxulSubAccountCreateReturn, type UseCapxulSubAccountDeleteReturn, type UseCapxulSubAccountRenameReturn, type UseCapxulSubAccountsListOptions, type UseCapxulSubAccountsListReturn, type UseCapxulTransferReturn, type UseCapxulVerifyOtpReturn, type VerifyOtpInput, useCapxul, useCapxulAccountBalance, useCapxulAccountFund, useCapxulAccountLifecycle, useCapxulAssignRole, useCapxulCreateOrg, useCapxulInviteMember, useCapxulOrg, useCapxulOrgDeployRoles, useCapxulOrgMembers, useCapxulOrgRoles, useCapxulOrgSpend, useCapxulOrgTreasury, useCapxulOrgs, useCapxulProfile, useCapxulRemoveMember, useCapxulSession, useCapxulSignIn, useCapxulSignOut, useCapxulSubAccountCreate, useCapxulSubAccountDelete, useCapxulSubAccountRename, useCapxulSubAccountsList, useCapxulTransfer, useCapxulVerifyOtp };
|
|
259
263
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/provider.tsx","../src/internal/capxul-bootstrap-context.tsx","../src/hooks/use-capxul-session.ts","../src/hooks/use-capxul-profile.ts","../src/hooks/use-capxul-account.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-
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/provider.tsx","../src/internal/capxul-bootstrap-context.tsx","../src/hooks/use-capxul-session.ts","../src/hooks/use-capxul-profile.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"],"mappings":";;;;;;;KAgCK,yBAAA;iFAEM,WAAA,GAAc,WAAA;EAAA,SACd,QAAA,EAAU,SAAS;AAAA;;KAIzB,iCAAA,GAAoC,yBAAA;EAAA,SAC9B,cAAA;EAAA,SACA,MAAA,UAPc;EAAA,SASd,WAAA,GAAc,kBAAA;EARJ;;AAAS;AAAA;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iBAAA;AAAA,iBAGc,qBAAA,CAAsB,KAAA,EAAO,KAAA,eAAoB,2BAA2B;;;;;;;AlBFV;;;;KmBFtE,2BAAA,GAA8B,iBAAA,OAAwB,WAAA,EAAa,iBAAA;AAAA,iBAE/D,qBAAA,CAAsB,KAAA,EAAO,KAAA,eAAoB,2BAA2B;;;;;;;AnBAV;;;;;KoBDtE,yBAAA,GAA4B,iBAAA,CAAkB,UAAA,EAAY,WAAA,EAAa,eAAA;AAAA,iBAEnE,mBAAA,CAAoB,KAAA,EAAO,KAAA,eAAoB,yBAAyB;;;;;;;ApBDN;;;;KqBFtE,uBAAA,GAA0B,iBAAA,CAAkB,cAAA,EAAgB,WAAA,EAAa,aAAA;AAAA,iBAErE,iBAAA,CAAkB,KAAA,EAAO,KAAA,eAAoB,uBAAuB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { createCapxulClient } from "@capxul/sdk";
|
|
4
|
+
import { createCapxulClient, isSettingUpLifecycle } from "@capxul/sdk";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { Errors } from "@capxul/config";
|
|
7
7
|
//#region src/internal/capxul-bootstrap-context.tsx
|
|
@@ -19,7 +19,8 @@ function useCapxul() {
|
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/internal/capxul-client-context.tsx
|
|
22
|
-
const
|
|
22
|
+
const MISSING_CAPXUL_CLIENT_PROVIDER = Symbol("MISSING_CAPXUL_CLIENT_PROVIDER");
|
|
23
|
+
const CapxulClientContext = createContext(MISSING_CAPXUL_CLIENT_PROVIDER);
|
|
23
24
|
function CapxulClientProvider({ client, children }) {
|
|
24
25
|
return /* @__PURE__ */ jsx(CapxulClientContext.Provider, {
|
|
25
26
|
value: client,
|
|
@@ -37,7 +38,9 @@ function useCapxulClient() {
|
|
|
37
38
|
* client resolves, rather than throwing during bootstrap.
|
|
38
39
|
*/
|
|
39
40
|
function useCapxulClientOrNull() {
|
|
40
|
-
|
|
41
|
+
const client = useContext(CapxulClientContext);
|
|
42
|
+
if (client === MISSING_CAPXUL_CLIENT_PROVIDER) throw new Error("useCapxulClient must be used within <CapxulProvider>");
|
|
43
|
+
return client;
|
|
41
44
|
}
|
|
42
45
|
//#endregion
|
|
43
46
|
//#region src/provider.tsx
|
|
@@ -50,10 +53,22 @@ function makeDefaultQueryClient() {
|
|
|
50
53
|
mutations: { retry: 0 }
|
|
51
54
|
} });
|
|
52
55
|
}
|
|
56
|
+
function isCapxulQueryKey(queryKey) {
|
|
57
|
+
return queryKey[0] === "capxul";
|
|
58
|
+
}
|
|
59
|
+
function clearClientScopedQueries(queryClient, ownsQueryClient) {
|
|
60
|
+
if (ownsQueryClient) {
|
|
61
|
+
queryClient.clear();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
queryClient.removeQueries({ predicate: (query) => isCapxulQueryKey(query.queryKey) });
|
|
65
|
+
}
|
|
53
66
|
function CapxulProvider(props) {
|
|
54
|
-
const { publishableKey, client: injectedClient, requirement,
|
|
67
|
+
const { publishableKey, client: injectedClient, requirement, signer, queryClient, children } = props;
|
|
55
68
|
const [resolvedQueryClient] = useState(() => queryClient ?? makeDefaultQueryClient());
|
|
69
|
+
const [ownsQueryClient] = useState(() => queryClient === void 0);
|
|
56
70
|
const [client, setClient] = useState(injectedClient ?? null);
|
|
71
|
+
const previousClientRef = useRef(injectedClient ?? null);
|
|
57
72
|
const [status, setStatus] = useState(injectedClient === void 0 ? "bootstrapping" : "ready");
|
|
58
73
|
const [error, setError] = useState(null);
|
|
59
74
|
const [attempt, setAttempt] = useState(0);
|
|
@@ -71,10 +86,6 @@ function CapxulProvider(props) {
|
|
|
71
86
|
const result = await createCapxulClient({
|
|
72
87
|
publishableKey,
|
|
73
88
|
...requirement === void 0 ? {} : { requirement },
|
|
74
|
-
...origin === void 0 ? {} : { origin },
|
|
75
|
-
...bootstrapBaseUrl === void 0 ? {} : { bootstrapBaseUrl },
|
|
76
|
-
...authCache === void 0 ? {} : { authCache },
|
|
77
|
-
...invokeTimeoutMs === void 0 ? {} : { invokeTimeoutMs },
|
|
78
89
|
...signer === void 0 ? {} : { signer }
|
|
79
90
|
});
|
|
80
91
|
if (cancelled) {
|
|
@@ -97,10 +108,6 @@ function CapxulProvider(props) {
|
|
|
97
108
|
}, [
|
|
98
109
|
publishableKey,
|
|
99
110
|
requirement,
|
|
100
|
-
origin,
|
|
101
|
-
bootstrapBaseUrl,
|
|
102
|
-
authCache,
|
|
103
|
-
invokeTimeoutMs,
|
|
104
111
|
signer,
|
|
105
112
|
attempt
|
|
106
113
|
]);
|
|
@@ -110,6 +117,15 @@ function CapxulProvider(props) {
|
|
|
110
117
|
setStatus("ready");
|
|
111
118
|
setError(null);
|
|
112
119
|
}, [injectedClient]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const previous = previousClientRef.current;
|
|
122
|
+
if (previous !== null && previous !== client) clearClientScopedQueries(resolvedQueryClient, ownsQueryClient);
|
|
123
|
+
previousClientRef.current = client;
|
|
124
|
+
}, [
|
|
125
|
+
client,
|
|
126
|
+
ownsQueryClient,
|
|
127
|
+
resolvedQueryClient
|
|
128
|
+
]);
|
|
113
129
|
const bootstrapState = useMemo(() => ({
|
|
114
130
|
status,
|
|
115
131
|
error,
|
|
@@ -153,6 +169,9 @@ const capxulKeys = {
|
|
|
153
169
|
session: ["capxul", "session"],
|
|
154
170
|
profile: ["capxul", "profile"],
|
|
155
171
|
account: ["capxul", "account"],
|
|
172
|
+
accountLifecycle: ["capxul", "accountLifecycle"],
|
|
173
|
+
provisioning: ["capxul", "provisioning"],
|
|
174
|
+
binding: ["capxul", "binding"],
|
|
156
175
|
accountBalance: ["capxul", "accountBalance"],
|
|
157
176
|
subAccounts: (accountId) => [
|
|
158
177
|
"capxul",
|
|
@@ -212,14 +231,68 @@ function useCapxulProfile() {
|
|
|
212
231
|
});
|
|
213
232
|
}
|
|
214
233
|
//#endregion
|
|
215
|
-
//#region src/
|
|
216
|
-
|
|
234
|
+
//#region src/internal/is-vitest-runtime.ts
|
|
235
|
+
/** True under Vitest — disables hook polling intervals that fight fake timers. */
|
|
236
|
+
function isVitestRuntime() {
|
|
237
|
+
return typeof process !== "undefined" && process.env["VITEST"] === "true";
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/internal/invalidate-auth-boundary.ts
|
|
241
|
+
/** Background refetch after verifyOtp — avoids hard reset cancel errors in UI. */
|
|
242
|
+
async function invalidateAuthBoundary(queryClient) {
|
|
243
|
+
await Promise.all([
|
|
244
|
+
queryClient.invalidateQueries({ queryKey: capxulKeys.session }),
|
|
245
|
+
queryClient.invalidateQueries({ queryKey: capxulKeys.profile }),
|
|
246
|
+
queryClient.invalidateQueries({ queryKey: capxulKeys.accountLifecycle }),
|
|
247
|
+
queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance })
|
|
248
|
+
]);
|
|
249
|
+
}
|
|
250
|
+
/** Hard reset after signOut — drop cached authenticated rows immediately. */
|
|
251
|
+
async function resetAuthBoundary(queryClient) {
|
|
252
|
+
await queryClient.cancelQueries({ queryKey: capxulKeys.accountBalance });
|
|
253
|
+
await Promise.all([
|
|
254
|
+
queryClient.resetQueries({ queryKey: capxulKeys.session }),
|
|
255
|
+
queryClient.resetQueries({ queryKey: capxulKeys.profile }),
|
|
256
|
+
queryClient.resetQueries({ queryKey: capxulKeys.accountLifecycle }),
|
|
257
|
+
queryClient.resetQueries({ queryKey: capxulKeys.accountBalance })
|
|
258
|
+
]);
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/hooks/use-capxul-account-lifecycle.ts
|
|
262
|
+
const LOADING_LIFECYCLE = { status: "loading" };
|
|
263
|
+
function useCapxulAccountLifecycle() {
|
|
217
264
|
const client = useCapxulClientOrNull();
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
265
|
+
const queryClient = useQueryClient();
|
|
266
|
+
const query = useQuery({
|
|
267
|
+
queryKey: capxulKeys.accountLifecycle,
|
|
268
|
+
queryFn: async () => unwrapCapxulResult(await requireBootstrappedClient(client, "account.getLifecycle").account.getLifecycle()),
|
|
269
|
+
enabled: client !== null,
|
|
270
|
+
refetchInterval: (q) => {
|
|
271
|
+
if (isVitestRuntime()) return false;
|
|
272
|
+
const data = q.state.data;
|
|
273
|
+
if (data === void 0) return false;
|
|
274
|
+
if (data.status === "loading" || isSettingUpLifecycle(data)) return 2e3;
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
222
277
|
});
|
|
278
|
+
const retryMutation = useMutation({
|
|
279
|
+
mutationFn: async () => unwrapCapxulResult(await requireBootstrappedClient(client, "account.retrySetup").account.retrySetup()),
|
|
280
|
+
onSuccess: async () => {
|
|
281
|
+
await invalidateAuthBoundary(queryClient);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const lifecycle = query.data ?? LOADING_LIFECYCLE;
|
|
285
|
+
const failedError = lifecycle.status === "failed" ? lifecycle.error : null;
|
|
286
|
+
return {
|
|
287
|
+
lifecycle,
|
|
288
|
+
isSettingUp: isSettingUpLifecycle(lifecycle),
|
|
289
|
+
error: failedError ?? (query.isError ? query.error : null),
|
|
290
|
+
isLoading: query.isLoading,
|
|
291
|
+
isFetching: query.isFetching,
|
|
292
|
+
isError: query.isError,
|
|
293
|
+
retry: retryMutation.mutateAsync,
|
|
294
|
+
isRetrying: retryMutation.isPending
|
|
295
|
+
};
|
|
223
296
|
}
|
|
224
297
|
//#endregion
|
|
225
298
|
//#region src/hooks/use-capxul-account-balance.ts
|
|
@@ -250,34 +323,15 @@ function useCapxulSignIn() {
|
|
|
250
323
|
return useMutation({ mutationFn: async (input) => unwrapCapxulResult(await requireBootstrappedClient(client, "auth.signIn").auth.signIn(input)) });
|
|
251
324
|
}
|
|
252
325
|
//#endregion
|
|
253
|
-
//#region src/internal/invalidate-auth-boundary.ts
|
|
254
|
-
/** Background refetch after verifyOtp — avoids hard reset cancel errors in UI. */
|
|
255
|
-
async function invalidateAuthBoundary(queryClient) {
|
|
256
|
-
await Promise.all([
|
|
257
|
-
queryClient.invalidateQueries({ queryKey: capxulKeys.session }),
|
|
258
|
-
queryClient.invalidateQueries({ queryKey: capxulKeys.profile }),
|
|
259
|
-
queryClient.invalidateQueries({ queryKey: capxulKeys.account }),
|
|
260
|
-
queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance })
|
|
261
|
-
]);
|
|
262
|
-
}
|
|
263
|
-
/** Hard reset after signOut — drop cached authenticated rows immediately. */
|
|
264
|
-
async function resetAuthBoundary(queryClient) {
|
|
265
|
-
await queryClient.cancelQueries({ queryKey: capxulKeys.accountBalance });
|
|
266
|
-
await Promise.all([
|
|
267
|
-
queryClient.resetQueries({ queryKey: capxulKeys.session }),
|
|
268
|
-
queryClient.resetQueries({ queryKey: capxulKeys.profile }),
|
|
269
|
-
queryClient.resetQueries({ queryKey: capxulKeys.account }),
|
|
270
|
-
queryClient.resetQueries({ queryKey: capxulKeys.accountBalance })
|
|
271
|
-
]);
|
|
272
|
-
}
|
|
273
|
-
//#endregion
|
|
274
326
|
//#region src/hooks/use-capxul-verify-otp.ts
|
|
275
327
|
function useCapxulVerifyOtp() {
|
|
276
328
|
const client = useCapxulClientOrNull();
|
|
277
329
|
const queryClient = useQueryClient();
|
|
278
330
|
return useMutation({
|
|
279
331
|
mutationFn: async (input) => unwrapCapxulResult(await requireBootstrappedClient(client, "auth.verifyOtp").auth.verifyOtp(input)),
|
|
280
|
-
onSuccess: () =>
|
|
332
|
+
onSuccess: async () => {
|
|
333
|
+
await invalidateAuthBoundary(queryClient);
|
|
334
|
+
}
|
|
281
335
|
});
|
|
282
336
|
}
|
|
283
337
|
//#endregion
|
|
@@ -294,16 +348,6 @@ function useCapxulSignOut() {
|
|
|
294
348
|
});
|
|
295
349
|
}
|
|
296
350
|
//#endregion
|
|
297
|
-
//#region src/hooks/use-capxul-ensure-ready.ts
|
|
298
|
-
function useCapxulEnsureReady() {
|
|
299
|
-
const client = useCapxulClientOrNull();
|
|
300
|
-
const queryClient = useQueryClient();
|
|
301
|
-
return useMutation({
|
|
302
|
-
mutationFn: async () => unwrapCapxulResult(await requireBootstrappedClient(client, "account.ensureReady").account.ensureReady()),
|
|
303
|
-
onSuccess: () => invalidateAuthBoundary(queryClient)
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
351
|
//#region src/hooks/use-capxul-sub-accounts.ts
|
|
308
352
|
function useCapxulSubAccountsList(accountId, options) {
|
|
309
353
|
const client = useCapxulClientOrNull();
|
|
@@ -519,6 +563,6 @@ function useCapxulOrgSpend(orgId) {
|
|
|
519
563
|
});
|
|
520
564
|
}
|
|
521
565
|
//#endregion
|
|
522
|
-
export { CapxulProvider, useCapxul,
|
|
566
|
+
export { CapxulProvider, useCapxul, useCapxulAccountBalance, useCapxulAccountFund, useCapxulAccountLifecycle, useCapxulAssignRole, useCapxulCreateOrg, useCapxulInviteMember, useCapxulOrg, useCapxulOrgDeployRoles, useCapxulOrgMembers, useCapxulOrgRoles, useCapxulOrgSpend, useCapxulOrgTreasury, useCapxulOrgs, useCapxulProfile, useCapxulRemoveMember, useCapxulSession, useCapxulSignIn, useCapxulSignOut, useCapxulSubAccountCreate, useCapxulSubAccountDelete, useCapxulSubAccountRename, useCapxulSubAccountsList, useCapxulTransfer, useCapxulVerifyOtp };
|
|
523
567
|
|
|
524
568
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -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","../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/hooks/use-capxul-account.ts","../src/hooks/use-capxul-account-balance.ts","../src/hooks/use-capxul-account-fund.ts","../src/hooks/use-capxul-sign-in.ts","../src/internal/invalidate-auth-boundary.ts","../src/hooks/use-capxul-verify-otp.ts","../src/hooks/use-capxul-sign-out.ts","../src/hooks/use-capxul-ensure-ready.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\nvoid React;\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 CapxulClientContext = createContext<CapxulClient | null>(null);\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 return useContext(CapxulClientContext);\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` (backend-orchestrated-deploy.md) threads into the deploy lane via\n// `createCapxulClient` for `requirement: \"deployed\"` flows.\n\nimport * as React from \"react\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\nimport type {\n AccountRequirement,\n CapxulClient,\n CapxulSigner,\n ProductionAdapterInput,\n} 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\nexport interface CapxulProviderProps {\n /** Publishable key — the provider bootstraps the client (browser / app path). */\n readonly publishableKey?: string;\n /**\n * Pre-built client (Node / server consumers that bootstrap before any React\n * tree, and test harnesses). Mutually exclusive with `publishableKey`.\n */\n readonly client?: CapxulClient;\n /** Init-time account readiness target. Default `\"none\"`. */\n readonly requirement?: AccountRequirement;\n /** Optional app origin forwarded to the SDK bootstrap request. */\n readonly origin?: ProductionAdapterInput[\"origin\"];\n /** Optional bootstrap host override for live/dev environments. */\n readonly bootstrapBaseUrl?: ProductionAdapterInput[\"bootstrapBaseUrl\"];\n /** Optional auth persistence adapter; Node CLIs pass their filesystem cache. */\n readonly authCache?: ProductionAdapterInput[\"authCache\"];\n /** Optional method invocation timeout in milliseconds. */\n readonly invokeTimeoutMs?: ProductionAdapterInput[\"invokeTimeoutMs\"];\n /**\n * Consumer-held signer for the backend-orchestrated deploy lane\n * (backend-orchestrated-deploy.md). Required for `requirement: \"deployed\"`.\n */\n readonly signer?: CapxulSigner;\n /** Bring your own QueryClient; otherwise the provider creates one. */\n readonly queryClient?: QueryClient;\n readonly children: ReactNode;\n}\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\nexport function CapxulProvider(props: CapxulProviderProps) {\n const {\n publishableKey,\n client: injectedClient,\n requirement,\n origin,\n bootstrapBaseUrl,\n authCache,\n invokeTimeoutMs,\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\n const [client, setClient] = useState<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 ...(origin === undefined ? {} : { origin }),\n ...(bootstrapBaseUrl === undefined ? {} : { bootstrapBaseUrl }),\n ...(authCache === undefined ? {} : { authCache }),\n ...(invokeTimeoutMs === undefined ? {} : { invokeTimeoutMs }),\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 }, [\n publishableKey,\n requirement,\n origin,\n bootstrapBaseUrl,\n authCache,\n invokeTimeoutMs,\n signer,\n attempt,\n ]);\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 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 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","\"use client\";\n\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\nimport type { AccountStatus } 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 UseCapxulAccountReturn = UseQueryResult<AccountStatus, CapxulError>;\n\nexport function useCapxulAccount(): UseCapxulAccountReturn {\n const client = useCapxulClientOrNull();\n return useQuery({\n queryKey: capxulKeys.account,\n queryFn: async () =>\n unwrapCapxulResult(\n await requireBootstrappedClient(client, \"account.getStatus\").account.getStatus(),\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 { 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","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.account }),\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.account }),\n queryClient.resetQueries({ queryKey: capxulKeys.accountBalance }),\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: () => invalidateAuthBoundary(queryClient),\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 { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\n\nimport type { CapxulError } from \"@capxul/config\";\nimport type { AccountStatus } 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 type UseCapxulEnsureReadyReturn = UseMutationResult<AccountStatus, CapxulError, void>;\n\nexport function useCapxulEnsureReady(): UseCapxulEnsureReadyReturn {\n const client = useCapxulClientOrNull();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async () =>\n unwrapCapxulResult(\n await requireBootstrappedClient(client, \"account.ensureReady\").account.ensureReady(),\n ),\n onSuccess: () => invalidateAuthBoundary(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 query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,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"}
|
|
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,WAA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C,IAAI,UAAU,KAAA,GACZ,MAAM,OAAO,aAAa,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/sdk-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"package.json",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@capxul/config": "0.0.0",
|
|
21
|
-
"@capxul/sdk": "0.
|
|
21
|
+
"@capxul/sdk": "1.0.0-alpha.6",
|
|
22
22
|
"@capxul/types": "0.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|