@websolutespa/bom-mixer-store 1.4.3 → 1.4.4
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 +130 -121
- package/dist/index.d.ts +8 -1
- package/dist/index.js +26 -2
- package/dist/index.mjs +24 -2
- package/package.json +1 -1
- package/src/decorators/index.ts +1 -0
- package/src/decorators/schema.ts +11 -0
- package/src/mock/mock-menu.service.ts +0 -2
- package/src/remote/remote-menu.service.ts +5 -3
- package/src/remote/remote-page.service.ts +5 -3
- package/src/remote/remote.service.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,121 +1,130 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-store
|
|
2
|
-
|
|
3
|
-
## 1.4.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## 1.4.
|
|
19
|
-
|
|
20
|
-
### Patch Changes
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
1
|
+
# @websolutespa/bom-mixer-store
|
|
2
|
+
|
|
3
|
+
## 1.4.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: Schema decorator
|
|
8
|
+
- Modified: RemoteMenuService, RemotePageService, RemoteService
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @websolutespa/bom-core@0.6.5
|
|
11
|
+
|
|
12
|
+
## 1.4.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Modified: CachedService, Decorators, LocalApi, MockApi, MockStore, RemoteApi, RemoteStore, StoreHandler
|
|
17
|
+
|
|
18
|
+
## 1.4.2
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Added: Decorators, CachedService, RemotePageService, RemoteMenuService, StoreStrategy.DecoratedApi, nextPhase, storeCacheDuration
|
|
23
|
+
- Modified: RemoteStore
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @websolutespa/bom-core@0.6.4
|
|
26
|
+
|
|
27
|
+
## 1.4.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Modified: MockPageService
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @websolutespa/bom-core@0.6.3
|
|
34
|
+
|
|
35
|
+
## 1.4.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- Added: BuildStrategy
|
|
40
|
+
|
|
41
|
+
## 1.3.0
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- Added: storeIndexHandler
|
|
46
|
+
- Modified: Store, StoreHandler, RemoteService, MockService, MockPageService, MockMenuService, StaticService
|
|
47
|
+
|
|
48
|
+
## 1.2.2
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Modified: MockMenuService IPageRelationResult
|
|
53
|
+
|
|
54
|
+
## 1.2.1
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Fixing: MockMenuService collectPages
|
|
59
|
+
|
|
60
|
+
## 1.2.0
|
|
61
|
+
|
|
62
|
+
### Minor Changes
|
|
63
|
+
|
|
64
|
+
- Updating: next 13
|
|
65
|
+
|
|
66
|
+
## 1.1.1
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Fixing: check redirects by pattern
|
|
71
|
+
|
|
72
|
+
## 1.1.0
|
|
73
|
+
|
|
74
|
+
### Minor Changes
|
|
75
|
+
|
|
76
|
+
- Modified: store refactor
|
|
77
|
+
|
|
78
|
+
## 1.0.1
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Fixing: localhost url
|
|
83
|
+
|
|
84
|
+
## 1.0.0
|
|
85
|
+
|
|
86
|
+
### Minor Changes
|
|
87
|
+
|
|
88
|
+
- Modified routes, added redirects
|
|
89
|
+
|
|
90
|
+
## 0.3.2
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Modified: MockMenuService
|
|
95
|
+
|
|
96
|
+
## 0.3.1
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- Added: source files
|
|
101
|
+
|
|
102
|
+
## 0.3.0
|
|
103
|
+
|
|
104
|
+
### Minor Changes
|
|
105
|
+
|
|
106
|
+
- Added: splat routes
|
|
107
|
+
|
|
108
|
+
## 0.2.0
|
|
109
|
+
|
|
110
|
+
### Minor Changes
|
|
111
|
+
|
|
112
|
+
- Added: @websolutespa/bom-core
|
|
113
|
+
|
|
114
|
+
## 0.1.1
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Modified: store service
|
|
119
|
+
|
|
120
|
+
## 0.1.0
|
|
121
|
+
|
|
122
|
+
### Minor Changes
|
|
123
|
+
|
|
124
|
+
- mock refactor
|
|
125
|
+
|
|
126
|
+
## 0.0.2
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Added: first release
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,13 @@ declare const SERVICE_DEFAULT_DEPTH = 2;
|
|
|
41
41
|
declare function decorateRelation_<T extends ISchema = ISchema>(store: IStore, item: T, params?: QueryParams): Promise<T>;
|
|
42
42
|
declare function decorateRelations_<T extends ISchema = ISchema>(store: IStore, items: T[], params?: QueryParams): Promise<T[]>;
|
|
43
43
|
|
|
44
|
+
declare function decorateSchema_<T extends ISchema = ISchema>(store: IStore, item: T, schema: string): Promise<T | T & {
|
|
45
|
+
schema: string;
|
|
46
|
+
}>;
|
|
47
|
+
declare function decorateSchemas_<T extends ISchema = ISchema>(store: IStore, items: T[], schema: string): Promise<(T & {
|
|
48
|
+
schema: string;
|
|
49
|
+
})[]>;
|
|
50
|
+
|
|
44
51
|
declare function getLocalApiUrl(pathname: string): string;
|
|
45
52
|
declare function localApiFetch<T = unknown>(pathname: string, options?: ApiRequestOptions, serviceOptions?: {
|
|
46
53
|
locale: string;
|
|
@@ -210,4 +217,4 @@ declare function findRoute(store: IStore, pathname: string, href: string): Promi
|
|
|
210
217
|
|
|
211
218
|
declare function getStore<T extends IStore>(): Promise<T>;
|
|
212
219
|
|
|
213
|
-
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_, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,8 @@ __export(src_exports, {
|
|
|
60
60
|
decorateNavs_: () => decorateNavs_,
|
|
61
61
|
decorateRelation_: () => decorateRelation_,
|
|
62
62
|
decorateRelations_: () => decorateRelations_,
|
|
63
|
+
decorateSchema_: () => decorateSchema_,
|
|
64
|
+
decorateSchemas_: () => decorateSchemas_,
|
|
63
65
|
decorateStaticRelation_: () => decorateStaticRelation_,
|
|
64
66
|
decorateStaticRelations_: () => decorateStaticRelations_,
|
|
65
67
|
defaultApiRequestOptions: () => defaultApiRequestOptions,
|
|
@@ -509,6 +511,16 @@ function collectRelations_(item, relations = []) {
|
|
|
509
511
|
return relations;
|
|
510
512
|
}
|
|
511
513
|
|
|
514
|
+
// src/decorators/schema.ts
|
|
515
|
+
async function decorateSchema_(store, item, schema) {
|
|
516
|
+
return { ...item, schema };
|
|
517
|
+
}
|
|
518
|
+
async function decorateSchemas_(store, items, schema) {
|
|
519
|
+
return items.map((item) => {
|
|
520
|
+
return { ...item, schema };
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
|
|
512
524
|
// src/local/local.api.ts
|
|
513
525
|
var import_bom_core5 = require("@websolutespa/bom-core");
|
|
514
526
|
var API_URL = process.env.NEXT_PUBLIC_URL === "https://" ? process.env.NEXT_PUBLIC_MOCK_FALLBACK_URL : process.env.NEXT_PUBLIC_URL;
|
|
@@ -1350,10 +1362,14 @@ var RemoteService = class {
|
|
|
1350
1362
|
return await this.decorateOne_(item, {});
|
|
1351
1363
|
}
|
|
1352
1364
|
async decorateOne_(item, params = {}) {
|
|
1353
|
-
|
|
1365
|
+
let decoratedItem = item;
|
|
1366
|
+
decoratedItem = await decorateSchema_(this.store, decoratedItem, this.key);
|
|
1367
|
+
return decoratedItem;
|
|
1354
1368
|
}
|
|
1355
1369
|
async decorateMany_(items, params = {}) {
|
|
1356
|
-
|
|
1370
|
+
let decoratedItems = items;
|
|
1371
|
+
decoratedItems = await decorateSchemas_(this.store, decoratedItems, this.key);
|
|
1372
|
+
return decoratedItems;
|
|
1357
1373
|
}
|
|
1358
1374
|
};
|
|
1359
1375
|
|
|
@@ -1362,6 +1378,7 @@ var RemoteMenuService = class extends RemoteService {
|
|
|
1362
1378
|
async decorateOne_(item, params = {}) {
|
|
1363
1379
|
const store = this.store;
|
|
1364
1380
|
let decoratedItem = item;
|
|
1381
|
+
decoratedItem = await decorateSchema_(store, decoratedItem, this.key);
|
|
1365
1382
|
decoratedItem = await localizeItem_(item, params);
|
|
1366
1383
|
if (params.market && params.locale) {
|
|
1367
1384
|
decoratedItem = await decorateMenu_(store, decoratedItem, {
|
|
@@ -1374,6 +1391,7 @@ var RemoteMenuService = class extends RemoteService {
|
|
|
1374
1391
|
async decorateMany_(items, params = {}) {
|
|
1375
1392
|
const store = this.store;
|
|
1376
1393
|
let decoratedItems = items;
|
|
1394
|
+
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1377
1395
|
decoratedItems = await localizeItems_(items, params);
|
|
1378
1396
|
if (params.market && params.locale) {
|
|
1379
1397
|
decoratedItems = await decorateMenus_(store, decoratedItems, {
|
|
@@ -1390,6 +1408,8 @@ var RemotePageService = class extends RemoteService {
|
|
|
1390
1408
|
async decorateOne_(item, params = {}) {
|
|
1391
1409
|
const store = this.store;
|
|
1392
1410
|
let decoratedItem = item;
|
|
1411
|
+
decoratedItem = await decorateSchema_(store, decoratedItem, this.key);
|
|
1412
|
+
decoratedItem = await decorateHref_(store, decoratedItem, params);
|
|
1393
1413
|
decoratedItem = await decorateNav_(store, decoratedItem, params);
|
|
1394
1414
|
decoratedItem = await decorateRelation_(store, decoratedItem, {
|
|
1395
1415
|
market: params.market,
|
|
@@ -1401,6 +1421,8 @@ var RemotePageService = class extends RemoteService {
|
|
|
1401
1421
|
async decorateMany_(items, params = {}) {
|
|
1402
1422
|
const store = this.store;
|
|
1403
1423
|
let decoratedItems = items;
|
|
1424
|
+
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1425
|
+
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
1404
1426
|
decoratedItems = await decorateNavs_(store, decoratedItems, params);
|
|
1405
1427
|
decoratedItems = await decorateRelations_(store, decoratedItems, {
|
|
1406
1428
|
market: params.market,
|
|
@@ -1905,6 +1927,8 @@ async function storeApiDelete(url, options = {}) {
|
|
|
1905
1927
|
decorateNavs_,
|
|
1906
1928
|
decorateRelation_,
|
|
1907
1929
|
decorateRelations_,
|
|
1930
|
+
decorateSchema_,
|
|
1931
|
+
decorateSchemas_,
|
|
1908
1932
|
decorateStaticRelation_,
|
|
1909
1933
|
decorateStaticRelations_,
|
|
1910
1934
|
defaultApiRequestOptions,
|
package/dist/index.mjs
CHANGED
|
@@ -408,6 +408,16 @@ function collectRelations_(item, relations = []) {
|
|
|
408
408
|
return relations;
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
+
// src/decorators/schema.ts
|
|
412
|
+
async function decorateSchema_(store, item, schema) {
|
|
413
|
+
return { ...item, schema };
|
|
414
|
+
}
|
|
415
|
+
async function decorateSchemas_(store, items, schema) {
|
|
416
|
+
return items.map((item) => {
|
|
417
|
+
return { ...item, schema };
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
|
|
411
421
|
// src/local/local.api.ts
|
|
412
422
|
import { httpFetch, isBrowser, merge } from "@websolutespa/bom-core";
|
|
413
423
|
var API_URL = process.env.NEXT_PUBLIC_URL === "https://" ? process.env.NEXT_PUBLIC_MOCK_FALLBACK_URL : process.env.NEXT_PUBLIC_URL;
|
|
@@ -1249,10 +1259,14 @@ var RemoteService = class {
|
|
|
1249
1259
|
return await this.decorateOne_(item, {});
|
|
1250
1260
|
}
|
|
1251
1261
|
async decorateOne_(item, params = {}) {
|
|
1252
|
-
|
|
1262
|
+
let decoratedItem = item;
|
|
1263
|
+
decoratedItem = await decorateSchema_(this.store, decoratedItem, this.key);
|
|
1264
|
+
return decoratedItem;
|
|
1253
1265
|
}
|
|
1254
1266
|
async decorateMany_(items, params = {}) {
|
|
1255
|
-
|
|
1267
|
+
let decoratedItems = items;
|
|
1268
|
+
decoratedItems = await decorateSchemas_(this.store, decoratedItems, this.key);
|
|
1269
|
+
return decoratedItems;
|
|
1256
1270
|
}
|
|
1257
1271
|
};
|
|
1258
1272
|
|
|
@@ -1261,6 +1275,7 @@ var RemoteMenuService = class extends RemoteService {
|
|
|
1261
1275
|
async decorateOne_(item, params = {}) {
|
|
1262
1276
|
const store = this.store;
|
|
1263
1277
|
let decoratedItem = item;
|
|
1278
|
+
decoratedItem = await decorateSchema_(store, decoratedItem, this.key);
|
|
1264
1279
|
decoratedItem = await localizeItem_(item, params);
|
|
1265
1280
|
if (params.market && params.locale) {
|
|
1266
1281
|
decoratedItem = await decorateMenu_(store, decoratedItem, {
|
|
@@ -1273,6 +1288,7 @@ var RemoteMenuService = class extends RemoteService {
|
|
|
1273
1288
|
async decorateMany_(items, params = {}) {
|
|
1274
1289
|
const store = this.store;
|
|
1275
1290
|
let decoratedItems = items;
|
|
1291
|
+
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1276
1292
|
decoratedItems = await localizeItems_(items, params);
|
|
1277
1293
|
if (params.market && params.locale) {
|
|
1278
1294
|
decoratedItems = await decorateMenus_(store, decoratedItems, {
|
|
@@ -1289,6 +1305,8 @@ var RemotePageService = class extends RemoteService {
|
|
|
1289
1305
|
async decorateOne_(item, params = {}) {
|
|
1290
1306
|
const store = this.store;
|
|
1291
1307
|
let decoratedItem = item;
|
|
1308
|
+
decoratedItem = await decorateSchema_(store, decoratedItem, this.key);
|
|
1309
|
+
decoratedItem = await decorateHref_(store, decoratedItem, params);
|
|
1292
1310
|
decoratedItem = await decorateNav_(store, decoratedItem, params);
|
|
1293
1311
|
decoratedItem = await decorateRelation_(store, decoratedItem, {
|
|
1294
1312
|
market: params.market,
|
|
@@ -1300,6 +1318,8 @@ var RemotePageService = class extends RemoteService {
|
|
|
1300
1318
|
async decorateMany_(items, params = {}) {
|
|
1301
1319
|
const store = this.store;
|
|
1302
1320
|
let decoratedItems = items;
|
|
1321
|
+
decoratedItems = await decorateSchemas_(store, decoratedItems, this.key);
|
|
1322
|
+
decoratedItems = await decorateHrefs_(store, decoratedItems, params);
|
|
1303
1323
|
decoratedItems = await decorateNavs_(store, decoratedItems, params);
|
|
1304
1324
|
decoratedItems = await decorateRelations_(store, decoratedItems, {
|
|
1305
1325
|
market: params.market,
|
|
@@ -1803,6 +1823,8 @@ export {
|
|
|
1803
1823
|
decorateNavs_,
|
|
1804
1824
|
decorateRelation_,
|
|
1805
1825
|
decorateRelations_,
|
|
1826
|
+
decorateSchema_,
|
|
1827
|
+
decorateSchemas_,
|
|
1806
1828
|
decorateStaticRelation_,
|
|
1807
1829
|
decorateStaticRelations_,
|
|
1808
1830
|
defaultApiRequestOptions,
|
package/package.json
CHANGED
package/src/decorators/index.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ISchema, IStore } from '@websolutespa/bom-core';
|
|
2
|
+
|
|
3
|
+
export async function decorateSchema_<T extends ISchema = ISchema>(store: IStore, item: T, schema: string): Promise<T | T & { schema: string }> {
|
|
4
|
+
return { ...item, schema };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function decorateSchemas_<T extends ISchema = ISchema>(store: IStore, items: T[], schema: string): Promise<(T & { schema: string })[]> {
|
|
8
|
+
return items.map(item => {
|
|
9
|
+
return { ...item, schema };
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -8,7 +8,6 @@ export class MockMenuService<T extends IEntity = IEntity> extends MockService<T>
|
|
|
8
8
|
const store = this.store;
|
|
9
9
|
let decoratedItem = item;
|
|
10
10
|
decoratedItem = await localizeItem_(item, params);
|
|
11
|
-
// decoratedItem = await decorateHref_<B>(store, decoratedItem, params);
|
|
12
11
|
if (params.market && params.locale) {
|
|
13
12
|
decoratedItem = await decorateMenu_(store, decoratedItem as any as IUndecoratedMenu, {
|
|
14
13
|
market: params.market,
|
|
@@ -22,7 +21,6 @@ export class MockMenuService<T extends IEntity = IEntity> extends MockService<T>
|
|
|
22
21
|
const store = this.store;
|
|
23
22
|
let decoratedItems = items;
|
|
24
23
|
decoratedItems = await localizeItems_(items, params);
|
|
25
|
-
// decoratedItems = await decorateHrefs_<B>(store, decoratedItems, params);
|
|
26
24
|
if (params.market && params.locale) {
|
|
27
25
|
decoratedItems = await decorateMenus_(store, decoratedItems as any as IUndecoratedMenu[], {
|
|
28
26
|
market: params.market,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEntity, IUndecoratedMenu, QueryParams } from '@websolutespa/bom-core';
|
|
2
|
-
import { decorateMenu_, decorateMenus_, localizeItem_, localizeItems_ } from '../decorators';
|
|
2
|
+
import { decorateMenu_, decorateMenus_, decorateSchema_, decorateSchemas_, localizeItem_, localizeItems_ } from '../decorators';
|
|
3
3
|
import { RemoteService } from './remote.service';
|
|
4
4
|
|
|
5
5
|
export class RemoteMenuService<T extends IEntity = IEntity> extends RemoteService<T> {
|
|
@@ -7,9 +7,10 @@ export class RemoteMenuService<T extends IEntity = IEntity> extends RemoteServic
|
|
|
7
7
|
protected override async decorateOne_<B extends T = T>(item: B, params: QueryParams = {}): Promise<B> {
|
|
8
8
|
const store = this.store;
|
|
9
9
|
let decoratedItem = item;
|
|
10
|
+
decoratedItem = await decorateSchema_<B>(store, decoratedItem, this.key);
|
|
10
11
|
decoratedItem = await localizeItem_(item, params);
|
|
11
12
|
if (params.market && params.locale) {
|
|
12
|
-
decoratedItem = await decorateMenu_(store, decoratedItem as
|
|
13
|
+
decoratedItem = await decorateMenu_(store, decoratedItem as IUndecoratedMenu, {
|
|
13
14
|
market: params.market,
|
|
14
15
|
locale: params.locale,
|
|
15
16
|
}) as any;
|
|
@@ -20,9 +21,10 @@ export class RemoteMenuService<T extends IEntity = IEntity> extends RemoteServic
|
|
|
20
21
|
protected override async decorateMany_<B extends T = T>(items: B[], params: QueryParams = {}): Promise<B[]> {
|
|
21
22
|
const store = this.store;
|
|
22
23
|
let decoratedItems = items;
|
|
24
|
+
decoratedItems = await decorateSchemas_<B>(store, decoratedItems, this.key);
|
|
23
25
|
decoratedItems = await localizeItems_(items, params);
|
|
24
26
|
if (params.market && params.locale) {
|
|
25
|
-
decoratedItems = await decorateMenus_(store, decoratedItems as
|
|
27
|
+
decoratedItems = await decorateMenus_(store, decoratedItems as IUndecoratedMenu[], {
|
|
26
28
|
market: params.market,
|
|
27
29
|
locale: params.locale,
|
|
28
30
|
}) as any[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEntity, QueryParams } from '@websolutespa/bom-core';
|
|
2
|
-
import { decorateNav_, decorateNavs_, decorateRelation_, decorateRelations_ } from '../decorators';
|
|
2
|
+
import { decorateHref_, decorateHrefs_, decorateNav_, decorateNavs_, decorateRelation_, decorateRelations_, decorateSchema_, decorateSchemas_ } from '../decorators';
|
|
3
3
|
import { RemoteService } from './remote.service';
|
|
4
4
|
|
|
5
5
|
export class RemotePageService<T extends IEntity = IEntity> extends RemoteService<T> {
|
|
@@ -7,7 +7,8 @@ export class RemotePageService<T extends IEntity = IEntity> extends RemoteServic
|
|
|
7
7
|
protected override async decorateOne_<B extends T = T>(item: B, params: QueryParams = {}): Promise<B> {
|
|
8
8
|
const store = this.store;
|
|
9
9
|
let decoratedItem = item;
|
|
10
|
-
|
|
10
|
+
decoratedItem = await decorateSchema_<B>(store, decoratedItem, this.key);
|
|
11
|
+
decoratedItem = await decorateHref_<B>(store, decoratedItem, params);
|
|
11
12
|
decoratedItem = await decorateNav_<B>(store, decoratedItem, params);
|
|
12
13
|
decoratedItem = await decorateRelation_<B>(store, decoratedItem, {
|
|
13
14
|
market: params.market,
|
|
@@ -20,7 +21,8 @@ export class RemotePageService<T extends IEntity = IEntity> extends RemoteServic
|
|
|
20
21
|
protected override async decorateMany_<B extends T = T>(items: B[], params: QueryParams = {}): Promise<B[]> {
|
|
21
22
|
const store = this.store;
|
|
22
23
|
let decoratedItems = items;
|
|
23
|
-
|
|
24
|
+
decoratedItems = await decorateSchemas_<B>(store, decoratedItems, this.key);
|
|
25
|
+
decoratedItems = await decorateHrefs_<B>(store, decoratedItems, params);
|
|
24
26
|
decoratedItems = await decorateNavs_<B>(store, decoratedItems, params);
|
|
25
27
|
decoratedItems = await decorateRelations_<B>(store, decoratedItems, {
|
|
26
28
|
market: params.market,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IEntity, IEquatable, IPagedResult, IQuerable, IStore, qsSerialize, QueryParams } from '@websolutespa/bom-core';
|
|
2
|
+
import { decorateSchema_, decorateSchemas_ } from '../decorators';
|
|
2
3
|
import { remoteApiDelete, remoteApiGet, remoteApiPost, remoteApiPut } from './remote.api';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -92,10 +93,14 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
protected async decorateOne_<B extends T = T>(item: B, params: QueryParams = {}): Promise<B> {
|
|
95
|
-
|
|
96
|
+
let decoratedItem = item;
|
|
97
|
+
decoratedItem = await decorateSchema_<B>(this.store, decoratedItem, this.key);
|
|
98
|
+
return decoratedItem;
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
protected async decorateMany_<B extends T = T>(items: B[], params: QueryParams = {}): Promise<B[]> {
|
|
99
|
-
|
|
102
|
+
let decoratedItems = items;
|
|
103
|
+
decoratedItems = await decorateSchemas_<B>(this.store, decoratedItems, this.key);
|
|
104
|
+
return decoratedItems;
|
|
100
105
|
}
|
|
101
106
|
}
|