@furystack/repository 10.0.26 → 10.0.28
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 +17 -16
- package/esm/data-set-setting.d.ts +6 -6
- package/esm/data-set-setting.d.ts.map +1 -1
- package/esm/data-set.js +2 -2
- package/esm/dataset.spec.js +6 -6
- package/esm/helpers.d.ts +2 -3
- package/esm/helpers.d.ts.map +1 -1
- package/esm/helpers.js +1 -1
- package/esm/helpers.js.map +1 -1
- package/package.json +4 -4
- package/src/data-set-setting.ts +6 -6
- package/src/data-set.ts +2 -2
- package/src/dataset.spec.ts +6 -6
- package/src/helpers.ts +2 -3
package/README.md
CHANGED
|
@@ -9,26 +9,27 @@ You can authorize, manipulate, and observe CRUD operations.
|
|
|
9
9
|
You can set up a repository as follows:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
+
import { Injector } from '@furystack/inject'
|
|
13
|
+
import { InMemoryStore, addStore } from '@furystack/core'
|
|
14
|
+
import { getRepository, getDataSetFor } from '@furystack/repository'
|
|
15
|
+
|
|
12
16
|
class MyModel {
|
|
13
17
|
declare id: number
|
|
14
18
|
declare value: string
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
const myInjector = new Injector()
|
|
18
|
-
myInjector
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/** custom repository options */
|
|
30
|
-
}),
|
|
31
|
-
)
|
|
22
|
+
addStore(myInjector, new InMemoryStore({ model: MyModel, primaryKey: 'id' }))
|
|
23
|
+
getRepository(myInjector).createDataSet(MyModel, 'id', {
|
|
24
|
+
onEntityAdded: ({ injector, entity }) => {
|
|
25
|
+
injector.logger.verbose({ message: `An entity was added with value '${entity.value}'` })
|
|
26
|
+
},
|
|
27
|
+
authorizeUpdate: async () => ({
|
|
28
|
+
isAllowed: false,
|
|
29
|
+
message: 'This is a read-only dataset. No update is allowed. :(',
|
|
30
|
+
}),
|
|
31
|
+
/** custom repository options */
|
|
32
|
+
})
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
In the example above, we've created a physical InMemory store for the model `MyModel`, and we've configured a repository with a DataSet.
|
|
@@ -40,7 +41,7 @@ A DataSet is similar to a physical store, but it can have custom event callbacks
|
|
|
40
41
|
You can retrieve the dataset as follows:
|
|
41
42
|
|
|
42
43
|
```ts
|
|
43
|
-
const dataSet =
|
|
44
|
+
const dataSet = getDataSetFor(myInjector, MyModel, 'id')
|
|
44
45
|
dataSet.add(myInjector, { id: 1, value: 'foo' }) // <-- this will log to a logger
|
|
45
46
|
dataSet.update(myInjector, 1, { id: 1, value: 'bar' }) // <--- this one will be rejected
|
|
46
47
|
```
|
|
@@ -51,7 +52,7 @@ Events are great for logging or monitoring DataSet changes or distributing chang
|
|
|
51
52
|
|
|
52
53
|
### Authorizing operations
|
|
53
54
|
|
|
54
|
-
**Authorizers** are similar callbacks but they have to return a promise with an `AuthorizationResult` object - you can allow or deny CRUD operations or add additional filters to collections with these Authorize callbacks. These `
|
|
55
|
+
**Authorizers** are similar callbacks but they have to return a promise with an `AuthorizationResult` object - you can allow or deny CRUD operations or add additional filters to collections with these Authorize callbacks. These are `authorizeAdd`, `authorizeUpdate`, `authorizeUpdateEntity` (this needs an additional reload of entity but can compare with the original one), `authorizeRemove`, `authorizeRemoveEntity` (also needs reloading), `authorizeGet`, `authorizeGetEntity` (also needs reloading),
|
|
55
56
|
|
|
56
57
|
### Modifiers and additional filters
|
|
57
58
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FindOptions, PhysicalStore, WithOptionalId } from '@furystack/core';
|
|
2
2
|
import type { Injector } from '@furystack/inject';
|
|
3
3
|
/**
|
|
4
4
|
* The result model returned by authorizers
|
|
@@ -6,13 +6,13 @@ import type { Injector } from '@furystack/inject';
|
|
|
6
6
|
export type AuthorizationResult = SuccessfullyValidationResult | FailedValidationResult;
|
|
7
7
|
export interface SuccessfullyValidationResult {
|
|
8
8
|
/**
|
|
9
|
-
* Indicates if the validation was
|
|
9
|
+
* Indicates if the validation was successful
|
|
10
10
|
*/
|
|
11
11
|
isAllowed: true;
|
|
12
12
|
}
|
|
13
13
|
export interface FailedValidationResult {
|
|
14
14
|
/**
|
|
15
|
-
* Indicates if the validation was
|
|
15
|
+
* Indicates if the validation was successful
|
|
16
16
|
*/
|
|
17
17
|
isAllowed: false;
|
|
18
18
|
/**
|
|
@@ -74,18 +74,18 @@ export interface DataSetSettings<T, TPrimaryKey extends keyof T, TWritableData =
|
|
|
74
74
|
/**
|
|
75
75
|
* Authorizes entity removal per loaded entity
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
authorizeRemoveEntity?: (options: {
|
|
78
78
|
injector: Injector;
|
|
79
79
|
entity: T;
|
|
80
80
|
}) => Promise<AuthorizationResult>;
|
|
81
81
|
/**
|
|
82
|
-
* Authorizes entity
|
|
82
|
+
* Authorizes entity retrieval without entity loading
|
|
83
83
|
*/
|
|
84
84
|
authorizeGet?: (options: {
|
|
85
85
|
injector: Injector;
|
|
86
86
|
}) => Promise<AuthorizationResult>;
|
|
87
87
|
/**
|
|
88
|
-
* Authorizes entity
|
|
88
|
+
* Authorizes entity retrieval
|
|
89
89
|
*/
|
|
90
90
|
authorizeGetEntity?: (options: {
|
|
91
91
|
injector: Injector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-set-setting.d.ts","sourceRoot":"","sources":["../src/data-set-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"data-set-setting.d.ts","sourceRoot":"","sources":["../src/data-set-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE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
|
|
131
|
-
if (this.settings.
|
|
131
|
+
if (this.settings.authorizeRemoveEntity) {
|
|
132
132
|
const entity = await this.settings.physicalStore.get(key);
|
|
133
133
|
if (entity) {
|
|
134
|
-
const removeResult = await this.settings.
|
|
134
|
+
const removeResult = await this.settings.authorizeRemoveEntity({ injector, entity });
|
|
135
135
|
if (!removeResult.isAllowed) {
|
|
136
136
|
throw new AuthorizationError(removeResult.message);
|
|
137
137
|
}
|
package/esm/dataset.spec.js
CHANGED
|
@@ -424,11 +424,11 @@ describe('DataSet', () => {
|
|
|
424
424
|
expect(count).toBe(1);
|
|
425
425
|
});
|
|
426
426
|
});
|
|
427
|
-
it('should remove the entity if
|
|
427
|
+
it('should remove the entity if authorizeRemoveEntity returns valid result', async () => {
|
|
428
428
|
await usingAsync(new Injector(), async (i) => {
|
|
429
|
-
const
|
|
429
|
+
const authorizeRemoveEntity = vi.fn(async () => ({ isAllowed: true, message: '' }));
|
|
430
430
|
addStore(i, new InMemoryStore({ model: TestClass, primaryKey: 'id' }));
|
|
431
|
-
getRepository(i).createDataSet(TestClass, 'id', {
|
|
431
|
+
getRepository(i).createDataSet(TestClass, 'id', { authorizeRemoveEntity });
|
|
432
432
|
const dataSet = getDataSetFor(i, TestClass, 'id');
|
|
433
433
|
await dataSet.add(i, { id: 1, value: 'asd' });
|
|
434
434
|
await dataSet.remove(i, 1);
|
|
@@ -436,11 +436,11 @@ describe('DataSet', () => {
|
|
|
436
436
|
expect(count).toBe(0);
|
|
437
437
|
});
|
|
438
438
|
});
|
|
439
|
-
it('should throw if
|
|
439
|
+
it('should throw if authorizeRemoveEntity returns invalid result', async () => {
|
|
440
440
|
await usingAsync(new Injector(), async (i) => {
|
|
441
|
-
const
|
|
441
|
+
const authorizeRemoveEntity = vi.fn(async () => ({ isAllowed: false, message: ':(' }));
|
|
442
442
|
addStore(i, new InMemoryStore({ model: TestClass, primaryKey: 'id' }));
|
|
443
|
-
getRepository(i).createDataSet(TestClass, 'id', {
|
|
443
|
+
getRepository(i).createDataSet(TestClass, 'id', { authorizeRemoveEntity });
|
|
444
444
|
const dataSet = getDataSetFor(i, TestClass, 'id');
|
|
445
445
|
await dataSet.add(i, { id: 1, value: 'asd' });
|
|
446
446
|
try {
|
package/esm/helpers.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Constructable } from '@furystack/inject';
|
|
2
|
-
import type { Injector } from '@furystack/inject';
|
|
1
|
+
import type { Constructable, Injector } from '@furystack/inject';
|
|
3
2
|
import { Repository } from './repository.js';
|
|
4
3
|
/**
|
|
5
4
|
* Returns a Repository on an injector
|
|
@@ -8,7 +7,7 @@ import { Repository } from './repository.js';
|
|
|
8
7
|
*/
|
|
9
8
|
export declare const getRepository: (injector: Injector) => Repository;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
10
|
+
* Gets a DataSet for a specific model from the repository
|
|
12
11
|
* @param injector The Injector instance
|
|
13
12
|
* @param model The Model
|
|
14
13
|
* @param primaryKey The Primary Key field
|
package/esm/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,eAAqC,CAAA;AAErF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,WAAW,SAAS,MAAM,CAAC,EAC1D,UAAU,QAAQ,EAClB,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,YAAY,WAAW,8GAC6C,CAAA"}
|
package/esm/helpers.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Repository } from './repository.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export const getRepository = (injector) => injector.getInstance(Repository);
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Gets a DataSet for a specific model from the repository
|
|
10
10
|
* @param injector The Injector instance
|
|
11
11
|
* @param model The Model
|
|
12
12
|
* @param primaryKey The Primary Key field
|
package/esm/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;AAErF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,QAAkB,EAClB,KAAuB,EACvB,UAAuB,EACvB,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/repository",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.28",
|
|
4
4
|
"description": "Repository implementation for FuryStack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -37,9 +37,9 @@
|
|
|
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.1.
|
|
40
|
+
"@furystack/core": "^15.0.28",
|
|
41
|
+
"@furystack/inject": "^12.0.22",
|
|
42
|
+
"@furystack/utils": "^8.1.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.9.3",
|
package/src/data-set-setting.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FindOptions, PhysicalStore, WithOptionalId } from '@furystack/core'
|
|
2
2
|
import type { Injector } from '@furystack/inject'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,14 +8,14 @@ export type AuthorizationResult = SuccessfullyValidationResult | FailedValidatio
|
|
|
8
8
|
|
|
9
9
|
export interface SuccessfullyValidationResult {
|
|
10
10
|
/**
|
|
11
|
-
* Indicates if the validation was
|
|
11
|
+
* Indicates if the validation was successful
|
|
12
12
|
*/
|
|
13
13
|
isAllowed: true
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface FailedValidationResult {
|
|
17
17
|
/**
|
|
18
|
-
* Indicates if the validation was
|
|
18
|
+
* Indicates if the validation was successful
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
isAllowed: false
|
|
@@ -71,15 +71,15 @@ export interface DataSetSettings<T, TPrimaryKey extends keyof T, TWritableData =
|
|
|
71
71
|
/**
|
|
72
72
|
* Authorizes entity removal per loaded entity
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
authorizeRemoveEntity?: (options: { injector: Injector; entity: T }) => Promise<AuthorizationResult>
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Authorizes entity
|
|
77
|
+
* Authorizes entity retrieval without entity loading
|
|
78
78
|
*/
|
|
79
79
|
authorizeGet?: (options: { injector: Injector }) => Promise<AuthorizationResult>
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* Authorizes entity
|
|
82
|
+
* Authorizes entity retrieval
|
|
83
83
|
*/
|
|
84
84
|
authorizeGetEntity?: (options: { injector: Injector; entity: T }) => Promise<AuthorizationResult>
|
|
85
85
|
|
package/src/data-set.ts
CHANGED
|
@@ -153,10 +153,10 @@ export class DataSet<T, TPrimaryKey extends keyof T, TWritableData = WithOptiona
|
|
|
153
153
|
throw new AuthorizationError(result.message)
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
if (this.settings.
|
|
156
|
+
if (this.settings.authorizeRemoveEntity) {
|
|
157
157
|
const entity = await this.settings.physicalStore.get(key)
|
|
158
158
|
if (entity) {
|
|
159
|
-
const removeResult = await this.settings.
|
|
159
|
+
const removeResult = await this.settings.authorizeRemoveEntity({ injector, entity })
|
|
160
160
|
if (!removeResult.isAllowed) {
|
|
161
161
|
throw new AuthorizationError(removeResult.message)
|
|
162
162
|
}
|
package/src/dataset.spec.ts
CHANGED
|
@@ -495,11 +495,11 @@ describe('DataSet', () => {
|
|
|
495
495
|
})
|
|
496
496
|
})
|
|
497
497
|
|
|
498
|
-
it('should remove the entity if
|
|
498
|
+
it('should remove the entity if authorizeRemoveEntity returns valid result', async () => {
|
|
499
499
|
await usingAsync(new Injector(), async (i) => {
|
|
500
|
-
const
|
|
500
|
+
const authorizeRemoveEntity = vi.fn(async () => ({ isAllowed: true, message: '' }))
|
|
501
501
|
addStore(i, new InMemoryStore({ model: TestClass, primaryKey: 'id' }))
|
|
502
|
-
getRepository(i).createDataSet(TestClass, 'id', {
|
|
502
|
+
getRepository(i).createDataSet(TestClass, 'id', { authorizeRemoveEntity })
|
|
503
503
|
|
|
504
504
|
const dataSet = getDataSetFor(i, TestClass, 'id')
|
|
505
505
|
await dataSet.add(i, { id: 1, value: 'asd' })
|
|
@@ -509,11 +509,11 @@ describe('DataSet', () => {
|
|
|
509
509
|
})
|
|
510
510
|
})
|
|
511
511
|
|
|
512
|
-
it('should throw if
|
|
512
|
+
it('should throw if authorizeRemoveEntity returns invalid result', async () => {
|
|
513
513
|
await usingAsync(new Injector(), async (i) => {
|
|
514
|
-
const
|
|
514
|
+
const authorizeRemoveEntity = vi.fn(async () => ({ isAllowed: false, message: ':(' }))
|
|
515
515
|
addStore(i, new InMemoryStore({ model: TestClass, primaryKey: 'id' }))
|
|
516
|
-
getRepository(i).createDataSet(TestClass, 'id', {
|
|
516
|
+
getRepository(i).createDataSet(TestClass, 'id', { authorizeRemoveEntity })
|
|
517
517
|
|
|
518
518
|
const dataSet = getDataSetFor(i, TestClass, 'id')
|
|
519
519
|
await dataSet.add(i, { id: 1, value: 'asd' })
|
package/src/helpers.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Constructable } from '@furystack/inject'
|
|
2
|
-
import type { Injector } from '@furystack/inject'
|
|
1
|
+
import type { Constructable, Injector } from '@furystack/inject'
|
|
3
2
|
import { Repository } from './repository.js'
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -10,7 +9,7 @@ import { Repository } from './repository.js'
|
|
|
10
9
|
export const getRepository = (injector: Injector) => injector.getInstance(Repository)
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* Gets a DataSet for a specific model from the repository
|
|
14
13
|
* @param injector The Injector instance
|
|
15
14
|
* @param model The Model
|
|
16
15
|
* @param primaryKey The Primary Key field
|