refactor(store)!: more reworks (#1860)

* refactor(store): more reworks

* Enable auto save by default

* Store to resource table by default

* Remove share store

* Clean up

* Add close store

* Add store function

* Add lazy store

* Add init to lazy store

* refresh cache in example

* Add get-or-create-store

* Revert "Add get-or-create-store"

This reverts commit 7ffd769240.

* try get first

* Docs

* Use absolute path for store

* more docs

* Allow js to use pre-stored (de)serialize functions

* Fix js get and close store

* Show case how to use pretty json

* Update readme

* Use store instead of `store_builder` in example

* Build

* Fix example

* More docs for StoreBuilder::build

* Add default (de)serialize fn

* Use pretty json by default

* Use `undefined` for empty value in get

* Change files

* Differentiate json null from no value for events

* Add create or existing

* Build

* Rename inner store's inset method to set

* Update readme

* Apply suggestions from code review

* Use close instead

* Update breaking changes

* Return result in resolve_store_path

* Change to close_resource and take &self

* Clean up

* Apply suggestions from code review

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>

* Remove unused pub(crate)

* Update change file

* Expose resolve_store_path

* Remove with_store

* Remove StoreInner from pub and expose is_empty

* Fix wrong jsdoc param

* Update readme

* rename createOrExistingStore to createOrLoad

* make api consistent with the JS implementation, add examples

* fmt

* reintroduce "get existing store" behavior for create_or_load

* rename createOrLoad to newOrExisting

* keep store lock throughout whole new_or_existing_inner

* Remove load

* Missed if load

* Don't make StoreState public

* Remove R: Runtime from Builder

* rename newOrExisting to load, load to reload

* update docs

* rename missing reload fn

* rename builder fn to build()

* fix default permission

* Fix description and create_new logic

* Clippy

* Update docs

* Update docs

* remove create_store command

* remove close_store command since we extend from Resource

* Revert "remove close_store command since we extend from Resource"

This reverts commit 4a29fc8990.

* Reapply "remove close_store command since we extend from Resource"

This reverts commit 70a1830e7d.

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
Tony
2024-10-17 19:14:41 +08:00
committed by GitHub
co-authored by Amr Bashir Lucas Nogueira
parent cfd48b3b2e
commit 8c67d44aef
20 changed files with 1073 additions and 522 deletions
@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-create-store"
description = "Enables the create_store command without any pre-configured scope."
commands.allow = ["create_store"]
[[permission]]
identifier = "deny-create-store"
description = "Denies the create_store command without any pre-configured scope."
commands.deny = ["create_store"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-get-store"
description = "Enables the get_store command without any pre-configured scope."
commands.allow = ["get_store"]
[[permission]]
identifier = "deny-get-store"
description = "Denies the get_store command without any pre-configured scope."
commands.deny = ["get_store"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-reload"
description = "Enables the reload command without any pre-configured scope."
commands.allow = ["reload"]
[[permission]]
identifier = "deny-reload"
description = "Denies the reload command without any pre-configured scope."
commands.deny = ["reload"]
@@ -9,19 +9,20 @@ All operations are enabled by default.
- `allow-create-store`
- `allow-clear`
- `allow-delete`
- `allow-entries`
- `allow-load`
- `allow-get-store`
- `allow-set`
- `allow-get`
- `allow-has`
- `allow-keys`
- `allow-length`
- `allow-load`
- `allow-delete`
- `allow-clear`
- `allow-reset`
- `allow-save`
- `allow-set`
- `allow-keys`
- `allow-values`
- `allow-entries`
- `allow-length`
- `allow-reload`
- `allow-save`
## Permission Table
@@ -61,32 +62,6 @@ Denies the clear command without any pre-configured scope.
<tr>
<td>
`store:allow-create-store`
</td>
<td>
Enables the create_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:deny-create-store`
</td>
<td>
Denies the create_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:allow-delete`
</td>
@@ -165,6 +140,32 @@ Denies the get command without any pre-configured scope.
<tr>
<td>
`store:allow-get-store`
</td>
<td>
Enables the get_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:deny-get-store`
</td>
<td>
Denies the get_store command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:allow-has`
</td>
@@ -269,6 +270,32 @@ Denies the load command without any pre-configured scope.
<tr>
<td>
`store:allow-reload`
</td>
<td>
Enables the reload command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:deny-reload`
</td>
<td>
Denies the reload command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`store:allow-reset`
</td>
+10 -9
View File
@@ -11,17 +11,18 @@ All operations are enabled by default.
"""
permissions = [
"allow-create-store",
"allow-clear",
"allow-delete",
"allow-entries",
"allow-load",
"allow-get-store",
"allow-set",
"allow-get",
"allow-has",
"allow-keys",
"allow-length",
"allow-load",
"allow-delete",
"allow-clear",
"allow-reset",
"allow-save",
"allow-set",
"allow-keys",
"allow-values",
"allow-entries",
"allow-length",
"allow-reload",
"allow-save",
]
+20 -10
View File
@@ -304,16 +304,6 @@
"type": "string",
"const": "deny-clear"
},
{
"description": "Enables the create_store command without any pre-configured scope.",
"type": "string",
"const": "allow-create-store"
},
{
"description": "Denies the create_store command without any pre-configured scope.",
"type": "string",
"const": "deny-create-store"
},
{
"description": "Enables the delete command without any pre-configured scope.",
"type": "string",
@@ -344,6 +334,16 @@
"type": "string",
"const": "deny-get"
},
{
"description": "Enables the get_store command without any pre-configured scope.",
"type": "string",
"const": "allow-get-store"
},
{
"description": "Denies the get_store command without any pre-configured scope.",
"type": "string",
"const": "deny-get-store"
},
{
"description": "Enables the has command without any pre-configured scope.",
"type": "string",
@@ -384,6 +384,16 @@
"type": "string",
"const": "deny-load"
},
{
"description": "Enables the reload command without any pre-configured scope.",
"type": "string",
"const": "allow-reload"
},
{
"description": "Denies the reload command without any pre-configured scope.",
"type": "string",
"const": "deny-reload"
},
{
"description": "Enables the reset command without any pre-configured scope.",
"type": "string",