@gem-sdk/core 1.46.0-staging.21 → 1.46.0-staging.23

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.
@@ -4,15 +4,19 @@ var addAppBlockId = require('./addAppBlockId.js');
4
4
  var generateAppBlockConfigs = require('./generateAppBlockConfigs.js');
5
5
  var mergeBlock = require('./mergeBlock.js');
6
6
  var mergeBlockOrder = require('./mergeBlockOrder.js');
7
+ var removeGPAppItems = require('./removeGPAppItems.js');
7
8
 
8
- const getAppBlocks = (section, currentBlock, currentBlockOrder)=>{
9
+ const getAppBlocks = (section)=>{
10
+ if (!section?.appBlocks) return {};
11
+ const { blocks: currentBlock, block_order: currentBlockOrder } = JSON.parse(section.appBlocks);
12
+ if (!currentBlock || !currentBlockOrder) return {};
9
13
  const component = JSON.parse(section?.component || '');
10
14
  const componentWithAppBlockId = addAppBlockId.addAppBlockId(component);
11
15
  const appBlockConfigs = generateAppBlockConfigs.generateAppBlockConfigs(componentWithAppBlockId);
12
16
  if (!appBlockConfigs) {
13
17
  return {
14
- blocks: currentBlock,
15
- block_order: currentBlockOrder
18
+ blocks: removeGPAppItems.removeAllGPAppItemsFromBlocks(currentBlock),
19
+ block_order: removeGPAppItems.removeAllGPAppItemsFromBlockOrder(currentBlockOrder)
16
20
  };
17
21
  }
18
22
  const { newBlocks, newBlockOrder } = appBlockConfigs;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var constant = require('./constant.js');
4
+
5
+ const removeAllGPAppItemsFromBlocks = (blocks)=>{
6
+ for(const key in blocks){
7
+ if (key.startsWith(constant.THIRD_PARTY_APP_BLOCK_ID_PREFIX)) {
8
+ delete blocks[key];
9
+ }
10
+ }
11
+ return blocks;
12
+ };
13
+ const removeAllGPAppItemsFromBlockOrder = (blockOrder)=>{
14
+ return blockOrder.filter((item)=>!item.includes(constant.THIRD_PARTY_APP_BLOCK_ID_PREFIX));
15
+ };
16
+
17
+ exports.removeAllGPAppItemsFromBlockOrder = removeAllGPAppItemsFromBlockOrder;
18
+ exports.removeAllGPAppItemsFromBlocks = removeAllGPAppItemsFromBlocks;
@@ -2,15 +2,19 @@ import { addAppBlockId } from './addAppBlockId.js';
2
2
  import { generateAppBlockConfigs } from './generateAppBlockConfigs.js';
3
3
  import { mergeBlocks } from './mergeBlock.js';
4
4
  import { mergeBlockOrder } from './mergeBlockOrder.js';
5
+ import { removeAllGPAppItemsFromBlocks, removeAllGPAppItemsFromBlockOrder } from './removeGPAppItems.js';
5
6
 
6
- const getAppBlocks = (section, currentBlock, currentBlockOrder)=>{
7
+ const getAppBlocks = (section)=>{
8
+ if (!section?.appBlocks) return {};
9
+ const { blocks: currentBlock, block_order: currentBlockOrder } = JSON.parse(section.appBlocks);
10
+ if (!currentBlock || !currentBlockOrder) return {};
7
11
  const component = JSON.parse(section?.component || '');
8
12
  const componentWithAppBlockId = addAppBlockId(component);
9
13
  const appBlockConfigs = generateAppBlockConfigs(componentWithAppBlockId);
10
14
  if (!appBlockConfigs) {
11
15
  return {
12
- blocks: currentBlock,
13
- block_order: currentBlockOrder
16
+ blocks: removeAllGPAppItemsFromBlocks(currentBlock),
17
+ block_order: removeAllGPAppItemsFromBlockOrder(currentBlockOrder)
14
18
  };
15
19
  }
16
20
  const { newBlocks, newBlockOrder } = appBlockConfigs;
@@ -0,0 +1,15 @@
1
+ import { THIRD_PARTY_APP_BLOCK_ID_PREFIX } from './constant.js';
2
+
3
+ const removeAllGPAppItemsFromBlocks = (blocks)=>{
4
+ for(const key in blocks){
5
+ if (key.startsWith(THIRD_PARTY_APP_BLOCK_ID_PREFIX)) {
6
+ delete blocks[key];
7
+ }
8
+ }
9
+ return blocks;
10
+ };
11
+ const removeAllGPAppItemsFromBlockOrder = (blockOrder)=>{
12
+ return blockOrder.filter((item)=>!item.includes(THIRD_PARTY_APP_BLOCK_ID_PREFIX));
13
+ };
14
+
15
+ export { removeAllGPAppItemsFromBlockOrder, removeAllGPAppItemsFromBlocks };
@@ -37365,8 +37365,13 @@ declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<P
37365
37365
 
37366
37366
  declare const getAppBlocks: (section: PublishedPageSection$1 & {
37367
37367
  appBlocks: string;
37368
- }, currentBlock: {}, currentBlockOrder: string[]) => {
37369
- blocks: {};
37368
+ }) => {
37369
+ blocks?: undefined;
37370
+ block_order?: undefined;
37371
+ } | {
37372
+ blocks: {
37373
+ [key: string]: any;
37374
+ };
37370
37375
  block_order: string[];
37371
37376
  };
37372
37377
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.46.0-staging.21",
3
+ "version": "1.46.0-staging.23",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",