@geosdi/ngx-store 1.1.13 → 2.0.0
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 +136 -13
- package/fesm2022/geosdi-ngx-store.mjs +56 -67
- package/fesm2022/geosdi-ngx-store.mjs.map +1 -1
- package/package.json +12 -9
- package/types/geosdi-ngx-store.d.ts +152 -0
- package/index.d.ts +0 -5
- package/lib/ngx-abstract-store.facade.d.ts +0 -55
- package/lib/ngx-actions.d.ts +0 -20
- package/lib/ngx-effects.d.ts +0 -19
- package/lib/ngx-state.d.ts +0 -17
- package/lib/ngx-store.facade.d.ts +0 -54
package/README.md
CHANGED
|
@@ -1,24 +1,147 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @geosdi/ngx-store
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The common pieces of an NgRx entity store in geoSDI applications: the facade contract that the
|
|
4
|
+
tables of `@geosdi/ngx-primeng-table` and the views of `@geosdi/ngx-primeng-view-template` talk to,
|
|
5
|
+
the base state for `@ngrx/entity`, a few shared actions, and the effects that keep the selected bean
|
|
6
|
+
of `@geosdi/ngx-select-bean` in step with deletes and updates.
|
|
4
7
|
|
|
5
|
-
##
|
|
8
|
+
## Installation
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
> Note: Don't forget to add `--project ngx-store` or else it will be added to the default project in your `angular.json` file.
|
|
10
|
+
`npm i @geosdi/ngx-store --save`
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
Peer dependencies:
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
"@angular/common": ">=22.0.0",
|
|
15
|
+
"@angular/core": ">=22.0.0",
|
|
16
|
+
"@geosdi/ngx-model": ">=1.2.0",
|
|
17
|
+
"@geosdi/ngx-select-bean": ">=1.1.0",
|
|
18
|
+
"@ngrx/entity": ">=22.0.0",
|
|
19
|
+
"@ngrx/effects": ">=22.0.0",
|
|
20
|
+
"@ngrx/store": ">=22.0.0",
|
|
21
|
+
"rxjs": ">=7.8.0"
|
|
13
22
|
|
|
14
|
-
##
|
|
23
|
+
## Usage
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
The state of an entity, built on the base state:
|
|
17
26
|
|
|
18
|
-
|
|
27
|
+
```typescript
|
|
28
|
+
import { createEntityAdapter } from "@ngrx/entity";
|
|
29
|
+
import { Model } from "@geosdi/ngx-model";
|
|
30
|
+
import {
|
|
31
|
+
NgxState,
|
|
32
|
+
getAdapterIntialState,
|
|
33
|
+
selectModelId,
|
|
34
|
+
} from "@geosdi/ngx-store";
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
export interface User extends Model {
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
21
39
|
|
|
22
|
-
|
|
40
|
+
export type UserState = NgxState<User>; // entities + paginatedBeanLoaded + total
|
|
23
41
|
|
|
24
|
-
|
|
42
|
+
export const userAdapter = createEntityAdapter<User>({
|
|
43
|
+
selectId: selectModelId,
|
|
44
|
+
});
|
|
45
|
+
export const initialUserState: UserState = getAdapterIntialState(userAdapter);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The facade the tables and views receive, implemented by the application:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { NgxAbstractStoreFacade } from "@geosdi/ngx-store";
|
|
52
|
+
|
|
53
|
+
@Injectable({ providedIn: "root" })
|
|
54
|
+
export class UserFacade extends NgxAbstractStoreFacade<User> {
|
|
55
|
+
private store = inject(Store);
|
|
56
|
+
|
|
57
|
+
loadStore() {
|
|
58
|
+
/* dispatch the load action */
|
|
59
|
+
}
|
|
60
|
+
selectPaginatedBeans(from: number, size: number, param?: string) {
|
|
61
|
+
/* … */
|
|
62
|
+
}
|
|
63
|
+
getTotal(): Observable<number> {
|
|
64
|
+
/* … */
|
|
65
|
+
}
|
|
66
|
+
// addBean, updateBean, deleteBean, clearStore, searchByValue, selectorBeanById
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The effects, which need the `selectBean` slice of `@geosdi/ngx-select-bean` to be registered:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { NgxSelectBeanModule } from "@geosdi/ngx-select-bean";
|
|
74
|
+
import { NgxEffects } from "@geosdi/ngx-store";
|
|
75
|
+
|
|
76
|
+
@NgModule({
|
|
77
|
+
imports: [
|
|
78
|
+
StoreModule.forRoot({}),
|
|
79
|
+
EffectsModule.forRoot([]),
|
|
80
|
+
NgxSelectBeanModule,
|
|
81
|
+
EffectsModule.forFeature([NgxEffects]),
|
|
82
|
+
],
|
|
83
|
+
})
|
|
84
|
+
export class AppModule {}
|
|
85
|
+
|
|
86
|
+
// or, standalone:
|
|
87
|
+
// providers: [provideStore(), provideEffects(NgxEffects),
|
|
88
|
+
// provideState("selectBean", ngxSelectBeanReducer)]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
After a successful delete or update, the application dispatches the matching action:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
store.dispatch(afterDeleting()); // the selected bean is reset
|
|
95
|
+
store.dispatch(afterUpdating({ table: "users", bean: updated })); // and refreshed
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## API
|
|
99
|
+
|
|
100
|
+
| Export | What it is |
|
|
101
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `INgxStoreFacade<B>` | the facade contract: `loadStore`, `selectPaginatedBeans`, `getTotal`, `addBean`, `updateBean`, `deleteBean`, `clearStore`, `searchByValue`, `selectorBeanById` |
|
|
103
|
+
| `NgxAbstractStoreFacade<B>` | the same contract as an abstract class |
|
|
104
|
+
| `NgxState<B>` | `EntityState<B>` plus `paginatedBeanLoaded: boolean` and `total: number` |
|
|
105
|
+
| `getAdapterIntialState(adapter)` | the adapter's initial state with `paginatedBeanLoaded: false` and `total: 0` |
|
|
106
|
+
| `selectModelId(model)` | `model.id`, for `createEntityAdapter({ selectId })` |
|
|
107
|
+
| `NgxAppState` | an empty interface, for applications to extend |
|
|
108
|
+
| `serviceSuccess()` | action `[Service] Service Success` |
|
|
109
|
+
| `afterDeleting()` | action `[Service] Service After Deleting`: `NgxEffects` dispatches `resetBean()` |
|
|
110
|
+
| `afterUpdating({ table, bean })` | action `[Service] Service After Updating`: `NgxEffects` dispatches `updateSelectBean` |
|
|
111
|
+
| `reloadTable({ table })` | action `[Service] Reload View` |
|
|
112
|
+
| `clearState()`, `CLEAR_STATE` | action `[Service] Clear State`, and its type |
|
|
113
|
+
| `NgxEffects` | the effects above; `@Injectable()` without `providedIn`, to register with NgRx effects |
|
|
114
|
+
|
|
115
|
+
## What the code does not show
|
|
116
|
+
|
|
117
|
+
- **Only `afterDeleting` and `afterUpdating` do something.** `serviceSuccess`, `reloadTable` and
|
|
118
|
+
`clearState` are declared here but no reducer or effect of the library handles them: they are
|
|
119
|
+
for the application's reducers (`clearState`, for instance, in a meta-reducer that empties the
|
|
120
|
+
store).
|
|
121
|
+
- **`serviceSuccess` no longer shows a message.** Up to 1.1.13 its effect printed the translated
|
|
122
|
+
`message.action_successful` through `NgxUtilityServiceService` of `@geosdi/ngx-utility-service`;
|
|
123
|
+
that service no longer exists, and the effect now does nothing.
|
|
124
|
+
- **`NgxEffects` writes into the `selectBean` slice**: without `@geosdi/ngx-select-bean` registered,
|
|
125
|
+
the dispatched actions change nothing.
|
|
126
|
+
- **`afterUpdating` refreshes the selected bean only if it was selected from the same `table`**
|
|
127
|
+
(the rule of `updateSelectBean`).
|
|
128
|
+
- **`getAdapterIntialState` is spelt that way** — "Intial" — and is part of the API.
|
|
129
|
+
- The action types of `serviceSuccess`, `afterDeleting` and `afterUpdating` contain two spaces
|
|
130
|
+
after `[Service]`: match them as they are if you filter actions by type.
|
|
131
|
+
|
|
132
|
+
## Changes in 2.0.0
|
|
133
|
+
|
|
134
|
+
- **A major version** because the peer dependencies now ask for Angular 22: an application on an
|
|
135
|
+
older Angular can no longer install it. The API is unchanged unless a point below says otherwise.
|
|
136
|
+
- **The peer dependencies on Angular and NgRx are `>=22.0.0`** (`@ngrx/entity`, `@ngrx/effects`,
|
|
137
|
+
`@ngrx/store` included): the library is compiled and tested with these versions only, so it no
|
|
138
|
+
longer claims to install on older ones.
|
|
139
|
+
- Compiled with Angular 22 and NgRx 22.
|
|
140
|
+
- **`NgxEffects` no longer depends on `@geosdi/ngx-utility-service`.** The 1.1.13 on npm injects
|
|
141
|
+
its `NgxUtilityServiceService`, which `@geosdi/ngx-utility-service` 2.x no longer exports: with
|
|
142
|
+
that version installed, an application importing `@geosdi/ngx-store` 1.1.13 does not build
|
|
143
|
+
(esbuild reports the missing export). The
|
|
144
|
+
`serviceSuccess` effect, which printed the success message through it, now does nothing.
|
|
145
|
+
- Peer dependencies: `@geosdi/ngx-model`, `@geosdi/ngx-select-bean` and `rxjs`, which the code
|
|
146
|
+
imports, are declared; `typescript`, which it does not, is no longer.
|
|
147
|
+
- This README, which replaces the one generated by Angular CLI.
|
|
@@ -1,78 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import * as i2 from '@geosdi/ngx-utility-service';
|
|
10
|
-
import { map } from 'rxjs';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
14
|
-
* @email vito.salvia@gmail.com
|
|
15
|
-
*/
|
|
16
|
-
class NgxAbstractStoreFacade {
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
import { Store, createAction, props } from "@ngrx/store";
|
|
2
|
+
import { Actions, createEffect, ofType } from "@ngrx/effects";
|
|
3
|
+
import { tap } from "rxjs/operators";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { Injectable, inject } from "@angular/core";
|
|
6
|
+
import { resetBean, updateSelectBean } from "@geosdi/ngx-select-bean";
|
|
7
|
+
import { map } from "rxjs";
|
|
8
|
+
var NgxAbstractStoreFacade = class {};
|
|
19
9
|
function selectModelId(model) {
|
|
20
|
-
|
|
10
|
+
return model.id;
|
|
21
11
|
}
|
|
22
12
|
function getAdapterIntialState(adapter) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
return adapter.getInitialState({
|
|
14
|
+
paginatedBeanLoaded: false,
|
|
15
|
+
total: 0
|
|
16
|
+
});
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
31
|
-
* @email vito.salvia@gmail.com
|
|
32
|
-
*/
|
|
33
18
|
const CLEAR_STATE = "[Service] Clear State";
|
|
34
19
|
const serviceSuccess = createAction("[Service] Service Success");
|
|
35
20
|
const afterDeleting = createAction("[Service] Service After Deleting");
|
|
36
21
|
const afterUpdating = createAction("[Service] Service After Updating", props());
|
|
37
22
|
const reloadTable = createAction("[Service] Reload View", props());
|
|
38
23
|
const clearState = createAction(CLEAR_STATE);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
i0.ɵɵ
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
24
|
+
var NgxEffects = class NgxEffects {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.actions$ = inject(Actions);
|
|
27
|
+
this.onSuccess$ = createEffect(() => this.actions$.pipe(ofType(serviceSuccess), tap((res) => {})), { dispatch: false });
|
|
28
|
+
this.appStore = inject(Store);
|
|
29
|
+
this.onDeleting$ = createEffect(() => this.actions$.pipe(ofType(afterDeleting), tap((res) => {
|
|
30
|
+
this.appStore.dispatch(resetBean());
|
|
31
|
+
})), { dispatch: false });
|
|
32
|
+
this.onUpdating$ = createEffect(() => this.actions$.pipe(ofType(afterUpdating), map((action) => {
|
|
33
|
+
this.appStore.dispatch(updateSelectBean({
|
|
34
|
+
bean: action.bean,
|
|
35
|
+
table: action.table
|
|
36
|
+
}));
|
|
37
|
+
})), { dispatch: false });
|
|
38
|
+
}
|
|
39
|
+
static {
|
|
40
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
41
|
+
minVersion: "12.0.0",
|
|
42
|
+
version: "22.2.4",
|
|
43
|
+
ngImport: i0,
|
|
44
|
+
type: NgxEffects,
|
|
45
|
+
deps: [],
|
|
46
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
static {
|
|
50
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
51
|
+
minVersion: "12.0.0",
|
|
52
|
+
version: "22.2.4",
|
|
53
|
+
ngImport: i0,
|
|
54
|
+
type: NgxEffects
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
59
|
+
minVersion: "12.0.0",
|
|
60
|
+
version: "22.2.4",
|
|
61
|
+
ngImport: i0,
|
|
62
|
+
type: NgxEffects,
|
|
63
|
+
decorators: [{ type: Injectable }]
|
|
64
|
+
});
|
|
77
65
|
export { CLEAR_STATE, NgxAbstractStoreFacade, NgxEffects, afterDeleting, afterUpdating, clearState, getAdapterIntialState, reloadTable, selectModelId, serviceSuccess };
|
|
78
|
-
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=geosdi-ngx-store.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geosdi-ngx-store.mjs","sources":["../../../../projects/geosdi/store/ngx-store/src/lib/ngx-abstract-store.facade.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-state.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-actions.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-effects.ts"
|
|
1
|
+
{"version":3,"file":"geosdi-ngx-store.mjs","names":[],"sources":["../../../../projects/geosdi/store/ngx-store/src/lib/ngx-abstract-store.facade.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-state.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-actions.ts","../../../../projects/geosdi/store/ngx-store/src/lib/ngx-effects.ts"],"sourcesContent":["import { Model } from \"@geosdi/ngx-model\";\nimport { Observable } from \"rxjs\";\nimport { INgxStoreFacade } from \"./ngx-store.facade\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\nexport abstract class NgxAbstractStoreFacade<\n B extends Model,\n> implements INgxStoreFacade<B> {\n /**\n *\n * @param bean\n */\n abstract addBean(bean: B): any;\n\n /**\n *\n */\n abstract clearStore(): any;\n\n /**\n *\n * @param id\n */\n abstract deleteBean(id: string | number): any;\n\n /**\n *\n * @param from\n * @param size\n * @param params\n */\n abstract searchByValue(from: number, size: number, params: any): any;\n\n /**\n *\n */\n abstract getTotal(): Observable<number>;\n\n /**\n *\n */\n abstract loadStore(): any;\n\n /**\n *\n * @param from\n * @param size\n * @param param\n */\n abstract selectPaginatedBeans(\n from: number,\n size: number,\n param?: string,\n ): any;\n\n /**\n *\n * @param id\n */\n abstract selectorBeanById(id: string | number): any;\n\n /**\n *\n * @param bean\n */\n abstract updateBean(bean: B): any;\n}\n","import { Model } from \"@geosdi/ngx-model\";\nimport { EntityAdapter, EntityState } from \"@ngrx/entity\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\nexport interface NgxAppState {}\n\nexport interface NgxState<B extends Model> extends EntityState<B> {\n paginatedBeanLoaded: boolean;\n total: number;\n}\n\nexport function selectModelId(model: Model): any {\n return model.id;\n}\n\nexport function getAdapterIntialState<B extends Model>(\n adapter: EntityAdapter<B>,\n) {\n return adapter.getInitialState({\n paginatedBeanLoaded: false,\n total: 0,\n });\n}\n","import { createAction, props } from \"@ngrx/store\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\nexport const CLEAR_STATE = \"[Service] Clear State\";\n\nexport const serviceSuccess = createAction(\"[Service] Service Success\");\nexport const afterDeleting = createAction(\"[Service] Service After Deleting\");\nexport const afterUpdating = createAction(\n \"[Service] Service After Updating\",\n props<{\n table: any;\n bean: any;\n }>(),\n);\nexport const reloadTable = createAction(\n \"[Service] Reload View\",\n props<{ table: any }>(),\n);\n\nexport const clearState = createAction(CLEAR_STATE);\n","import { Actions, createEffect, ofType } from \"@ngrx/effects\";\nimport { tap } from \"rxjs/operators\";\nimport { Injectable, inject } from \"@angular/core\";\nimport { Store } from \"@ngrx/store\";\nimport { resetBean, updateSelectBean } from \"@geosdi/ngx-select-bean\";\nimport { afterDeleting, afterUpdating, serviceSuccess } from \"./ngx-actions\";\nimport { map } from \"rxjs\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n@Injectable()\nexport class NgxEffects {\n private actions$: Actions = inject(Actions);\n onSuccess$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(serviceSuccess),\n tap((res) => {}),\n ),\n { dispatch: false },\n );\n private appStore: Store = inject(Store);\n onDeleting$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(afterDeleting),\n tap((res) => {\n this.appStore.dispatch(resetBean());\n }),\n ),\n { dispatch: false },\n );\n\n onUpdating$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(afterUpdating),\n map((action: any) => {\n this.appStore.dispatch(\n updateSelectBean({\n bean: action.bean,\n table: action.table,\n }),\n );\n }),\n ),\n { dispatch: false },\n );\n}\n"],"mappings":";;;;;;;AAQA,IAAsB,yBAAtB,MAA4C,CA6D3C;ACvDD,SAAgB,cAAc,OAAY;CACtC,OAAO,MAAM;AACjB;AAEA,SAAgB,sBACZ,SAAyB;CAEzB,OAAO,QAAQ,gBAAgB;EAC3B,qBAAqB;EACrB,OAAO;CACV,CAAA;AACL;ACnBA,MAAa,cAAc;AAE3B,MAAa,iBAAiB,aAAa,4BAA4B;AACvE,MAAa,gBAAgB,aAAa,mCAAmC;AAC7E,MAAa,gBAAgB,aACzB,qCACA,MAAK,CAGD;AAER,MAAa,cAAc,aACvB,yBACA,MAAK,CAAkB;AAG3B,MAAa,aAAa,aAAa,WAAW;ACTlD,IAAa,aAAb,MAAa,WAAU;CADvB,cAAA;EAEY,KAAA,WAAoB,OAAO,OAAO;EAC1C,KAAA,aAAa,mBAEL,KAAK,SAAS,KACV,OAAO,cAAc,GACrB,KAAK,QAAO,CAAE,CAAC,CAAC,GAExB,EAAE,UAAU,MAAK,CAAE;EAEf,KAAA,WAAkB,OAAO,KAAK;EACtC,KAAA,cAAc,mBAEN,KAAK,SAAS,KACV,OAAO,aAAa,GACpB,KAAK,QAAO;GACR,KAAK,SAAS,SAAS,UAAS,CAAE;EACtC,CAAC,CAAC,GAEV,EAAE,UAAU,MAAK,CAAE;EAGvB,KAAA,cAAc,mBAEN,KAAK,SAAS,KACV,OAAO,aAAa,GACpB,KAAK,WAAe;GAChB,KAAK,SAAS,SACV,iBAAiB;IACb,MAAM,OAAO;IACb,OAAO,OAAO;GACjB,CAAA,CAAC;EAEV,CAAC,CAAC,GAEV,EAAE,UAAU,MAAK,CAAE;CAE1B;CArCY;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAU,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAV;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;EAAU,CAAA;CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA,EADtB,MAAA,W"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geosdi/ngx-store",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Ngrx store facade",
|
|
5
5
|
"author": "Salvia Vito (vito.salvia@gmail.com)",
|
|
6
6
|
"keywords": [
|
|
@@ -11,25 +11,28 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@angular/common": ">=
|
|
15
|
-
"@angular/core": ">=
|
|
16
|
-
"
|
|
17
|
-
"@
|
|
18
|
-
"@ngrx/
|
|
19
|
-
"@ngrx/
|
|
14
|
+
"@angular/common": ">=22.0.0",
|
|
15
|
+
"@angular/core": ">=22.0.0",
|
|
16
|
+
"@geosdi/ngx-model": ">=1.2.0",
|
|
17
|
+
"@geosdi/ngx-select-bean": ">=1.1.0",
|
|
18
|
+
"@ngrx/entity": ">=22.0.0",
|
|
19
|
+
"@ngrx/effects": ">=22.0.0",
|
|
20
|
+
"@ngrx/store": ">=22.0.0",
|
|
21
|
+
"rxjs": ">=7.8.0"
|
|
20
22
|
},
|
|
21
23
|
"sideEffects": false,
|
|
22
24
|
"module": "fesm2022/geosdi-ngx-store.mjs",
|
|
23
|
-
"typings": "
|
|
25
|
+
"typings": "types/geosdi-ngx-store.d.ts",
|
|
24
26
|
"exports": {
|
|
25
27
|
"./package.json": {
|
|
26
28
|
"default": "./package.json"
|
|
27
29
|
},
|
|
28
30
|
".": {
|
|
29
|
-
"types": "./
|
|
31
|
+
"types": "./types/geosdi-ngx-store.d.ts",
|
|
30
32
|
"default": "./fesm2022/geosdi-ngx-store.mjs"
|
|
31
33
|
}
|
|
32
34
|
},
|
|
35
|
+
"type": "module",
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"tslib": "^2.3.0"
|
|
35
38
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Model } from "@geosdi/ngx-model";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { EntityAdapter, EntityState } from "@ngrx/entity";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
7
|
+
* @email vito.salvia@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export interface INgxStoreFacade<B extends Model> {
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param from
|
|
13
|
+
* @param size
|
|
14
|
+
* @param param
|
|
15
|
+
*/
|
|
16
|
+
selectPaginatedBeans(from: number, size: number, param?: string): any;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param bean
|
|
20
|
+
*/
|
|
21
|
+
updateBean(bean: B): any;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param bean
|
|
25
|
+
*/
|
|
26
|
+
addBean(bean: B): any;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
clearStore(): any;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
loadStore(): any;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param id
|
|
38
|
+
*/
|
|
39
|
+
deleteBean(id: string | number): any;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
getTotal(): Observable<number>;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param id
|
|
47
|
+
*/
|
|
48
|
+
selectorBeanById(id: string | number): any;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param from
|
|
52
|
+
* @param size
|
|
53
|
+
* @param params
|
|
54
|
+
*/
|
|
55
|
+
searchByValue(from: number, size: number, params: any): any;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
59
|
+
* @email vito.salvia@gmail.com
|
|
60
|
+
*/
|
|
61
|
+
export declare abstract class NgxAbstractStoreFacade<B extends Model> implements INgxStoreFacade<B> {
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param bean
|
|
65
|
+
*/
|
|
66
|
+
abstract addBean(bean: B): any;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
abstract clearStore(): any;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param id
|
|
74
|
+
*/
|
|
75
|
+
abstract deleteBean(id: string | number): any;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param from
|
|
79
|
+
* @param size
|
|
80
|
+
* @param params
|
|
81
|
+
*/
|
|
82
|
+
abstract searchByValue(from: number, size: number, params: any): any;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
abstract getTotal(): Observable<number>;
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
abstract loadStore(): any;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param from
|
|
94
|
+
* @param size
|
|
95
|
+
* @param param
|
|
96
|
+
*/
|
|
97
|
+
abstract selectPaginatedBeans(from: number, size: number, param?: string): any;
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @param id
|
|
101
|
+
*/
|
|
102
|
+
abstract selectorBeanById(id: string | number): any;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @param bean
|
|
106
|
+
*/
|
|
107
|
+
abstract updateBean(bean: B): any;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
111
|
+
* @email vito.salvia@gmail.com
|
|
112
|
+
*/
|
|
113
|
+
export interface NgxAppState {}
|
|
114
|
+
export interface NgxState<B extends Model> extends EntityState<B> {
|
|
115
|
+
paginatedBeanLoaded: boolean;
|
|
116
|
+
total: number;
|
|
117
|
+
}
|
|
118
|
+
export declare function selectModelId(model: Model): any;
|
|
119
|
+
export declare function getAdapterIntialState<B extends Model>(adapter: EntityAdapter<B>): EntityState<B>;
|
|
120
|
+
/**
|
|
121
|
+
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
122
|
+
* @email vito.salvia@gmail.com
|
|
123
|
+
*/
|
|
124
|
+
export declare const CLEAR_STATE = "[Service] Clear State";
|
|
125
|
+
export declare const serviceSuccess: import("@ngrx/store").ActionCreator<"[Service] Service Success", () => import("@ngrx/store").Action<"[Service] Service Success">>;
|
|
126
|
+
export declare const afterDeleting: import("@ngrx/store").ActionCreator<"[Service] Service After Deleting", () => import("@ngrx/store").Action<"[Service] Service After Deleting">>;
|
|
127
|
+
export declare const afterUpdating: import("@ngrx/store").ActionCreator<"[Service] Service After Updating", (props: {
|
|
128
|
+
table: any;
|
|
129
|
+
bean: any;
|
|
130
|
+
}) => {
|
|
131
|
+
table: any;
|
|
132
|
+
bean: any;
|
|
133
|
+
} & import("@ngrx/store").Action<"[Service] Service After Updating">>;
|
|
134
|
+
export declare const reloadTable: import("@ngrx/store").ActionCreator<"[Service] Reload View", (props: {
|
|
135
|
+
table: any;
|
|
136
|
+
}) => {
|
|
137
|
+
table: any;
|
|
138
|
+
} & import("@ngrx/store").Action<"[Service] Reload View">>;
|
|
139
|
+
export declare const clearState: import("@ngrx/store").ActionCreator<"[Service] Clear State", () => import("@ngrx/store").Action<"[Service] Clear State">>;
|
|
140
|
+
/**
|
|
141
|
+
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
142
|
+
* @email vito.salvia@gmail.com
|
|
143
|
+
*/
|
|
144
|
+
export declare class NgxEffects {
|
|
145
|
+
private actions$;
|
|
146
|
+
onSuccess$: import("rxjs").Observable<import("@ngrx/store").Action<"[Service] Service Success">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
147
|
+
private appStore;
|
|
148
|
+
onDeleting$: import("rxjs").Observable<import("@ngrx/store").Action<"[Service] Service After Deleting">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
149
|
+
onUpdating$: import("rxjs").Observable<void> & import("@ngrx/effects").CreateEffectMetadata;
|
|
150
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxEffects, never>;
|
|
151
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
152
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Model } from "@geosdi/ngx-model";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
import { INgxStoreFacade } from "./ngx-store.facade";
|
|
4
|
-
/**
|
|
5
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
6
|
-
* @email vito.salvia@gmail.com
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class NgxAbstractStoreFacade<B extends Model> implements INgxStoreFacade<B> {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param bean
|
|
12
|
-
*/
|
|
13
|
-
abstract addBean(bean: B): any;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
abstract clearStore(): any;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param id
|
|
21
|
-
*/
|
|
22
|
-
abstract deleteBean(id: string | number): any;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param from
|
|
26
|
-
* @param size
|
|
27
|
-
* @param params
|
|
28
|
-
*/
|
|
29
|
-
abstract searchByValue(from: number, size: number, params: any): any;
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
abstract getTotal(): Observable<number>;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
abstract loadStore(): any;
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param from
|
|
41
|
-
* @param size
|
|
42
|
-
* @param param
|
|
43
|
-
*/
|
|
44
|
-
abstract selectPaginatedBeans(from: number, size: number, param?: string): any;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param id
|
|
48
|
-
*/
|
|
49
|
-
abstract selectorBeanById(id: string | number): any;
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param bean
|
|
53
|
-
*/
|
|
54
|
-
abstract updateBean(bean: B): any;
|
|
55
|
-
}
|
package/lib/ngx-actions.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
3
|
-
* @email vito.salvia@gmail.com
|
|
4
|
-
*/
|
|
5
|
-
export declare const CLEAR_STATE = "[Service] Clear State";
|
|
6
|
-
export declare const serviceSuccess: import("@ngrx/store").ActionCreator<"[Service] Service Success", () => import("@ngrx/store").Action<"[Service] Service Success">>;
|
|
7
|
-
export declare const afterDeleting: import("@ngrx/store").ActionCreator<"[Service] Service After Deleting", () => import("@ngrx/store").Action<"[Service] Service After Deleting">>;
|
|
8
|
-
export declare const afterUpdating: import("@ngrx/store").ActionCreator<"[Service] Service After Updating", (props: {
|
|
9
|
-
table: any;
|
|
10
|
-
bean: any;
|
|
11
|
-
}) => {
|
|
12
|
-
table: any;
|
|
13
|
-
bean: any;
|
|
14
|
-
} & import("@ngrx/store").Action<"[Service] Service After Updating">>;
|
|
15
|
-
export declare const reloadTable: import("@ngrx/store").ActionCreator<"[Service] Reload View", (props: {
|
|
16
|
-
table: any;
|
|
17
|
-
}) => {
|
|
18
|
-
table: any;
|
|
19
|
-
} & import("@ngrx/store").Action<"[Service] Reload View">>;
|
|
20
|
-
export declare const clearState: import("@ngrx/store").ActionCreator<"[Service] Clear State", () => import("@ngrx/store").Action<"[Service] Clear State">>;
|
package/lib/ngx-effects.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Actions } from "@ngrx/effects";
|
|
2
|
-
import { Store } from "@ngrx/store";
|
|
3
|
-
import { NgxUtilityServiceService } from "@geosdi/ngx-utility-service";
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
7
|
-
* @email vito.salvia@gmail.com
|
|
8
|
-
*/
|
|
9
|
-
export declare class NgxEffects {
|
|
10
|
-
private actions$;
|
|
11
|
-
private utilityService;
|
|
12
|
-
private appStore;
|
|
13
|
-
onSuccess$: import("rxjs").Observable<import("@ngrx/store").Action<"[Service] Service Success">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
14
|
-
onDeleting$: import("rxjs").Observable<import("@ngrx/store").Action<"[Service] Service After Deleting">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
15
|
-
onUpdating$: import("rxjs").Observable<void> & import("@ngrx/effects").CreateEffectMetadata;
|
|
16
|
-
constructor(actions$: Actions, utilityService: NgxUtilityServiceService, appStore: Store);
|
|
17
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<NgxEffects, never>;
|
|
18
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<NgxEffects>;
|
|
19
|
-
}
|
package/lib/ngx-state.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Model } from "@geosdi/ngx-model";
|
|
2
|
-
import { EntityAdapter, EntityState } from "@ngrx/entity";
|
|
3
|
-
/**
|
|
4
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
5
|
-
* @email vito.salvia@gmail.com
|
|
6
|
-
*/
|
|
7
|
-
export interface NgxAppState {
|
|
8
|
-
}
|
|
9
|
-
export interface NgxState<B extends Model> extends EntityState<B> {
|
|
10
|
-
paginatedBeanLoaded: boolean;
|
|
11
|
-
total: number;
|
|
12
|
-
}
|
|
13
|
-
export declare function selectModelId(model: Model): any;
|
|
14
|
-
export declare function getAdapterIntialState<B extends Model>(adapter: EntityAdapter<B>): EntityState<B> & {
|
|
15
|
-
paginatedBeanLoaded: boolean;
|
|
16
|
-
total: number;
|
|
17
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Model } from "@geosdi/ngx-model";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
|
-
/**
|
|
4
|
-
* @author Vito Salvia - CNR IMAA geoSDI Group
|
|
5
|
-
* @email vito.salvia@gmail.com
|
|
6
|
-
*/
|
|
7
|
-
export interface INgxStoreFacade<B extends Model> {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param from
|
|
11
|
-
* @param size
|
|
12
|
-
* @param param
|
|
13
|
-
*/
|
|
14
|
-
selectPaginatedBeans(from: number, size: number, param?: string): any;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param bean
|
|
18
|
-
*/
|
|
19
|
-
updateBean(bean: B): any;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param bean
|
|
23
|
-
*/
|
|
24
|
-
addBean(bean: B): any;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
clearStore(): any;
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
loadStore(): any;
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param id
|
|
36
|
-
*/
|
|
37
|
-
deleteBean(id: string | number): any;
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
getTotal(): Observable<number>;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param id
|
|
45
|
-
*/
|
|
46
|
-
selectorBeanById(id: string | number): any;
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @param from
|
|
50
|
-
* @param size
|
|
51
|
-
* @param params
|
|
52
|
-
*/
|
|
53
|
-
searchByValue(from: number, size: number, params: any): any;
|
|
54
|
-
}
|