@websolutespa/bom-mixer-store 1.4.0 → 1.4.2
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 +115 -98
- package/dist/index.d.ts +76 -25
- package/dist/index.js +998 -851
- package/dist/index.mjs +984 -847
- package/package.json +1 -1
- package/src/cached/cached.service.ts +97 -0
- package/src/decorators/href.ts +55 -0
- package/src/decorators/index.ts +6 -0
- package/src/decorators/localize.ts +20 -0
- package/src/decorators/menu.ts +348 -0
- package/src/decorators/nav.ts +71 -0
- package/src/decorators/relation.ts +98 -0
- package/src/index.ts +5 -0
- package/src/mock/mock-menu.service.ts +13 -318
- package/src/mock/mock-page.service.ts +15 -134
- package/src/mock/mock.service.ts +12 -124
- package/src/mock/mock.store.ts +3 -1
- package/src/remote/remote-menu.service.ts +33 -0
- package/src/remote/remote-page.service.ts +33 -0
- package/src/remote/remote.service.ts +9 -4
- package/src/remote/remote.store.ts +20 -4
- package/src/static/static.service.ts +10 -6
- package/src/store/store.handler.ts +5 -3
- package/src/store/store.service.ts +3 -3
- package/src/store/store.ts +35 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,98 +1,115 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-store
|
|
2
|
-
|
|
3
|
-
## 1.4.
|
|
4
|
-
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- Added:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
# @websolutespa/bom-mixer-store
|
|
2
|
+
|
|
3
|
+
## 1.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: Decorators, CachedService, RemotePageService, RemoteMenuService, StoreStrategy.DecoratedApi, nextPhase, storeCacheDuration.
|
|
8
|
+
- Modified: RemoteStore.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @websolutespa/bom-core@0.6.4
|
|
11
|
+
|
|
12
|
+
## 1.4.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Modified: MockPageService.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @websolutespa/bom-core@0.6.3
|
|
19
|
+
|
|
20
|
+
## 1.4.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- Added: BuildStrategy.
|
|
25
|
+
|
|
26
|
+
## 1.3.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- Added: storeIndexHandler.
|
|
31
|
+
- Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService.
|
|
32
|
+
|
|
33
|
+
## 1.2.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Modified: MockMenuService IPageRelationResult.
|
|
38
|
+
|
|
39
|
+
## 1.2.1
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Fixing: MockMenuService collectPages.
|
|
44
|
+
|
|
45
|
+
## 1.2.0
|
|
46
|
+
|
|
47
|
+
### Minor Changes
|
|
48
|
+
|
|
49
|
+
- Updating: next 13.
|
|
50
|
+
|
|
51
|
+
## 1.1.1
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Fixing: check redirects by pattern.
|
|
56
|
+
|
|
57
|
+
## 1.1.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- Modified: store refactor.
|
|
62
|
+
|
|
63
|
+
## 1.0.1
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Fixing: localhost url.
|
|
68
|
+
|
|
69
|
+
## 1.0.0
|
|
70
|
+
|
|
71
|
+
### Minor Changes
|
|
72
|
+
|
|
73
|
+
- Modified routes, added redirects.
|
|
74
|
+
|
|
75
|
+
## 0.3.2
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Modified: MockMenuService.
|
|
80
|
+
|
|
81
|
+
## 0.3.1
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Added: source files.
|
|
86
|
+
|
|
87
|
+
## 0.3.0
|
|
88
|
+
|
|
89
|
+
### Minor Changes
|
|
90
|
+
|
|
91
|
+
- Added: splat routes.
|
|
92
|
+
|
|
93
|
+
## 0.2.0
|
|
94
|
+
|
|
95
|
+
### Minor Changes
|
|
96
|
+
|
|
97
|
+
- Added: @websolutespa/bom-core.
|
|
98
|
+
|
|
99
|
+
## 0.1.1
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- Modified: store service.
|
|
104
|
+
|
|
105
|
+
## 0.1.0
|
|
106
|
+
|
|
107
|
+
### Minor Changes
|
|
108
|
+
|
|
109
|
+
- mock refactor.
|
|
110
|
+
|
|
111
|
+
## 0.0.2
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- Added: first release.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FetchRequestOptions,
|
|
1
|
+
import { FetchRequestOptions, ISchema, IStore, QueryParams, IUndecoratedMenu, IMenu, IRoute, IEntity, JsonService, IMemoryStore, IQuerable, IEquatable, IPagedResult } from '@websolutespa/bom-core';
|
|
2
2
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
3
3
|
import { NextRequest } from 'next/server';
|
|
4
4
|
|
|
@@ -14,6 +14,33 @@ declare function errorHandler(error: any, response: NextApiResponse): Promise<an
|
|
|
14
14
|
|
|
15
15
|
declare function fromCache<T = unknown>(callback: () => Promise<T>, key?: string): Promise<T>;
|
|
16
16
|
|
|
17
|
+
declare function decorateHref_<T extends ISchema = ISchema>(store: IStore, item: T, params?: QueryParams): Promise<T | T & {
|
|
18
|
+
href: string | null;
|
|
19
|
+
}>;
|
|
20
|
+
declare function decorateHrefs_<T extends ISchema = ISchema>(store: IStore, items: T[], params?: QueryParams): Promise<T[] | (T & {
|
|
21
|
+
href: string | null;
|
|
22
|
+
})[]>;
|
|
23
|
+
|
|
24
|
+
declare function localizeItem_<B>(item: B, params?: QueryParams): Promise<B>;
|
|
25
|
+
declare function localizeItems_<B>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
26
|
+
|
|
27
|
+
declare function decorateMenu_(store: IStore, item: IUndecoratedMenu, params: {
|
|
28
|
+
market: string;
|
|
29
|
+
locale: string;
|
|
30
|
+
}): Promise<IMenu>;
|
|
31
|
+
declare function decorateMenus_(store: IStore, items: IUndecoratedMenu[], params: {
|
|
32
|
+
market: string;
|
|
33
|
+
locale: string;
|
|
34
|
+
}): Promise<IMenu[]>;
|
|
35
|
+
declare const MAX_INT = 1000000000000;
|
|
36
|
+
|
|
37
|
+
declare function decorateNav_<T extends ISchema = ISchema>(store: IStore, item: T, params?: QueryParams, routes?: IRoute[]): Promise<T>;
|
|
38
|
+
declare function decorateNavs_<T extends ISchema = ISchema>(store: IStore, items: T[], params?: QueryParams): Promise<T[]>;
|
|
39
|
+
|
|
40
|
+
declare const SERVICE_DEFAULT_DEPTH = 2;
|
|
41
|
+
declare function decorateRelation_<T extends ISchema = ISchema>(store: IStore, item: T, params?: QueryParams): Promise<T>;
|
|
42
|
+
declare function decorateRelations_<T extends ISchema = ISchema>(store: IStore, items: T[], params?: QueryParams): Promise<T[]>;
|
|
43
|
+
|
|
17
44
|
declare function getLocalApiUrl(pathname: string): string;
|
|
18
45
|
declare function localApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions, serviceOptions?: {
|
|
19
46
|
locale: string;
|
|
@@ -44,6 +71,23 @@ declare function isStaticRequest(request: NextRequest): boolean;
|
|
|
44
71
|
declare function isNextRequest(request: NextRequest): boolean;
|
|
45
72
|
declare function isApiRequest(request: NextRequest): boolean;
|
|
46
73
|
|
|
74
|
+
declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
|
|
75
|
+
store: IStore;
|
|
76
|
+
constructor(items: T[], store: IStore);
|
|
77
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
78
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare class MockMenuService<T extends IEntity = IEntity> extends MockService<T> {
|
|
82
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
83
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare class MockPageService<T extends IEntity = IEntity> extends MockService<T> {
|
|
87
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
88
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
89
|
+
}
|
|
90
|
+
|
|
47
91
|
declare function mockApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
|
|
48
92
|
declare function mockApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
49
93
|
declare function mockApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
@@ -53,39 +97,19 @@ declare function mockApiDelete<T = unknown>(url: string, options?: ApiRequestOpt
|
|
|
53
97
|
|
|
54
98
|
declare function mockHandler(): any;
|
|
55
99
|
|
|
56
|
-
declare const MOCK_SERVICE_DEFAULT_DEPTH = 2;
|
|
57
|
-
declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
|
|
58
|
-
store: IStore;
|
|
59
|
-
constructor(items: T[], store: IStore);
|
|
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[]>;
|
|
62
|
-
}
|
|
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[]>;
|
|
67
|
-
|
|
68
100
|
declare function getMockStoreFromData_<T extends IStore>(data?: IMemoryStore): T;
|
|
69
101
|
declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
|
|
70
102
|
|
|
71
|
-
declare function remoteApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
|
|
72
|
-
declare function remoteApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
73
|
-
declare function remoteApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
74
|
-
declare function remoteApiPut<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
75
|
-
declare function remoteApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
76
|
-
declare function remoteApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
77
|
-
|
|
78
103
|
/**
|
|
79
104
|
* This service handle call to remote api (bowl or over)
|
|
80
105
|
*/
|
|
81
106
|
declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
82
107
|
key: string;
|
|
83
|
-
|
|
108
|
+
store: IStore;
|
|
109
|
+
constructor(key: string, store: IStore);
|
|
84
110
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
85
111
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
86
|
-
findPaged<B extends T = T>(params?: QueryParams): Promise<
|
|
87
|
-
docs: B[];
|
|
88
|
-
} & Pagination>;
|
|
112
|
+
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
89
113
|
create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
|
|
90
114
|
update<B extends T = T>(payload: Partial<B>): Promise<B>;
|
|
91
115
|
delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
|
|
@@ -93,6 +117,23 @@ declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
93
117
|
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
94
118
|
}
|
|
95
119
|
|
|
120
|
+
declare class RemoteMenuService<T extends IEntity = IEntity> extends RemoteService<T> {
|
|
121
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
122
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class RemotePageService<T extends IEntity = IEntity> extends RemoteService<T> {
|
|
126
|
+
protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
|
|
127
|
+
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare function remoteApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
|
|
131
|
+
declare function remoteApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
132
|
+
declare function remoteApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
133
|
+
declare function remoteApiPut<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
134
|
+
declare function remoteApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
135
|
+
declare function remoteApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
136
|
+
|
|
96
137
|
declare function getRemoteStore<T extends IStore>(): Promise<T>;
|
|
97
138
|
|
|
98
139
|
type IField = {
|
|
@@ -126,6 +167,14 @@ declare class StaticService<T extends IEntity = IEntity> extends JsonService<T>
|
|
|
126
167
|
declare function decorateStaticRelation_<T>(store: IStore, fields: IField[], item: T, params?: QueryParams): Promise<T>;
|
|
127
168
|
declare function decorateStaticRelations_<T>(store: IStore, fields: IField[], items: T[], params?: QueryParams): Promise<T[]>;
|
|
128
169
|
|
|
170
|
+
declare enum NextPhase {
|
|
171
|
+
Export = "phase-export",
|
|
172
|
+
ProductionBuild = "phase-production-build",
|
|
173
|
+
ProductionServer = "phase-production-server",
|
|
174
|
+
DevelopmentServer = "phase-development-server",
|
|
175
|
+
Test = "phase-test"
|
|
176
|
+
}
|
|
177
|
+
declare const nextPhase: NextPhase;
|
|
129
178
|
declare enum BuildStrategy {
|
|
130
179
|
Static = "static",
|
|
131
180
|
Runtime = "runtime"
|
|
@@ -133,10 +182,12 @@ declare enum BuildStrategy {
|
|
|
133
182
|
declare const buildStrategy: BuildStrategy;
|
|
134
183
|
declare enum StoreStrategy {
|
|
135
184
|
Api = "api",
|
|
185
|
+
DecoratedApi = "decoratedApi",
|
|
136
186
|
Data = "data",
|
|
137
187
|
Mock = "mock"
|
|
138
188
|
}
|
|
139
189
|
declare const storeStrategy: StoreStrategy;
|
|
190
|
+
declare const storeCacheDuration: number;
|
|
140
191
|
declare const MOCK_COLLECTIONS: string[];
|
|
141
192
|
declare const STATIC_COLLECTIONS: string[];
|
|
142
193
|
declare const KNOWN_COLLECTIONS: string[];
|
|
@@ -158,4 +209,4 @@ declare function storeIndexHandler(): any;
|
|
|
158
209
|
|
|
159
210
|
declare function getStore<T extends IStore>(): Promise<T>;
|
|
160
211
|
|
|
161
|
-
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS,
|
|
212
|
+
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, SERVICE_DEFAULT_DEPTH, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateHref_, decorateHrefs_, decorateMenu_, decorateMenus_, decorateNav_, decorateNavs_, 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, nextPhase, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy };
|