cogsbox-shape 0.5.199 → 0.5.201

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.
@@ -1,28 +1,14 @@
1
- import { createCogsState, createPluginContext } from "cogsbox-state";
2
- import { createSchemaBox, s, schema } from "cogsbox-shape";
3
- function createShapeInitialState(shape) {
4
- return shape.generateDefaults();
5
- }
1
+ import { createPluginContext } from "cogsbox-state";
6
2
  const { createPlugin } = createPluginContext();
7
- export function createShapePlugin(shape) {
8
- return createPlugin("shape").initialState(() => createShapeInitialState(shape));
3
+ export function createShapePlugin(box) {
4
+ return createPlugin("shape").initialState(() => {
5
+ const state = {};
6
+ for (const key of Object.keys(box)) {
7
+ const entry = box[key];
8
+ if (!entry)
9
+ continue;
10
+ state[key] = entry.generateDefaults();
11
+ }
12
+ return state;
13
+ });
9
14
  }
10
- const shapeStateSchema = schema({
11
- _tableName: "shape_state",
12
- name: s.sqlite({ type: "varchar", length: 100 }).clientInput({
13
- value: "",
14
- }),
15
- });
16
- export const shapeBox = createSchemaBox({ shapeState: shapeStateSchema }, { shapeState: {} });
17
- export const myShape = shapeBox.shapeState;
18
- export const shapePlugin = createShapePlugin(myShape);
19
- // type ShapeCogsState = ReturnType<
20
- // typeof createCogsState<{}, readonly [typeof shapePlugin]>
21
- // >;
22
- // const shapeState = createCogsState(
23
- // {},
24
- // {
25
- // plugins: [shapePlugin],
26
- // },
27
- // );
28
- // export const { useCogsState } = shapeState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.199",
3
+ "version": "0.5.201",
4
4
  "description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",