@localazy/strapi-plugin 0.1.14 → 0.1.16

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.
@@ -49,10 +49,45 @@ const getPickPaths = (transferSetupModelProps) => {
49
49
  return pickPaths;
50
50
  };
51
51
 
52
+ const getPickPathsWithComponents = (transferSetupModelProps) => {
53
+ const flattenedObject = flattenObject(transferSetupModelProps);
54
+ let pickComponents = {};
55
+ Object.keys(flattenedObject).forEach((key) => {
56
+ if (key.includes(".__component__")) {
57
+ const componentKey = key.split(".__component__")[0];
58
+ const propertyName = componentKey.split("[")[0];
59
+ if (!pickComponents[componentKey]) {
60
+ const splitByDot = flattenedObject[key].split(".");
61
+ pickComponents[componentKey] = `${propertyName}[${splitByDot[1]}]`;
62
+ }
63
+ }
64
+ });
65
+ const pickPaths = Object.keys(flattenedObject)
66
+ .filter(
67
+ (key) => flattenedObject[key] === true && key.indexOf("__model__") === -1
68
+ );
69
+
70
+ // id needs to be always included
71
+ pickPaths.push("id");
72
+
73
+ let pickPathsWithComponents = [];
74
+ Object.entries(pickPaths).forEach(([, value]) => {
75
+ const componentKey = value.split(".")[0];
76
+ let pushValue = value;
77
+ if (pickComponents[componentKey]) {
78
+ pushValue = value.replace(componentKey, pickComponents[componentKey]);
79
+ }
80
+ pickPathsWithComponents.push(pushValue);
81
+ });
82
+
83
+ return pickPathsWithComponents;
84
+ };
85
+
52
86
  module.exports = {
53
87
  findSetupModelByCollectionName,
54
88
  findSetupModelByCollectionUid,
55
89
  getCollectionsNames,
56
90
  isCollectionTransferEnabled,
57
91
  getPickPaths,
92
+ getPickPathsWithComponents,
58
93
  };
@@ -0,0 +1,9 @@
1
+ const strapi = {
2
+ entityService: {
3
+ findOne: jest.fn(),
4
+ },
5
+ };
6
+
7
+ module.exports = {
8
+ strapi,
9
+ };