@furystack/repository
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;GAEG;AACH,qBACa,UAAW,YAAW,UAAU;IACpC,OAAO;IAKd,OAAO,CAAC,QAAQ,CAAyC;IAElD,aAAa,CAAC,CAAC,EAAE,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,EACjG,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,UAAU,EAAE,WAAW;IAYlB,aAAa,CAAC,CAAC,EAAE,WAAW,SAAS,MAAM,CAAC,EACjD,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,UAAU,EAAE,WAAW,EACvB,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAYrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;CAC7C"} | ||
| {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;GAEG;AACH,qBACa,UAAW,YAAW,UAAU;IACpC,OAAO;IAKd,OAAO,CAAC,QAAQ,CAAyC;IAElD,aAAa,CAAC,CAAC,EAAE,WAAW,SAAS,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,EACjG,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,UAAU,EAAE,WAAW;IAYlB,aAAa,CAAC,CAAC,EAAE,WAAW,SAAS,MAAM,CAAC,EACjD,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EACvB,UAAU,EAAE,WAAW,EACvB,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAWrD,iBACyB,YAAY,CAAc;CACpD"} |
@@ -41,3 +41,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| } | ||
| storeManager; | ||
| }; | ||
@@ -44,0 +43,0 @@ __decorate([ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IACd,OAAO;QACZ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;IAEO,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAA;IAElD,aAAa,CAClB,KAAuB,EACvB,UAAuB;QAEvB,MAAM,QAAQ,GAAG,I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E,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;IAEO,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAA;IAElD,aAAa,CAClB,KAAuB,EACvB,UAAuB;QAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yBAAyB,KAAK,GAAG,CAAC,CAAA;QAChD,CAAC;QACD,IAAI,QAAQ,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YACvC,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACrC,CAAC;QAED,OAAO,QAAyD,CAAA;IAClE,CAAC;IACM,aAAa,CAClB,KAAuB,EACvB,UAAuB,EACvB,QAAmD;QAEnD,MAAM,aAAa,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;QAC9G,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC;YAC3B,GAAG,QAAQ;YACX,aAAa;SACd,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;CAIF,CAAA;AAD0B;IADxB,QAAQ,CAAC,YAAY,CAAC;8BACgB,YAAY;gDAAA;AArCxC,UAAU;IADtB,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;GACzB,UAAU,CAsCtB"} |
+5
-5
| { | ||
| "name": "@furystack/repository", | ||
| "version": "9.0.0", | ||
| "version": "9.0.1", | ||
| "description": "Repository implementation for FuryStack", | ||
@@ -40,8 +40,8 @@ "type": "module", | ||
| "dependencies": { | ||
| "@furystack/core": "^14.0.0", | ||
| "@furystack/inject": "^10.0.0", | ||
| "@furystack/utils": "^6.0.0" | ||
| "@furystack/core": "^14.0.1", | ||
| "@furystack/inject": "^11.0.0", | ||
| "@furystack/utils": "^6.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "typescript": "^5.4.2", | ||
| "typescript": "^5.4.3", | ||
| "vitest": "^1.4.0" | ||
@@ -48,0 +48,0 @@ }, |
+9
-5
@@ -13,4 +13,4 @@ # repository | ||
| class MyModel { | ||
| public id!: number | ||
| public value!: string | ||
| declare id: number | ||
| declare value: string | ||
| } | ||
@@ -20,4 +20,4 @@ | ||
| myInjector | ||
| .setupStores(stores => stores.addStore(new InMemoryStore({ model: MyModel, primaryKey: 'id' }))) | ||
| .setupRepository(repo => | ||
| .setupStores((stores) => stores.addStore(new InMemoryStore({ model: MyModel, primaryKey: 'id' }))) | ||
| .setupRepository((repo) => | ||
| repo.createDataSet(MyModel, { | ||
@@ -51,8 +51,11 @@ onEntityAdded: ({ injector, entity }) => { | ||
| ### Events | ||
| Events are great for logging / monitoring DataSet changes or distribute changes to clients. They are simple optional callbacks - if they are defined, they will be called on a specific event. These events are `onEntityAdded`, `onEntityUpdated` and `onEntityRemoved` | ||
| ### Authorizing operations | ||
| **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 `areauthorizeAdd`, `authorizeUpdate`, `authorizeUpdateEntity` (this needs an additional reload of entity but can compare with the original one), `authorizeRemove`, `authroizeRemoveEntity` (also needs reloading), `authorizeGet`,`authorizeGetEntity` (also needs reloading), | ||
| ### Modifiers and additional filters | ||
| There are some callbacks that modifies an entity before persisting (like `modifyOnAdd` or `modifyOnUpdate`). For example, you can fill createdByUser or lastModifiedByUser fields with these. | ||
@@ -62,2 +65,3 @@ There is an additional property called `addFilter`, you can use that to add a pre-filter condition **before** a filter expression will be evaluated in the data store - ensuring e.g. that the user can _retrieve_ only suff from the physical store that she has enough permission. | ||
| ### Getting the Context | ||
| All methods above has an _injector instance_ on the call parameter - you can use that injector to get service instances from the right caller context. It means that you can use e.g.: HttpUserContext to getting the current user. | ||
| All methods above has an _injector instance_ on the call parameter - you can use that injector to get service instances from the right caller context. It means that you can use e.g.: HttpUserContext to getting the current user. |
@@ -50,3 +50,3 @@ import type { WithOptionalId } from '@furystack/core' | ||
| @Injected(StoreManager) | ||
| private readonly storeManager!: StoreManager | ||
| private declare readonly storeManager: StoreManager | ||
| } |
64
8.47%144043
-0.02%1719
-0.06%- Removed
Updated
Updated
Updated