cogsbox-state 0.5.450 → 0.5.451

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.450",
3
+ "version": "0.5.451",
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
@@ -724,6 +724,7 @@ type UseCogsStateFromSync<
724
724
  ): StateObject<TSyncSchema['schemas'][K]['schemas']['defaultValues']>;
725
725
  };
726
726
  // Simplified approach that actually works
727
+ // Fixed version that properly handles the apiParams type
727
728
  export function createCogsStateFromSync<
728
729
  TSyncSchema extends {
729
730
  schemas: Record<
@@ -752,13 +753,13 @@ export function createCogsStateFromSync<
752
753
  __syncNotifications: syncSchema.notifications,
753
754
  });
754
755
 
755
- // Create a wrapper that validates API params at runtime
756
756
  const useCogsState = <K extends keyof TSyncSchema['schemas']>(
757
757
  stateKey: K,
758
- options?: OptionsType<
759
- TSyncSchema['schemas'][K]['schemas']['defaultValues']
758
+ options?: Omit<
759
+ OptionsType<TSyncSchema['schemas'][K]['schemas']['defaultValues']>,
760
+ 'apiParams'
760
761
  > & {
761
- apiParams?: any; // We'll validate this at runtime
762
+ apiParams?: any; // Allow any apiParams, validate at runtime
762
763
  }
763
764
  ): StateObject<TSyncSchema['schemas'][K]['schemas']['defaultValues']> => {
764
765
  // Runtime validation of API params
@@ -773,10 +774,14 @@ export function createCogsStateFromSync<
773
774
  }
774
775
  }
775
776
 
777
+ // Create options without apiParams for the base call
778
+ const { apiParams, ...baseOptions } = options || {};
779
+
776
780
  // Cast to the correct type since we know it's properly typed
777
- return baseApi.useCogsState(stateKey as any, options as any) as StateObject<
778
- TSyncSchema['schemas'][K]['schemas']['defaultValues']
779
- >;
781
+ return baseApi.useCogsState(
782
+ stateKey as any,
783
+ baseOptions as any
784
+ ) as StateObject<TSyncSchema['schemas'][K]['schemas']['defaultValues']>;
780
785
  };
781
786
 
782
787
  return {