@capxul/sdk 0.1.0-alpha.1 → 0.1.0-alpha.12

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 CHANGED
@@ -1,5 +1,116 @@
1
1
  # @capxul/sdk
2
2
 
3
+ ## 0.1.0-alpha.12
4
+
5
+ ### Minor Changes
6
+
7
+ - f497aef: Publish the post-alpha.11 SDK and React SDK surface: funds v1 sub-account
8
+ runtime coverage, React hook wiring, payments list support, and the latest
9
+ generated Convex API snapshots used by current alpha consumers.
10
+
11
+ ## 0.1.0-alpha.9
12
+
13
+ ### Minor Changes
14
+
15
+ - Add the canonical auth bootstrap flow.
16
+
17
+ `verifyOtp()` now resolves a verified email session into either an
18
+ `existing_member` identity or a `bootstrap_required` continuation. New and
19
+ incomplete members continue through `completeBootstrap()`, which validates a
20
+ server-issued bootstrap token, claims the username, provisions the account/Safe
21
+ through the backend bootstrap path, and returns the authenticated product
22
+ identity. The React SDK adds `useAuthBootstrapFlow()` as the typed first-run
23
+ flow wrapper.
24
+
25
+ ## 0.1.0-alpha.8
26
+
27
+ ### Minor Changes
28
+
29
+ - 57203a4: Withdrawals v1 W2 (#465) — public surface tightening + org-scope create
30
+ - `WithdrawalsCreateInput.destination` no longer accepts `kind`. The
31
+ backend now resolves the `external_account` row by FK and infers
32
+ the kind + rail server-side. Anything that doesn't route to
33
+ `chain_wallet` (or is chain_wallet but non-EVM in slice 1) returns
34
+ `VERIFICATION_REQUIRED` with `details.rail` + `details.currentKind`.
35
+ - `organizations.withdrawals.create` is now a real mutation (no
36
+ longer a `NOT_IMPLEMENTED` stub). Returns the `processing` row
37
+ only — Safe + Zodiac submission orchestration ships in W3+.
38
+ - `Errors.verificationRequired({ rail, currentKind })` factory
39
+ added; the `VERIFICATION_REQUIRED` code now broadens to cover
40
+ both KYC tier gates and unsupported withdrawal rails.
41
+
42
+ **Migration:** Remove `destination.kind` from any
43
+ `capxul.withdrawals.create({ destination: { kind, externalAccountId } })`
44
+ call sites. Pass only `externalAccountId`.
45
+
46
+ ## 0.1.0-alpha.4
47
+
48
+ ### Minor Changes
49
+
50
+ - Post-alpha hardening — WAVE 1 + WAVE 2 cumulative
51
+
52
+ **WAVE 1 (merged 2026-05-03 12:44Z):**
53
+ - S2 story 1: wire onboarding readback hooks (#469) — `me.update`, `accounts.retrieve`, `accounts.update`, `useAccount`, `useSafe`
54
+ - S3 phase 1: Ink reference CLI scaffold + `auth+me` end-to-end against live alpha-3 Convex (#470). Stickiness gate (D3) fired.
55
+ - 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.
56
+
57
+ **WAVE 2 (merged 2026-05-03 12:54-13:16Z):**
58
+ - 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.
59
+ - 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).
60
+
61
+ **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.
62
+
63
+ **Friction issues filed for alpha.4+ polish:**
64
+ - #474 — `me.get` returns `NOT_IMPLEMENTED` when `config.data` is undefined; should be `NOT_AUTHENTICATED`.
65
+ - #475 — `@capxul/sdk/headless` slim entry point excludes xstate flow machines + brand constructors (1.6 MB → much smaller).
66
+ - #477 / #478 — `transfers.*` / `balanceLedger.*` / `treasury` canon-shape alignment with indexer feed.
67
+ - #471 — Vercel-capxul-web preview-deploy systemic failure on api-first base (separate from epic).
68
+
69
+ ## 0.1.0-alpha.3
70
+
71
+ ### Patch Changes
72
+
73
+ - Re-export `tryCatch` from `@capxul/sdk`.
74
+
75
+ `tryCatch` is referenced in `packages/sdk/README.md` (live on npm at
76
+ `0.1.0-alpha.2`) and in `.claude/rules/sdk.md` as the canonical
77
+ async-error helper for SDK operations:
78
+
79
+ ```ts
80
+ import { tryCatch } from "@capxul/sdk";
81
+
82
+ const [err, payment] = await tryCatch(capxul.payments.create({ ... }));
83
+ ```
84
+
85
+ The helper lives at `@repo/observability/try-catch.ts` and is bundled
86
+ into the SDK dist via tsup `noExternal`, but it was never re-exported
87
+ from `packages/sdk/src/index.ts`. Consumers following the README example
88
+ hit `Module '"@capxul/sdk"' has no exported member 'tryCatch'.` at
89
+ import time.
90
+
91
+ Caught during alpha.2 spike-install verification (REVIEW.html, "What's
92
+ not proven" row 6). One-line public-export addition; no runtime change.
93
+
94
+ ## 0.1.0-alpha.2
95
+
96
+ ### Patch Changes
97
+
98
+ - Add `convex` as a peer dependency.
99
+
100
+ `@capxul/sdk`'s bundled `_generated/api` snapshot calls
101
+ `anyApi` / `componentsGeneric` from `convex/server` at runtime — they
102
+ are not just types — and tsup correctly externalizes `convex` /
103
+ `convex/server` / `convex/react` so the consumer's own Convex install
104
+ is reused. The peer was missing from the published manifest, so
105
+ `require('@capxul/sdk')` failed with `Cannot find module 'convex/server'`
106
+ in any spike that hadn't already installed `convex`.
107
+
108
+ `@capxul/sdk-react` mirrors the peer because its bundle re-exports
109
+ flow-machine constructors from `@capxul/sdk` and may transitively
110
+ pull in the same module.
111
+
112
+ Caught during alpha.1 spike-install verification.
113
+
3
114
  ## 0.1.0-alpha.1
4
115
 
5
116
  ### Patch Changes
package/README.md CHANGED
@@ -19,9 +19,9 @@ pnpm add @capxul/sdk @capxul/sdk-react
19
19
  React-flavored entry point lives in `@capxul/sdk-react`. Pick:
20
20
 
21
21
  - **Browser apps (recommended).** Install both. Use
22
- `<CapxulProvider publishableKey="cap_pk_…">` from `@capxul/sdk-react`
23
- and the `useMe` / `useCapxulStatus` hooks. See that package's
24
- README for the lazy-DX example.
22
+ `<CapxulProvider config={{ mode: "publishable-key", publishableKey }}>`
23
+ from `@capxul/sdk-react` and the `useMe` / `useCapxulStatus` hooks.
24
+ See that package's README for the lazy-DX example.
25
25
  - **Server / CLI / scripts.** Install only `@capxul/sdk`. Build a
26
26
  `CapxulClient` directly with your own auth and Convex adapters
27
27
  (see "Server-side construction" below).
@@ -76,11 +76,93 @@ runtime URLs lazily — no need to ship secrets to the client:
76
76
  ```tsx
77
77
  import { CapxulProvider, useMe, useCapxulStatus } from "@capxul/sdk-react";
78
78
 
79
- <CapxulProvider publishableKey="cap_pk_live_…">
79
+ <CapxulProvider
80
+ config={{
81
+ mode: "publishable-key",
82
+ publishableKey: process.env.NEXT_PUBLIC_CAPXUL_PUBLISHABLE_KEY!,
83
+ }}
84
+ >
80
85
  <App />
81
86
  </CapxulProvider>;
82
87
  ```
83
88
 
89
+ ## Publishable-key transport
90
+
91
+ The browser transport accepts a publishable key, then lazily resolves
92
+ runtime URLs by POSTing to `/v1/client/bootstrap` on the first auth or
93
+ `ensureRuntime()` call. The successful backend response is intentionally
94
+ small:
95
+
96
+ ```json
97
+ { "authBaseUrl": "https://<deployment>.convex.site/api/auth", "convexUrl": "https://<deployment>.convex.cloud" }
98
+ ```
99
+
100
+ The resolved runtime is cached for the lifetime of the transport. Concurrent
101
+ callers share one bootstrap request, successful resolutions are reused, and
102
+ failed bootstrap attempts reset so the next call can retry. Tests and
103
+ non-default deployments can inject both `fetchImpl` and an absolute
104
+ `bootstrapUrl`:
105
+
106
+ ```ts
107
+ import { makeHttpTransport, CapxulError } from "@capxul/sdk";
108
+
109
+ const transport = makeHttpTransport({
110
+ mode: "publishable-key",
111
+ publishableKey: process.env.NEXT_PUBLIC_CAPXUL_PUBLISHABLE_KEY!,
112
+ bootstrapUrl: "https://api.capxul.com/v1/client/bootstrap",
113
+ fetchImpl: fetch,
114
+ });
115
+
116
+ await transport.ensureRuntime();
117
+ ```
118
+
119
+ Local setup errors and backend bootstrap errors both use `CapxulError`, but
120
+ carry different `details.source` values:
121
+
122
+ ```ts
123
+ try {
124
+ await transport.ensureRuntime();
125
+ } catch (error) {
126
+ if (error instanceof CapxulError) {
127
+ if (error.details?.source === "sdk-config") {
128
+ // Missing or malformed local config, such as publishableKey or bootstrapUrl.
129
+ }
130
+ if (error.details?.source === "backend-bootstrap") {
131
+ // Sanitized backend refusal, such as NOT_AUTHENTICATED or PERMISSION_DENIED.
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ Runtime proof status:
138
+
139
+ | Surface | Source support | Runtime proof | Status |
140
+ |---|---|---|---|
141
+ | SDK transport | `makeHttpTransport({ mode: "publishable-key", publishableKey })` | `packages/sdk/tests/unit/transport.test.ts` proves config validation, singleflight bootstrap, retry after failure, lifecycle transitions, and sanitized backend errors. | Proven with mocked fetch |
142
+ | React provider | `CapxulProvider config={{ mode: "publishable-key", ... }}` | `packages/sdk-react/ops/proof/react-headless.test.tsx` proves bootstrap before a real `useMe()` read through the provider and lazy Convex data client. | Proven with mocked fetch + headless React |
143
+ | Reference CLI | `bootstrap probe --mock --json` | `apps/reference-cli/scripts/agent-driver.ts` phase 0 and the direct CLI command prove provider/bootstrap/auth ordering and sanitized output. | Proven locally; live endpoint remains manual-key gated |
144
+
145
+ Copy-paste local replication:
146
+
147
+ ```bash
148
+ corepack pnpm --filter @capxul/sdk check-types
149
+ corepack pnpm --filter @capxul/sdk build
150
+ corepack pnpm --filter @capxul/sdk-react check-types
151
+ corepack pnpm --filter @capxul/sdk-react build
152
+ corepack pnpm --filter @capxul/reference-cli check-types
153
+ corepack pnpm --filter @capxul/reference-cli build
154
+ node apps/reference-cli/dist/cli.js bootstrap probe --mock --json
155
+ ```
156
+
157
+ Run the SDK and React SDK builds before the reference CLI typecheck in a
158
+ fresh checkout; the CLI depends on their generated declaration outputs.
159
+
160
+ Expected sanitized pass signal:
161
+
162
+ ```json
163
+ {"command":"bootstrap.probe","ok":true,"mode":"publishable-key","status":"ready","bootstrapRequests":1,"authRequests":1,"keyLengthClass":"provided","mocked":true}
164
+ ```
165
+
84
166
  ## Public surface (alpha)
85
167
 
86
168
  ```ts
@@ -90,7 +172,7 @@ capxul.accounts // create, retrieve, list
90
172
  capxul.organizations // CRUD + members + payments + treasury
91
173
  capxul.payments // create, retrieve, list
92
174
  capxul.invoices // create, retrieve, list
93
- capxul.withdrawals // request, retrieve, list
175
+ capxul.withdrawals // create, retrieve, list
94
176
  capxul.documents // KYC uploads, invoices, receipts, tax forms
95
177
  capxul.flows.{auth, onboarding, provisioning} // XState v5 flows
96
178
  ```