@gem-sdk/core 1.46.0-staging.21 → 1.46.0-staging.24
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/dist/cjs/helpers/third-party/getAppBlocks.js +7 -3
- package/dist/cjs/helpers/third-party/removeGPAppItems.js +18 -0
- package/dist/esm/helpers/third-party/getAppBlocks.js +7 -3
- package/dist/esm/helpers/third-party/removeGPAppItems.js +15 -0
- package/dist/types/index.d.ts +7 -2
- package/package.json +1 -1
|
@@ -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
|
|
9
|
+
const getAppBlocks = (section)=>{
|
|
10
|
+
if (!section?.appBlocks) return {};
|
|
11
|
+
const { blocks: currentBlock, block_order: currentBlockOrder } = JSON.parse(section.appBlocks);
|
|
9
12
|
const component = JSON.parse(section?.component || '');
|
|
10
13
|
const componentWithAppBlockId = addAppBlockId.addAppBlockId(component);
|
|
11
14
|
const appBlockConfigs = generateAppBlockConfigs.generateAppBlockConfigs(componentWithAppBlockId);
|
|
12
15
|
if (!appBlockConfigs) {
|
|
16
|
+
if (!currentBlock || !currentBlockOrder) return {};
|
|
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
|
|
7
|
+
const getAppBlocks = (section)=>{
|
|
8
|
+
if (!section?.appBlocks) return {};
|
|
9
|
+
const { blocks: currentBlock, block_order: currentBlockOrder } = JSON.parse(section.appBlocks);
|
|
7
10
|
const component = JSON.parse(section?.component || '');
|
|
8
11
|
const componentWithAppBlockId = addAppBlockId(component);
|
|
9
12
|
const appBlockConfigs = generateAppBlockConfigs(componentWithAppBlockId);
|
|
10
13
|
if (!appBlockConfigs) {
|
|
14
|
+
if (!currentBlock || !currentBlockOrder) return {};
|
|
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 };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
-
}
|
|
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
|
|