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/dist/CogsState.d.ts +6 -5
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +126 -123
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +13 -6
package/package.json
CHANGED
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]['
|
|
705
|
-
|
|
706
|
-
|
|
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
|
-
|
|
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 {
|