@localazy/strapi-plugin 0.1.10 → 0.1.11-rc.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.
Files changed (42) hide show
  1. package/.eslintrc +6 -2
  2. package/admin/src/modules/@common/models/supported-content-type-fields.js +8 -0
  3. package/admin/src/modules/plugin-settings/components/Tree/index.js +2 -0
  4. package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +4 -4
  5. package/admin/src/modules/plugin-settings/utils/get-models-tree.js +3 -1
  6. package/package.json +1 -1
  7. package/server/bootstrap.js +15 -1
  8. package/server/controllers/localazy-transfer-controller.js +41 -46
  9. package/server/functions/should-set-downloaded-property.js +16 -0
  10. package/server/models/supported-content-type-fields.js +8 -0
  11. package/server/services/index.js +2 -0
  12. package/server/services/strapi-i18n-service.js +4 -3
  13. package/server/services/strapi-localazy-i18n-service.js +104 -0
  14. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
  15. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
  16. package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
  17. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
  18. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
  19. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
  20. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
  21. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
  22. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
  23. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
  24. package/server/tests/fixtures/{all-models-with-multimedia.js → strapi-plugin-all-models.js} +717 -540
  25. package/server/utils/__tests__/get-models-tree.test.js +1 -1
  26. package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +90 -93
  27. package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +417 -101
  28. package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +852 -0
  29. package/server/utils/get-full-populate-object.js +56 -0
  30. package/server/utils/get-models-tree.js +3 -1
  31. package/server/utils/model-utils.js +38 -0
  32. package/server/utils/parsed-localazy-entry-to-create-entry.js +1 -18
  33. package/server/utils/parsed-localazy-entry-to-update-entry.js +38 -3
  34. package/server/utils/populate-create-update-entry-with-base-entry.js +222 -0
  35. package/server/utils/transfer-setup-utils.js +14 -0
  36. package/server/tests/fixtures/restaurant-model.js +0 -230
  37. package/server/tests/fixtures/restaurants-entries.js +0 -152
  38. package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
  39. package/server/tests/fixtures/stringified-book-cs.js +0 -3
  40. package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
  41. package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
  42. package/server/tests/fixtures/stringified-restaurant-de.js +0 -5
@@ -70,7 +70,7 @@ it("should return a tree all all models", () => {
70
70
  up_users: {
71
71
  __model__: true,
72
72
  username: false,
73
- email: null,
73
+ email: false,
74
74
  provider: false,
75
75
  password: null,
76
76
  resetPasswordToken: false,
@@ -1,121 +1,118 @@
1
1
  "use strict";
2
2
 
3
3
  const parsedLocalazyEntryToCreateEntry = require("../parsed-localazy-entry-to-create-entry");
4
- const allModels = require("../../tests/fixtures/all-models");
5
- const stringifiedRestaurantCs = require("../../tests/fixtures/stringified-restaurant-cs");
6
- const stringifiedBookCs = require("../../tests/fixtures/stringified-book-cs");
4
+ const allModels = require("../../tests/fixtures/strapi-plugin-all-models");
5
+ const simpleMenuWithMediaModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu");
6
+ const cookbookModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook");
7
7
 
8
8
  describe("parsed-localazy-entry-to-create-entry.js", () => {
9
- it("should return transformed restaurant entry to strapi create entry structure", () => {
10
- // SETUP
11
- const uid = "api::restaurant.restaurant";
12
- const entry = JSON.parse(stringifiedRestaurantCs);
13
-
14
- const locale = "cs";
15
-
9
+ it("should return transformed 'restaurant-simple-menu' entry to strapi create entry structure", () => {
16
10
  // EXECUTE
17
11
  const result = parsedLocalazyEntryToCreateEntry(
18
- 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\"}]"),
19
- 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ý\"}]}"),
20
- 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-30T20:49:14.959Z\",\"publishedAt\":null,\"locale\":\"cs\"}]}"),
21
- "api::loc-5087.loc-5087",
22
- ""
12
+ allModels,
13
+ simpleMenuWithMediaModel.parsedLocalazyEntry,
14
+ simpleMenuWithMediaModel.baseEntry,
15
+ simpleMenuWithMediaModel.uid,
16
+ simpleMenuWithMediaModel.locale
23
17
  );
24
18
 
25
19
  // VERIFY
26
20
  const expected = {
27
- ingredients: [
28
- {
29
- name: "dvanáctý",
30
- __component: "food.ingredients",
31
- },
32
- {
33
- name: "první",
34
- __component: "food.ingredients",
35
- },
36
- {
37
- name: "druhý",
38
- __component: "food.ingredients",
39
- },
40
- {
41
- name: "jedenáctý",
42
- __component: "food.ingredients",
43
- },
44
- {
45
- name: "třetí",
46
- __component: "food.ingredients",
47
- },
48
- {
49
- name: "čtvrtý",
50
- __component: "food.ingredients",
51
- },
52
- {
53
- name: "pátý",
54
- __component: "food.ingredients",
55
- },
56
- {
57
- name: "šestý",
58
- __component: "food.ingredients",
59
- },
60
- {
61
- name: "čtrnáctý",
62
- __component: "food.ingredients",
63
- },
64
- {
65
- name: "sedmý",
66
- __component: "food.ingredients",
67
- },
68
- {
69
- name: "osmý",
70
- __component: "food.ingredients",
71
- },
72
- {
73
- name: "devátý",
74
- __component: "food.ingredients",
75
- },
76
- {
77
- name: "desátý",
78
- __component: "food.ingredients",
79
- },
80
- {
81
- name: "třináctý",
82
- __component: "food.ingredients",
83
- },
84
- ],
85
- }
21
+ name: "hlad, okno",
22
+ description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
23
+ locale: "cs",
24
+ };
25
+
86
26
  expect(result).toEqual(expected);
87
27
  });
88
- it("should return transformed book entry to strapi create entry structure", () => {
28
+ it("should return transformed 'cookbook' entry to strapi create entry structure", () => {
89
29
  // SETUP
90
- const uid = "api::book.book";
91
- const entry = JSON.parse(stringifiedBookCs);
92
30
 
93
- const locale = "cs";
94
31
 
95
32
  // EXECUTE
96
33
  const result = parsedLocalazyEntryToCreateEntry(
97
34
  allModels,
98
- entry,
99
- entry,
100
- uid,
101
- locale
35
+ cookbookModel.parsedLocalazyEntry,
36
+ cookbookModel.baseEntry,
37
+ cookbookModel.uid,
38
+ cookbookModel.locale
102
39
  );
103
40
 
104
41
  // VERIFY
105
42
  const expected = {
106
- locale: "cs",
107
- Title: "Moje první dětská kniha",
108
- additional_info: {
109
- __component: "food.pub-component-1",
110
- rich_description:
111
- "# H1\n## H2\n#### H4\n\n** Jedna** _dva_ <u>tři</u>... a možná ještě více pohádek...",
112
- history: "Není tu žádný...",
113
- excerpt: "Krátký výňatek",
114
- test_variants: {
115
- __component: "food.ingredient-variants",
116
- name: "toto je finální verze",
43
+ title: "Pro každý den v roce",
44
+ recipes: [
45
+ {
46
+ name: "Bramborový salát",
47
+ __component: "food.cookbook-item",
48
+ recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
49
+ author_name: "Mr. Bramborová hlava",
50
+ gallery: [
51
+ {
52
+ image_title: "Syrové brambory",
53
+ __component: "food.gallery-item",
54
+ image_description: "Čerstvý!",
55
+ },
56
+ {
57
+ image_title: "Salát",
58
+ __component: "food.gallery-item",
59
+ image_description: "Mňam!",
60
+ },
61
+ ],
62
+ ingredients: [
63
+ {
64
+ name: "Brambory",
65
+ __component: "food.recipe-ingredient",
66
+ unit: "kg",
67
+ },
68
+ {
69
+ name: "Hrášek",
70
+ __component: "food.recipe-ingredient",
71
+ unit: "plechovka",
72
+ },
73
+ {
74
+ name: "Kukuřice",
75
+ __component: "food.recipe-ingredient",
76
+ unit: "plechovka",
77
+ },
78
+ {
79
+ name: "Mayo",
80
+ __component: "food.recipe-ingredient",
81
+ unit: "lžíce",
82
+ },
83
+ {
84
+ name: "Sýr",
85
+ __component: "food.recipe-ingredient",
86
+ unit: "blok",
87
+ },
88
+ {
89
+ name: "Apple",
90
+ __component: "food.recipe-ingredient",
91
+ unit: "ks",
92
+ },
93
+ ],
117
94
  },
95
+ ],
96
+ gallery: {
97
+ __component: "food.gallery",
98
+ annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
99
+ main_image: {
100
+ __component: "food.gallery-item",
101
+ image_title: "Kuchařka",
102
+ image_description: "Brožura II",
103
+ },
104
+ gallery: [
105
+ {
106
+ image_description: "Brožura a listy a vidlice.",
107
+ __component: "food.gallery-item",
108
+ },
109
+ {
110
+ image_title: "Koření",
111
+ __component: "food.gallery-item",
112
+ },
113
+ ],
118
114
  },
115
+ locale: "cs",
119
116
  };
120
117
 
121
118
  expect(result).toEqual(expected);