@microphi/store 0.2.9 → 1.1.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/esm2020/lib/effect/effect.mjs +75 -0
- package/esm2020/lib/list/list.mjs +75 -0
- package/esm2020/lib/reduce/reduce.mjs +26 -0
- package/esm2020/lib/store/store.mjs +101 -0
- package/esm2020/lib/utilities/scan-instance.mjs +19 -0
- package/{esm2015/microphi-store.js → esm2020/microphi-store.mjs} +0 -0
- package/esm2020/public-api.mjs +8 -0
- package/fesm2015/microphi-store.mjs +305 -0
- package/fesm2015/microphi-store.mjs.map +1 -0
- package/fesm2020/microphi-store.mjs +303 -0
- package/fesm2020/microphi-store.mjs.map +1 -0
- package/index.d.ts +6 -0
- package/lib/effect/effect.d.ts +62 -0
- package/lib/effect/effect.d.ts.map +1 -0
- package/lib/list/list.d.ts +2 -1
- package/lib/list/list.d.ts.map +1 -0
- package/lib/reduce/reduce.d.ts +12 -0
- package/lib/reduce/reduce.d.ts.map +1 -0
- package/lib/store/store.d.ts +39 -0
- package/lib/store/store.d.ts.map +1 -0
- package/lib/utilities/scan-instance.d.ts +3 -0
- package/lib/utilities/scan-instance.d.ts.map +1 -0
- package/microphi-store.d.ts.map +1 -0
- package/package.json +22 -12
- package/public-api.d.ts +4 -8
- package/public-api.d.ts.map +1 -0
- package/bundles/microphi-store.umd.js +0 -1108
- package/bundles/microphi-store.umd.js.map +0 -1
- package/bundles/microphi-store.umd.min.js +0 -17
- package/bundles/microphi-store.umd.min.js.map +0 -1
- package/esm2015/lib/actions.js +0 -105
- package/esm2015/lib/base-store.js +0 -156
- package/esm2015/lib/effect.js +0 -11
- package/esm2015/lib/http-status/http-status.interceptor.js +0 -29
- package/esm2015/lib/http-status/http-status.store.js +0 -65
- package/esm2015/lib/list/list.js +0 -80
- package/esm2015/lib/observable-list/observable-list.js +0 -119
- package/esm2015/lib/reduce.js +0 -15
- package/esm2015/lib/store.js +0 -13
- package/esm2015/public-api.js +0 -13
- package/fesm2015/microphi-store.js +0 -588
- package/fesm2015/microphi-store.js.map +0 -1
- package/lib/actions.d.ts +0 -77
- package/lib/base-store.d.ts +0 -31
- package/lib/effect.d.ts +0 -2
- package/lib/http-status/http-status.interceptor.d.ts +0 -7
- package/lib/http-status/http-status.store.d.ts +0 -17
- package/lib/observable-list/observable-list.d.ts +0 -29
- package/lib/reduce.d.ts +0 -7
- package/lib/store.d.ts +0 -9
- package/microphi-store.d.ts +0 -4
- package/microphi-store.metadata.json +0 -1
package/lib/actions.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export declare const REQUEST_SUFFIX = "_REQUEST";
|
|
2
|
-
export declare const RESPONSE_SUFFIX = "_RESPONSE";
|
|
3
|
-
export declare const ERROR_SUFFIX = "_ERROR";
|
|
4
|
-
export interface Action {
|
|
5
|
-
type: string;
|
|
6
|
-
payload: any;
|
|
7
|
-
}
|
|
8
|
-
export interface RestActions {
|
|
9
|
-
request: string;
|
|
10
|
-
response: string;
|
|
11
|
-
error: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Action are defined with an enum. Such as:
|
|
15
|
-
*
|
|
16
|
-
* emun {
|
|
17
|
-
* GET_ALL,
|
|
18
|
-
* GET_ONE,
|
|
19
|
-
* DELETE,
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* For each action defined a REQUEST, a RESPONSE and an ERROR are associated to it.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
export declare class Actions<A extends any> {
|
|
27
|
-
/**
|
|
28
|
-
* Example:
|
|
29
|
-
* {
|
|
30
|
-
* 0: { request: 'ACTION_NAME_REQUEST', response: 'ACTION_NAME_RESPONSE', error: 'ACTION_NAME_ERROR' }
|
|
31
|
-
* [....]
|
|
32
|
-
* }
|
|
33
|
-
*/
|
|
34
|
-
actions: {
|
|
35
|
-
[k: number]: RestActions;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Example:
|
|
39
|
-
* {
|
|
40
|
-
* ACTION_NAME: 0
|
|
41
|
-
* [....]
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
names: {
|
|
46
|
-
[actionName: string]: number;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Example:
|
|
50
|
-
* {
|
|
51
|
-
* 0: 'ACTION_NAME',
|
|
52
|
-
* [....]
|
|
53
|
-
*
|
|
54
|
-
* }
|
|
55
|
-
*/
|
|
56
|
-
codes: {
|
|
57
|
-
[actionCode: number]: string;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Example:
|
|
61
|
-
* {
|
|
62
|
-
* ACTION_NAME': { request: 'ACTION_NAME_REQUEST', response: 'ACTION_NAME_RESPONSE', error: 'ACTION_NAME_ERROR' }
|
|
63
|
-
* [....]
|
|
64
|
-
* }
|
|
65
|
-
*/
|
|
66
|
-
restActionsByName: {
|
|
67
|
-
[name: string]: RestActions;
|
|
68
|
-
};
|
|
69
|
-
constructor(actions: A);
|
|
70
|
-
private static createAction;
|
|
71
|
-
getByName(actionName: string): number;
|
|
72
|
-
getByCode(code: number): string;
|
|
73
|
-
getActionsByCode(key: number): RestActions;
|
|
74
|
-
getActionsByName(actionName: string): RestActions;
|
|
75
|
-
getActionNameFromChild(childAction: string): string;
|
|
76
|
-
getActionCodeFromChild(childAction: string): number;
|
|
77
|
-
}
|
package/lib/base-store.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { OnDestroy } from '@angular/core';
|
|
3
|
-
export declare abstract class BaseStore<T extends {}> implements OnDestroy {
|
|
4
|
-
private logger;
|
|
5
|
-
private readonly storeMetadata;
|
|
6
|
-
private readonly actionsMetadata;
|
|
7
|
-
private _state;
|
|
8
|
-
private get state();
|
|
9
|
-
private set state(value);
|
|
10
|
-
private _store$;
|
|
11
|
-
get store$(): Observable<T>;
|
|
12
|
-
private actions$;
|
|
13
|
-
private _loading$;
|
|
14
|
-
get loading$(): Observable<{
|
|
15
|
-
type: string;
|
|
16
|
-
code?: number;
|
|
17
|
-
payload: any;
|
|
18
|
-
status: boolean;
|
|
19
|
-
}>;
|
|
20
|
-
private _error$;
|
|
21
|
-
get error$(): Observable<{
|
|
22
|
-
action: number;
|
|
23
|
-
error: any;
|
|
24
|
-
}>;
|
|
25
|
-
private destroy$;
|
|
26
|
-
constructor();
|
|
27
|
-
dispatch(type: number, payload?: any): void;
|
|
28
|
-
private parseReducers;
|
|
29
|
-
private remapEffects;
|
|
30
|
-
ngOnDestroy(): void;
|
|
31
|
-
}
|
package/lib/effect.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
-
import { HttpStatusStore } from './http-status.store';
|
|
3
|
-
export declare class HttpStatusInterceptor implements HttpInterceptor {
|
|
4
|
-
private httpStatusStore;
|
|
5
|
-
constructor(httpStatusStore: HttpStatusStore);
|
|
6
|
-
intercept(req: HttpRequest<any>, next: HttpHandler): import("rxjs").Observable<import("@angular/common/http").HttpEvent<any>>;
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HttpErrorResponse } from '@angular/common/http';
|
|
2
|
-
import { BaseStore } from '../base-store';
|
|
3
|
-
export interface HttpState {
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
error?: HttpErrorResponse;
|
|
6
|
-
}
|
|
7
|
-
export declare enum HttpActions {
|
|
8
|
-
REQUEST = 0,
|
|
9
|
-
RESPONSE = 1,
|
|
10
|
-
ERROR = 2
|
|
11
|
-
}
|
|
12
|
-
export declare class HttpStatusStore extends BaseStore<HttpState> {
|
|
13
|
-
isLoading$: import("rxjs").Observable<boolean>;
|
|
14
|
-
private onRequest;
|
|
15
|
-
private onResponse;
|
|
16
|
-
onError(state: HttpState, err: any): HttpState;
|
|
17
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
export declare class ObservableList<T extends {}> {
|
|
3
|
-
private idFieldName;
|
|
4
|
-
private readonly ids;
|
|
5
|
-
private data;
|
|
6
|
-
private static difference;
|
|
7
|
-
private static intersection;
|
|
8
|
-
private static symmetricDifference;
|
|
9
|
-
constructor(items: T[], idFieldName?: string);
|
|
10
|
-
[Symbol.iterator](): IterableIterator<BehaviorSubject<T>>;
|
|
11
|
-
push(...items: T[]): void;
|
|
12
|
-
updateOne(item: T): void;
|
|
13
|
-
toJSON(): any[];
|
|
14
|
-
/**
|
|
15
|
-
* Will update items that are already present only if they need to be updated and remove items that are not present.
|
|
16
|
-
* @param items items of the list
|
|
17
|
-
*/
|
|
18
|
-
set(...items: T[]): void;
|
|
19
|
-
/**
|
|
20
|
-
* Remove an item from the list given its id
|
|
21
|
-
* @param id id of the item to remove
|
|
22
|
-
*/
|
|
23
|
-
removeItem(id: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Adds an new item to the list
|
|
26
|
-
* @param item the item to be added
|
|
27
|
-
*/
|
|
28
|
-
private addItem;
|
|
29
|
-
}
|
package/lib/reduce.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BaseStore } from './base-store';
|
|
2
|
-
export declare const ReduceMetadata = "@Reduce";
|
|
3
|
-
export interface Reducers {
|
|
4
|
-
[actionName: number]: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function Reduce(onAction: number): <Store extends BaseStore<any>>(target: Store, key: string) => void;
|
|
7
|
-
export declare function getReduceMetadata(instance: any): Reducers;
|
package/lib/store.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const StoreMetadata = "@Store";
|
|
2
|
-
export interface StoreOptions {
|
|
3
|
-
initialState: any;
|
|
4
|
-
name: string;
|
|
5
|
-
actions: any;
|
|
6
|
-
useLocalStorage?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function Store(options: StoreOptions): (target: any) => void;
|
|
9
|
-
export declare function getStoreMetadata(instance: any): StoreOptions;
|
package/microphi-store.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"metadata":{"REQUEST_SUFFIX":"_REQUEST","RESPONSE_SUFFIX":"_RESPONSE","ERROR_SUFFIX":"_ERROR","Action":{"__symbolic":"interface"},"RestActions":{"__symbolic":"interface"},"Actions":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":77,"character":23,"context":{"typeName":"A"},"module":"./lib/actions"}]}],"getByName":[{"__symbolic":"method"}],"getByCode":[{"__symbolic":"method"}],"getActionsByCode":[{"__symbolic":"method"}],"getActionsByName":[{"__symbolic":"method"}],"getActionNameFromChild":[{"__symbolic":"method"}],"getActionCodeFromChild":[{"__symbolic":"method"}]},"statics":{"createAction":{"__symbolic":"function","parameters":["key"],"value":{"request":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"reference","name":"key"},"right":"_REQUEST"},"response":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"reference","name":"key"},"right":"_RESPONSE"},"error":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"reference","name":"key"},"right":"_ERROR"}}}}},"BaseStore":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor"}],"dispatch":[{"__symbolic":"method"}],"parseReducers":[{"__symbolic":"method"}],"remapEffects":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}]}},"Effect":{"__symbolic":"function","parameters":["onAction"],"value":{"__symbolic":"error","message":"Lambda not supported","line":5,"character":9,"module":"./lib/effect"}},"ReduceMetadata":"@Reduce","Reducers":{"__symbolic":"interface"},"Reduce":{"__symbolic":"function","parameters":["onAction"],"value":{"__symbolic":"error","message":"Lambda not supported","line":10,"character":9,"module":"./lib/reduce"}},"getReduceMetadata":{"__symbolic":"function","parameters":["instance"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Reflect"},"member":"getMetadata"},"arguments":["@Reduce",{"__symbolic":"reference","name":"instance"}]},"right":{}}},"StoreMetadata":"@Store","StoreOptions":{"__symbolic":"interface"},"Store":{"__symbolic":"function"},"getStoreMetadata":{"__symbolic":"function","parameters":["instance"],"value":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Reflect"},"member":"getMetadata"},"arguments":["@Store",{"__symbolic":"select","expression":{"__symbolic":"reference","name":"instance"},"member":"constructor"}]}},"ObservableList":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":36,"character":21,"context":{"typeName":"T"},"module":"./lib/observable-list/observable-list"}]},null]}],"push":[{"__symbolic":"method"}],"updateOne":[{"__symbolic":"method"}],"toJSON":[{"__symbolic":"method"}],"set":[{"__symbolic":"method"}],"removeItem":[{"__symbolic":"method"}],"addItem":[{"__symbolic":"method"}]}},"HttpStatusInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":5,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"HttpStatusStore"}]}],"intercept":[{"__symbolic":"method"}]}},"HttpState":{"__symbolic":"interface"},"HttpActions":{"REQUEST":0,"RESPONSE":1,"ERROR":2},"HttpStatusStore":{"__symbolic":"class","extends":{"__symbolic":"reference","name":"BaseStore"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Store"},"arguments":[{"name":"httpStatusStore","initialState":{"isLoading":false,"error":null},"actions":{"__symbolic":"reference","name":"HttpActions"}}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":26,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"onRequest":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Reduce"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"HttpActions"},"member":"REQUEST"}]}]}],"onResponse":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Reduce"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"HttpActions"},"member":"RESPONSE"}]}]}],"onError":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"Reduce"},"arguments":[{"__symbolic":"select","expression":{"__symbolic":"reference","name":"HttpActions"},"member":"ERROR"}]}]}]},"statics":{"ɵprov":{}}},"List":{"__symbolic":"class","arity":1,"members":{"get":[{"__symbolic":"method"}],"getId":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":27,"character":24,"context":{"typeName":"EntityType"},"module":"./lib/list/list"}]},{"__symbolic":"reference","name":"$Keys","module":"utility-types","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":27,"character":61,"context":{"typeName":"EntityType"},"module":"./lib/list/list"}]}]}],"upsert":[{"__symbolic":"method"}],"prepend":[{"__symbolic":"method"}],"delete":[{"__symbolic":"method"}],"append":[{"__symbolic":"method"}]}}},"origins":{"REQUEST_SUFFIX":"./lib/actions","RESPONSE_SUFFIX":"./lib/actions","ERROR_SUFFIX":"./lib/actions","Action":"./lib/actions","RestActions":"./lib/actions","Actions":"./lib/actions","BaseStore":"./lib/base-store","Effect":"./lib/effect","ReduceMetadata":"./lib/reduce","Reducers":"./lib/reduce","Reduce":"./lib/reduce","getReduceMetadata":"./lib/reduce","StoreMetadata":"./lib/store","StoreOptions":"./lib/store","Store":"./lib/store","getStoreMetadata":"./lib/store","ObservableList":"./lib/observable-list/observable-list","HttpStatusInterceptor":"./lib/http-status/http-status.interceptor","HttpState":"./lib/http-status/http-status.store","HttpActions":"./lib/http-status/http-status.store","HttpStatusStore":"./lib/http-status/http-status.store","List":"./lib/list/list"},"importAs":"@microphi/store"}
|