@websolutespa/bom-mixer-store 1.2.2 → 1.4.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/CHANGELOG.md +13 -0
- package/dist/index.d.ts +23 -10
- package/dist/index.js +606 -285
- package/dist/index.mjs +579 -269
- package/package.json +1 -1
- package/src/mock/mock-menu.service.ts +63 -28
- package/src/mock/mock-page.service.ts +133 -54
- package/src/mock/mock.service.ts +120 -45
- package/src/mock/mock.store.ts +1 -1
- package/src/remote/remote.service.ts +14 -9
- package/src/remote/remote.store.ts +21 -5
- package/src/static/static.service.ts +67 -50
- package/src/store/store.handler.ts +140 -8
- package/src/store/store.ts +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-store
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added: BuildStrategy.
|
|
8
|
+
|
|
9
|
+
## 1.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Added: storeIndexHandler.
|
|
14
|
+
- Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService.
|
|
15
|
+
|
|
3
16
|
## 1.2.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams,
|
|
1
|
+
import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, ISchema, IMemoryStore, IQuerable, IEquatable, Pagination } from '@websolutespa/bom-core';
|
|
2
2
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
3
3
|
import { NextRequest } from 'next/server';
|
|
4
4
|
|
|
@@ -53,14 +53,19 @@ declare function mockApiDelete<T = unknown>(url: string, options?: ApiRequestOpt
|
|
|
53
53
|
|
|
54
54
|
declare function mockHandler(): any;
|
|
55
55
|
|
|
56
|
+
declare const MOCK_SERVICE_DEFAULT_DEPTH = 2;
|
|
56
57
|
declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
|
|
57
58
|
store: IStore;
|
|
58
59
|
constructor(items: T[], store: IStore);
|
|
59
|
-
protected
|
|
60
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
61
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
60
62
|
}
|
|
61
|
-
declare function
|
|
62
|
-
declare function
|
|
63
|
+
declare function localizeItem_<B>(item: B, params?: QueryParams): Promise<B>;
|
|
64
|
+
declare function localizeItems_<B>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
65
|
+
declare function decorateRelation_<T extends ISchema = ISchema>(store: IStore, item: T, params?: QueryParams): Promise<T>;
|
|
66
|
+
declare function decorateRelations_<T extends ISchema = ISchema>(store: IStore, items: T[], params?: QueryParams): Promise<T[]>;
|
|
63
67
|
|
|
68
|
+
declare function getMockStoreFromData_<T extends IStore>(data?: IMemoryStore): T;
|
|
64
69
|
declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
|
|
65
70
|
|
|
66
71
|
declare function remoteApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
|
|
@@ -84,7 +89,8 @@ declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
84
89
|
create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
|
|
85
90
|
update<B extends T = T>(payload: Partial<B>): Promise<B>;
|
|
86
91
|
delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
|
|
87
|
-
protected
|
|
92
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
93
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
declare function getRemoteStore<T extends IStore>(): Promise<T>;
|
|
@@ -112,13 +118,19 @@ declare class StaticService<T extends IEntity = IEntity> extends JsonService<T>
|
|
|
112
118
|
config: StaticServiceConfig<T>;
|
|
113
119
|
store: IStore;
|
|
114
120
|
constructor(config: StaticServiceConfig<T>, store: IStore);
|
|
115
|
-
getItems<B extends T = T>(): Promise<B[]>;
|
|
116
|
-
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
117
121
|
protected mapItems_<B extends T = T>(items: B[], map?: MapTo): B[];
|
|
118
|
-
|
|
119
|
-
protected
|
|
122
|
+
getItems<B extends T = T>(): Promise<B[]>;
|
|
123
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
124
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
120
125
|
}
|
|
126
|
+
declare function decorateStaticRelation_<T>(store: IStore, fields: IField[], item: T, params?: QueryParams): Promise<T>;
|
|
127
|
+
declare function decorateStaticRelations_<T>(store: IStore, fields: IField[], items: T[], params?: QueryParams): Promise<T[]>;
|
|
121
128
|
|
|
129
|
+
declare enum BuildStrategy {
|
|
130
|
+
Static = "static",
|
|
131
|
+
Runtime = "runtime"
|
|
132
|
+
}
|
|
133
|
+
declare const buildStrategy: BuildStrategy;
|
|
122
134
|
declare enum StoreStrategy {
|
|
123
135
|
Api = "api",
|
|
124
136
|
Data = "data",
|
|
@@ -142,7 +154,8 @@ declare function collectionPost<T extends IStore>(storePromise: () => Promise<T>
|
|
|
142
154
|
declare function collectionPatch<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
143
155
|
declare function collectionDelete<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
144
156
|
declare function routePost(store: IStore, request: NextApiRequest, response: NextApiResponse): Promise<void>;
|
|
157
|
+
declare function storeIndexHandler(): any;
|
|
145
158
|
|
|
146
159
|
declare function getStore<T extends IStore>(): Promise<T>;
|
|
147
160
|
|
|
148
|
-
export { ApiRequestOptions, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, MapTo, MockService, RemoteService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, collectionDelete, collectionGet, collectionPatch, collectionPost, defaultApiRequestOptions, errorHandler, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, getRemoteStore, getStore, isApiRequest, isNextRequest,
|
|
161
|
+
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, MOCK_SERVICE_DEFAULT_DEPTH, MapTo, MockService, RemoteService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateRelation_, decorateRelations_, decorateStaticRelation_, decorateStaticRelations_, defaultApiRequestOptions, errorHandler, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, getMockStoreFromData_, getRemoteStore, getStore, isApiRequest, isNextRequest, isStaticRequest, localApiDelete, localApiFetch, localApiGet, localApiPatch, localApiPost, localApiPut, localizeItem_, localizeItems_, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeHandler, storeIndexHandler, storeStrategy };
|