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/dist/CogsState.d.ts +1 -1
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +8 -4
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +12 -7
package/package.json
CHANGED
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?:
|
|
759
|
-
TSyncSchema['schemas'][K]['schemas']['defaultValues']
|
|
758
|
+
options?: Omit<
|
|
759
|
+
OptionsType<TSyncSchema['schemas'][K]['schemas']['defaultValues']>,
|
|
760
|
+
'apiParams'
|
|
760
761
|
> & {
|
|
761
|
-
apiParams?: any; //
|
|
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(
|
|
778
|
-
|
|
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 {
|