@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.7.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: getRemoteApiRequestOptions, getLocalApiRequestOptions
8
+
3
9
  ## 1.7.6
4
10
 
5
11
  ### Patch Changes
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
- declare function getDefaultApiRequestOptions(): ApiRequestOptions;
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, 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, varsHandler };
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
- getDefaultApiRequestOptions: () => getDefaultApiRequestOptions,
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 getDefaultApiRequestOptions() {
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)({ ...getDefaultApiRequestOptions() }, options);
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)({ ...getDefaultApiRequestOptions() }, options);
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)({ ...getDefaultApiRequestOptions() }, options);
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
- getDefaultApiRequestOptions,
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 getDefaultApiRequestOptions() {
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({ ...getDefaultApiRequestOptions() }, options);
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({ ...getDefaultApiRequestOptions() }, options);
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({ ...getDefaultApiRequestOptions() }, options);
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
- getDefaultApiRequestOptions,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
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
- export function getDefaultApiRequestOptions(): ApiRequestOptions {
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: {
@@ -1,5 +1,5 @@
1
1
  import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
2
- import { ApiRequestOptions, getDefaultApiRequestOptions } from '../api/api';
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({ ...getDefaultApiRequestOptions() }, options);
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);
@@ -1,10 +1,9 @@
1
1
  import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
2
- import { ApiRequestOptions, getDefaultApiRequestOptions } from '../api/api';
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({ ...getDefaultApiRequestOptions() }, options);
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;
@@ -1,5 +1,5 @@
1
1
  import { httpFetch, isBrowser, merge } from '@websolutespa/bom-core';
2
- import { ApiRequestOptions, getDefaultApiRequestOptions } from '../api/api';
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({ ...getDefaultApiRequestOptions() }, options);
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;