@localazy/strapi-plugin 0.1.10 → 0.1.11-rc.1

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 (59) 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/ContentTransferSetup/index.js +5 -0
  4. package/admin/src/modules/plugin-settings/components/Tree/index.js +22 -5
  5. package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +1 -1
  6. package/admin/src/modules/plugin-settings/functions/has-model-changed.js +1 -1
  7. package/admin/src/modules/plugin-settings/locale/en.js +1 -1
  8. package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +1 -7
  9. package/admin/src/modules/plugin-settings/utils/get-models-tree.js +21 -3
  10. package/package.json +4 -4
  11. package/server/bootstrap.js +15 -1
  12. package/server/controllers/localazy-transfer-controller.js +67 -52
  13. package/server/functions/should-set-downloaded-property.js +61 -0
  14. package/server/models/supported-content-type-fields.js +8 -0
  15. package/server/services/index.js +2 -0
  16. package/server/services/strapi-i18n-service.js +5 -4
  17. package/server/services/strapi-localazy-i18n-service.js +104 -0
  18. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-cookbook.js +5761 -0
  19. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz.js +392 -0
  20. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-restaurant-simple-menu.js +536 -0
  21. package/server/tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz.js +4675 -0
  22. package/server/tests/fixtures/parsed-localazy-entry-to-update-entry.js +35157 -0
  23. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook-empty-recipes.js +202 -0
  24. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-cookbook.js +2700 -0
  25. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-lesson-dz.js +309 -0
  26. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-simple.js +47 -0
  27. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-flat-with-media.js +169 -0
  28. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-empty.js +3003 -0
  29. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-restaurant-simple-menu-with-media.js +2057 -0
  30. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json-dz.js +884 -0
  31. package/server/tests/fixtures/populate-create-update-entry-with-base-entry-sample-json.js +46 -0
  32. package/server/tests/fixtures/strapi-plugin-all-models.js +2048 -0
  33. package/server/utils/__tests__/get-models-tree.test.js +1 -1
  34. package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +237 -91
  35. package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +417 -101
  36. package/server/utils/__tests__/pick-entries.test.js +936 -56
  37. package/server/utils/__tests__/populate-create-update-entry-with-base-entry.test.js +1139 -0
  38. package/server/utils/build-populate.js +5 -0
  39. package/server/utils/get-full-populate-object.js +56 -0
  40. package/server/utils/get-models-tree.js +3 -1
  41. package/server/utils/model-utils.js +43 -0
  42. package/server/utils/omit-deep.js +7 -0
  43. package/server/utils/parsed-localazy-entry-to-create-entry.js +58 -21
  44. package/server/utils/parsed-localazy-entry-to-update-entry.js +44 -4
  45. package/server/utils/pick-deep.js +22 -0
  46. package/server/utils/pick-entries.js +90 -5
  47. package/server/utils/populate-create-update-entry-with-base-entry.js +270 -0
  48. package/server/utils/transfer-setup-utils.js +14 -0
  49. package/server/tests/fixtures/all-models-with-multimedia.js +0 -1064
  50. package/server/tests/fixtures/collection-flattened.js +0 -76
  51. package/server/tests/fixtures/restaurant-flattened.js +0 -46
  52. package/server/tests/fixtures/restaurant-model.js +0 -230
  53. package/server/tests/fixtures/restaurants-entries.js +0 -152
  54. package/server/tests/fixtures/restaurants-pick-paths.js +0 -15
  55. package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +0 -31
  56. package/server/tests/fixtures/stringified-book-cs.js +0 -3
  57. package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +0 -3
  58. package/server/tests/fixtures/stringified-restaurant-cs.js +0 -3
  59. 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,267 @@
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
+ const lessonDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-lesson-dz");
8
+ const sampleJSONDZModel = require("../../tests/fixtures/parsed-localazy-entry-to-create-entry-sample-json-dz");
7
9
 
8
10
  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);
11
+ it("should return transformed 'restaurant-simple-menu' entry to strapi create entry structure", () => {
12
+ // EXECUTE
13
+ const result = parsedLocalazyEntryToCreateEntry(
14
+ allModels,
15
+ simpleMenuWithMediaModel.parsedLocalazyEntry,
16
+ simpleMenuWithMediaModel.baseEntry,
17
+ simpleMenuWithMediaModel.uid,
18
+ simpleMenuWithMediaModel.locale
19
+ );
13
20
 
14
- const locale = "cs";
21
+ // VERIFY
22
+ const expected = {
23
+ createEntry: {
24
+ name: "hlad, okno",
25
+ description: "Orientální pouliční jídlo v ústech rychlé a snadné!",
26
+ locale: "cs",
27
+ },
28
+ dynamicZoneComponentKeys: []
29
+ };
15
30
 
31
+ expect(result).toEqual(expected);
32
+ });
33
+ it("should return transformed 'cookbook' entry to strapi create entry structure", () => {
16
34
  // EXECUTE
17
35
  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
- ""
36
+ allModels,
37
+ cookbookModel.parsedLocalazyEntry,
38
+ cookbookModel.baseEntry,
39
+ cookbookModel.uid,
40
+ cookbookModel.locale
23
41
  );
24
42
 
25
43
  // VERIFY
26
44
  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",
45
+ createEntry: {
46
+ title: "Pro každý den v roce",
47
+ recipes: [
48
+ {
49
+ name: "Bramborový salát",
50
+ __component: "food.cookbook-item",
51
+ recipe: "Oloupejte brambory, smíchejte je se všemi ingrediencemi a máte hotovo. Bon apetit!",
52
+ author_name: "Mr. Bramborová hlava",
53
+ gallery: [
54
+ {
55
+ image_title: "Syrové brambory",
56
+ __component: "food.gallery-item",
57
+ image_description: "Čerstvý!",
58
+ },
59
+ {
60
+ image_title: "Salát",
61
+ __component: "food.gallery-item",
62
+ image_description: "Mňam!",
63
+ },
64
+ ],
65
+ ingredients: [
66
+ {
67
+ name: "Brambory",
68
+ __component: "food.recipe-ingredient",
69
+ unit: "kg",
70
+ },
71
+ {
72
+ name: "Hrášek",
73
+ __component: "food.recipe-ingredient",
74
+ unit: "plechovka",
75
+ },
76
+ {
77
+ name: "Kukuřice",
78
+ __component: "food.recipe-ingredient",
79
+ unit: "plechovka",
80
+ },
81
+ {
82
+ name: "Mayo",
83
+ __component: "food.recipe-ingredient",
84
+ unit: "lžíce",
85
+ },
86
+ {
87
+ name: "Sýr",
88
+ __component: "food.recipe-ingredient",
89
+ unit: "blok",
90
+ },
91
+ {
92
+ name: "Apple",
93
+ __component: "food.recipe-ingredient",
94
+ unit: "ks",
95
+ },
96
+ ],
97
+ },
98
+ ],
99
+ gallery: {
100
+ __component: "food.gallery",
101
+ annotation: "Podívejte se na naše chutné jídlo, pak čtěte dál a ponořte se do kulinářského nebe!",
102
+ main_image: {
103
+ __component: "food.gallery-item",
104
+ image_title: "Kuchařka",
105
+ image_description: "Brožura II",
106
+ },
107
+ gallery: [
108
+ {
109
+ image_description: "Brožura a listy a vidlice.",
110
+ __component: "food.gallery-item",
111
+ },
112
+ {
113
+ image_title: "Koření",
114
+ __component: "food.gallery-item",
115
+ },
116
+ ],
79
117
  },
118
+ locale: "cs",
119
+ },
120
+ dynamicZoneComponentKeys: [],
121
+ };
122
+
123
+ expect(result).toEqual(expected);
124
+ });
125
+
126
+ it("should return transformed 'lesson' entry including Dynamic Zones to strapi create entry structure", () => {
127
+ // EXECUTE
128
+ const result = parsedLocalazyEntryToCreateEntry(
129
+ allModels,
130
+ lessonDZModel.parsedLocalazyEntry,
131
+ lessonDZModel.baseEntry,
132
+ lessonDZModel.uid,
133
+ lessonDZModel.locale
134
+ );
135
+
136
+ // VERIFY
137
+ const expected = {
138
+ createEntry: {
139
+ title: "Test: Sčítání",
140
+ description: "Otestujte si své dovednosti, které jsme se naučili v předchozí lekci.",
141
+ lesson_type: [
142
+ {
143
+ title: "Vyberte správnou odpověď",
144
+ __component: "lesson.quiz",
145
+ questions: [
146
+ {
147
+ question: "1 + 1 = ",
148
+ __component: "lesson.survey-question",
149
+ },
150
+ {
151
+ question: "5 + 15 = ",
152
+ __component: "lesson.survey-question",
153
+ },
154
+ {
155
+ question: "Kolik pohárů je na fotce?",
156
+ __component: "lesson.survey-question",
157
+ },
158
+ ],
159
+ answers: [
160
+ {
161
+ correct_answer: "2",
162
+ __component: "lesson.answers",
163
+ },
164
+ {
165
+ correct_answer: "20",
166
+ __component: "lesson.answers",
167
+ },
168
+ {
169
+ correct_answer: "15",
170
+ __component: "lesson.answers",
171
+ },
172
+ ],
173
+ },
174
+ ],
175
+ locale: "cs",
176
+ },
177
+ dynamicZoneComponentKeys: [
80
178
  {
81
- name: "třináctý",
82
- __component: "food.ingredients",
179
+ key: "lesson_type.0.__component",
180
+ component: "lesson.quiz",
83
181
  },
84
- ],
85
- }
182
+ ]
183
+ };
184
+
86
185
  expect(result).toEqual(expected);
87
186
  });
88
- it("should return transformed book entry to strapi create entry structure", () => {
89
- // SETUP
90
- const uid = "api::book.book";
91
- const entry = JSON.parse(stringifiedBookCs);
92
-
93
- const locale = "cs";
94
187
 
188
+ it("should return transformed 'sample-json' entry including Dynamic Zones to strapi create entry structure", () => {
95
189
  // EXECUTE
96
190
  const result = parsedLocalazyEntryToCreateEntry(
97
191
  allModels,
98
- entry,
99
- entry,
100
- uid,
101
- locale
192
+ sampleJSONDZModel.parsedLocalazyEntry,
193
+ sampleJSONDZModel.baseEntry,
194
+ sampleJSONDZModel.uid,
102
195
  );
103
196
 
104
197
  // VERIFY
105
198
  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",
117
- },
199
+ createEntry: {
200
+ purpose: "Bar",
201
+ repeatable_component_property: [
202
+ {
203
+ name: "Položka 1",
204
+ __component: "restaurant.menu-item",
205
+ description: "Nějaký popis",
206
+ },
207
+ {
208
+ name: "Položka 2",
209
+ __component: "restaurant.menu-item",
210
+ description: "Nějaký další popis",
211
+ },
212
+ ],
213
+ dynamic_property: [
214
+ {
215
+ image_title: "Nějaký název obrázku",
216
+ __component: "food.gallery-item",
217
+ image_description: "Nějaký popis obrázku",
218
+ },
219
+ {
220
+ name: "Přísada I",
221
+ __component: "food.recipe-ingredient",
222
+ },
223
+ {
224
+ name: "První položka CB",
225
+ __component: "food.cookbook-item",
226
+ author_name: "Já",
227
+ ingredients: [
228
+ {
229
+ name: "První Ingr DZ",
230
+ __component: "food.recipe-ingredient",
231
+ },
232
+ ],
233
+ gallery: [
234
+ {
235
+ image_title: "Obrázek G Jedna",
236
+ __component: "food.gallery-item",
237
+ image_description: "Obrázek G Popis Jedna",
238
+ },
239
+ ],
240
+ },
241
+ {
242
+ name: "Druhá přísada",
243
+ __component: "food.recipe-ingredient",
244
+ },
245
+ ],
118
246
  },
247
+ dynamicZoneComponentKeys: [
248
+ {
249
+ key: "dynamic_property.2.__component",
250
+ component: "food.cookbook-item",
251
+ },
252
+ {
253
+ key: "dynamic_property.0.__component",
254
+ component: "food.gallery-item",
255
+ },
256
+ {
257
+ key: "dynamic_property.1.__component",
258
+ component: "food.recipe-ingredient",
259
+ },
260
+ {
261
+ key: "dynamic_property.3.__component",
262
+ component: "food.recipe-ingredient",
263
+ },
264
+ ]
119
265
  };
120
266
 
121
267
  expect(result).toEqual(expected);