@capxul/sdk-react 0.0.0-rc-2cdddbb91
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/README.md +131 -0
- package/dist/index.d.mts +1167 -0
- package/dist/index.mjs +3936 -0
- package/dist/onboarding-controller-DWuvVuC8.mjs +1108 -0
- package/dist/onboarding-controller-DrJiYWfY.d.mts +205 -0
- package/dist/testing/index.d.mts +19 -0
- package/dist/testing/index.mjs +22 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# `@capxul/sdk-react`
|
|
2
|
+
|
|
3
|
+
The React projection over `@capxul/sdk`. It owns provider lifecycle, the one
|
|
4
|
+
canonical identity projection, renderer-neutral identity controllers, TanStack
|
|
5
|
+
Query bindings for rich data, and authenticated-cache cleanup.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
"use client";
|
|
9
|
+
|
|
10
|
+
import { CapxulProvider } from "@capxul/sdk-react";
|
|
11
|
+
|
|
12
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
13
|
+
return (
|
|
14
|
+
<CapxulProvider publishableKey={process.env.NEXT_PUBLIC_CAPXUL_PUBLISHABLE_KEY!}>
|
|
15
|
+
{children}
|
|
16
|
+
</CapxulProvider>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Public shape
|
|
22
|
+
|
|
23
|
+
- `useCapxulIdentity`, `useCapxulDestination`, and `useCapxulTransitions`
|
|
24
|
+
expose the Core SDK identity actor without a parallel React state model.
|
|
25
|
+
- `useCapxulSend` carries caller-owned invocation controls to that actor.
|
|
26
|
+
- `useCapxulAuth` is the stable six-verb application facade.
|
|
27
|
+
- The provider restores Account readiness after a complete authenticated
|
|
28
|
+
session. Account and Organization readiness transitions refresh active
|
|
29
|
+
authenticated queries.
|
|
30
|
+
- CapxulAuthenticationController and CapxulOnboardingController select
|
|
31
|
+
app-owned slots and render no SDK-owned DOM. Organization create begins a
|
|
32
|
+
backend setup and returns its exact ID. The Core SDK actor subscribes to
|
|
33
|
+
that setup. Awaiting authorization, attention, and failure reach actionable
|
|
34
|
+
slots; processing and rechecking reach a finite progress slot.
|
|
35
|
+
- CapxulDashboardAccess combines current setup with current org.me authority.
|
|
36
|
+
Initial and changed scopes wait for verified authority. Unchanged setup
|
|
37
|
+
snapshots reuse cached data. Background authority checks keep an already
|
|
38
|
+
verified ready dashboard mounted. Non-ready setup, sign-out, scope changes,
|
|
39
|
+
and authority errors close access. A revoked membership cannot keep a grant.
|
|
40
|
+
- Rich-data hooks such as `useCapxulProfile`, `useCapxulOrgs`, members, roles,
|
|
41
|
+
treasury, and money hooks remain TanStack Query projections. Personal
|
|
42
|
+
holdings and activity reads start only after the Account is claimed.
|
|
43
|
+
- `CapxulActivity` is the compound activity component. One root owns fetching,
|
|
44
|
+
paging, filtering, searching, the summary numbers, row meaning, memo saving
|
|
45
|
+
and CSV building, and draws nothing. The `.Summary`, `.Filters`, `.Search`,
|
|
46
|
+
`.Rows`, `.LoadMore`, `.Detail` and `.Export` region parts each hand the
|
|
47
|
+
screen one finished slice, so the same component serves a ten-row dashboard
|
|
48
|
+
card and a full transactions page. Paging is infinite scroll through a
|
|
49
|
+
sentinel ref; `.Export` pages at the backend maximum and stops at 5,000 rows
|
|
50
|
+
rather than draining a ledger. Detail state and reads stay scoped to the root
|
|
51
|
+
actor.
|
|
52
|
+
- `capxulKeys` is the public query-key catalog. An application invalidates SDK
|
|
53
|
+
lanes with it instead of keeping a parallel key namespace.
|
|
54
|
+
- `useCapxulHoldings` takes an optional `actor`, and its cache entry is keyed by
|
|
55
|
+
that actor.
|
|
56
|
+
- `CapxulSendMoney` is the compound send component. One root owns the send
|
|
57
|
+
behaviour and draws nothing. The `.Source`, `.Asset`, `.Amount`, `.Recipient`,
|
|
58
|
+
and `.Actions` region parts each hand the screen one finished slice. The
|
|
59
|
+
engine hook stays module-scoped. Both actor paths ship: a personal actor omits
|
|
60
|
+
`.Source` and spends the personal Account; an organization actor holds the
|
|
61
|
+
Budget the payment is drawn from and spends the treasury Account.
|
|
62
|
+
The submitted amount uses the selected registry AssetId and precision. This
|
|
63
|
+
includes 18-decimal WETH.
|
|
64
|
+
- `CapxulContacts` is the compound address-book component. One root owns the
|
|
65
|
+
book behaviour and draws nothing. The `.Summary`, `.List`, and `.Add` region
|
|
66
|
+
parts each hand the screen one finished slice, and a `.List` row carries its
|
|
67
|
+
own `rename`, `hide`, and `unhide` verbs. A screen places any subset. Both
|
|
68
|
+
actor paths ship: a personal actor reads the account book, and an
|
|
69
|
+
organization actor reads the organization book. The `managePeople` capability
|
|
70
|
+
gate stays in the app, on `CapxulOrgMember.Can`.
|
|
71
|
+
- `CapxulPayroll` and `CapxulPayrollRun` are the two payroll compound
|
|
72
|
+
components. `CapxulPayroll` owns the payroll page's reads through its
|
|
73
|
+
`.Summary` and `.Groups` region parts; `CapxulPayrollRun` owns the run
|
|
74
|
+
composer through `.Recipients`, `.Amounts`, `.Asset`, `.Summary`, and
|
|
75
|
+
`.Actions`. A screen places any subset — the pay-now sheet places all five
|
|
76
|
+
run parts, the group sheet places two. `.Actions.blockedReason` names the
|
|
77
|
+
first false fact as a `CapxulPayrollRunBlockedReason` code, never a
|
|
78
|
+
sentence. `.Amounts` prefills a row from the organization's active engagement
|
|
79
|
+
terms when the run's period can state that rate — the value stays editable,
|
|
80
|
+
and an amount the caller passed in `prefill` wins over it. Both engine hooks
|
|
81
|
+
stay module-scoped.
|
|
82
|
+
|
|
83
|
+
Activity groups use AssetId. The SDK resolves symbols and precision only for
|
|
84
|
+
display and CSV output. Assets with the same peg remain separate.
|
|
85
|
+
|
|
86
|
+
Payroll confirmation restores a saved run before enabling submission. An
|
|
87
|
+
uncertain run keeps its period, amounts, recipients, and SDK request key across
|
|
88
|
+
close/reopen and reload. Its fields remain fixed until Core confirms success or terminal closure.
|
|
89
|
+
Use `.Actions.recovery` and `.Actions.recoveryError` to present recovery and
|
|
90
|
+
storage errors. Group editors without `.Actions` keep their editable drafts.
|
|
91
|
+
The application still owns the surrounding sheet and error copy.
|
|
92
|
+
|
|
93
|
+
The packed npm package exposes `@capxul/sdk-react` and
|
|
94
|
+
`@capxul/sdk-react/testing`. The workspace-only `@capxul/sdk-react/headless`
|
|
95
|
+
subpath is not published.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { createCapxulReactTestHarness } from "@capxul/sdk-react/testing";
|
|
99
|
+
|
|
100
|
+
const harness = createCapxulReactTestHarness();
|
|
101
|
+
const tree = harness.provider(harness.authentication(slots));
|
|
102
|
+
await harness.testing.close();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The testing harness uses the real public provider and controllers and imports
|
|
106
|
+
its client factory only through `@capxul/sdk/testing`; it owns no renderer or
|
|
107
|
+
parallel identity state.
|
|
108
|
+
|
|
109
|
+
## Activity documents
|
|
110
|
+
|
|
111
|
+
`CapxulActivity.Detail` exposes `documents`, `selectedDocument`, and
|
|
112
|
+
`selectDocument({ documentHash, contentHash })`. Selection defaults to the
|
|
113
|
+
instruction, then the Movement Memo. `renderDocument()` returns safe semantic
|
|
114
|
+
HTML. `downloadDocument()` returns exact bytes for a deliberate download.
|
|
115
|
+
The host owns the panel and download action. Do not log these results.
|
|
116
|
+
Account or Organization changes clear selection and cancel pending reads.
|
|
117
|
+
These methods replace the receipt-only selector and action.
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
- [Maintainer context](./CONTEXT.md)
|
|
122
|
+
- [Architecture](./docs/architecture.md)
|
|
123
|
+
- [Proof map](./docs/proof.md)
|
|
124
|
+
|
|
125
|
+
## Development
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
vp run --filter @capxul/sdk-react check-types
|
|
129
|
+
vp run --filter @capxul/sdk-react test
|
|
130
|
+
(cd packages/sdk-react && vp pack)
|
|
131
|
+
```
|