@capxul/sdk-react 1.0.0-alpha.11 → 1.0.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/dist/index.d.mts +104 -159
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +191 -210
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, use
|
|
|
3
3
|
import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { captureExceptionSync, createCapxulClient, isSettingUpLifecycle } from "@capxul/sdk";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Errors, isCapxulError } from "@capxul/errors";
|
|
7
|
+
import "@capxul/types";
|
|
6
8
|
//#region src/internal/capxul-bootstrap-context.tsx
|
|
7
9
|
const CapxulBootstrapContext = createContext(null);
|
|
8
10
|
function CapxulBootstrapProvider({ value, children }) {
|
|
@@ -147,159 +149,6 @@ function CapxulProvider(props) {
|
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
151
|
//#endregion
|
|
150
|
-
//#region ../errors/src/errors.ts
|
|
151
|
-
const CAPXUL_ERROR_CODES = [
|
|
152
|
-
"NOT_AUTHENTICATED",
|
|
153
|
-
"EMAIL_DELIVERY_FAILED",
|
|
154
|
-
"PROFILE_NOT_FOUND",
|
|
155
|
-
"SMART_ACCOUNT_MISSING",
|
|
156
|
-
"PLAYER_NOT_FOUND",
|
|
157
|
-
"ACCOUNT_NOT_FOUND",
|
|
158
|
-
"PROVIDER_ERROR",
|
|
159
|
-
"INVALID_INPUT",
|
|
160
|
-
"ENV_MISSING",
|
|
161
|
-
"NOT_IMPLEMENTED",
|
|
162
|
-
"VERIFICATION_REQUIRED",
|
|
163
|
-
"INSUFFICIENT_BALANCE",
|
|
164
|
-
"INVALID_RECIPIENT",
|
|
165
|
-
"ROLE_PERMISSION_DENIED",
|
|
166
|
-
"TRANSACTION_FAILED",
|
|
167
|
-
"RATE_LIMITED",
|
|
168
|
-
"NETWORK_ERROR",
|
|
169
|
-
"UNKNOWN",
|
|
170
|
-
"OTP_EXPIRED",
|
|
171
|
-
"SIGNER_REJECTED",
|
|
172
|
-
"CANCELLED",
|
|
173
|
-
"WRONG_STATE"
|
|
174
|
-
];
|
|
175
|
-
var CapxulError = class extends Error {
|
|
176
|
-
code;
|
|
177
|
-
details;
|
|
178
|
-
correlationId;
|
|
179
|
-
layer;
|
|
180
|
-
constructor(code, message, options = {}) {
|
|
181
|
-
super(message, "cause" in options ? { cause: options.cause } : void 0);
|
|
182
|
-
this.name = "CapxulError";
|
|
183
|
-
this.code = code;
|
|
184
|
-
if (options.details !== void 0) this.details = options.details;
|
|
185
|
-
if (options.correlationId !== void 0) this.correlationId = options.correlationId;
|
|
186
|
-
if (options.layer !== void 0) this.layer = options.layer;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
function isCapxulError(value) {
|
|
190
|
-
return value instanceof CapxulError;
|
|
191
|
-
}
|
|
192
|
-
const Errors = {
|
|
193
|
-
notAuthenticated: (message, opts) => new CapxulError("NOT_AUTHENTICATED", message ?? "Not authenticated", opts?.failure_mode ? { details: { failure_mode: opts.failure_mode } } : void 0),
|
|
194
|
-
emailDeliveryFailed: (detail) => new CapxulError("EMAIL_DELIVERY_FAILED", "Failed to send email", { details: { detail } }),
|
|
195
|
-
profileNotFound: (authUserId) => new CapxulError("PROFILE_NOT_FOUND", `Profile not found for user ${authUserId}`, { details: { authUserId } }),
|
|
196
|
-
smartAccountMissing: (authUserId) => new CapxulError("SMART_ACCOUNT_MISSING", "Smart account not provisioned", { details: { authUserId } }),
|
|
197
|
-
playerNotFound: (playerId) => new CapxulError("PLAYER_NOT_FOUND", playerId ? `Openfort player ${playerId} not found` : "Openfort player not found", playerId === void 0 ? void 0 : { details: { playerId } }),
|
|
198
|
-
accountNotFound: (accountId) => new CapxulError("ACCOUNT_NOT_FOUND", accountId ? `Openfort account ${accountId} not found` : "Openfort account not found", accountId === void 0 ? void 0 : { details: { accountId } }),
|
|
199
|
-
providerError: (provider, operation, cause, opts) => {
|
|
200
|
-
const details = {
|
|
201
|
-
provider,
|
|
202
|
-
operation
|
|
203
|
-
};
|
|
204
|
-
if (opts?.failure_mode) details.failure_mode = opts.failure_mode;
|
|
205
|
-
return new CapxulError("PROVIDER_ERROR", `Provider error: ${provider} ${operation}`, {
|
|
206
|
-
cause,
|
|
207
|
-
details
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
invalidInput: (field, reason) => new CapxulError("INVALID_INPUT", `Invalid ${field}: ${reason}`, { details: {
|
|
211
|
-
field,
|
|
212
|
-
reason
|
|
213
|
-
} }),
|
|
214
|
-
envMissing: (name) => new CapxulError("ENV_MISSING", `Environment variable ${name} not configured`, { details: { name } }),
|
|
215
|
-
notImplemented: (domain, method) => new CapxulError("NOT_IMPLEMENTED", `${domain}.${method} is not yet implemented. This feature is planned for a future release.`, { details: {
|
|
216
|
-
domain,
|
|
217
|
-
method
|
|
218
|
-
} }),
|
|
219
|
-
/**
|
|
220
|
-
* Sibling factory to {@link Errors.providerError} for the per-state timeout
|
|
221
|
-
* path in flows (initially ProvisioningFlow's mint_openfort / deploy_safe /
|
|
222
|
-
* register_indexer `after:` timers). Same `PROVIDER_ERROR` code as
|
|
223
|
-
* `providerError`, plus a `details.reason: "timeout"` discriminator so
|
|
224
|
-
* downstream observers can distinguish failure modes without parsing the
|
|
225
|
-
* message string. The redacted message names the timeout budget; the
|
|
226
|
-
* native `cause` carries the same information for `reportError` fidelity.
|
|
227
|
-
*/
|
|
228
|
-
providerTimeout: (provider, operation, timeoutMs) => new CapxulError("PROVIDER_ERROR", `Provider error: ${provider} ${operation} (timeout exceeded ${timeoutMs}ms)`, {
|
|
229
|
-
details: {
|
|
230
|
-
provider,
|
|
231
|
-
operation,
|
|
232
|
-
reason: "timeout"
|
|
233
|
-
},
|
|
234
|
-
cause: /* @__PURE__ */ new Error(`timeout: ${operation} exceeded ${timeoutMs}ms`)
|
|
235
|
-
}),
|
|
236
|
-
verificationRequired: (details) => {
|
|
237
|
-
return new CapxulError("VERIFICATION_REQUIRED", "rail" in details ? `Verification is required before ${details.rail} can use ${details.currentKind}.` : `Verification tier ${details.requiredTier} is required.`, { details });
|
|
238
|
-
},
|
|
239
|
-
insufficientBalance: (asset, available, required) => new CapxulError("INSUFFICIENT_BALANCE", `Insufficient ${asset} balance`, { details: {
|
|
240
|
-
asset,
|
|
241
|
-
available,
|
|
242
|
-
required
|
|
243
|
-
} }),
|
|
244
|
-
invalidRecipient: (reason) => new CapxulError("INVALID_RECIPIENT", `Invalid recipient: ${reason}`, { details: { reason } }),
|
|
245
|
-
/**
|
|
246
|
-
* The org Zodiac Roles modifier REFUSED the spend on-chain (G4 · #547): the
|
|
247
|
-
* member's role condition (per-tx cap, per-day allowance, allowed recipient,
|
|
248
|
-
* or membership) was violated, so `execTransactionWithRole` reverted. This is
|
|
249
|
-
* a PERMISSION denial — explicitly NOT an `INSUFFICIENT_BALANCE` (the treasury
|
|
250
|
-
* held the funds; the role's authority is what bound). `reason` discriminates
|
|
251
|
-
* the violated condition (`over_cap` / `daily_cap` / `not_member` /
|
|
252
|
-
* `disallowed_recipient` / `condition_violation`); leak-safe — no on-chain
|
|
253
|
-
* identifiers ever enter the details.
|
|
254
|
-
*/
|
|
255
|
-
rolePermissionDenied: (details) => new CapxulError("ROLE_PERMISSION_DENIED", `Org role denied this spend on-chain (${details.reason}).`, { details: details.operation === void 0 ? { reason: details.reason } : {
|
|
256
|
-
reason: details.reason,
|
|
257
|
-
operation: details.operation
|
|
258
|
-
} }),
|
|
259
|
-
/**
|
|
260
|
-
* A transaction (or sponsored UserOp) failed. `details.reason` discriminates
|
|
261
|
-
* the failure mode for callers that must distinguish a CONFIRMED on-chain
|
|
262
|
-
* revert (`"onchain_revert"` — the op executed and reverted, e.g. a Zodiac
|
|
263
|
-
* Roles condition violation) from an inconclusive infra failure. A confirmed
|
|
264
|
-
* revert is the ONLY mode the org spend port may map to a roles denial.
|
|
265
|
-
*/
|
|
266
|
-
transactionFailed: (operation, cause, extra) => new CapxulError("TRANSACTION_FAILED", `Transaction failed: ${operation}`, {
|
|
267
|
-
cause,
|
|
268
|
-
details: extra?.reason === void 0 ? { operation } : {
|
|
269
|
-
operation,
|
|
270
|
-
reason: extra.reason
|
|
271
|
-
}
|
|
272
|
-
}),
|
|
273
|
-
rateLimited: (details) => new CapxulError("RATE_LIMITED", "Rate limit exceeded", details === void 0 ? void 0 : { details: { ...details } }),
|
|
274
|
-
networkError: (operation, cause) => new CapxulError("NETWORK_ERROR", `Network error during ${operation}`, {
|
|
275
|
-
cause,
|
|
276
|
-
details: { operation }
|
|
277
|
-
}),
|
|
278
|
-
unknown: (cause) => new CapxulError("UNKNOWN", "Unknown error", { cause }),
|
|
279
|
-
otpExpired: (details) => new CapxulError("OTP_EXPIRED", "Verification code has expired. Request a new one.", details === void 0 ? void 0 : { details: { ...details } }),
|
|
280
|
-
signerRejected: (details) => new CapxulError("SIGNER_REJECTED", "Signer rejected the request.", {
|
|
281
|
-
cause: details.cause,
|
|
282
|
-
details: details.reason === void 0 ? { source: details.source } : {
|
|
283
|
-
source: details.source,
|
|
284
|
-
reason: details.reason
|
|
285
|
-
}
|
|
286
|
-
}),
|
|
287
|
-
cancelled: (details) => new CapxulError("CANCELLED", "Operation was cancelled.", details === void 0 ? void 0 : { details: { ...details } }),
|
|
288
|
-
/**
|
|
289
|
-
* Method called from a flow state where its precondition fails (TA16). The
|
|
290
|
-
* SDK's method API short-circuits with this error before driving the
|
|
291
|
-
* internal state machine. `currentState` is the Effect-machine snapshot
|
|
292
|
-
* tag (stringified — substrate is `@effect/experimental/Machine` per
|
|
293
|
-
* `docs/canon/decisions/state-machine-substrate.md`); `validStates`
|
|
294
|
-
* enumerates the states the method accepts.
|
|
295
|
-
*/
|
|
296
|
-
wrongState: (details) => new CapxulError("WRONG_STATE", `${details.method} called from state '${details.currentState}'; valid states: ${details.validStates.join(", ")}`, { details: {
|
|
297
|
-
...details,
|
|
298
|
-
validStates: [...details.validStates]
|
|
299
|
-
} })
|
|
300
|
-
};
|
|
301
|
-
new Set(CAPXUL_ERROR_CODES);
|
|
302
|
-
//#endregion
|
|
303
152
|
//#region src/internal/require-bootstrapped-client.ts
|
|
304
153
|
/**
|
|
305
154
|
* Narrow the bootstrap-nullable client to a ready client inside a query /
|
|
@@ -319,7 +168,48 @@ function requireBootstrappedClient(client, method) {
|
|
|
319
168
|
//#region src/internal/reactivity-keys.ts
|
|
320
169
|
function actorKey(actor) {
|
|
321
170
|
if (actor === void 0) return ["pending"];
|
|
322
|
-
|
|
171
|
+
if (actor.kind === "account" || actor.kind === "personal") return ["account"];
|
|
172
|
+
if (actor.kind === "org") return ["org", actor.orgId];
|
|
173
|
+
return ["org", actor.organizationId];
|
|
174
|
+
}
|
|
175
|
+
function targetKey(target) {
|
|
176
|
+
if (target === void 0) return "all";
|
|
177
|
+
switch (target.kind) {
|
|
178
|
+
case "handle": return `handle:${target.handle}`;
|
|
179
|
+
case "email": return `email:${target.email}`;
|
|
180
|
+
case "organization": return `organization:${target.handle}`;
|
|
181
|
+
case "orgHandle": return `organization:${target.orgHandle}`;
|
|
182
|
+
case "payee": return `payee:${target.id}`;
|
|
183
|
+
case "payeeId": return `payee:${target.payeeId}`;
|
|
184
|
+
case "destination": return `destination:${target.id}`;
|
|
185
|
+
case "capxulUserId": return `capxulUserId:${target.capxulUserId}`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function activityKey(params) {
|
|
189
|
+
if (params === void 0) return "default";
|
|
190
|
+
return JSON.stringify({
|
|
191
|
+
actor: actorKey(params.actor),
|
|
192
|
+
cursor: params.cursor ?? null,
|
|
193
|
+
limit: params.limit ?? null,
|
|
194
|
+
paymentType: params.paymentType ?? null,
|
|
195
|
+
timing: params.timing ?? null
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function destinationListKey(input) {
|
|
199
|
+
if (input === void 0) return "pending";
|
|
200
|
+
return JSON.stringify({
|
|
201
|
+
actor: actorKey(input.actor),
|
|
202
|
+
target: targetKey(input.target ?? input.ref),
|
|
203
|
+
kind: input.kind ?? null
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function offrampQuoteKey(input) {
|
|
207
|
+
if (input === void 0) return "pending";
|
|
208
|
+
return JSON.stringify({
|
|
209
|
+
actor: actorKey(input.actor),
|
|
210
|
+
destinationId: input.destinationId,
|
|
211
|
+
amount: input.amount
|
|
212
|
+
});
|
|
323
213
|
}
|
|
324
214
|
const capxulKeys = {
|
|
325
215
|
session: ["capxul", "session"],
|
|
@@ -329,6 +219,7 @@ const capxulKeys = {
|
|
|
329
219
|
provisioning: ["capxul", "provisioning"],
|
|
330
220
|
binding: ["capxul", "binding"],
|
|
331
221
|
accountBalance: ["capxul", "accountBalance"],
|
|
222
|
+
currentUser: ["capxul", "currentUser"],
|
|
332
223
|
subAccounts: (accountId) => [
|
|
333
224
|
"capxul",
|
|
334
225
|
"subAccounts",
|
|
@@ -358,6 +249,18 @@ const capxulKeys = {
|
|
|
358
249
|
orgId ?? "pending",
|
|
359
250
|
"treasury"
|
|
360
251
|
],
|
|
252
|
+
orgAccount: (orgId) => [
|
|
253
|
+
"capxul",
|
|
254
|
+
"org",
|
|
255
|
+
orgId ?? "pending",
|
|
256
|
+
"account"
|
|
257
|
+
],
|
|
258
|
+
orgAuditLog: (orgId) => [
|
|
259
|
+
"capxul",
|
|
260
|
+
"org",
|
|
261
|
+
orgId ?? "pending",
|
|
262
|
+
"auditLog"
|
|
263
|
+
],
|
|
361
264
|
actorAddressBook: (actor) => [
|
|
362
265
|
"capxul",
|
|
363
266
|
"actor",
|
|
@@ -417,6 +320,29 @@ const capxulKeys = {
|
|
|
417
320
|
"destinations",
|
|
418
321
|
refKey ?? "pending"
|
|
419
322
|
],
|
|
323
|
+
destinationsScope: ["capxul", "destinations"],
|
|
324
|
+
destinations: (input) => [
|
|
325
|
+
"capxul",
|
|
326
|
+
"destinations",
|
|
327
|
+
destinationListKey(input)
|
|
328
|
+
],
|
|
329
|
+
activity: (params) => [
|
|
330
|
+
"capxul",
|
|
331
|
+
"activity",
|
|
332
|
+
activityKey(params)
|
|
333
|
+
],
|
|
334
|
+
offrampQuote: (input) => [
|
|
335
|
+
"capxul",
|
|
336
|
+
"offramp",
|
|
337
|
+
"quote",
|
|
338
|
+
offrampQuoteKey(input)
|
|
339
|
+
],
|
|
340
|
+
offrampStatus: (offrampId) => [
|
|
341
|
+
"capxul",
|
|
342
|
+
"offramp",
|
|
343
|
+
"status",
|
|
344
|
+
offrampId ?? "pending"
|
|
345
|
+
],
|
|
420
346
|
payments: ["capxul", "payments"],
|
|
421
347
|
payment: (paymentId) => [
|
|
422
348
|
"capxul",
|
|
@@ -474,6 +400,19 @@ function useCapxulProfile() {
|
|
|
474
400
|
});
|
|
475
401
|
}
|
|
476
402
|
//#endregion
|
|
403
|
+
//#region src/hooks/use-capxul-current-user.ts
|
|
404
|
+
function useCapxulCurrentUser(options) {
|
|
405
|
+
const client = useCapxulClientOrNull();
|
|
406
|
+
return useQuery({
|
|
407
|
+
queryKey: capxulKeys.currentUser,
|
|
408
|
+
queryFn: async () => {
|
|
409
|
+
const bootstrappedClient = requireBootstrappedClient(client, "currentUser.get");
|
|
410
|
+
return unwrapCapxulResult(await bootstrappedClient.currentUser.get(), bootstrappedClient._internal.telemetry);
|
|
411
|
+
},
|
|
412
|
+
enabled: client !== null && (options?.enabled ?? true)
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
//#endregion
|
|
477
416
|
//#region src/internal/is-vitest-runtime.ts
|
|
478
417
|
/** True under Vitest — disables hook polling intervals that fight fake timers. */
|
|
479
418
|
function isVitestRuntime() {
|
|
@@ -711,8 +650,11 @@ async function invalidateMoneyState(queryClient, input) {
|
|
|
711
650
|
queryClient.invalidateQueries({ queryKey: capxulKeys.actorInsightsHistory(input.actor) })
|
|
712
651
|
];
|
|
713
652
|
if (input.payment !== void 0) invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.payment(input.payment.id) }));
|
|
714
|
-
if (input.actor.kind === "account") invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance }));
|
|
715
|
-
else
|
|
653
|
+
if (input.actor.kind === "account" || input.actor.kind === "personal") invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.accountBalance }));
|
|
654
|
+
else {
|
|
655
|
+
const orgId = input.actor.kind === "org" ? input.actor.orgId : input.actor.organizationId;
|
|
656
|
+
invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.orgAccount(orgId) }), queryClient.invalidateQueries({ queryKey: capxulKeys.orgTreasury(orgId) }));
|
|
657
|
+
}
|
|
716
658
|
if (input.includeAddressBook === true) invalidations.push(queryClient.invalidateQueries({ queryKey: capxulKeys.actorAddressBook(input.actor) }));
|
|
717
659
|
await Promise.all(invalidations);
|
|
718
660
|
}
|
|
@@ -728,7 +670,7 @@ function useCapxulPay() {
|
|
|
728
670
|
},
|
|
729
671
|
onSuccess: async (payment) => {
|
|
730
672
|
await invalidateMoneyState(queryClient, {
|
|
731
|
-
actor: { kind: "
|
|
673
|
+
actor: { kind: "personal" },
|
|
732
674
|
payment,
|
|
733
675
|
includeAddressBook: true
|
|
734
676
|
});
|
|
@@ -745,7 +687,7 @@ function useCapxulPayout() {
|
|
|
745
687
|
},
|
|
746
688
|
onSuccess: async (payment, variables) => {
|
|
747
689
|
await invalidateMoneyState(queryClient, {
|
|
748
|
-
actor: variables.actor ?? { kind: "
|
|
690
|
+
actor: variables.actor ?? { kind: "personal" },
|
|
749
691
|
payment
|
|
750
692
|
});
|
|
751
693
|
}
|
|
@@ -761,7 +703,23 @@ function useCapxulWithdraw() {
|
|
|
761
703
|
},
|
|
762
704
|
onSuccess: async (payment) => {
|
|
763
705
|
await invalidateMoneyState(queryClient, {
|
|
764
|
-
actor: { kind: "
|
|
706
|
+
actor: { kind: "personal" },
|
|
707
|
+
payment
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function useCapxulCancelPayment() {
|
|
713
|
+
const client = useCapxulClientOrNull();
|
|
714
|
+
const queryClient = useQueryClient();
|
|
715
|
+
return useMutation({
|
|
716
|
+
mutationFn: async (paymentId) => {
|
|
717
|
+
const bootstrappedClient = requireBootstrappedClient(client, "payments.cancel");
|
|
718
|
+
return unwrapCapxulResult(await bootstrappedClient.payments.cancel(paymentId), bootstrappedClient._internal.telemetry, "mutation");
|
|
719
|
+
},
|
|
720
|
+
onSuccess: async (payment) => {
|
|
721
|
+
await invalidateMoneyState(queryClient, {
|
|
722
|
+
actor: { kind: "personal" },
|
|
765
723
|
payment
|
|
766
724
|
});
|
|
767
725
|
}
|
|
@@ -948,24 +906,12 @@ function useCapxulInsightsHistory(actor, options) {
|
|
|
948
906
|
}
|
|
949
907
|
//#endregion
|
|
950
908
|
//#region src/hooks/use-capxul-destinations.ts
|
|
951
|
-
function refKeyForRef(ref) {
|
|
952
|
-
switch (ref.kind) {
|
|
953
|
-
case "handle": return `handle:${ref.handle}`;
|
|
954
|
-
case "email": return `email:${ref.email}`;
|
|
955
|
-
case "orgHandle": return `orgHandle:${ref.orgHandle}`;
|
|
956
|
-
case "capxulUserId": return `capxulUserId:${ref.capxulUserId}`;
|
|
957
|
-
case "payeeId": return `payeeId:${ref.payeeId}`;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
function refCacheKey(input) {
|
|
961
|
-
return input === void 0 ? void 0 : refKeyForRef(input.ref);
|
|
962
|
-
}
|
|
963
909
|
function useCapxulDestinations(input, options) {
|
|
964
910
|
const client = useCapxulClientOrNull();
|
|
965
911
|
return useQuery({
|
|
966
|
-
queryKey: capxulKeys.
|
|
912
|
+
queryKey: capxulKeys.destinations(input),
|
|
967
913
|
queryFn: async () => {
|
|
968
|
-
if (input === void 0) throw Errors.invalidInput("
|
|
914
|
+
if (input === void 0) throw Errors.invalidInput("input", "required for destinations.list");
|
|
969
915
|
const bootstrappedClient = requireBootstrappedClient(client, "destinations.list");
|
|
970
916
|
return unwrapCapxulResult(await bootstrappedClient.destinations.list(input), bootstrappedClient._internal.telemetry);
|
|
971
917
|
},
|
|
@@ -981,8 +927,8 @@ function useCapxulAddDestination() {
|
|
|
981
927
|
return unwrapCapxulResult(await bootstrappedClient.destinations.add(input), bootstrappedClient._internal.telemetry, "mutation");
|
|
982
928
|
},
|
|
983
929
|
onSuccess: async (_value, variables) => {
|
|
984
|
-
await queryClient.invalidateQueries({ queryKey: capxulKeys.
|
|
985
|
-
await queryClient.invalidateQueries({ queryKey: capxulKeys.actorAddressBook(variables.actor ?? { kind: "
|
|
930
|
+
await queryClient.invalidateQueries({ queryKey: capxulKeys.destinationsScope });
|
|
931
|
+
await queryClient.invalidateQueries({ queryKey: capxulKeys.actorAddressBook(variables.actor ?? { kind: "personal" }) });
|
|
986
932
|
}
|
|
987
933
|
});
|
|
988
934
|
}
|
|
@@ -994,12 +940,51 @@ function useCapxulRemoveDestination() {
|
|
|
994
940
|
const bootstrappedClient = requireBootstrappedClient(client, "destinations.remove");
|
|
995
941
|
return unwrapCapxulResult(await bootstrappedClient.destinations.remove(input), bootstrappedClient._internal.telemetry, "mutation");
|
|
996
942
|
},
|
|
997
|
-
onSuccess: async (
|
|
998
|
-
await queryClient.invalidateQueries({ queryKey: capxulKeys.
|
|
943
|
+
onSuccess: async () => {
|
|
944
|
+
await queryClient.invalidateQueries({ queryKey: capxulKeys.destinationsScope });
|
|
999
945
|
}
|
|
1000
946
|
});
|
|
1001
947
|
}
|
|
1002
948
|
//#endregion
|
|
949
|
+
//#region src/hooks/use-capxul-activity.ts
|
|
950
|
+
function useCapxulActivity(params, options) {
|
|
951
|
+
const client = useCapxulClientOrNull();
|
|
952
|
+
return useQuery({
|
|
953
|
+
queryKey: capxulKeys.activity(params),
|
|
954
|
+
queryFn: async () => {
|
|
955
|
+
const bootstrappedClient = requireBootstrappedClient(client, "activity.list");
|
|
956
|
+
return unwrapCapxulResult(await bootstrappedClient.activity.list(params), bootstrappedClient._internal.telemetry);
|
|
957
|
+
},
|
|
958
|
+
enabled: client !== null && (options?.enabled ?? true)
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/hooks/use-capxul-offramp.ts
|
|
963
|
+
function useCapxulOfframpQuote(input, options) {
|
|
964
|
+
const client = useCapxulClientOrNull();
|
|
965
|
+
return useQuery({
|
|
966
|
+
queryKey: capxulKeys.offrampQuote(input),
|
|
967
|
+
queryFn: async () => {
|
|
968
|
+
if (input === void 0) throw Errors.invalidInput("input", "required for useCapxulOfframpQuote");
|
|
969
|
+
const bootstrappedClient = requireBootstrappedClient(client, "offramp.quote");
|
|
970
|
+
return unwrapCapxulResult(await bootstrappedClient.offramp.quote(input), bootstrappedClient._internal.telemetry);
|
|
971
|
+
},
|
|
972
|
+
enabled: client !== null && input !== void 0 && (options?.enabled ?? true)
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
function useCapxulOfframpStatus(offrampId, options) {
|
|
976
|
+
const client = useCapxulClientOrNull();
|
|
977
|
+
return useQuery({
|
|
978
|
+
queryKey: capxulKeys.offrampStatus(offrampId),
|
|
979
|
+
queryFn: async () => {
|
|
980
|
+
if (offrampId === void 0) throw Errors.invalidInput("offrampId", "required for useCapxulOfframpStatus");
|
|
981
|
+
const bootstrappedClient = requireBootstrappedClient(client, "offramp.status");
|
|
982
|
+
return unwrapCapxulResult(await bootstrappedClient.offramp.status(offrampId), bootstrappedClient._internal.telemetry);
|
|
983
|
+
},
|
|
984
|
+
enabled: client !== null && offrampId !== void 0 && (options?.enabled ?? true)
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
//#endregion
|
|
1003
988
|
//#region src/hooks/use-capxul-payroll.ts
|
|
1004
989
|
function useCapxulPayrollRoster(orgId, options) {
|
|
1005
990
|
const client = useCapxulClientOrNull();
|
|
@@ -1133,6 +1118,34 @@ function useCapxulOrgTreasury(orgId, options) {
|
|
|
1133
1118
|
});
|
|
1134
1119
|
}
|
|
1135
1120
|
//#endregion
|
|
1121
|
+
//#region src/hooks/use-capxul-organization-account.ts
|
|
1122
|
+
function useCapxulOrganizationAccount(organizationId, options) {
|
|
1123
|
+
const client = useCapxulClientOrNull();
|
|
1124
|
+
return useQuery({
|
|
1125
|
+
queryKey: capxulKeys.orgAccount(organizationId),
|
|
1126
|
+
queryFn: async () => {
|
|
1127
|
+
if (organizationId === void 0) throw Errors.invalidInput("organizationId", "required for useCapxulOrganizationAccount");
|
|
1128
|
+
const bootstrappedClient = requireBootstrappedClient(client, "org.account.get");
|
|
1129
|
+
return unwrapCapxulResult(await bootstrappedClient.org(organizationId).account.get(), bootstrappedClient._internal.telemetry);
|
|
1130
|
+
},
|
|
1131
|
+
enabled: client !== null && organizationId !== void 0 && (options?.enabled ?? true)
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/hooks/use-capxul-organization-audit-log.ts
|
|
1136
|
+
function useCapxulOrganizationAuditLog(organizationId, options) {
|
|
1137
|
+
const client = useCapxulClientOrNull();
|
|
1138
|
+
return useQuery({
|
|
1139
|
+
queryKey: capxulKeys.orgAuditLog(organizationId),
|
|
1140
|
+
queryFn: async () => {
|
|
1141
|
+
if (organizationId === void 0) throw Errors.invalidInput("organizationId", "required for useCapxulOrganizationAuditLog");
|
|
1142
|
+
const bootstrappedClient = requireBootstrappedClient(client, "org.auditLog");
|
|
1143
|
+
return unwrapCapxulResult(await bootstrappedClient.org(organizationId).auditLog(), bootstrappedClient._internal.telemetry);
|
|
1144
|
+
},
|
|
1145
|
+
enabled: client !== null && organizationId !== void 0 && (options?.enabled ?? true)
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
//#endregion
|
|
1136
1149
|
//#region src/hooks/use-capxul-create-org.ts
|
|
1137
1150
|
function useCapxulCreateOrg() {
|
|
1138
1151
|
const client = useCapxulClient();
|
|
@@ -1331,38 +1344,6 @@ function toQuerySlotState(query) {
|
|
|
1331
1344
|
};
|
|
1332
1345
|
}
|
|
1333
1346
|
//#endregion
|
|
1334
|
-
//#region ../types/src/index.ts
|
|
1335
|
-
const SUPPORTED_CURRENCIES = [
|
|
1336
|
-
{
|
|
1337
|
-
code: "USD",
|
|
1338
|
-
symbol: "$",
|
|
1339
|
-
name: "US Dollar"
|
|
1340
|
-
},
|
|
1341
|
-
{
|
|
1342
|
-
code: "NGN",
|
|
1343
|
-
symbol: "NGN",
|
|
1344
|
-
name: "Nigerian Naira"
|
|
1345
|
-
},
|
|
1346
|
-
{
|
|
1347
|
-
code: "GHS",
|
|
1348
|
-
symbol: "GHS",
|
|
1349
|
-
name: "Ghanaian Cedi"
|
|
1350
|
-
},
|
|
1351
|
-
{
|
|
1352
|
-
code: "KES",
|
|
1353
|
-
symbol: "KSh",
|
|
1354
|
-
name: "Kenyan Shilling"
|
|
1355
|
-
},
|
|
1356
|
-
{
|
|
1357
|
-
code: "UGX",
|
|
1358
|
-
symbol: "USh",
|
|
1359
|
-
name: "Ugandan Shilling"
|
|
1360
|
-
}
|
|
1361
|
-
];
|
|
1362
|
-
SUPPORTED_CURRENCIES.map((currency) => currency.code);
|
|
1363
|
-
Object.fromEntries(SUPPORTED_CURRENCIES.map((currency) => [currency.code, currency.symbol]));
|
|
1364
|
-
Math.floor(Number.MAX_SAFE_INTEGER / 1e3);
|
|
1365
|
-
//#endregion
|
|
1366
1347
|
//#region src/headless/money/SendMoney.tsx
|
|
1367
1348
|
function SendMoney({ initialValue = null, slots, onSent }) {
|
|
1368
1349
|
const pay = useCapxulPay();
|
|
@@ -1480,6 +1461,6 @@ function Destinations({ input, slots }) {
|
|
|
1480
1461
|
return slots.root?.({ children }) ?? children;
|
|
1481
1462
|
}
|
|
1482
1463
|
//#endregion
|
|
1483
|
-
export { AddressBook, CapxulProvider, Destinations, InsightsSummary, PayrollRoster, RequestInbox, SendMoney, capxulAccountScope, capxulOrgScope, useCapxul, useCapxulAccountBalance, useCapxulAccountFund, useCapxulAccountLifecycle, useCapxulAddAddressBookEntry, useCapxulAddDestination, useCapxulAddPayrollRosterLine, useCapxulAddressBook, useCapxulAddressBookEntry, useCapxulApproveInboxRequest, useCapxulAssignRole, useCapxulCancelRequest, useCapxulClientOrNull, useCapxulCompleteOrganizationOnboarding, useCapxulCompletePersonalOnboarding, useCapxulCreateOrg, useCapxulDeclineInboxRequest, useCapxulDestinations, useCapxulHideAddressBookEntry, useCapxulInbox, useCapxulInsightsHistory, useCapxulInsightsSummary, useCapxulInviteMember, useCapxulIssueRequest, useCapxulLabelAddressBookEntry, useCapxulOrg, useCapxulOrgDeployRoles, useCapxulOrgMembers, useCapxulOrgRoles, useCapxulOrgTreasury, useCapxulOrgs, useCapxulPay, useCapxulPayment, useCapxulPayments, useCapxulPayout, useCapxulPayrollRoster, useCapxulProfile, useCapxulReconcileRequests, useCapxulRemoveDestination, useCapxulRemoveMember, useCapxulRemovePayrollRosterLine, useCapxulRequest, useCapxulRequests, useCapxulRunPayroll, useCapxulSession, useCapxulSignIn, useCapxulSignOut, useCapxulSubAccountCreate, useCapxulSubAccountDelete, useCapxulSubAccountRename, useCapxulSubAccountsList, useCapxulSwitchActingEntity, useCapxulTransfer, useCapxulUnhideAddressBookEntry, useCapxulUpdatePayrollRosterLine, useCapxulVerifyOtp, useCapxulWithdraw };
|
|
1464
|
+
export { AddressBook, CapxulProvider, Destinations, InsightsSummary, PayrollRoster, RequestInbox, SendMoney, capxulAccountScope, capxulOrgScope, useCapxul, useCapxulAccountBalance, useCapxulAccountFund, useCapxulAccountLifecycle, useCapxulActivity, useCapxulAddAddressBookEntry, useCapxulAddDestination, useCapxulAddPayrollRosterLine, useCapxulAddressBook, useCapxulAddressBookEntry, useCapxulApproveInboxRequest, useCapxulAssignRole, useCapxulCancelPayment, useCapxulCancelRequest, useCapxulClientOrNull, useCapxulCompleteOrganizationOnboarding, useCapxulCompletePersonalOnboarding, useCapxulCreateOrg, useCapxulCurrentUser, useCapxulDeclineInboxRequest, useCapxulDestinations, useCapxulHideAddressBookEntry, useCapxulInbox, useCapxulInsightsHistory, useCapxulInsightsSummary, useCapxulInviteMember, useCapxulIssueRequest, useCapxulLabelAddressBookEntry, useCapxulOfframpQuote, useCapxulOfframpStatus, useCapxulOrg, useCapxulOrgDeployRoles, useCapxulOrgMembers, useCapxulOrgRoles, useCapxulOrgTreasury, useCapxulOrganizationAccount, useCapxulOrganizationAuditLog, useCapxulOrgs, useCapxulPay, useCapxulPayment, useCapxulPayments, useCapxulPayout, useCapxulPayrollRoster, useCapxulProfile, useCapxulReconcileRequests, useCapxulRemoveDestination, useCapxulRemoveMember, useCapxulRemovePayrollRosterLine, useCapxulRequest, useCapxulRequests, useCapxulRunPayroll, useCapxulSession, useCapxulSignIn, useCapxulSignOut, useCapxulSubAccountCreate, useCapxulSubAccountDelete, useCapxulSubAccountRename, useCapxulSubAccountsList, useCapxulSwitchActingEntity, useCapxulTransfer, useCapxulUnhideAddressBookEntry, useCapxulUpdatePayrollRosterLine, useCapxulVerifyOtp, useCapxulWithdraw };
|
|
1484
1465
|
|
|
1485
1466
|
//# sourceMappingURL=index.mjs.map
|