@websolutespa/bom-mixer-store 1.8.12 → 1.10.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,17 @@
1
1
  # @websolutespa/bom-mixer-store
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: remote.service, Added: preview.handler
8
+
9
+ ## 1.8.13
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: decorators collectRelations\_ depth 0
14
+
3
15
  ## 1.8.12
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -132,9 +132,8 @@ declare function mockHandler(): IHandler<any>;
132
132
  declare function getMockStoreFromData_<T extends IStore>(data?: IMemoryStore): T;
133
133
  declare function getMockStore<T extends IStore = IStore>(): Promise<T>;
134
134
 
135
- declare const RemoteServiceStrategy: {
136
- draft: boolean;
137
- };
135
+ declare function previewHandler(): IHandler<any>;
136
+
138
137
  /**
139
138
  * This service handle call to remote api (bowl or over)
140
139
  */
@@ -252,4 +251,4 @@ declare function getStore<T extends IStore>(): Promise<T>;
252
251
 
253
252
  declare function varsHandler(): IHandler<any>;
254
253
 
255
- export { ApiRequestOptions, BuildStrategy, COLLECTIONS, DEFAULT_DEPTH, IApiHandler, ICrudMethod, IField, IHandler, IPageResolvedRelation, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, RemoteServiceStrategy, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectCategory_, 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 };
254
+ export { ApiRequestOptions, BuildStrategy, COLLECTIONS, DEFAULT_DEPTH, IApiHandler, ICrudMethod, IField, IHandler, IPageResolvedRelation, KNOWN_COLLECTIONS, MAX_INT, MOCK_COLLECTIONS, MapTo, MockMenuService, MockPageService, MockService, NextPhase, RemoteMenuService, RemotePageService, RemoteService, STATIC_COLLECTIONS, StaticService, StaticServiceConfig, StaticServiceSrc, StoreStrategy, apiHandler, buildStrategy, collectCategory_, 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_, previewHandler, remoteApiDelete, remoteApiFetch, remoteApiGet, remoteApiPatch, remoteApiPost, remoteApiPut, routePost, staticCollections, storeApiDelete, storeApiGet, storeApiPatch, storeApiPost, storeApiPut, storeCacheDuration, storeHandler, storeIndexHandler, storeStrategy, varsHandler };
package/dist/index.js CHANGED
@@ -43,7 +43,6 @@ __export(src_exports, {
43
43
  RemoteMenuService: () => RemoteMenuService,
44
44
  RemotePageService: () => RemotePageService,
45
45
  RemoteService: () => RemoteService,
46
- RemoteServiceStrategy: () => RemoteServiceStrategy,
47
46
  STATIC_COLLECTIONS: () => STATIC_COLLECTIONS,
48
47
  StaticService: () => StaticService,
49
48
  StoreStrategy: () => StoreStrategy,
@@ -100,6 +99,7 @@ __export(src_exports, {
100
99
  nextPhase: () => nextPhase,
101
100
  optimizeMany_: () => optimizeMany_,
102
101
  optimizeOne_: () => optimizeOne_,
102
+ previewHandler: () => previewHandler,
103
103
  remoteApiDelete: () => remoteApiDelete,
104
104
  remoteApiFetch: () => remoteApiFetch,
105
105
  remoteApiGet: () => remoteApiGet,
@@ -606,9 +606,6 @@ async function optimizeMany_(items) {
606
606
  var import_bom_core5 = require("@websolutespa/bom-core");
607
607
  async function decorateRelation_(store, item, params = {}) {
608
608
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
609
- if (depth === 0) {
610
- return item;
611
- }
612
609
  item = await collectRelations_({ store, params, depth }, item);
613
610
  return item;
614
611
  }
@@ -620,6 +617,9 @@ async function decorateRelations_(store, items, params = {}) {
620
617
  }
621
618
  async function collectRelations_(context, item, relations = []) {
622
619
  if ((0, import_bom_core5.isUnresolvedRelation)(item)) {
620
+ if (context.depth === 0) {
621
+ return item.value;
622
+ }
623
623
  const index = relations.findIndex(
624
624
  (x) => x.relationTo === item.relationTo && x.value === item.value
625
625
  );
@@ -1528,9 +1528,6 @@ async function remoteApiDelete(url, options = {}) {
1528
1528
  }
1529
1529
 
1530
1530
  // src/remote/remote.service.ts
1531
- var RemoteServiceStrategy = {
1532
- draft: false
1533
- };
1534
1531
  var RemoteService = class {
1535
1532
  constructor(key, store) {
1536
1533
  if (!key) {
@@ -1544,7 +1541,6 @@ var RemoteService = class {
1544
1541
  }
1545
1542
  async findOne(id, params = {}, token) {
1546
1543
  params.richText = String(params.richText) === "true" ? true : false;
1547
- params.draft = RemoteServiceStrategy.draft;
1548
1544
  const query = (0, import_bom_core14.qsSerialize)(params);
1549
1545
  const search = query ? `?${query}` : "";
1550
1546
  const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
@@ -1560,7 +1556,6 @@ var RemoteService = class {
1560
1556
  }
1561
1557
  async findMany(params = {}, token) {
1562
1558
  params.richText = String(params.richText) === "true" ? true : false;
1563
- params.draft = RemoteServiceStrategy.draft;
1564
1559
  params.pagination = false;
1565
1560
  const query = (0, import_bom_core14.qsSerialize)(params);
1566
1561
  const search = query ? `?${query}` : "";
@@ -1571,7 +1566,6 @@ var RemoteService = class {
1571
1566
  }
1572
1567
  async findPaged(params = {}, token) {
1573
1568
  params.richText = String(params.richText) === "true" ? true : false;
1574
- params.draft = RemoteServiceStrategy.draft;
1575
1569
  params.pagination = true;
1576
1570
  const query = (0, import_bom_core14.qsSerialize)(params);
1577
1571
  const search = query ? `?${query}` : "";
@@ -1583,7 +1577,6 @@ var RemoteService = class {
1583
1577
  }
1584
1578
  async create(payload, params = {}, token) {
1585
1579
  params.richText = String(params.richText) === "true" ? true : false;
1586
- params.draft = RemoteServiceStrategy.draft;
1587
1580
  const query = (0, import_bom_core14.qsSerialize)(params);
1588
1581
  const search = query ? `?${query}` : "";
1589
1582
  const url = `/${this.key}${search}`;
@@ -1601,7 +1594,6 @@ var RemoteService = class {
1601
1594
  }
1602
1595
  async updateMany(payload, params = {}, token) {
1603
1596
  params.richText = String(params.richText) === "true" ? true : false;
1604
- params.draft = RemoteServiceStrategy.draft;
1605
1597
  params.pagination = false;
1606
1598
  const query = (0, import_bom_core14.qsSerialize)(params);
1607
1599
  const search = query ? `?${query}` : "";
@@ -1619,7 +1611,6 @@ var RemoteService = class {
1619
1611
  }
1620
1612
  async deleteMany(params = {}, token) {
1621
1613
  params.richText = String(params.richText) === "true" ? true : false;
1622
- params.draft = RemoteServiceStrategy.draft;
1623
1614
  params.pagination = false;
1624
1615
  const query = (0, import_bom_core14.qsSerialize)(params);
1625
1616
  const search = query ? `?${query}` : "";
@@ -2242,6 +2233,23 @@ function mockHandler() {
2242
2233
  return storeHandler(async () => await getMockStore());
2243
2234
  }
2244
2235
 
2236
+ // src/preview/preview.handler.ts
2237
+ function previewHandler() {
2238
+ return apiHandler({
2239
+ options: async (request, response) => {
2240
+ response.status(200).end();
2241
+ },
2242
+ get: async (request, response) => {
2243
+ const query = request.query;
2244
+ const { marketId, localeId, templateId, documentId, _status } = query;
2245
+ const destination = `/${marketId}/${localeId}/${templateId}/${documentId}${query._live ? "?_live=true" : ""}`;
2246
+ response.setPreviewData({ _status });
2247
+ response.setDraftMode({ enable: true });
2248
+ response.redirect(307, destination);
2249
+ }
2250
+ });
2251
+ }
2252
+
2245
2253
  // src/store/store.api.ts
2246
2254
  var storeApiFetch = storeStrategy === "mock" /* Mock */ ? localApiFetch : remoteApiFetch;
2247
2255
  async function storeApiGet(url, options = {}) {
@@ -2308,23 +2316,29 @@ async function getRouteLinkTree(market, locale) {
2308
2316
  const categories = await store.category.findMany({ market, locale });
2309
2317
  const rootCategory = (0, import_bom_core16.getRootCategory)(categories);
2310
2318
  if (rootCategory) {
2311
- const root = categoryToRouteLink(routes, categories, rootCategory, locale);
2319
+ const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
2312
2320
  return root;
2313
2321
  }
2314
2322
  return void 0;
2315
2323
  }
2316
- function categoryToRouteLink(routes, categories, category, locale) {
2324
+ function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
2317
2325
  const route = (0, import_bom_core16.findRouteOfCategory)(routes, category.id);
2318
- if (!route) {
2319
- return void 0;
2320
- }
2321
- const rootCategory = (0, import_bom_core16.getRootCategory)(categories);
2322
- const childCategories = categories.filter((x) => {
2323
- const parentId = (0, import_bom_core16.asCategoryId)(x.category);
2324
- return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
2325
- });
2326
+ const otherCategories = categories.filter((x) => x.id !== category.id);
2327
+ const childCategories = otherCategories.filter((x) => (0, import_bom_core16.asCategoryId)(x.category) === category.id);
2326
2328
  const routeLink = newRouteLink(category, route, locale);
2327
- routeLink.items = childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale)).filter((x) => x !== void 0);
2329
+ const items = [];
2330
+ for (const childCategory of childCategories) {
2331
+ const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
2332
+ if (Array.isArray(itemOrItems)) {
2333
+ items.push(...itemOrItems);
2334
+ } else if (itemOrItems) {
2335
+ items.push(itemOrItems);
2336
+ }
2337
+ }
2338
+ if (!route || category.isHidden && category.id !== rootCategory.id) {
2339
+ return items;
2340
+ }
2341
+ routeLink.items = items;
2328
2342
  return routeLink;
2329
2343
  }
2330
2344
  function newRouteLink(category, route, locale) {
@@ -2539,7 +2553,6 @@ function varsHandler() {
2539
2553
  RemoteMenuService,
2540
2554
  RemotePageService,
2541
2555
  RemoteService,
2542
- RemoteServiceStrategy,
2543
2556
  STATIC_COLLECTIONS,
2544
2557
  StaticService,
2545
2558
  StoreStrategy,
@@ -2596,6 +2609,7 @@ function varsHandler() {
2596
2609
  nextPhase,
2597
2610
  optimizeMany_,
2598
2611
  optimizeOne_,
2612
+ previewHandler,
2599
2613
  remoteApiDelete,
2600
2614
  remoteApiFetch,
2601
2615
  remoteApiGet,
package/dist/index.mjs CHANGED
@@ -501,9 +501,6 @@ async function optimizeMany_(items) {
501
501
  import { isArray as isArray2, isObject as isObject2, isUnresolvedRelation } from "@websolutespa/bom-core";
502
502
  async function decorateRelation_(store, item, params = {}) {
503
503
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
504
- if (depth === 0) {
505
- return item;
506
- }
507
504
  item = await collectRelations_({ store, params, depth }, item);
508
505
  return item;
509
506
  }
@@ -515,6 +512,9 @@ async function decorateRelations_(store, items, params = {}) {
515
512
  }
516
513
  async function collectRelations_(context, item, relations = []) {
517
514
  if (isUnresolvedRelation(item)) {
515
+ if (context.depth === 0) {
516
+ return item.value;
517
+ }
518
518
  const index = relations.findIndex(
519
519
  (x) => x.relationTo === item.relationTo && x.value === item.value
520
520
  );
@@ -1423,9 +1423,6 @@ async function remoteApiDelete(url, options = {}) {
1423
1423
  }
1424
1424
 
1425
1425
  // src/remote/remote.service.ts
1426
- var RemoteServiceStrategy = {
1427
- draft: false
1428
- };
1429
1426
  var RemoteService = class {
1430
1427
  constructor(key, store) {
1431
1428
  if (!key) {
@@ -1439,7 +1436,6 @@ var RemoteService = class {
1439
1436
  }
1440
1437
  async findOne(id, params = {}, token) {
1441
1438
  params.richText = String(params.richText) === "true" ? true : false;
1442
- params.draft = RemoteServiceStrategy.draft;
1443
1439
  const query = qsSerialize2(params);
1444
1440
  const search = query ? `?${query}` : "";
1445
1441
  const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
@@ -1455,7 +1451,6 @@ var RemoteService = class {
1455
1451
  }
1456
1452
  async findMany(params = {}, token) {
1457
1453
  params.richText = String(params.richText) === "true" ? true : false;
1458
- params.draft = RemoteServiceStrategy.draft;
1459
1454
  params.pagination = false;
1460
1455
  const query = qsSerialize2(params);
1461
1456
  const search = query ? `?${query}` : "";
@@ -1466,7 +1461,6 @@ var RemoteService = class {
1466
1461
  }
1467
1462
  async findPaged(params = {}, token) {
1468
1463
  params.richText = String(params.richText) === "true" ? true : false;
1469
- params.draft = RemoteServiceStrategy.draft;
1470
1464
  params.pagination = true;
1471
1465
  const query = qsSerialize2(params);
1472
1466
  const search = query ? `?${query}` : "";
@@ -1478,7 +1472,6 @@ var RemoteService = class {
1478
1472
  }
1479
1473
  async create(payload, params = {}, token) {
1480
1474
  params.richText = String(params.richText) === "true" ? true : false;
1481
- params.draft = RemoteServiceStrategy.draft;
1482
1475
  const query = qsSerialize2(params);
1483
1476
  const search = query ? `?${query}` : "";
1484
1477
  const url = `/${this.key}${search}`;
@@ -1496,7 +1489,6 @@ var RemoteService = class {
1496
1489
  }
1497
1490
  async updateMany(payload, params = {}, token) {
1498
1491
  params.richText = String(params.richText) === "true" ? true : false;
1499
- params.draft = RemoteServiceStrategy.draft;
1500
1492
  params.pagination = false;
1501
1493
  const query = qsSerialize2(params);
1502
1494
  const search = query ? `?${query}` : "";
@@ -1514,7 +1506,6 @@ var RemoteService = class {
1514
1506
  }
1515
1507
  async deleteMany(params = {}, token) {
1516
1508
  params.richText = String(params.richText) === "true" ? true : false;
1517
- params.draft = RemoteServiceStrategy.draft;
1518
1509
  params.pagination = false;
1519
1510
  const query = qsSerialize2(params);
1520
1511
  const search = query ? `?${query}` : "";
@@ -2137,6 +2128,23 @@ function mockHandler() {
2137
2128
  return storeHandler(async () => await getMockStore());
2138
2129
  }
2139
2130
 
2131
+ // src/preview/preview.handler.ts
2132
+ function previewHandler() {
2133
+ return apiHandler({
2134
+ options: async (request, response) => {
2135
+ response.status(200).end();
2136
+ },
2137
+ get: async (request, response) => {
2138
+ const query = request.query;
2139
+ const { marketId, localeId, templateId, documentId, _status } = query;
2140
+ const destination = `/${marketId}/${localeId}/${templateId}/${documentId}${query._live ? "?_live=true" : ""}`;
2141
+ response.setPreviewData({ _status });
2142
+ response.setDraftMode({ enable: true });
2143
+ response.redirect(307, destination);
2144
+ }
2145
+ });
2146
+ }
2147
+
2140
2148
  // src/store/store.api.ts
2141
2149
  var storeApiFetch = storeStrategy === "mock" /* Mock */ ? localApiFetch : remoteApiFetch;
2142
2150
  async function storeApiGet(url, options = {}) {
@@ -2203,23 +2211,29 @@ async function getRouteLinkTree(market, locale) {
2203
2211
  const categories = await store.category.findMany({ market, locale });
2204
2212
  const rootCategory = getRootCategory(categories);
2205
2213
  if (rootCategory) {
2206
- const root = categoryToRouteLink(routes, categories, rootCategory, locale);
2214
+ const root = getRouteLinkCategory(locale, routes, categories, rootCategory, rootCategory);
2207
2215
  return root;
2208
2216
  }
2209
2217
  return void 0;
2210
2218
  }
2211
- function categoryToRouteLink(routes, categories, category, locale) {
2219
+ function getRouteLinkCategory(locale, routes, categories, rootCategory, category) {
2212
2220
  const route = findRouteOfCategory3(routes, category.id);
2213
- if (!route) {
2214
- return void 0;
2215
- }
2216
- const rootCategory = getRootCategory(categories);
2217
- const childCategories = categories.filter((x) => {
2218
- const parentId = asCategoryId2(x.category);
2219
- return rootCategory && rootCategory.id === category.id ? x.id !== rootCategory.id && (parentId === category.id || !parentId) : parentId === category.id;
2220
- });
2221
+ const otherCategories = categories.filter((x) => x.id !== category.id);
2222
+ const childCategories = otherCategories.filter((x) => asCategoryId2(x.category) === category.id);
2221
2223
  const routeLink = newRouteLink(category, route, locale);
2222
- routeLink.items = childCategories.map((x) => categoryToRouteLink(routes, categories, x, locale)).filter((x) => x !== void 0);
2224
+ const items = [];
2225
+ for (const childCategory of childCategories) {
2226
+ const itemOrItems = getRouteLinkCategory(locale, routes, otherCategories, rootCategory, childCategory);
2227
+ if (Array.isArray(itemOrItems)) {
2228
+ items.push(...itemOrItems);
2229
+ } else if (itemOrItems) {
2230
+ items.push(itemOrItems);
2231
+ }
2232
+ }
2233
+ if (!route || category.isHidden && category.id !== rootCategory.id) {
2234
+ return items;
2235
+ }
2236
+ routeLink.items = items;
2223
2237
  return routeLink;
2224
2238
  }
2225
2239
  function newRouteLink(category, route, locale) {
@@ -2433,7 +2447,6 @@ export {
2433
2447
  RemoteMenuService,
2434
2448
  RemotePageService,
2435
2449
  RemoteService,
2436
- RemoteServiceStrategy,
2437
2450
  STATIC_COLLECTIONS,
2438
2451
  StaticService,
2439
2452
  StoreStrategy,
@@ -2490,6 +2503,7 @@ export {
2490
2503
  nextPhase,
2491
2504
  optimizeMany_,
2492
2505
  optimizeOne_,
2506
+ previewHandler,
2493
2507
  remoteApiDelete,
2494
2508
  remoteApiFetch,
2495
2509
  remoteApiGet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-store",
3
- "version": "1.8.12",
3
+ "version": "1.10.0",
4
4
  "description": "Mixer Store module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -3,9 +3,7 @@ import { DEFAULT_DEPTH } from './consts';
3
3
 
4
4
  export async function decorateRelation_<T extends ISchema = ISchema>(store: IStore, item: T, params: QueryParams = {}): Promise<T> {
5
5
  const depth = params.depth != null ? params.depth : DEFAULT_DEPTH;
6
- if (depth === 0) {
7
- return item;
8
- }
6
+ // console.log('decorateRelation_', depth, typeof depth);
9
7
  item = await collectRelations_({ store, params, depth }, item);
10
8
  return item;
11
9
  }
@@ -30,6 +28,9 @@ async function collectRelations_<T = any>(context: {
30
28
  depth: number;
31
29
  }, item: T, relations: IPageResolvedRelation[] = []): Promise<T> {
32
30
  if (isUnresolvedRelation(item)) {
31
+ if (context.depth === 0) {
32
+ return item.value as T;
33
+ }
33
34
  // skip circular reference
34
35
  const index = relations.findIndex(x =>
35
36
  x.relationTo === item.relationTo && x.value === item.value
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export * from './mock/mock.api';
10
10
  export * from './mock/mock.handler';
11
11
  export * from './mock/mock.service';
12
12
  export * from './mock/mock.store';
13
+ export * from './preview/preview.handler';
13
14
  export * from './remote/remote-menu.service';
14
15
  export * from './remote/remote-page.service';
15
16
  export * from './remote/remote.api';
@@ -0,0 +1,26 @@
1
+ import { NextApiRequest, NextApiResponse } from 'next';
2
+ import { apiHandler } from '../api/api.handler';
3
+
4
+ export function previewHandler() {
5
+ return apiHandler({
6
+ options: async (request: NextApiRequest, response: NextApiResponse) => {
7
+ response.status(200).end();
8
+ },
9
+ get: async (request: NextApiRequest, response: NextApiResponse) => {
10
+ const query = request.query as {
11
+ marketId: string;
12
+ localeId: string;
13
+ templateId: string;
14
+ documentId: string;
15
+ _status: 'published' | 'draft';
16
+ _live: string;
17
+ _token: string;
18
+ };
19
+ const { marketId, localeId, templateId, documentId, _status } = query;
20
+ const destination = `/${marketId}/${localeId}/${templateId}/${documentId}${query._live ? '?_live=true' : ''}`;
21
+ response.setPreviewData({ _status });
22
+ response.setDraftMode({ enable: true });
23
+ response.redirect(307, destination);
24
+ },
25
+ });
26
+ }
@@ -3,10 +3,6 @@ import { getRemoteApiRequestOptions } from '../api/api';
3
3
  import { decorateSchema_, decorateSchemas_ } from '../decorators';
4
4
  import { remoteApiDelete, remoteApiGet, remoteApiPatch, remoteApiPost } from './remote.api';
5
5
 
6
- export const RemoteServiceStrategy = {
7
- draft: false,
8
- };
9
-
10
6
  /**
11
7
  * This service handle call to remote api (bowl or over)
12
8
  */
@@ -28,7 +24,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
28
24
 
29
25
  async findOne<B extends T = T>(id: IEquatable, params: Omit<QueryParams, 'where'> = {}, token?: string): Promise<B | undefined> {
30
26
  params.richText = String(params.richText) === 'true' ? true : false;
31
- params.draft = RemoteServiceStrategy.draft;
32
27
  const query = qsSerialize(params);
33
28
  const search = query ? `?${query}` : '';
34
29
  const url = `/${this.key}/${encodeURIComponent(id)}${search}`;
@@ -46,7 +41,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
46
41
 
47
42
  async findMany<B extends T = T>(params: QueryParams = {}, token?: string): Promise<B[]> {
48
43
  params.richText = String(params.richText) === 'true' ? true : false;
49
- params.draft = RemoteServiceStrategy.draft;
50
44
  params.pagination = false;
51
45
  const query = qsSerialize(params);
52
46
  const search = query ? `?${query}` : '';
@@ -59,7 +53,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
59
53
 
60
54
  async findPaged<B extends T = T>(params: QueryParams = {}, token?: string): Promise<IPagedResult<B>> {
61
55
  params.richText = String(params.richText) === 'true' ? true : false;
62
- params.draft = RemoteServiceStrategy.draft;
63
56
  params.pagination = true;
64
57
  const query = qsSerialize(params);
65
58
  const search = query ? `?${query}` : '';
@@ -73,7 +66,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
73
66
 
74
67
  async create<B extends T = T>(payload: Omit<B, 'id'>, params: QueryParams = {}, token?: string): Promise<B> {
75
68
  params.richText = String(params.richText) === 'true' ? true : false;
76
- params.draft = RemoteServiceStrategy.draft;
77
69
  const query = qsSerialize(params);
78
70
  const search = query ? `?${query}` : '';
79
71
  const url = `/${this.key}${search}`;
@@ -95,7 +87,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
95
87
 
96
88
  async updateMany<B extends T = T>(payload: Partial<B>, params: QueryParams = {}, token?: string): Promise<B[]> {
97
89
  params.richText = String(params.richText) === 'true' ? true : false;
98
- params.draft = RemoteServiceStrategy.draft;
99
90
  params.pagination = false;
100
91
  const query = qsSerialize(params);
101
92
  const search = query ? `?${query}` : '';
@@ -117,7 +108,6 @@ export class RemoteService<T extends IEntity = IEntity> implements IQuerable<T>
117
108
 
118
109
  async deleteMany<B extends T = T>(params: QueryParams = {}, token?: string): Promise<B[]> {
119
110
  params.richText = String(params.richText) === 'true' ? true : false;
120
- params.draft = RemoteServiceStrategy.draft;
121
111
  params.pagination = false;
122
112
  const query = qsSerialize(params);
123
113
  const search = query ? `?${query}` : '';