@capxul/sdk-react 1.0.0-alpha.13 → 1.0.0-alpha.14

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.mjs CHANGED
@@ -810,12 +810,29 @@ async function invalidateMoneyState(queryClient, input) {
810
810
  await Promise.all(invalidations);
811
811
  }
812
812
  //#endregion
813
+ //#region src/internal/reject-unresolved-actor.ts
814
+ /**
815
+ * Guard for mutation hooks whose variables carry an optional `actor` field
816
+ * (`useCapxulPay`, `useCapxulPayout`, `useCapxulAddDestination`,
817
+ * `useCapxulRemoveDestination`). Mirrors `requireActorScope` on the query path:
818
+ * an EXPLICITLY-passed `actor: undefined` (the `capxulOrgScope(notYetLoadedOrgId)`
819
+ * footgun) must fail loudly rather than silently fall back to the personal
820
+ * scope. Omitting the `actor` key entirely keeps the personal-scope default.
821
+ *
822
+ * Throws `CapxulError` code `INVALID_INPUT` with `details.field === "actor"`;
823
+ * called inside an async mutationFn it surfaces as `mutation.error: CapxulError`.
824
+ */
825
+ function rejectUnresolvedActor(variables, operation) {
826
+ if (Object.hasOwn(variables, "actor") && variables.actor === void 0) throw Errors.invalidInput("actor", `explicitly provided but undefined for ${operation} — actor scope not yet resolved; omit actor for the personal scope`);
827
+ }
828
+ //#endregion
813
829
  //#region src/hooks/use-capxul-money.ts
814
830
  function useCapxulPay() {
815
831
  const client = useCapxulClientOrNull();
816
832
  const queryClient = useQueryClient();
817
833
  return useMutation({
818
834
  mutationFn: async (input) => {
835
+ rejectUnresolvedActor(input, "payments.pay");
819
836
  const bootstrappedClient = requireBootstrappedClient(client, "payments.pay");
820
837
  return unwrapCapxulResult(await bootstrappedClient.payments.pay(input), bootstrappedClient._internal.telemetry, "mutation");
821
838
  },
@@ -833,6 +850,7 @@ function useCapxulPayout() {
833
850
  const queryClient = useQueryClient();
834
851
  return useMutation({
835
852
  mutationFn: async (input) => {
853
+ rejectUnresolvedActor(input, "payments.payout");
836
854
  const bootstrappedClient = requireBootstrappedClient(client, "payments.payout");
837
855
  return unwrapCapxulResult(await bootstrappedClient.payments.payout(input), bootstrappedClient._internal.telemetry, "mutation");
838
856
  },
@@ -1074,6 +1092,7 @@ function useCapxulAddDestination() {
1074
1092
  const queryClient = useQueryClient();
1075
1093
  return useMutation({
1076
1094
  mutationFn: async (input) => {
1095
+ rejectUnresolvedActor(input, "destinations.add");
1077
1096
  const bootstrappedClient = requireBootstrappedClient(client, "destinations.add");
1078
1097
  return unwrapCapxulResult(await bootstrappedClient.destinations.add(input), bootstrappedClient._internal.telemetry, "mutation");
1079
1098
  },
@@ -1088,6 +1107,7 @@ function useCapxulRemoveDestination() {
1088
1107
  const queryClient = useQueryClient();
1089
1108
  return useMutation({
1090
1109
  mutationFn: async (input) => {
1110
+ rejectUnresolvedActor(input, "destinations.remove");
1091
1111
  const bootstrappedClient = requireBootstrappedClient(client, "destinations.remove");
1092
1112
  return unwrapCapxulResult(await bootstrappedClient.destinations.remove(input), bootstrappedClient._internal.telemetry, "mutation");
1093
1113
  },