@capxul/sdk-react 4.2.0-rc.11 → 4.2.0-rc.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.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "source": {
3
- "commit": "12a590f10914e8b056ce54732e6f484f36e060f3",
4
- "tree": "90adc6656be3c1fb0a6e18170877d46081fa2538",
3
+ "commit": "fd5b4d0f124c75f609e469b8673c61f84253c0dc",
4
+ "tree": "d61f0f6b0c83dfc2d405ffc6b55eecf2e9d80f2d",
5
5
  "branch": "codex/programme-rc",
6
6
  "repository": "https://github.com/Xelmar-tech/infrastructure",
7
7
  "lockfileSha256": "5870f53b72706d103220c1bcf733cb4fb71196aea32a9cfbdc277d73cc959264"
8
8
  },
9
9
  "name": "@capxul/sdk-react",
10
- "version": "4.2.0-rc.11"
10
+ "version": "4.2.0-rc.12"
11
11
  }
package/dist/index.d.mts CHANGED
@@ -891,8 +891,14 @@ interface PayrollSummarySlice {
891
891
  }
892
892
  interface PayrollGroupsSlice {
893
893
  readonly groups: readonly PayrollGroupRow[];
894
- readonly save: (input: PayrollGroupInput) => Promise<CapxulResult<PayrollGroupRow>>;
895
- readonly remove: (id: PayrollGroupId) => Promise<CapxulResult<void>>;
894
+ /**
895
+ * R13 (#1968): `options` is the browser attempt the caller captured before the
896
+ * employer pressed the button. It reaches the SDK operation unchanged, so the
897
+ * group's `ui_payroll_action_completed` and the durable `payroll_group_changed`
898
+ * share one correlation. Absent, the write keeps its own invocation context.
899
+ */
900
+ readonly save: (input: PayrollGroupInput, options?: InvocationOptions) => Promise<CapxulResult<PayrollGroupRow>>;
901
+ readonly remove: (id: PayrollGroupId, options?: InvocationOptions) => Promise<CapxulResult<void>>;
896
902
  readonly isSaving: boolean;
897
903
  readonly isLoading: boolean;
898
904
  readonly error: CapxulError | null;
@@ -984,7 +990,14 @@ interface PayrollRunSummarySlice {
984
990
  interface PayrollRunActionsSlice {
985
991
  readonly recovery: "none" | "restoring" | "required" | "unavailable";
986
992
  readonly recoveryError: CapxulError | null;
987
- readonly submit: () => void;
993
+ /**
994
+ * R13 (#1968): `options` is the browser attempt captured before the employer
995
+ * confirmed. It reaches `authorizeRun` unchanged, so the sheet's own
996
+ * `ui_payroll_action_completed` and the durable `payroll_run_transitioned`
997
+ * rows share one correlation. It is NEVER written into the persisted draft —
998
+ * a restored run keeps its own identity, not a stale attempt's.
999
+ */
1000
+ readonly submit: (options?: InvocationOptions) => void;
988
1001
  readonly isSubmitting: boolean;
989
1002
  readonly blocked: boolean;
990
1003
  readonly blockedReason: CapxulPayrollRunBlockedReason | null;
package/dist/index.mjs CHANGED
@@ -880,7 +880,7 @@ function useCapxulUploadImage() {
880
880
  //#endregion
881
881
  //#region src/headless/contacts/use-contacts.ts
882
882
  /** One captured snapshot, or nothing — never a fabricated empty options object. */
883
- const carry = (options) => options === void 0 ? {} : { options };
883
+ const carry$1 = (options) => options === void 0 ? {} : { options };
884
884
  function useContacts(input) {
885
885
  const { actor, onAdded, onFailed } = input;
886
886
  const client = useCapxulClientOrNull();
@@ -922,7 +922,7 @@ function useContacts(input) {
922
922
  setAddError(null);
923
923
  addMutate({
924
924
  ref: refFromTypedText(value),
925
- ...carry(attempt)
925
+ ...carry$1(attempt)
926
926
  }, {
927
927
  onSuccess: (entry) => {
928
928
  setValue("");
@@ -955,17 +955,17 @@ function useContacts(input) {
955
955
  kind: "rename",
956
956
  id,
957
957
  name,
958
- ...carry(toInvocationOptions(options))
958
+ ...carry$1(toInvocationOptions(options))
959
959
  }), [writeMutate]),
960
960
  hide: useCallback((id, options) => writeMutate({
961
961
  kind: "hide",
962
962
  id,
963
- ...carry(toInvocationOptions(options))
963
+ ...carry$1(toInvocationOptions(options))
964
964
  }), [writeMutate]),
965
965
  unhide: useCallback((id, options) => writeMutate({
966
966
  kind: "unhide",
967
967
  id,
968
- ...carry(toInvocationOptions(options))
968
+ ...carry$1(toInvocationOptions(options))
969
969
  }), [writeMutate]),
970
970
  add: {
971
971
  value,
@@ -2579,6 +2579,14 @@ function scopedClient(client, method, orgId) {
2579
2579
  //#region src/headless/payroll/use-payroll.ts
2580
2580
  /** Money reads the same way everywhere on this screen: amount then code. */
2581
2581
  const GRAMMAR$1 = { grammar: "code" };
2582
+ /**
2583
+ * One captured snapshot, or nothing — never a fabricated empty options object,
2584
+ * and never a DOM event a screen wired straight to `onClick`.
2585
+ */
2586
+ function carry(options) {
2587
+ const attempt = toInvocationOptions(options);
2588
+ return attempt === void 0 ? {} : { options: attempt };
2589
+ }
2582
2590
  function toPayrollGroupRow(group) {
2583
2591
  const currency = new Set(group.members.map((member) => member.currency)).size === 1 ? group.members[0]?.currency : void 0;
2584
2592
  return {
@@ -2618,16 +2626,17 @@ function usePayroll(orgId) {
2618
2626
  const write = useMutation({
2619
2627
  mutationFn: async (command) => {
2620
2628
  const payroll = scopedClient(client, CAPXUL_OPERATIONS.org.payroll.groups[command.kind], orgId).payroll;
2629
+ const controls = toInvocationControls(command.options);
2621
2630
  if (command.kind === "remove") {
2622
- unwrapCapxulResult(await payroll.groups.remove(command.id));
2631
+ unwrapCapxulResult(await payroll.groups.remove(command.id, controls));
2623
2632
  return null;
2624
2633
  }
2625
- return unwrapCapxulResult(await payroll.groups.save(command.input));
2634
+ return unwrapCapxulResult(await payroll.groups.save(command.input, controls));
2626
2635
  },
2627
2636
  onSettled: invalidate
2628
2637
  });
2629
2638
  const mutateAsync = write.mutateAsync;
2630
- const save = useCallback(async (input) => {
2639
+ const save = useCallback(async (input, options) => {
2631
2640
  const refusal = invalidGroup(input);
2632
2641
  if (refusal !== null) return {
2633
2642
  ok: false,
@@ -2636,7 +2645,8 @@ function usePayroll(orgId) {
2636
2645
  try {
2637
2646
  const saved = await mutateAsync({
2638
2647
  kind: "save",
2639
- input
2648
+ input,
2649
+ ...carry(options)
2640
2650
  });
2641
2651
  return saved === null ? {
2642
2652
  ok: false,
@@ -2652,11 +2662,12 @@ function usePayroll(orgId) {
2652
2662
  };
2653
2663
  }
2654
2664
  }, [mutateAsync]);
2655
- const remove = useCallback(async (id) => {
2665
+ const remove = useCallback(async (id, options) => {
2656
2666
  try {
2657
2667
  await mutateAsync({
2658
2668
  kind: "remove",
2659
- id
2669
+ id,
2670
+ ...carry(options)
2660
2671
  });
2661
2672
  return {
2662
2673
  ok: true,
@@ -3174,11 +3185,12 @@ function usePayrollRun(input) {
3174
3185
  amountsParse: total !== null
3175
3186
  });
3176
3187
  const authorize = useMutation({
3177
- mutationFn: async (candidate) => {
3188
+ mutationFn: async ({ candidate, options }) => {
3178
3189
  if (candidate.scope !== currentScope.current) throw Errors.notAuthenticated();
3179
3190
  return executeRunDraft(candidate, async (persisted, onRequestKey, onResolved) => {
3180
3191
  if (candidate.scope === currentScope.current) setDraft(persisted);
3181
3192
  return unwrapCapxulResult(await scopedClient(client, CAPXUL_OPERATIONS.org.payroll.authorizeRun, orgId).payroll.authorizeRun(persisted.input, {
3193
+ ...toInvocationControls(options),
3182
3194
  onResolved,
3183
3195
  onRequestKey: (key) => {
3184
3196
  if (candidate.scope !== currentScope.current) throw Errors.notAuthenticated();
@@ -3187,14 +3199,15 @@ function usePayrollRun(input) {
3187
3199
  }));
3188
3200
  });
3189
3201
  },
3190
- onSettled: (_run, _error, candidate) => {
3202
+ onSettled: (_run, _error, { candidate }) => {
3191
3203
  queryClient.invalidateQueries({ queryKey: capxulKeys.payrollRuns(orgId) });
3192
3204
  if (candidate.scope === currentScope.current) restoreDraft(candidate.scope);
3193
3205
  }
3194
3206
  });
3195
3207
  const totalDisplay = total === null ? null : formatMoney(total, GRAMMAR);
3196
3208
  const authorizeMutate = authorize.mutate;
3197
- const submit = useCallback(() => {
3209
+ const submit = useCallback((options) => {
3210
+ const attempt = toInvocationOptions(options);
3198
3211
  const permissionId = budgets[0]?.id;
3199
3212
  if (blockedReason !== null || submitGate.current || draftBlocked || draftScope === null || assetMoney === null || selectedAsset === null) return;
3200
3213
  if (permissionId === void 0 || totalDisplay === null || parsedAmounts === null) return;
@@ -3236,7 +3249,10 @@ function usePayrollRun(input) {
3236
3249
  }
3237
3250
  };
3238
3251
  submitGate.current = true;
3239
- authorizeMutate(candidate, {
3252
+ authorizeMutate({
3253
+ candidate,
3254
+ ...attempt === void 0 ? {} : { options: attempt }
3255
+ }, {
3240
3256
  onSuccess: (run) => {
3241
3257
  if (candidate.scope === currentScope.current) onRun({
3242
3258
  id: run.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk-react",
3
- "version": "4.2.0-rc.11",
3
+ "version": "4.2.0-rc.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Xelmar-tech/infrastructure.git",
@@ -26,7 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@capxul/sdk": "4.2.0-rc.11"
29
+ "@capxul/sdk": "4.2.0-rc.12"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@tanstack/react-query": "^5.66.9",
@@ -43,9 +43,9 @@
43
43
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
44
44
  "vite-plus": "0.3.0",
45
45
  "vitest": "4.1.11",
46
- "@capxul/types": "0.3.0",
46
+ "@capxul/typescript-config": "0.0.0",
47
47
  "@capxul/errors": "0.3.0",
48
- "@capxul/typescript-config": "0.0.0"
48
+ "@capxul/types": "0.3.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@tanstack/react-query": "^5.66.9",