@websolutespa/bom-mixer-store 1.4.5 → 1.6.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 +14 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +18 -10
- package/dist/index.mjs +17 -10
- package/package.json +1 -1
- package/src/cached/cached.service.ts +9 -9
- package/src/remote/remote.service.ts +7 -0
- package/src/remote/remote.store.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-store
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f664993: Added: useLivePreview
|
|
8
|
+
- Updated dependencies [6cbf4cb]
|
|
9
|
+
- @websolutespa/bom-core@0.6.7
|
|
10
|
+
|
|
11
|
+
## 1.4.6
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fixing: CachedService findMany DecoratedApi
|
|
16
|
+
|
|
3
17
|
## 1.4.5
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,9 @@ declare function mockHandler(): any;
|
|
|
107
107
|
declare function getMockStoreFromData_<T extends IStore>(data?: IMemoryStore): T;
|
|
108
108
|
declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
|
|
109
109
|
|
|
110
|
+
declare const RemoteServiceStrategy: {
|
|
111
|
+
draft: boolean;
|
|
112
|
+
};
|
|
110
113
|
/**
|
|
111
114
|
* This service handle call to remote api (bowl or over)
|
|
112
115
|
*/
|
|
@@ -217,4 +220,4 @@ declare function findRoute(store: IStore, pathname: string, href: string): Promi
|
|
|
217
220
|
|
|
218
221
|
declare function getStore<T extends IStore>(): Promise<T>;
|
|
219
222
|
|
|
220
|
-
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, SERVICE_DEFAULT_DEPTH, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectionDelete, collectionGet, collectionPatch, collectionPost, decorateHref_, decorateHrefs_, 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, localizeItem_, localizeItems_, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, nextPhase, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy };
|
|
223
|
+
export { ApiRequestOptions, BuildStrategy, COLLECTIONS, IApiHandler, ICrudMethod, IField, IHandler, 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, decorateHref_, decorateHrefs_, 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, localizeItem_, localizeItems_, mockApiDelete, mockApiFetch, mockApiGet, mockApiPatch, mockApiPost, mockApiPut, mockHandler, nextPhase, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy };
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(src_exports, {
|
|
|
42
42
|
RemoteMenuService: () => RemoteMenuService,
|
|
43
43
|
RemotePageService: () => RemotePageService,
|
|
44
44
|
RemoteService: () => RemoteService,
|
|
45
|
+
RemoteServiceStrategy: () => RemoteServiceStrategy,
|
|
45
46
|
SERVICE_DEFAULT_DEPTH: () => SERVICE_DEFAULT_DEPTH,
|
|
46
47
|
STATIC_COLLECTIONS: () => STATIC_COLLECTIONS,
|
|
47
48
|
StaticService: () => StaticService,
|
|
@@ -1219,16 +1220,16 @@ var CachedService = class extends import_bom_core10.JsonService {
|
|
|
1219
1220
|
const { market, locale, ...otherParams } = params;
|
|
1220
1221
|
const serializedParams = (0, import_bom_core10.qsSerialize)({ market, locale });
|
|
1221
1222
|
const key = `findMany?${serializedParams}`;
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
if (otherParams.where) {
|
|
1225
|
-
items = this.whereItems_(items, otherParams.where);
|
|
1226
|
-
}
|
|
1227
|
-
if (otherParams.sort) {
|
|
1228
|
-
items = this.sortCollection_(items, otherParams.sort);
|
|
1229
|
-
}
|
|
1230
|
-
return items;
|
|
1223
|
+
let items = await this.fromCache_(async () => {
|
|
1224
|
+
return await this.service_.findMany({ market, locale });
|
|
1231
1225
|
}, key);
|
|
1226
|
+
if (otherParams.where) {
|
|
1227
|
+
items = this.whereItems_(items, otherParams.where);
|
|
1228
|
+
}
|
|
1229
|
+
if (otherParams.sort) {
|
|
1230
|
+
items = this.sortCollection_(items, otherParams.sort);
|
|
1231
|
+
}
|
|
1232
|
+
return items;
|
|
1232
1233
|
} else {
|
|
1233
1234
|
const serializedParams = (0, import_bom_core10.qsSerialize)(params);
|
|
1234
1235
|
const key = `findMany?${serializedParams}`;
|
|
@@ -1291,6 +1292,9 @@ async function remoteApiDelete(url, options = {}) {
|
|
|
1291
1292
|
}
|
|
1292
1293
|
|
|
1293
1294
|
// src/remote/remote.service.ts
|
|
1295
|
+
var RemoteServiceStrategy = {
|
|
1296
|
+
draft: false
|
|
1297
|
+
};
|
|
1294
1298
|
var RemoteService = class {
|
|
1295
1299
|
constructor(key, store) {
|
|
1296
1300
|
if (!key) {
|
|
@@ -1304,6 +1308,7 @@ var RemoteService = class {
|
|
|
1304
1308
|
}
|
|
1305
1309
|
async findOne(id, params = {}) {
|
|
1306
1310
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1311
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1307
1312
|
const query = (0, import_bom_core12.qsSerialize)(params);
|
|
1308
1313
|
const search = query ? `?${query}` : "";
|
|
1309
1314
|
const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
|
|
@@ -1315,6 +1320,7 @@ var RemoteService = class {
|
|
|
1315
1320
|
}
|
|
1316
1321
|
async findMany(params = {}) {
|
|
1317
1322
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1323
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1318
1324
|
params.pagination = false;
|
|
1319
1325
|
const query = (0, import_bom_core12.qsSerialize)(params);
|
|
1320
1326
|
const search = query ? `?${query}` : "";
|
|
@@ -1325,6 +1331,7 @@ var RemoteService = class {
|
|
|
1325
1331
|
}
|
|
1326
1332
|
async findPaged(params = {}) {
|
|
1327
1333
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1334
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1328
1335
|
params.pagination = true;
|
|
1329
1336
|
const query = (0, import_bom_core12.qsSerialize)(params);
|
|
1330
1337
|
const search = query ? `?${query}` : "";
|
|
@@ -1471,7 +1478,7 @@ async function getRemoteStoreStaticBuild_() {
|
|
|
1471
1478
|
return fromCache(async () => {
|
|
1472
1479
|
console.log("getRemoteStoreStaticBuild_");
|
|
1473
1480
|
const store = {};
|
|
1474
|
-
const url = "/store
|
|
1481
|
+
const url = "/store";
|
|
1475
1482
|
const json = await remoteApiGet(url);
|
|
1476
1483
|
if (json != null) {
|
|
1477
1484
|
const collections = Object.keys(json);
|
|
@@ -1909,6 +1916,7 @@ async function storeApiDelete(url, options = {}) {
|
|
|
1909
1916
|
RemoteMenuService,
|
|
1910
1917
|
RemotePageService,
|
|
1911
1918
|
RemoteService,
|
|
1919
|
+
RemoteServiceStrategy,
|
|
1912
1920
|
SERVICE_DEFAULT_DEPTH,
|
|
1913
1921
|
STATIC_COLLECTIONS,
|
|
1914
1922
|
StaticService,
|
package/dist/index.mjs
CHANGED
|
@@ -1116,16 +1116,16 @@ var CachedService = class extends JsonService3 {
|
|
|
1116
1116
|
const { market, locale, ...otherParams } = params;
|
|
1117
1117
|
const serializedParams = qsSerialize({ market, locale });
|
|
1118
1118
|
const key = `findMany?${serializedParams}`;
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
if (otherParams.where) {
|
|
1122
|
-
items = this.whereItems_(items, otherParams.where);
|
|
1123
|
-
}
|
|
1124
|
-
if (otherParams.sort) {
|
|
1125
|
-
items = this.sortCollection_(items, otherParams.sort);
|
|
1126
|
-
}
|
|
1127
|
-
return items;
|
|
1119
|
+
let items = await this.fromCache_(async () => {
|
|
1120
|
+
return await this.service_.findMany({ market, locale });
|
|
1128
1121
|
}, key);
|
|
1122
|
+
if (otherParams.where) {
|
|
1123
|
+
items = this.whereItems_(items, otherParams.where);
|
|
1124
|
+
}
|
|
1125
|
+
if (otherParams.sort) {
|
|
1126
|
+
items = this.sortCollection_(items, otherParams.sort);
|
|
1127
|
+
}
|
|
1128
|
+
return items;
|
|
1129
1129
|
} else {
|
|
1130
1130
|
const serializedParams = qsSerialize(params);
|
|
1131
1131
|
const key = `findMany?${serializedParams}`;
|
|
@@ -1188,6 +1188,9 @@ async function remoteApiDelete(url, options = {}) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
|
|
1190
1190
|
// src/remote/remote.service.ts
|
|
1191
|
+
var RemoteServiceStrategy = {
|
|
1192
|
+
draft: false
|
|
1193
|
+
};
|
|
1191
1194
|
var RemoteService = class {
|
|
1192
1195
|
constructor(key, store) {
|
|
1193
1196
|
if (!key) {
|
|
@@ -1201,6 +1204,7 @@ var RemoteService = class {
|
|
|
1201
1204
|
}
|
|
1202
1205
|
async findOne(id, params = {}) {
|
|
1203
1206
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1207
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1204
1208
|
const query = qsSerialize2(params);
|
|
1205
1209
|
const search = query ? `?${query}` : "";
|
|
1206
1210
|
const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
|
|
@@ -1212,6 +1216,7 @@ var RemoteService = class {
|
|
|
1212
1216
|
}
|
|
1213
1217
|
async findMany(params = {}) {
|
|
1214
1218
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1219
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1215
1220
|
params.pagination = false;
|
|
1216
1221
|
const query = qsSerialize2(params);
|
|
1217
1222
|
const search = query ? `?${query}` : "";
|
|
@@ -1222,6 +1227,7 @@ var RemoteService = class {
|
|
|
1222
1227
|
}
|
|
1223
1228
|
async findPaged(params = {}) {
|
|
1224
1229
|
params.richText = String(params.richText) === "true" ? true : false;
|
|
1230
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
1225
1231
|
params.pagination = true;
|
|
1226
1232
|
const query = qsSerialize2(params);
|
|
1227
1233
|
const search = query ? `?${query}` : "";
|
|
@@ -1368,7 +1374,7 @@ async function getRemoteStoreStaticBuild_() {
|
|
|
1368
1374
|
return fromCache(async () => {
|
|
1369
1375
|
console.log("getRemoteStoreStaticBuild_");
|
|
1370
1376
|
const store = {};
|
|
1371
|
-
const url = "/store
|
|
1377
|
+
const url = "/store";
|
|
1372
1378
|
const json = await remoteApiGet(url);
|
|
1373
1379
|
if (json != null) {
|
|
1374
1380
|
const collections = Object.keys(json);
|
|
@@ -1805,6 +1811,7 @@ export {
|
|
|
1805
1811
|
RemoteMenuService,
|
|
1806
1812
|
RemotePageService,
|
|
1807
1813
|
RemoteService,
|
|
1814
|
+
RemoteServiceStrategy,
|
|
1808
1815
|
SERVICE_DEFAULT_DEPTH,
|
|
1809
1816
|
STATIC_COLLECTIONS,
|
|
1810
1817
|
StaticService,
|
package/package.json
CHANGED
|
@@ -73,16 +73,16 @@ export class CachedService<T extends IEntity = IEntity> extends JsonService<T> {
|
|
|
73
73
|
const { market, locale, ...otherParams } = params;
|
|
74
74
|
const serializedParams = qsSerialize({ market, locale });
|
|
75
75
|
const key = `findMany?${serializedParams}`;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (otherParams.where) {
|
|
79
|
-
items = this.whereItems_(items, otherParams.where);
|
|
80
|
-
}
|
|
81
|
-
if (otherParams.sort) {
|
|
82
|
-
items = this.sortCollection_(items, otherParams.sort);
|
|
83
|
-
}
|
|
84
|
-
return items;
|
|
76
|
+
let items = await this.fromCache_(async () => {
|
|
77
|
+
return await this.service_.findMany({ market, locale });
|
|
85
78
|
}, key) as B[];
|
|
79
|
+
if (otherParams.where) {
|
|
80
|
+
items = this.whereItems_(items, otherParams.where);
|
|
81
|
+
}
|
|
82
|
+
if (otherParams.sort) {
|
|
83
|
+
items = this.sortCollection_(items, otherParams.sort);
|
|
84
|
+
}
|
|
85
|
+
return items;
|
|
86
86
|
} else {
|
|
87
87
|
const serializedParams = qsSerialize(params);
|
|
88
88
|
const key = `findMany?${serializedParams}`;
|
|
@@ -2,6 +2,10 @@ import { IEntity, IEquatable, IPagedResult, IQuerable, IStore, qsSerialize, Quer
|
|
|
2
2
|
import { decorateSchema_, decorateSchemas_ } from '../decorators';
|
|
3
3
|
import { remoteApiDelete, remoteApiGet, remoteApiPost, remoteApiPut } from './remote.api';
|
|
4
4
|
|
|
5
|
+
export const RemoteServiceStrategy = {
|
|
6
|
+
draft: false,
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* This service handle call to remote api (bowl or over)
|
|
7
11
|
*/
|
|
@@ -23,6 +27,7 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
23
27
|
|
|
24
28
|
async findOne<B extends T = T>(id: IEquatable, params: QueryParams = {}): Promise<B | undefined> {
|
|
25
29
|
params.richText = String(params.richText) === 'true' ? true : false;
|
|
30
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
26
31
|
const query = qsSerialize(params);
|
|
27
32
|
const search = query ? `?${query}` : '';
|
|
28
33
|
const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
|
|
@@ -36,6 +41,7 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
36
41
|
|
|
37
42
|
async findMany<B extends T = T>(params: QueryParams = {}): Promise<B[]> {
|
|
38
43
|
params.richText = String(params.richText) === 'true' ? true : false;
|
|
44
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
39
45
|
params.pagination = false;
|
|
40
46
|
const query = qsSerialize(params);
|
|
41
47
|
const search = query ? `?${query}` : '';
|
|
@@ -48,6 +54,7 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
48
54
|
|
|
49
55
|
async findPaged<B extends T = T>(params: QueryParams = {}): Promise<IPagedResult<B>> {
|
|
50
56
|
params.richText = String(params.richText) === 'true' ? true : false;
|
|
57
|
+
params.draft = RemoteServiceStrategy.draft;
|
|
51
58
|
params.pagination = true;
|
|
52
59
|
const query = qsSerialize(params);
|
|
53
60
|
const search = query ? `?${query}` : '';
|
|
@@ -50,7 +50,7 @@ async function getRemoteStoreStaticBuild_<T extends IStore>(): Promise<T> {
|
|
|
50
50
|
return fromCache<T>(async () => {
|
|
51
51
|
console.log('getRemoteStoreStaticBuild_');
|
|
52
52
|
const store: IStore = {};
|
|
53
|
-
const url = '/store
|
|
53
|
+
const url = '/store';
|
|
54
54
|
const json = await remoteApiGet<IMemoryStore>(url);
|
|
55
55
|
if (json != null) {
|
|
56
56
|
const collections = Object.keys(json);
|