@websolutespa/bom-mixer-store 1.7.1 → 1.7.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 +178 -164
- package/dist/index.d.ts +8 -7
- package/dist/index.js +6 -4
- package/dist/index.mjs +5 -4
- package/package.json +5 -5
- package/src/api/api.handler.ts +5 -4
- package/src/remote/remote.api.ts +1 -1
- package/src/store/store.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,164 +1,178 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-store
|
|
2
|
-
|
|
3
|
-
## 1.7.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## 1.
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
## 1.
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
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
|
-
## 1.
|
|
76
|
-
|
|
77
|
-
###
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1
|
+
# @websolutespa/bom-mixer-store
|
|
2
|
+
|
|
3
|
+
## 1.7.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updating: dependencies
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @websolutespa/bom-core@1.7.3
|
|
10
|
+
|
|
11
|
+
## 1.7.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 7898849: Modified: exporting getRemoteApiUrl
|
|
16
|
+
|
|
17
|
+
## 1.7.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Fixing: findRoute redirects
|
|
22
|
+
|
|
23
|
+
## 1.7.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 28e86bd: Modified: IPage, Store services & decorators
|
|
28
|
+
- Updated dependencies [28e86bd]
|
|
29
|
+
- @websolutespa/bom-core@1.7.0
|
|
30
|
+
|
|
31
|
+
## 1.6.0
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- f664993: Added: useLivePreview
|
|
36
|
+
- Updated dependencies [6cbf4cb]
|
|
37
|
+
- @websolutespa/bom-core@0.6.7
|
|
38
|
+
|
|
39
|
+
## 1.4.6
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Fixing: CachedService findMany DecoratedApi
|
|
44
|
+
|
|
45
|
+
## 1.4.5
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Fixing: decorateSchema
|
|
50
|
+
|
|
51
|
+
## 1.4.4
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Added: Schema decorator
|
|
56
|
+
- Modified: RemoteMenuService, RemotePageService, RemoteService
|
|
57
|
+
- Updated dependencies
|
|
58
|
+
- @websolutespa/bom-core@0.6.5
|
|
59
|
+
|
|
60
|
+
## 1.4.3
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Modified: CachedService, Decorators, LocalApi, MockApi, MockStore, RemoteApi, RemoteStore, StoreHandler
|
|
65
|
+
|
|
66
|
+
## 1.4.2
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Added: Decorators, CachedService, RemotePageService, RemoteMenuService, StoreStrategy.DecoratedApi, nextPhase, storeCacheDuration
|
|
71
|
+
- Modified: RemoteStore
|
|
72
|
+
- Updated dependencies
|
|
73
|
+
- @websolutespa/bom-core@0.6.4
|
|
74
|
+
|
|
75
|
+
## 1.4.1
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Modified: MockPageService
|
|
80
|
+
- Updated dependencies
|
|
81
|
+
- @websolutespa/bom-core@0.6.3
|
|
82
|
+
|
|
83
|
+
## 1.4.0
|
|
84
|
+
|
|
85
|
+
### Minor Changes
|
|
86
|
+
|
|
87
|
+
- Added: BuildStrategy
|
|
88
|
+
|
|
89
|
+
## 1.3.0
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- Added: storeIndexHandler
|
|
94
|
+
- Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService
|
|
95
|
+
|
|
96
|
+
## 1.2.2
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Modified: MockMenuService IPageRelationResult
|
|
101
|
+
|
|
102
|
+
## 1.2.1
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Fixing: MockMenuService collectPages
|
|
107
|
+
|
|
108
|
+
## 1.2.0
|
|
109
|
+
|
|
110
|
+
### Minor Changes
|
|
111
|
+
|
|
112
|
+
- Updating: next 13
|
|
113
|
+
|
|
114
|
+
## 1.1.1
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Fixing: check redirects by pattern
|
|
119
|
+
|
|
120
|
+
## 1.1.0
|
|
121
|
+
|
|
122
|
+
### Minor Changes
|
|
123
|
+
|
|
124
|
+
- Modified: store refactor
|
|
125
|
+
|
|
126
|
+
## 1.0.1
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Fixing: localhost url
|
|
131
|
+
|
|
132
|
+
## 1.0.0
|
|
133
|
+
|
|
134
|
+
### Minor Changes
|
|
135
|
+
|
|
136
|
+
- Modified routes, added redirects
|
|
137
|
+
|
|
138
|
+
## 0.3.2
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Modified: MockMenuService
|
|
143
|
+
|
|
144
|
+
## 0.3.1
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- Added: source files
|
|
149
|
+
|
|
150
|
+
## 0.3.0
|
|
151
|
+
|
|
152
|
+
### Minor Changes
|
|
153
|
+
|
|
154
|
+
- Added: splat routes
|
|
155
|
+
|
|
156
|
+
## 0.2.0
|
|
157
|
+
|
|
158
|
+
### Minor Changes
|
|
159
|
+
|
|
160
|
+
- Added: @websolutespa/bom-core
|
|
161
|
+
|
|
162
|
+
## 0.1.1
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- Modified: store service
|
|
167
|
+
|
|
168
|
+
## 0.1.0
|
|
169
|
+
|
|
170
|
+
### Minor Changes
|
|
171
|
+
|
|
172
|
+
- mock refactor
|
|
173
|
+
|
|
174
|
+
## 0.0.2
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Added: first release
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ declare const defaultApiRequestOptions: ApiRequestOptions;
|
|
|
7
7
|
declare function getDefaultApiRequestOptions(): ApiRequestOptions;
|
|
8
8
|
|
|
9
9
|
type ICrudMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | string;
|
|
10
|
-
type IHandler = (request: NextApiRequest, response: NextApiResponse) => Promise<
|
|
10
|
+
type IHandler<T = any> = (request: NextApiRequest, response: NextApiResponse<T>) => Promise<NextApiResponse<T> | void>;
|
|
11
11
|
type IApiHandler = Record<ICrudMethod, IHandler>;
|
|
12
|
-
declare function apiHandler(handler: IApiHandler):
|
|
13
|
-
declare function errorHandler(error: any, response: NextApiResponse):
|
|
12
|
+
declare function apiHandler<T = any>(handler: IApiHandler): IHandler<T>;
|
|
13
|
+
declare function errorHandler(error: any, response: NextApiResponse): NextApiResponse | void;
|
|
14
14
|
|
|
15
15
|
declare function fromCache<T = unknown>(callback: () => Promise<T>, key?: string): Promise<T>;
|
|
16
16
|
|
|
@@ -117,7 +117,7 @@ declare function mockApiPut<T = unknown>(url: string, payload: unknown, options?
|
|
|
117
117
|
declare function mockApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
118
118
|
declare function mockApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
119
119
|
|
|
120
|
-
declare function mockHandler(): any
|
|
120
|
+
declare function mockHandler(): IHandler<any>;
|
|
121
121
|
|
|
122
122
|
declare function getMockStoreFromData_<T extends IStore>(data?: IMemoryStore): T;
|
|
123
123
|
declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
|
|
@@ -152,6 +152,7 @@ declare class RemotePageService<T extends ICategorized = ICategorized> extends R
|
|
|
152
152
|
protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
declare function getRemoteApiUrl(pathname: string): string;
|
|
155
156
|
declare function remoteApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
|
|
156
157
|
declare function remoteApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
157
158
|
declare function remoteApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
@@ -224,15 +225,15 @@ declare function storeApiPut<T = unknown>(url: string, payload: unknown, options
|
|
|
224
225
|
declare function storeApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
225
226
|
declare function storeApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
|
|
226
227
|
|
|
227
|
-
declare function storeHandler<T extends IStore>(storePromise?: () => Promise<T>): any
|
|
228
|
+
declare function storeHandler<T extends IStore>(storePromise?: () => Promise<T>): IHandler<any>;
|
|
228
229
|
declare function collectionGet<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
229
230
|
declare function collectionPost<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
230
231
|
declare function collectionPatch<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
231
232
|
declare function collectionDelete<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
|
|
232
233
|
declare function routePost(store: IStore, request: NextApiRequest, response: NextApiResponse): Promise<void>;
|
|
233
|
-
declare function storeIndexHandler(): any
|
|
234
|
+
declare function storeIndexHandler(): IHandler<any>;
|
|
234
235
|
declare function findRoute(store: IStore, pathname: string, href: string, hrefBeforeRedirect: string | null): Promise<IRoute | undefined>;
|
|
235
236
|
|
|
236
237
|
declare function getStore<T extends IStore>(): Promise<T>;
|
|
237
238
|
|
|
238
|
-
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, IPageResolvedRelation, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, RemoteServiceStrategy, SERVICE_DEFAULT_DEPTH, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateLocalizable_, decorateLocalizables_, decorateMenu_, decorateMenus_, decorateNav_, decorateNavs_, decorateRelation_, decorateRelations_, decorateSchema_, decorateSchemas_, decorateStaticRelation_, decorateStaticRelations_, defaultApiRequestOptions, errorHandler, findRoute, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, getMockStoreFromData_, getRemoteStore, getStore, isApiRequest, isNextRequest, isStaticRequest, localApiDelete, localApiFetch, localApiGet, localApiPatch, localApiPost, localApiPut, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, nextPhase, optimizeMany_, optimizeOne_, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy };
|
|
239
|
+
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, IPageResolvedRelation, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, RemoteServiceStrategy, SERVICE_DEFAULT_DEPTH, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateCategories_, decorateCategory_, decorateHref_, decorateHrefs_, decorateLocalizable_, decorateLocalizables_, decorateMenu_, decorateMenus_, decorateNav_, decorateNavs_, decorateRelation_, decorateRelations_, decorateSchema_, decorateSchemas_, decorateStaticRelation_, decorateStaticRelations_, defaultApiRequestOptions, errorHandler, findRoute, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, getMockStoreFromData_, getRemoteApiUrl, getRemoteStore, getStore, isApiRequest, isNextRequest, isStaticRequest, localApiDelete, localApiFetch, localApiGet, localApiPatch, localApiPost, localApiPut, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, nextPhase, optimizeMany_, optimizeOne_, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ __export(src_exports, {
|
|
|
77
77
|
getLocalApiUrl: () => getLocalApiUrl,
|
|
78
78
|
getMockStore: () => getMockStore,
|
|
79
79
|
getMockStoreFromData_: () => getMockStoreFromData_,
|
|
80
|
+
getRemoteApiUrl: () => getRemoteApiUrl,
|
|
80
81
|
getRemoteStore: () => getRemoteStore,
|
|
81
82
|
getStore: () => getStore,
|
|
82
83
|
isApiRequest: () => isApiRequest,
|
|
@@ -999,7 +1000,7 @@ var NextPhase = /* @__PURE__ */ ((NextPhase2) => {
|
|
|
999
1000
|
})(NextPhase || {});
|
|
1000
1001
|
function getNextPhase() {
|
|
1001
1002
|
let nextPhase2 = "phase-export" /* Export */;
|
|
1002
|
-
if (process && process.env.NEXT_PHASE) {
|
|
1003
|
+
if (typeof process !== "undefined" && process.env.NEXT_PHASE) {
|
|
1003
1004
|
nextPhase2 = process.env.NEXT_PHASE;
|
|
1004
1005
|
}
|
|
1005
1006
|
return nextPhase2;
|
|
@@ -1012,7 +1013,7 @@ var BuildStrategy = /* @__PURE__ */ ((BuildStrategy2) => {
|
|
|
1012
1013
|
})(BuildStrategy || {});
|
|
1013
1014
|
function getBuildStrategy() {
|
|
1014
1015
|
let buildStrategy2 = "static" /* Static */;
|
|
1015
|
-
if (process && process.env.BUILD_STRATEGY) {
|
|
1016
|
+
if (typeof process !== "undefined" && process.env.BUILD_STRATEGY) {
|
|
1016
1017
|
buildStrategy2 = process.env.BUILD_STRATEGY;
|
|
1017
1018
|
}
|
|
1018
1019
|
return buildStrategy2;
|
|
@@ -1027,7 +1028,7 @@ var StoreStrategy = /* @__PURE__ */ ((StoreStrategy2) => {
|
|
|
1027
1028
|
})(StoreStrategy || {});
|
|
1028
1029
|
function getStoreStrategy() {
|
|
1029
1030
|
let storeStrategy2 = "mock" /* Mock */;
|
|
1030
|
-
if (process && process.env.STORE_STRATEGY) {
|
|
1031
|
+
if (typeof process !== "undefined" && process.env.STORE_STRATEGY) {
|
|
1031
1032
|
storeStrategy2 = process.env.STORE_STRATEGY;
|
|
1032
1033
|
}
|
|
1033
1034
|
return storeStrategy2;
|
|
@@ -1035,7 +1036,7 @@ function getStoreStrategy() {
|
|
|
1035
1036
|
var storeStrategy = getStoreStrategy();
|
|
1036
1037
|
function getStoreCacheDuration() {
|
|
1037
1038
|
let storeCacheDuration2 = 1 * 60 * 1e3;
|
|
1038
|
-
if (process && process.env.STORE_CACHE_DURATION) {
|
|
1039
|
+
if (typeof process !== "undefined" && process.env.STORE_CACHE_DURATION) {
|
|
1039
1040
|
storeCacheDuration2 = parseInt(process.env.STORE_CACHE_DURATION);
|
|
1040
1041
|
}
|
|
1041
1042
|
return storeCacheDuration2;
|
|
@@ -2076,6 +2077,7 @@ async function storeApiDelete(url, options = {}) {
|
|
|
2076
2077
|
getLocalApiUrl,
|
|
2077
2078
|
getMockStore,
|
|
2078
2079
|
getMockStoreFromData_,
|
|
2080
|
+
getRemoteApiUrl,
|
|
2079
2081
|
getRemoteStore,
|
|
2080
2082
|
getStore,
|
|
2081
2083
|
isApiRequest,
|
package/dist/index.mjs
CHANGED
|
@@ -891,7 +891,7 @@ var NextPhase = /* @__PURE__ */ ((NextPhase2) => {
|
|
|
891
891
|
})(NextPhase || {});
|
|
892
892
|
function getNextPhase() {
|
|
893
893
|
let nextPhase2 = "phase-export" /* Export */;
|
|
894
|
-
if (process && process.env.NEXT_PHASE) {
|
|
894
|
+
if (typeof process !== "undefined" && process.env.NEXT_PHASE) {
|
|
895
895
|
nextPhase2 = process.env.NEXT_PHASE;
|
|
896
896
|
}
|
|
897
897
|
return nextPhase2;
|
|
@@ -904,7 +904,7 @@ var BuildStrategy = /* @__PURE__ */ ((BuildStrategy2) => {
|
|
|
904
904
|
})(BuildStrategy || {});
|
|
905
905
|
function getBuildStrategy() {
|
|
906
906
|
let buildStrategy2 = "static" /* Static */;
|
|
907
|
-
if (process && process.env.BUILD_STRATEGY) {
|
|
907
|
+
if (typeof process !== "undefined" && process.env.BUILD_STRATEGY) {
|
|
908
908
|
buildStrategy2 = process.env.BUILD_STRATEGY;
|
|
909
909
|
}
|
|
910
910
|
return buildStrategy2;
|
|
@@ -919,7 +919,7 @@ var StoreStrategy = /* @__PURE__ */ ((StoreStrategy2) => {
|
|
|
919
919
|
})(StoreStrategy || {});
|
|
920
920
|
function getStoreStrategy() {
|
|
921
921
|
let storeStrategy2 = "mock" /* Mock */;
|
|
922
|
-
if (process && process.env.STORE_STRATEGY) {
|
|
922
|
+
if (typeof process !== "undefined" && process.env.STORE_STRATEGY) {
|
|
923
923
|
storeStrategy2 = process.env.STORE_STRATEGY;
|
|
924
924
|
}
|
|
925
925
|
return storeStrategy2;
|
|
@@ -927,7 +927,7 @@ function getStoreStrategy() {
|
|
|
927
927
|
var storeStrategy = getStoreStrategy();
|
|
928
928
|
function getStoreCacheDuration() {
|
|
929
929
|
let storeCacheDuration2 = 1 * 60 * 1e3;
|
|
930
|
-
if (process && process.env.STORE_CACHE_DURATION) {
|
|
930
|
+
if (typeof process !== "undefined" && process.env.STORE_CACHE_DURATION) {
|
|
931
931
|
storeCacheDuration2 = parseInt(process.env.STORE_CACHE_DURATION);
|
|
932
932
|
}
|
|
933
933
|
return storeCacheDuration2;
|
|
@@ -1967,6 +1967,7 @@ export {
|
|
|
1967
1967
|
getLocalApiUrl,
|
|
1968
1968
|
getMockStore,
|
|
1969
1969
|
getMockStoreFromData_,
|
|
1970
|
+
getRemoteApiUrl,
|
|
1970
1971
|
getRemoteStore,
|
|
1971
1972
|
getStore,
|
|
1972
1973
|
isApiRequest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-store",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Mixer Store module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@websolutespa/bom-core": "*",
|
|
30
30
|
"iron-session": ">= 6.2.1",
|
|
31
|
-
"next": ">=
|
|
31
|
+
"next": ">= 14.1.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/mime": "^3.0.1",
|
|
35
35
|
"@websolutespa/bom-cli": "*",
|
|
36
36
|
"@websolutespa/test": "*",
|
|
37
37
|
"@websolutespa/tsconfig": "*",
|
|
38
|
-
"eslint": "^
|
|
38
|
+
"eslint": "^9.0.0",
|
|
39
39
|
"eslint-config-websolute": "*",
|
|
40
40
|
"npm-run-all": "^4.1.5",
|
|
41
|
-
"ts-node": "^10.9.
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
42
|
"tsup": "^6.7.0",
|
|
43
|
-
"typescript": "^5.
|
|
43
|
+
"typescript": "^5.4.5"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
package/src/api/api.handler.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
1
2
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
2
3
|
|
|
3
4
|
export type ICrudMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | string;
|
|
4
5
|
|
|
5
|
-
export type IHandler = (request: NextApiRequest, response: NextApiResponse) => Promise<
|
|
6
|
+
export type IHandler<T = any> = (request: NextApiRequest, response: NextApiResponse<T>) => Promise<NextApiResponse<T> | void>;
|
|
6
7
|
|
|
7
8
|
export type IApiHandler = Record<ICrudMethod, IHandler>;
|
|
8
9
|
|
|
9
|
-
export function apiHandler(handler: IApiHandler):
|
|
10
|
-
return async (request: NextApiRequest, response: NextApiResponse): Promise<
|
|
10
|
+
export function apiHandler<T = any>(handler: IApiHandler): IHandler<T> {
|
|
11
|
+
return async (request: NextApiRequest, response: NextApiResponse<T>): Promise<NextApiResponse<T> | void> => {
|
|
11
12
|
const method: ICrudMethod = (request.method || 'GET').toLowerCase() as ICrudMethod;
|
|
12
13
|
// check handler supports HTTP method
|
|
13
14
|
if (!handler[method]) {
|
|
@@ -26,7 +27,7 @@ export function apiHandler(handler: IApiHandler): any {
|
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export function errorHandler(error: any, response: NextApiResponse):
|
|
30
|
+
export function errorHandler(error: any, response: NextApiResponse): NextApiResponse | void {
|
|
30
31
|
if (typeof (error) === 'string') {
|
|
31
32
|
// custom application error
|
|
32
33
|
const is404 = error.toLowerCase().endsWith('not found');
|
package/src/remote/remote.api.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ApiRequestOptions, getDefaultApiRequestOptions } from '../api/api';
|
|
|
8
8
|
const API_URL = process.env.STORE_URL;
|
|
9
9
|
const API_BASE = process.env.STORE_API || '/api';
|
|
10
10
|
|
|
11
|
-
function getRemoteApiUrl(pathname: string): string {
|
|
11
|
+
export function getRemoteApiUrl(pathname: string): string {
|
|
12
12
|
let url = `${API_URL}${API_BASE}${pathname}`;
|
|
13
13
|
// !!! node 18 issue -> require('dns').setDefaultResultOrder('ipv4first');
|
|
14
14
|
url = isBrowser ? url : url.replace('://localhost', '://127.0.0.1');
|
package/src/store/store.ts
CHANGED
|
@@ -11,7 +11,7 @@ export enum NextPhase {
|
|
|
11
11
|
|
|
12
12
|
function getNextPhase(): NextPhase {
|
|
13
13
|
let nextPhase = NextPhase.Export;
|
|
14
|
-
if (process && process.env.NEXT_PHASE) {
|
|
14
|
+
if (typeof process !== 'undefined' && process.env.NEXT_PHASE) {
|
|
15
15
|
nextPhase = process.env.NEXT_PHASE as NextPhase;
|
|
16
16
|
}
|
|
17
17
|
return nextPhase;
|
|
@@ -27,7 +27,7 @@ export enum BuildStrategy {
|
|
|
27
27
|
|
|
28
28
|
function getBuildStrategy(): BuildStrategy {
|
|
29
29
|
let buildStrategy = BuildStrategy.Static;
|
|
30
|
-
if (process && process.env.BUILD_STRATEGY) {
|
|
30
|
+
if (typeof process !== 'undefined' && process.env.BUILD_STRATEGY) {
|
|
31
31
|
buildStrategy = process.env.BUILD_STRATEGY as BuildStrategy;
|
|
32
32
|
}
|
|
33
33
|
return buildStrategy;
|
|
@@ -45,7 +45,7 @@ export enum StoreStrategy {
|
|
|
45
45
|
|
|
46
46
|
function getStoreStrategy(): StoreStrategy {
|
|
47
47
|
let storeStrategy = StoreStrategy.Mock;
|
|
48
|
-
if (process && process.env.STORE_STRATEGY) {
|
|
48
|
+
if (typeof process !== 'undefined' && process.env.STORE_STRATEGY) {
|
|
49
49
|
storeStrategy = process.env.STORE_STRATEGY as StoreStrategy;
|
|
50
50
|
}
|
|
51
51
|
return storeStrategy;
|
|
@@ -56,7 +56,7 @@ export const storeStrategy: StoreStrategy = getStoreStrategy();
|
|
|
56
56
|
// storeCacheDuration
|
|
57
57
|
function getStoreCacheDuration(): number {
|
|
58
58
|
let storeCacheDuration = (1 * 60 * 1000);
|
|
59
|
-
if (process && process.env.STORE_CACHE_DURATION) {
|
|
59
|
+
if (typeof process !== 'undefined' && process.env.STORE_CACHE_DURATION) {
|
|
60
60
|
storeCacheDuration = parseInt(process.env.STORE_CACHE_DURATION);
|
|
61
61
|
}
|
|
62
62
|
return storeCacheDuration;
|