@capxul/sdk 0.1.0-alpha.4 → 0.1.0-alpha.8

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.
@@ -0,0 +1,1136 @@
1
+ import { Y as PublicId, A as AccountId$1, S as SafeId$1, d as OrganizationId$1, c as KycProfileId$1, b as ExternalAccountId$1, O as OperationId$1, C as CorrelationId$1, f as SubAccountId$1, B as BalanceLedgerEntryId$1, a as ApiKeyId$1, h as TreasuryId$1, M as MemberId$1, K as KybProfileId$1, N as NextAction$1, P as PaymentId$1, g as TransferId$1, k as WithdrawalId$1, D as DocumentId$1, W as WebhookEndpointId$1, j as WebhookEventId$1, V as VirtualAccountId$1, i as VirtualCardId$1 } from './next-action-DkrwXYay.js';
2
+
3
+ type AccountId = string;
4
+ type OrganizationId = string;
5
+ type MemberId = string;
6
+ type SafeId = string;
7
+ type TreasuryId = string;
8
+ type KycProfileId = string;
9
+ type KybProfileId = string;
10
+ type ExternalAccountId = string;
11
+ type PaymentId = string;
12
+ type WithdrawalId = string;
13
+ type OperationId = string;
14
+ type CorrelationId = string;
15
+ type WebhookEndpointId = string;
16
+ type WebhookEventId = string;
17
+ type SubAccountId = string;
18
+ type VirtualAccountId = string;
19
+ type VirtualCardId = string;
20
+ type TransferId = string;
21
+ type DocumentId = string;
22
+ type BalanceLedgerEntryId = string;
23
+ type ApiKeyId = string;
24
+ /**
25
+ * Lowercased, shape-validated email address.
26
+ */
27
+ type Email = string;
28
+ /**
29
+ * E.164 international phone number.
30
+ */
31
+ type PhoneNumber = string;
32
+ /**
33
+ * 3–30 chars, letter-first, lowercased; globally unique handle.
34
+ */
35
+ type Username = string;
36
+ /**
37
+ * ISO 8601 timestamp in UTC.
38
+ */
39
+ type TimestampIso$1 = string;
40
+ /**
41
+ * Lowercased EVM address .
42
+ */
43
+ type Address = string;
44
+ /**
45
+ * EVM transaction hash.
46
+ */
47
+ type TxHash = string;
48
+ /**
49
+ * Non-negative EVM block number.
50
+ */
51
+ type BlockNumber = number;
52
+ /**
53
+ * EVM chain ID (positive integer).
54
+ */
55
+ type ChainId = number;
56
+ /**
57
+ * Non-negative integer string for token amounts (avoids JS float precision).
58
+ */
59
+ type WeiAmount = string;
60
+ /**
61
+ * Mutually-exclusive-keys union (Stripe-style, no `kind` wrapper) for
62
+ * addressing a user by any of four identifiers: email, phone, username,
63
+ * or accountId. Exactly one field must be present.
64
+ *
65
+ */
66
+ type UserIdentifier$1 = {
67
+ email: Email;
68
+ } | {
69
+ phone: PhoneNumber;
70
+ } | {
71
+ username: Username;
72
+ } | {
73
+ accountId: AccountId;
74
+ };
75
+ /**
76
+ * On-chain settlement detail. Present on the HTTP wire; the `@capxul/sdk`
77
+ * client strips by default — opt back in via `include: ["settlement"]`.
78
+ *
79
+ */
80
+ type Settlement$1 = {
81
+ token: "USDC";
82
+ tokenAmount: WeiAmount;
83
+ contractAddress: Address;
84
+ chain: ChainId;
85
+ txHash?: TxHash;
86
+ blockNumber?: BlockNumber;
87
+ };
88
+ type Money$1 = {
89
+ value: string;
90
+ currency: string;
91
+ };
92
+ type OperationStatus$1 = "accepted" | "processing" | "action_required" | "submitted" | "succeeded" | "failed" | "canceled" | "indexed";
93
+ type OperationSummary$1 = {
94
+ id: OperationId;
95
+ status: OperationStatus$1;
96
+ correlationId: CorrelationId;
97
+ };
98
+ type NextAction = CompleteKycAction | CompleteKybAction | ApproveTransactionAction | SendFundsAction | FollowRedirectAction | ProvideOtpAction | FixDestinationAction | ContactSupportAction | ConfirmFxQuoteAction;
99
+ type CompleteKycAction = {
100
+ kind: "complete_kyc";
101
+ url?: string;
102
+ expiresAt?: string;
103
+ };
104
+ type CompleteKybAction = {
105
+ kind: "complete_kyb";
106
+ url?: string;
107
+ embedToken?: string;
108
+ expiresAt?: string;
109
+ };
110
+ type ApproveTransactionAction = {
111
+ kind: "approve_transaction";
112
+ intentId: string;
113
+ url?: string;
114
+ };
115
+ type SendFundsAction = {
116
+ kind: "send_funds";
117
+ amount: Money$1;
118
+ destination: {
119
+ [key: string]: unknown;
120
+ };
121
+ };
122
+ type FollowRedirectAction = {
123
+ kind: "follow_redirect";
124
+ url: string;
125
+ expiresAt?: string;
126
+ };
127
+ type ProvideOtpAction = {
128
+ kind: "provide_otp";
129
+ channel?: "email" | "sms" | "provider";
130
+ };
131
+ /**
132
+ * Recipient address needs attention. Enriched payload carries
133
+ * invitation metadata for `reason = recipient_not_yet_capxul_user`
134
+ * so the client UI can surface an "invite" CTA.
135
+ *
136
+ */
137
+ type FixDestinationAction = {
138
+ kind: "fix_destination";
139
+ reason: "recipient_not_yet_capxul_user" | "recipient_unreachable_email" | "destination_kyc_blocked" | "invalid_format";
140
+ recipient?: {
141
+ email?: Email;
142
+ phone?: PhoneNumber;
143
+ username?: Username;
144
+ invitationSentAt?: TimestampIso$1;
145
+ invitationExpiresAt?: TimestampIso$1;
146
+ signupUrl?: string;
147
+ };
148
+ };
149
+ /**
150
+ * Cross-currency transfer needs the caller to commit the quoted
151
+ * FX rate before processing begins. Quotes expire — on
152
+ * POST /v1/transfers/{id}/confirm the API returns
153
+ * QUOTE_EXPIRED (409) or QUOTE_NOT_FOUND (404).
154
+ *
155
+ */
156
+ type ConfirmFxQuoteAction = {
157
+ kind: "confirm_fx_quote";
158
+ quoteId: string;
159
+ /**
160
+ * Decimal string (no floats).
161
+ */
162
+ rate: string;
163
+ sourceAmount: Money$1;
164
+ creditAmount: Money$1;
165
+ fees?: Money$1;
166
+ expiresAt: TimestampIso$1;
167
+ };
168
+ type ContactSupportAction = {
169
+ kind: "contact_support";
170
+ reason: string;
171
+ };
172
+ type Account$1 = {
173
+ object: "account";
174
+ id: AccountId;
175
+ email: Email;
176
+ name?: string;
177
+ username?: Username;
178
+ phone?: PhoneNumber;
179
+ /**
180
+ * ISO 3166-1 alpha-2 country code. Self-lens only.
181
+ */
182
+ countryCode?: string;
183
+ /**
184
+ * KYC tier for the account owner. Self-lens only; null until KYC starts.
185
+ */
186
+ kycTier?: 0 | 1 | 2 | 3;
187
+ /**
188
+ * The personal Safe pointer for self-lens reads. Lens-
189
+ * conditional per Doc 02: omitted on co-member and
190
+ * service-key responses for other users' accounts;
191
+ * present on `capxul.me.get()` and on
192
+ * `capxul.accounts.retrieve(selfAccountId)`. The SDK's
193
+ * response parser trusts server-side lens filtering to
194
+ * either include or omit this field.
195
+ *
196
+ */
197
+ primarySafeId?: string;
198
+ /**
199
+ * Self/admin visibility flag for email lookup consent.
200
+ */
201
+ discoverableByEmail?: boolean;
202
+ /**
203
+ * Self/admin visibility flag for phone lookup consent.
204
+ */
205
+ discoverableByPhone?: boolean;
206
+ createdAt: TimestampIso$1;
207
+ updatedAt: TimestampIso$1;
208
+ };
209
+ type Organization$1 = {
210
+ object: "organization";
211
+ id: OrganizationId;
212
+ status: string;
213
+ operation: OperationSummary$1;
214
+ };
215
+ type Member$1 = {
216
+ object: "member";
217
+ id: MemberId;
218
+ organizationId: OrganizationId;
219
+ accountId: AccountId;
220
+ role: "owner" | "finance_manager" | "team_lead" | "viewer";
221
+ createdAt: TimestampIso$1;
222
+ };
223
+ type Safe$1 = {
224
+ object: "safe";
225
+ id: SafeId;
226
+ owner: {
227
+ [key: string]: unknown;
228
+ };
229
+ status: "not_started" | "deploying" | "active" | "failed" | "action_required";
230
+ /**
231
+ * The on-chain Safe address (lowercased). Absent while
232
+ * `status` is `not_started` or `deploying`; present once
233
+ * `status` is `active`.
234
+ *
235
+ */
236
+ address?: string;
237
+ /**
238
+ * The chain the Safe is deployed on. 84532 = Base Sepolia
239
+ * (v1 scope). Absent during pre-deploy statuses.
240
+ *
241
+ */
242
+ chainId?: number;
243
+ /**
244
+ * In-flight operation (typically the deploy operation) during
245
+ * `deploying` status. Absent when the Safe has reached a
246
+ * terminal state.
247
+ *
248
+ */
249
+ operation?: OperationSummary$1;
250
+ };
251
+ type Treasury$1 = {
252
+ object: "treasury";
253
+ id: TreasuryId;
254
+ organizationId: OrganizationId;
255
+ status: string;
256
+ };
257
+ type KycProfile$1 = {
258
+ object: "kyc_profile";
259
+ id: KycProfileId;
260
+ owner: {
261
+ [key: string]: unknown;
262
+ };
263
+ status: "not_started" | "pending" | "action_required" | "verified" | "rejected" | "expired";
264
+ nextAction?: NextAction;
265
+ };
266
+ type KybProfile$1 = {
267
+ object: "kyb_profile";
268
+ id: KybProfileId;
269
+ owner: {
270
+ type: "organization";
271
+ id: OrganizationId;
272
+ };
273
+ /**
274
+ * 6-value KYB state machine. Live-key gating fires on `approved`.
275
+ */
276
+ status: "not_started" | "pending" | "action_required" | "approved" | "rejected" | "expired";
277
+ nextAction?: NextAction;
278
+ };
279
+ /**
280
+ * Withdrawal destination kind. `card_payout` covers
281
+ * Visa/Mastercard push-to-card rails.
282
+ *
283
+ */
284
+ type ExternalAccountKind$1 = "bank" | "evm" | "solana" | "starknet" | "card_payout";
285
+ type ExternalAccount$1 = {
286
+ object: "external_account";
287
+ id: ExternalAccountId;
288
+ kind: ExternalAccountKind$1;
289
+ label?: string;
290
+ status: "pending_verification" | "active" | "revoked" | "failed";
291
+ address?: string;
292
+ iban?: string;
293
+ bic?: string;
294
+ accountHolder?: string;
295
+ network?: "visa" | "mastercard";
296
+ last4?: string;
297
+ createdAt?: TimestampIso$1;
298
+ /**
299
+ * Trust-chain operation summary from the most-recent
300
+ * observability-instrumented mutation that produced or
301
+ * modified this resource. Reflects the LATEST mutation,
302
+ * not the original create. See OperationSummary for
303
+ * shape (id, status, correlationId).
304
+ *
305
+ */
306
+ operation: OperationSummary$1;
307
+ };
308
+ /**
309
+ * Sender or recipient on a Payment. Two-kind discriminator on
310
+ * resolution state: `capxul_user` (identifier resolved to an
311
+ * accountId) vs `pending_recipient` (identifier recognized but
312
+ * the user hasn't signed up yet — see `nextAction.kind =
313
+ * "fix_destination"`). Address fields mirror UserIdentifier.
314
+ *
315
+ */
316
+ type PaymentParty$1 = {
317
+ kind: "capxul_user";
318
+ accountId: AccountId;
319
+ publicName?: string;
320
+ email?: Email;
321
+ phone?: PhoneNumber;
322
+ username?: Username;
323
+ } | {
324
+ kind: "pending_recipient";
325
+ email?: Email;
326
+ phone?: PhoneNumber;
327
+ username?: Username;
328
+ invitationSentAt?: TimestampIso$1;
329
+ invitationExpiresAt?: TimestampIso$1;
330
+ signupUrl?: string;
331
+ };
332
+ type Payment$1 = {
333
+ object: "payment";
334
+ id: PaymentId;
335
+ status: "processing" | "action_required" | "succeeded" | "failed" | "canceled";
336
+ amount?: Money$1;
337
+ reference?: string;
338
+ sender?: PaymentParty$1;
339
+ recipient?: PaymentParty$1;
340
+ operation: OperationSummary$1;
341
+ nextAction?: NextAction;
342
+ settlement?: Settlement$1;
343
+ /**
344
+ * Populated when `status` is `failed`. Absent on any non-failed
345
+ * status. Carries the machine-routable code + human message
346
+ * for UI display per sdk-surface.md §1a.
347
+ *
348
+ */
349
+ error?: {
350
+ /**
351
+ * Value drawn from the `CapxulErrorCode` catalog — see
352
+ * `ErrorEnvelope.error.code` for the 34-value enum. The
353
+ * enum is deliberately inlined (not $ref'd) to avoid
354
+ * TS7056 in the generated schemas export; runtime values
355
+ * still match the canonical catalog one-for-one.
356
+ *
357
+ */
358
+ code: string;
359
+ message: string;
360
+ };
361
+ createdAt?: TimestampIso$1;
362
+ };
363
+ type Withdrawal$1 = {
364
+ object: "withdrawal";
365
+ id: WithdrawalId;
366
+ status: "processing" | "action_required" | "succeeded" | "failed" | "canceled";
367
+ amount?: Money$1;
368
+ reference?: string;
369
+ source?: {
370
+ subAccountId?: SubAccountId;
371
+ };
372
+ destination?: {
373
+ externalAccountId?: ExternalAccountId;
374
+ };
375
+ operation: OperationSummary$1;
376
+ nextAction?: NextAction;
377
+ settlement?: Settlement$1;
378
+ /**
379
+ * Populated when `status` is `failed`. Absent on any non-failed
380
+ * status. Same shape as Payment.error per sdk-surface.md §1a.
381
+ *
382
+ */
383
+ error?: {
384
+ /**
385
+ * Value drawn from the `CapxulErrorCode` catalog — see
386
+ * `ErrorEnvelope.error.code`. Inlined (not $ref'd) to
387
+ * avoid TS7056 in the generated schemas export.
388
+ *
389
+ */
390
+ code: string;
391
+ message: string;
392
+ };
393
+ createdAt?: TimestampIso$1;
394
+ };
395
+ type Operation$1 = {
396
+ object: "operation";
397
+ id: OperationId;
398
+ correlationId: CorrelationId;
399
+ /**
400
+ * Public API remains open-ended for forward-compatible
401
+ * operation projection. Internal TypeScript emitters are
402
+ * compile-time checked against `OPERATION_KINDS` in
403
+ * `@repo/platform-kernel`; generated public clients keep this
404
+ * as `string` so new operation kinds can appear before a
405
+ * client regeneration.
406
+ *
407
+ */
408
+ kind: string;
409
+ status: OperationStatus$1;
410
+ source: string;
411
+ actor: {
412
+ [key: string]: unknown;
413
+ };
414
+ subject?: {
415
+ [key: string]: unknown;
416
+ };
417
+ nextAction?: NextAction;
418
+ /**
419
+ * Present when the operation reached a terminal successful
420
+ * state (`succeeded` or `indexed`) AND produced a public
421
+ * resource. Absent for pre-terminal, failed, or canceled
422
+ * operations, or for operations that don't produce a resource
423
+ * (e.g. pure read operations). Locked by CANON.md §4.33.
424
+ *
425
+ */
426
+ result?: {
427
+ /**
428
+ * Discriminator naming the kind of public resource
429
+ * produced by this operation. Union of the `object:
430
+ * const` values across every primitive declared in
431
+ * sdk-surface.md §1a. Inlined (not extracted as a
432
+ * reusable `PublicResource` schema) to avoid TS7056
433
+ * in the generated schemas export catalog.
434
+ *
435
+ */
436
+ object: "account" | "organization" | "safe" | "treasury" | "kyc_profile" | "kyb_profile" | "external_account" | "payment" | "member" | "withdrawal" | "operation" | "webhook_endpoint" | "webhook_event" | "sub_account" | "virtual_account" | "virtual_card" | "transfer" | "document" | "balance_ledger_entry" | "api_key";
437
+ /**
438
+ * The public ID of the resource this operation produced.
439
+ * Prefix pattern matches `object` (e.g., `pay_01…` when
440
+ * `object = payment`, `txfr_…` when `object = transfer`).
441
+ *
442
+ */
443
+ id: string;
444
+ };
445
+ /**
446
+ * Present when the operation reached a terminal failed state.
447
+ * Same shape as resource-level errors per sdk-surface.md §1a.
448
+ *
449
+ */
450
+ error?: {
451
+ /**
452
+ * Value drawn from the `CapxulErrorCode` catalog — see
453
+ * `ErrorEnvelope.error.code`. Inlined (not $ref'd) to
454
+ * avoid TS7056 in the generated schemas export.
455
+ *
456
+ */
457
+ code: string;
458
+ message: string;
459
+ };
460
+ createdAt: string;
461
+ updatedAt: string;
462
+ };
463
+ type BalanceLedgerEntry$1 = {
464
+ object: "balance_ledger_entry";
465
+ id: BalanceLedgerEntryId;
466
+ safeId: SafeId;
467
+ delta: Money$1;
468
+ runningBalance: Money$1;
469
+ originatedBy: {
470
+ type: "payment" | "withdrawal" | "transfer" | "document" | "external";
471
+ id?: string;
472
+ };
473
+ occurredAt: TimestampIso$1;
474
+ };
475
+ type CreateWebhookEndpointRequest = {
476
+ url: string;
477
+ eventTypes?: Array<string>;
478
+ };
479
+ type WebhookEndpoint$1 = {
480
+ object: "webhook_endpoint";
481
+ id: WebhookEndpointId;
482
+ url: string;
483
+ status: string;
484
+ };
485
+ type WebhookEvent$1 = {
486
+ object: "webhook_event";
487
+ id: WebhookEventId;
488
+ type: string;
489
+ createdAt: string;
490
+ operationId?: OperationId;
491
+ correlationId?: CorrelationId;
492
+ data: {
493
+ [key: string]: unknown;
494
+ };
495
+ };
496
+ /**
497
+ * Venmo-style minimal discoverability result.
498
+ * `exists` tells the caller whether the identifier resolves to a
499
+ * Capxul user. `accountId` + `publicName` present only when exists
500
+ * AND the user opted into discoverability for that identifier kind.
501
+ * `memberSince` is month-precision to resist timing enumeration.
502
+ *
503
+ */
504
+ type AccountLookupResult$1 = {
505
+ email?: Email;
506
+ phone?: PhoneNumber;
507
+ username?: Username;
508
+ exists: boolean;
509
+ accountId?: AccountId;
510
+ publicName?: string;
511
+ /**
512
+ * Month-precision membership stamp, format YYYY-MM.
513
+ */
514
+ memberSince?: string;
515
+ };
516
+ type SubAccountOwnerKind$1 = "account" | "organization";
517
+ /**
518
+ * Named partition under an account or organization. OFF-CHAIN
519
+ * accounting construct — no per-sub-account Safe deploy. Balance
520
+ * AGGREGATES across custody sources (parent Safe stablecoin pool,
521
+ * virtual-account fiat at providers, etc.).
522
+ *
523
+ */
524
+ type SubAccount$1 = {
525
+ object: "sub_account";
526
+ id: SubAccountId;
527
+ parent: {
528
+ kind: SubAccountOwnerKind$1;
529
+ /**
530
+ * AccountId or OrganizationId matching `kind`.
531
+ */
532
+ id: string;
533
+ };
534
+ name: string;
535
+ purpose?: string;
536
+ status: "active" | "archived";
537
+ balance: Money$1;
538
+ /**
539
+ * Per-custody-source balance breakdown. Present only when the
540
+ * caller opts in via `include: ["balancesByCustody"]`.
541
+ *
542
+ */
543
+ balancesByCustody?: Array<{
544
+ source: "root" | "virtual_account";
545
+ amount: Money$1;
546
+ virtualAccountId?: VirtualAccountId;
547
+ }>;
548
+ createdAt: TimestampIso$1;
549
+ };
550
+ type VirtualAccountOwnerKind$1 = "account" | "sub_account" | "organization";
551
+ /**
552
+ * IBAN-bearing fiat receive rail. Funds physically held at an
553
+ * external provider (Bridge, Modern Treasury, etc.); provider is
554
+ * abstracted at the SDK level.
555
+ *
556
+ */
557
+ type VirtualAccount$1 = {
558
+ object: "virtual_account";
559
+ id: VirtualAccountId;
560
+ owner: {
561
+ kind: VirtualAccountOwnerKind$1;
562
+ id: string;
563
+ };
564
+ /**
565
+ * International Bank Account Number (provider-issued).
566
+ */
567
+ iban?: string;
568
+ bic?: string;
569
+ bankName?: string;
570
+ /**
571
+ * ISO 4217 three-letter currency code.
572
+ */
573
+ currency: string;
574
+ status: "provisioning" | "active" | "frozen" | "closed";
575
+ balance: Money$1;
576
+ /**
577
+ * Opaque provider identifier (e.g. `bridge`, `modern_treasury`).
578
+ */
579
+ provider: string;
580
+ createdAt: TimestampIso$1;
581
+ };
582
+ type CreateVirtualAccountRequest = {
583
+ ownerKind: VirtualAccountOwnerKind$1;
584
+ /**
585
+ * AccountId, SubAccountId, or OrganizationId matching `ownerKind`.
586
+ */
587
+ ownerId: string;
588
+ /**
589
+ * ISO 4217 three-letter currency code.
590
+ */
591
+ currency: string;
592
+ };
593
+ type VirtualCardOwnerKind$1 = "account" | "sub_account" | "organization";
594
+ type VirtualCardLimits$1 = {
595
+ dailyLimit?: Money$1;
596
+ monthlyLimit?: Money$1;
597
+ };
598
+ /**
599
+ * Issued card spending the owning sub-account's balance. Active /
600
+ * frozen / canceled lifecycle.
601
+ *
602
+ */
603
+ type VirtualCard$1 = {
604
+ object: "virtual_card";
605
+ id: VirtualCardId;
606
+ owner: {
607
+ kind: VirtualCardOwnerKind$1;
608
+ id: string;
609
+ };
610
+ network: "visa" | "mastercard";
611
+ last4: string;
612
+ currency: string;
613
+ limits?: VirtualCardLimits$1;
614
+ status: "active" | "frozen" | "canceled";
615
+ createdAt: TimestampIso$1;
616
+ };
617
+ type CreateVirtualCardRequest = {
618
+ ownerKind: VirtualCardOwnerKind$1;
619
+ ownerId: string;
620
+ network?: "visa" | "mastercard";
621
+ currency?: string;
622
+ limits?: VirtualCardLimits$1;
623
+ };
624
+ /**
625
+ * Forward-only pagination. `cursor` absent when
626
+ * `hasMore: false`.
627
+ *
628
+ */
629
+ type PageInfo$1 = {
630
+ hasMore: boolean;
631
+ cursor?: string;
632
+ };
633
+ /**
634
+ * Custody-source kind for transfer source/destination. `root` is
635
+ * the parent account/org's main Safe stablecoin pool and takes no
636
+ * `id`.
637
+ *
638
+ */
639
+ type TransferCustody$1 = "root" | "sub_account" | "virtual_account";
640
+ type TransferEndpoint$1 = {
641
+ custody: TransferCustody$1;
642
+ /**
643
+ * SubAccountId or VirtualAccountId when `custody` is not `root`.
644
+ */
645
+ id?: string;
646
+ };
647
+ type TransferOwner = {
648
+ kind: "account" | "organization";
649
+ id: string;
650
+ };
651
+ /**
652
+ * Foreign-exchange block. Present when `source` and `destination`
653
+ * currencies differ. Quote must be confirmed via POST
654
+ * /v1/transfers/{id}/confirm before processing begins (unless
655
+ * `autoConfirm` with `maxSlippageBps` is supplied at create time).
656
+ *
657
+ */
658
+ type TransferFx$1 = {
659
+ /**
660
+ * Decimal string (no floats).
661
+ */
662
+ rate: string;
663
+ quoteId: string;
664
+ expiresAt: TimestampIso$1;
665
+ fees?: Money$1;
666
+ };
667
+ /**
668
+ * Cross-custody internal move within a single owner (not a payment
669
+ * to another party; not a withdrawal out of Capxul). Status
670
+ * lifecycle: processing → succeeded | failed | canceled for
671
+ * same-currency; cross-currency inserts `action_required:
672
+ * confirm_fx_quote` before processing.
673
+ *
674
+ */
675
+ type Transfer$1 = {
676
+ object: "transfer";
677
+ id: TransferId;
678
+ owner: TransferOwner;
679
+ source: TransferEndpoint$1;
680
+ destination: TransferEndpoint$1;
681
+ amount: Money$1;
682
+ debitAmount?: Money$1;
683
+ creditAmount?: Money$1;
684
+ fx?: TransferFx$1;
685
+ reference?: string;
686
+ status: "processing" | "action_required" | "succeeded" | "failed" | "canceled";
687
+ nextAction?: NextAction;
688
+ operation: OperationSummary$1;
689
+ settlement?: Settlement$1;
690
+ /**
691
+ * Populated when `status` is `failed`. Absent on any non-failed
692
+ * status. Same shape as Payment.error per sdk-surface.md §1a.
693
+ *
694
+ */
695
+ error?: {
696
+ /**
697
+ * Value drawn from the `CapxulErrorCode` catalog — see
698
+ * `ErrorEnvelope.error.code`. Inlined (not $ref'd) to
699
+ * avoid TS7056 in the generated schemas export.
700
+ *
701
+ */
702
+ code: string;
703
+ message: string;
704
+ };
705
+ createdAt: TimestampIso$1;
706
+ };
707
+ type DocumentOwner = {
708
+ kind: "account" | "organization";
709
+ id: string;
710
+ };
711
+ /**
712
+ * `type = invoice` — a request for payment addressed to a recipient.
713
+ * Subsumes the former top-level `invoice` primitive.
714
+ * Lifecycle: draft → open → paid → canceled | expired. The
715
+ * `fulfilledBy` link dereferences to the settling Payment when
716
+ * `status = paid` and the caller expands `include: ["fulfilledBy"]`.
717
+ *
718
+ */
719
+ type InvoiceDocument$1 = {
720
+ object: "document";
721
+ id: DocumentId;
722
+ type: "invoice";
723
+ owner: DocumentOwner;
724
+ recipient: UserIdentifier$1;
725
+ amount: Money$1;
726
+ reference?: string;
727
+ dueAt?: TimestampIso$1;
728
+ status: "draft" | "open" | "paid" | "canceled" | "expired";
729
+ fulfilledBy?: PaymentId;
730
+ createdAt: TimestampIso$1;
731
+ };
732
+ /**
733
+ * `type = payroll_run` — per-execution payroll artifact. Shape
734
+ * detail deferred (payroll schedule vs run
735
+ * field set lands in a follow-up design session). Current schema
736
+ * is the minimum required for the discriminator + ownership.
737
+ *
738
+ */
739
+ type PayrollRunDocument$1 = {
740
+ object: "document";
741
+ id: DocumentId;
742
+ type: "payroll_run";
743
+ owner: DocumentOwner;
744
+ scheduleId?: DocumentId;
745
+ totalAmount?: Money$1;
746
+ status?: "draft" | "processing" | "completed" | "failed" | "canceled";
747
+ paymentIds?: Array<PaymentId>;
748
+ createdAt: TimestampIso$1;
749
+ };
750
+ /**
751
+ * `type = payroll_schedule` — recurring payroll metadata. Shape
752
+ * detail deferred
753
+ *
754
+ */
755
+ type PayrollScheduleDocument$1 = {
756
+ object: "document";
757
+ id: DocumentId;
758
+ type: "payroll_schedule";
759
+ owner: DocumentOwner;
760
+ cadence?: "weekly" | "biweekly" | "semimonthly" | "monthly";
761
+ nextRunAt?: TimestampIso$1;
762
+ status?: "active" | "paused" | "canceled";
763
+ createdAt: TimestampIso$1;
764
+ };
765
+ /**
766
+ * `type = receipt` — customer-facing confirmation of a settled
767
+ * payment.
768
+ *
769
+ */
770
+ type ReceiptDocument$1 = {
771
+ object: "document";
772
+ id: DocumentId;
773
+ type: "receipt";
774
+ owner: DocumentOwner;
775
+ for: PaymentId;
776
+ amount: Money$1;
777
+ issuedAt?: TimestampIso$1;
778
+ createdAt: TimestampIso$1;
779
+ };
780
+ /**
781
+ * `type = kyc_upload` — an uploaded KYC artifact (passport scan,
782
+ * utility bill, etc.) attached to a KYC profile.
783
+ *
784
+ */
785
+ type KycUploadDocument$1 = {
786
+ object: "document";
787
+ id: DocumentId;
788
+ type: "kyc_upload";
789
+ owner: DocumentOwner;
790
+ kycProfileId?: KycProfileId;
791
+ storageId: string;
792
+ kind: "passport" | "driver_license" | "national_id" | "utility_bill" | "selfie" | "other";
793
+ status?: "uploaded" | "reviewing" | "approved" | "rejected";
794
+ createdAt: TimestampIso$1;
795
+ };
796
+ /**
797
+ * `type = bank_statement` — uploaded periodic bank statement.
798
+ */
799
+ type BankStatementDocument$1 = {
800
+ object: "document";
801
+ id: DocumentId;
802
+ type: "bank_statement";
803
+ owner: DocumentOwner;
804
+ storageId: string;
805
+ periodStart?: TimestampIso$1;
806
+ periodEnd?: TimestampIso$1;
807
+ createdAt: TimestampIso$1;
808
+ };
809
+ /**
810
+ * `type = tax_form` — uploaded tax form (W2 / W9 / 1099 / etc.).
811
+ */
812
+ type TaxFormDocument$1 = {
813
+ object: "document";
814
+ id: DocumentId;
815
+ type: "tax_form";
816
+ owner: DocumentOwner;
817
+ storageId: string;
818
+ kind: "w2" | "w9" | "1099-nec" | "1099-misc" | "other";
819
+ year: number;
820
+ createdAt: TimestampIso$1;
821
+ };
822
+ /**
823
+ * Unified artifact primitive with `type` discriminator. Subsumes
824
+ * the former top-level `invoice` and `org_payroll_entry` primitives
825
+ * dropped from the v1 catalog. Extending this union with new
826
+ * `type` values is additive.
827
+ *
828
+ */
829
+ type Document$1 = InvoiceDocument$1 | PayrollRunDocument$1 | PayrollScheduleDocument$1 | ReceiptDocument$1 | KycUploadDocument$1 | BankStatementDocument$1 | TaxFormDocument$1;
830
+ /**
831
+ * Discriminated on `type`. Per-type fields are validated at runtime
832
+ * by Zod — unknown fields for a given type return INVALID_INPUT.
833
+ *
834
+ */
835
+ type CreateDocumentRequest = {
836
+ type: "invoice";
837
+ recipient: UserIdentifier$1;
838
+ amount: Money$1;
839
+ reference?: string;
840
+ dueAt?: TimestampIso$1;
841
+ include?: Array<string>;
842
+ } | {
843
+ type: "payroll_schedule";
844
+ cadence?: "weekly" | "biweekly" | "semimonthly" | "monthly";
845
+ nextRunAt?: TimestampIso$1;
846
+ include?: Array<string>;
847
+ } | {
848
+ type: "receipt";
849
+ for: PaymentId;
850
+ include?: Array<string>;
851
+ } | {
852
+ type: "kyc_upload";
853
+ storageId: string;
854
+ kind: "passport" | "driver_license" | "national_id" | "utility_bill" | "selfie" | "other";
855
+ kycProfileId?: KycProfileId;
856
+ include?: Array<string>;
857
+ } | {
858
+ type: "bank_statement";
859
+ storageId: string;
860
+ periodStart?: TimestampIso$1;
861
+ periodEnd?: TimestampIso$1;
862
+ include?: Array<string>;
863
+ } | {
864
+ type: "tax_form";
865
+ storageId: string;
866
+ kind: "w2" | "w9" | "1099-nec" | "1099-misc" | "other";
867
+ year: number;
868
+ include?: Array<string>;
869
+ };
870
+ /**
871
+ * API-key scope vocabulary. `resource:read` +
872
+ * `resource:write` per public primitive, plus three special verbs
873
+ * where they meaningfully differ (`payments:refund`,
874
+ * `accounts:lookup`). 35-scope catalog total. Unknown scopes
875
+ * return INVALID_INPUT with details.field = "scopes" at mint time.
876
+ *
877
+ */
878
+ type Scope$1 = "accounts:read" | "accounts:write" | "accounts:lookup" | "organizations:read" | "organizations:write" | "members:read" | "members:write" | "payments:read" | "payments:write" | "payments:refund" | "transfers:read" | "transfers:write" | "withdrawals:read" | "withdrawals:write" | "external_accounts:read" | "external_accounts:write" | "sub_accounts:read" | "sub_accounts:write" | "virtual_accounts:read" | "virtual_accounts:write" | "virtual_cards:read" | "virtual_cards:write" | "documents:read" | "documents:write" | "kyc_profiles:read" | "kyc_profiles:write" | "kyb_profiles:read" | "kyb_profiles:write" | "api_keys:read" | "api_keys:write" | "webhook_endpoints:read" | "webhook_endpoints:write" | "webhook_events:read" | "operations:read" | "balance_ledger:read" | "treasury:read";
879
+ type ApiKeyEnvironment$1 = "test" | "live";
880
+ type ApiKeyType$1 = "secret" | "publishable";
881
+ /**
882
+ * Mint a new api-key for the organization. `environment` + `type`
883
+ * select the prefix family (cap_test_, cap_live_, cap_pk_test_,
884
+ * cap_pk_live_ ,). `scopes` array is
885
+ * validated against the canonical catalog — unknown values
886
+ * return INVALID_INPUT.
887
+ *
888
+ */
889
+ type CreateApiKeyRequest = {
890
+ label?: string;
891
+ environment: ApiKeyEnvironment$1;
892
+ type: ApiKeyType$1;
893
+ scopes: Array<Scope$1>;
894
+ };
895
+ /**
896
+ * Minted api-key resource. The plaintext `secret` is RETURNED
897
+ * ONCE in the create response; subsequent reads omit it and
898
+ * expose only `prefix` + `tail` (last 4 chars) for display.
899
+ *
900
+ */
901
+ type ApiKey$1 = {
902
+ object: "api_key";
903
+ id: ApiKeyId;
904
+ label?: string;
905
+ environment: ApiKeyEnvironment$1;
906
+ type: ApiKeyType$1;
907
+ /**
908
+ * Public prefix (e.g. `cap_live_`, `cap_pk_test_`).
909
+ */
910
+ prefix?: string;
911
+ /**
912
+ * Last 4 chars of the secret for display.
913
+ */
914
+ tail?: string;
915
+ scopes: Array<Scope$1>;
916
+ status: "active" | "revoked";
917
+ /**
918
+ * Plaintext secret. Returned ONCE on the create response;
919
+ * subsequent retrievals omit this field.
920
+ *
921
+ */
922
+ secret?: string;
923
+ createdAt: TimestampIso$1;
924
+ revokedAt?: TimestampIso$1;
925
+ };
926
+
927
+ /**
928
+ * SDK surface types.
929
+ *
930
+ * Derivation policy (post-codegen-relitigation, 2026-04-20):
931
+ * - Import wire types directly from `@repo/api-contract/gen/types` — the
932
+ * new generator (@hey-api/openapi-ts) emits faithful discriminated
933
+ * unions from OpenAPI `const:` and narrow string-literal enums, so
934
+ * the old `z.infer<typeof schemas.X>` round-trip through Zod (which
935
+ * stripped discriminants via `passthrough()`) is gone.
936
+ * - Rebrand the top-level `id` field on every resource to the kernel's
937
+ * branded ID type per `.claude/rules/typescript-style.md`.
938
+ * - Keep `WithStatus<>` so per-method narrowings are discriminated unions
939
+ * (one variant per status literal), which `Extract<T, { status: K }>`
940
+ * can narrow inside `matchStatus`.
941
+ * - Use `Override<>` ONLY where the OpenAPI source emits `additionalProperties`
942
+ * open shapes (`Safe.owner`, `Operation.actor`, `Operation.subject`) that
943
+ * need the SDK's canonical tagged-ref shape. Every other former
944
+ * `Override<>` site was redundant and has been deleted.
945
+ */
946
+
947
+ type Rebrand<Wire, Id extends PublicId> = Wire & {
948
+ readonly id: Id;
949
+ };
950
+ /**
951
+ * Override-via-intersection helper. Kept for the few wire fields that
952
+ * OpenAPI emits as open-shape (`additionalProperties` → `{ [key:
953
+ * string]: unknown }`) where the SDK surface needs the canonical
954
+ * tagged-ref shape. `Safe.owner`, `Operation.actor`, `Operation.subject`
955
+ * are the current consumers.
956
+ */
957
+ type Override<Wire, Fields> = Wire & Fields;
958
+ /**
959
+ * Distributes over the literal union `S` so the result is a discrim-
960
+ * inated union (one member per status value). `Extract<T, { status:
961
+ * "x" }>` narrows correctly against the output — without the
962
+ * distribution, a plain object with a union-typed `status` field is
963
+ * not a discriminated union and Extract returns `never`.
964
+ *
965
+ * When `S === "action_required"` the variant additionally requires
966
+ * `nextAction: NextAction` (not optional) per Rule D (CANON.md §4.40 +
967
+ * sdk-surface.md §3a): `action_required` is inline on mutation /
968
+ * snapshot responses and callers can safely route via `matchAction`.
969
+ */
970
+ type WithStatus<T, S extends string> = S extends unknown ? T & {
971
+ readonly status: S;
972
+ } & (S extends "action_required" ? {
973
+ readonly nextAction: NextAction$1;
974
+ } : unknown) : never;
975
+ type Money = Money$1;
976
+ type Settlement = Settlement$1;
977
+ type TimestampIso = TimestampIso$1;
978
+ type UserIdentifier = UserIdentifier$1;
979
+ /**
980
+ * Tagged reference to the public resource a succeeded operation
981
+ * produced (per sdk-surface.md §1b `operation`).
982
+ */
983
+ type OperationResult = {
984
+ readonly object: "account" | "organization" | "safe" | "treasury" | "kyc_profile" | "kyb_profile" | "external_account" | "payment" | "member" | "withdrawal" | "operation" | "webhook_endpoint" | "webhook_event" | "sub_account" | "virtual_account" | "virtual_card" | "transfer" | "document" | "balance_ledger_entry" | "api_key";
985
+ readonly id: string;
986
+ };
987
+ /**
988
+ * Terminal-state error sidecar on resources that can fail (Operation,
989
+ * Payment, Withdrawal, Transfer).
990
+ */
991
+ type ResourceError = {
992
+ readonly code: string;
993
+ readonly message: string;
994
+ };
995
+
996
+ type OperationStatus = OperationStatus$1;
997
+ type OperationSummary = Rebrand<OperationSummary$1, OperationId$1> & {
998
+ readonly correlationId: CorrelationId$1;
999
+ };
1000
+ /**
1001
+ * Full operation envelope.
1002
+ *
1003
+ * `actor` and `subject` are hand-overridden because OpenAPI emits
1004
+ * them as `additionalProperties` open-shape; SDK surface carries the
1005
+ * canonical tagged-ref shape.
1006
+ *
1007
+ * `nextAction` is re-asserted against the kernel's `NextAction` union
1008
+ * (9 kinds including `confirm_fx_quote` per §4.58) so callers get the
1009
+ * kernel-branded field types (e.g. `Email`, `PhoneNumber`, `Username`
1010
+ * on `fix_destination.recipient`). The wire carries the same 9 kinds
1011
+ * structurally; the kernel re-assertion preserves the SDK surface's
1012
+ * exhaustiveness contract against drift.
1013
+ *
1014
+ * `result` and `error` come through the generator faithfully, but
1015
+ * we re-type them to narrow the tagged-ref `object` field to the
1016
+ * closed `OperationResult["object"]` catalog.
1017
+ */
1018
+ type Operation = Override<Rebrand<Operation$1, OperationId$1>, {
1019
+ readonly correlationId: CorrelationId$1;
1020
+ readonly actor: {
1021
+ readonly type: string;
1022
+ readonly id: string;
1023
+ };
1024
+ readonly subject?: {
1025
+ readonly type: string;
1026
+ readonly id: string;
1027
+ };
1028
+ readonly nextAction?: NextAction$1;
1029
+ readonly result?: OperationResult | null;
1030
+ readonly error?: ResourceError | null;
1031
+ }>;
1032
+ type Account = Omit<Rebrand<Account$1, AccountId$1>, "kycTier" | "primarySafeId"> & {
1033
+ readonly kycTier?: Account$1["kycTier"] | null;
1034
+ readonly primarySafeId?: SafeId$1 | null;
1035
+ };
1036
+ type AccountLookupResult = AccountLookupResult$1;
1037
+ /**
1038
+ * `owner` is hand-overridden: the OpenAPI source emits it as an
1039
+ * `additionalProperties` open object; SDK surface carries the canonical
1040
+ * tagged-ref shape.
1041
+ */
1042
+ type Safe = Override<Rebrand<Safe$1, SafeId$1>, {
1043
+ readonly owner: {
1044
+ readonly type: "account";
1045
+ readonly id: AccountId$1;
1046
+ } | {
1047
+ readonly type: "organization";
1048
+ readonly id: OrganizationId$1;
1049
+ };
1050
+ }>;
1051
+ type Organization = Rebrand<Organization$1, OrganizationId$1>;
1052
+ type Treasury = Rebrand<Treasury$1, TreasuryId$1> & {
1053
+ readonly organizationId: OrganizationId$1;
1054
+ };
1055
+ type KycProfile = Rebrand<KycProfile$1, KycProfileId$1>;
1056
+ type KybProfile = Rebrand<KybProfile$1, KybProfileId$1>;
1057
+ /**
1058
+ * Trust-chain operation summary is sourced from the wire's nested
1059
+ * `operation: OperationSummary` field (see resources.mdx §canonical
1060
+ * operation envelope). The wire surfaces `correlationId` as a plain
1061
+ * string; we override the nested field with the kernel-branded SDK
1062
+ * `OperationSummary` so callers get `CorrelationId` / `OperationId`
1063
+ * brands. Required at the resource boundary (matches Withdrawal /
1064
+ * Payment / Transfer / Organization).
1065
+ */
1066
+ type ExternalAccount = Override<Rebrand<ExternalAccount$1, ExternalAccountId$1>, {
1067
+ readonly operation: OperationSummary;
1068
+ }>;
1069
+ type ExternalAccountKind = ExternalAccountKind$1;
1070
+ type PageInfo = PageInfo$1;
1071
+ type List<T> = {
1072
+ readonly object: "list";
1073
+ readonly data: readonly T[];
1074
+ readonly page: PageInfo;
1075
+ };
1076
+ type WirePaymentWithBrand = Rebrand<Payment$1, PaymentId$1>;
1077
+ type PaymentStatus = "processing" | "action_required" | "succeeded" | "failed" | "canceled";
1078
+ /**
1079
+ * Full `Payment` — discriminated union on status so `matchStatus`
1080
+ * narrows correctly.
1081
+ */
1082
+ type Payment = WithStatus<WirePaymentWithBrand, PaymentStatus>;
1083
+ /**
1084
+ * Per-method narrowing for `payments.create`. Terminal states
1085
+ * (`succeeded`, `canceled`) arrive out-of-band per Rule D (CANON.md
1086
+ * §4.40 + sdk-surface.md §3a), so the synchronous return carries
1087
+ * only `processing | action_required | failed`.
1088
+ */
1089
+ type CreatePaymentResult = WithStatus<WirePaymentWithBrand, "processing" | "action_required" | "failed">;
1090
+ type PaymentParty = PaymentParty$1;
1091
+ type WireWithdrawalWithBrand = Rebrand<Withdrawal$1, WithdrawalId$1>;
1092
+ /**
1093
+ * Canon-aligned superset (resources.mdx §withdrawal lifecycle note).
1094
+ * Wider than `OperationStatus` because `submitted → completed` is a
1095
+ * withdrawal-specific transition driven by external reconciliation
1096
+ * the operation envelope cannot witness directly. Slice 1 of
1097
+ * Withdrawals v1 (#440) widened this from `PaymentStatus` to match
1098
+ * canon.
1099
+ */
1100
+ type WithdrawalStatus = "draft" | "action_required" | "processing" | "submitted" | "completed" | "failed" | "canceled";
1101
+ type Withdrawal = WithStatus<WireWithdrawalWithBrand, WithdrawalStatus>;
1102
+ type CreateWithdrawalResult = WithStatus<WireWithdrawalWithBrand, "processing" | "action_required" | "failed">;
1103
+ type WireTransferWithBrand = Rebrand<Transfer$1, TransferId$1>;
1104
+ type TransferStatus = PaymentStatus;
1105
+ type Transfer = WithStatus<WireTransferWithBrand, TransferStatus>;
1106
+ type CreateTransferResult = WithStatus<WireTransferWithBrand, "processing" | "action_required" | "failed">;
1107
+ type TransferEndpoint = TransferEndpoint$1;
1108
+ type TransferCustody = TransferCustody$1;
1109
+ type TransferFx = TransferFx$1;
1110
+ type Document = Document$1 & {
1111
+ readonly id: DocumentId$1;
1112
+ };
1113
+ type InvoiceDocument = InvoiceDocument$1;
1114
+ type PayrollRunDocument = PayrollRunDocument$1;
1115
+ type PayrollScheduleDocument = PayrollScheduleDocument$1;
1116
+ type ReceiptDocument = ReceiptDocument$1;
1117
+ type KycUploadDocument = KycUploadDocument$1;
1118
+ type BankStatementDocument = BankStatementDocument$1;
1119
+ type TaxFormDocument = TaxFormDocument$1;
1120
+ type SubAccount = Rebrand<SubAccount$1, SubAccountId$1>;
1121
+ type SubAccountOwnerKind = SubAccountOwnerKind$1;
1122
+ type VirtualAccount = Rebrand<VirtualAccount$1, VirtualAccountId$1>;
1123
+ type VirtualAccountOwnerKind = VirtualAccountOwnerKind$1;
1124
+ type VirtualCard = Rebrand<VirtualCard$1, VirtualCardId$1>;
1125
+ type VirtualCardOwnerKind = VirtualCardOwnerKind$1;
1126
+ type VirtualCardLimits = VirtualCardLimits$1;
1127
+ type WebhookEndpoint = Rebrand<WebhookEndpoint$1, WebhookEndpointId$1>;
1128
+ type WebhookEvent = Rebrand<WebhookEvent$1, WebhookEventId$1>;
1129
+ type ApiKey = Rebrand<ApiKey$1, ApiKeyId$1>;
1130
+ type ApiKeyEnvironment = ApiKeyEnvironment$1;
1131
+ type ApiKeyType = ApiKeyType$1;
1132
+ type Scope = Scope$1;
1133
+ type Member = Rebrand<Member$1, MemberId$1>;
1134
+ type BalanceLedgerEntry = Rebrand<BalanceLedgerEntry$1, BalanceLedgerEntryId$1>;
1135
+
1136
+ export type { WithdrawalStatus as $, Account as A, BalanceLedgerEntry as B, CreatePaymentResult as C, Document as D, ExternalAccount as E, TransferEndpoint as F, TransferFx as G, TransferStatus as H, InvoiceDocument as I, Treasury as J, KybProfile as K, List as L, Member as M, VirtualAccountOwnerKind as N, Operation as O, PageInfo as P, VirtualCard as Q, ReceiptDocument as R, Safe as S, TaxFormDocument as T, UserIdentifier as U, VirtualAccount as V, VirtualCardLimits as W, VirtualCardOwnerKind as X, WebhookEndpoint as Y, WebhookEvent as Z, Withdrawal as _, AccountLookupResult as a, CreateApiKeyRequest as a0, CreateDocumentRequest as a1, CreateWebhookEndpointRequest as a2, CreateVirtualAccountRequest as a3, CreateVirtualCardRequest as a4, ApiKey as b, ApiKeyEnvironment as c, ApiKeyType as d, BankStatementDocument as e, CreateTransferResult as f, CreateWithdrawalResult as g, ExternalAccountKind as h, KycProfile as i, KycUploadDocument as j, Money as k, OperationStatus as l, OperationSummary as m, Organization as n, Payment as o, PaymentParty as p, PaymentStatus as q, PayrollRunDocument as r, PayrollScheduleDocument as s, Scope as t, Settlement as u, SubAccount as v, SubAccountOwnerKind as w, TimestampIso as x, Transfer as y, TransferCustody as z };