asasvirtuais 2.2.2 → 2.2.3

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,7 +1,7 @@
1
1
  {
2
2
  "name": "asasvirtuais",
3
3
  "type": "module",
4
- "version": "2.2.2",
4
+ "version": "2.2.3",
5
5
  "description": "React form and action management utilities",
6
6
  "directories": {
7
7
  "packages": "./packages"
@@ -31,6 +31,21 @@ export function indexedInterface<Schema extends DatabaseSchema>(
31
31
 
32
32
  const db = new Dexie(dbName)
33
33
 
34
+
35
+ // Dynamically define the database schema for Dexie from the Zod schema.
36
+ // It marks 'id' as the primary key and indexes all other top-level readable fields.
37
+ const dexieSchema = Object.fromEntries(
38
+ Object.keys(schema).map(tableName => {
39
+ const fields = Object.keys(schema[tableName].readable.shape)
40
+ // 'id' is the primary key, the rest are indexed fields.
41
+ const indexedFields = fields.filter(f => f !== 'id').join(', ')
42
+ return [tableName, `id, ${indexedFields}`]
43
+ })
44
+ )
45
+
46
+ db.version(1).stores(dexieSchema)
47
+
48
+
34
49
  type GenericReadable = z.infer<Schema[keyof Schema]['readable']>
35
50
  type GenericWritable = z.infer<Schema[keyof Schema]['writable']>
36
51