@capxul/sdk-react 0.1.0-alpha.3 → 0.1.0-alpha.4
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/CHANGELOG.md +28 -0
- package/dist/index.cjs +138 -140
- package/dist/index.d.cts +79 -45
- package/dist/index.d.ts +79 -45
- package/dist/index.js +138 -142
- package/dist/proof/index.cjs +12777 -0
- package/dist/proof/index.d.cts +753 -0
- package/dist/proof/index.d.ts +753 -0
- package/dist/proof/index.js +12750 -0
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @capxul/sdk-react
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Post-alpha hardening — WAVE 1 + WAVE 2 cumulative
|
|
8
|
+
|
|
9
|
+
**WAVE 1 (merged 2026-05-03 12:44Z):**
|
|
10
|
+
- S2 story 1: wire onboarding readback hooks (#469) — `me.update`, `accounts.retrieve`, `accounts.update`, `useAccount`, `useSafe`
|
|
11
|
+
- S3 phase 1: Ink reference CLI scaffold + `auth+me` end-to-end against live alpha-3 Convex (#470). Stickiness gate (D3) fired.
|
|
12
|
+
- S5: split `CapxulProvider` into public single-input `BrowserCapxulConfig` + test-only `CapxulTestProvider` from `@capxul/sdk-react/proof` (#473). Q1 lock honored. 7 type-level provider-shape guards including `@ts-expect-error` against test-provider leaking to public barrel.
|
|
13
|
+
|
|
14
|
+
**WAVE 2 (merged 2026-05-03 12:54-13:16Z):**
|
|
15
|
+
- S3 phase 2: per-domain CLI commands closing #458 (#476) — `account retrieve/update`, `safe retrieve`, `payment retrieve`, `withdrawal retrieve/list`. 12/12 agent-driver tests pass.
|
|
16
|
+
- S2 story 2: `capxul.tokenTransfers.*` non-canonical SDK namespace (#479) — Option A per #477 (canon-aligned `transfers.*` shape deferred to alpha.5+ pending backend canon work). New `useTokenTransfers` + `useTokenTransfer` hooks; new `getByTxLogIndex` backend query. Hook proof matrix length unchanged at 41 (non-canonical hooks deliberately excluded).
|
|
17
|
+
|
|
18
|
+
**S1 (#456) closed no-op** — alpha publish infrastructure (tsup, lazy-DX, transport state machine, npm metadata, READMEs, CHANGELOG, changesets, OIDC release workflow) physically merged into `api-first` via PRs #449-#452 earlier the same day; the slice merge produced 0 file changes per clean-room probe.
|
|
19
|
+
|
|
20
|
+
**Friction issues filed for alpha.4+ polish:**
|
|
21
|
+
- #474 — `me.get` returns `NOT_IMPLEMENTED` when `config.data` is undefined; should be `NOT_AUTHENTICATED`.
|
|
22
|
+
- #475 — `@capxul/sdk/headless` slim entry point excludes xstate flow machines + brand constructors (1.6 MB → much smaller).
|
|
23
|
+
- #477 / #478 — `transfers.*` / `balanceLedger.*` / `treasury` canon-shape alignment with indexer feed.
|
|
24
|
+
- #471 — Vercel-capxul-web preview-deploy systemic failure on api-first base (separate from epic).
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @capxul/sdk@0.1.0-alpha.4
|
|
30
|
+
|
|
3
31
|
## 0.1.0-alpha.3
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,45 @@ var viem = require('viem');
|
|
|
11
11
|
var accounts = require('viem/accounts');
|
|
12
12
|
|
|
13
13
|
// src/provider.tsx
|
|
14
|
+
var CapxulClientContext = react.createContext(null);
|
|
15
|
+
function CapxulClientProvider({
|
|
16
|
+
client,
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CapxulClientContext.Provider, { value: client, children });
|
|
20
|
+
}
|
|
21
|
+
function useCapxul() {
|
|
22
|
+
const client = react.useContext(CapxulClientContext);
|
|
23
|
+
if (!client) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"useCapxul() was called outside a <CapxulProvider>. Wrap your app in <CapxulProvider config={...}> before rendering hooks from @capxul/sdk-react."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return client;
|
|
29
|
+
}
|
|
30
|
+
var CapxulTransportContext = react.createContext(null);
|
|
31
|
+
function CapxulTransportProvider({
|
|
32
|
+
transport,
|
|
33
|
+
children
|
|
34
|
+
}) {
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CapxulTransportContext.Provider, { value: transport, children });
|
|
36
|
+
}
|
|
37
|
+
function useCapxulStatus() {
|
|
38
|
+
const transport = react.useContext(CapxulTransportContext);
|
|
39
|
+
return react.useSyncExternalStore(
|
|
40
|
+
(listener) => {
|
|
41
|
+
if (!transport) return () => {
|
|
42
|
+
};
|
|
43
|
+
return transport.subscribe(listener);
|
|
44
|
+
},
|
|
45
|
+
() => transport?.getState() ?? FALLBACK_READY,
|
|
46
|
+
() => transport?.getState() ?? FALLBACK_READY
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
var FALLBACK_READY = Object.freeze({
|
|
50
|
+
status: "ready",
|
|
51
|
+
runtime: { authBaseUrl: "", convexUrl: "" }
|
|
52
|
+
});
|
|
14
53
|
|
|
15
54
|
// ../config/src/errors.ts
|
|
16
55
|
var CapxulError = class extends Error {
|
|
@@ -83,56 +122,62 @@ function roleKeyFromLabel(label) {
|
|
|
83
122
|
roleKeyFromLabel("OWNER");
|
|
84
123
|
roleKeyFromLabel("FINANCE_MANAGER");
|
|
85
124
|
roleKeyFromLabel("TEAM_LEAD");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
function useCapxul() {
|
|
94
|
-
const client = react.useContext(CapxulClientContext);
|
|
95
|
-
if (!client) {
|
|
96
|
-
throw new Error(
|
|
97
|
-
"useCapxul() was called outside a <CapxulProvider>. Wrap your app in <CapxulProvider config={...}> before rendering hooks from @capxul/sdk-react."
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
return client;
|
|
101
|
-
}
|
|
102
|
-
var CapxulTransportContext = react.createContext(null);
|
|
103
|
-
function CapxulTransportProvider({
|
|
104
|
-
transport,
|
|
105
|
-
children
|
|
106
|
-
}) {
|
|
107
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CapxulTransportContext.Provider, { value: transport, children });
|
|
125
|
+
|
|
126
|
+
// src/config.ts
|
|
127
|
+
function createCapxulConfig(input) {
|
|
128
|
+
assertOnlyKnownKeys(input);
|
|
129
|
+
assertModeRequiredFields(input);
|
|
130
|
+
return Object.freeze({ ...input });
|
|
108
131
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
var ALLOWED_BROWSER_CONFIG_KEYS = [
|
|
133
|
+
"mode",
|
|
134
|
+
"authBaseUrl",
|
|
135
|
+
"convexUrl",
|
|
136
|
+
"publishableKey",
|
|
137
|
+
"bootstrapUrl",
|
|
138
|
+
"fetchImpl"
|
|
139
|
+
];
|
|
140
|
+
function assertOnlyKnownKeys(input) {
|
|
141
|
+
const candidate = input;
|
|
142
|
+
const allowed = new Set(ALLOWED_BROWSER_CONFIG_KEYS);
|
|
143
|
+
const unknown = Object.keys(candidate).filter((key) => !allowed.has(key));
|
|
144
|
+
if (unknown.length === 0) return;
|
|
145
|
+
throw Errors.invalidInput(
|
|
146
|
+
"config",
|
|
147
|
+
`Browser Capxul config contains unknown or secret/server-only fields: ${unknown.join(", ")}. Allowed keys: ${ALLOWED_BROWSER_CONFIG_KEYS.join(", ")}.`
|
|
119
148
|
);
|
|
120
149
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
150
|
+
function assertModeRequiredFields(input) {
|
|
151
|
+
switch (input.mode) {
|
|
152
|
+
case "build-time-urls": {
|
|
153
|
+
if (!input.authBaseUrl || input.authBaseUrl.trim().length === 0) {
|
|
154
|
+
throw Errors.invalidInput("authBaseUrl", "non-empty string required.");
|
|
155
|
+
}
|
|
156
|
+
if (!input.convexUrl || input.convexUrl.trim().length === 0) {
|
|
157
|
+
throw Errors.invalidInput("convexUrl", "non-empty string required.");
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
case "publishable-key": {
|
|
162
|
+
if (!input.publishableKey || input.publishableKey.trim().length === 0) {
|
|
163
|
+
throw Errors.invalidInput("publishableKey", "non-empty string required.");
|
|
164
|
+
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
default: {
|
|
168
|
+
const value = input;
|
|
169
|
+
throw Errors.internalError(
|
|
170
|
+
`Unhandled BrowserCapxulConfig.mode: ${String(value.mode)}.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
125
175
|
function CapxulProvider({
|
|
126
176
|
config,
|
|
127
|
-
publishableKey,
|
|
128
|
-
browserConfig,
|
|
129
177
|
queryClient,
|
|
130
178
|
children
|
|
131
179
|
}) {
|
|
132
|
-
const wiring = react.useMemo(
|
|
133
|
-
() => buildWiring({ config, publishableKey, browserConfig }),
|
|
134
|
-
[config, publishableKey, browserConfig]
|
|
135
|
-
);
|
|
180
|
+
const wiring = react.useMemo(() => buildWiring(config), [config]);
|
|
136
181
|
const defaultClient = react.useMemo(
|
|
137
182
|
() => new reactQuery.QueryClient({
|
|
138
183
|
defaultOptions: { queries: { staleTime: 3e4 } }
|
|
@@ -140,47 +185,14 @@ function CapxulProvider({
|
|
|
140
185
|
[]
|
|
141
186
|
);
|
|
142
187
|
const effectiveClient = queryClient ?? defaultClient;
|
|
143
|
-
|
|
144
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: effectiveClient, children: wiring.transport ? /* @__PURE__ */ jsxRuntime.jsx(CapxulTransportProvider, { transport: wiring.transport, children: inner }) : inner });
|
|
188
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: effectiveClient, children: /* @__PURE__ */ jsxRuntime.jsx(CapxulTransportProvider, { transport: wiring.transport, children: /* @__PURE__ */ jsxRuntime.jsx(CapxulClientProvider, { client: wiring.client, children }) }) });
|
|
145
189
|
}
|
|
146
|
-
function buildWiring({
|
|
147
|
-
config
|
|
148
|
-
|
|
149
|
-
browserConfig
|
|
150
|
-
}) {
|
|
151
|
-
const sources = [
|
|
152
|
-
config !== void 0,
|
|
153
|
-
publishableKey !== void 0,
|
|
154
|
-
browserConfig !== void 0
|
|
155
|
-
].filter(Boolean).length;
|
|
156
|
-
if (sources === 0) {
|
|
157
|
-
throw Errors.invalidInput(
|
|
158
|
-
"CapxulProvider",
|
|
159
|
-
"Pass exactly one of `config`, `publishableKey`, or `browserConfig`."
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
if (sources > 1) {
|
|
163
|
-
throw Errors.invalidInput(
|
|
164
|
-
"CapxulProvider",
|
|
165
|
-
"`config`, `publishableKey`, and `browserConfig` are mutually exclusive \u2014 pass exactly one."
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
if (config !== void 0) {
|
|
169
|
-
return {
|
|
170
|
-
client: sdk.createCapxulClient(config),
|
|
171
|
-
transport: null
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const browserCfg = browserConfig ?? {
|
|
175
|
-
mode: "publishable-key",
|
|
176
|
-
// The narrowing above (`sources === 0` rejected; `config` not
|
|
177
|
-
// present) guarantees `publishableKey` is set on this branch.
|
|
178
|
-
publishableKey
|
|
179
|
-
};
|
|
180
|
-
const transport = sdk.makeHttpTransport(browserCfg);
|
|
190
|
+
function buildWiring(config) {
|
|
191
|
+
const validated = createCapxulConfig(config);
|
|
192
|
+
const transport = sdk.makeHttpTransport(validated);
|
|
181
193
|
const sdkConfig = {
|
|
182
194
|
_transport: transport,
|
|
183
|
-
publishableKey:
|
|
195
|
+
publishableKey: validated.mode === "publishable-key" ? validated.publishableKey : void 0
|
|
184
196
|
};
|
|
185
197
|
return {
|
|
186
198
|
client: sdk.createCapxulClient(sdkConfig),
|
|
@@ -274,8 +286,12 @@ function useMe() {
|
|
|
274
286
|
staleTime: 3e4
|
|
275
287
|
});
|
|
276
288
|
}
|
|
277
|
-
function useAccount(
|
|
278
|
-
|
|
289
|
+
function useAccount(accountId) {
|
|
290
|
+
const capxul = useCapxul();
|
|
291
|
+
return useSdkQuery(
|
|
292
|
+
() => accountId !== void 0 ? capxul.accounts.retrieve(accountId) : capxul.me.get(),
|
|
293
|
+
[capxul, accountId]
|
|
294
|
+
);
|
|
279
295
|
}
|
|
280
296
|
function useOrganization(_organizationId) {
|
|
281
297
|
return notImplementedQuery("useOrganization");
|
|
@@ -283,8 +299,12 @@ function useOrganization(_organizationId) {
|
|
|
283
299
|
function useMember(_args) {
|
|
284
300
|
return notImplementedQuery("useMember");
|
|
285
301
|
}
|
|
286
|
-
function useSafe(
|
|
287
|
-
|
|
302
|
+
function useSafe(safeId) {
|
|
303
|
+
const capxul = useCapxul();
|
|
304
|
+
return useSdkQuery(
|
|
305
|
+
() => capxul.accounts.safes.retrieve(safeId),
|
|
306
|
+
[capxul, safeId]
|
|
307
|
+
);
|
|
288
308
|
}
|
|
289
309
|
function useTreasury(_organizationId) {
|
|
290
310
|
return notImplementedQuery("useTreasury");
|
|
@@ -316,14 +336,25 @@ function usePayment(_paymentId) {
|
|
|
316
336
|
function useTransfer(_transferId) {
|
|
317
337
|
return notImplementedQuery("useTransfer");
|
|
318
338
|
}
|
|
339
|
+
function useTokenTransfer(args) {
|
|
340
|
+
const capxul = useCapxul();
|
|
341
|
+
return useSdkQuery(
|
|
342
|
+
() => capxul.tokenTransfers.retrieve(args),
|
|
343
|
+
[capxul, args.txHash, args.logIndex, args.chainId]
|
|
344
|
+
);
|
|
345
|
+
}
|
|
319
346
|
function useBalanceLedgerEntry(_args) {
|
|
320
347
|
return notImplementedQuery("useBalanceLedgerEntry");
|
|
321
348
|
}
|
|
322
349
|
function useDocument(_documentId) {
|
|
323
350
|
return notImplementedQuery("useDocument");
|
|
324
351
|
}
|
|
325
|
-
function useWithdrawal(
|
|
326
|
-
|
|
352
|
+
function useWithdrawal(withdrawalId) {
|
|
353
|
+
const capxul = useCapxul();
|
|
354
|
+
return useSdkQuery(() => capxul.withdrawals.retrieve(withdrawalId), [
|
|
355
|
+
capxul,
|
|
356
|
+
withdrawalId
|
|
357
|
+
]);
|
|
327
358
|
}
|
|
328
359
|
function useOperation(operationId) {
|
|
329
360
|
const capxul = useCapxul();
|
|
@@ -370,6 +401,13 @@ function useTransfers(_filters) {
|
|
|
370
401
|
function useOrgTransfers(_args) {
|
|
371
402
|
return notImplementedQuery("useOrgTransfers");
|
|
372
403
|
}
|
|
404
|
+
function useTokenTransfers(filters) {
|
|
405
|
+
const capxul = useCapxul();
|
|
406
|
+
return useSdkQuery(
|
|
407
|
+
() => capxul.tokenTransfers.list(filters),
|
|
408
|
+
[capxul, filters?.limit, filters?.cursor, filters?.direction]
|
|
409
|
+
);
|
|
410
|
+
}
|
|
373
411
|
function useBalanceLedger(_args) {
|
|
374
412
|
return notImplementedQuery("useBalanceLedger");
|
|
375
413
|
}
|
|
@@ -379,11 +417,19 @@ function useDocuments(_filters) {
|
|
|
379
417
|
function useOrgDocuments(_args) {
|
|
380
418
|
return notImplementedQuery("useOrgDocuments");
|
|
381
419
|
}
|
|
382
|
-
function useWithdrawals(
|
|
383
|
-
|
|
420
|
+
function useWithdrawals(filters) {
|
|
421
|
+
const capxul = useCapxul();
|
|
422
|
+
return useSdkQuery(
|
|
423
|
+
() => capxul.withdrawals.list(filters),
|
|
424
|
+
[capxul, filters?.limit, filters?.cursor]
|
|
425
|
+
);
|
|
384
426
|
}
|
|
385
|
-
function useOrgWithdrawals(
|
|
386
|
-
|
|
427
|
+
function useOrgWithdrawals(args) {
|
|
428
|
+
const capxul = useCapxul();
|
|
429
|
+
return useSdkQuery(
|
|
430
|
+
() => capxul.organizations.withdrawals.list(args),
|
|
431
|
+
[capxul, args.organizationId, args.limit, args.cursor]
|
|
432
|
+
);
|
|
387
433
|
}
|
|
388
434
|
function useApiKeys(_organizationId) {
|
|
389
435
|
return notImplementedQuery("useApiKeys");
|
|
@@ -409,56 +455,6 @@ function useProvisioningFlow() {
|
|
|
409
455
|
const [snapshot, send] = react$1.useActor(machine);
|
|
410
456
|
return { snapshot, send };
|
|
411
457
|
}
|
|
412
|
-
|
|
413
|
-
// src/config.ts
|
|
414
|
-
function createCapxulConfig(input) {
|
|
415
|
-
assertOnlyKnownKeys(input);
|
|
416
|
-
assertModeRequiredFields(input);
|
|
417
|
-
return Object.freeze({ ...input });
|
|
418
|
-
}
|
|
419
|
-
var ALLOWED_BROWSER_CONFIG_KEYS = [
|
|
420
|
-
"mode",
|
|
421
|
-
"authBaseUrl",
|
|
422
|
-
"convexUrl",
|
|
423
|
-
"publishableKey",
|
|
424
|
-
"bootstrapUrl",
|
|
425
|
-
"fetchImpl"
|
|
426
|
-
];
|
|
427
|
-
function assertOnlyKnownKeys(input) {
|
|
428
|
-
const candidate = input;
|
|
429
|
-
const allowed = new Set(ALLOWED_BROWSER_CONFIG_KEYS);
|
|
430
|
-
const unknown = Object.keys(candidate).filter((key) => !allowed.has(key));
|
|
431
|
-
if (unknown.length === 0) return;
|
|
432
|
-
throw Errors.invalidInput(
|
|
433
|
-
"config",
|
|
434
|
-
`Browser Capxul config contains unknown or secret/server-only fields: ${unknown.join(", ")}. Allowed keys: ${ALLOWED_BROWSER_CONFIG_KEYS.join(", ")}.`
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
function assertModeRequiredFields(input) {
|
|
438
|
-
switch (input.mode) {
|
|
439
|
-
case "build-time-urls": {
|
|
440
|
-
if (!input.authBaseUrl || input.authBaseUrl.trim().length === 0) {
|
|
441
|
-
throw Errors.invalidInput("authBaseUrl", "non-empty string required.");
|
|
442
|
-
}
|
|
443
|
-
if (!input.convexUrl || input.convexUrl.trim().length === 0) {
|
|
444
|
-
throw Errors.invalidInput("convexUrl", "non-empty string required.");
|
|
445
|
-
}
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
case "publishable-key": {
|
|
449
|
-
if (!input.publishableKey || input.publishableKey.trim().length === 0) {
|
|
450
|
-
throw Errors.invalidInput("publishableKey", "non-empty string required.");
|
|
451
|
-
}
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
default: {
|
|
455
|
-
const value = input;
|
|
456
|
-
throw Errors.internalError(
|
|
457
|
-
`Unhandled BrowserCapxulConfig.mode: ${String(value.mode)}.`
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
458
|
var PRIVATE_KEY_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
463
459
|
var EVM_ADDRESS_PATTERN = /^0x[0-9a-fA-F]{40}$/;
|
|
464
460
|
function injectedConnector(options = {}) {
|
|
@@ -592,6 +588,8 @@ exports.useProvisioningFlow = useProvisioningFlow;
|
|
|
592
588
|
exports.useSafe = useSafe;
|
|
593
589
|
exports.useSubAccount = useSubAccount;
|
|
594
590
|
exports.useSubAccounts = useSubAccounts;
|
|
591
|
+
exports.useTokenTransfer = useTokenTransfer;
|
|
592
|
+
exports.useTokenTransfers = useTokenTransfers;
|
|
595
593
|
exports.useTransfer = useTransfer;
|
|
596
594
|
exports.useTransfers = useTransfers;
|
|
597
595
|
exports.useTreasury = useTreasury;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { HttpTransport, TransportState,
|
|
2
|
+
import { HttpTransport, TransportState, BrowserCapxulConfig, AccountId, OrganizationId, ApiKeyId, BalanceLedgerEntryId, ExternalAccountId, MemberId, Account, ApiKey, BalanceLedgerEntry, DocumentId, Document, ExternalAccount, KybProfile, KycProfile, CapxulError as CapxulError$1, Member, OperationId, Operation, Organization, PaymentId, Payment, SafeId, Safe, SubAccountId, SubAccount, TokenTransfer, TransferId, Transfer, Treasury, VirtualAccountId, VirtualAccount, VirtualCardId, VirtualCard, WebhookEndpointId, WebhookEndpoint, WebhookEventId, WebhookEvent, WithdrawalId, Withdrawal, List, TokenTransfersListInput, TokenTransfersListPage, LocalPrivateKeySignerProvider } from '@capxul/sdk';
|
|
3
3
|
export { AuthFlowContext, AuthFlowEvent, BrowserCapxulConfig, OnboardingFlowContext, OnboardingFlowEvent, ProvisioningFlowContext, ProvisioningFlowEvent } from '@capxul/sdk';
|
|
4
4
|
import { QueryClient, UseQueryResult } from '@tanstack/react-query';
|
|
5
5
|
import { CapxulClient } from '@capxul/sdk/client';
|
|
@@ -55,55 +55,39 @@ declare function CapxulTransportProvider({ transport, children, }: CapxulTranspo
|
|
|
55
55
|
declare function useCapxulStatus(): TransportState;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* `CapxulProvider` — React
|
|
59
|
-
* `@capxul/sdk` client AND a TanStack Query `QueryClient` for the
|
|
60
|
-
* subtree.
|
|
58
|
+
* `CapxulProvider` — public React provider for `@capxul/sdk-react`.
|
|
61
59
|
*
|
|
62
|
-
*
|
|
60
|
+
* Single-input contract: accepts ONLY `{ config: BrowserCapxulConfig,
|
|
61
|
+
* queryClient?, children }`. The browser config is the secret-safe
|
|
62
|
+
* discriminated union from `@capxul/sdk` — `apiKey`, `data`, `signer`,
|
|
63
|
+
* and other server-only fields are rejected at compile-time AND at
|
|
64
|
+
* runtime via `createCapxulConfig`'s allow-list validator.
|
|
63
65
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
66
|
+
* The provider builds an `HttpTransport` synchronously and injects it
|
|
67
|
+
* into `createCapxulClient` via the internal `_transport` slot. The
|
|
68
|
+
* transport is exposed through `CapxulTransportContext` so
|
|
69
|
+
* `useCapxulStatus()` can subscribe to its lifecycle state machine.
|
|
67
70
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* internal `_transport` slot, and exposes the transport through
|
|
72
|
-
* `CapxulTransportContext` so `useCapxulStatus()` can subscribe
|
|
73
|
-
* to its lifecycle state machine.
|
|
74
|
-
*
|
|
75
|
-
* The lazy-DX provider mounts synchronously. There is no
|
|
76
|
-
* `useState` mutating config, no `useMemo` rebuilding config when
|
|
77
|
-
* state changes, and no Suspense gate at mount. State transitions
|
|
78
|
-
* happen on the transport (a stable singleton); React subscribes
|
|
79
|
-
* via `useSyncExternalStore` and re-renders only the components
|
|
80
|
-
* that actually depend on the transport state.
|
|
71
|
+
* Tests and the e2e harness need the server-augmented `CapxulConfig`
|
|
72
|
+
* shape (with `data`, `signer`, `signing`). Those callers use
|
|
73
|
+
* `CapxulTestProvider` from `@capxul/sdk-react/proof` instead.
|
|
81
74
|
*
|
|
82
75
|
* Per ADR 4 in the API-first architecture stack PLAN, only
|
|
83
76
|
* `QueryClientProvider` is allowed to live OUTSIDE the single
|
|
84
77
|
* `CapxulContext`. The `QueryClientProvider` is the outermost wrap;
|
|
85
|
-
* the SDK client provider sits inside it; the
|
|
86
|
-
*
|
|
78
|
+
* the SDK client provider sits inside it; the transport provider sits
|
|
79
|
+
* between the two.
|
|
87
80
|
*/
|
|
88
81
|
|
|
89
82
|
type CapxulProviderProps = {
|
|
90
83
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* Shorthand for the publishable-key arm of `BrowserCapxulConfig`.
|
|
97
|
-
* Provider builds the transport synchronously and injects it into
|
|
98
|
-
* the SDK client — the canonical lazy-DX entry point per ADR #14c.
|
|
99
|
-
*/
|
|
100
|
-
readonly publishableKey?: string;
|
|
101
|
-
/**
|
|
102
|
-
* Full `BrowserCapxulConfig` for callers that need
|
|
103
|
-
* `mode: "build-time-urls"` or a custom `fetchImpl` (e.g. tests).
|
|
104
|
-
* Mutually exclusive with `publishableKey` / `config`.
|
|
84
|
+
* Browser-safe Capxul config — the discriminated union from
|
|
85
|
+
* `@capxul/sdk`. Either the `build-time-urls` arm or the
|
|
86
|
+
* `publishable-key` arm. Server-only fields (`apiKey`, `data`,
|
|
87
|
+
* `signer`, `signing`) are rejected at compile-time and at runtime
|
|
88
|
+
* via `createCapxulConfig`'s allow-list validator.
|
|
105
89
|
*/
|
|
106
|
-
readonly
|
|
90
|
+
readonly config: BrowserCapxulConfig;
|
|
107
91
|
/**
|
|
108
92
|
* Optional TanStack Query `QueryClient`. Pass your app's existing
|
|
109
93
|
* client to share the cache across the SDK hooks and the host
|
|
@@ -113,7 +97,7 @@ type CapxulProviderProps = {
|
|
|
113
97
|
readonly queryClient?: QueryClient;
|
|
114
98
|
readonly children: ReactNode;
|
|
115
99
|
};
|
|
116
|
-
declare function CapxulProvider({ config,
|
|
100
|
+
declare function CapxulProvider({ config, queryClient, children, }: CapxulProviderProps): ReactNode;
|
|
117
101
|
|
|
118
102
|
/**
|
|
119
103
|
* `QueryResult<T>` — the canonical three-state return shape for every
|
|
@@ -220,16 +204,27 @@ declare function useMe(): UseQueryResult<Account, CapxulError$1>;
|
|
|
220
204
|
/**
|
|
221
205
|
* Account by id. Omit `accountId` for the calling user (alias for
|
|
222
206
|
* `useMe()` from a developer-perspective lens).
|
|
207
|
+
*
|
|
208
|
+
* Slice 2 (#457 story 1): wired via `capxul.accounts.retrieve` for
|
|
209
|
+
* the id-bearing call and `capxul.me.get()` for the self-lens
|
|
210
|
+
* shortcut. Returns the legacy `QueryResult<Account>` shape because
|
|
211
|
+
* only `useMe` has migrated to TanStack Query so far (PLAN.md task
|
|
212
|
+
* 1.8) — per-hook migration is the rollout pattern.
|
|
223
213
|
*/
|
|
224
|
-
declare function useAccount(
|
|
214
|
+
declare function useAccount(accountId?: AccountId): QueryResult<Account>;
|
|
225
215
|
declare function useOrganization(_organizationId: OrganizationId): QueryResult<Organization>;
|
|
226
216
|
declare function useMember(_args: UseMemberArgs): QueryResult<Member>;
|
|
227
217
|
/**
|
|
228
218
|
* Live; status advances as the indexer reconciles the on-chain
|
|
229
219
|
* deployment. Consumers pattern-match on `data.status` via
|
|
230
220
|
* `matchStatus` (see `@capxul/sdk`).
|
|
221
|
+
*
|
|
222
|
+
* Slice 2 (#457 story 1): wired via
|
|
223
|
+
* `capxul.accounts.safes.retrieve(safeId)`. The SDK method is real
|
|
224
|
+
* post-Withdrawals v1 slice 1; this hook closes the React-side
|
|
225
|
+
* stub so onboarding can subscribe to Safe deploy progress.
|
|
231
226
|
*/
|
|
232
|
-
declare function useSafe(
|
|
227
|
+
declare function useSafe(safeId: SafeId): QueryResult<Safe>;
|
|
233
228
|
declare function useTreasury(_organizationId: OrganizationId): QueryResult<Treasury>;
|
|
234
229
|
/**
|
|
235
230
|
* Org-admin lens only — the hook NEVER returns `secret`.
|
|
@@ -243,13 +238,34 @@ declare function useVirtualAccount(_virtualAccountId: VirtualAccountId): QueryRe
|
|
|
243
238
|
declare function useVirtualCard(_virtualCardId: VirtualCardId): QueryResult<VirtualCard>;
|
|
244
239
|
declare function usePayment(_paymentId: PaymentId): QueryResult<Payment>;
|
|
245
240
|
declare function useTransfer(_transferId: TransferId): QueryResult<Transfer>;
|
|
241
|
+
type UseTokenTransferArgs = {
|
|
242
|
+
readonly txHash: string;
|
|
243
|
+
readonly logIndex: number;
|
|
244
|
+
readonly chainId?: number;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* **NON-CANONICAL** raw on-chain ERC-20 transfer detail. Wired through
|
|
248
|
+
* `capxul.tokenTransfers.retrieve` per slice/02-story2-balance
|
|
249
|
+
* Option-A verdict. Identifier is the canonical on-chain composite
|
|
250
|
+
* `(txHash, logIndex)` so consumers don't have to round-trip through
|
|
251
|
+
* the Convex doc id.
|
|
252
|
+
*
|
|
253
|
+
* Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
|
|
254
|
+
* — the canonical proof manifest tracks canon-aligned hooks only.
|
|
255
|
+
*/
|
|
256
|
+
declare function useTokenTransfer(args: UseTokenTransferArgs): QueryResult<TokenTransfer>;
|
|
246
257
|
/**
|
|
247
258
|
* Immutable once written; `live` semantically only for late
|
|
248
259
|
* `paymentId` / `transferId` attachment per Doc 02 §"balance_ledger".
|
|
249
260
|
*/
|
|
250
261
|
declare function useBalanceLedgerEntry(_args: UseBalanceLedgerEntryArgs): QueryResult<BalanceLedgerEntry>;
|
|
251
262
|
declare function useDocument(_documentId: DocumentId): QueryResult<Document>;
|
|
252
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.retrieve`.
|
|
265
|
+
* Mirrors `useOperation` (the canonical evidence subscription) since
|
|
266
|
+
* the withdrawal resource is operation-shaped at its core.
|
|
267
|
+
*/
|
|
268
|
+
declare function useWithdrawal(withdrawalId: WithdrawalId): QueryResult<Withdrawal>;
|
|
253
269
|
/**
|
|
254
270
|
* The canonical evidence subscription per CANON.md §3.3 —
|
|
255
271
|
* `operationId` + `correlationId` are the cross-layer join keys for
|
|
@@ -340,6 +356,17 @@ declare function usePayments(_filters?: PaymentsFilters): QueryResult<List<Payme
|
|
|
340
356
|
declare function useOrgPayments(_args: OrgScopedFilters): QueryResult<List<Payment>>;
|
|
341
357
|
declare function useTransfers(_filters?: TransfersFilters): QueryResult<List<Transfer>>;
|
|
342
358
|
declare function useOrgTransfers(_args: OrgScopedFilters): QueryResult<List<Transfer>>;
|
|
359
|
+
/**
|
|
360
|
+
* **NON-CANONICAL** raw on-chain ERC-20 transfer feed. Wired through
|
|
361
|
+
* `capxul.tokenTransfers.list` per slice/02-story2-balance Option-A
|
|
362
|
+
* verdict. Will be subsumed by canonical `useTransfers` once the
|
|
363
|
+
* `transfers.*` shape alignment lands. See `core/token-transfers.ts`
|
|
364
|
+
* doc-comment for the full contract.
|
|
365
|
+
*
|
|
366
|
+
* Intentionally NOT in `packages/sdk-react/ops/proof/hook-manifest.ts`
|
|
367
|
+
* — the canonical proof manifest tracks canon-aligned hooks only.
|
|
368
|
+
*/
|
|
369
|
+
declare function useTokenTransfers(filters?: TokenTransfersListInput): QueryResult<TokenTransfersListPage>;
|
|
343
370
|
/**
|
|
344
371
|
* Append-only per-owner balance-delta feed. Live for late
|
|
345
372
|
* `paymentId` / `transferId` attachment per Doc 02.
|
|
@@ -352,8 +379,15 @@ declare function useBalanceLedger(_args: OwnerScopedFilters): QueryResult<List<B
|
|
|
352
379
|
*/
|
|
353
380
|
declare function useDocuments(_filters?: DocumentsFilters): QueryResult<List<Document>>;
|
|
354
381
|
declare function useOrgDocuments(_args: OrgDocumentsFilters): QueryResult<List<Document>>;
|
|
355
|
-
|
|
356
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Withdrawals v1 slice 1 (#440) — wired through `capxul.withdrawals.list`.
|
|
384
|
+
*/
|
|
385
|
+
declare function useWithdrawals(filters?: WithdrawalsFilters): QueryResult<List<Withdrawal>>;
|
|
386
|
+
/**
|
|
387
|
+
* Withdrawals v1 slice 1 (#440) — wired through
|
|
388
|
+
* `capxul.organizations.withdrawals.list`.
|
|
389
|
+
*/
|
|
390
|
+
declare function useOrgWithdrawals(args: OrgScopedFilters): QueryResult<List<Withdrawal>>;
|
|
357
391
|
/**
|
|
358
392
|
* Org-admin lens only — the hook NEVER returns `secret` for any row.
|
|
359
393
|
*/
|
|
@@ -458,4 +492,4 @@ declare function injectedConnector(options?: InjectedConnectorOptions): CapxulCo
|
|
|
458
492
|
*/
|
|
459
493
|
declare function localPrivateKeyConnector(options: LocalPrivateKeyConnectorOptions): CapxulConnector;
|
|
460
494
|
|
|
461
|
-
export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };
|
|
495
|
+
export { CapxulClientProvider, type CapxulClientProviderProps, type CapxulConnector, type CapxulConnectorKind, type CapxulConnectorSession, CapxulProvider, type CapxulProviderProps, CapxulTransportProvider, type CapxulTransportProviderProps, type DocumentsFilters, type InjectedConnectorOptions, type LocalPrivateKeyConnectorOptions, type OrgDocumentsFilters, type OrgScopedFilters, type OwnerRef, type OwnerScopedFilters, type PaginationFilters, type PaymentsFilters, type QueryResult, type TransfersFilters, type UseApiKeyArgs, type UseBalanceLedgerEntryArgs, type UseExternalAccountArgs, type UseMemberArgs, type UseTokenTransferArgs, type VirtualAccountsFilters, type VirtualCardsFilters, type WithdrawalsFilters, createCapxulConfig, injectedConnector, localPrivateKeyConnector, useAccount, useApiKey, useApiKeys, useAuthFlow, useBalanceLedger, useBalanceLedgerEntry, useCapxul, useCapxulStatus, useDocument, useDocuments, useExternalAccount, useExternalAccounts, useKybProfile, useKycProfile, useMe, useMember, useMembers, useOnboardingFlow, useOperation, useOrgDocuments, useOrgPayments, useOrgTransfers, useOrgWithdrawals, useOrganization, useOrganizations, usePayment, usePayments, useProvisioningFlow, useSafe, useSubAccount, useSubAccounts, useTokenTransfer, useTokenTransfers, useTransfer, useTransfers, useTreasury, useVirtualAccount, useVirtualAccounts, useVirtualCard, useVirtualCards, useWebhookEndpoint, useWebhookEndpoints, useWebhookEvent, useWithdrawal, useWithdrawals };
|