cogsbox-state 0.5.441 → 0.5.442

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.441",
3
+ "version": "0.5.442",
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
@@ -676,13 +676,12 @@ export const createCogsState = <State extends Record<StateKeys, unknown>>(
676
676
 
677
677
  return { useCogsState, setCogsOptions } as CogsApi<State>;
678
678
  };
679
- // or wherever your shape types are
680
679
  export function createCogsStateFromSync<
681
680
  TSyncSchema extends {
682
681
  schemas: Record<
683
682
  string,
684
683
  {
685
- schemas: { defaults: any };
684
+ schemas: { defaultValues: any };
686
685
  [key: string]: any;
687
686
  }
688
687
  >;
@@ -691,22 +690,27 @@ export function createCogsStateFromSync<
691
690
  >(
692
691
  syncSchema: TSyncSchema
693
692
  ): CogsApi<{
694
- [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['schemas']['defaults'];
693
+ [K in keyof TSyncSchema['schemas']]: TSyncSchema['schemas'][K]['schemas']['defaultValues'];
695
694
  }> {
696
695
  const schemas = syncSchema.schemas;
697
696
  const initialState: any = {};
698
697
 
699
- // Extract defaults from each entry
698
+ // Extract defaultValues from each entry
700
699
  for (const key in schemas) {
701
- const entry = schemas[key]!;
702
- initialState[key] = entry.schemas?.defaults || {};
700
+ const entry = schemas[key];
701
+ initialState[key] = entry?.schemas?.defaultValues || {};
703
702
  }
704
703
 
705
- // Store sync metadata
706
- // getGlobalStore.getState().setInitialStateOptions('__syncSchema', syncSchema);
707
- getGlobalStore
708
- .getState()
709
- .setInitialStateOptions('__notifications', syncSchema.notifications);
704
+ // Store sync metadata in each state key's options
705
+ // for (const key in schemas) {
706
+ // const currentOptions =
707
+ // getGlobalStore.getState().getInitialOptions(key) || {};
708
+ // getGlobalStore.getState().setInitialStateOptions(key, {
709
+ // ...currentOptions,
710
+ // syncSchema: schemas[key],
711
+ // notificationChannels: syncSchema.notifications,
712
+ // });
713
+ // }
710
714
 
711
715
  return createCogsState(initialState);
712
716
  }