@websolutespa/bom-mixer-store 1.0.0 → 1.1.0

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,49 +1,61 @@
1
- # @websolutespa/bom-mixer-store
2
-
3
- ## 0.4.0
4
-
5
- ### Minor Changes
6
-
7
- - Modified routes, added redirects.
8
-
9
- ## 0.3.2
10
-
11
- ### Patch Changes
12
-
13
- - Modified: MockMenuService.
14
-
15
- ## 0.3.1
16
-
17
- ### Patch Changes
18
-
19
- - Added: source files.
20
-
21
- ## 0.3.0
22
-
23
- ### Minor Changes
24
-
25
- - Added: splat routes.
26
-
27
- ## 0.2.0
28
-
29
- ### Minor Changes
30
-
31
- - Added: @websolutespa/bom-core.
32
-
33
- ## 0.1.1
34
-
35
- ### Patch Changes
36
-
37
- - Modified: store service.
38
-
39
- ## 0.1.0
40
-
41
- ### Minor Changes
42
-
43
- - mock refactor.
44
-
45
- ## 0.0.2
46
-
47
- ### Patch Changes
48
-
49
- - Added: first release.
1
+ # @websolutespa/bom-mixer-store
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Modified: store refactor.
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: localhost url.
14
+
15
+ ## 1.0.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Modified routes, added redirects.
20
+
21
+ ## 0.3.2
22
+
23
+ ### Patch Changes
24
+
25
+ - Modified: MockMenuService.
26
+
27
+ ## 0.3.1
28
+
29
+ ### Patch Changes
30
+
31
+ - Added: source files.
32
+
33
+ ## 0.3.0
34
+
35
+ ### Minor Changes
36
+
37
+ - Added: splat routes.
38
+
39
+ ## 0.2.0
40
+
41
+ ### Minor Changes
42
+
43
+ - Added: @websolutespa/bom-core.
44
+
45
+ ## 0.1.1
46
+
47
+ ### Patch Changes
48
+
49
+ - Modified: store service.
50
+
51
+ ## 0.1.0
52
+
53
+ ### Minor Changes
54
+
55
+ - mock refactor.
56
+
57
+ ## 0.0.2
58
+
59
+ ### Patch Changes
60
+
61
+ - Added: first release.
package/dist/index.d.ts CHANGED
@@ -1,35 +1,41 @@
1
+ import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, IPageRelation, IQuerable, IEquatable, Pagination } from '@websolutespa/bom-core';
1
2
  import { NextApiRequest, NextApiResponse } from 'next';
2
- import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, IPageRelation, IMemoryStore, IEquatable, IQuerable, Pagination } from '@websolutespa/bom-core';
3
3
  import { NextRequest } from 'next/server';
4
4
 
5
+ type ApiRequestOptions = FetchRequestOptions;
6
+ declare const defaultApiRequestOptions: ApiRequestOptions;
7
+ declare function getDefaultApiRequestOptions(): ApiRequestOptions;
8
+
5
9
  type ICrudMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | string;
6
10
  type IHandler = (request: NextApiRequest, response: NextApiResponse) => Promise<any>;
7
11
  type IApiHandler = Record<ICrudMethod, IHandler>;
8
12
  declare function apiHandler(handler: IApiHandler): any;
9
13
  declare function errorHandler(error: any, response: NextApiResponse): Promise<any> | void;
10
14
 
11
- declare function getApiUrl(pathname: string): string;
12
- declare function apiFetch<T = any>(pathname: string, options?: FetchRequestOptions, serviceOptions?: {
15
+ declare function fromCache<T = unknown>(callback: () => Promise<T>, key?: string): Promise<T>;
16
+
17
+ declare function getLocalApiUrl(pathname: string): string;
18
+ declare function localApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions, serviceOptions?: {
13
19
  locale: string;
14
20
  market: string;
15
21
  }): Promise<T>;
16
- declare function apiGet<T = any>(url: string, options?: FetchRequestOptions, serviceOptions?: {
22
+ declare function localApiGet<T = unknown>(url: string, options?: ApiRequestOptions, serviceOptions?: {
17
23
  locale: string;
18
24
  market: string;
19
25
  }): Promise<T>;
20
- declare function apiPost<T = any>(url: string, payload?: unknown, options?: FetchRequestOptions, serviceOptions?: {
26
+ declare function localApiPost<T = unknown>(url: string, payload?: unknown, options?: ApiRequestOptions, serviceOptions?: {
21
27
  locale: string;
22
28
  market: string;
23
29
  }): Promise<T>;
24
- declare function apiPut<T = any>(url: string, payload?: unknown, options?: FetchRequestOptions, serviceOptions?: {
30
+ declare function localApiPut<T = unknown>(url: string, payload?: unknown, options?: ApiRequestOptions, serviceOptions?: {
25
31
  locale: string;
26
32
  market: string;
27
33
  }): Promise<T>;
28
- declare function apiPatch<T = any>(url: string, payload?: unknown, options?: FetchRequestOptions, serviceOptions?: {
34
+ declare function localApiPatch<T = unknown>(url: string, payload?: unknown, options?: ApiRequestOptions, serviceOptions?: {
29
35
  locale: string;
30
36
  market: string;
31
37
  }): Promise<T>;
32
- declare function apiDelete<T = any>(url: string, options?: FetchRequestOptions, serviceOptions?: {
38
+ declare function localApiDelete<T = unknown>(url: string, options?: ApiRequestOptions, serviceOptions?: {
33
39
  locale: string;
34
40
  market: string;
35
41
  }): Promise<T>;
@@ -38,7 +44,14 @@ declare function isStaticRequest(request: NextRequest): boolean;
38
44
  declare function isNextRequest(request: NextRequest): boolean;
39
45
  declare function isApiRequest(request: NextRequest): boolean;
40
46
 
41
- declare function mockHandler(getJson: () => Promise<string>): any;
47
+ declare function mockApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
48
+ declare function mockApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
49
+ declare function mockApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
50
+ declare function mockApiPut<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
51
+ declare function mockApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
52
+ declare function mockApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
53
+
54
+ declare function mockHandler(): any;
42
55
 
43
56
  declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
44
57
  store: IStore;
@@ -48,9 +61,33 @@ declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
48
61
  declare function isObject(item: unknown): item is Record<string, unknown>;
49
62
  declare function isRelation(item: unknown): item is IPageRelation;
50
63
 
51
- declare function getMockStoreServer<T extends IStore>(): Promise<T>;
52
- declare function getMockStore<T extends IStore>(getJson: () => Promise<string>): Promise<T>;
53
- declare function getMockStoreFromData<T extends IStore>(data?: IMemoryStore): T;
64
+ declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
65
+
66
+ declare function remoteApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions): Promise<T>;
67
+ declare function remoteApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
68
+ declare function remoteApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
69
+ declare function remoteApiPut<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
70
+ declare function remoteApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
71
+ declare function remoteApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
72
+
73
+ /**
74
+ * This service handle call to remote api (bowl or over)
75
+ */
76
+ declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T> {
77
+ key: string;
78
+ constructor(key: string);
79
+ findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
80
+ findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
81
+ findPaged<B extends T = T>(params?: QueryParams): Promise<{
82
+ docs: B[];
83
+ } & Pagination>;
84
+ create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
85
+ update<B extends T = T>(payload: Partial<B>): Promise<B>;
86
+ delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
87
+ protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
88
+ }
89
+
90
+ declare function getRemoteStore<T extends IStore>(): Promise<T>;
54
91
 
55
92
  type IField = {
56
93
  name: string;
@@ -87,7 +124,17 @@ declare enum StoreStrategy {
87
124
  Data = "data",
88
125
  Mock = "mock"
89
126
  }
90
- declare const storeStrategy: StoreStrategy;
127
+ declare const storeStrategy: StoreStrategy;
128
+ declare const MOCK_COLLECTIONS: string[];
129
+ declare const STATIC_COLLECTIONS: string[];
130
+ declare const KNOWN_COLLECTIONS: string[];
131
+ declare const COLLECTIONS: string[];
132
+
133
+ declare function storeApiGet<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
134
+ declare function storeApiPost<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
135
+ declare function storeApiPut<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
136
+ declare function storeApiPatch<T = unknown>(url: string, payload: unknown, options?: ApiRequestOptions): Promise<T>;
137
+ declare function storeApiDelete<T = unknown>(url: string, options?: ApiRequestOptions): Promise<T>;
91
138
 
92
139
  declare function storeHandler<T extends IStore>(storePromise?: () => Promise<T>): any;
93
140
  declare function collectionGet<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
@@ -96,35 +143,6 @@ declare function collectionPatch<T extends IStore>(storePromise: () => Promise<T
96
143
  declare function collectionDelete<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
97
144
  declare function routePost(store: IStore, request: NextApiRequest, response: NextApiResponse): Promise<void>;
98
145
 
99
- declare const MOCK_COLLECTIONS: string[];
100
- declare const STATIC_COLLECTIONS: string[];
101
- declare const KNOWN_COLLECTIONS: string[];
102
- declare const COLLECTIONS: string[];
103
146
  declare function getStore<T extends IStore>(): Promise<T>;
104
147
 
105
- type ApiRequestOptions = FetchRequestOptions;
106
- declare function storeApiFetch(pathname: string, options?: ApiRequestOptions): Promise<any>;
107
- declare function storeApiGet(url: string, options?: ApiRequestOptions): Promise<any>;
108
- declare function storeApiPost(url: string, payload: any, options?: ApiRequestOptions): Promise<any>;
109
- declare function storeApiPut(url: string, payload: any, options?: ApiRequestOptions): Promise<any>;
110
- declare function storeApiPatch(url: string, payload: any, options?: ApiRequestOptions): Promise<any>;
111
- declare function storeApiDelete(url: string, options?: ApiRequestOptions): Promise<any>;
112
- declare class StoreApiService<T extends IEntity = IEntity> implements IQuerable<T> {
113
- key: string;
114
- constructor(key: string);
115
- findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
116
- findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
117
- findPaged<B extends T = T>(params?: QueryParams): Promise<{
118
- docs: B[];
119
- } & Pagination>;
120
- create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
121
- update<B extends T = T>(payload: Partial<B>): Promise<B>;
122
- delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
123
- protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
124
- }
125
-
126
- declare function getApiStore<T extends IStore>(collections: string[]): Promise<T>;
127
- declare function getApiRuntimeStore<T extends IStore>(collections: string[]): Promise<T>;
128
- declare function getApiBuildStore<T extends IStore>(): Promise<T>;
129
-
130
- export { ApiRequestOptions, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, MapTo, MockService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreApiService, StoreStrategy, apiDelete, apiFetch, apiGet, apiHandler, apiPatch, apiPost, apiPut, collectionDelete, collectionGet, collectionPatch, collectionPost, errorHandler, getApiBuildStore, getApiRuntimeStore, getApiStore, getApiUrl, getMockStore, getMockStoreFromData, getMockStoreServer, getStore, isApiRequest, isNextRequest, isObject, isRelation, isStaticRequest, mockHandler, routePost, staticCollections, storeApiDelete, storeApiFetch, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeHandler, storeStrategy };
148
+ export { ApiRequestOptions, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, MapTo, MockService, RemoteService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, collectionDelete, collectionGet, collectionPatch, collectionPost, defaultApiRequestOptions, errorHandler, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, getRemoteStore, getStore, isApiRequest, isNextRequest, isObject, isRelation, isStaticRequest, localApiDelete, localApiFetch, localApiGet, localApiPatch, localApiPost, localApiPut, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeHandler, storeStrategy };