@websolutespa/bom-mixer-store 1.2.2 → 1.3.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,5 +1,12 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added: storeIndexHandler.
8
+ - Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService.
9
+
3
10
  ## 1.2.2
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, IPageRelation, IQuerable, IEquatable, Pagination } from '@websolutespa/bom-core';
1
+ import { FetchRequestOptions, IEntity, JsonService, IStore, QueryParams, ISchema, IQuerable, IEquatable, Pagination } from '@websolutespa/bom-core';
2
2
  import { NextApiRequest, NextApiResponse } from 'next';
3
3
  import { NextRequest } from 'next/server';
4
4
 
@@ -53,13 +53,17 @@ declare function mockApiDelete<T = unknown>(url: string, options?: ApiRequestOpt
53
53
 
54
54
  declare function mockHandler(): any;
55
55
 
56
+ declare const MOCK_SERVICE_DEFAULT_DEPTH = 2;
56
57
  declare class MockService<T extends IEntity = IEntity> extends JsonService<T> {
57
58
  store: IStore;
58
59
  constructor(items: T[], store: IStore);
59
- protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
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[]>;
60
62
  }
61
- declare function isObject(item: unknown): item is Record<string, unknown>;
62
- declare function isRelation(item: unknown): item is IPageRelation;
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[]>;
63
67
 
64
68
  declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
65
69
 
@@ -84,7 +88,8 @@ declare class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
84
88
  create<B extends T = T>(payload: Omit<B, 'id'>): Promise<B>;
85
89
  update<B extends T = T>(payload: Partial<B>): Promise<B>;
86
90
  delete<B extends T = T>(id: IEquatable): Promise<B | undefined>;
87
- protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
91
+ protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
92
+ protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
88
93
  }
89
94
 
90
95
  declare function getRemoteStore<T extends IStore>(): Promise<T>;
@@ -112,12 +117,13 @@ declare class StaticService<T extends IEntity = IEntity> extends JsonService<T>
112
117
  config: StaticServiceConfig<T>;
113
118
  store: IStore;
114
119
  constructor(config: StaticServiceConfig<T>, store: IStore);
115
- getItems<B extends T = T>(): Promise<B[]>;
116
- findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
117
120
  protected mapItems_<B extends T = T>(items: B[], map?: MapTo): B[];
118
- protected relatedItems_<B extends T = T>(item: B, fields: IField[], locale?: string): Promise<B>;
119
- protected decorator_<B extends T = T>(item: B, params?: QueryParams): B;
121
+ getItems<B extends T = T>(): Promise<B[]>;
122
+ protected decorateOne_<B extends T = T>(item: B, params?: QueryParams): Promise<B>;
123
+ protected decorateMany_<B extends T = T>(items: B[], params?: QueryParams): Promise<B[]>;
120
124
  }
125
+ declare function decorateStaticRelation_<T>(store: IStore, fields: IField[], item: T, params?: QueryParams): Promise<T>;
126
+ declare function decorateStaticRelations_<T>(store: IStore, fields: IField[], items: T[], params?: QueryParams): Promise<T[]>;
121
127
 
122
128
  declare enum StoreStrategy {
123
129
  Api = "api",
@@ -142,7 +148,8 @@ declare function collectionPost<T extends IStore>(storePromise: () => Promise<T>
142
148
  declare function collectionPatch<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
143
149
  declare function collectionDelete<T extends IStore>(storePromise: () => Promise<T>): (request: NextApiRequest, response: NextApiResponse) => Promise<void>;
144
150
  declare function routePost(store: IStore, request: NextApiRequest, response: NextApiResponse): Promise<void>;
151
+ declare function storeIndexHandler(): any;
145
152
 
146
153
  declare function getStore<T extends IStore>(): Promise<T>;
147
154
 
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 };
155
+ export { ApiRequestOptions, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MOCK_COLLECTIONS, MOCK_SERVICE_DEFAULT_DEPTH, MapTo, MockService, RemoteService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateRelation_, decorateRelations_, decorateStaticRelation_, decorateStaticRelations_, defaultApiRequestOptions, errorHandler, fromCache, getDefaultApiRequestOptions, getLocalApiUrl, getMockStore, 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 };