@websolutespa/bom-mixer-store 1.4.1 → 1.4.3

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: CachedService, Decorators, LocalApi, MockApi, MockStore, RemoteApi, RemoteStore, StoreHandler
8
+
9
+ ## 1.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Added: Decorators, CachedService, RemotePageService, RemoteMenuService, StoreStrategy.DecoratedApi, nextPhase, storeCacheDuration
14
+ - Modified: RemoteStore
15
+ - Updated dependencies
16
+ - @websolutespa/bom-core@0.6.4
17
+
3
18
  ## 1.4.1
4
19
 
5
20
  ### Patch Changes
@@ -12,95 +27,95 @@
12
27
 
13
28
  ### Minor Changes
14
29
 
15
- - Added: BuildStrategy.
30
+ - Added: BuildStrategy
16
31
 
17
32
  ## 1.3.0
18
33
 
19
34
  ### Minor Changes
20
35
 
21
- - Added: storeIndexHandler.
22
- - Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService.
36
+ - Added: storeIndexHandler
37
+ - Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService
23
38
 
24
39
  ## 1.2.2
25
40
 
26
41
  ### Patch Changes
27
42
 
28
- - Modified: MockMenuService IPageRelationResult.
43
+ - Modified: MockMenuService IPageRelationResult
29
44
 
30
45
  ## 1.2.1
31
46
 
32
47
  ### Patch Changes
33
48
 
34
- - Fixing: MockMenuService collectPages.
49
+ - Fixing: MockMenuService collectPages
35
50
 
36
51
  ## 1.2.0
37
52
 
38
53
  ### Minor Changes
39
54
 
40
- - Updating: next 13.
55
+ - Updating: next 13
41
56
 
42
57
  ## 1.1.1
43
58
 
44
59
  ### Patch Changes
45
60
 
46
- - Fixing: check redirects by pattern.
61
+ - Fixing: check redirects by pattern
47
62
 
48
63
  ## 1.1.0
49
64
 
50
65
  ### Minor Changes
51
66
 
52
- - Modified: store refactor.
67
+ - Modified: store refactor
53
68
 
54
69
  ## 1.0.1
55
70
 
56
71
  ### Patch Changes
57
72
 
58
- - Fixing: localhost url.
73
+ - Fixing: localhost url
59
74
 
60
75
  ## 1.0.0
61
76
 
62
77
  ### Minor Changes
63
78
 
64
- - Modified routes, added redirects.
79
+ - Modified routes, added redirects
65
80
 
66
81
  ## 0.3.2
67
82
 
68
83
  ### Patch Changes
69
84
 
70
- - Modified: MockMenuService.
85
+ - Modified: MockMenuService
71
86
 
72
87
  ## 0.3.1
73
88
 
74
89
  ### Patch Changes
75
90
 
76
- - Added: source files.
91
+ - Added: source files
77
92
 
78
93
  ## 0.3.0
79
94
 
80
95
  ### Minor Changes
81
96
 
82
- - Added: splat routes.
97
+ - Added: splat routes
83
98
 
84
99
  ## 0.2.0
85
100
 
86
101
  ### Minor Changes
87
102
 
88
- - Added: @websolutespa/bom-core.
103
+ - Added: @websolutespa/bom-core
89
104
 
90
105
  ## 0.1.1
91
106
 
92
107
  ### Patch Changes
93
108
 
94
- - Modified: store service.
109
+ - Modified: store service
95
110
 
96
111
  ## 0.1.0
97
112
 
98
113
  ### Minor Changes
99
114
 
100
- - mock refactor.
115
+ - mock refactor
101
116
 
102
117
  ## 0.0.2
103
118
 
104
119
  ### Patch Changes
105
120
 
106
- - Added: first release.
121
+ - Added: first release
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, ISchema, IMemoryStore, IQuerable, IEquatable, Pagination } from '@websolutespa/bom-core';
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
- constructor(key: string);
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[];
@@ -155,7 +206,8 @@ declare function collectionPatch<T extends IStore>(storePromise: () => Promise<T
155
206
  declare function collectionDelete<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
156
207
  declare function routePost(store: IStore, request: NextApiRequest, response: NextApiResponse): Promise<void>;
157
208
  declare function storeIndexHandler(): any;
209
+ declare function findRoute(store: IStore, pathname: string, href: string): Promise<IRoute | undefined>;
158
210
 
159
211
  declare function getStore<T extends IStore>(): Promise<T>;
160
212
 
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 };
213
+ 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, findRoute, 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 };