cogsbox-state 0.5.457 → 0.5.458

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.457",
3
+ "version": "0.5.458",
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
@@ -426,7 +426,7 @@ export type OptionsType<T extends unknown = unknown, TApiParams = never> = {
426
426
  syncUpdate?: Partial<UpdateTypeDetail>;
427
427
 
428
428
  defaultState?: T;
429
- apiParams?: TApiParams;
429
+
430
430
  dependencies?: any[];
431
431
  };
432
432
 
@@ -708,7 +708,9 @@ export function createCogsStateFromSync<
708
708
  string,
709
709
  {
710
710
  schemas: { defaultValues: any };
711
- apiParamsSchema?: any;
711
+ api?: {
712
+ queryData?: any;
713
+ };
712
714
  [key: string]: any;
713
715
  }
714
716
  >;
@@ -721,10 +723,12 @@ export function createCogsStateFromSync<
721
723
  [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['schemas']['defaultValues'];
722
724
  },
723
725
  {
724
- [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['apiParamsSchema'] extends z.ZodObject<
725
- infer P
726
- >
727
- ? P
726
+ [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['api'] extends {
727
+ queryData: infer Q;
728
+ }
729
+ ? Q extends { _paramType: infer P }
730
+ ? P
731
+ : never
728
732
  : never;
729
733
  }
730
734
  > {
@@ -737,9 +741,9 @@ export function createCogsStateFromSync<
737
741
  const entry = schemas[key];
738
742
  initialState[key] = entry?.schemas?.defaultValues || {};
739
743
 
740
- // Store the apiParamsSchema for each key
741
- if (entry?.apiParamsSchema) {
742
- apiParamsMap[key] = entry.apiParamsSchema;
744
+ // Extract apiParams from the api.queryData._paramType
745
+ if (entry?.api?.queryData?._paramType) {
746
+ apiParamsMap[key] = entry.api.queryData._paramType;
743
747
  }
744
748
  }
745
749
 
@@ -750,7 +754,6 @@ export function createCogsStateFromSync<
750
754
  __apiParamsMap: apiParamsMap,
751
755
  }) as any;
752
756
  }
753
-
754
757
  const {
755
758
  getInitialOptions,
756
759
  getValidationErrors,