@localazy/strapi-plugin 0.1.7 → 0.1.10
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/.github/workflows/.build.yml +2 -13
- package/.nvmrc +1 -1
- package/admin/src/modules/@common/components/PluginPageLoader/index.js +22 -0
- package/admin/src/modules/@common/services/product-analytics-service.js +67 -0
- package/admin/src/modules/@common/utils/format-number.js +1 -0
- package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +33 -22
- package/admin/src/modules/plugin-settings/components/ContentTransferSetupEmpty/index.js +86 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +10 -1
- package/admin/src/modules/plugin-settings/locale/en.js +7 -0
- package/admin/src/modules/plugin-settings/services/plugin-settings-service.js +23 -0
- package/admin/src/pages/App/index.js +4 -2
- package/admin/src/pages/Download/index.js +16 -1
- package/admin/src/pages/Login/index.js +8 -1
- package/admin/src/pages/Settings/index.js +17 -3
- package/admin/src/pages/Upload/index.js +17 -1
- package/admin/src/plugins/analytics-service.js +14 -0
- package/admin/src/utils/createPluginConnectorAxiosInstance.js +45 -0
- package/package.json +4 -4
- package/server/config/index.js +10 -5
- package/server/config/local/index.js +15 -0
- package/server/controllers/localazy-transfer-controller.js +5 -2
- package/server/controllers/plugin-settings-controller.js +14 -0
- package/server/db/model/plugin-settings.js +13 -0
- package/server/routes/plugin-settings.js +16 -0
- package/server/services/plugin-settings-service.js +28 -7
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +58 -88
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +79 -132
- package/server/utils/parsed-localazy-entry-to-create-entry.js +23 -6
- package/server/utils/parsed-localazy-entry-to-update-entry.js +5 -1
- package/server/utils/pick-entries.js +2 -1
- package/server/utils/reset-array-keys-deep.js +19 -0
|
@@ -16,155 +16,102 @@ describe("parsed-localazy-entry-to-update-entry.js", () => {
|
|
|
16
16
|
|
|
17
17
|
// EXECUTE
|
|
18
18
|
const result = parsedLocalazyEntryToUpdateEntry(
|
|
19
|
-
allModelsWithMultimedia,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
JSON.parse("[{\"kind\":\"singleType\",\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"a_first_positioned_some_test_single_types\",\"info\":{\"singularName\":\"a-first-positioned-some-test-single-type\",\"pluralName\":\"a-first-positioned-some-test-single-types\",\"displayName\":\"a_first_positioned_some_test_single_type\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"label\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"singleType\"},\"modelType\":\"contentType\",\"modelName\":\"a-first-positioned-some-test-single-type\",\"connection\":\"default\",\"uid\":\"api::a-first-positioned-some-test-single-type.a-first-positioned-some-test-single-type\",\"apiName\":\"a-first-positioned-some-test-single-type\",\"globalId\":\"AFirstPositionedSomeTestSingleType\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"a-first-positioned-some-test-single-type\",\"tableName\":\"a_first_positioned_some_test_single_types\"},{\"kind\":\"collectionType\",\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"presentations\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"books\",\"info\":{\"singularName\":\"book\",\"pluralName\":\"books\",\"displayName\":\"Book\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"Title\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Author\":{\"type\":\"string\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"Pages\":{\"type\":\"integer\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"additional_info\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.pub-component-1\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"cover\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"presentations\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"],\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"seo_setup\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"seo.gallery\"},\"non_localizable_name\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"book\",\"connection\":\"default\",\"uid\":\"api::book.book\",\"apiName\":\"book\",\"globalId\":\"Book\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"book\",\"tableName\":\"books\"},{\"kind\":\"collectionType\",\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::loc-5087.loc-5087\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"loc_5087s\",\"info\":{\"singularName\":\"loc-5087\",\"pluralName\":\"loc-5087s\",\"displayName\":\"LOC-5087\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\",\"pluginOptions\":{\"i18n\":{\"localized\":true}}}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"loc-5087\",\"connection\":\"default\",\"uid\":\"api::loc-5087.loc-5087\",\"apiName\":\"loc-5087\",\"globalId\":\"Loc5087\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"loc-5087\",\"tableName\":\"loc_5087s\"},{\"kind\":\"collectionType\",\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"createdAt\":{\"type\":\"datetime\"},\"updatedAt\":{\"type\":\"datetime\"},\"publishedAt\":{\"type\":\"datetime\",\"configurable\":false,\"writable\":true,\"visible\":false},\"createdBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"updatedBy\":{\"type\":\"relation\",\"relation\":\"oneToOne\",\"target\":\"admin::user\",\"configurable\":false,\"writable\":false,\"visible\":false,\"useJoinTable\":false,\"private\":true},\"localizations\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::restaurant.restaurant\"},\"locale\":{\"writable\":true,\"private\":false,\"configurable\":false,\"visible\":false,\"type\":\"string\"}},\"__schema__\":{\"collectionName\":\"restaurants\",\"info\":{\"singularName\":\"restaurant\",\"pluralName\":\"restaurants\",\"displayName\":\"Restaurant\",\"description\":\"\"},\"options\":{\"draftAndPublish\":true},\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"attributes\":{\"title\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\",\"required\":true},\"description\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"text\"},\"books\":{\"type\":\"relation\",\"relation\":\"oneToMany\",\"target\":\"api::book.book\"},\"recipes\":{\"type\":\"component\",\"repeatable\":true,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.recipe\"},\"descs\":{\"type\":\"component\",\"repeatable\":false,\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"component\":\"food.pub-component-1\"},\"street\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"city\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"country\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"Motto\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"},\"motto_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":false}},\"type\":\"string\"},\"title_2\":{\"pluginOptions\":{\"i18n\":{\"localized\":true}},\"type\":\"string\"}},\"kind\":\"collectionType\"},\"modelType\":\"contentType\",\"modelName\":\"restaurant\",\"connection\":\"default\",\"uid\":\"api::restaurant.restaurant\",\"apiName\":\"restaurant\",\"globalId\":\"Restaurant\",\"actions\":{},\"lifecycles\":{},\"singularName\":\"restaurant\",\"tableName\":\"restaurants\"},{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredient_variants\",\"info\":{\"displayName\":\"ingredient_variants\",\"icon\":\"atlas\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\"}},\"__filename__\":\"ingredient-variants.json\"},\"uid\":\"food.ingredient-variants\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredient-variants\",\"globalId\":\"ComponentFoodIngredientVariants\",\"singularName\":\"ingredient-variants\",\"tableName\":\"components_food_ingredient_variants\"},{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\",\"__schema__\":{\"collectionName\":\"components_food_ingredients\",\"info\":{\"displayName\":\"ingredients\",\"icon\":\"atom\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"pcs\":{\"type\":\"integer\"},\"required\":{\"type\":\"boolean\"}},\"__filename__\":\"ingredients.json\"},\"uid\":\"food.ingredients\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"ingredients\",\"globalId\":\"ComponentFoodIngredients\",\"singularName\":\"ingredients\",\"tableName\":\"components_food_ingredients\"},{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\",\"__schema__\":{\"collectionName\":\"components_food_pub_component_1s\",\"info\":{\"displayName\":\"Pub Component 1\",\"icon\":\"american-sign-language-interpreting\",\"description\":\"\"},\"options\":{},\"attributes\":{\"rich_description\":{\"type\":\"richtext\"},\"history\":{\"type\":\"text\"},\"excerpt\":{\"type\":\"string\"},\"test_variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"pub-component-1.json\"},\"uid\":\"food.pub-component-1\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"pub-component-1\",\"globalId\":\"ComponentFoodPubComponent1\",\"singularName\":\"pub-component-1\",\"tableName\":\"components_food_pub_component_1s\"},{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\",\"__schema__\":{\"collectionName\":\"components_food_recipes\",\"info\":{\"displayName\":\"recipe\",\"icon\":\"ad\",\"description\":\"\"},\"options\":{},\"attributes\":{\"name\":{\"type\":\"string\",\"required\":true},\"ingredients\":{\"type\":\"component\",\"repeatable\":true,\"component\":\"food.ingredients\"},\"variants\":{\"type\":\"component\",\"repeatable\":false,\"component\":\"food.ingredient-variants\"}},\"__filename__\":\"recipe.json\"},\"uid\":\"food.recipe\",\"category\":\"food\",\"modelType\":\"component\",\"modelName\":\"recipe\",\"globalId\":\"ComponentFoodRecipe\",\"singularName\":\"recipe\",\"tableName\":\"components_food_recipes\"},{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"relation\",\"relation\":\"morphOne\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"rest\":{\"type\":\"relation\",\"relation\":\"morphMany\",\"target\":\"plugin::upload.file\",\"morphBy\":\"related\"},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\",\"__schema__\":{\"collectionName\":\"components_seo_galleries\",\"info\":{\"displayName\":\"Gallery\",\"icon\":\"address-card\",\"description\":\"\"},\"options\":{},\"attributes\":{\"main_image\":{\"type\":\"media\",\"multiple\":false,\"required\":false,\"allowedTypes\":[\"images\",\"files\",\"videos\",\"audios\"]},\"rest\":{\"type\":\"media\",\"multiple\":true,\"required\":false,\"allowedTypes\":[\"images\",\"videos\",\"audios\",\"files\"]},\"seo_desc\":{\"type\":\"string\"}},\"__filename__\":\"gallery.json\"},\"uid\":\"seo.gallery\",\"category\":\"seo\",\"modelType\":\"component\",\"modelName\":\"gallery\",\"globalId\":\"ComponentSeoGallery\",\"singularName\":\"gallery\",\"tableName\":\"components_seo_galleries\"}]"),
|
|
20
|
+
JSON.parse("{\"ingredients\":[null,{\"name\":\"první\"},{\"name\":\"druhý\"},{\"name\":\"třetí\"},{\"name\":\"čtvrtý\"},{\"name\":\"pátý\"},{\"name\":\"šestý\"},{\"name\":\"sedmý\"},{\"name\":\"osmý\"},{\"name\":\"devátý\"},{\"name\":\"desátý\"},null,null,null,null,null,null,null,null,null,null,{\"name\":\"jedenáctý\"},null,{\"name\":\"dvanáctý\"},{\"name\":\"třináctý\"},null,{\"name\":\"čtrnáctý\"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,{\"Name\":\"první\"},{\"Name\":\"druhý\"},{\"Name\":\"třetina\"},{\"Name\":\"čtvrtý\"},{\"Name\":\"pátý\"},{\"Name\":\"šestý\"},{\"Name\":\"sedmý\"},{\"Name\":\"osmý\"},{\"Name\":\"devátý\"},{\"Name\":\"desátý\"}]}"),
|
|
21
|
+
JSON.parse("{\"id\":3,\"ingredients\":[{\"id\":28,\"name\":\"dvanáctý\",\"pcs\":null,\"required\":null},{\"id\":29,\"name\":\"první\",\"pcs\":null,\"required\":null},{\"id\":30,\"name\":\"druhý\",\"pcs\":null,\"required\":null},{\"id\":31,\"name\":\"jedenáctý\",\"pcs\":null,\"required\":null},{\"id\":32,\"name\":\"třetí\",\"pcs\":null,\"required\":null},{\"id\":33,\"name\":\"čtvrtý\",\"pcs\":null,\"required\":null},{\"id\":34,\"name\":\"pátý\",\"pcs\":null,\"required\":null},{\"id\":35,\"name\":\"šestý\",\"pcs\":null,\"required\":null},{\"id\":36,\"name\":\"čtrnáctý\",\"pcs\":null,\"required\":null},{\"id\":37,\"name\":\"sedmý\",\"pcs\":null,\"required\":null},{\"id\":38,\"name\":\"osmý\",\"pcs\":null,\"required\":null},{\"id\":39,\"name\":\"devátý\",\"pcs\":null,\"required\":null},{\"id\":40,\"name\":\"desátý\",\"pcs\":null,\"required\":null},{\"id\":41,\"name\":\"třináctý\",\"pcs\":null,\"required\":null}]}"),
|
|
22
|
+
JSON.parse("{\"id\":1,\"createdAt\":\"2022-08-30T09:21:23.903Z\",\"updatedAt\":\"2022-08-30T15:09:19.107Z\",\"publishedAt\":null,\"locale\":\"en\",\"ingredients\":[{\"id\":23,\"name\":\"twelveth\",\"pcs\":12,\"required\":null},{\"id\":1,\"name\":\"first\",\"pcs\":1,\"required\":null},{\"id\":2,\"name\":\"second\",\"pcs\":2,\"required\":null},{\"id\":21,\"name\":\"eleventh\",\"pcs\":11,\"required\":null},{\"id\":3,\"name\":\"third\",\"pcs\":3,\"required\":null},{\"id\":4,\"name\":\"fourth\",\"pcs\":4,\"required\":null},{\"id\":5,\"name\":\"fifth\",\"pcs\":5,\"required\":null},{\"id\":6,\"name\":\"sixth\",\"pcs\":6,\"required\":null},{\"id\":26,\"name\":\"fourteenth\",\"pcs\":14,\"required\":null},{\"id\":7,\"name\":\"seventh\",\"pcs\":7,\"required\":null},{\"id\":8,\"name\":\"eighth\",\"pcs\":8,\"required\":null},{\"id\":9,\"name\":\"nineth\",\"pcs\":9,\"required\":null},{\"id\":10,\"name\":\"tenth\",\"pcs\":10,\"required\":null},{\"id\":24,\"name\":\"thirteenth\",\"pcs\":13,\"required\":null}],\"createdBy\":{\"id\":1,\"firstname\":\"David\",\"lastname\":\"Vaclavek\",\"username\":null,\"email\":\"david@localazy.com\",\"password\":\"$2a$10$pRWPPnTWp8HFWPR7aD4Pju2nNBD9vyNPt.QaMpU9IA6pMoGFl7eVC\",\"resetPasswordToken\":null,\"registrationToken\":null,\"isActive\":true,\"blocked\":false,\"preferedLanguage\":null,\"createdAt\":\"2022-07-11T11:58:02.016Z\",\"updatedAt\":\"2022-07-11T12:56:16.558Z\"},\"updatedBy\":{\"id\":1,\"firstname\":\"David\",\"lastname\":\"Vaclavek\",\"username\":null,\"email\":\"david@localazy.com\",\"password\":\"$2a$10$pRWPPnTWp8HFWPR7aD4Pju2nNBD9vyNPt.QaMpU9IA6pMoGFl7eVC\",\"resetPasswordToken\":null,\"registrationToken\":null,\"isActive\":true,\"blocked\":false,\"preferedLanguage\":null,\"createdAt\":\"2022-07-11T11:58:02.016Z\",\"updatedAt\":\"2022-07-11T12:56:16.558Z\"},\"localizations\":[{\"id\":3,\"createdAt\":\"2022-08-30T15:08:02.889Z\",\"updatedAt\":\"2022-08-30T21:03:30.453Z\",\"publishedAt\":null,\"locale\":\"cs\"}]}"),
|
|
23
|
+
"api::loc-5087.loc-5087"
|
|
23
24
|
);
|
|
24
25
|
|
|
25
26
|
// VERIFY
|
|
26
27
|
const expected = {
|
|
27
|
-
id:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
rich_description: "RD",
|
|
35
|
-
history: "H 2",
|
|
36
|
-
excerpt: "E",
|
|
37
|
-
test_variants: {
|
|
38
|
-
id: 38,
|
|
39
|
-
name: "Nejsou k dispozici žádné varianty, proč?",
|
|
28
|
+
id: 3,
|
|
29
|
+
ingredients: [
|
|
30
|
+
{
|
|
31
|
+
id: 28,
|
|
32
|
+
name: "dvanáctý",
|
|
33
|
+
pcs: null,
|
|
34
|
+
required: null,
|
|
40
35
|
},
|
|
41
|
-
},
|
|
42
|
-
seo_setup: [
|
|
43
36
|
{
|
|
44
|
-
id:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
id: 29,
|
|
38
|
+
name: "první",
|
|
39
|
+
pcs: null,
|
|
40
|
+
required: null,
|
|
48
41
|
},
|
|
49
42
|
{
|
|
50
|
-
id:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
id: 30,
|
|
44
|
+
name: "druhý",
|
|
45
|
+
pcs: null,
|
|
46
|
+
required: null,
|
|
54
47
|
},
|
|
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
|
-
|
|
48
|
+
{
|
|
49
|
+
id: 31,
|
|
50
|
+
name: "jedenáctý",
|
|
51
|
+
pcs: null,
|
|
52
|
+
required: null,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 32,
|
|
56
|
+
name: "třetí",
|
|
57
|
+
pcs: null,
|
|
58
|
+
required: null,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 33,
|
|
62
|
+
name: "čtvrtý",
|
|
63
|
+
pcs: null,
|
|
64
|
+
required: null,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 34,
|
|
68
|
+
name: "pátý",
|
|
69
|
+
pcs: null,
|
|
70
|
+
required: null,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 35,
|
|
74
|
+
name: "šestý",
|
|
75
|
+
pcs: null,
|
|
76
|
+
required: null,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 36,
|
|
80
|
+
name: "čtrnáctý",
|
|
81
|
+
pcs: null,
|
|
82
|
+
required: null,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 37,
|
|
86
|
+
name: "sedmý",
|
|
87
|
+
pcs: null,
|
|
88
|
+
required: null,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 38,
|
|
92
|
+
name: "osmý",
|
|
93
|
+
pcs: null,
|
|
94
|
+
required: null,
|
|
87
95
|
},
|
|
88
|
-
},
|
|
89
|
-
id: 3,
|
|
90
|
-
recipes: [
|
|
91
96
|
{
|
|
92
|
-
id:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
name: "Rindfleisch",
|
|
97
|
-
pcs: 4,
|
|
98
|
-
required: false,
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: 3,
|
|
102
|
-
name: "Wasser",
|
|
103
|
-
pcs: 1,
|
|
104
|
-
required: true,
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
name: "Rinderbrühe",
|
|
108
|
-
variants: {
|
|
109
|
-
id: 4,
|
|
110
|
-
name: "Red, yellow, green",
|
|
111
|
-
},
|
|
97
|
+
id: 39,
|
|
98
|
+
name: "devátý",
|
|
99
|
+
pcs: null,
|
|
100
|
+
required: null,
|
|
112
101
|
},
|
|
113
102
|
{
|
|
114
|
-
id:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
name: "Tomate",
|
|
119
|
-
pcs: 1,
|
|
120
|
-
required: true,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: 5,
|
|
124
|
-
name: "Suppe",
|
|
125
|
-
pcs: 2,
|
|
126
|
-
required: true,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
name: "Tomatensuppe",
|
|
130
|
-
variants: {
|
|
131
|
-
name: "Rot, gelb, grün",
|
|
132
|
-
},
|
|
103
|
+
id: 40,
|
|
104
|
+
name: "desátý",
|
|
105
|
+
pcs: null,
|
|
106
|
+
required: null,
|
|
133
107
|
},
|
|
134
108
|
{
|
|
135
|
-
id:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
name: "Rindfleisch",
|
|
140
|
-
pcs: 1,
|
|
141
|
-
required: true,
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
id: 7,
|
|
145
|
-
name: "Pfeffer",
|
|
146
|
-
pcs: 4,
|
|
147
|
-
required: null,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
id: 8,
|
|
151
|
-
name: "Pfeffer-Gewürze",
|
|
152
|
-
pcs: 1,
|
|
153
|
-
required: true,
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
id: 9,
|
|
157
|
-
name: "Wasser",
|
|
158
|
-
pcs: 1,
|
|
159
|
-
required: null,
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
name: "Gulasch",
|
|
163
|
-
variants: null,
|
|
109
|
+
id: 41,
|
|
110
|
+
name: "třináctý",
|
|
111
|
+
pcs: null,
|
|
112
|
+
required: null,
|
|
164
113
|
},
|
|
165
114
|
],
|
|
166
|
-
street: "Testowa",
|
|
167
|
-
title: "Volles Restaurant",
|
|
168
115
|
};
|
|
169
116
|
|
|
170
117
|
expect(result).toEqual(expected);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const set = require("lodash/set");
|
|
4
|
+
const get = require("lodash/get");
|
|
5
|
+
const resetArrayKeysDeep = require("./reset-array-keys-deep");
|
|
4
6
|
|
|
5
7
|
const getAttribute = (model, attribute) => {
|
|
6
8
|
const attributeObj = model.attributes[attribute];
|
|
@@ -23,14 +25,17 @@ const findModel = (models, uid) => {
|
|
|
23
25
|
const parsedLocalazyEntryToCreateEntry = (
|
|
24
26
|
models,
|
|
25
27
|
parsedLocalazyEntry,
|
|
28
|
+
baseEntry,
|
|
26
29
|
uid,
|
|
27
30
|
locale = ""
|
|
28
31
|
) => {
|
|
29
32
|
const createEntry = {};
|
|
33
|
+
const repeatableComponentsKeystoFilter = [];
|
|
30
34
|
|
|
31
35
|
const toCreateEntry = (
|
|
32
36
|
entry,
|
|
33
37
|
model,
|
|
38
|
+
baseEntry,
|
|
34
39
|
// eslint-disable-next-line no-unused-vars
|
|
35
40
|
key = "",
|
|
36
41
|
prefix = "",
|
|
@@ -39,16 +44,25 @@ const parsedLocalazyEntryToCreateEntry = (
|
|
|
39
44
|
) => {
|
|
40
45
|
if (Array.isArray(entry)) {
|
|
41
46
|
// is array
|
|
42
|
-
|
|
43
|
-
Object.entries(entry).forEach(([, value]) => {
|
|
47
|
+
Object.entries(entry).forEach(([baseEntryItemId, value]) => {
|
|
44
48
|
if (value !== null) {
|
|
45
49
|
if (component && isRepeatableComponent) {
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
// used for indices filtering in repeatable components
|
|
51
|
+
if (!repeatableComponentsKeystoFilter.includes(prefix)) {
|
|
52
|
+
repeatableComponentsKeystoFilter.push(prefix);
|
|
53
|
+
}
|
|
54
|
+
const baseEntryRepeatableItemId = parseInt(baseEntryItemId);
|
|
55
|
+
const baseEntryRepeateableGroup = get(baseEntry, prefix);
|
|
56
|
+
if (baseEntryRepeateableGroup !== undefined) {
|
|
57
|
+
const localizedEntryRepeatableItemPosition = baseEntryRepeateableGroup.findIndex((repeatableItem) => !!repeatableItem && repeatableItem.id === baseEntryRepeatableItemId);
|
|
58
|
+
if (localizedEntryRepeatableItemPosition > -1) {
|
|
59
|
+
toCreateEntry(value, model, baseEntry, localizedEntryRepeatableItemPosition, `${prefix}.${localizedEntryRepeatableItemPosition}`, component);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
if (component && !isRepeatableComponent) {
|
|
51
|
-
toCreateEntry(value, model, `${prefix}`, `${prefix}`);
|
|
65
|
+
toCreateEntry(value, model, baseEntry, `${prefix}`, `${prefix}`);
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
});
|
|
@@ -70,6 +84,7 @@ const parsedLocalazyEntryToCreateEntry = (
|
|
|
70
84
|
toCreateEntry(
|
|
71
85
|
value,
|
|
72
86
|
componentModel,
|
|
87
|
+
baseEntry,
|
|
73
88
|
objectKey,
|
|
74
89
|
newPrefix,
|
|
75
90
|
component,
|
|
@@ -84,6 +99,7 @@ const parsedLocalazyEntryToCreateEntry = (
|
|
|
84
99
|
toCreateEntry(
|
|
85
100
|
value,
|
|
86
101
|
componentModel,
|
|
102
|
+
baseEntry,
|
|
87
103
|
objectKey,
|
|
88
104
|
newPrefix,
|
|
89
105
|
component,
|
|
@@ -104,11 +120,12 @@ const parsedLocalazyEntryToCreateEntry = (
|
|
|
104
120
|
};
|
|
105
121
|
|
|
106
122
|
const model = findModel(models, uid);
|
|
107
|
-
toCreateEntry(parsedLocalazyEntry, model);
|
|
123
|
+
toCreateEntry(parsedLocalazyEntry, model, baseEntry);
|
|
108
124
|
if (locale) {
|
|
109
125
|
createEntry.locale = locale;
|
|
110
126
|
}
|
|
111
127
|
|
|
128
|
+
resetArrayKeysDeep(createEntry, repeatableComponentsKeystoFilter);
|
|
112
129
|
return createEntry;
|
|
113
130
|
};
|
|
114
131
|
|
|
@@ -8,14 +8,18 @@ const parsedLocalazyEntryToUpdateEntry = (
|
|
|
8
8
|
allModels,
|
|
9
9
|
localazyEntry,
|
|
10
10
|
currentEntry,
|
|
11
|
+
baseEntry,
|
|
11
12
|
uid
|
|
12
13
|
) => {
|
|
13
14
|
const createEntry = parsedLocalazyEntryToCreateEntry(
|
|
14
15
|
allModels,
|
|
15
16
|
localazyEntry,
|
|
17
|
+
baseEntry,
|
|
16
18
|
uid
|
|
17
19
|
);
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
let updateEntry = {};
|
|
22
|
+
merge(updateEntry, currentEntry, createEntry);
|
|
19
23
|
updateEntry = omitDeep(updateEntry, [
|
|
20
24
|
"__component",
|
|
21
25
|
"locale",
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
const pickEntries = (flatten, pickPaths) => {
|
|
4
4
|
const pickedEntries = {};
|
|
5
5
|
Object.keys(flatten).forEach((key) => {
|
|
6
|
-
const filteredKey = key.replace(/\
|
|
6
|
+
const filteredKey = key.replace(/\[\d+\]/g, "");
|
|
7
|
+
// const filteredKey = key.replace(/\d|[[\]]+/g, "");
|
|
7
8
|
if (pickPaths.includes(filteredKey)) {
|
|
8
9
|
pickedEntries[key] = flatten[key];
|
|
9
10
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const set = require("lodash/set");
|
|
2
|
+
const get = require("lodash/get");
|
|
3
|
+
|
|
4
|
+
const resetArrayKeysDeep = (object, keysToFilter) => {
|
|
5
|
+
// sort keys from deep to shallow (so we won't rewrite indices)
|
|
6
|
+
const sortedKeysToFilter = keysToFilter.sort((a, b) => {
|
|
7
|
+
const aLvl = a.match(/\./g)?.length || 0;
|
|
8
|
+
const bLvl = b.match(/\./g)?.length || 0;
|
|
9
|
+
|
|
10
|
+
return bLvl - aLvl;
|
|
11
|
+
})
|
|
12
|
+
for (const key of sortedKeysToFilter) {
|
|
13
|
+
const part = get(object, key);
|
|
14
|
+
const filteredPart = part.filter((item) => item !== undefined);
|
|
15
|
+
set(object, key, filteredPart);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = resetArrayKeysDeep;
|