@websolutespa/bom-mixer-store 1.7.6 → 1.7.7
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 +6 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +13 -6
- package/dist/index.mjs +11 -5
- package/package.json +1 -1
- package/src/api/api.ts +12 -1
- package/src/local/local.api.ts +2 -2
- package/src/mock/mock.api.ts +2 -3
- package/src/remote/remote.api.ts +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ import { NextRequest } from 'next/server';
|
|
|
4
4
|
import * as _websolutespa_bom_mixer_store from '@websolutespa/bom-mixer-store';
|
|
5
5
|
|
|
6
6
|
type ApiRequestOptions = FetchRequestOptions;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* !!! todo: evaluate authenticated end user bearer
|
|
9
|
+
*/
|
|
10
|
+
declare function getLocalApiRequestOptions(): ApiRequestOptions;
|
|
11
|
+
declare function getRemoteApiRequestOptions(): ApiRequestOptions;
|
|
8
12
|
|
|
9
13
|
type ICrudMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | string;
|
|
10
14
|
type IHandler<T = any> = (request: NextApiRequest, response: NextApiResponse<T>) => Promise<NextApiResponse<T> | void>;
|
|
@@ -238,4 +242,4 @@ declare function getStore<T extends IStore>(): Promise<T>;
|
|
|
238
242
|
|
|
239
243
|
declare function varsHandler(): _websolutespa_bom_mixer_store.IHandler<any>;
|
|
240
244
|
|
|
241
|
-
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_, errorHandler, findRoute, fromCache,
|
|
245
|
+
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_, errorHandler, findRoute, fromCache, getLocalApiRequestOptions, getLocalApiUrl, getMockStore, getMockStoreFromData_, getRemoteApiRequestOptions, 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, varsHandler };
|
package/dist/index.js
CHANGED
|
@@ -72,10 +72,11 @@ __export(src_exports, {
|
|
|
72
72
|
errorHandler: () => errorHandler,
|
|
73
73
|
findRoute: () => findRoute,
|
|
74
74
|
fromCache: () => fromCache,
|
|
75
|
-
|
|
75
|
+
getLocalApiRequestOptions: () => getLocalApiRequestOptions,
|
|
76
76
|
getLocalApiUrl: () => getLocalApiUrl,
|
|
77
77
|
getMockStore: () => getMockStore,
|
|
78
78
|
getMockStoreFromData_: () => getMockStoreFromData_,
|
|
79
|
+
getRemoteApiRequestOptions: () => getRemoteApiRequestOptions,
|
|
79
80
|
getRemoteApiUrl: () => getRemoteApiUrl,
|
|
80
81
|
getRemoteStore: () => getRemoteStore,
|
|
81
82
|
getStore: () => getStore,
|
|
@@ -120,7 +121,12 @@ __export(src_exports, {
|
|
|
120
121
|
module.exports = __toCommonJS(src_exports);
|
|
121
122
|
|
|
122
123
|
// src/api/api.ts
|
|
123
|
-
function
|
|
124
|
+
function getLocalApiRequestOptions() {
|
|
125
|
+
return {
|
|
126
|
+
headers: {}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function getRemoteApiRequestOptions() {
|
|
124
130
|
return {
|
|
125
131
|
// mode: 'cors',
|
|
126
132
|
headers: {
|
|
@@ -626,7 +632,7 @@ async function localApiFetch(pathname, options = {}, serviceOptions) {
|
|
|
626
632
|
url.searchParams.append("locale", serviceOptions.locale);
|
|
627
633
|
url.searchParams.append("market", serviceOptions.market);
|
|
628
634
|
}
|
|
629
|
-
const apiOptions = (0, import_bom_core6.merge)({ ...
|
|
635
|
+
const apiOptions = (0, import_bom_core6.merge)({ ...getLocalApiRequestOptions() }, options);
|
|
630
636
|
console.log("localApiFetch", apiOptions.method, url.href);
|
|
631
637
|
const apiResponse = await (0, import_bom_core6.httpFetch)(url.href, apiOptions);
|
|
632
638
|
return apiResponse;
|
|
@@ -763,7 +769,7 @@ function getMockApiUrl(pathname) {
|
|
|
763
769
|
}
|
|
764
770
|
async function mockApiFetch(pathname, options = {}) {
|
|
765
771
|
const url = getMockApiUrl(pathname);
|
|
766
|
-
const apiOptions = (0, import_bom_core8.merge)({ ...
|
|
772
|
+
const apiOptions = (0, import_bom_core8.merge)({ ...getLocalApiRequestOptions() }, options);
|
|
767
773
|
console.log("mockApiFetch", apiOptions.method, url);
|
|
768
774
|
const apiResponse = await (0, import_bom_core8.httpFetch)(url, apiOptions);
|
|
769
775
|
return apiResponse;
|
|
@@ -1359,7 +1365,7 @@ function getRemoteApiUrl(pathname) {
|
|
|
1359
1365
|
}
|
|
1360
1366
|
async function remoteApiFetch(pathname, options = {}) {
|
|
1361
1367
|
const url = getRemoteApiUrl(pathname);
|
|
1362
|
-
const apiOptions = (0, import_bom_core12.merge)({ ...
|
|
1368
|
+
const apiOptions = (0, import_bom_core12.merge)({ ...getRemoteApiRequestOptions() }, options);
|
|
1363
1369
|
console.log("remoteApiFetch", apiOptions.method, url);
|
|
1364
1370
|
const apiResponse = await (0, import_bom_core12.httpFetch)(url, apiOptions);
|
|
1365
1371
|
return apiResponse;
|
|
@@ -2338,10 +2344,11 @@ function varsHandler() {
|
|
|
2338
2344
|
errorHandler,
|
|
2339
2345
|
findRoute,
|
|
2340
2346
|
fromCache,
|
|
2341
|
-
|
|
2347
|
+
getLocalApiRequestOptions,
|
|
2342
2348
|
getLocalApiUrl,
|
|
2343
2349
|
getMockStore,
|
|
2344
2350
|
getMockStoreFromData_,
|
|
2351
|
+
getRemoteApiRequestOptions,
|
|
2345
2352
|
getRemoteApiUrl,
|
|
2346
2353
|
getRemoteStore,
|
|
2347
2354
|
getStore,
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/api/api.ts
|
|
10
|
-
function
|
|
10
|
+
function getLocalApiRequestOptions() {
|
|
11
|
+
return {
|
|
12
|
+
headers: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getRemoteApiRequestOptions() {
|
|
11
16
|
return {
|
|
12
17
|
// mode: 'cors',
|
|
13
18
|
headers: {
|
|
@@ -517,7 +522,7 @@ async function localApiFetch(pathname, options = {}, serviceOptions) {
|
|
|
517
522
|
url.searchParams.append("locale", serviceOptions.locale);
|
|
518
523
|
url.searchParams.append("market", serviceOptions.market);
|
|
519
524
|
}
|
|
520
|
-
const apiOptions = merge({ ...
|
|
525
|
+
const apiOptions = merge({ ...getLocalApiRequestOptions() }, options);
|
|
521
526
|
console.log("localApiFetch", apiOptions.method, url.href);
|
|
522
527
|
const apiResponse = await httpFetch(url.href, apiOptions);
|
|
523
528
|
return apiResponse;
|
|
@@ -654,7 +659,7 @@ function getMockApiUrl(pathname) {
|
|
|
654
659
|
}
|
|
655
660
|
async function mockApiFetch(pathname, options = {}) {
|
|
656
661
|
const url = getMockApiUrl(pathname);
|
|
657
|
-
const apiOptions = merge2({ ...
|
|
662
|
+
const apiOptions = merge2({ ...getLocalApiRequestOptions() }, options);
|
|
658
663
|
console.log("mockApiFetch", apiOptions.method, url);
|
|
659
664
|
const apiResponse = await httpFetch2(url, apiOptions);
|
|
660
665
|
return apiResponse;
|
|
@@ -1250,7 +1255,7 @@ function getRemoteApiUrl(pathname) {
|
|
|
1250
1255
|
}
|
|
1251
1256
|
async function remoteApiFetch(pathname, options = {}) {
|
|
1252
1257
|
const url = getRemoteApiUrl(pathname);
|
|
1253
|
-
const apiOptions = merge3({ ...
|
|
1258
|
+
const apiOptions = merge3({ ...getRemoteApiRequestOptions() }, options);
|
|
1254
1259
|
console.log("remoteApiFetch", apiOptions.method, url);
|
|
1255
1260
|
const apiResponse = await httpFetch3(url, apiOptions);
|
|
1256
1261
|
return apiResponse;
|
|
@@ -2228,10 +2233,11 @@ export {
|
|
|
2228
2233
|
errorHandler,
|
|
2229
2234
|
findRoute,
|
|
2230
2235
|
fromCache,
|
|
2231
|
-
|
|
2236
|
+
getLocalApiRequestOptions,
|
|
2232
2237
|
getLocalApiUrl,
|
|
2233
2238
|
getMockStore,
|
|
2234
2239
|
getMockStoreFromData_,
|
|
2240
|
+
getRemoteApiRequestOptions,
|
|
2235
2241
|
getRemoteApiUrl,
|
|
2236
2242
|
getRemoteStore,
|
|
2237
2243
|
getStore,
|
package/package.json
CHANGED
package/src/api/api.ts
CHANGED
|
@@ -2,7 +2,18 @@ import { FetchRequestOptions } from '@websolutespa/bom-core';
|
|
|
2
2
|
|
|
3
3
|
export type ApiRequestOptions = FetchRequestOptions;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* !!! todo: evaluate authenticated end user bearer
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function getLocalApiRequestOptions(): ApiRequestOptions {
|
|
10
|
+
return {
|
|
11
|
+
headers: {
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getRemoteApiRequestOptions(): ApiRequestOptions {
|
|
6
17
|
return {
|
|
7
18
|
// mode: 'cors',
|
|
8
19
|
headers: {
|
package/src/local/local.api.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
|
|
2
|
-
import { ApiRequestOptions,
|
|
2
|
+
import { ApiRequestOptions, getLocalApiRequestOptions } from '../api/api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This methods handle api requests / responses to local api (mixer)
|
|
@@ -27,7 +27,7 @@ export async function localApiFetch<T = unknown>(pathname: string, options: ApiR
|
|
|
27
27
|
url.searchParams.append('locale', serviceOptions.locale);
|
|
28
28
|
url.searchParams.append('market', serviceOptions.market);
|
|
29
29
|
}
|
|
30
|
-
const apiOptions = merge({ ...
|
|
30
|
+
const apiOptions = merge({ ...getLocalApiRequestOptions() }, options);
|
|
31
31
|
console.log('localApiFetch', apiOptions.method, url.href);
|
|
32
32
|
const apiResponse = await httpFetch(url.href, apiOptions);
|
|
33
33
|
// console.log('localApiFetch', pathname, apiResponse);
|
package/src/mock/mock.api.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
|
|
2
|
-
import { ApiRequestOptions,
|
|
2
|
+
import { ApiRequestOptions, getLocalApiRequestOptions } from '../api/api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This methods handle api requests / responses to local /api/_mock data
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
const API_URL = process.env.NEXT_PUBLIC_URL;
|
|
9
8
|
const API_BASE = process.env.NEXT_PUBLIC_API || '/api';
|
|
10
9
|
|
|
@@ -18,7 +17,7 @@ function getMockApiUrl(pathname: string): string {
|
|
|
18
17
|
|
|
19
18
|
export async function mockApiFetch<T = unknown>(pathname: string, options: ApiRequestOptions = {}): Promise<T> {
|
|
20
19
|
const url = getMockApiUrl(pathname);
|
|
21
|
-
const apiOptions = merge({ ...
|
|
20
|
+
const apiOptions = merge({ ...getLocalApiRequestOptions() }, options);
|
|
22
21
|
console.log('mockApiFetch', apiOptions.method, url);
|
|
23
22
|
const apiResponse = await httpFetch(url, apiOptions);
|
|
24
23
|
return apiResponse;
|
package/src/remote/remote.api.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
|
|
2
|
-
import { ApiRequestOptions,
|
|
2
|
+
import { ApiRequestOptions, getRemoteApiRequestOptions } from '../api/api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This methods handle api requests / responses to remote api (bowl or over)
|
|
@@ -18,7 +18,7 @@ export function getRemoteApiUrl(pathname: string): string {
|
|
|
18
18
|
|
|
19
19
|
export async function remoteApiFetch<T = unknown>(pathname: string, options: ApiRequestOptions = {}): Promise<T> {
|
|
20
20
|
const url = getRemoteApiUrl(pathname);
|
|
21
|
-
const apiOptions = merge({ ...
|
|
21
|
+
const apiOptions = merge({ ...getRemoteApiRequestOptions() }, options);
|
|
22
22
|
console.log('remoteApiFetch', apiOptions.method, url);
|
|
23
23
|
const apiResponse = await httpFetch(url, apiOptions);
|
|
24
24
|
return apiResponse;
|