cogsbox-state 0.5.446 → 0.5.448

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-state",
3
- "version": "0.5.446",
3
+ "version": "0.5.448",
4
4
  "description": "React state management library with form controls and server sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/CogsState.tsx CHANGED
@@ -37,7 +37,7 @@ import { useCogsConfig } from './CogsStateClient.js';
37
37
  import { Operation } from 'fast-json-patch';
38
38
  import { useInView } from 'react-intersection-observer';
39
39
  import * as z3 from 'zod/v3';
40
- import * as z4 from 'zod/v4';
40
+ import z, * as z4 from 'zod/v4';
41
41
 
42
42
  type Prettify<T> = T extends any ? { [K in keyof T]: T[K] } : never;
43
43
 
@@ -689,6 +689,7 @@ export function createCogsStateFromSync<
689
689
  string,
690
690
  {
691
691
  schemas: { defaultValues: any };
692
+ apiParamsSchema?: z.ZodObject<any>; // Add this type
692
693
  [key: string]: any;
693
694
  }
694
695
  >;
@@ -701,10 +702,12 @@ export function createCogsStateFromSync<
701
702
  [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['schemas']['defaultValues'];
702
703
  },
703
704
  {
704
- [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['apiParams'];
705
- }[keyof {
706
- [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['apiParams'];
707
- }]
705
+ [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['apiParamsSchema'] extends z.ZodObject<
706
+ infer U
707
+ >
708
+ ? { [P in keyof U]: z.infer<U[P]> }
709
+ : never;
710
+ }[keyof TSyncSchema['schemas']]
708
711
  > {
709
712
  const schemas = syncSchema.schemas;
710
713
  const initialState: any = {};
@@ -715,7 +718,11 @@ export function createCogsStateFromSync<
715
718
  initialState[key] = entry?.schemas?.defaultValues || {};
716
719
  }
717
720
 
718
- return createCogsState(initialState);
721
+ // Create the cogs state with proper API params type inference
722
+ return createCogsState(initialState, {
723
+ __fromSyncSchema: true,
724
+ __syncNotifications: syncSchema.notifications,
725
+ });
719
726
  }
720
727
 
721
728
  const {