@furystack/repository 10.0.18 → 10.0.20
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/README.md +9 -9
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Repository implementation for FuryStack.
|
|
4
4
|
With a repository, you can implement entity-level business logic in an easy and structured way.
|
|
5
|
-
You can authorize, manipulate and observe CRUD operations.
|
|
5
|
+
You can authorize, manipulate, and observe CRUD operations.
|
|
6
6
|
|
|
7
|
-
## Setting
|
|
7
|
+
## Setting Up a Repository
|
|
8
8
|
|
|
9
|
-
You can set up a repository
|
|
9
|
+
You can set up a repository as follows:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
class MyModel {
|
|
@@ -20,24 +20,24 @@ myInjector
|
|
|
20
20
|
.setupRepository((repo) =>
|
|
21
21
|
repo.createDataSet(MyModel, {
|
|
22
22
|
onEntityAdded: ({ injector, entity }) => {
|
|
23
|
-
injector.logger.verbose({ message: `An entity added with value '${entity.value}'` })
|
|
23
|
+
injector.logger.verbose({ message: `An entity was added with value '${entity.value}'` })
|
|
24
24
|
},
|
|
25
25
|
authorizeUpdate: async () => ({
|
|
26
26
|
isAllowed: false,
|
|
27
|
-
message: 'This is a read
|
|
27
|
+
message: 'This is a read-only dataset. No update is allowed. :(',
|
|
28
28
|
}),
|
|
29
29
|
/** custom repository options */
|
|
30
30
|
}),
|
|
31
31
|
)
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
In the
|
|
35
|
-
It will log to a logger when an entity has been added and it won't allow
|
|
34
|
+
In the example above, we've created a physical InMemory store for the model `MyModel`, and we've configured a repository with a DataSet.
|
|
35
|
+
It will log to a logger when an entity has been added, and it won't allow updates to entities.
|
|
36
36
|
|
|
37
37
|
### Working with the DataSet
|
|
38
38
|
|
|
39
39
|
A DataSet is similar to a physical store, but it can have custom event callbacks and authorization logic.
|
|
40
|
-
You can retrieve the dataset
|
|
40
|
+
You can retrieve the dataset as follows:
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
43
|
const dataSet = myInjector.getDataSetFor(MyModel)
|
|
@@ -47,7 +47,7 @@ dataSet.update(myInjector, 1, { id: 1, value: 'bar' }) // <--- this one will be
|
|
|
47
47
|
|
|
48
48
|
### Events
|
|
49
49
|
|
|
50
|
-
Events are great for logging
|
|
50
|
+
Events are great for logging or monitoring DataSet changes or distributing changes to clients. They are simple optional callbacks – if defined, they will be called on a specific event. These events are `onEntityAdded`, `onEntityUpdated`, and `onEntityRemoved`
|
|
51
51
|
|
|
52
52
|
### Authorizing operations
|
|
53
53
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/repository",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.20",
|
|
4
4
|
"description": "Repository implementation for FuryStack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/furystack/furystack",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@furystack/core": "^15.0.
|
|
41
|
-
"@furystack/inject": "^12.0.
|
|
42
|
-
"@furystack/utils": "^8.0.
|
|
40
|
+
"@furystack/core": "^15.0.20",
|
|
41
|
+
"@furystack/inject": "^12.0.17",
|
|
42
|
+
"@furystack/utils": "^8.0.16"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.8.3",
|
|
46
|
-
"vitest": "^3.
|
|
46
|
+
"vitest": "^3.2.3"
|
|
47
47
|
},
|
|
48
48
|
"gitHead": "1045d854bfd8c475b7035471d130d401417a2321"
|
|
49
49
|
}
|